adding the parsed path to etc/kdump.conf of kdump initrd

Steve found a bug. When mount a disk in /var and not specify path
in /etc/kdump.conf, the vmcore will be dumped into /var/crash of
that disk, but not /crash on that disk.

This is because when write the parsed path into /tmp/$$-kdump.conf
in default_dump_target_install_conf() of mkdumprd, it uses below
sed command. So if no path specified at all, this sed command won't
add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default
path, namely "/var/crash" as path if no path in /etc/kdump.conf in
2nd kernel.

    sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf

According to Dave Young's suggestion, erase the old path line and then
insert the parsed path. This can fix it.

v2->v3:
    erase the old path line and then insert the parsed path.

    sed -i -e "s#^path[[:space:]]\+$_save_path##" /tmp/$$-kdump.conf
    echo "path $_path" >> /tmp/$$-kdump.conf

v3->v4:
    Change the sed pattern, erase lines starting with "path" and then
    insert the parsed path.

    sed -i -e "s#^path.*##" /tmp/$$-kdump.conf
    echo "path $_path" >> /tmp/$$-kdump.conf

v4->v5:
    Chaowang suggested using sed command d to remove the whole line
    like below:
    sed -i "/^path/d" /tmp/$$-kdump.conf
    echo "path $_path" >> /tmp/$$-kdump.conf

Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: WANG Chao <chaowang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
Baoquan He 2014-12-31 10:48:59 +08:00 committed by WANG Chao
parent 1c9362c10d
commit 1a8a39aa9c

View File

@ -331,7 +331,10 @@ default_dump_target_install_conf()
echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
#erase the old path line, then insert the parsed path
sed -i "/^path/d" /tmp/$$-kdump.conf
echo "path $_path" >> /tmp/$$-kdump.conf
fi
}