[LEDE-DEV] [PATCH] base-files: uci-defaults: do config flush in one shot

John Crispin john at phrozen.org
Tue Dec 12 02:19:51 PST 2017



On 02/12/17 00:26, Roman Yeryomin wrote:
> Moving a file between tmpfs and other fs is neither
> faster nor safer, thus no point in doing it in two steps.
>
> Signed-off-by: Roman Yeryomin <roman at advem.lv>

Hi Roman,

The code needs to stay like this. the moment you start the command with 
redirection, the shell will truncate the target file and wont write it 
until a flush() or close() is called. this would leave a window where 
the file is 0 bytes. doing this in 2 steps mitigates that problem.

     John

> ---
>   package/base-files/files/lib/functions/uci-defaults.sh | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/package/base-files/files/lib/functions/uci-defaults.sh b/package/base-files/files/lib/functions/uci-defaults.sh
> index 0cd519a147..8eab5ac1e1 100755
> --- a/package/base-files/files/lib/functions/uci-defaults.sh
> +++ b/package/base-files/files/lib/functions/uci-defaults.sh
> @@ -633,6 +633,5 @@ board_config_update() {
>   }
>   
>   board_config_flush() {
> -	json_dump -i > /tmp/.board.json
> -	mv /tmp/.board.json ${CFG}
> +	json_dump -i > ${CFG}
>   }




More information about the Lede-dev mailing list