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 fsync
manual page states that calling fsync
on a file does not imply the associated directory will be fsynced as well. If required, fsync
has 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 FileDescriptor
instance for a directory.
Looking at the behavior of the OpenJDK implementation based on its source code, java.io.FileDescriptor.sync()
simply triggers an fsync
on UNIX and FlushFileBuffers
on Windows.
So, no, java.io.FileDescriptor.sync()
does not affect associated directories in any way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With