kdump-lib.sh: introduce two functions abstracted from get_block_dump_target for reuse

In function get_block_dump_target(), code block to get user configured
dump disk and get root fs device can be reused by other places. Now
abstract and wrap them into 2 new functions:

get_user_configured_dump_disk()
get_root_fs_device()

And put them into kdump-lib.sh.

Meanwhile change the get_block_dump_target() accordingly.

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
This commit is contained in:
Baoquan He 2014-03-03 18:37:14 +08:00 committed by WANG Chao
parent 3b9a0140cb
commit 8c527aba43
2 changed files with 26 additions and 5 deletions

View File

@ -37,3 +37,27 @@ is_fence_kdump()
# fence kdump not configured?
(pcs cluster cib | grep -q 'type="fence_kdump"') &> /dev/null || return 1
}
get_user_configured_dump_disk()
{
local _target
if is_ssh_dump_target || is_nfs_dump_target; then
return
fi
_target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf 2>/dev/null |awk '{print $2}')
[ -n "$_target" ] && echo $_target
return
}
get_root_fs_device()
{
local _target
_target=$(findmnt -k -f -n -o SOURCE /)
[ -n "$_target" ] && echo $_target
return
}

View File

@ -346,15 +346,12 @@ get_block_dump_target()
{
local _target
if is_ssh_dump_target || is_nfs_dump_target; then
return
fi
_target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf 2>/dev/null |awk '{print $2}')
_target=$(get_user_configured_dump_disk)
[ -n "$_target" ] && echo $(to_dev_name $_target) && return
#get rootfs device name
_target=$(findmnt -k -f -n -o SOURCE /)
_target=$(get_root_fs_device)
[ -b "$_target" ] && echo $(to_dev_name $_target)
}