summaryrefslogtreecommitdiff
path: root/package/base-files/files/sbin/mount_root
blob: 86d4ef95fbb0f5f785f84d5a6a663e6bbcc8b05f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
. /etc/functions.sh

jffs2_ready () {
	mtdpart="$(find_mtd_part rootfs_data)"
	magic=$(hexdump $mtdpart -n 4 -e '4/1 "%02x"')
	[ "$magic" != "deadc0de" ]
}

grep rootfs_data /proc/mtd >/dev/null 2>/dev/null && {
	. /sbin/firstboot
	mtd unlock rootfs_data
	jffs2_ready && {
		echo "switching to jffs2"
		mount "$(find_mtd_part rootfs_data)" /jffs -t jffs2 && \
			fopivot /jffs /rom
	} || {
		echo "jffs2 not ready yet; using ramdisk"
		ramoverlay
	}
} || {
	mtd unlock rootfs
	mount -o remount,rw /dev/root /
}