[OpenWrt-Devel] [PATCH] fstools: Check FS state before writing

Wojciech Dubowik Wojciech.Dubowik at neratec.com
Fri Jan 8 06:07:43 EST 2016


It reduces number of flash writes on systems with FS ready.

Signed-off-by: Wojciech Dubowik <Wojciech.Dubowik at neratec.com>
---
 libfstools/overlay.c | 3 ++-
 mount_root.c         | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libfstools/overlay.c b/libfstools/overlay.c
index 7f69606..b51a6ae 100644
--- a/libfstools/overlay.c
+++ b/libfstools/overlay.c
@@ -251,7 +251,8 @@ jffs2_switch(struct volume *v)
 		return ret;
 
 	sync();
-	fs_state_set("/overlay", FS_STATE_READY);
+	if (fs_state_get("/overlay") != FS_STATE_READY)
+		fs_state_set("/overlay", FS_STATE_READY);
 	return 0;
 }
 
diff --git a/mount_root.c b/mount_root.c
index bf70265..29b2758 100644
--- a/mount_root.c
+++ b/mount_root.c
@@ -106,7 +106,8 @@ done(int argc, char *argv[1])
 
 	case FS_JFFS2:
 	case FS_UBIFS:
-		fs_state_set("/overlay", FS_STATE_READY);
+		if (fs_state_get("/overlay") != FS_STATE_READY)
+			fs_state_set("/overlay", FS_STATE_READY);
 		break;
 	}
 
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list