From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:60992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5nrL-0000vi-2j for guix-patches@gnu.org; Mon, 18 Mar 2019 04:43:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h5nrJ-0006V2-Vm for guix-patches@gnu.org; Mon, 18 Mar 2019 04:43:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34490) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h5nrJ-0006Uu-Me for guix-patches@gnu.org; Mon, 18 Mar 2019 04:43:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h5nrJ-0004Fa-K4 for guix-patches@gnu.org; Mon, 18 Mar 2019 04:43:01 -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> Date: Mon, 18 Mar 2019 09:42:36 +0100 In-Reply-To: <20190316121709.27c979dc@scratchpost.org> (Danny Milosavljevic's message of "Sat, 16 Mar 2019 12:17:09 +0100") Message-ID: <87wokwshdv.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 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, i= t=E2=80=99s undocumented. So >> I=E2=80=99d suggest using =E2=80=98open-file=E2=80=99 instead to be on t= he 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 device > is fine). It=E2=80=99d be good to double-check. :-) >> > +(let ((loop-device (allocate-new-loop-device (open-io-file "/dev/loop= -control")))) >> > + (set-loop-device-backing-file loop-device (open-input-file "tests/s= yscalls.scm")) >> > + (set-loop-device-status loop-device (get-loop-device-status loop-de= vice)))=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. Oth= erwise it=E2=80=99s code that=E2=80=99s evaluated as the top level and that=E2=80=99s not liste= d in the test log. So in this case, to check for a 'system-error exception, you could do, say: (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.