Skip to content
This repository has been archived by the owner on Jan 10, 2019. It is now read-only.

Commit

Permalink
8080589: (fs) FileChannel.force should use fcntl(F_FULLFSYNC) instead…
Browse files Browse the repository at this point in the history
… of fsync on OS X

Summary: Replace f[data]sync(fd) with fcntl(fd, F_FULLSYNC) on OS X.
Reviewed-by: alanb
  • Loading branch information
bpb committed May 21, 2015
1 parent 333ae61 commit 4449192
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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");
}

Expand Down

0 comments on commit 4449192

Please sign in to comment.