diff --git a/src/native/libs/Common/pal_config.h.in b/src/native/libs/Common/pal_config.h.in index abc93358e69f6c..e0d211c087c1ab 100644 --- a/src/native/libs/Common/pal_config.h.in +++ b/src/native/libs/Common/pal_config.h.in @@ -9,7 +9,6 @@ #cmakedefine01 HAVE_FLOCK64 #cmakedefine01 HAVE_F_DUPFD_CLOEXEC #cmakedefine01 HAVE_F_DUPFD -#cmakedefine01 HAVE_F_FULLFSYNC #cmakedefine01 HAVE_O_CLOEXEC #cmakedefine01 HAVE_GETIFADDRS #cmakedefine01 HAVE_UTSNAME_DOMAINNAME diff --git a/src/native/libs/System.Native/pal_io.c b/src/native/libs/System.Native/pal_io.c index 7a7ea2b83c5dd2..908057230ab2cf 100644 --- a/src/native/libs/System.Native/pal_io.c +++ b/src/native/libs/System.Native/pal_io.c @@ -743,13 +743,18 @@ int32_t SystemNative_FSync(intptr_t fd) int fileDescriptor = ToFileDescriptor(fd); int32_t result; - while ((result = -#if defined(TARGET_OSX) && HAVE_F_FULLFSYNC - fcntl(fileDescriptor, F_FULLFSYNC) -#else - fsync(fileDescriptor) +#ifdef TARGET_OSX + while ((result = fcntl(fileDescriptor, F_FULLFSYNC)) < 0 && errno == EINTR); + if (result >= 0) + { + return result; + } + + // F_FULLFSYNC is not supported on all file systems and handle types (e.g., + // network file systems, read-only handles). Fall back to fsync. + // For genuine I/O errors (e.g., EIO), fsync will also fail and propagate the error. #endif - < 0) && errno == EINTR); + while ((result = fsync(fileDescriptor)) < 0 && errno == EINTR); return result; } diff --git a/src/native/libs/configure.cmake b/src/native/libs/configure.cmake index 4da74e115c6db8..1f83f6972d5f93 100644 --- a/src/native/libs/configure.cmake +++ b/src/native/libs/configure.cmake @@ -148,11 +148,6 @@ check_symbol_exists( fcntl.h HAVE_F_DUPFD) -check_symbol_exists( - F_FULLFSYNC - fcntl.h - HAVE_F_FULLFSYNC) - check_function_exists( getifaddrs HAVE_GETIFADDRS)