Always use get_save_path to get the 'path' option

This help deduplicate the code. Use a single function instead of
repeat the same logic.

Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
This commit is contained in:
Kairui Song 2019-11-30 23:46:55 +08:00
parent d10f202996
commit 03111c797b
2 changed files with 7 additions and 17 deletions

View File

@ -428,12 +428,7 @@ default_dump_target_install_conf()
is_user_configured_dump_target && return is_user_configured_dump_target && return
_save_path=$(get_option_value "path") _save_path=$(get_save_path)
[ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
# strip the duplicated "/"
_save_path=$(echo $_save_path | tr -s /)
_mntpoint=$(get_mntpoint_from_path $_save_path) _mntpoint=$(get_mntpoint_from_path $_save_path)
_target=$(get_target_from_path $_save_path) _target=$(get_target_from_path $_save_path)
@ -472,13 +467,9 @@ default_dump_target_install_conf()
adjust_bind_mount_path() adjust_bind_mount_path()
{ {
local _target=$1 local _target=$1
local _save_path=$(get_option_value "path") local _save_path=$(get_save_path)
[ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
# strip the duplicated "/"
_save_path=$(echo $_save_path | tr -s /)
local _absolute_save_path=$(get_mntpoint_from_target $_target)/$_save_path local _absolute_save_path=$(get_mntpoint_from_target $_target)/$_save_path
_absolute_save_path=$(echo "$_absolute_save_path" | tr -s /) _absolute_save_path=$(echo "$_absolute_save_path" | tr -s /)
local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path) local _mntpoint=$(get_mntpoint_from_path $_absolute_save_path)

View File

@ -127,11 +127,10 @@ get_root_fs_device()
get_save_path() get_save_path()
{ {
local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}') local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}')
if [ -z "$_save_path" ]; then [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
_save_path=$DEFAULT_PATH
fi
echo $_save_path # strip the duplicated "/"
echo $(echo $_save_path | tr -s /)
} }
get_block_dump_target() get_block_dump_target()