[kexec-tools/f18] mkdumprd: add function get_persistent_dev

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


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

    mkdumprd: add function get_persistent_dev
    
    Copy the function get_persistent_dev from dracut for us to handle the
    persistent name issues.
    [vivek] add error handling for get_persistent_dev
    
    Signed-off-by: Dave Young <dyoung at redhat.com>
    Acked-by: Vivek Goyal <vgoyal at redhat.com>

 mkdumprd |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/mkdumprd b/mkdumprd
index c2c6116..fbe7f67 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -15,6 +15,27 @@ SAVE_PATH=$(grep ^path $conf_file| cut -d' '  -f2)
 extra_modules=""
 dracut_args=("--hostonly" "-o" "plymouth dash")
 
+get_persistent_dev() {
+    local i _tmp _dev
+
+    _dev=$(udevadm info --query=name --name="$1" 2>/dev/null)
+    [ -z "$_dev" ] && {
+        echo "Kernel dev name of $1 is not found."
+        exit 1
+    }
+
+    for i in /dev/disk/by-id/*; do
+        _tmp=$(udevadm info --query=name --name="$i" 2>/dev/null)
+        if [ "$_tmp" = "$_dev" ]; then
+            echo $i
+            return
+        fi
+    done
+
+    echo "Persistent device name of $1 is not found."
+    exit 1
+}
+
 add_dracut_arg() {
     while [ $# -gt 0 ];
     do


More information about the scm-commits mailing list