type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-if [ -e /dev/root ]; then
- if strstr "$(udevadm info --query=env --name=/dev/root)" "ID_FS_TYPE=btrfs"; then
+dev="${1:-/dev/root}"
+
+if [ -e "$dev" ]; then
+ if strstr "$(udevadm info --query=env \"--name=$dev\")" "ID_FS_TYPE=btrfs"; then
info "Checking, if btrfs device complete"
unset __btrfs_mount
- mount -o ro /dev/root /tmp >/dev/null 2>&1
+ mount -o ro "$dev" /tmp >/dev/null 2>&1
__btrfs_mount=$?
- [ $__btrfs_mount -eq 0 ] && umount /dev/root >/dev/null 2>&1
+ [ $__btrfs_mount -eq 0 ] && umount "$dev" >/dev/null 2>&1
exit $__btrfs_mount
fi
fi
printf 'SYMLINK=="%s", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root $env{DEVNAME}"\n' \
${root#live:/dev/}
} >> /etc/udev/rules.d/99-live-squash.rules
- echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/dmsquash.sh
+ wait_for_dev "${root#live:}"
;;
live:*)
if [ -f "${root#live:}" ]; then
/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root "${root#live:}"
- echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/dmsquash.sh
fi
;;
esac
printf 'KERNEL=="loop0", RUN+="/sbin/initqueue --settled --onetime --unique /sbin/dmsquash-live-root `/sbin/losetup -f --show %s`"\n' \
${root#liveiso:}
} >> /etc/udev/rules.d/99-liveiso-mount.rules
- echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/dmsquash.sh
fi
rm -f /etc/udev/rules.d/64-lvm*.rules
else
for dev in $(getargs rd.lvm.vg rd_LVM_VG=) $(getargs rd.lvm.lv rd_LVM_LV=); do
- printf '[ -e "/dev/%s" ] || return 1\n' $dev \
- >> $hookdir/initqueue/finished/lvm.sh
- {
- printf '[ -e "/dev/%s" ] || ' $dev
- printf 'warn "LVM "%s" not found"\n' $dev
- } >> $hookdir/emergency/90-lvm.sh
+ wait_for_dev "/dev/$dev"
done
fi
# Shut up init error check
[ -z "$root" ] && root="iscsi"
-echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/iscsi.sh
-
fi
netroot=$root
+ unset root
fi
# If it's not nbd we don't continue
rootok=1
# Shut up init error check
-[ -z "$root" ] && root="nbd"
-
-echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/nbd.sh
+if [ -z "$root" ]; then
+ root=block:/dev/root
+ wait_for_dev /dev/root
+fi
printf '[ -e "%s" ] && { ln -s "%s" /dev/resume; rm "$job"; }\n' \
"$resume" "$resume" >> $hookdir/initqueue/settled/resume.sh
- echo '[ -e /dev/resume ]' > $hookdir/initqueue/finished/resume.sh
-
- {
- printf '[ -e /dev/resume ] || '
- printf 'warn "resume device "%s" not found"\n' "$resume"
- } >> $hookdir/emergency/00-resume.sh
-
+ wait_for_dev "/dev/resume"
elif ! getarg noresume; then
{
printf '[ -e "%s" ] && { ln -s "%s" /dev/root 2>/dev/null; rm "$job"; }\n' \
"${root#block:}" "${root#block:}" > $hookdir/initqueue/settled/blocksymlink.sh
- echo '[ -e /dev/root ]' > $hookdir/initqueue/finished/block.sh
+ wait_for_dev "${root#block:}"
fi
check_finished() {
local f
- for f in $hookdir/initqueue/finished/*.sh; do { [ -e "$f" ] && ( . "$f" ) ; } || return 1 ; done
+ for f in $hookdir/initqueue/finished/*.sh; do
+ [ "$f" = "$hookdir/initqueue/finished/*.sh" ] && return 0
+ { [ -e "$f" ] && ( . "$f" ) ; } || return 1
+ done
return 0
}
done
return 0
}
+
+wait_for_mount()
+{
+ local _name
+ _name="$(str_replace "$1" '/' '\\x2f')"
+ printf '. /lib/dracut-lib.sh\nismounted "%s"\n' $1 \
+ >> "$hookdir/initqueue/finished/ismounted-${_name}.sh"
+ {
+ printf 'ismounted "%s" || ' $1
+ printf 'warn "\"%s\" is not mounted"\n' $1
+ } >> "$hookdir/emergency/90-${_name}.sh"
+}
+
+wait_for_dev()
+{
+ local _name
+ _name="$(str_replace "$1" '/' '\\x2f')"
+ printf '[ -e "%s" ]\n' $1 \
+ >> "$hookdir/initqueue/finished/devexists-${_name}.sh"
+ {
+ printf '[ -e "%s" ] || ' $1
+ printf 'warn "\"%s\" does not exist"\n' $1
+ } >> "$hookdir/emergency/80-${_name}.sh"
+}