On 03/26/15 at 04:10pm, Baoquan He wrote:
On 03/04/15 at 01:07am, Minfei Huang wrote:
It fails to cut out the substring, if the string contains duplicated "/".
Add the new function which it will get the path accurately.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 7 +++---- kdump-lib.sh | 22 ++++++++++++++++++++++ mkdumprd | 2 +- 3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 4641025..477ede1 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -311,9 +311,8 @@ 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
@@ -334,11 +333,11 @@ default_dump_target_install_conf()
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
_save_path=$(cut_out_substring $_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
Hi Minfei,
Do you remember what's wrong with the duplicate "/"? Why does't it matter in old code?
Kdump may fails in the case that we specify the path as "//mnt/var/crash", and mount the device on the point "/mnt". Following is the example.
1) set path=/mnt/var/crash, kdump works well. [root@localhost 99kdumpbase]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Force rebuild /boot/initramfs-3.11.10-301.fc20.x86_64kdump.img Rebuilding /boot/initramfs-3.11.10-301.fc20.x86_64kdump.img + _path=/var/crash + set +x kexec: loaded kdump kernel Starting kdump: [OK]
2) set path=//mnt/var/crash, the target path is incorrect in 2nd kernel. [root@localhost 99kdumpbase]# kdumpctl restart kexec: unloaded kdump kernel Stopping kdump: [OK] Force rebuild /boot/initramfs-3.11.10-301.fc20.x86_64kdump.img Rebuilding /boot/initramfs-3.11.10-301.fc20.x86_64kdump.img df: ‘/mnt///mnt/var/crash’: No such file or directory /sbin/mkdumprd: line 239: [: -lt: unary operator expected + _path=//mnt/var/crash + set +x kexec: loaded kdump kernel Starting kdump: [OK]
Since the /mnt is the mount point, the correct path is /var/crash.
fi
} diff --git a/kdump-lib.sh b/kdump-lib.sh index f24f08d..b6dcea0 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -188,3 +188,25 @@ is_ipv6_target() _server=${_server:-$_server_tmp} echo $_server | grep -q ":" }
+# fail to cut out the path, if the path contains duplicated "/"
This function is not good. I suggest using one line of sed command to do this. This kind of process looks weird.
I will investigate it, if there is a better way to deal it.
Thanks Minfei
+cut_out_substring() +{
- local _prefix_tmp="${initdir}/tmp/$$-kdump-dir"
- local _main_str=$_prefix_tmp/$1 _sub_str=$_prefix_tmp/$2 _pwd=`pwd`
- mkdir -p $_main_str
- mkdir -p $_sub_str
- cd $_main_str
- _main_str=`pwd`
- cd $_sub_str
- _sub_str=`pwd`
- cd $_pwd
- rm -rf $_prefix_tmp
- _main_str=${_main_str#*"$_prefix_tmp"}
- _sub_str=${_sub_str#*"$_prefix_tmp"}
- echo ${_main_str#*"$_sub_str"}
+} diff --git a/mkdumprd b/mkdumprd index 4d251ba..a8f9cbb 100644 --- a/mkdumprd +++ b/mkdumprd @@ -364,7 +364,7 @@ handle_default_dump_target() _mntpoint=$(get_mntpoint_from_path $SAVE_PATH) _target=$(get_target_from_path $SAVE_PATH) if [ "$_mntpoint" != "/" ]; then
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
SAVE_PATH=$(cut_out_substring $SAVE_PATH $_mntpoint) _fstype=$(get_fs_type_from_target $_target) if $(is_fs_type_nfs $_fstype); then
-- 1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec