From b2429dbd3d301a94c1f7f476cd2fab423a0bc8d4 Mon Sep 17 00:00:00 2001 From: Baoquan He Date: Fri, 11 Apr 2014 20:27:00 +0800 Subject: [PATCH] user need make sure "path" on mounted fs has been created kdump need create the dir specified in "path" formerly if it does not exist. Now change the behavior to be that ueser takes charge of the "path", make sure "path" has been created, especially when separate disk is mounted on this "path". Also introduce 2 helper functions to help check the existence of path. Signed-off-by: Baoquan He Acked-by: Vivek Goyal --- kdump-lib.sh | 26 ++++++++++++++++++++++++++ mkdumprd | 33 +-------------------------------- 2 files changed, 27 insertions(+), 32 deletions(-) diff --git a/kdump-lib.sh b/kdump-lib.sh index e20197e..c629af8 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -116,3 +116,29 @@ get_option_value() { echo $(strip_comments `grep ^$1 /etc/kdump.conf | tail -1 | cut -d\ -f2-`) } +#This function compose a absolute path with the mount +#point and the relative $SAVE_PATH. +#target is passed in as argument, could be UUID, LABEL, +#block device or even nfs server export of the form of +#"my.server.com:/tmp/export"? +#And possibly this could be used for both default case +#as well as when dump taret is specified. When dump +#target is not specified, then $target would be null. +make_absolute_save_path() +{ + local _target=$1 + local _mnt + + [ -n $_target ] && _mnt=$(get_mntpoint_from_target $1) + echo "${_mnt}/$SAVE_PATH" +} + +check_save_path_fs() +{ + local _path=$1 + + if [ ! -d $_path ]; then + perror_exit "Dump path $_path does not exist." + fi +} + diff --git a/mkdumprd b/mkdumprd index 3849866..adf9167 100644 --- a/mkdumprd +++ b/mkdumprd @@ -173,37 +173,6 @@ mkdir_save_path_ssh() return 0 } - -#mkdir if save path does not exist on dump target filesystem -#$1=dump target -#caller should ensure $1 is mounted -mkdir_save_path_fs() { - local _mnt=$(to_mount_point $1) - local _remount="no" - local _ret - - [ ! -d ${_mnt}/$SAVE_PATH ] && { - if is_readonly_mount $1; then - echo "Mounting $1 as read-write for creating dump directory.." - mount -o remount,rw $1 || { - perror_exit "Mounting $1 as read-write failed." - } - _remount="yes" - fi - mkdir -p ${_mnt}/$SAVE_PATH - _ret=$? - [ "$_remount" = "yes" ] && { - echo "Remounting $1 as read-only." - mount -o remount,ro $1 || { - perror_exit "Remounting $1 as read-only failed." - } - } - [ $_ret -ne 0 ] && { - perror_exit "Creating ${_mnt}/$SAVE_PATH failed." - } - } -} - #Function: get_fs_size #$1=dump target get_fs_size() { @@ -538,7 +507,7 @@ do add_dracut_module "nfs" fi add_mount "$config_val" - mkdir_save_path_fs $config_val + check_save_path_fs $(make_absolute_save_path $config_val) check_size fs $config_val ;; raw)