8080589: (fs) FileChannel.force should use fcntl(F_FULLFSYNC) instead of fsync on OS X
authorbpb
Thu, 21 May 2015 09:57:59 -0700
changeset 30689 446373feb21e
parent 30688 7f1db57197d4
child 30690 f6d8413a278c
8080589: (fs) FileChannel.force should use fcntl(F_FULLFSYNC) instead of fsync on OS X Summary: Replace f[data]sync(fd) with fcntl(fd, F_FULLSYNC) on OS X. Reviewed-by: alanb
jdk/src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c
--- a/jdk/src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c	Thu May 21 17:42:15 2015 +0100
+++ b/jdk/src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c	Thu May 21 09:57:59 2015 -0700
@@ -148,6 +148,13 @@
     jint fd = fdval(env, fdo);
     int result = 0;
 
+#ifdef MACOSX
+    result = fcntl(fd, F_FULLFSYNC);
+    if (result == -1 && errno == ENOTSUP) {
+        /* Try fsync() in case F_FULLSYUNC is not implemented on the file system. */
+        result = fsync(fd);
+    }
+#else /* end MACOSX, begin not-MACOSX */
     if (md == JNI_FALSE) {
         result = fdatasync(fd);
     } else {
@@ -163,9 +170,10 @@
         if (getfl >= 0 && (getfl & O_ACCMODE) == O_RDONLY) {
             return 0;
         }
-#endif
+#endif /* _AIX */
         result = fsync(fd);
     }
+#endif /* not-MACOSX */
     return handle(env, result, "Force failed");
 }