mkinitrd unification across distributions
 help / color / mirror / Atom feed
* [PATCH] dracut-gencmdline: use udevadm info to go from /dev/X to /sys/Y
@ 2009-10-29  9:29 Alan Jenkins
       [not found] ` <4AE9606C.1090008-cCz0Lq7MMjm9FHfhHBbuYA@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Jenkins @ 2009-10-29  9:29 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Avoid some manual spelunking in sysfs.  This makes for slightly shorter
and simpler code.

diff --git a/dracut-gencmdline b/dracut-gencmdline
index 625546c..a4e2c3d 100755
--- a/dracut-gencmdline
+++ b/dracut-gencmdline
@@ -169,17 +169,20 @@ resolve_device_name() {
     echo "$1" 
 }
 
+finddevinsys() {
+    path=$(udevadm info --name "$1" --query=path 2>/dev/null)
+    if [ -n "$path" ]; then
+        echo "/sys/$path"
+        return 0
+    fi
+    return 1
+}
+
 finddevnoinsys() {
     majmin="$1"
     if [ -n "$majmin" ]; then
-        dev=$(for x in /sys/block/* ; do find $x/ -name dev ; done | while read device ; do \
-              echo "$majmin" | cmp -s $device && echo $device ; done)
-        if [ -n "$dev" ]; then
-            dev=${dev%%/dev}
-            dev=${dev%%/}
-            echo "$dev"
-            return 0
-        fi
+        finddevinsys "/dev/block/$majmin"
+        return $?
     fi
     return 1
 }
@@ -252,11 +255,10 @@ findstoragedriver () {
         return
     fi
 
-    local majmin=$(get_numeric_dev dec "$device")
-    local sysfs=$(finddevnoinsys "$majmin")
+    local sysfs=$(finddevinsys "$device")
 
     if [ -z "$sysfs" ]; then
-        #error "WARNING: $device major:minor $majmin not found, skipping"
+        #error "WARNING: $device not found in sysfs, skipping"
         return
     fi
 


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] dracut-gencmdline: use udevadm info to go from /dev/X to /sys/Y
       [not found] ` <4AE9606C.1090008-cCz0Lq7MMjm9FHfhHBbuYA@public.gmane.org>
@ 2009-10-29 10:59   ` Alan Jenkins
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Jenkins @ 2009-10-29 10:59 UTC (permalink / raw)
  To: initramfs-u79uwXL29TY76Z2rM5mHXA

Alan Jenkins wrote:
> Avoid some manual spelunking in sysfs.  This makes for slightly shorter
> and simpler code.
>   

Argh, please ignore this patch.

> +    path=$(udevadm info --name "$1" --query=path 2>/dev/null

> -        dev=$(for x in /sys/block/* ; do find $x/ -name dev ; done | while read device ; do \
> -              echo "$majmin" | cmp -s $device && echo $device ; done)
> -        if [ -n "$dev" ]; then
> -            dev=${dev%%/dev}
> -            dev=${dev%%/}
> -            echo "$dev"
> -            return 0
> -        fi
>   

Device-mapper was still creating some of it's own device nodes as of
April this year.  So it's not safe to rely on udev knowing about
everything in /dev.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-29 10:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-29  9:29 [PATCH] dracut-gencmdline: use udevadm info to go from /dev/X to /sys/Y Alan Jenkins
     [not found] ` <4AE9606C.1090008-cCz0Lq7MMjm9FHfhHBbuYA@public.gmane.org>
2009-10-29 10:59   ` Alan Jenkins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox