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(a)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?
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.
+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(a)lists.fedoraproject.org
https://lists.fedoraproject.org/mailman/listinfo/kexec