From d0f8fde5668cfd7fda1d15824e268b4949b4fd04 Mon Sep 17 00:00:00 2001 From: Philipp Rudo Date: Thu, 25 Jul 2024 12:47:00 +0200 Subject: [PATCH] fix(dracut-init.sh): add module to mods_to_load before checking dependencies When implementing erofs support for 99squash we end up with three modules 99squash, 95squash-squashfs and 95squash-erofs. Where 99squash contains the common code for filesystem images and 95squash-{squashfs,erofs} the special handing depending on the filesystem used. This leads to a dependency cycle as we want to allow users both to choose 99squash, when the exact filesystem doesn't matter, as well as 95squash-{squashfs,erofs} when a specific filesystem is required. But when 99squash is added as a dependency calling dracut_module_included fails in its depends() function. This lead to cases where both handlers, 95squash-squashfs and 95squash-erofs, were added to the initrd. Reason for the failure is that a module only is marked to be loaded after all it's dependencies have been checked as well. Thus a child module cannot detect which parent module wants it to be included. Fix this by marking modules to be loaded before checking its dependencies in check_module. Do the same change in check_mount for consistency. Signed-off-by: Philipp Rudo --- dracut-init.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/dracut-init.sh b/dracut-init.sh index b91348644..e47e034d2 100755 --- a/dracut-init.sh +++ b/dracut-init.sh @@ -882,6 +882,9 @@ check_mount() { fi fi + [[ " $mods_to_load " == *\ $_mod\ * ]] \ + || mods_to_load+=" $_mod " + for _moddep in $(module_depends "$_mod" "$_moddir"); do # handle deps as if they were manually added [[ " $dracutmodules " == *\ $_mod\ * ]] \ @@ -900,9 +903,6 @@ check_mount() { fi done - [[ " $mods_to_load " == *\ $_mod\ * ]] \ - || mods_to_load+=" $_mod " - return 0 } @@ -957,6 +957,9 @@ check_module() { fi fi + [[ " $mods_to_load " == *\ $_mod\ * ]] \ + || mods_to_load+=" $_mod " + for _moddep in $(module_depends "$_mod" "$_moddir"); do # handle deps as if they were manually added [[ " $dracutmodules " == *\ $_mod\ * ]] \ @@ -975,9 +978,6 @@ check_module() { fi done - [[ " $mods_to_load " == *\ $_mod\ * ]] \ - || mods_to_load+=" $_mod " - return 0 } -- 2.47.3