[Patch v5 2/6] user need make sure "path" on mounted fs has been created

Baoquan He bhe at redhat.com
Mon Mar 31 07:17:02 UTC 2014


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 <bhe at redhat.com>
---
 kdump-lib.sh | 26 ++++++++++++++++++++++++++
 mkdumprd     | 33 +--------------------------------
 2 files changed, 27 insertions(+), 32 deletions(-)

diff --git a/kdump-lib.sh b/kdump-lib.sh
index bf57a91..cf2474a 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -96,3 +96,29 @@ get_mntpoint_from_target()
     echo $(findmnt -k -f -n -r -o TARGET $1)
 }
 
+#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)
-- 
1.8.5.3



More information about the kexec mailing list