From de1c158f32e1d4060daa600a62b68fe22b613424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Mon, 22 Sep 2014 11:06:42 +0200 Subject: system: Add support for boot-time mapped devices. * gnu/build/linux-boot.scm (boot-system): Add #:pre-mount parameter and honor it. * gnu/system/linux-initrd.scm (base-initrd): Add #:mapped-devices parameter. Add 'device-mapping-commands' variable, and use it to build the #:pre-mount argument of 'boot-system'. * gnu/system.scm (mapped-device-user, operating-system-user-mapped-devices, operating-system-boot-mapped-devices): New procedures. (device-mapping-services): Use 'operating-system-user-mapped-devices' instead of 'operating-system-mapped-devices'. (operating-system-initrd-file): Call the initrd with #:mapped-devices. --- gnu/system.scm | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'gnu/system.scm') diff --git a/gnu/system.scm b/gnu/system.scm index 13b461c003..d15c864384 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -216,6 +216,34 @@ as 'needed-for-boot'." #:flags flags)))) file-systems))) +(define (mapped-device-user device file-systems) + "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) + (string=? (file-system-device fs) target)) + file-systems))) + +(define (operating-system-user-mapped-devices os) + "Return the subset of mapped devices that can be installed in +user-land--i.e., those not needed during boot." + (let ((devices (operating-system-mapped-devices os)) + (file-systems (operating-system-file-systems os))) + (filter (lambda (md) + (let ((user (mapped-device-user md file-systems))) + (or (not user) + (not (file-system-needed-for-boot? user))))) + devices))) + +(define (operating-system-boot-mapped-devices os) + "Return the subset of mapped devices that must be installed during boot, +from the initrd." + (let ((devices (operating-system-mapped-devices os)) + (file-systems (operating-system-file-systems os))) + (filter (lambda (md) + (let ((user (mapped-device-user md file-systems))) + (and user (file-system-needed-for-boot? user)))) + devices))) + (define (device-mapping-services os) "Return the list of device-mapping services for OS as a monadic list." (sequence %store-monad @@ -228,7 +256,7 @@ as 'needed-for-boot'." (device-mapping-service target (open source target) (close source target)))) - (operating-system-mapped-devices os)))) + (operating-system-user-mapped-devices os)))) (define (swap-services os) "Return the list of swap services for OS as a monadic list." @@ -561,10 +589,14 @@ we're running in the final root." boot?)) (operating-system-file-systems os))) - ;; TODO: Pass the mapped devices required by boot-time file systems to the - ;; initrd. - (mlet %store-monad - ((initrd ((operating-system-initrd os) boot-file-systems))) + (define mapped-devices + (operating-system-boot-mapped-devices os)) + + (define make-initrd + (operating-system-initrd os)) + + (mlet %store-monad ((initrd (make-initrd boot-file-systems + #:mapped-devices mapped-devices))) (return #~(string-append #$initrd "/initrd")))) (define (kernel->grub-label kernel) -- cgit v1.2.3