On Mon, Mar 03, 2014 at 06:37:14PM +0800, Baoquan He wrote:
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(a)redhat.com>
This patch looks good to me.
Acked-by: Vivek Goyal <vgoyal(a)redhat.com>
Thanks
Vivek
---
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)
}
--
1.8.3.1