Author: undefine
Date: Mon Jan 28 01:27:21 2008
New Revision: 9204

Modified:
   geninitrd/trunk/geninitrd
Log:
- parse CMDLINE for root=something once and put it into ROOT
- when blkid is used and in ROOT is something like UUID or LABEL - 
  put into ROOT real device (detected by blkid)


Modified: geninitrd/trunk/geninitrd
==============================================================================
--- geninitrd/trunk/geninitrd   (original)
+++ geninitrd/trunk/geninitrd   Mon Jan 28 01:27:21 2008
@@ -1461,20 +1461,15 @@
                EOF
                add_linuxrc <<-'EOF'
                        # parse rootdev from kernel commandline
-                       for arg in $CMDLINE; do
-                               if [ "${arg##root=}" != "${arg}" ]; then
-                                       local rdev=${arg##root=}
-                                       if [ "$rdev" != "$ROOTDEV" ]; then
-                                               ROOTDEV=$rdev
-                                               echo "LVM: Using 
'root=$ROOTDEV' from kernel commandline"
-                                               local tmp=${ROOTDEV#/dev/}
-                                               if [ "$tmp" != "$ROOTDEV" ]; 
then
-                                                       VGVOLUME=${tmp%/*}
-                                                       echo "LVM: Using Volume 
Group '$VGVOLUME'"
-                                               fi
-                                       fi
+                       if [ "$ROOT" != "$ROOTDEV" ]; then
+                               ROOTDEV=$ROOT
+                               echo "LVM: Using 'root=$ROOTDEV' from kernel 
commandline"
+                               local tmp=${ROOTDEV#/dev/}
+                               if [ "$tmp" != "$ROOTDEV" ]; then
+                                       VGVOLUME=${tmp%/*}
+                                       echo "LVM: Using Volume Group 
'$VGVOLUME'"
                                fi
-                       done
+                       fi
 
                        # disable noise from LVM accessing devices that aren't 
ready.
                        read printk < /proc/sys/kernel/printk
@@ -1518,17 +1513,18 @@
        inst /sbin/initrd-blkid /bin/blkid
        initrd_gen_devices
        add_linuxrc <<-'EOF'
-               device=/dev/no_partition_found
-               label="$(echo "$CMDLINE" | busybox awk '/root=LABEL=/ { 
gsub(/.*root=/,NIL,$0); gsub(/ .*/,NIL,$0); print $0; } ')"
-               [ -n $label ] && root="$(/bin/blkid -t $label -o device -l | 
busybox awk '/dev/ { gsub(/\/dev\//,NIL,$0); print $0; } ' )"
-               [ -n "$root" ] && device=/dev/$root
+               # if built with blkid change ROOT=LABEL=something into 
ROOT=/dev/somethingelse - 
+               # parsed by blkid
+               if [ "${ROOT##LABEL=}" != "${ROOT}" -o "${ROOT##UUID=}" != 
"${ROOT}" ]; then
+                       ROOT="$(/bin/blkid -t $ROOT -o device -l)"
+               fi
        EOF
 }
 
 initrd_gen_procdata() {
        debug "Adding rootfs finding based on kernel cmdline root= option 
support."
        add_linuxrc <<-'EOF'
-               [ -z "$root" ] && root="$(echo "$CMDLINE" | busybox awk ' 
/root=\/dev\// { gsub(/.*root=\/dev\//,NIL,$0); gsub(/ .*/,NIL,$0); print $0; } 
')"
+               [ "${ROOT##/dev/}" != "${ROOT}" ] && root="${ROOT##/dev/}"
                if [ -n "$root" ]; then
                        rootnr="$(busybox awk -v root="$root" ' { if ($4 == 
root) { print 256*$1+$2; } } ' /proc/partitions)"
                        if [ -n "$rootnr" ]; then
@@ -1902,6 +1898,9 @@
                if [ "${arg##debuginitrd=}" != "${arg}" ]; then
                        DEBUGINITRD=${arg##debuginitrd=}
                fi
+               if [ "${arg##root=}" != "${arg}" ]; then
+                       ROOT=${arg##root=}
+               fi
        done
 
        # make debugshell() invoke subshell if $DEBUGINITRD=sh
@@ -1988,9 +1987,8 @@
        # Parsing root parameter
        # We support passing root as hda3 /dev/hda3 0303 0x0303 and 303
        add_linuxrc <<-'EOF'
-               [ -z "$device" ] && device=/dev/no_partition_found 
-               if [ "$device" = '/dev/no_partition_found' ]; then
-                       eval "$(busybox awk -v c="$CMDLINE" '
+               device=/dev/no_partition_found 
+               eval "$(busybox awk -v c="$ROOT" '
                        BEGIN {
                                num_pattern_short = "[0-9a-f][0-9a-f][0-9a-f]";
                                num_pattern = "[0-9a-f]" num_pattern_short;
@@ -1998,9 +1996,6 @@
                                partition = "no_partition_found";
                                min = -1; maj = -1;
 
-                               gsub(/.*root=/,NIL,c);
-                               gsub(/ .*/,NIL,c);
-
                                sub("^0x", "", c);
                                if (c ~ "^" num_pattern_short "$") sub("^", 
"0", c);
                                if (c ~ "^" num_pattern  "$") {
@@ -2019,7 +2014,6 @@
                                        partition, maj, min);
                        }
                        ' /proc/partitions)"
-               fi
                if [ "$device" != '/dev/no_partition_found' -a ! -b $device ]; 
then
                        mknod $device b $maj $min
                fi
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to