kdump-lib.sh: introduce a helper to get all crypt dev used by kdump

Resolves: bz1951415
Upstream: fedora
Conflict: None

commit 1c70cf51c7678499e2d48eec10ad24b839fe9f64
Author: Kairui Song <kasong@redhat.com>
Date:   Tue May 18 16:13:16 2021 +0800

    kdump-lib.sh: introduce a helper to get all crypt dev used by kdump

    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:
Kairui Song 2021-05-18 16:13:16 +08:00
parent ccdd4f2894
commit 8387b514f1
1 changed files with 21 additions and 0 deletions

View File

@ -956,3 +956,24 @@ get_luks_crypt_dev()
get_luks_crypt_dev "$(< "$_x/dev")"
done
}
# kdump_get_maj_min <device>
# Prints the major and minor of a device node.
# Example:
# $ get_maj_min /dev/sda2
# 8:2
kdump_get_maj_min() {
local _majmin
_majmin="$(stat -L -c '%t:%T' "$1" 2> /dev/null)"
printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))"
}
get_all_kdump_crypt_dev()
{
local _dev _crypt
for _dev in $(get_block_dump_target); do
_crypt=$(get_luks_crypt_dev $(kdump_get_maj_min "$_dev"))
[[ -n "$_crypt" ]] && echo $_crypt
done
}