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

Matthias Schiffer mschiffer at universe-factory.net
Tue Dec 12 02:38:26 PST 2017


On 12/12/2017 11:24 AM, John Crispin wrote:
> 
>  
>  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

As Roman correctly noted in his patch, this is not the case. The file is
moved between different filesystems (tmpfs to actual root), which is never
guaranteed to be atomic; internally, rename() can't be used, so mv just
falls back to truncate+write as well. The mv makes the race window shorter,
but does not completely mitigate it.

Either the comment should correctly reflect the situation, or we should
actually fix this by creating the temporary file on the root fs.

Regards,
Matthias

>  	json_dump -i > /tmp/.board.json
>  	mv /tmp/.board.json ${CFG}
>  }
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/lede-dev/attachments/20171212/40602478/attachment.sig>


More information about the Lede-dev mailing list