]> git.pld-linux.org Git - projects/geninitrd.git/blobdiff - geninitrd
no need to mess with magic values, let the "magic" be value
[projects/geninitrd.git] / geninitrd
index 39daad1be248e92b38ed0e17958550049b06d414..bd4f92e69a5749f9f023fcf9927c609acd87a76c 100755 (executable)
--- a/geninitrd
+++ b/geninitrd
@@ -100,7 +100,7 @@ find_tool() {
                        return 0
                fi
        done
-       debug "find_tool: did not found any of: $@"
+       debug "find_tool: did not find any of: $@"
        return 1
 }
 
@@ -468,6 +468,14 @@ modprobe_conf() {
        echo "$modprobe_conf_cache"
 }
 
+# return options for MODULE
+# @param $1 module name
+modprobe_options() {
+       local module=$1
+       local options=$(modprobe_conf | awk -vmodule="$module" '{ if ($1 == "options" && $2 == module) { for(i=3;i<=NF;i++) printf("%s ",$i); }}')
+       echo ${options# }
+}
+
 #
 # defaults to modprobe -c if not told otherwise, this means include statements
 # work from there.
@@ -681,7 +689,7 @@ modules_add_linuxrc() {
 
                # name of the module
                local module=${modpath##*/}; module=${module%$modext}
-               local options=$(modprobe_conf | awk -vmodule="$module" '{ if ($1 == "options" && $2 == module) { for(i=3;i<=NF;i++) printf("%s ",$i); }}' | xargs)
+               local options=$(modprobe_options "$module")
                local genericname=$(echo $module | tr - _)
                local usleep=$(eval echo \$MODULE_${genericname}_USLEEP)
                local firmware=$(eval echo \$MODULE_${genericname}_FIRMWARE)
@@ -776,42 +784,46 @@ initrd_gen_initramfs_switchroot() {
        # parse 'root=xxx' kernel commandline
        # We support passing root as hda3 /dev/hda3 0303 0x0303 and 303
        add_linuxrc <<-'EOF'
-               device=/dev/no_partition_found
+               device=
                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;
                                dev_pattern = "[hms][a-z][a-z]([0-9])+";
-                               partition = "no_partition_found";
+                               partition = "";
                                min = -1; maj = -1;
 
                                sub("^0x", "", c);
                                if (c ~ "^" num_pattern_short "$") sub("^", "0", c);
                                if (c ~ "^" num_pattern  "$") {
-                                       maj = sprintf("%s",substr(c,1,2));
-                                       min = sprintf("%s",substr(c,3));
+                                       maj = sprintf("%d",substr(c,1,2));
+                                       min = sprintf("%d",substr(c,3));
                                }
                                if (c ~ "^\/dev\/" dev_pattern "$") sub("^/dev/","", c);
                                if (c ~ "^" dev_pattern "$") partition = c;
                        }
 
-                       $4 == partition { maj = $1; min = $2; }
+                       partition && $4 == partition { maj = $1; min = $2; }
                        $1 == maj && $2 == min { partition = $4; }
 
                        END {
                                if (maj >= 0 && min >= 0) {
-                                       printf("device=/dev/%s; maj=%s; min=%s;\n", partition, maj, min);
+                                       printf("maj=%s; min=%s;\n", maj, min);
+                               }
+                               if (partition) {
+                                       printf("device=/dev/%s;\n", partition);
                                }
                        }
                        ' /proc/partitions)"
-               if [ "$device" != '/dev/no_partition_found' -a ! -b $device ]; then
-                       mknod $device b $maj $min
-               fi
 
-               if [ "$device" = '/dev/no_partition_found' ]; then
+               if [ -z "$device" ]; then
                        device=$ROOT
                fi
 
+               if [ "$device" -a ! -b $device ]; then
+                       mknod $device b $maj $min
+               fi
+
                [ -n "$ROOTFSFLAGS" ] && ROOTFSFLAGS="-o $ROOTFSFLAGS"
 
                mount -t $ROOTFS -r $device $ROOTFSFLAGS /newroot || echo "Mount of rootfs failed."
This page took 0.104308 seconds and 4 git commands to generate.