Fixes <https://bugs.gnu.org/34902>.
Reported by Julien Lepiller <julien@lepiller.eu>.
* gnu/build/linux-modules.scm (module-formal-name): New procedure.
(load-linux-modules-from-directory)[lookup-module]: Remove.
[module-name->file-name]: New variable. Use it.
(module-name->file-name/guess, module-name-lookup)
(write-module-name-database): New procedures.
* gnu/system/linux-initrd.scm (flat-linux-module-directory): Call
'write-module-name-database'.
* gnu/build/linux-modules.scm (aliases->device-tuple)
(write-module-device-database): New procedures.
(%not-dash): New variable.
Co-authored-by: Danny Milosavljevic <dannym@scratchpost.org>.
Previously we'd get an unhelpful backtrace like this:
In gnu/build/linux-modules.scm:
184:47 4 (recursive-module-dependencies _ #:lookup-module _)
98:14 3 (module-dependencies _)
85:18 2 (modinfo-section-contents _)
In ice-9/ports.scm:
439:11 1 (call-with-input-file #f #<procedure get-bytevector-al?> ?)
In unknown file:
0 (open-file #f "r" #:encoding #f #:guess-encoding #f)
ERROR: In procedure open-file:
Wrong type (expecting string): #f
builder for `/gnu/store/…-linux-modules.drv' failed with exit code 1
* gnu/build/linux-modules.scm (find-module-file): When MODULE cannot be
found, raise an error instead of returning #f. This is more useful to
the user.
* gnu/build/linux-modules.scm (section-contents): Honor SECTION as was
intended.
(modinfo-section-contents): Pass 'section-contents' a section, not a
section name.
Previously we would not strip the ".ko" suffix if present.
* gnu/build/linux-modules.scm (file-name->module-name): Export.
* gnu/system/mapped-devices.scm (check-device-initrd-modules): Use
'file-name->module-name' instead of 'normalize-module-name'.
This should be more efficient than loading the whole thing in user space.
* gnu/build/linux-modules.scm (load-linux-module*): Use
'load-linux-module/fd' instead of 'load-linux-module'. Remove 'slurp'.
* gnu/packages/patches/guile-linux-syscalls.patch (scm_load_linux_module):
Leave 'errno' unchanged when ERR != 0.
* gnu/build/linux-modules.scm (load-linux-module*): Check for the errno
value of ARGS to determine whether the module was already loaded.