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
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html