From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:51633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hEEex-00061Z-6a for guix-patches@gnu.org; Wed, 10 Apr 2019 10:57:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hEEeu-00016h-4T for guix-patches@gnu.org; Wed, 10 Apr 2019 10:57:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39883) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hEEet-00016Y-U3 for guix-patches@gnu.org; Wed, 10 Apr 2019 10:57:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hEEer-0000B9-KO for guix-patches@gnu.org; Wed, 10 Apr 2019 10:57:03 -0400 Subject: [bug#34863] [WIP] syscalls: Add loop device interface. Resent-Message-ID: From: Ludovic =?UTF-8?Q?Court=C3=A8s?= 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Danny Milosavljevic Cc: 34863@debbugs.gnu.org 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.