[kexec-tools/f18] pass persistent name to dracut --mount

Dave Young yangrr at fedoraproject.org
Thu Sep 20 03:08:38 UTC 2012


commit 9d161703a6fcf566180a4302e646e56b3cca8af2
Author: Dave Young <dyoung at redhat.com>
Date:   Thu Sep 20 11:03:19 2012 +0800

    pass persistent name to dracut --mount
    
    currently --mount param are retrieved from /proc/mounts, but the device
    name could be renamed in initramfs. So here convert them to persistent
    names before passing to dracut
    
    lvm canonical dev name is /dev/mapper/lvname-link which will be showed
    in /proc/mounts
    here fix get_mp function by using findmnt utils to find the mount point.
    
    This patch depends on below dracut patch:
    http://permalink.gmane.org/gmane.linux.kernel.initramfs/2903
    
    [chaowang]:
    in case device is not mounted we should not echo the mount line in to_mount()
    use findmnt -n to strip the header line
    for nfs don't pass persistent name to dracut
    [vivek]:
    improve variable names
    
    Signed-off-by: Dave Young <dyoung at redhat.com>
    Acked-by: Vivek Goyal <vgoyal at redhat.com>

 dracut-kdump.sh |   16 +---------------
 mkdumprd        |   17 +++++++++++++----
 2 files changed, 14 insertions(+), 19 deletions(-)
---
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 8828472..2999073 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -53,23 +53,9 @@ add_dump_code()
     DUMP_INSTRUCTION=$1
 }
 
-get_mp()
-{
-    local _mp
-    local dev mp fs opts rest
-    while read dev mp fs opts rest; do
-        if [ "$dev" = "$1" ]; then
-            _mp="$mp"
-            break
-        fi
-    done < /proc/mounts
-    echo "$_mp"
-}
-
 dump_fs()
 {
-    local _dev=$1
-    local _mp=`get_mp $_dev`
+    local _mp=$(findmnt -k -f -n -r -o TARGET $1)
 
     if [ -z "$_mp" ]; then
         echo "kdump: error: Dump target $1 is not mounted."
diff --git a/mkdumprd b/mkdumprd
index fbe7f67..43e4689 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -78,13 +78,22 @@ get_rootdev() {
 }
 
 to_mount() {
-    local _dev=$(to_dev_name $1)
-    echo "$(grep "$_dev" /proc/mounts | cut -d' ' -f1-4)"
+    local _dev _mntopts _pdev
+    _dev=$(to_dev_name $1)
+    _mntopts=$(findmnt -k -f -n -r -o TARGET,FSTYPE,OPTIONS $_dev)
+    [ -z "$_mntopts" ] && return
+    #for non-nfs _dev converting to use udev persistent name
+    if [ -b "$_dev" ]; then
+        _pdev="$(get_persistent_dev $_dev)"
+    else
+        _pdev=$_dev
+    fi
+
+    echo "$_pdev $_mntopts"
 }
 
 to_mount_point() {
-    local _dev=$(to_dev_name $1)
-    echo "$(grep "$_dev" /proc/mounts | cut -d' ' -f2)"
+    echo $(findmnt -k -f -n -r -o TARGET $1)
 }
 
 #Function: get_ssh_size


More information about the scm-commits mailing list