Skip to content

Commit

Permalink
8232861: (fc) FileChannel.force fails on WebDAV file systems (macOS)
Browse files Browse the repository at this point in the history
Reviewed-by: alanb
  • Loading branch information
Brian Burkhalter committed Apr 9, 2021
1 parent 1ca4abe commit 6de0bb2
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/java.base/unix/native/libnio/ch/FileDispatcherImpl.c
Expand Up @@ -28,6 +28,8 @@
#include <fcntl.h>
#include <sys/uio.h>
#include <unistd.h>
#include <sys/mount.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/statvfs.h>

Expand Down Expand Up @@ -167,9 +169,18 @@ Java_sun_nio_ch_FileDispatcherImpl_force0(JNIEnv *env, jobject this,

#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);
if (result == -1) {
struct statfs fbuf;
int errno_fcntl = errno;
if (fstatfs(fd, &fbuf) == 0) {
if ((fbuf.f_flags & MNT_LOCAL) == 0) {
/* Try fsync() in case file is not local. */
result = fsync(fd);
}
} else {
/* fstatfs() failed so restore errno from fcntl(). */
errno = errno_fcntl;
}
}
#else /* end MACOSX, begin not-MACOSX */
if (md == JNI_FALSE) {
Expand Down

1 comment on commit 6de0bb2

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.