From debbugs-submit-bounces@debbugs.gnu.org Mon Mar 18 04:42:46 2019 Received: (at 34863) by debbugs.gnu.org; 18 Mar 2019 08:42:46 +0000 Received: from localhost ([127.0.0.1]:48034 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h5nr4-0004F2-3Y for submit@debbugs.gnu.org; Mon, 18 Mar 2019 04:42:46 -0400 Received: from eggs.gnu.org ([209.51.188.92]:46545) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h5nr2-0004Eq-5I for 34863@debbugs.gnu.org; Mon, 18 Mar 2019 04:42:44 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:33022) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h5nqw-0006LE-HO; Mon, 18 Mar 2019 04:42:38 -0400 Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=53232 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1h5nqv-0002WP-TV; Mon, 18 Mar 2019 04:42:38 -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> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 28 =?utf-8?Q?Vent=C3=B4se?= an 227 de la =?utf-8?Q?R?= =?utf-8?Q?=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu 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> 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: 0.0 (/) 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: -1.0 (-) 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.