check if some /proc files exist, before using it, for systems without diag kernel...
[openwrt.git] / package / base-files / default / sbin / mount_root
1 #!/bin/sh
2 . /etc/nvram.sh
3 if [ "$1" != "failsafe" ]; then 
4         mount | grep jffs2 >&-
5         if [ $? = 0 ] ; then
6                 if [ $(cat /proc/mtd | wc -l) = 6 ]; then
7                         [ -f /proc/sys/diag ] && echo 5 > /proc/sys/diag
8                         mtd unlock linux
9                         mtd erase OpenWrt
10                         jffs2root --move
11                 else
12                         mtd unlock rootfs
13                         mount -o remount,rw /dev/root /
14                 fi
15         else
16                 if [ -z "$(nvram get no_root_swap)" ]; then
17                         mtd unlock OpenWrt
18                         mount -t jffs2 /dev/mtdblock/4 /jffs
19                         pivot_root /jffs /jffs/rom
20                         mount none /proc -t proc
21                         mount none /dev -t devfs
22                         umount /rom/proc rom/dev >&-
23                 fi
24         fi
25 fi
26 mount none /tmp -t tmpfs -o nosuid,nodev,mode=1777,size=50%
27 mkdir -p /dev/pts
28 mount none /dev/pts -t devpts