[PATCH 04/50] Modify root cmdline parsing to use a case statement.

This code takes less space and is easier to read at a glance.
master
Victor Lowther 2009-02-13 04:41:40 -08:00 committed by Dave Jones
parent 9f99d479b3
commit f9a0b9f868
1 changed files with 9 additions and 12 deletions

21
init
View File

@ -59,19 +59,16 @@ NEWROOT="/sysroot"
# it'd be nice if we had a udev rule that just did all of the bits for # 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 # figuring out what the specified root is and linking it /dev/root
root=$(getarg 'root=*'); root=${root#root=} root=$(getarg 'root=*'); root=${root#root=}

echo -n "Going to mount rootfs ($root)" echo -n "Going to mount rootfs ($root)"
if [ -z "$root" ]; then case $root in
echo "Warning: no root specified" LABEL=*) root=${root#LABEL=}
root="/dev/sda1" root=${root//\//\\x2f}
elif [ "${root#LABEL=}" != $root ]; then root="/dev/disk/by-label/${root}" ;;
# FIXME: may need to do more escaping here UUID=*) root="/dev/disk/by-uuid/${root#UUID=}" ;;
l=${root#LABEL=} '') echo "Warning: no root specified"
label=${l//\//\\x2f} root="/dev/sda1" ;;
root="/dev/disk/by-label/${label}" esac
elif [ "${root#UUID=}" != $root ]; then
root="/dev/disk/by-uuid/${root#UUID=}"
fi
# should we have a timeout? # should we have a timeout?
tries=0 tries=0
while [ ! -e $root ]; do while [ ! -e $root ]; do