Power-fail safe writes

Sebastian Brand sebastian.brand at axis.com
Tue Apr 2 07:41:05 UTC 2019


Hello,

I recently had problems when updating a configuration file using sed with in-place edit option (-i), shortly followed by a power fail, which has the end result of an empty configuration file and a system that won't boot.
The reason behind this is me relying on sed and sed in-place editing not using a power-fail safe write pattern (copy, edit copy, synchronize copy, rename, synchronize folder).
I have locally written a feature to enable "safe write" for sed, but since this is a problem for many flash filesystems there might be more people interested in this? (Perhaps especially people using Busybox for embedded systems?) And this is probably not only relevant for sed?

There is also a part 2 that arises when trying to "manually" do a safe write: since the fsync applet uses the O_NOATIME flag it is impossible for user1:group1 to synchronize a directory owned by user2:group1 (you get an "Operation not permitted" error from fsync). Is this intended? (Using gnu sync [8.26] and synchronizing on a specific folder works for the same situation.)

Regards
Sebastian Brand
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20190402/ce509535/attachment.html>


More information about the busybox mailing list