From debbugs-submit-bounces@debbugs.gnu.org Wed Apr 10 10:56:15 2019 Received: (at 34863) by debbugs.gnu.org; 10 Apr 2019 14:56:15 +0000 Received: from localhost ([127.0.0.1]:53427 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hEEe7-00009r-6K for submit@debbugs.gnu.org; Wed, 10 Apr 2019 10:56:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36949) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hEEe4-00009c-QH for 34863@debbugs.gnu.org; Wed, 10 Apr 2019 10:56:14 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:35551) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEEdz-0000ZZ-5A; Wed, 10 Apr 2019 10:56:07 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=44630 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hEEdx-0005Lj-2u; Wed, 10 Apr 2019 10:56:05 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Danny Milosavljevic Subject: Re: [bug#34863] [WIP] syscalls: Add loop device interface. References: <20190314220823.30769-1-dannym@scratchpost.org> <87k1gzyuwy.fsf@gnu.org> <20190316121709.27c979dc@scratchpost.org> <87wokwshdv.fsf@gnu.org> Date: Wed, 10 Apr 2019 16:56:03 +0200 In-Reply-To: <87wokwshdv.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Mon, 18 Mar 2019 09:42:36 +0100") Message-ID: <87mukxdi4c.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 34863 Cc: 34863@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Ping! :-) Ludovic Court=C3=A8s skribis: > Hello, > > Danny Milosavljevic skribis: > >> On Sat, 16 Mar 2019 11:29:17 +0100 >> Ludovic Court=C3=A8s wrote: >> >>> What will be the use for this? I prefer to make sure we only add code >>> that is actually going to be used. :-) >> >> See "boot multiple Gnu/Linux Distributions from one USB key" on the guix= -devel >> list. This would make it possible to loop-mount stuff at boot. > > Oh OK (too much mail!). > >>> > + (open-io-file (string-append "/dev/loop" (number->string ret))= ))=20=20 >>>=20 >>> I didn=E2=80=99t know about =E2=80=98open-io-file=E2=80=99 and indeed, = it=E2=80=99s undocumented. So >>> I=E2=80=99d suggest using =E2=80=98open-file=E2=80=99 instead to be on = the safe side. >> >> Do you mean=20 >> >> open-file ... "r+" >> >> ? > > Exactly. > >>>Note that BACKING-FILE, the port, can be closed when it=E2=80=99s GC=E2= =80=99d, which as >>>a side effect would close its associated file descriptor. Is this OK or >>>does the FD have to remain open for the lifetime of the loopback device? >> >> I don't know, but guess it's okay for it to be closed again (the >> "losetup" process doesn't keep running for long either and the loop devi= ce >> is fine). > > It=E2=80=99d be good to double-check. :-) > >>> > +(let ((loop-device (allocate-new-loop-device (open-io-file "/dev/loo= p-control")))) >>> > + (set-loop-device-backing-file loop-device (open-input-file "tests/= syscalls.scm")) >>> > + (set-loop-device-status loop-device (get-loop-device-status loop-d= evice)))=20=20 >>>=20 >>> You=E2=80=99re missing a =E2=80=98test-assert=E2=80=99 or similar.=20=20 >> >> What would I be asserting? I found no function to test whether an >> exception was raised or not (or to just assert that no exception was >> raised). So I resorted to that. > > Tests always need to be enclosed in a =E2=80=98test-XYZ=E2=80=99 form. O= therwise it=E2=80=99s > code that=E2=80=99s evaluated as the top level and that=E2=80=99s not lis= ted in the test > log. > > So in this case, to check for a 'system-error exception, you could do, sa= y: > > (test-equal "foo" > ENOENT > (catch 'system-error > (lambda () =E2=80=A6 #f) > (lambda args > (system-error-errno args)))) > > There are examples of that in =E2=80=98tests/syscalls.scm=E2=80=99. > > HTH! > > Ludo=E2=80=99.