;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
;;;
;;; This file is part of GNU Guix.
;;;
#:export (file-system
file-system?
file-system-device
+ file-system-device->string
file-system-title ;deprecated
file-system-mount-point
file-system-type
;; differs from user to user.
(define (%store-prefix)
"Return the store prefix."
- (cond ((resolve-module '(guix store) #:ensure #f)
+ ;; Note: If we have (guix store database) in the search path and we do *not*
+ ;; have (guix store) proper, 'resolve-module' returns an empty (guix store)
+ ;; with one sub-module.
+ (cond ((and=> (resolve-module '(guix store) #:ensure #f)
+ (lambda (store)
+ (module-variable store '%store-prefix)))
=>
- (lambda (store)
- ((module-ref store '%store-prefix))))
+ (lambda (variable)
+ ((variable-ref variable))))
((getenv "NIX_STORE")
=> identity)
(else
(()
#f)))))))
+(define* (file-system-device->string device #:key uuid-type)
+ "Return the string representations of the DEVICE field of a <file-system>
+record. When the device is a UUID, its representation is chosen depending on
+UUID-TYPE, a symbol such as 'dce or 'iso9660."
+ (match device
+ ((? file-system-label?)
+ (file-system-label->string device))
+ ((? uuid?)
+ (if uuid-type
+ (uuid->string (uuid-bytevector device) uuid-type)
+ (uuid->string device)))
+ ((? string?)
+ device)))
+
(define (file-system-needed-for-boot? fs)
"Return true if FS has the 'needed-for-boot?' flag set, or if it holds the
store--e.g., if FS is the root file system."
(mount-point (%store-prefix))
(type "none")
(check? #f)
- (flags '(read-only bind-mount))))
+ (flags '(read-only bind-mount no-atime))))
(define %control-groups
(let ((parent (file-system
;; parent directory.
(dependencies (list parent))))
'("cpuset" "cpu" "cpuacct" "memory" "devices" "freezer"
- "blkio" "perf_event")))))
+ "blkio" "perf_event" "pids")))))
(define %elogind-file-systems
;; We don't use systemd, but these file systems are needed for elogind,
;; XXX: On some GNU/Linux systems, /etc/resolv.conf is a
;; symlink to a file in a tmpfs which, for an unknown reason,
;; cannot be bind mounted read-only within the container.
- (writable? (string=? file "/etc/resolv.conf"))))
- %network-configuration-files))
+ ;; The same goes with /var/run/nscd, as discussed in
+ ;; <https://bugs.gnu.org/37967>.
+ (writable? (or (string=? file "/etc/resolv.conf")
+ (string=? file "/var/run/nscd")))))
+ (cons "/var/run/nscd" %network-configuration-files)))
(define (file-system-type-predicate type)
"Return a predicate that, when passed a file system, returns #t if that file