[sysupgrade] Don't try to pivot to new ramfs if already running on one
[openwrt.git] / package / base-files / files / sbin / mount_root
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3 . /etc/functions.sh
4
5 jffs2_ready () {
6         mtdpart="$(find_mtd_part rootfs_data)"
7         magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"')
8         [ "$magic" != "deadc0de" ]
9 }
10
11 grep rootfs_data /proc/mtd >/dev/null 2>/dev/null && {
12         . /bin/firstboot
13         mtd unlock rootfs_data
14         jffs2_ready && {
15                 echo "switching to jffs2"
16                 mount "$(find_mtd_part rootfs_data)" /jffs -t jffs2 && \
17                         fopivot /jffs /rom
18         } || {
19                 echo "jffs2 not ready yet; using ramdisk"
20                 ramoverlay
21         }
22 } || {
23         mtd unlock rootfs
24         mount -o remount,rw /dev/root /
25 }