> Atomicity is a solved problem. Just create the new config file as a separate file, then use rename() to get either the old or new file. Every filesystem that I know of has this semantic with rename (yes, I know it's not strictly in POSIX.) Every major UNIX text editor (vi, emacs, etc.) uses the rename() trick by default.
Doesn't that blow away the file ownership, permissions, ACL and extended attribute information?
Posted Jan 31, 2010 9:35 UTC (Sun) by anselm (subscriber, #2796)
[Link]
In the general case, yes. In the case of config files this is rarely an
issue -- if you can do »rename()« on the original file (write to the
parent directory,
really), you're usually in a position to set up the permissions etc. of
the
new file to match the old, and it's not as if there are lots of obvious
choices for these, anyway.