Patchwork [OpenWrt-Devel] base-files: implement new config "root_readonly" (RESENT)

login
register
Submitter ching
Date 2012-04-21 12:54:44
Message ID <4F92AE14.102@gmail.com>
Download mbox | patch
Permalink /patch/2104/
State New
Headers show

Comments

ching - 2012-04-21 12:54:44
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 <lsching17@gmail.com>

1 files changed

Patch

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