]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
[PATCH 04/50] Modify root cmdline parsing to use a case statement.
authorVictor Lowther <victor.lowther@gmail.com>
Fri, 13 Feb 2009 12:41:40 +0000 (04:41 -0800)
committerDave Jones <davej@redhat.com>
Mon, 16 Feb 2009 18:56:40 +0000 (13:56 -0500)
This code takes less space and is easier to read at a glance.

init

diff --git a/init b/init
index 7b2a9856789944148104053ea0059e562d58ee25..78f962ef13287bfb63730719494f74fbfc844e64 100755 (executable)
--- a/init
+++ b/init
@@ -59,19 +59,16 @@ NEWROOT="/sysroot"
 # it'd be nice if we had a udev rule that just did all of the bits for
 # figuring out what the specified root is and linking it /dev/root
 root=$(getarg 'root=*'); root=${root#root=}
-
 echo -n "Going to mount rootfs ($root)"
-if [ -z "$root" ]; then 
-  echo "Warning: no root specified"
-  root="/dev/sda1"
-elif [ "${root#LABEL=}" != $root ]; then
-  # FIXME: may need to do more escaping here
-  l=${root#LABEL=}
-  label=${l//\//\\x2f}
-  root="/dev/disk/by-label/${label}"
-elif [ "${root#UUID=}" != $root ]; then
-  root="/dev/disk/by-uuid/${root#UUID=}"
-fi
+case $root in
+    LABEL=*) root=${root#LABEL=}
+             root=${root//\//\\x2f}
+            root="/dev/disk/by-label/${root}" ;;
+    UUID=*) root="/dev/disk/by-uuid/${root#UUID=}" ;;
+    '') echo "Warning: no root specified"
+       root="/dev/sda1" ;;
+esac
+
 # should we have a timeout?
 tries=0
 while [ ! -e $root ]; do