fix mdev for broadcom 2.6
[openwrt/staging/wigyori.git] / target / linux / brcm-2.4 / base-files / default / sbin / mount_root
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3 . /etc/functions.sh
4
5 is_dirty() {
6 mtdpart="$(find_mtd_part linux)"
7 grep Broadcom /proc/cpuinfo >&- || return 1
8 OFFSET="$(($(hexdump -v $mtdpart -s 20 -n 2 -e '"%d"')-1))"
9 return $(hexdump -v $mtdpart -s $OFFSET -n 1 -e '"%d"')
10 }
11
12 if grep devfs /proc/filesystems > /dev/null; then
13 mount none /dev -t devfs
14 else
15 mount -t sysfs none /sys
16 mount -t tmpfs tmpfs /dev -o size=512K
17 mknod /dev/console c 5 1
18 mkdir /dev/shm
19 /sbin/mdev -s
20 fi
21 mkdir -p /dev/pts
22 mount none /dev/pts -t devpts
23
24 if [ "$1" != "failsafe" ]; then
25 mtd unlock linux
26 mount | grep jffs2 >&-
27 if [ $? = 0 ] ; then
28 mount -o remount,rw /dev/root /
29 else
30 . /bin/firstboot
31 is_dirty
32 [ $? != 0 ] && {
33 echo "switching to jffs2"
34 mount $(find_mtd_part OpenWrt) /jffs -t jffs2
35 fopivot /jffs /rom
36 } || {
37 echo "jffs2 not ready yet; using ramdisk"
38 ramoverlay
39 }
40 fi
41 fi
42
43 grep sysfs /proc/filesystems >/dev/null && mount -t sysfs none /sys 2>&-