8232861: (fc) FileChannel.force fails on WebDAV file systems (macOS)
Reviewed-by: alanb
This commit is contained in:
parent
1ca4abe9f2
commit
6de0bb204a
@ -28,6 +28,8 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/mount.h>
|
||||||
|
#include <sys/param.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
|
|
||||||
@ -167,9 +169,18 @@ Java_sun_nio_ch_FileDispatcherImpl_force0(JNIEnv *env, jobject this,
|
|||||||
|
|
||||||
#ifdef MACOSX
|
#ifdef MACOSX
|
||||||
result = fcntl(fd, F_FULLFSYNC);
|
result = fcntl(fd, F_FULLFSYNC);
|
||||||
if (result == -1 && errno == ENOTSUP) {
|
if (result == -1) {
|
||||||
/* Try fsync() in case F_FULLSYUNC is not implemented on the file system. */
|
struct statfs fbuf;
|
||||||
result = fsync(fd);
|
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 */
|
#else /* end MACOSX, begin not-MACOSX */
|
||||||
if (md == JNI_FALSE) {
|
if (md == JNI_FALSE) {
|
||||||
|
Loading…
Reference in New Issue
Block a user