From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:59175) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h57KF-0003U9-83 for guix-patches@gnu.org; Sat, 16 Mar 2019 07:18:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h57KE-00077M-58 for guix-patches@gnu.org; Sat, 16 Mar 2019 07:18:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:60531) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h57KD-00077C-S7 for guix-patches@gnu.org; Sat, 16 Mar 2019 07:18:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h57KD-00010c-LC for guix-patches@gnu.org; Sat, 16 Mar 2019 07:18:01 -0400 Subject: [bug#34863] [WIP] syscalls: Add loop device interface. Resent-Message-ID: Date: Sat, 16 Mar 2019 12:17:09 +0100 From: Danny Milosavljevic Message-ID: <20190316121709.27c979dc@scratchpost.org> In-Reply-To: <87k1gzyuwy.fsf@gnu.org> References: <20190314220823.30769-1-dannym@scratchpost.org> <87k1gzyuwy.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/ThL=zvr0b_QYsTuN1b1m8DC"; protocol="application/pgp-signature" 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: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 34863@debbugs.gnu.org --Sig_/ThL=zvr0b_QYsTuN1b1m8DC Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ludo :) 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-de= vel list. This would make it possible to loop-mount stuff at boot. > Like I wrote, a record may be more appropriate than an alist here. > Also, no need to repeat =E2=80=98lo-=E2=80=99 in the parameter names. Sure. > > +(define (allocate-new-loop-device control-file) > > + "Allocates a new loop device and returns an FD for it. > > +CONTROL-FILE should be an open file \"/dev/loop-control\". =20 >=20 > Nitpick: s/an FD/a file descriptor/ > s/an open file/an open port for/ >=20 > > + (open-io-file (string-append "/dev/loop" (number->string ret))))= =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 th= e safe side. Do you mean=20 open-file ... "r+" ? >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). > > +(let ((loop-device (allocate-new-loop-device (open-io-file "/dev/loop-= control")))) > > + (set-loop-device-backing-file loop-device (open-input-file "tests/sy= scalls.scm")) > > + (set-loop-device-status loop-device (get-loop-device-status loop-dev= ice))) =20 >=20 > You=E2=80=99re missing a =E2=80=98test-assert=E2=80=99 or similar. =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. >Also, isn=E2=80=99t =E2=80=98loop-device=E2=80=99 a > number? Then the =E2=80=98set-loop-device-*=E2=80=99 calls fail with wro= ng-type-arg, > no? It's actually a port now and the comment in allocate-new-loop-device is outdated. --Sig_/ThL=zvr0b_QYsTuN1b1m8DC Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlyM2zUACgkQ5xo1VCww uqW1wAgAgdsYDShzoJ7nHwh/SnYeUgLlgC3/Ncy1I6tlf02HnL52yA/QPwDxGBzX tLyEpXlWB98s/NaD0xeCa+7skSXlLAZ5T3QWlQH7QA4vqVsDGUO2gh+pJYCoNasp CHqbSqDlq6dNFYAz1n4NFd3ANyhbUD3wSbO9U6Jk/bWcjY5l7Tn6vqS5q8XV/c+d /qXTMD+jqHPMU4hHEdGPW+mQB2WneGtmcWetn82/J82RHJpRP2ETQZi7monAVPVx ZciT6wWv6k0dEltE2Tvu8tfy8tFhNnpWmfJjfHBqyzAm5/tUKiKJiQ3cpAB17JfU ZPkfbwnWsJ3yei2whhCvrOdxeeh7pg== =VhcT -----END PGP SIGNATURE----- --Sig_/ThL=zvr0b_QYsTuN1b1m8DC--