Return LUKS devices in the form of UUIDs directly
Resolves: https://issues.redhat.com/browse/RHEL-104940 Conflict: None commit 9980a416759c58e67a206525ddb82d581932c3ad Author: Coiby Xu <coxu@redhat.com> Date: Tue Sep 16 11:52:00 2025 +0800 Return LUKS devices in the form of UUIDs directly So the callers of kdump_check_crypt_targets don't need to convert the result into UUIDs. Signed-off-by: Coiby Xu <coxu@redhat.com> Signed-off-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
parent
8a045edc52
commit
936e845423
@ -1146,7 +1146,7 @@ remove_cpu_online_rule() {
|
||||
}
|
||||
|
||||
kdump_check_crypt_targets() {
|
||||
local _luks_dev _devuuid _key_desc
|
||||
local _devuuid _key_desc
|
||||
declare -a _luks_devs
|
||||
|
||||
mapfile -t _luks_devs < <(get_all_kdump_crypt_dev)
|
||||
@ -1175,8 +1175,7 @@ kdump_check_crypt_targets() {
|
||||
# shellcheck disable=SC2154
|
||||
mkdir -p "$hookdir/initqueue/finished"
|
||||
CRYPTSETUP_PATH=$(command -v cryptsetup)
|
||||
for _luks_dev in "${_luks_devs[@]}"; do
|
||||
_devuuid=$(maj_min_to_uuid "$_luks_dev")
|
||||
for _devuuid in "${_luks_devs[@]}"; do
|
||||
_key_desc=$LUKS_KEY_PRFIX$_devuuid
|
||||
cat << EOF >> "${initdir}/etc/udev/rules.d/70-luks-kdump.rules"
|
||||
ENV{ID_FS_UUID}=="$_devuuid", \
|
||||
|
||||
14
kdump-lib.sh
14
kdump-lib.sh
@ -1210,7 +1210,12 @@ kdump_get_arch_recommend_size()
|
||||
get_recommend_size "$_sys_mem" "$_ck_cmdline"
|
||||
}
|
||||
|
||||
# Print all underlying crypt devices of a block device
|
||||
maj_min_to_uuid()
|
||||
{
|
||||
lsblk -no uuid,MAJ:MIN | awk -v dev="$1" 'NF==2 && $2 == dev {print $1}'
|
||||
}
|
||||
|
||||
# Print all underlying crypt devices (UUID) of a block device
|
||||
# print nothing if device is not on top of a crypt device
|
||||
# $1: the block device to be checked in maj:min format
|
||||
get_luks_crypt_dev()
|
||||
@ -1221,7 +1226,7 @@ get_luks_crypt_dev()
|
||||
|
||||
_type=$(blkid -u filesystem,crypto -o export -- "/dev/block/$1" | \
|
||||
sed -n -E "s/^TYPE=(.*)$/\1/p")
|
||||
[[ $_type == "crypto_LUKS" ]] && echo "$1"
|
||||
[[ $_type == "crypto_LUKS" ]] && maj_min_to_uuid "$1"
|
||||
|
||||
for _x in "/sys/dev/block/$1/slaves/"*; do
|
||||
[[ -f $_x/dev ]] || continue
|
||||
@ -1230,11 +1235,6 @@ get_luks_crypt_dev()
|
||||
done
|
||||
}
|
||||
|
||||
maj_min_to_uuid()
|
||||
{
|
||||
lsblk -no uuid,MAJ:MIN | awk -v dev="$1" 'NF==2 && $2 == dev {print $1}'
|
||||
}
|
||||
|
||||
# kdump_get_maj_min <device>
|
||||
# Prints the major and minor of a device node.
|
||||
# Example:
|
||||
|
||||
5
kdumpctl
5
kdumpctl
@ -1092,7 +1092,7 @@ _get_luks_key_by_unlock()
|
||||
|
||||
prepare_luks()
|
||||
{
|
||||
local _luks_dev _key_id _key_des _luks_unlock_cmd
|
||||
local _key_id _key_des _luks_unlock_cmd
|
||||
declare -a _luks_devs
|
||||
|
||||
mapfile -t _luks_devs < <(get_all_kdump_crypt_dev)
|
||||
@ -1109,8 +1109,7 @@ prepare_luks()
|
||||
# For the case of CPU/memory hotplugging, we can reuse loaded keys
|
||||
[[ $(cat $LUKS_CONFIGFS/reuse) == 1 ]] && return 0
|
||||
|
||||
for _luks_dev in "${_luks_devs[@]}"; do
|
||||
_devuuid=$(maj_min_to_uuid "$_luks_dev")
|
||||
for _devuuid in "${_luks_devs[@]}"; do
|
||||
_key_dir=$LUKS_CONFIGFS/$_devuuid
|
||||
_key_des=$LUKS_KEY_PRFIX$_devuuid
|
||||
if _key_id=$(keyctl request logon "$_key_des" 2> /dev/null); then
|
||||
|
||||
Loading…
Reference in New Issue
Block a user