]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dmsquash-live): check kernel for built-in squashfs drivers
authorLaszlo Gombos <laszlo.gombos@gmail.com>
Sat, 13 Aug 2022 02:00:09 +0000 (02:00 +0000)
committerJóhann B. Guðmundsson <johannbg@gmail.com>
Mon, 15 Aug 2022 06:07:39 +0000 (06:07 +0000)
Check first for squashfs in `/proc/filesystems`.
This is needed in the --no-kernel use case to avoid the error:
modprobe: FATAL: Module overlay not found in directory /lib/modules/<kver>

Introduce load_fstype function to make it easier to check `/proc/filesystems`
before calling modprobe.

modules.d/90dmsquash-live/dmsquash-live-root.sh
modules.d/99base/dracut-lib.sh

index 9f9eefc01a3c95637ed547926facf012d0993dce..6d9ce42c8ab4e3f33bbc10eb0956876882b08d7e 100755 (executable)
@@ -89,7 +89,7 @@ det_img_fs() {
     blkid -s TYPE -u noraid -o value "$1"
 }
 
-modprobe squashfs
+load_fstype squashfs
 CMDLINE=$(getcmdline)
 for arg in $CMDLINE; do
     case $arg in
@@ -204,7 +204,7 @@ do_live_overlay() {
         fi
     fi
     if [ -n "$overlayfs" ]; then
-        if ! { strstr "$(< /proc/filesystems)" overlay || modprobe overlay; }; then
+        if ! load_fstype overlay; then
             if [ "$overlayfs" = required ]; then
                 die "OverlayFS is required but not available."
                 exit 1
index 43b023e141a01b162ed789e4fc36d0991f60faf7..913d0a8c05afc4ba9985c80fc51651148388bb57 100755 (executable)
@@ -1152,3 +1152,10 @@ remove_hostonly_files() {
         done < /lib/dracut/hostonly-files
     fi
 }
+
+# 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"
+}