For user specified target, the config value is used as the dump target,
and SAVE_PATH (path in kdump.conf) value is used as the dump path within
the dump target, no need to do anything extra with the path value.
Current code logic is not only complicated, it also wrongly generate
an redundantly long path in atomic/silverblue enviroment.
The right way is only check two things, and do nothing else:
1. The path exists within the target;
2. The target is large engouth to hold to contain the vmcore.
Currently checking the target still requires it to be mounted so it will
error out if it's not mounted. Will implement some auto mount as next
step.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
kdump-lib.sh | 29 +++++++++--------------------
mkdumprd | 15 ++++-----------
2 files changed, 13 insertions(+), 31 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index ea41d0c..f3ee95d 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -310,26 +310,6 @@ get_option_value() {
strip_comments `grep "^$1[[:space:]]\+" /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)
- _mnt="${_mnt}/$SAVE_PATH"
-
- # strip the duplicated "/"
- echo "$_mnt" | tr -s /
-}
-
check_save_path_fs()
{
local _path=$1
@@ -339,6 +319,15 @@ check_save_path_fs()
fi
}
+# Check if path exists within dump target
+check_save_path_user_configured()
+{
+ local _target=$1 _path=$2
+ local _mnt=$(get_mntpoint_from_target $_target)
+
+ check_save_path_fs "$_mnt/$_path"
+}
+
is_atomic()
{
grep -q "ostree" /proc/cmdline
diff --git a/mkdumprd b/mkdumprd
index d86d9b5..a32cead 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -377,20 +377,13 @@ do
perror_exit "Dump target $config_val is probably not mounted."
fi
- _absolute_save_path=$(make_absolute_save_path $config_val)
- _mntpoint=$(get_mntpoint_from_path $_absolute_save_path)
- if is_atomic && is_bind_mount $_mntpoint; then
- SAVE_PATH=${_absolute_save_path##"$_mntpoint"}
- # the real dump path in the 2nd kernel, if the mount point is bind mounted.
- SAVE_PATH=$(get_bind_mount_directory $_mntpoint)/$SAVE_PATH
- fi
-
+ # User configured target, use $SAVE_PATH as the dump path within the target
+ check_save_path_user_configured "$config_val" "$SAVE_PATH"
+ check_size fs "$config_val"
add_mount "$config_val"
- check_save_path_fs $_absolute_save_path
- check_size fs $config_val
;;
raw)
- #checking raw disk writable
+ # checking raw disk writable
dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || {
perror_exit "Bad raw disk $config_val"
}
--
2.24.1