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:
parent
b4b0a27d8a
commit
4b9c868b8d
32
mkdumprd
32
mkdumprd
@ -59,35 +59,23 @@ add_dracut_sshkey() {
|
|||||||
# Generic substring function. If $2 is in $1, return 0.
|
# Generic substring function. If $2 is in $1, return 0.
|
||||||
strstr() { [[ $1 =~ $2 ]]; }
|
strstr() { [[ $1 =~ $2 ]]; }
|
||||||
|
|
||||||
to_dev_name() {
|
target_is_root() {
|
||||||
local dev="$1"
|
local _t
|
||||||
|
_t=$(findmnt -k -n -r -o TARGET $1|sort|head -1)
|
||||||
case "$dev" in
|
[ "$_t" = "/" ]
|
||||||
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}'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_mount() {
|
to_mount() {
|
||||||
local _dev _t _o _mntopts _pdev
|
local _dev=$1 _s _t _o _mntopts _pdev
|
||||||
_dev=$(to_dev_name $1)
|
_s=$(findmnt -k -f -n -r -o SOURCE $_dev)
|
||||||
_t=$(findmnt -k -f -n -r -o TARGET,FSTYPE $_dev)
|
_t=$(findmnt -k -f -n -r -o TARGET,FSTYPE $_dev)
|
||||||
_o=$(findmnt -k -f -n -r -o OPTIONS $_dev)
|
_o=$(findmnt -k -f -n -r -o OPTIONS $_dev)
|
||||||
[ -z "$_t" -o -z "$_o" ] && return
|
[ -z "$_t" -o -z "$_o" ] && return
|
||||||
_o=${_o/#ro/rw} #mount fs target as rw in 2nd kernel
|
_o=${_o/#ro/rw} #mount fs target as rw in 2nd kernel
|
||||||
_mntopts="$_t $_o"
|
_mntopts="$_t $_o"
|
||||||
#for non-nfs _dev converting to use udev persistent name
|
#for non-nfs _dev converting to use udev persistent name
|
||||||
if [ -b "$_dev" ]; then
|
if [ -b "$_s" ]; then
|
||||||
_pdev="$(get_persistent_dev $_dev)"
|
_pdev="$(get_persistent_dev $_s)"
|
||||||
else
|
else
|
||||||
_pdev=$_dev
|
_pdev=$_dev
|
||||||
fi
|
fi
|
||||||
@ -222,9 +210,9 @@ verify_core_collector() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
add_mount() {
|
add_mount() {
|
||||||
local _dev=$(to_dev_name "$1")
|
|
||||||
local _mnt=$(to_mount "$1")
|
local _mnt=$(to_mount "$1")
|
||||||
if [ "$_dev" = "$(get_rootdev)" ]; then
|
|
||||||
|
if target_is_root "$1"; then
|
||||||
:
|
:
|
||||||
elif [ -n "$_mnt" ]; then
|
elif [ -n "$_mnt" ]; then
|
||||||
add_dracut_mount "$_mnt"
|
add_dracut_mount "$_mnt"
|
||||||
|
Loading…
Reference in New Issue
Block a user