fsync(2) manpage tells syncing directory is explicitly needed if a file is synced.
How about Java's sync method in io package? Does is take care about that? Does it depend on OS and/or file system?
I found nothing helpful in http://docs.oracle.com/javase/7/docs/api/java/io/FileDescriptor.html#sync...
The
fsyncmanual page states that callingfsyncon a file does not imply the associated directory will be fsynced as well. If required,fsynchas to be called for the directory.I can see several good reasons for that definition/behavior:
With that out of the way, let's look into Java's definition/behavior.
The JavaDoc does not mention anything in respect to associated filesystem objects like directories. Additionally, I don't see a way to get a
FileDescriptorinstance for a directory.Looking at the behavior of the OpenJDK implementation based on its source code,
java.io.FileDescriptor.sync()simply triggers anfsyncon UNIX andFlushFileBufferson Windows.So, no,
java.io.FileDescriptor.sync()does not affect associated directories in any way.