diff options
author | mbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2007-05-10 08:35:48 +0000 |
---|---|---|
committer | mbm <mbm@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2007-05-10 08:35:48 +0000 |
commit | 7ab4d88438816cada428a75854b6591029006945 (patch) | |
tree | 32937324ae761d2abd5cba3762295fa2f36f7fac | |
parent | 7a5c6744213c2db8419b4ce5f8c76afce3501479 (diff) |
change handling of target/linux/generic-2.x/files to match other targets (#1648)
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@7158 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rw-r--r-- | include/kernel-defaults.mk | 5 | ||||
-rwxr-xr-x | target/linux/generic-2.6/base-files/init | 93 |
2 files changed, 95 insertions, 3 deletions
diff --git a/include/kernel-defaults.mk b/include/kernel-defaults.mk index c2becb9011..b9231a9beb 100644 --- a/include/kernel-defaults.mk +++ b/include/kernel-defaults.mk @@ -29,6 +29,7 @@ KERNEL_MAKEOPTS := -C $(LINUX_DIR) \ define Kernel/Prepare/Default bzcat $(DL_DIR)/$(LINUX_SOURCE) | tar -C $(KERNEL_BUILD_DIR) $(TAR_OPTIONS) + if [ -d $(GENERIC_PLATFORM_DIR)/files ]; then $(CP) $(GENERIC_PLATFORM_DIR)/files/* $(LINUX_DIR)/; fi if [ -d $(GENERIC_PLATFORM_DIR)/patches ]; then $(PATCH) $(LINUX_DIR) $(GENERIC_PLATFORM_DIR)/patches; fi if [ -d ./files ]; then $(CP) ./files/* $(LINUX_DIR)/; fi if [ -d ./patches ]; then $(PATCH) $(LINUX_DIR) ./patches; fi @@ -67,14 +68,12 @@ ifeq ($(KERNEL),2.6) echo 'CONFIG_INITRAMFS_SOURCE="../../root"' >> $(LINUX_DIR)/.config echo 'CONFIG_INITRAMFS_ROOT_UID=0' >> $(LINUX_DIR)/.config echo 'CONFIG_INITRAMFS_ROOT_GID=0' >> $(LINUX_DIR)/.config - mkdir -p $(BUILD_DIR)/root/etc/init.d - $(CP) $(GENERIC_PLATFORM_DIR)/files/init $(BUILD_DIR)/root/ endef else define Kernel/SetInitramfs mv $(LINUX_DIR)/.config $(LINUX_DIR)/.config.old grep -v INITRAMFS $(LINUX_DIR)/.config.old > $(LINUX_DIR)/.config - rm -f $(BUILD_DIR)/root/init $(BUILD_DIR)/root/etc/init.d/S00initramfs + rm -f $(BUILD_DIR)/root/init echo 'CONFIG_INITRAMFS_SOURCE=""' >> $(LINUX_DIR)/.config endef endif diff --git a/target/linux/generic-2.6/base-files/init b/target/linux/generic-2.6/base-files/init new file mode 100755 index 0000000000..9f595c0f95 --- /dev/null +++ b/target/linux/generic-2.6/base-files/init @@ -0,0 +1,93 @@ +#!/bin/sh +# Copyright (C) 2006 OpenWrt.org + +export PATH=/bin:/sbin:/usr/bin:/usr/sbin +mount none /proc -t proc + +if grep devfs /proc/filesystems > /dev/null; then + mount none /dev -t devfs +else + mount -t sysfs none /sys + mount -t tmpfs tmpfs /dev -o size=512K + mknod /dev/console c 5 1 + mkdir /dev/pts + mkdir /dev/shm + /sbin/hotplug2 --no-persistent --coldplug --max_children 1 +fi + +mount none /dev/pts -t devpts + +# the root mount point can come from the kernel command line +# or it can be overridden in the preinit.arch file +[ -f /etc/preinit.arch ] && . /etc/preinit.arch + +# if we have no root parameter, just go to running from ramfs +[ -z $rootfs ] && { + export NOMOUNT="No Root" + exec /sbin/init +} + +#if we have a failsafe boot selected, dont bother +#trying to find or wait for a root mount point +[ -z "$FAILSAFE" ] || { + exec /bin/busybox init +} + +# Load the modules we have in initramfs, this should +# make the media accessible, but, it may take some time +. /etc/functions.sh +load_modules /etc/modules /etc/modules.d/* + +#wait 10 seconds for the disc to show up +#usb stick typically takes 4 to 6 seconds +#till it's readable +#it's quite possible the disc never shows up +#if we netbooted this kernel +COUNTER=0 +while [ $COUNTER -lt 10 ]; do + sleep 1 + [ -e $rootfs ] && let COUNTER=10; + let COUNTER=COUNTER+1 +done +[ -e $rootfs ] || { + export FAILSAFE="NoDisc" + exec /bin/busybox init +} + +# now we'll try mount it, again with a timeout +# This will fail if the inserted stick is formatted +# in a manner we dont understand +COUNTER=0 +while [ $COUNTER -lt 10 ]; do + sleep 1 + mount $rootfs /mnt + [ $? -eq "0" ] && let COUNTER=100; + let COUNTER=COUNTER+1 +done +[ $? -ne "0" ] && { + export FAILSAFE="MountFail" + exec /bin/busybox init +} + +#It mounted, lets look for a postinit file, again, give it time +#I've seen this take 6 seconds to actually complete +COUNTER=0 +while [ $COUNTER -lt 10 ]; do + sleep 1 + [ -e /mnt/etc/banner ] && let COUNTER=10; + let COUNTER=COUNTER+1 +done +[ -e /mnt/etc/banner ] || { + export FAILSAFE="No Openwrt FS" + exec /bin/busybox init +} + +unset rootfs + +mount -o move /proc /mnt/proc +mount -o move /dev /mnt/dev +mount -o move /dev/pts /mnt/dev/pts +mount -o move /tmp /mnt/tmp +mount -o move /sys /mnt/sys +mount none /tmp -t tmpfs +exec switch_root -c /dev/console /mnt /sbin/init |