>Could any of the fsync advocates post real code that does the atomic variant of open, write, close?
> Hint: it's not possible without tons of regressions.
depending on how much you want to write, and what your definition of atomic is, what you are asking for may not be possible.
it also depends on what you mean about 'tons of regressions'
but what you can do is
open temp file
write to temp file
close temp file
fsync temp file (may require fsync of directory)
mv temp file to name of real file
if you want to be sure the change has taken place, fsync directory.
if you are doing this in a shell script, you have to do 'sync' instead of fsync (on ext3, the result is the same, on other filesystems fsync is significantly faster)
no, this isn't "real code", but translating it into your language of choice is not that hard.
There are a lot of programs out there that do this right today. Most mail, nntp, and database apps do this right because their users are unwilling to loose data, and they need to work across different flavors of Unix.
for the longer answer, lookup the lwn.net article on safely saving data from a few months back