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

Roman Yeryomin roman at advem.lv
Thu Dec 14 07:30:59 PST 2017


On 2017-12-12 13:41, John Crispin wrote:
> On 12/12/17 12:37, Felix Fietkau wrote:
>> 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.

Exactly

>> 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.

Would it make any difference if json_dump already failed and wrote 
incomplete/wrong/none information?

> 
> or add a -w <file> parameter to json_dump to have it write the file 
> directly
> 

Probably this could be faster. But IMO there is no perfect solution. We 
can only introduce error checking using siphash or similar. Though in 
this case it's probably an overkill.
Redirecting output or writing directly from jshn should have similar 
effect.


Regards,
Roman




More information about the Lede-dev mailing list