mkdumprd: make use of the new get_luks_crypt_dev helper
Resolves: bz1951415
Upstream: fedora
Conflict: None
commit 85c725813b
Author: Kairui Song <kasong@redhat.com>
Date: Thu Apr 8 01:41:21 2021 +0800
mkdumprd: make use of the new get_luks_crypt_dev helper
Simplfy the code and also improve the performance. udevadm call is
heavy.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
Signed-off-by: Kairui Song <kasong@redhat.com>
This commit is contained in:
parent
8387b514f1
commit
de1c56b637
32
mkdumprd
32
mkdumprd
@ -305,7 +305,6 @@ get_override_resettable()
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# $1: function name
|
||||
for_each_block_target()
|
||||
{
|
||||
@ -320,8 +319,6 @@ for_each_block_target()
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
|
||||
#judge if a specific device with $1 is unresettable
|
||||
#return false if unresettable.
|
||||
is_unresettable()
|
||||
@ -358,32 +355,15 @@ check_resettable()
|
||||
return 1
|
||||
}
|
||||
|
||||
# $1: maj:min
|
||||
is_crypt()
|
||||
{
|
||||
local majmin=$1 dev line ID_FS_TYPE=""
|
||||
|
||||
line=$(udevadm info --query=property --path=/sys/dev/block/$majmin \
|
||||
| grep "^ID_FS_TYPE")
|
||||
eval "$line"
|
||||
[[ "$ID_FS_TYPE" = "crypto_LUKS" ]] && {
|
||||
dev=$(udevadm info --query=all --path=/sys/dev/block/$majmin | awk -F= '/DEVNAME/{print $2}')
|
||||
derror "Device $dev is encrypted."
|
||||
return 0
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
check_crypt()
|
||||
{
|
||||
local _ret _target
|
||||
local _dev
|
||||
|
||||
for_each_block_target is_crypt
|
||||
_ret=$?
|
||||
|
||||
[ $_ret -eq 0 ] && return
|
||||
|
||||
return 1
|
||||
for _dev in $(get_kdump_targets); do
|
||||
if [[ -n $(get_luks_crypt_dev "$(get_maj_min "$_dev")") ]]; then
|
||||
derror "Device $_dev is encrypted." && return 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if ! check_resettable; then
|
||||
|
Loading…
Reference in New Issue
Block a user