]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Modify getarg to be slightly more useful.
authorVictor Lowther <victor.lowther-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Thu, 26 Feb 2009 02:32:40 +0000 (18:32 -0800)
committerHarald Hoyer <harald@redhat.com>
Wed, 4 Mar 2009 15:54:31 +0000 (16:54 +0100)
If the last character in the argument to search for is "=", then
getarg will echo all the text after the = as well as returning 0 or 1 depending
on whether or not the arg is found.
Otherwise, getarg will jsut return 0 if the exact test of the argument is found,
1 otherwise.

hooks/mount-partition.sh
hooks/resume.sh
init
modules/95udev-rules.sh

index 53a0f4c8465823160e6683ab681324745fbb2b8c..f554c28b250157d505605f1fe4736bcdf5f05444 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 [ "$root" ] || {
-    root=$(getarg root); root=${root#root=}
+    root=$(getarg root=)
     case $root in
        LABEL=*) root=${root#LABEL=}
             root="$(echo $root |sed 's,/,\\x2f,g')"
 }
 
 [ "$rflags" ] || {
-    if rflags="$(getarg rootflags)"; then
-       rflags="${rflags#rootflags=}"
-       getarg rw >/dev/null && rflags="${rflags},rw" || rflags="${rflags},ro"
+    if rflags="$(getarg rootflags=)"; then
+       getarg rw && rflags="${rflags},rw" || rflags="${rflags},ro"
     else
-       getarg rw >/dev/null && rflags=rw || rflags=ro
+       getarg rw && rflags=rw || rflags=ro
     fi
 }
 
 [ "$fstype" ] || {
-    fstype="$(getarg rootfstype)" && fstype="-t ${fstype#rootfstype=}"
+    fstype="$(getarg rootfstype=)" && fstype="-t ${fstype}"
 }
 
-[ -e "$root" ] && {
-    ln -sf "$root" /dev/root
-    mount $fstype -o $rflags /dev/root $NEWROOT && ROOTFS_MOUNTED=yes
-}
+[ -e "$root" ] && mount $fstype -o "$rflags" "$root" "$NEWROOT" && \
+    ROOTFS_MOUNTED=yes
index 619d63478ce6bcdf3fbee4149ffac7eb7e424320..a01a61319abb5ff97aa303c5b033ea43eb79bee5 100755 (executable)
@@ -1,10 +1,7 @@
 #!/bin/sh
-resume=$(getarg resume) && [ "$(getarg noresume)" = "" ] && {
-    resume=${resume#resume=}
-    [ -b "$resume" ] && {
-        # parsing the output of ls is Bad, but until there is a better way...
-       ls -lH "$resume" | ( 
-           read x x x x maj min x;
-           echo "${maj%,}:$min"> /sys/power/resume)
-    }
+resume=$(getarg resume=) && ! getarg noresume && [ -b "$resume" ] && {
+    # parsing the output of ls is Bad, but until there is a better way...
+    ls -lH "$resume" | ( 
+       read x x x x maj min x;
+       echo "${maj%,}:$min"> /sys/power/resume)
 }
diff --git a/init b/init
index 36522162c7ba35256ffa8202b4f79f47f939b9fe..c3f515072f403faf0cd8a7b1de84c7a7cd4b08fa 100755 (executable)
--- a/init
+++ b/init
@@ -16,7 +16,8 @@ emergency_shell()
 getarg() {
     local o line
     for o in $CMDLINE; do
-       [ "${o%%=*}" = "$1" ] && { echo $o; return 0; }
+       [ "$o" = "$1" ] && return 0
+       [ "${o%%=*}" = "${1%=}" ] && { echo ${o#*=}; return 0; }
     done
     return 1
 }
@@ -75,17 +76,14 @@ while :; do
 done
 
 # by the time we get here, the root filesystem should be mounted.
-
-INIT=$(getarg init)
+# Try to find init.
+for i in "$(getarg init=)" /sbin/init /etc/init /init /bin/sh; do
+    [ -f "$NEWROOT$i" -a -x "$NEWROOT$i" ] && { INIT="$i"; break; }
+done
 [ "$INIT" ] || {
-    for i in /sbin/init /etc/init /init /bin/sh; do
-       [ -x "$NEWROOT$i" ] && { INIT="$i"; break; }
-    done
-    [ "$INIT" ] || {
-       echo "Cannot find init! Please check to make sure you passed"
-       echo "a valid root filesystem!  Dropping to a shell."
-       emergency_shell
-    }
+    echo "Cannot find init! Please check to make sure you passed"
+    echo "a valid root filesystem!  Dropping to a shell."
+    emergency_shell
 }
 
 # pre pivot scripts are sourced just before we switch over to the new root.
index 9801e7ef20bd10eeee56ed1effd3ef39f9baba62..61125cd38521602d6fef391b6d891debfc16923d 100755 (executable)
@@ -7,4 +7,6 @@ dracut_install udevd udevadm /lib/udev/*_id /lib/udev/console_*
 inst_rules /lib/udev/rules.d/10-console* /lib/udev/rules.d/40-redhat* \
     /lib/udev/rules.d/50* /lib/udev/rules.d/60-persistent-storage.rules \
     /lib/udev/rules.d/61*edd* /lib/udev/rules.d/64* /lib/udev/rules.d/80* \
-    /lib/udev/rules.d/95*
\ No newline at end of file
+    /lib/udev/rules.d/95*
+# make udevadm shut up about missing udev.conf
+inst /etc/udev/udev.conf
\ No newline at end of file