diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 14:01:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-03 14:01:35 +0000 |
commit | e6f2eaf47a177a8eca054d1d70a1b6287e8c3521 (patch) | |
tree | c5719e819a9e37df4b54affd61438f382ec38a8f /modules.d/90dm/dm-shutdown.sh | |
parent | Adding upstream version 060+5. (diff) | |
download | dracut-upstream/102.tar.xz dracut-upstream/102.zip |
Adding upstream version 102.upstream/102
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules.d/90dm/dm-shutdown.sh')
-rwxr-xr-x | modules.d/90dm/dm-shutdown.sh | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/modules.d/90dm/dm-shutdown.sh b/modules.d/90dm/dm-shutdown.sh index bd7134a..93b62bb 100755 --- a/modules.d/90dm/dm-shutdown.sh +++ b/modules.d/90dm/dm-shutdown.sh @@ -2,26 +2,40 @@ _remove_dm() { local dev="$1" + local final="$2" local s local devname for s in /sys/block/"${dev}"/holders/dm-*; do [ -e "${s}" ] || continue - _remove_dm "${s##*/}" + _remove_dm "${s##*/}" "$final" || return $? done - # multipath devices might have MD devices on top, - # which are removed after this script. So do not - # remove those to avoid spurious errors + + read -r devname < /sys/block/"${dev}"/dm/name case $(cat /sys/block/"${dev}"/dm/uuid) in mpath-*) + # multipath devices might have MD devices on top, + # which are removed after this script. So do not + # remove those to avoid spurious errors return 0 ;; - *) - read -r devname < /sys/block/"${dev}"/dm/name - dmsetup -v --noudevsync remove "$devname" || return $? + CRYPT-*) + if command -v systemd-cryptsetup > /dev/null; then + DM_DISABLE_UDEV=true SYSTEMD_LOG_LEVEL=debug systemd-cryptsetup detach "$devname" && return 0 + elif command -v cryptsetup > /dev/null; then + DM_DISABLE_UDEV=true cryptsetup close --debug "$devname" && return 0 + else + dmsetup -v --noudevsync remove "$devname" + return $? + fi + + # try using plain dmsetup if we're on the final attempt. + [ -z "$final" ] && return 1 ;; esac - return 0 + + dmsetup -v --noudevsync remove "$devname" + return $? } _do_dm_shutdown() { @@ -33,9 +47,9 @@ _do_dm_shutdown() { for dev in /sys/block/dm-*; do [ -e "${dev}" ] || continue if [ "x$final" != "x" ]; then - _remove_dm "${dev##*/}" || ret=$? + _remove_dm "${dev##*/}" "$final" || ret=$? else - _remove_dm "${dev##*/}" > /dev/null 2>&1 || ret=$? + _remove_dm "${dev##*/}" "$final" > /dev/null 2>&1 || ret=$? fi done if [ "x$final" != "x" ]; then |