At the hardware level it's quite simple: write the new data to new blocks, then write the meta-data.
> it also depends on what you mean about 'tons of regressions'
Assuming the target is not a symlink to a different volume
Assuming you are allowed to create the tmp file
Assuming you are allowed to overwrite an existing file having the same name as your tmp file
Assuming it's ok to reset meta-data, like file owner, permissions, acls, creation timestamp, etc.
Assuming the performance regression due to fsync is ok (request was for atomic, not durable)
> fsync temp file (may require fsync of directory)
How does one check that requirement in a portable way?
> if you want to be sure the change has taken place, fsync directory.
> no, this isn't "real code", but translating it into your language of choice is not that hard.
But it's far from trivial either.
> There are a lot of programs out there that do this right today.
But there are even more ones that don't. There's also no tool to detect these ones (AFAIK).
> lookup the lwn.net article on safely saving data from a few months back
It also failed to address any of the assumptions / regressions.
Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds