summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-07-18 00:51:02 +0200
committerLudovic Courtès <ludo@gnu.org>2016-07-18 01:26:03 +0200
commit2bdd7ac17ceff60cd5ef77e530f62cea902bf90d (patch)
tree20b37d40904546f380d0cc6dcae8505bad16a737
parent0b07350675ef8b94041605cb53d4763fb97c8d7d (diff)
system: Honor the 'dependencies' field of file systems.
This allows mapped devices listed in 'dependencies' to be properly taken into account. Reported by Andreas Enge <andreas@enge.fr>. * gnu/system.scm (mapped-device-user): Check whether DEVICE is a member of the 'dependencies' of FS. * tests/system.scm (%luks-device, %os-with-mapped-device): New variables. ("operating-system-user-mapped-devices") ("operating-system-boot-mapped-devices") ("operating-system-boot-mapped-devices, implicit dependency"): New tests.
-rw-r--r--gnu/system.scm7
-rw-r--r--tests/system.scm43
2 files changed, 48 insertions, 2 deletions
diff --git a/gnu/system.scm b/gnu/system.scm
index a49b3f29b3f..476720b9f9b 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -81,6 +81,8 @@
81 operating-system-mapped-devices 81 operating-system-mapped-devices
82 operating-system-file-systems 82 operating-system-file-systems
83 operating-system-store-file-system 83 operating-system-store-file-system
84 operating-system-user-mapped-devices
85 operating-system-boot-mapped-devices
84 operating-system-activation-script 86 operating-system-activation-script
85 operating-system-user-accounts 87 operating-system-user-accounts
86 operating-system-shepherd-service-names 88 operating-system-shepherd-service-names
@@ -208,8 +210,9 @@ as 'needed-for-boot'."
208 "Return a file system among FILE-SYSTEMS that uses DEVICE, or #f." 210 "Return a file system among FILE-SYSTEMS that uses DEVICE, or #f."
209 (let ((target (string-append "/dev/mapper/" (mapped-device-target device)))) 211 (let ((target (string-append "/dev/mapper/" (mapped-device-target device))))
210 (find (lambda (fs) 212 (find (lambda (fs)
211 (and (eq? 'device (file-system-title fs)) 213 (or (member device (file-system-dependencies fs))
212 (string=? (file-system-device fs) target))) 214 (and (eq? 'device (file-system-title fs))
215 (string=? (file-system-device fs) target))))
213 file-systems))) 216 file-systems)))
214 217
215(define (operating-system-user-mapped-devices os) 218(define (operating-system-user-mapped-devices os)
diff --git a/tests/system.scm b/tests/system.scm
index b935bd07ebc..b5bb9af016d 100644
--- a/tests/system.scm
+++ b/tests/system.scm
@@ -41,6 +41,25 @@
41 41
42 (users %base-user-accounts))) 42 (users %base-user-accounts)))
43 43
44(define %luks-device
45 (mapped-device
46 (source "/dev/foo") (target "my-luks-device")
47 (type luks-device-mapping)))
48
49(define %os-with-mapped-device
50 (operating-system
51 (host-name "komputilo")
52 (timezone "Europe/Berlin")
53 (locale "en_US.utf8")
54 (bootloader (grub-configuration (device "/dev/sdX")))
55 (mapped-devices (list %luks-device))
56 (file-systems (cons (file-system
57 (inherit %root-fs)
58 (dependencies (list %luks-device)))
59 %base-file-systems))
60 (users %base-user-accounts)))
61
62
44(test-begin "system") 63(test-begin "system")
45 64
46(test-assert "operating-system-store-file-system" 65(test-assert "operating-system-store-file-system"
@@ -71,4 +90,28 @@
71 %base-file-systems))))) 90 %base-file-systems)))))
72 (eq? gnu (operating-system-store-file-system os)))) 91 (eq? gnu (operating-system-store-file-system os))))
73 92
93(test-equal "operating-system-user-mapped-devices"
94 '()
95 (operating-system-user-mapped-devices %os-with-mapped-device))
96
97(test-equal "operating-system-boot-mapped-devices"
98 (list %luks-device)
99 (operating-system-boot-mapped-devices %os-with-mapped-device))
100
101(test-equal "operating-system-boot-mapped-devices, implicit dependency"
102 (list %luks-device)
103
104 ;; Here we expect the implicit dependency between "/" and
105 ;; "/dev/mapper/my-luks-device" to be found, in spite of the lack of a
106 ;; 'dependencies' field in the root file system.
107 (operating-system-boot-mapped-devices
108 (operating-system
109 (inherit %os-with-mapped-device)
110 (file-systems (cons (file-system
111 (device "/dev/mapper/my-luks-device")
112 (title 'device)
113 (mount-point "/")
114 (type "ext4"))
115 %base-file-systems)))))
116
74(test-end) 117(test-end)