use findmnt instead of blkid in mkdumprd

Previously to_dev_name use blkid to get dev name from dump target,
but blkid can not handle UUID/LABEL with quotes so to_dev_name will
silently fail.

Because we enforce dump target being mounted before creating kdump
initrd, so change to use findmnt is fine. findmnt can handle input
params with quotes.

to_dev_name is not necessary anymore, just remove it.
Also there's another user of it is for checking if the dev is root
or not, here change to use findmnt for this as well.

Tested the rootfs dump, UUID with/without quotes dump.

Signed-off-by: Dave Young <dyoung@redhat.com>
Reviewed-by: Caspar Zhang <czhang@redhat.com>
Acked-by: Baoquan He <bhe@redhat.com>
This commit is contained in:
dyoung@redhat.com 2013-03-05 16:07:35 +08:00 committed by Baoquan He
parent b4b0a27d8a
commit 4b9c868b8d

View File

@ -59,35 +59,23 @@ add_dracut_sshkey() {
# Generic substring function. If $2 is in $1, return 0.
strstr() { [[ $1 =~ $2 ]]; }
to_dev_name() {
local dev="$1"
case "$dev" in
UUID=*)
dev=`blkid -U "${dev#UUID=}"`
;;
LABEL=*)
dev=`blkid -L "${dev#LABEL=}"`
;;
esac
echo $dev
}
get_rootdev() {
mount | grep 'on / ' | grep -v rootfs | awk '{print $1}'
target_is_root() {
local _t
_t=$(findmnt -k -n -r -o TARGET $1|sort|head -1)
[ "$_t" = "/" ]
}
to_mount() {
local _dev _t _o _mntopts _pdev
_dev=$(to_dev_name $1)
local _dev=$1 _s _t _o _mntopts _pdev
_s=$(findmnt -k -f -n -r -o SOURCE $_dev)
_t=$(findmnt -k -f -n -r -o TARGET,FSTYPE $_dev)
_o=$(findmnt -k -f -n -r -o OPTIONS $_dev)
[ -z "$_t" -o -z "$_o" ] && return
_o=${_o/#ro/rw} #mount fs target as rw in 2nd kernel
_mntopts="$_t $_o"
#for non-nfs _dev converting to use udev persistent name
if [ -b "$_dev" ]; then
_pdev="$(get_persistent_dev $_dev)"
if [ -b "$_s" ]; then
_pdev="$(get_persistent_dev $_s)"
else
_pdev=$_dev
fi
@ -222,9 +210,9 @@ verify_core_collector() {
}
add_mount() {
local _dev=$(to_dev_name "$1")
local _mnt=$(to_mount "$1")
if [ "$_dev" = "$(get_rootdev)" ]; then
if target_is_root "$1"; then
:
elif [ -n "$_mnt" ]; then
add_dracut_mount "$_mnt"