In the view of user, we always hard power-off router, and do not expect any unexpected background flashing which can lead to fs corruption.

As the number of package of OpenWRT increases, the probability of unexpected background flashing will increase.

Although OpenWRT developers are brilliant and hard-working, it is impossible to guarantee all packages are bug-free.

This change try to implement a new config "root_readonly" in /etc/config/system, which will remount root to read only when reading system config during boot process. This should prevent background flashing.

root_readonly=0 #0 - root will be read-write, 1 - root will be read-only

Assumption
1. Early boot process do not trigger unnecessary flashing
2. default setting=0 (read-write) to preserve backward compatibility
3. user know how to remount root rw manually if he/she set this option

Signed-off-by: ching <[email protected]>

2 files changed
Index: trunk/package/base-files/files/etc/init.d/boot
===================================================================
--- trunk/package/base-files/files/etc/init.d/boot	(revision 31391)
+++ trunk/package/base-files/files/etc/init.d/boot	(working copy)
@@ -7,7 +7,11 @@
 system_config() {
 	local cfg="$1"
 
-	local hostname conloglevel timezone
+	local hostname conloglevel timezone root_readonly
+	
+	#remount root as readonly
+	config_get root_readonly "$cfg" root_readonly '0'
+	[ "$root_readonly" -eq 1 ] && mount -o remount,ro /
 
 	config_get hostname "$cfg" hostname 'OpenWrt'
 	echo "$hostname" > /proc/sys/kernel/hostname
Index: trunk/package/base-files/files/etc/config/system
===================================================================
--- trunk/package/base-files/files/etc/config/system	(revision 31391)
+++ trunk/package/base-files/files/etc/config/system	(working copy)
@@ -1,6 +1,7 @@
 config system
 	option hostname	OpenWrt
 	option timezone	UTC
+	option root_readonly 0	#0 - root will be read-write, 1 - root will be read-only
 
 config timeserver ntp
 	list server	0.openwrt.pool.ntp.org
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to