When you call fsync on a file, you flush its buffer and make sure it gets written to disk.
But if your program newly creates a file, then that needs to get recorded in the metadata of the parent directory. Thus, even if you fsync
a file, it's not guaranteed to be persistent in the file system yet. You need to flush the parent directory's buffer as well.
Is there a simple call, such as fsync_parent(fd)
that'll accomplish this? If?
(Looking at this question, it seems there's no C standard way to get the parent directory of a file)