Conversation

So, for the standard primitive approach to safe writes, fsync(fd), check for errors, and then only rename it to clobber the original file if it was successful. For multiple files, can have dir_a and dir_b, alternating where you write, and atomically flip a symlink between them.
2