]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
move get_persistent_dev to dracut-functions.sh
authorDave Young <dyoung@redhat.com>
Mon, 10 Sep 2012 08:10:46 +0000 (16:10 +0800)
committerHarald Hoyer <harald@redhat.com>
Mon, 10 Sep 2012 13:50:36 +0000 (15:50 +0200)
kdump module also need to convert dev name to udev symlinks.
So better to move function get_persistent_dev() to dracut-functions.sh

Also in this patch improvement and fix the original function:
a) use udevadm info --query=name to get the kernel name.
   This will fix the issue caused by passing symbolic link of a device.
b) fix a bug to compare $_tmp instead of $i with $_dev. Really sorry,
   should have tested more carefully.

Signed-off-by: Dave Young <dyoung@redhat.com>
dracut-functions.sh
modules.d/99base/module-setup.sh

index 2399a1dac19e4a4fd3551f05ce4b18622ff10691..e6200c265189173f70b70afa0fd107fb9ebba575 100755 (executable)
@@ -239,6 +239,21 @@ else
     }
 fi
 
+get_persistent_dev() {
+    local i _tmp _dev
+
+    _dev=$(udevadm info --query=name --name="$1" 2>/dev/null)
+    [ -z "$_dev" ] && return
+
+    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
+}
+
 # get_fs_env <device>
 # Get and set the ID_FS_TYPE and ID_FS_UUID variable from udev for a device.
 # Example:
index 8a18100720aec3f295d48f1e0ac80bb6693f03dd..115b544636181f9ee570a18d82d5f8277d662739 100755 (executable)
@@ -11,19 +11,6 @@ depends() {
     return 0
 }
 
-get_persistent_dev() {
-    local i _tmp
-    local _dev=${1##*/}
-
-    for i in /dev/disk/by-id/*; do
-        _tmp=$(readlink $i)
-        if [ "$i" = "$_dev" ]; then
-            echo $i
-            return
-        fi
-    done
-}
-
 install() {
     local _d
     dracut_install mount mknod mkdir pidof sleep chroot \