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