guix-patches
[Top][All Lists]
Advanced

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

[bug#30604] [PATCH 4/4] linux-boot: Load kernel modules only when the ha


From: Danny Milosavljevic
Subject: [bug#30604] [PATCH 4/4] linux-boot: Load kernel modules only when the hardware is present.
Date: Sun, 25 Feb 2018 12:48:16 +0100

* gnu/build/linux-boot.scm (boot-system): Load kernel modules only when
the hardware is present.
* gnu/system/linux-initrd.scm (raw-initrd): Add imports.
---
 gnu/build/linux-boot.scm    | 24 ++++++++++++++++++++----
 gnu/system/linux-initrd.scm |  4 +++-
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..65c91c50f 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -473,6 +473,25 @@ upon error."
     (string-append linux-module-directory "/"
                    (ensure-dot-ko name)))
 
+  (define (load-kernel-modules)
+    (define enter?
+      (const #t))
+    (file-system-fold
+     enter?
+     ;; This is the Leaf handler.  It tries to modprobe all the modaliases.
+     (lambda (path stat result) ; leaf
+       (let ((modalias-name (string-append path "/modalias")))
+         (if (file-exists? modalias-name)
+             (let ((modalias (call-with-input-file modalias-name read-string)))
+               (if (not (string=? modalias ""))
+                   (system* "/sbin/modprobe" "-q" "--" modalias))))))
+     (const #t) ; down
+     (const #t) ; up
+     (const #f) ; skip
+     (const #f) ; error
+     #f ; init
+     "/sys/devices"))
+
   (display "Welcome, this is GNU's early boot Guile.\n")
   (display "Use '--repl' for an initrd REPL.\n\n")
 
@@ -486,10 +505,7 @@ upon error."
        (when (member "--repl" args)
          (start-repl))
 
-       (display "loading kernel modules...\n")
-       (for-each (cut load-linux-module* <>
-                      #:lookup-module lookup-module)
-                 (map lookup-module linux-modules))
+       (load-kernel-modules)
 
        (when qemu-guest-networking?
          (unless (configure-qemu-networking)
diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm
index 93089a869..573f4a324 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -228,7 +228,9 @@ upon error."
                       ;; this info via gexps.
                       ((gnu build file-systems)
                        #:select (find-partition-by-luks-uuid))
-                      (rnrs bytevectors))
+                      (rnrs bytevectors)
+                      (ice-9 ftw)
+                      (ice-9 rdelim))
 
          (with-output-to-port (%make-void-port "w")
            (lambda ()





reply via email to

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