From 7a0bf3d5337d2662b0e4cdb8c9f8b5162c401d23 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sat, 25 Jul 2020 15:48:35 +0200 Subject: file-systems: Convey hint via '&fix-hint'. * gnu/system/file-systems.scm (btrfs-store-subvolume-file-name): Use '&fix-hint' for the hint. --- gnu/system/file-systems.scm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'gnu/system/file-systems.scm') diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index 0f94577760..f6b0d8a964 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès +;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2020 Jakub Kądziołka ;;; Copyright © 2020 Maxim Cournoyer ;;; @@ -28,6 +28,8 @@ #:use-module (srfi srfi-35) #:use-module (srfi srfi-9 gnu) #:use-module (guix records) + #:use-module ((guix diagnostics) #:select (&fix-hint)) + #:use-module (guix i18n) #:use-module (gnu system uuid) #:re-export (uuid ;backward compatibility string->uuid @@ -613,12 +615,13 @@ store is located, else #f." ;; XXX: Deriving the subvolume name based from a subvolume ID is not ;; supported, as we'd need to query the actual file system. (or (and=> (assoc-ref options "subvol") prepend-slash/maybe) - ;; FIXME: Use &fix-hint once it no longer pulls in (guix utils). (raise (condition (&message (message "The store is on a Btrfs subvolume, but the \ -subvolume name is unknown. -Hint: Use the \"subvol\" Btrfs file system option."))))))) +subvolume name is unknown.")) + (&fix-hint + (hint + (G_ "Use the @code{subvol} Btrfs file system option.")))))))) ;;; file-systems.scm ends here -- cgit 1.4.1 From 6bb07e91e1ab9367f636a3a5e9d52a9e0772aa89 Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 31 Jul 2020 12:58:16 +0200 Subject: file-systems: Add %debug-file-system. * gnu/system/file-systems.scm (%debug-file-system): New variable, (%base-file-systems): add it. --- gnu/system/file-systems.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gnu/system/file-systems.scm') diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index f6b0d8a964..660f9942b0 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -68,6 +68,7 @@ %pseudo-file-system-types %fuse-control-file-system %binary-format-file-system + %debug-file-system %shared-memory-file-system %pseudo-terminal-file-system %tty-gid @@ -368,6 +369,14 @@ TARGET in the other system." (type "binfmt_misc") (check? #f))) +(define %debug-file-system + (file-system + (type "debugfs") + (device "none") + (mount-point "/sys/kernel/debug") + (check? #f) + (create-mount-point? #t))) + (define %tty-gid ;; ID of the 'tty' group. Allocate it statically to make it easy to refer ;; to it from here and from the 'tty' group definitions. @@ -467,6 +476,7 @@ TARGET in the other system." ;; List of basic file systems to be mounted. Note that /proc and /sys are ;; currently mounted by the initrd. (list %pseudo-terminal-file-system + %debug-file-system %shared-memory-file-system %immutable-store)) -- cgit 1.4.1 From 7c27bd115b14afd142da7684cc349369965f9eab Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 31 Jul 2020 13:43:20 +0200 Subject: file-system: Add mount-may-fail? option. * gnu/system/file-systems.scm (): Add a mount-may-fail? field. (file-system->spec): adapt accordingly, (spec->file-system): ditto. * gnu/build/file-systems.scm (mount-file-system): If 'system-error is raised and mount-may-fail? is true, ignore it. Otherwise, re-raise the exception. Signed-off-by: Mathieu Othacehe --- gnu/build/file-systems.scm | 49 ++++++++++++++++++++++++++------------------- gnu/system/file-systems.scm | 11 +++++++--- 2 files changed, 36 insertions(+), 24 deletions(-) (limited to 'gnu/system/file-systems.scm') diff --git a/gnu/build/file-systems.scm b/gnu/build/file-systems.scm index 478c71a4e1..4ba1503b9f 100644 --- a/gnu/build/file-systems.scm +++ b/gnu/build/file-systems.scm @@ -814,26 +814,33 @@ corresponds to the symbols listed in FLAGS." (when (file-system-check? fs) (check-file-system source type)) - ;; Create the mount point. Most of the time this is a directory, but - ;; in the case of a bind mount, a regular file or socket may be needed. - (if (and (= MS_BIND (logand flags MS_BIND)) - (not (file-is-directory? source))) - (unless (file-exists? mount-point) - (mkdir-p (dirname mount-point)) - (call-with-output-file mount-point (const #t))) - (mkdir-p mount-point)) - - (cond - ((string-prefix? "nfs" type) - (mount-nfs source mount-point type flags options)) - (else - (mount source mount-point type flags options))) - - ;; For read-only bind mounts, an extra remount is needed, as per - ;; , which still applies to Linux 4.0. - (when (and (= MS_BIND (logand flags MS_BIND)) - (= MS_RDONLY (logand flags MS_RDONLY))) - (let ((flags (logior MS_BIND MS_REMOUNT MS_RDONLY))) - (mount source mount-point type flags #f))))) + (catch 'system-error + (lambda () + ;; Create the mount point. Most of the time this is a directory, but + ;; in the case of a bind mount, a regular file or socket may be + ;; needed. + (if (and (= MS_BIND (logand flags MS_BIND)) + (not (file-is-directory? source))) + (unless (file-exists? mount-point) + (mkdir-p (dirname mount-point)) + (call-with-output-file mount-point (const #t))) + (mkdir-p mount-point)) + + (cond + ((string-prefix? "nfs" type) + (mount-nfs source mount-point type flags options)) + (else + (mount source mount-point type flags options))) + + ;; For read-only bind mounts, an extra remount is needed, as per + ;; , which still applies to Linux + ;; 4.0. + (when (and (= MS_BIND (logand flags MS_BIND)) + (= MS_RDONLY (logand flags MS_RDONLY))) + (let ((flags (logior MS_BIND MS_REMOUNT MS_RDONLY))) + (mount source mount-point type flags #f)))) + (lambda args + (or (file-system-mount-may-fail? fs) + (apply throw args)))))) ;;; file-systems.scm ends here diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index 660f9942b0..9c5cbc9b4e 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -48,6 +48,7 @@ alist->file-system-options file-system-mount? + file-system-mount-may-fail? file-system-check? file-system-create-mount-point? file-system-dependencies @@ -114,6 +115,8 @@ (default #f)) (mount? file-system-mount? ; Boolean (default #t)) + (mount-may-fail? file-system-mount-may-fail? ; Boolean + (default #f)) (needed-for-boot? %file-system-needed-for-boot? ; Boolean (default #f)) (check? file-system-check? ; Boolean @@ -301,18 +304,19 @@ store--e.g., if FS is the root file system." "Return a list corresponding to file-system FS that can be passed to the initrd code." (match fs - (($ device mount-point type flags options _ _ check?) + (($ device mount-point type flags options mount? + mount-may-fail? needed-for-boot? check?) (list (cond ((uuid? device) `(uuid ,(uuid-type device) ,(uuid-bytevector device))) ((file-system-label? device) `(file-system-label ,(file-system-label->string device))) (else device)) - mount-point type flags options check?)))) + mount-point type flags options mount-may-fail? check?)))) (define (spec->file-system sexp) "Deserialize SEXP, a list, to the corresponding object." (match sexp - ((device mount-point type flags options check?) + ((device mount-point type flags options mount-may-fail? check?) (file-system (device (match device (('uuid (? symbol? type) (? bytevector? bv)) @@ -323,6 +327,7 @@ initrd code." device))) (mount-point mount-point) (type type) (flags flags) (options options) + (mount-may-fail? mount-may-fail?) (check? check?))))) (define (specification->file-system-mapping spec writable?) -- cgit 1.4.1 From f94835a917cf78675eb597fecd222b6c6d1fb1ae Mon Sep 17 00:00:00 2001 From: Mathieu Othacehe Date: Fri, 31 Jul 2020 13:43:36 +0200 Subject: file-system: Add efivarfs support. Tools such as efibootmgr rely on the deprecated /sys/firmware/efi/vars API as well as on the new /sys/firmware/efi/efivars API. The latter needs to be mounted. Reported by Keyhenge here: https://lists.gnu.org/archive/html/bug-guix/2020-04/msg00274.html Here is the efivarfs documentation: https://www.kernel.org/doc/Documentation/filesystems/efivarfs.txt. * gnu/system/file-systems.scm (%efivars-file-system): New exported variable, (%base-file-systems): add it. * gnu/system/install.scm (%efivars-file-system): Add it. Signed-off-by: Mathieu Othacehe --- gnu/system/file-systems.scm | 12 ++++++++++++ gnu/system/install.scm | 1 + 2 files changed, 13 insertions(+) (limited to 'gnu/system/file-systems.scm') diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index 9c5cbc9b4e..a62cf902bf 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -70,6 +70,7 @@ %fuse-control-file-system %binary-format-file-system %debug-file-system + %efivars-file-system %shared-memory-file-system %pseudo-terminal-file-system %tty-gid @@ -382,6 +383,16 @@ TARGET in the other system." (check? #f) (create-mount-point? #t))) +(define %efivars-file-system + ;; Support for EFI variables file system. + (file-system + (device "efivarfs") + (mount-point "/sys/firmware/efi/efivars") + (type "efivarfs") + (mount-may-fail? #t) + (needed-for-boot? #f) + (check? #f))) + (define %tty-gid ;; ID of the 'tty' group. Allocate it statically to make it easy to refer ;; to it from here and from the 'tty' group definitions. @@ -483,6 +494,7 @@ TARGET in the other system." (list %pseudo-terminal-file-system %debug-file-system %shared-memory-file-system + %efivars-file-system %immutable-store)) ;; File systems for Linux containers differ from %base-file-systems in that diff --git a/gnu/system/install.scm b/gnu/system/install.scm index d0ff2e7c52..a87c2f4207 100644 --- a/gnu/system/install.scm +++ b/gnu/system/install.scm @@ -497,6 +497,7 @@ Access documentation at any time by pressing Alt-F2.\x1b[0m ;; elogind's cgroup file systems. (list %pseudo-terminal-file-system %shared-memory-file-system + %efivars-file-system %immutable-store))) (users (list (user-account -- cgit 1.4.1 From 86c926d7f2dd4906d51dbcd7d39474116768a68d Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 3 Aug 2020 17:44:38 +0200 Subject: file-systems: Leave room for extension in serialized specs. * gnu/system/file-systems.scm (spec->file-system): Ignore extra fields. (file-system->spec): Add comment. --- gnu/system/file-systems.scm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gnu/system/file-systems.scm') diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index a62cf902bf..5c02dfac93 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -307,6 +307,7 @@ initrd code." (match fs (($ device mount-point type flags options mount? mount-may-fail? needed-for-boot? check?) + ;; Note: Add new fields towards the end for compatibility. (list (cond ((uuid? device) `(uuid ,(uuid-type device) ,(uuid-bytevector device))) ((file-system-label? device) @@ -317,7 +318,8 @@ initrd code." (define (spec->file-system sexp) "Deserialize SEXP, a list, to the corresponding object." (match sexp - ((device mount-point type flags options mount-may-fail? check?) + ((device mount-point type flags options mount-may-fail? check? + _ ...) ;placeholder for new fields (file-system (device (match device (('uuid (? symbol? type) (? bytevector? bv)) -- cgit 1.4.1