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>
This commit is contained in:
parent
1c70cf51c7
commit
85c725813b
32
mkdumprd
32
mkdumprd
@ -325,7 +325,6 @@ get_override_resettable()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# $1: function name
|
# $1: function name
|
||||||
for_each_block_target()
|
for_each_block_target()
|
||||||
{
|
{
|
||||||
@ -340,8 +339,6 @@ for_each_block_target()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#judge if a specific device with $1 is unresettable
|
#judge if a specific device with $1 is unresettable
|
||||||
#return false if unresettable.
|
#return false if unresettable.
|
||||||
is_unresettable()
|
is_unresettable()
|
||||||
@ -378,32 +375,15 @@ check_resettable()
|
|||||||
return 1
|
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()
|
check_crypt()
|
||||||
{
|
{
|
||||||
local _ret _target
|
local _dev
|
||||||
|
|
||||||
for_each_block_target is_crypt
|
for _dev in $(get_kdump_targets); do
|
||||||
_ret=$?
|
if [[ -n $(get_luks_crypt_dev "$(get_maj_min "$_dev")") ]]; then
|
||||||
|
derror "Device $_dev is encrypted." && return 1
|
||||||
[ $_ret -eq 0 ] && return
|
fi
|
||||||
|
done
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! check_resettable; then
|
if ! check_resettable; then
|
||||||
|
Loading…
Reference in New Issue
Block a user