summaryrefslogtreecommitdiff
path: root/libfstools/overlay.c
diff options
context:
space:
mode:
authorRoman Yeryomin <roman@advem.lv>2017-12-15 16:10:30 +0200
committerJohn Crispin <john@phrozen.org>2018-01-02 07:54:17 +0100
commit11efbf3b90f031ce634fc38cad07a4aef2985777 (patch)
treec905560e5d0fdb34460132a34f1a135698ac9b7f /libfstools/overlay.c
parentbdeb95a849913bfe2c0eff5d03857c79a4c7d66d (diff)
downloadfstools-11efbf3b90f031ce634fc38cad07a4aef2985777.tar.gz
overlay: fix race condition when switching to jffs2
There is a race between `cp -a /tmp/root/* /rom/overlay` from libfstools/overlay.c and a process creating new file(s) before pivot(/rom, /mnt) occured. That is a process can create a file and it will not be copied. To workaround this, do additional copy after jffs2 is ready. This doesn't completely solve the problem but since there was no other fix provided since original RFC [1], it is better than nothiing. [1] https://www.mail-archive.com/openwrt-devel@lists.openwrt.org/msg38218.html Signed-off-by: Roman Yeryomin <roman@advem.lv>
Diffstat (limited to 'libfstools/overlay.c')
-rw-r--r--libfstools/overlay.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libfstools/overlay.c b/libfstools/overlay.c
index 7ada5ff..8423a57 100644
--- a/libfstools/overlay.c
+++ b/libfstools/overlay.c
@@ -243,6 +243,10 @@ jffs2_switch(struct volume *v)
ULOG_INFO("performing overlay whiteout\n");
umount2("/tmp/root", MNT_DETACH);
foreachdir("/overlay/", handle_whiteout);
+
+ /* try hard to be in sync */
+ ULOG_INFO("syncronizing overlay\n");
+ system("cp -a /tmp/root/upper/* / 2>/dev/null");
break;
case FS_EXT4: