finally move buildroot-ng to trunk
[openwrt.git] / package / base-files / brcm-2.6 / sbin / mount_root
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3
4 is_dirty() {
5         grep Broadcom /proc/cpuinfo >&- || return 1
6         OFFSET="$(($(hexdump -v /dev/mtdblock/1 -s 20 -n 2 -e '"%d"')-1))"
7         return $(hexdump -v /dev/mtdblock/1 -s $OFFSET -n 1 -e '"%d"')
8 }
9
10 size=$(awk '/Mem:/ {l=5242880;print((s=$2/2)<l)?$2-l:s}' /proc/meminfo)
11 mount none /tmp -t tmpfs -o size=$size
12
13 if [ "$1" != "failsafe" ]; then 
14         mtd unlock linux
15         mount | grep jffs2 >&-
16         if [ $? = 0 ] ; then
17                 mount -o remount,rw /dev/root /
18         else
19                 . /bin/firstboot
20                 is_dirty 
21                 [ $? != 0 ] && {
22                         echo "switching to jffs2"
23                         mount /dev/mtdblock/4 /jffs -t jffs2
24                         pivot /jffs /rom
25                 } || {
26                         echo "jffs2 unusable; using ramdisk"
27                         ramoverlay
28                 }
29         fi
30 fi
31
32 mount none /tmp -t tmpfs -o remount,nosuid,nodev,mode=1777
33 mkdir -p /dev/pts
34 mount none /dev/pts -t devpts
35 mount -t sysfs none /sys 2>&-