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