From 0e97d3d4ee013b6f405bebeb2e4383e39a01d1e1 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 20 Feb 2019 21:37:23 +0100 Subject: [PATCH] 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: https://github.com/libuv/libuv/commit/6fc797c3fe18d8df71b36ecf2184f085c0283251 --- src/nvim/os/fs.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index 9a4391a0ae..cead8d802b 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -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; }