]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(nfs,virtiofs): check kernel for builtin fs drivers
authorLaszlo Gombos <laszlo.gombos@gmail.com>
Mon, 15 Aug 2022 20:10:30 +0000 (20:10 +0000)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Thu, 18 Aug 2022 06:25:20 +0000 (06:25 +0000)
Check first for fs support in `/proc/filesystems` before attempting
to load the kernel module.

This is needed in the --no-kernel use case to avoid the error:
modprobe: FATAL: Module overlay not found in directory /lib/modules/<kver>

modules.d/95nfs/nfs-start-rpc.sh
modules.d/95virtiofs/mount-virtiofs.sh
modules.d/99base/dracut-lib.sh

index 69fcfd5a3ec2c8f3cb591e0dab00f67a28200817..52f6a4dedd428dc6d5bd93b70ca77037c4ef8bfa 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-if modprobe sunrpc || strstr "$(cat /proc/filesystems)" rpc_pipefs; then
+if load_fstype sunrpc rpc_pipefs; then
     [ ! -d /var/lib/nfs/rpc_pipefs/nfs ] \
         && mount -t rpc_pipefs rpc_pipefs /var/lib/nfs/rpc_pipefs
 
index e88043293264abf99acf04c0ed5d8c835e892b87..e6b9d41606044c35b179d7fafc87541cd2f23ddb 100755 (executable)
@@ -3,7 +3,7 @@
 type ismounted > /dev/null 2>&1 || . /lib/dracut-lib.sh
 
 if [ "${fstype}" = "virtiofs" -o "${root%%:*}" = "virtiofs" ]; then
-    if ! { modprobe virtiofs || strstr "$(cat /proc/filesystems)" virtiofs; }; then
+    if ! load_fstype virtiofs; then
         die "virtiofs is required but not available."
     fi
 
index 913d0a8c05afc4ba9985c80fc51651148388bb57..2cebbc8ad7a8ad09109d82492cfabcb10bffc7c5 100755 (executable)
@@ -1153,9 +1153,12 @@ remove_hostonly_files() {
     fi
 }
 
-# parameter: kernel_module filesystem_name
+# parameter: kernel_module [filesystem_name]
 # returns OK if kernel_module is loaded
 # modprobe fails if /lib/modules is not available (--no-kernel use case)
 load_fstype() {
-    strstr "$(cat /proc/filesystems)" "$1" || modprobe "$1"
+    if [ -z "$2" ]; then
+        set -- "$1" "$2"
+    fi
+    strstr "$(cat /proc/filesystems)" "$2" || modprobe "$1"
 }