[LEDE-DEV] [PATCH] base-files: add comment to uci-defaults.sh script

John Crispin john at phrozen.org
Tue Dec 12 02:24:53 PST 2017


add comment explaining why we generate board.json in 2 steps

Signed-off-by: John Crispin <john at phrozen.org>
---
 package/base-files/files/lib/functions/uci-defaults.sh | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
index 82ac1d2a4d..fd37088208 100755
--- a/package/base-files/files/lib/functions/uci-defaults.sh
+++ b/package/base-files/files/lib/functions/uci-defaults.sh
@@ -609,6 +609,10 @@ board_config_update() {
 }
 
 board_config_flush() {
+	# when calling json_dump with a redirect, the shell will truncate the target
+	# file and not update it until a close/flush is called. this results in a short
+	# window where the file is 0 bytes. mitigate the issue by generating the file
+	# in 2 steps
 	json_dump -i > /tmp/.board.json
 	mv /tmp/.board.json ${CFG}
 }
-- 
2.11.0




More information about the Lede-dev mailing list