From a29de38da554ff4e67af6ba52e4739222146ddb8 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Tue, 16 Jun 2020 11:25:26 +0800 Subject: [PATCH] Always wrap up call to dracut get_persistent_dev function Dracut get_persistent_dev function don't recognize UUID= or LABEL= format, so caller should conver it to the path to the block device before calling it. There is already such a helper "kdump_get_persistent_dev", just move it to kdump-lib.sh and rename it to reuse it, Signed-off-by: Kairui Song Acked-by: Dave Young --- dracut-module-setup.sh | 14 -------------- kdump-lib.sh | 14 ++++++++++++++ kdumpctl | 2 +- mkdumprd | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 90f3772..2454463 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -48,20 +48,6 @@ depends() { return 0 } -kdump_get_persistent_dev() { - local dev="${1//\"/}" - - case "$dev" in - UUID=*) - dev=`blkid -U "${dev#UUID=}"` - ;; - LABEL=*) - dev=`blkid -L "${dev#LABEL=}"` - ;; - esac - echo $(get_persistent_dev "$dev") -} - kdump_is_bridge() { [ -d /sys/class/net/"$1"/bridge ] } diff --git a/kdump-lib.sh b/kdump-lib.sh index 74dac4c..6f250d4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -307,6 +307,20 @@ get_option_value() { strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-` } +kdump_get_persistent_dev() { + local dev="${1//\"/}" + + case "$dev" in + UUID=*) + dev=`blkid -U "${dev#UUID=}"` + ;; + LABEL=*) + dev=`blkid -L "${dev#LABEL=}"` + ;; + esac + echo $(get_persistent_dev "$dev") +} + is_atomic() { grep -q "ostree" /proc/cmdline diff --git a/kdumpctl b/kdumpctl index 408b88a..70fb551 100755 --- a/kdumpctl +++ b/kdumpctl @@ -482,7 +482,7 @@ check_dump_fs_modified() if [[ $(expr substr $_new_fstype 1 3) = "nfs" ]];then _new_dev=$_target else - _new_dev=$(get_persistent_dev $_target) + _new_dev=$(kdump_get_persistent_dev $_target) if [ -z "$_new_dev" ]; then echo "Get persistent device name failed" return 2 diff --git a/mkdumprd b/mkdumprd index 7bc1bd1..4b1e11c 100644 --- a/mkdumprd +++ b/mkdumprd @@ -93,7 +93,7 @@ to_mount() { _mntopts="$_new_mntpoint $_fstype $_options" # for non-nfs _target converting to use udev persistent name if [ -b "$_target" ]; then - _pdev="$(get_persistent_dev $_target)" + _pdev="$(kdump_get_persistent_dev $_target)" if [ -z "$_pdev" ]; then return 1 fi @@ -438,7 +438,7 @@ do dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || { perror_exit "Bad raw disk $config_val" } - _praw=$(persistent_policy="by-id" get_persistent_dev $config_val) + _praw=$(persistent_policy="by-id" kdump_get_persistent_dev $config_val) if [ -z "$_praw" ]; then exit 1 fi