8080589: (fs) FileChannel.force should use fcntl(F_FULLFSYNC) instead of fsync on OS X

Replace f[data]sync(fd) with fcntl(fd, F_FULLSYNC) on OS X.

Reviewed-by: alanb
This commit is contained in:
Brian Burkhalter 2015-05-21 09:57:59 -07:00
parent 6deb69ac50
commit 457be276d8

View File

@ -148,6 +148,13 @@ Java_sun_nio_ch_FileDispatcherImpl_force0(JNIEnv *env, jobject this,
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 @@ Java_sun_nio_ch_FileDispatcherImpl_force0(JNIEnv *env, jobject this,
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");
}