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

Felix Fietkau nbd at nbd.name
Tue Dec 12 03:37:56 PST 2017


On 2017-12-12 11:19, John Crispin wrote:
> 
> 
> 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.
I think Roman has a point that even now it's unsafe and leaves a time
window where the file is incomplete. That said, it's not a good reason
to make this window even bigger. We could easily fix this entirely by
storing the intermediate file in /etc instead of /tmp to ensure that
it's on the same filesystem as the target file.

- Felix



More information about the Lede-dev mailing list