* add getarg method to parse /proc/cmdline and return the option value; * refactor readargs to use getarg API; * avoid printing when 'quiet' boot param is used;
Signed-off-by: Otavio Salvador <[email protected]> --- recipes/initrdscripts/files/init.sh | 60 ++++++++++++++--------- recipes/initrdscripts/initramfs-uniboot_1.0.bb | 2 +- 2 files changed, 37 insertions(+), 25 deletions(-) diff --git a/recipes/initrdscripts/files/init.sh b/recipes/initrdscripts/files/init.sh index 26fd57f..00fec0d 100644 --- a/recipes/initrdscripts/files/init.sh +++ b/recipes/initrdscripts/files/init.sh @@ -3,6 +3,7 @@ MODULE_DIR=/initrd.d BOOT_ROOT= ROOT_DEVICE= +VERBOSE= early_setup() { mkdir -p /proc /sys /mnt /tmp @@ -13,34 +14,45 @@ early_setup() { modprobe -q mtdblock } +info() { + [ -n "$VERBOSE" ] && echo $* +} + dev_setup() { - echo -n "initramfs: Creating device nodes: " + info -n "initramfs: Creating device nodes: " grep '^ *[0-9]' /proc/partitions | while read major minor blocks dev do if [ ! -e /dev/$dev ]; then - echo -n "$dev " + info -n "$dev " [ -e /dev/$dev ] || mknod /dev/$dev b $major $minor fi done - echo + info } -read_args() { - [ -z "$CMDLINE" ] && CMDLINE=`cat /proc/cmdline` - for arg in $CMDLINE; do - optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'` - case $arg in - root=*) - ROOT_DEVICE=$optarg ;; - rootfstype=*) - ROOT_FSTYPE=$optarg ;; - rootdelay=*) - rootdelay=$optarg ;; - debug) set -x ;; - shell) sh ;; - esac +getarg() { + local o + + [ -z "$cmdline" ] && cmdline=`cat /proc/cmdline` + for o in $cmdline; do + test "$o" = "$1" && return 0 + if test "${o%%=*}" = "${1%=}"; then + echo ${o#*=} + return 0 + fi done + return 1 +} + +read_args() { + ROOT_DEVICE=$(getarg root=) + ROOTFS_TYPE=$(getarg rootfstype=) + rootdelay=$(getarg rootdelay=) + + getarg debug && set -x + getarg quiet || VERBOSE=1 + getarg shell && sh } do_depmod() { @@ -49,7 +61,7 @@ do_depmod() { load_module() { # Cannot redir to $CONSOLE here easily - may not be set yet - echo "initramfs: Loading $module module" + info "initramfs: Loading $module module" source $1 } @@ -71,22 +83,22 @@ fatal() { } -echo "Starting initramfs boot..." early_setup +read_args + +info "Starting initramfs boot..." load_modules '0*' do_depmod [ -z "$CONSOLE" ] && CONSOLE="/dev/console" -read_args - if [ -z "$rootdelay" ]; then - echo "rootdelay parameter was not passed on kernel command line - assuming 2s delay" - echo "If you would like to avoid this delay, pass explicit rootdelay=0" + info "rootdelay parameter was not passed on kernel command line - assuming 2s delay" + info "If you would like to avoid this delay, pass explicit rootdelay=0" rootdelay="2" fi if [ -n "$rootdelay" ]; then - echo "Waiting $rootdelay seconds for devices to settle..." >$CONSOLE + info "Waiting $rootdelay seconds for devices to settle..." >$CONSOLE sleep $rootdelay fi diff --git a/recipes/initrdscripts/initramfs-uniboot_1.0.bb b/recipes/initrdscripts/initramfs-uniboot_1.0.bb index 79650aa..e90d268 100644 --- a/recipes/initrdscripts/initramfs-uniboot_1.0.bb +++ b/recipes/initrdscripts/initramfs-uniboot_1.0.bb @@ -1,5 +1,5 @@ SRC_URI = "file://init.sh" -PR = "r12" +PR = "r13" DESCRIPTION = "A modular initramfs init script system." RRECOMMENDS_${PN} = "kernel-module-mtdblock" -- 1.7.1 _______________________________________________ Openembedded-devel mailing list [email protected] http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
