Changeset 3391
- Timestamp:
- 08/02/07 17:13:19 (5 years ago)
- Author:
- tg
- Message:
• remove more instances of evil code like
[ $? != 0 ] && { foo; bar; }
{ baz; blah; }
• from ramovl target: never do the symlink dance,
use mini_fo with tmpfs overlay if jffs2 unusable
(speeds up post-flash first boot a lot)
• clean up even more (tho the awk(1) abuse is still there)
• flash the power led almost as early as possible,
to not make people think it's done when it's pre-boot
tested.
- Files:
- trunk/freewrt/package/base-files/Makefile (modified) (1 diff)
- trunk/freewrt/package/base-files/files/etc/preinit (modified) (1 diff)
- trunk/freewrt/target/linux/brcm-2.4/squashfs/files/etc/init.d/jffs2clean (modified) (1 diff)
- trunk/freewrt/target/linux/brcm-2.4/squashfs/files/sbin/mount_root (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/freewrt/package/base-files/Makefile
r3388 r3391 10 10 PKG_NAME:= base-files 11 11 PKG_VERSION:= 1.1 12 PKG_RELEASE:= 2 512 PKG_RELEASE:= 26 13 13 WRKDIST= ${WRKDIR}/base-files 14 14 NO_DISTFILES:= 1 trunk/freewrt/package/base-files/files/etc/preinit
r3344 r3391 23 23 24 24 [ -f /etc/preinit.arch ] && . /etc/preinit.arch 25 [ -f /proc/diag/led/power ] && echo 1 >/proc/diag/led/power25 [ -f /proc/diag/led/power ] && echo f >/proc/diag/led/power 26 26 27 27 # failsafe via hotplug trunk/freewrt/target/linux/brcm-2.4/squashfs/files/etc/init.d/jffs2clean
r2779 r3391 3 3 case $1 in 4 4 autostart|start) 5 # if / is tmpfs, we have an old or broken jffs25 # if /jffs is dirty, we have an old or broken jffs2 6 6 # erase data partition and set flag between bootloader and kernel 7 if mount | fgrep "on / type tmpfs" >/dev/null; then7 if mount | grep "dirty.*/jffs" >/dev/null; then 8 8 mtd erase rootfs_data 9 9 jffs2root --clean trunk/freewrt/target/linux/brcm-2.4/squashfs/files/sbin/mount_root
r3388 r3391 1 1 #!/bin/sh 2 2 3 is_dirty() { 3 grep Broadcom /proc/cpuinfo >&- || return 14 4 OFFSET="$(($(hexdump -v /dev/mtdblock/1 -s 20 -n 2 -e '"%d"')-1))" 5 5 return $(hexdump -v /dev/mtdblock/1 -s $OFFSET -n 1 -e '"%d"') 6 }7 8 pivot() { # <new_root> <old_root>9 mount -o move /proc $1/proc && \10 pivot_root $1 $1$2 && {11 mount -o move $2/dev /dev12 mount -o move $2/tmp /tmp13 return 014 }15 }16 17 dupe() { # <new_root> <old_root>18 cd $119 echo -n "creating directories... "20 {21 cd $222 find . -xdev -type d23 echo "./dev ./jffs ./mnt ./proc ./tmp"24 # xdev skips mounted directories25 cd $126 } | xargs mkdir -p27 echo "done"28 29 echo -n "setting up symlinks... "30 for file in $(cd $2; find . -xdev -type f;); do31 case "$file" in32 ./rom/note) ;; #nothing33 ./etc/resolv.conf|\34 ./usr/lib/ipkg/info) cp -af $2/$file $file;;35 *) ln -sf /rom/${file#./*} $file;;36 esac37 done38 for file in $(cd $2; find . -xdev -type l;); do39 cp -af $2/${file#./*} $file40 done41 echo "done"42 }43 44 mountdp() { # <device> <mount_point> <ignored> <fs>45 dev=$1; mnt=$2; shift 2; opt=$*46 mount $dev $mnt $opt47 dupe $mnt $rom48 pivot $mnt /rom49 6 } 50 7 … … 53 10 54 11 mtd unlock linux 55 is_dirty 56 [ $? != 0 ] && { 57 echo "switching to overlay filesystem" 12 echo "switching to overlay filesystem" 13 if is_dirty; then 14 echo "jffs2 unusable; using ramdisk" 15 mount -t tmpfs dirty /jffs 16 else 58 17 datanr=$(awk -F : '/data/ { print $1 }' /proc/mtd |sed "s#mtd##") 59 mount /dev/mtdblock/$datanr /jffs -t jffs2 60 mount -t mini_fo -o base=/,sto=/jffs /jffs /mnt 61 pivot /mnt /rom 62 } || { 63 echo "jffs2 unusable; using ramdisk" 64 mkdir -p /tmp/root 65 mountdp /tmp/root /mnt -o bind 66 } 18 if ! mount /dev/mtdblock/$datanr /jffs -t jffs2; then 19 echo "jffs2 unmountable; using ramdisk" 20 mount -t tmpfs none /jffs 21 fi 22 fi 23 mount -t mini_fo -o base=/,sto=/jffs / /mnt 24 mount -o move /proc /mnt/proc 25 pivot_root /mnt /mnt/rom 26 mount -o move /rom/dev /dev 27 mount -o move /rom/tmp /tmp 67 28 68 29 mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777
Download in other formats:


