From fedeba5e4ba2a6b45b442b9386cc9f02496d707c Mon Sep 17 00:00:00 2001 From: Minfei Huang Date: Fri, 10 Apr 2015 16:18:57 +0800 Subject: [PATCH] Remove duplicate slash in save path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now kdump cannt parse the path correctly, if the path contains duplicated "/". Following is an example to explain it detail. (the directory /mnt is a mount point which is mounted a block device) path //mnt/var/crash Then the warning will raise. Force rebuild /boot/initramfs-3.19.1kdump.img Rebuilding /boot/initramfs-3.19.1kdump.img df: ‘/mnt///mnt/var/crash’: No such file or directory /sbin/mkdumprd: line 239: [: -lt: unary operator expected kexec: loaded kdump kernel Starting kdump: [OK] For above case, kdump fails to check the fs size, due to the incorrect path. In kdump code flow, we will cut out the mount point(/mnt) from the path(//mnt/var/crash). But the mount point cannt match the path, because of the duplicated "/". To fix it, we will strip the duplicated "/" firstly. Signed-off-by: Minfei Huang Acked-by: Dave Young Acked-by: Baoquan He --- dracut-module-setup.sh | 11 ++++++----- mkdumprd | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4641025..540e154 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -311,15 +311,17 @@ kdump_install_net() { default_dump_target_install_conf() { local _target _fstype - local _s _t local _mntpoint - local _path _save_path + local _save_path is_user_configured_dump_target && return _save_path=$(get_option_value "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) _target=$(get_target_from_path $_save_path) if [ "$_mntpoint" != "/" ]; then @@ -334,13 +336,12 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf - _path=${_save_path##"$_mntpoint"} + _save_path=${_save_path##"$_mntpoint"} #erase the old path line, then insert the parsed path sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf - echo "path $_path" >> ${initdir}/tmp/$$-kdump.conf + echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf fi - } #install kdump.conf and what user specifies in kdump.conf diff --git a/mkdumprd b/mkdumprd index 4d251ba..7c572a7 100644 --- a/mkdumprd +++ b/mkdumprd @@ -13,6 +13,9 @@ conf_file="/etc/kdump.conf" SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2) [ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH +# strip the duplicated "/" +SAVE_PATH=$(echo $SAVE_PATH | tr -s /) + extra_modules="" dracut_args=("--hostonly" "-o" "plymouth dash resume") OVERRIDE_RESETTABLE=0