Changeset 3391

Show
Ignore:
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:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/freewrt/package/base-files/Makefile

    r3388 r3391  
    1010PKG_NAME:=              base-files 
    1111PKG_VERSION:=           1.1 
    12 PKG_RELEASE:=           25 
     12PKG_RELEASE:=           26 
    1313WRKDIST=                ${WRKDIR}/base-files 
    1414NO_DISTFILES:=          1 
  • trunk/freewrt/package/base-files/files/etc/preinit

    r3344 r3391  
    2323 
    2424[ -f /etc/preinit.arch ] && . /etc/preinit.arch 
    25 [ -f /proc/diag/led/power ] && echo 1 > /proc/diag/led/power 
     25[ -f /proc/diag/led/power ] && echo f >/proc/diag/led/power 
    2626 
    2727# failsafe via hotplug 
  • trunk/freewrt/target/linux/brcm-2.4/squashfs/files/etc/init.d/jffs2clean

    r2779 r3391  
    33case $1 in 
    44autostart|start) 
    5         # if / is tmpfs, we have an old or broken jffs2 
     5        # if /jffs is dirty, we have an old or broken jffs2 
    66        # erase data partition and set flag between bootloader and kernel 
    7         if mount | fgrep "on / type tmpfs" >/dev/null; then 
     7        if mount | grep "dirty.*/jffs" >/dev/null; then 
    88                mtd erase rootfs_data 
    99                jffs2root --clean 
  • trunk/freewrt/target/linux/brcm-2.4/squashfs/files/sbin/mount_root

    r3388 r3391  
    11#!/bin/sh 
     2 
    23is_dirty() { 
    3         grep Broadcom /proc/cpuinfo >&- || return 1 
    44        OFFSET="$(($(hexdump -v /dev/mtdblock/1 -s 20 -n 2 -e '"%d"')-1))" 
    55        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 /dev 
    12                 mount -o move $2/tmp /tmp 
    13                 return 0 
    14         } 
    15 } 
    16  
    17 dupe() { # <new_root> <old_root> 
    18         cd $1 
    19         echo -n "creating directories... " 
    20         { 
    21                 cd $2 
    22                 find . -xdev -type d 
    23                 echo "./dev ./jffs ./mnt ./proc ./tmp" 
    24                 # xdev skips mounted directories 
    25                 cd $1 
    26         } | xargs mkdir -p 
    27         echo "done" 
    28  
    29         echo -n "setting up symlinks... " 
    30         for file in $(cd $2; find . -xdev -type f;); do 
    31                 case "$file" in 
    32                 ./rom/note) ;; #nothing 
    33                 ./etc/resolv.conf|\ 
    34                 ./usr/lib/ipkg/info) cp -af $2/$file $file;; 
    35                 *) ln -sf /rom/${file#./*} $file;; 
    36                 esac 
    37         done 
    38         for file in $(cd $2; find . -xdev -type l;); do 
    39                 cp -af $2/${file#./*} $file 
    40         done 
    41         echo "done" 
    42 } 
    43  
    44 mountdp() { # <device> <mount_point> <ignored> <fs> 
    45         dev=$1; mnt=$2; shift 2; opt=$* 
    46         mount $dev $mnt $opt 
    47         dupe $mnt $rom 
    48         pivot $mnt /rom 
    496} 
    507 
     
    5310 
    5411mtd unlock linux 
    55 is_dirty 
    56 [ $? != 0 ] && { 
    57         echo "switching to overlay filesystem" 
     12echo "switching to overlay filesystem" 
     13if is_dirty; then 
     14        echo "jffs2 unusable; using ramdisk" 
     15        mount -t tmpfs dirty /jffs 
     16else 
    5817        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 
     22fi 
     23mount -t mini_fo -o base=/,sto=/jffs / /mnt 
     24mount -o move /proc /mnt/proc 
     25pivot_root /mnt /mnt/rom 
     26mount -o move /rom/dev /dev 
     27mount -o move /rom/tmp /tmp 
    6728 
    6829mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777