From 8c527aba43083b3254385a3b568e92555957027b Mon Sep 17 00:00:00 2001 From: Baoquan He Date: Mon, 3 Mar 2014 18:37:14 +0800 Subject: [PATCH] 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 Acked-by: Vivek Goyal --- kdump-lib.sh | 24 ++++++++++++++++++++++++ mkdumprd | 7 ++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index aac0c5f..384f7b4 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -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 +} + diff --git a/mkdumprd b/mkdumprd index 6797791..0b71391 100644 --- a/mkdumprd +++ b/mkdumprd @@ -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) }