[kexec-tools] use findmnt instead of blkid in mkdumprd
Baoquan He
baoquan at fedoraproject.org
Thu Mar 14 02:43:37 UTC 2013
commit 4b9c868b8de57d49aad822f386945c01e8f2ddfe
Author: dyoung at redhat.com <dyoung at redhat.com>
Date: Tue Mar 5 16:07:35 2013 +0800
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 at redhat.com>
Reviewed-by: Caspar Zhang <czhang at redhat.com>
Acked-by: Baoquan He <bhe at redhat.com>
mkdumprd | 32 ++++++++++----------------------
1 files changed, 10 insertions(+), 22 deletions(-)
---
diff --git a/mkdumprd b/mkdumprd
index af630c2..719e6f2 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -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"
More information about the scm-commits
mailing list