guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

02/03: system: Honor the 'dependencies' field of file systems.


From: Ludovic Courtès
Subject: 02/03: system: Honor the 'dependencies' field of file systems.
Date: Sun, 17 Jul 2016 23:26:42 +0000 (UTC)

civodul pushed a commit to branch master
in repository guix.

commit 2bdd7ac17ceff60cd5ef77e530f62cea902bf90d
Author: Ludovic Courtès <address@hidden>
Date:   Mon Jul 18 00:51:02 2016 +0200

    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 <address@hidden>.
    
    * 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.
---
 gnu/system.scm   |    7 +++++--
 tests/system.scm |   43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 2 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index a49b3f2..476720b 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -81,6 +81,8 @@
             operating-system-mapped-devices
             operating-system-file-systems
             operating-system-store-file-system
+            operating-system-user-mapped-devices
+            operating-system-boot-mapped-devices
             operating-system-activation-script
             operating-system-user-accounts
             operating-system-shepherd-service-names
@@ -208,8 +210,9 @@ as 'needed-for-boot'."
   "Return a file system among FILE-SYSTEMS that uses DEVICE, or #f."
   (let ((target (string-append "/dev/mapper/" (mapped-device-target device))))
     (find (lambda (fs)
-            (and (eq? 'device (file-system-title fs))
-                 (string=? (file-system-device fs) target)))
+            (or (member device (file-system-dependencies fs))
+                (and (eq? 'device (file-system-title fs))
+                     (string=? (file-system-device fs) target))))
           file-systems)))
 
 (define (operating-system-user-mapped-devices os)
diff --git a/tests/system.scm b/tests/system.scm
index b935bd0..b5bb9af 100644
--- a/tests/system.scm
+++ b/tests/system.scm
@@ -41,6 +41,25 @@
 
     (users %base-user-accounts)))
 
+(define %luks-device
+  (mapped-device
+   (source "/dev/foo") (target "my-luks-device")
+   (type luks-device-mapping)))
+
+(define %os-with-mapped-device
+  (operating-system
+    (host-name "komputilo")
+    (timezone "Europe/Berlin")
+    (locale "en_US.utf8")
+    (bootloader (grub-configuration (device "/dev/sdX")))
+    (mapped-devices (list %luks-device))
+    (file-systems (cons (file-system
+                          (inherit %root-fs)
+                          (dependencies (list %luks-device)))
+                        %base-file-systems))
+    (users %base-user-accounts)))
+
+
 (test-begin "system")
 
 (test-assert "operating-system-store-file-system"
@@ -71,4 +90,28 @@
                                      %base-file-systems)))))
     (eq? gnu (operating-system-store-file-system os))))
 
+(test-equal "operating-system-user-mapped-devices"
+  '()
+  (operating-system-user-mapped-devices %os-with-mapped-device))
+
+(test-equal "operating-system-boot-mapped-devices"
+  (list %luks-device)
+  (operating-system-boot-mapped-devices %os-with-mapped-device))
+
+(test-equal "operating-system-boot-mapped-devices, implicit dependency"
+  (list %luks-device)
+
+  ;; Here we expect the implicit dependency between "/" and
+  ;; "/dev/mapper/my-luks-device" to be found, in spite of the lack of a
+  ;; 'dependencies' field in the root file system.
+  (operating-system-boot-mapped-devices
+   (operating-system
+     (inherit %os-with-mapped-device)
+     (file-systems (cons (file-system
+                           (device "/dev/mapper/my-luks-device")
+                           (title 'device)
+                           (mount-point "/")
+                           (type "ext4"))
+                         %base-file-systems)))))
+
 (test-end)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]