From 16a3f228361050026880c9c884148a598ac8f40b Mon Sep 17 00:00:00 2001 From: Alain Kalker Date: Tue, 20 Mar 2012 21:46:58 +0100 Subject: [PATCH] busybox-initramfs: init: cleanup, improve readability Use consistent whitespace for all `progress "..."` lines. Don't mount $disk if it is not set (e.g. in the installer). Don't check for /storage/$OVERLAY_DIR, just create it. Move the overlay functionality into an if statement. Don't move /storage if $disk is not set (e.g. in the installer). Signed-off-by: Alain Kalker --- .../sysutils/busybox-initramfs/scripts/init | 45 +++++++++++-------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/packages/initramfs/sysutils/busybox-initramfs/scripts/init b/packages/initramfs/sysutils/busybox-initramfs/scripts/init index e3baf0d490..e391c6b9c9 100755 --- a/packages/initramfs/sysutils/busybox-initramfs/scripts/init +++ b/packages/initramfs/sysutils/busybox-initramfs/scripts/init @@ -168,9 +168,9 @@ NBD_DEVS="0" mount_part() { # Mount a local or network filesystem # $1:[TYPE=]target, $2:mountpoint, $3:mount options, [$4:fs type] - MOUNT_TARGET="${1#*=}" - progress "mount filesystem $1 ..." + + MOUNT_TARGET="${1#*=}" case $1 in LABEL=*|UUID=*|/*) MOUNT_CMD="mount_common" @@ -222,6 +222,7 @@ NBD_DEVS="0" load_modules() { progress "Loading kernel modules" + [ ! -f "/etc/modules" ] && return for module in $(cat /etc/modules); do progress "Loading kernel module $module" @@ -232,6 +233,7 @@ NBD_DEVS="0" check_disks() { progress "Checking disks" + if [ -x /sbin/fsck_hfs ]; then # deal with hfs partitions hfsdiskprep @@ -240,30 +242,34 @@ NBD_DEVS="0" mount_disks() { progress "Mounting disks" + mount_part "$boot" "/flash" "ro,noatime" - mount_part "$disk" "/storage" "rw,noatime" - [ -z "$OVERLAY" ] && return - OVERLAY_DIR=`cat /sys/class/net/eth0/address | /bin/busybox tr -d :` - if [ ! -d /storage/$OVERLAY_DIR ]; then - mkdir /storage/$OVERLAY_DIR - fi - /bin/busybox umount /storage + if [ -n "$disk" ]; then + if [ -n "$OVERLAY" ]; then + OVERLAY_DIR=`cat /sys/class/net/eth0/address | /bin/busybox tr -d :` - # split $disk into $target,$options so we can append $OVERLAY_DIR - options="${disk#*,}" - target="${disk%%,*}" - if [ "$options" = "$disk" ]; then - disk="$target/$OVERLAY_DIR" - else - disk="$target/$OVERLAY_DIR,$options" + mount_part "$disk" "/storage" "rw,noatime" + mkdir -p /storage/$OVERLAY_DIR + /bin/busybox umount /storage + + # split $disk into $target,$options so we can append $OVERLAY_DIR + options="${disk#*,}" + target="${disk%%,*}" + if [ "$options" = "$disk" ]; then + disk="$target/$OVERLAY_DIR" + else + disk="$target/$OVERLAY_DIR,$options" + fi fi - mount_part "$disk" "/storage" "rw,noatime" + mount_part "$disk" "/storage" "rw,noatime" + fi } check_update() { progress "Checking for updates" + if [ -f "/flash/MACH_KERNEL" ]; then IMAGE_KERNEL="MACH_KERNEL" fi @@ -288,7 +294,10 @@ NBD_DEVS="0" # /flash is actual root filesystem /bin/busybox mount --move /flash /sysroot fi - /bin/busybox mount --move /storage /sysroot/storage + + if [ -n "$disk" ]; then + /bin/busybox mount --move /storage /sysroot/storage + fi [ -f "/sysroot/sbin/init" ] || error "final_check" "Could not find system." }