fix "E667: Fsync failed" on macOS

macOS: Try direct fsync() if F_FULLFSYNC fails.
closes #6725
ref https://github.com/vim/vim/pull/4016
vim-patch:8.1.0957

> on macOS F_FULLFSYNC fails with ENOTSUP for unsupported storage systems
> (e.g. SMB), though this is not documented in the Apple fcntl man page.

libuv fixed this in v1.25.0:
6fc797c3fe
This commit is contained in:
Justin M. Keyes 2019-02-20 21:37:23 +01:00
parent 40f5a6c4da
commit 0e97d3d4ee

View File

@ -643,12 +643,19 @@ ptrdiff_t os_write(const int fd, const char *const buf, const size_t size,
///
/// @param fd the file descriptor of the file to flush to disk.
///
/// @return `0` on success, a libuv error code on failure.
/// @return 0 on success, or libuv error code on failure.
int os_fsync(int fd)
{
int r;
RUN_UV_FS_FUNC(r, uv_fs_fsync, fd, NULL);
g_stats.fsync++;
#ifdef __APPLE__
// TODO(justinmk): Remove this after it is fixed in libuv. #6725
if (r == UV_ENOTSUP) {
int rv = fsync(fd);
return rv ? -rv : rv;
}
#endif
return r;
}