X-Loop: help-debbugs@HIDDEN Subject: [bug#34863] [WIP] syscalls: Add loop device interface. Resent-From: Danny Milosavljevic <dannym@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Thu, 14 Mar 2019 22:09:01 +0000 Resent-Message-ID: <handler.34863.B.155260131913202 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: report 34863 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 34863 <at> debbugs.gnu.org Cc: Danny Milosavljevic <dannym@HIDDEN> X-Debbugs-Original-To: guix-patches@HIDDEN Received: via spool by submit <at> debbugs.gnu.org id=B.155260131913202 (code B ref -1); Thu, 14 Mar 2019 22:09:01 +0000 Received: (at submit) by debbugs.gnu.org; 14 Mar 2019 22:08:39 +0000 Received: from localhost ([127.0.0.1]:44151 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1h4YWl-0003Qr-Dc for submit <at> debbugs.gnu.org; Thu, 14 Mar 2019 18:08:39 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45246) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <dannym@HIDDEN>) id 1h4YWj-0003Qe-JZ for submit <at> debbugs.gnu.org; Thu, 14 Mar 2019 18:08:38 -0400 Received: from lists.gnu.org ([209.51.188.17]:53751) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <dannym@HIDDEN>) id 1h4YWe-00049t-FE for submit <at> debbugs.gnu.org; Thu, 14 Mar 2019 18:08:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <dannym@HIDDEN>) id 1h4YWd-000177-1H for guix-patches@HIDDEN; Thu, 14 Mar 2019 18:08:32 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_20,RCVD_IN_DNSWL_LOW autolearn=disabled version=3.3.2 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <dannym@HIDDEN>) id 1h4YWb-00044T-Pr for guix-patches@HIDDEN; Thu, 14 Mar 2019 18:08:30 -0400 Received: from dd26836.kasserver.com ([85.13.145.193]:52142) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from <dannym@HIDDEN>) id 1h4YWb-00041o-E7 for guix-patches@HIDDEN; Thu, 14 Mar 2019 18:08:29 -0400 Received: from dayas.3.home (178.112.254.29.wireless.dyn.drei.com [178.112.254.29]) by dd26836.kasserver.com (Postfix) with ESMTPSA id 005F633606A9; Thu, 14 Mar 2019 23:08:26 +0100 (CET) From: Danny Milosavljevic <dannym@HIDDEN> Date: Thu, 14 Mar 2019 23:08:23 +0100 Message-Id: <20190314220823.30769-1-dannym@HIDDEN> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Tags: patch Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 85.13.145.193 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) * guix/build/syscalls.scm (%ioctl-unsigned-long): New procedure. (LOOP_CTL_GET_FREE): New macro. (LOOP_SET_FD): New macro. (LOOP_SET_STATUS64): New macro. (LOOP_GET_STATUS64): New macro. (lo-flags): New bits. (lo-flags->symbols): New procedure. (LO_NAME_SIZE): New variable. (LO_KEY_SIZE): New variable. (%struct-loop-info64): New C structure. (allocate-new-loop-device): New procedure. (set-loop-device-backing-file): New procedure. (get-loop-device-status): New procedure. * tests/syscalls.scm: Add test. --- guix/build/syscalls.scm | 130 +++++++++++++++++++++++++++++++++++++++- tests/syscalls.scm | 4 ++ 2 files changed, 133 insertions(+), 1 deletion(-) diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 66d63a2931..a828aa18e2 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -155,7 +155,12 @@ utmpx-address login-type utmpx-entries - (read-utmpx-from-port . read-utmpx))) + (read-utmpx-from-port . read-utmpx) + + allocate-new-loop-device + set-loop-device-backing-file + get-loop-device-status + set-loop-device-status)) =20 ;;; Commentary: ;;; @@ -1237,6 +1242,10 @@ bytevector BV at INDEX." ;; The most terrible interface, live from Scheme. (syscall->procedure int "ioctl" (list int unsigned-long '*))) =20 +(define %ioctl-unsigned-long + ;; The most terrible interface, live from Scheme. + (syscall->procedure int "ioctl" (list int unsigned-long unsigned-long)= )) + (define (bytes->string bytes) "Read BYTES, a list of bytes, and return the null-terminated string de= coded from there, or #f if that would be an empty string." @@ -1953,4 +1962,123 @@ entry." ((? bytevector? bv) (read-utmpx bv)))) =20 +;;; Loopback device setup. + +;;; /dev/loop-control + +(define-syntax LOOP_CTL_GET_FREE ;<uapi/linux/loop.h> + (identifier-syntax #x4C82)) + +;;; /dev/loopN + +(define-syntax LOOP_SET_FD ;<uapi/linux/loop.h> + (identifier-syntax #x4C00)) + +(define-syntax LOOP_SET_STATUS64 ;<uapi/linux/loop.h> + (identifier-syntax #x4C04)) + +(define-syntax LOOP_GET_STATUS64 ;<uapi/linux/loop.h> + (identifier-syntax #x4C05)) + +(define-bits lo-flags ;<uapi/linux/loop.h> + lo-flags->symbols + (define LO_FLAGS_READ_ONLY 1) + (define LO_FLAGS_AUTOCLEAR 4) + (define LO_FLAGS_PARTSCAN 8) + (define LO_FLAGS_DIRECT_IO 16)) + +(define LO_NAME_SIZE 64) +(define LO_KEY_SIZE 32) + +;; 'struct loop_info64' for GNU/Linux. ;<uapi/linux/loop.h> +(define-c-struct %struct-loop-info64 + sizeof-loop-info64 + (lambda (lo-device lo-inode lo-rdevice lo-offset lo-sizelimit lo-numbe= r + lo-encrypt-type lo-encrypt-key-size lo-flags lo-file-name + lo-crypt-name lo-encrypt-key lo-init) + `((lo-device . ,lo-device) + (lo-inode . ,lo-inode) + (lo-rdevice . ,lo-rdevice) + (lo-offset . ,lo-offset) + (lo-sizelimit . ,lo-sizelimit) + (lo-number . ,lo-number) + (lo-encrypt-type . ,lo-encrypt-type) + (lo-encrypt-key-size . ,lo-encrypt-key-size) + (lo-flags . ,(lo-flags->symbols lo-flags)) + (lo-file-name . ,(bytes->string lo-file-name)) + (lo-crypt-name . ,(bytes->string lo-crypt-name)) + (lo-encrypt-key . ,(bytes->string lo-encrypt-key)) + (lo-init . ,lo-init))) + read-loop-info64 + write-loop-info64! + (lo-device uint64) ; ioctl r/o + (lo-inode uint64) ; ioctl r/o + (lo-rdevice uint64) ; ioctl r/o + (lo-offset uint64) + (lo-sizelimit uint64) ; Bytes; 0 =3D=3D max available. + (lo-number uint32) ; ioctl r/o + (lo-encrypt-type uint32) + (lo-encrypt-key-size uint32) ; ioctl w/o + (lo-flags uint32) + (lo-file-name (array uint8 LO_NAME_SIZE)) + (lo-crypt-name (array uint8 LO_NAME_SIZE)) + (lo-encrypt-key (array uint8 LO_KEY_SIZE)) + (lo-init (array uint64 2))) + +(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\". +The result is a number to be appended to the name \"/dev/loop\" in order= to +find the loop device." + (let-values (((ret err) + (%ioctl (fileno control-file) + LOOP_CTL_GET_FREE %null-pointer))) + (cond + ((>=3D ret 0) + (open-io-file (string-append "/dev/loop" (number->string ret)))) + (else + (throw 'system-error "ioctl" "~A" + (list (strerror err)) + (list err)))))) + +(define (set-loop-device-backing-file loop-file backing-file) + "Sets up the loop device LOOP-FILE for BACKING-FILE." + (let-values (((ret err) + (%ioctl-unsigned-long (fileno loop-file) LOOP_SET_FD + (fileno backing-file)))) + (cond + ((>=3D ret 0) + #t) + (else + (throw 'system-error "ioctl" "~A" + (list (strerror err)) + (list err)))))) + +(define (get-loop-device-status loop-file) + (let*-values (((buf) (make-bytevector sizeof-loop-info64)) + ((ret err) + (%ioctl (fileno loop-file) + LOOP_GET_STATUS64 (bytevector->pointer buf)))) + (cond + ((=3D ret 0) + (read-loop-info64 buf)) + (else + (throw 'system-error "ioctl" "~A" + (list (strerror err)) + (list err)))))) + +(define (set-loop-device-status loop-file status) + (let ((buf (make-bytevector sizeof-loop-info64))) + (apply write-loop-info64! buf status) ; TODO: Be more user-friendly. + (let-values (((ret err) (%ioctl (fileno loop-file) + LOOP_SET_STATUS64 + (bytevector->pointer buf)))) + (cond + ((=3D ret 0) + #t) + (else + (throw 'system-error "ioctl" "~A" + (list (strerror err)) + (list err))))))) + ;;; syscalls.scm ends here diff --git a/tests/syscalls.scm b/tests/syscalls.scm index 3e267c9f01..57b63421b0 100644 --- a/tests/syscalls.scm +++ b/tests/syscalls.scm @@ -564,6 +564,10 @@ (let ((result (call-with-input-file "/var/run/utmpx" read-utmpx))) (or (utmpx? result) (eof-object? result)))) =20 +(let ((loop-device (allocate-new-loop-device (open-io-file "/dev/loop-co= ntrol")))) + (set-loop-device-backing-file loop-device (open-input-file "tests/sysc= alls.scm")) + (set-loop-device-status loop-device (get-loop-device-status loop-devic= e))) + (test-end) =20 (false-if-exception (delete-file temp-file))
Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) Content-Type: text/plain; charset=utf-8 X-Loop: help-debbugs@HIDDEN From: help-debbugs@HIDDEN (GNU bug Tracking System) To: Danny Milosavljevic <dannym@HIDDEN> Subject: bug#34863: Acknowledgement ([WIP] syscalls: Add loop device interface.) Message-ID: <handler.34863.B.155260131913202.ack <at> debbugs.gnu.org> References: <20190314220823.30769-1-dannym@HIDDEN> X-Gnu-PR-Message: ack 34863 X-Gnu-PR-Package: guix-patches Reply-To: 34863 <at> debbugs.gnu.org Date: Thu, 14 Mar 2019 22:09:02 +0000 Thank you for filing a new bug report with debbugs.gnu.org. This is an automatically generated reply to let you know your message has been received. Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course. Your message has been sent to the package maintainer(s): guix-patches@HIDDEN If you wish to submit further information on this problem, please send it to 34863 <at> debbugs.gnu.org. Please do not send mail to help-debbugs@HIDDEN unless you wish to report a problem with the Bug-tracking system. --=20 34863: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D34863 GNU Bug Tracking System Contact help-debbugs@HIDDEN with problems
X-Loop: help-debbugs@HIDDEN Subject: [bug#34863] [WIP] syscalls: Add loop device interface. Resent-From: Danny Milosavljevic <dannym@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Fri, 15 Mar 2019 16:14:02 +0000 Resent-Message-ID: <handler.34863.B34863.155266639528462 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 34863 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: 34863 <at> debbugs.gnu.org Received: via spool by 34863-submit <at> debbugs.gnu.org id=B34863.155266639528462 (code B ref 34863); Fri, 15 Mar 2019 16:14:02 +0000 Received: (at 34863) by debbugs.gnu.org; 15 Mar 2019 16:13:15 +0000 Received: from localhost ([127.0.0.1]:45421 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1h4pSN-0007Oz-HW for submit <at> debbugs.gnu.org; Fri, 15 Mar 2019 12:13:15 -0400 Received: from dd26836.kasserver.com ([85.13.145.193]:56468) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <dannym@HIDDEN>) id 1h4pSL-0007Or-JE for 34863 <at> debbugs.gnu.org; Fri, 15 Mar 2019 12:13:14 -0400 Received: from localhost (178.112.254.29.wireless.dyn.drei.com [178.112.254.29]) by dd26836.kasserver.com (Postfix) with ESMTPSA id CF7F63360BD2 for <34863 <at> debbugs.gnu.org>; Fri, 15 Mar 2019 17:13:11 +0100 (CET) Date: Fri, 15 Mar 2019 17:13:06 +0100 From: Danny Milosavljevic <dannym@HIDDEN> Message-ID: <20190315171306.777c88bd@HIDDEN> In-Reply-To: <20190314220823.30769-1-dannym@HIDDEN> References: <20190314220823.30769-1-dannym@HIDDEN> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/zI3CErw2ah9RIwaGdV+Iof="; protocol="application/pgp-signature" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) --Sig_/zI3CErw2ah9RIwaGdV+Iof= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable > +(define (set-loop-device-status loop-file status) > + (let ((buf (make-bytevector sizeof-loop-info64))) > + (apply write-loop-info64! buf status) ; TODO: Be more user-friendly. I don't know how instantiate a C structure given an assoc list. Help? --Sig_/zI3CErw2ah9RIwaGdV+Iof= Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEds7GsXJ0tGXALbPZ5xo1VCwwuqUFAlyLzxIACgkQ5xo1VCww uqU0Cwf9FNKmRRo1mwrFNNeUsgDkA9AqfMrBWwWBdQnF3QRNtfmycGGV9QT2ffrS NIFrwXAZs+gwVRUpLgJOuL6VrN6YcSZkAC7yF69CgetMPJ1swa3+rzcP0SyCFEE4 tX23hFXy0nGEVZJYf2utPFj2/4dr/eUxANZD0UDokMd8RNZDkCbiLlnSx8Nigirh 1jb7UrlSEAxeFAGXUUzrezt8St0iA4fgSL3flHfeglbbdpihvIS91v6hnQtnBHML YZMhc2tzU1oHMRzJTDoh/mreBbzjYVpaE4NIDEhHD10dUxXoYKWRxZj2vVjvEKj0 L7N7jrMKSZCeGt6QizjilEZGLx3juw== =C+jG -----END PGP SIGNATURE----- --Sig_/zI3CErw2ah9RIwaGdV+Iof=--
X-Loop: help-debbugs@HIDDEN Subject: [bug#34863] [WIP] syscalls: Add loop device interface. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Sat, 16 Mar 2019 10:19:01 +0000 Resent-Message-ID: <handler.34863.B34863.155273150530298 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 34863 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Danny Milosavljevic <dannym@HIDDEN> Cc: 34863 <at> debbugs.gnu.org Received: via spool by 34863-submit <at> debbugs.gnu.org id=B34863.155273150530298 (code B ref 34863); Sat, 16 Mar 2019 10:19:01 +0000 Received: (at 34863) by debbugs.gnu.org; 16 Mar 2019 10:18:25 +0000 Received: from localhost ([127.0.0.1]:45796 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1h56OW-0007sc-TM for submit <at> debbugs.gnu.org; Sat, 16 Mar 2019 06:18:25 -0400 Received: from eggs.gnu.org ([209.51.188.92]:36124) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1h56OU-0007sP-Tx for 34863 <at> debbugs.gnu.org; Sat, 16 Mar 2019 06:18:23 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57716) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>) id 1h56OO-00018J-1Q; Sat, 16 Mar 2019 06:18:17 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=33942 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from <ludo@HIDDEN>) id 1h56OL-00076j-NS; Sat, 16 Mar 2019 06:18:15 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> References: <20190314220823.30769-1-dannym@HIDDEN> <20190315171306.777c88bd@HIDDEN> Date: Sat, 16 Mar 2019 11:18:12 +0100 In-Reply-To: <20190315171306.777c88bd@HIDDEN> (Danny Milosavljevic's message of "Fri, 15 Mar 2019 17:13:06 +0100") Message-ID: <877ecz15sr.fsf@HIDDEN> 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-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hi! Danny Milosavljevic <dannym@HIDDEN> skribis: >> +(define (set-loop-device-status loop-file status) >> + (let ((buf (make-bytevector sizeof-loop-info64))) >> + (apply write-loop-info64! buf status) ; TODO: Be more user-friendly. > > I don't know how instantiate a C structure given an assoc list. Help? You have to extract the fields from STATUS and then pass them in the right order to =E2=80=98write-loop-info64!=E2=80=99: (let-syntax ((field (syntax-rules () ((_ field) (assoc-ref status 'field))))) (write-loop-info64! buf (field lo-device) (field lo-inode) (field lo-rdevice) =E2=80=A6)) However, given the number of fields, you might want to define a Scheme record type, as is done for =E2=80=98%statfs=E2=80=99 and <file-system>. HTH! Ludo=E2=80=99.
X-Loop: help-debbugs@HIDDEN Subject: [bug#34863] [WIP] syscalls: Add loop device interface. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Sat, 16 Mar 2019 10:30:02 +0000 Resent-Message-ID: <handler.34863.B34863.155273216831501 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 34863 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Danny Milosavljevic <dannym@HIDDEN> Cc: 34863 <at> debbugs.gnu.org Received: via spool by 34863-submit <at> debbugs.gnu.org id=B34863.155273216831501 (code B ref 34863); Sat, 16 Mar 2019 10:30:02 +0000 Received: (at 34863) by debbugs.gnu.org; 16 Mar 2019 10:29:28 +0000 Received: from localhost ([127.0.0.1]:45801 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1h56ZE-0008C1-1G for submit <at> debbugs.gnu.org; Sat, 16 Mar 2019 06:29:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:37201) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1h56ZC-0008Bk-2D for 34863 <at> debbugs.gnu.org; Sat, 16 Mar 2019 06:29:26 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57750) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>) id 1h56Z6-0000eL-Pc; Sat, 16 Mar 2019 06:29:20 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=33970 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from <ludo@HIDDEN>) id 1h56Z5-00052g-DL; Sat, 16 Mar 2019 06:29:20 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> References: <20190314220823.30769-1-dannym@HIDDEN> Date: Sat, 16 Mar 2019 11:29:17 +0100 In-Reply-To: <20190314220823.30769-1-dannym@HIDDEN> (Danny Milosavljevic's message of "Thu, 14 Mar 2019 23:08:23 +0100") Message-ID: <87k1gzyuwy.fsf@HIDDEN> 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-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hallo! Danny Milosavljevic <dannym@HIDDEN> skribis: > * guix/build/syscalls.scm (%ioctl-unsigned-long): New procedure. > (LOOP_CTL_GET_FREE): New macro. > (LOOP_SET_FD): New macro. > (LOOP_SET_STATUS64): New macro. > (LOOP_GET_STATUS64): New macro. > (lo-flags): New bits. > (lo-flags->symbols): New procedure. > (LO_NAME_SIZE): New variable. > (LO_KEY_SIZE): New variable. > (%struct-loop-info64): New C structure. > (allocate-new-loop-device): New procedure. > (set-loop-device-backing-file): New procedure. > (get-loop-device-status): New procedure. > * tests/syscalls.scm: Add test. What will be the use for this? I prefer to make sure we only add code that is actually going to be used. :-) > +(define-c-struct %struct-loop-info64 > + sizeof-loop-info64 > + (lambda (lo-device lo-inode lo-rdevice lo-offset lo-sizelimit lo-number > + lo-encrypt-type lo-encrypt-key-size lo-flags lo-file-name > + lo-crypt-name lo-encrypt-key lo-init) > + `((lo-device . ,lo-device) > + (lo-inode . ,lo-inode) 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. > +(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\". Nitpick: s/an FD/a file descriptor/ s/an open file/an open port for/ > + (open-io-file (string-append "/dev/loop" (number->string ret)))) 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. > +(define (set-loop-device-backing-file loop-file backing-file) > + "Sets up the loop device LOOP-FILE for BACKING-FILE." Maybe the docstring should be: =E2=80=9CSet BACKING-FILE, a port, as the ba= cking file of LOOP-FILE, an open port to a loopback device.=E2=80=9D? > + (let-values (((ret err) > + (%ioctl-unsigned-long (fileno loop-file) LOOP_SET_FD > + (fileno backing-file)))) 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? In the latter case you=E2=80=99d have to use =E2=80=98port->fdes=E2=80=99 i= nstead of =E2=80=98fileno=E2=80=99 to increase the =E2=80=9Crevealed count=E2=80=9D of the port. > +(define (get-loop-device-status loop-file) Please add a docstring. Also I=E2=80=99d remove =E2=80=98get-=E2=80=99. > +(define (set-loop-device-status loop-file status) Docstring! :-) > --- a/tests/syscalls.scm > +++ b/tests/syscalls.scm > @@ -564,6 +564,10 @@ > (let ((result (call-with-input-file "/var/run/utmpx" read-utmpx))) > (or (utmpx? result) (eof-object? result)))) >=20=20 > +(let ((loop-device (allocate-new-loop-device (open-io-file "/dev/loop-co= ntrol")))) > + (set-loop-device-backing-file loop-device (open-input-file "tests/sysc= alls.scm")) > + (set-loop-device-status loop-device (get-loop-device-status loop-devic= e))) You=E2=80=99re missing a =E2=80=98test-assert=E2=80=99 or similar. Also, i= sn=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 wrong= -type-arg, no? Thank you! Ludo=E2=80=99.
X-Loop: help-debbugs@HIDDEN Subject: [bug#34863] [WIP] syscalls: Add loop device interface. Resent-From: Danny Milosavljevic <dannym@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Sat, 16 Mar 2019 11:18:01 +0000 Resent-Message-ID: <handler.34863.B34863.15527350423824 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 34863 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> Cc: 34863 <at> debbugs.gnu.org Received: via spool by 34863-submit <at> debbugs.gnu.org id=B34863.15527350423824 (code B ref 34863); Sat, 16 Mar 2019 11:18:01 +0000 Received: (at 34863) by debbugs.gnu.org; 16 Mar 2019 11:17:22 +0000 Received: from localhost ([127.0.0.1]:45842 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1h57JY-0000zb-T5 for submit <at> debbugs.gnu.org; Sat, 16 Mar 2019 07:17:22 -0400 Received: from dd26836.kasserver.com ([85.13.145.193]:57224) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <dannym@HIDDEN>) id 1h57JW-0000zQ-QI for 34863 <at> debbugs.gnu.org; Sat, 16 Mar 2019 07:17:19 -0400 Received: from localhost (178.112.219.56.wireless.dyn.drei.com [178.112.219.56]) by dd26836.kasserver.com (Postfix) with ESMTPSA id 36EC13360A67; Sat, 16 Mar 2019 12:17:17 +0100 (CET) Date: Sat, 16 Mar 2019 12:17:09 +0100 From: Danny Milosavljevic <dannym@HIDDEN> Message-ID: <20190316121709.27c979dc@HIDDEN> In-Reply-To: <87k1gzyuwy.fsf@HIDDEN> References: <20190314220823.30769-1-dannym@HIDDEN> <87k1gzyuwy.fsf@HIDDEN> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-unknown-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/ThL=zvr0b_QYsTuN1b1m8DC"; protocol="application/pgp-signature" X-Spam-Score: -0.7 (/) X-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.7 (-) --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 <ludo@HIDDEN> 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--
X-Loop: help-debbugs@HIDDEN Subject: [bug#34863] [WIP] syscalls: Add loop device interface. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Mon, 18 Mar 2019 08:43:01 +0000 Resent-Message-ID: <handler.34863.B34863.155289856616314 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 34863 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Danny Milosavljevic <dannym@HIDDEN> Cc: 34863 <at> debbugs.gnu.org Received: via spool by 34863-submit <at> debbugs.gnu.org id=B34863.155289856616314 (code B ref 34863); Mon, 18 Mar 2019 08:43:01 +0000 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 <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1h5nr4-0004F2-3Y for submit <at> 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 <ludo@HIDDEN>) id 1h5nr2-0004Eq-5I for 34863 <at> 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 <ludo@HIDDEN>) 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 <ludo@HIDDEN>) id 1h5nqv-0002WP-TV; Mon, 18 Mar 2019 04:42:38 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> References: <20190314220823.30769-1-dannym@HIDDEN> <87k1gzyuwy.fsf@HIDDEN> <20190316121709.27c979dc@HIDDEN> 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=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@HIDDEN> (Danny Milosavljevic's message of "Sat, 16 Mar 2019 12:17:09 +0100") Message-ID: <87wokwshdv.fsf@HIDDEN> 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-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -1.0 (-) Hello, Danny Milosavljevic <dannym@HIDDEN> skribis: > On Sat, 16 Mar 2019 11:29:17 +0100 > Ludovic Court=C3=A8s <ludo@HIDDEN> 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.
X-Loop: help-debbugs@HIDDEN Subject: [bug#34863] [WIP] syscalls: Add loop device interface. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Wed, 10 Apr 2019 14:57:01 +0000 Resent-Message-ID: <handler.34863.B34863.1554908175616 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 34863 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Danny Milosavljevic <dannym@HIDDEN> Cc: 34863 <at> debbugs.gnu.org Received: via spool by 34863-submit <at> debbugs.gnu.org id=B34863.1554908175616 (code B ref 34863); Wed, 10 Apr 2019 14:57:01 +0000 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 <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hEEe7-00009r-6K for submit <at> 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 <ludo@HIDDEN>) id 1hEEe4-00009c-QH for 34863 <at> 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 <ludo@HIDDEN>) 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 <ludo@HIDDEN>) id 1hEEdx-0005Lj-2u; Wed, 10 Apr 2019 10:56:05 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> References: <20190314220823.30769-1-dannym@HIDDEN> <87k1gzyuwy.fsf@HIDDEN> <20190316121709.27c979dc@HIDDEN> <87wokwshdv.fsf@HIDDEN> Date: Wed, 10 Apr 2019 16:56:03 +0200 In-Reply-To: <87wokwshdv.fsf@HIDDEN> ("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@HIDDEN> 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-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Ping! :-) Ludovic Court=C3=A8s <ludo@HIDDEN> skribis: > Hello, > > Danny Milosavljevic <dannym@HIDDEN> skribis: > >> On Sat, 16 Mar 2019 11:29:17 +0100 >> Ludovic Court=C3=A8s <ludo@HIDDEN> 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.
X-Loop: help-debbugs@HIDDEN Subject: [bug#34863] [WIP] syscalls: Add loop device interface. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> Resent-CC: guix-patches@HIDDEN Resent-Date: Tue, 21 May 2019 14:52:02 +0000 Resent-Message-ID: <handler.34863.B34863.155845029123000 <at> debbugs.gnu.org> Resent-Sender: help-debbugs@HIDDEN X-GNU-PR-Message: followup 34863 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: To: Danny Milosavljevic <dannym@HIDDEN> Cc: 34863 <at> debbugs.gnu.org Received: via spool by 34863-submit <at> debbugs.gnu.org id=B34863.155845029123000 (code B ref 34863); Tue, 21 May 2019 14:52:02 +0000 Received: (at 34863) by debbugs.gnu.org; 21 May 2019 14:51:31 +0000 Received: from localhost ([127.0.0.1]:40552 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>) id 1hT671-0005yu-HL for submit <at> debbugs.gnu.org; Tue, 21 May 2019 10:51:31 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34550) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <ludo@HIDDEN>) id 1hT66z-0005yg-Tm for 34863 <at> debbugs.gnu.org; Tue, 21 May 2019 10:51:30 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:47143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <ludo@HIDDEN>) id 1hT66u-0007e9-IL; Tue, 21 May 2019 10:51:24 -0400 Received: from [2001:660:6102:320:e120:2c8f:8909:cdfe] (port=40416 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from <ludo@HIDDEN>) id 1hT66u-0005lg-4C; Tue, 21 May 2019 10:51:24 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= <ludo@HIDDEN> References: <20190314220823.30769-1-dannym@HIDDEN> <87k1gzyuwy.fsf@HIDDEN> <20190316121709.27c979dc@HIDDEN> <87wokwshdv.fsf@HIDDEN> Date: Tue, 21 May 2019 16:51:22 +0200 In-Reply-To: <87wokwshdv.fsf@HIDDEN> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Mon, 18 Mar 2019 09:42:36 +0100") Message-ID: <87v9y3zwr9.fsf@HIDDEN> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (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-BeenThere: debbugs-submit <at> debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: <debbugs-submit.debbugs.gnu.org> List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe> List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/> List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org> List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help> List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe> Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org> X-Spam-Score: -3.3 (---) Ping! :-) Ludovic Court=C3=A8s <ludo@HIDDEN> skribis: > Hello, > > Danny Milosavljevic <dannym@HIDDEN> skribis: > >> On Sat, 16 Mar 2019 11:29:17 +0100 >> Ludovic Court=C3=A8s <ludo@HIDDEN> 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.
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997 nCipher Corporation Ltd,
1994-97 Ian Jackson.