Hi Ludo,
On Mon, 12 Mar 2018 13:39:17 +0100Ludovic Courtès <ludo@gnu.org> wrote:
Toggle quote (8 lines)
> + (when modprobe> + ;; Tell the kernel to invoke MODPROBE.> + (call-with-output-file "/proc/sys/kernel/modprobe"> + (lambda (port)> + (display modprobe port))))> +> (display "loading kernel modules...\n")
There's a race because Linux could just start loading modulesimmediately before boot-system even starts / executed far enough.
That was why earlier I kept /sbin/modprobe as the name (it's thedefault Linux uses) and made sure that the file /sbin/modprobe is alreadyin the initrd (as opposed to created by boot-system).
The race didn't happen to me yet (and I doubt that Linux has modulesfine-grained enough that that's a problem in practise) - but I would preferit not to be possible.
WDYT?
Toggle quote (7 lines)
> + (define aliases> + ;; The list of aliases we are asked to load.> + (filter-map (match-lambda> + (('argument . alias) alias)> + (_ #f))> + options))
Without "-a", it's not supposed to be a list of aliases. It's supposed to beone alias and the remainder are parameters supposed to be passed to thatkernel module.
(I didn't know that before).
When Linux invokes /sbin/modprobe, it doesn't pass "-a" but it doesn'tpass any module parameters either - it just passes one module alias.
For clarity and in order that we don't have weird problems later (trying toload a module named "verbose=1" or something :) ), let's just accept one aliasfor now.
Toggle quote (2 lines)
>+(define* (modprobe-program linux-module-directory #:key>+ (guile %guile-static-stripped))[...]
Toggle quote (5 lines)
> + (call-with-output-file "/dev/kmsg"> + (lambda (port)> + (format port "modprobe[~a]: aliases ~s; modules ~s; args ~s~%"> + (getpid) aliases modules (program-arguments))))
Hmm, logging is nice!
But with /dev/kmsg one write(2) syscall needs to pass the entire message.
What do you think about additionally calling setvbuf with 1024 ? Because:
kernel/printk/printk.c: #define LOG_LINE_MAX (1024 - PREFIX_MAX)
Toggle quote (3 lines)
> + (when (< (length modules) (length aliases))> + (error "alias resolution failed" aliases))
The original modprobe loads as many modules as it can and possibly sets an(always the same) error flag (and continues loading the other modules).
Then modprobe's exit status is that error flag.
This is moot because we shouldn't accept more than one alias - see above.
Toggle quote (2 lines)
> + (write-module-alias-database #$output))))
One of the devnames created statically is the one for btrfs, so not writing orusing devnames is not going to end well.
If it did work without it I'd be even more on guard :)
(I'd also copy the modules.builtin (from Linux). Also, what happens if we load a module which has as dependency a builtin? Will we try to load the builtin as a .ko file and fail the entire thing?)
Toggle quote (2 lines)
> + ;; We may need to lazy-load modules. The initrd installs a
Nitpick: "kernel modules" (to clarify).