]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(dracut-systemd): check and create generator dir outside of inner function
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Wed, 1 Mar 2023 11:07:29 +0000 (12:07 +0100)
committerLaszlo Gombos <laszlo.gombos@gmail.com>
Wed, 10 May 2023 12:10:01 +0000 (08:10 -0400)
modules.d/98dracut-systemd/rootfs-generator.sh

index 32179fb40b1fe79a0a82952f3f7795f150614050..0ba1709ba3b8e352704221bf530bd051f57c4683 100755 (executable)
@@ -51,7 +51,6 @@ generator_mount_rootfs() {
     [ -z "$1" ] && return 0
 
     _name=$(dev_unit_name "$1")
-    [ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
     if ! [ -f "$GENERATOR_DIR"/sysroot.mount ]; then
         {
             echo "[Unit]"
@@ -101,9 +100,11 @@ case "${root#block:}" in
         ;;
 esac
 
-GENERATOR_DIR="$1"
-
 if [ "$rootok" = "1" ]; then
+    GENERATOR_DIR="$1"
+    [ -z "$GENERATOR_DIR" ] && exit 1
+    [ -d "$GENERATOR_DIR" ] || mkdir -p "$GENERATOR_DIR"
+
     generator_wait_for_dev "${root#block:}"
     generator_fsck_after_pre_mount "${root#block:}"
     strstr "$(cat /proc/cmdline)" 'root=' || generator_mount_rootfs "${root#block:}" "$(getarg rootfstype=)" "$(getarg rootflags=)"