GNU bug report logs -
#30604
[PATCH 0/4] Load Linux module only when supported hardware is present.
Previous Next
Full log
Message #86 received at 30604 <at> debbugs.gnu.org (full text, mbox):
* 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 | 31 +++++++++++++++++++++++++++----
gnu/system/linux-initrd.scm | 4 +++-
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/gnu/build/linux-boot.scm b/gnu/build/linux-boot.scm
index 18d87260a..6d00ea9be 100644
--- a/gnu/build/linux-boot.scm
+++ b/gnu/build/linux-boot.scm
@@ -473,6 +473,32 @@ upon error."
(string-append linux-module-directory "/"
(ensure-dot-ko name)))
+ (define (load-kernel-modules)
+ "Examine /sys/devices to find out which modules to load and load them."
+ (define enter?
+ (const #t))
+ (define (down! path stat result)
+ ;; Note: modprobe mutates the tree starting with path.
+ (let ((modalias-name (string-append path "/modalias")))
+ (if (file-exists? modalias-name)
+ (let ((modalias
+ (string-trim-right (call-with-input-file modalias-name
+ read-string)
+ #\newline)))
+ (system* "/sbin/modprobe" "-q" "--" modalias))))
+ #t)
+ (define up
+ (const #t))
+ (define skip
+ (const #t))
+ (define leaf
+ (const #t))
+ (define (error name stat errno result)
+ (format (current-error-port) "warning: ~a: ~a~%"
+ name (strerror errno))
+ result)
+ (file-system-fold enter? leaf down! up skip error #t "/sys/devices"))
+
(display "Welcome, this is GNU's early boot Guile.\n")
(display "Use '--repl' for an initrd REPL.\n\n")
@@ -486,10 +512,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 46ef055f0..c8a9e4950 100644
--- a/gnu/system/linux-initrd.scm
+++ b/gnu/system/linux-initrd.scm
@@ -225,7 +225,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 ()
This bug report was last modified 5 years and 305 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.