[kexec-tools/f20] kdump-lib.sh: introduce two functions abstracted from get_block_dump_target for reuse

WANG Chao wangchao at fedoraproject.org
Mon Mar 10 05:54:22 UTC 2014


commit cfcd4882829826d305a2b8bffa9a316fbb061c9d
Author: Baoquan He <bhe at redhat.com>
Date:   Mon Mar 3 18:37:14 2014 +0800

    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 at redhat.com>
    Acked-by: Vivek Goyal <vgoyal at redhat.com>

 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)
 }
 


More information about the scm-commits mailing list