28ab1c
From debb3b29ca103e2dac8a3ccafe73f7f815b54979 Mon Sep 17 00:00:00 2001
28ab1c
From: Kairui Song <kasong@redhat.com>
28ab1c
Date: Mon, 12 Oct 2020 15:23:30 +0800
28ab1c
Subject: [PATCH] 99squash: Check require module earlier, and properly
28ab1c
28ab1c
Let 99squash fail earlier if required modules are not enabled or
28ab1c
missing, using the new added helper.
28ab1c
28ab1c
Signed-off-by: Kairui Song <kasong@redhat.com>
28ab1c
(cherry picked from commit 83c65fd3db9f5f3436cfe74ec67d2894dedda397)
28ab1c
28ab1c
Resolves: #1959336
28ab1c
---
28ab1c
 dracut.sh                          | 11 -----------
28ab1c
 modules.d/99squash/module-setup.sh |  7 +++++++
28ab1c
 2 files changed, 7 insertions(+), 11 deletions(-)
28ab1c
28ab1c
diff --git a/dracut.sh b/dracut.sh
28ab1c
index 176b2259..2090d89f 100755
28ab1c
--- a/dracut.sh
28ab1c
+++ b/dracut.sh
28ab1c
@@ -1736,17 +1736,6 @@ fi
28ab1c
 
28ab1c
 if dracut_module_included "squash"; then
28ab1c
     dinfo "*** Install squash loader ***"
28ab1c
-    for config in \
28ab1c
-      CONFIG_SQUASHFS \
28ab1c
-      CONFIG_OVERLAY_FS \
28ab1c
-      CONFIG_DEVTMPFS;
28ab1c
-    do
28ab1c
-      if ! check_kernel_config $config; then
28ab1c
-        dfatal "$config have to be enabled for dracut squash module to work"
28ab1c
-        exit 1
28ab1c
-      fi
28ab1c
-    done
28ab1c
-
28ab1c
     readonly squash_dir="$initdir/squash/root"
28ab1c
     readonly squash_img="$initdir/squash/root.img"
28ab1c
     readonly squash_candidate=( "usr" "etc" )
28ab1c
diff --git a/modules.d/99squash/module-setup.sh b/modules.d/99squash/module-setup.sh
28ab1c
index 6307377c..e2fe3dd4 100644
28ab1c
--- a/modules.d/99squash/module-setup.sh
28ab1c
+++ b/modules.d/99squash/module-setup.sh
28ab1c
@@ -11,6 +11,13 @@ check() {
28ab1c
         return 1
28ab1c
     fi
28ab1c
 
28ab1c
+    for i in squashfs loop overlay; do
28ab1c
+        if ! check_kernel_module $i; then
28ab1c
+            derror "dracut-squash module requires kernel module $i"
28ab1c
+            return 1
28ab1c
+        fi
28ab1c
+    done
28ab1c
+
28ab1c
     return 255
28ab1c
 }
28ab1c
 
28ab1c