[PATCH] fstools: prevent error log when temporary overlay is empty

Zefir Kurtisi zefir.kurtisi at westermo.com
Tue Dec 15 08:43:09 EST 2020


When a FW upgrade is performed without keeping the
current config, the temporary overlay directory is
eventually empty and causes the archive copy to /
to fail. This has no functional impact but adds a
false 'failed to sync jffs2 overlay' to the error
log.

Fix this by explicitly checking for the directory
to exist and being non-empty.

Signed-off-by: Zefir Kurtisi <zefir.kurtisi at westermo.com>
---
 libfstools/overlay.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libfstools/overlay.c b/libfstools/overlay.c
index eadafcf..d3987a8 100644
--- a/libfstools/overlay.c
+++ b/libfstools/overlay.c
@@ -315,6 +315,11 @@ jffs2_switch(struct volume *v)
 		umount2("/tmp/root", MNT_DETACH);
 		foreachdir("/overlay/", handle_whiteout);
 
+		/* prevent below cp command failing with empty temporary overlay */
+		if (system("[ ! -d /tmp/root/upper ] || [ -z \"$(ls -A /tmp/root/upper/)\" ]")) {
+			ULOG_INFO("temporary overlay empty\n");
+			break;
+		}
 		/* try hard to be in sync */
 		ULOG_INFO("syncronizing overlay\n");
 		if (system("cp -a /tmp/root/upper/* / 2>/dev/null"))
-- 
2.17.1




More information about the openwrt-devel mailing list