Subject: Re: [bug#30604] [PATCH v3 4/6] linux-boot: Load kernel modules only when the hardware is present.

From: [email-masked] (Ludovic Courtès)
Date: Tue, 27 Feb 2018 15:26:06 +0100

Hello,

Nice patch series!

Danny Milosavljevic <[email-masked]> skribis:

> * 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.

[...]

> +  (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))))

Can we build upon (gnu build linux-modules) to achieve this?

Hopefully the tools at
<https://debbugs.gnu.org/cgi/bugreport.cgi?bug=30629#14> can help a bit.

Thanks,
Ludo’.