aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-02-20 21:37:23 +0100
committerJustin M. Keyes <justinkz@gmail.com>2019-02-21 02:00:51 +0100
commit0e97d3d4ee013b6f405bebeb2e4383e39a01d1e1 (patch)
tree89f0df13b2df4925d1261ce0ab3485707427e118
parent40f5a6c4dafe4bbca227d4c6bda0d9a94d817d71 (diff)
downloadrneovim-0e97d3d4ee013b6f405bebeb2e4383e39a01d1e1.tar.gz
rneovim-0e97d3d4ee013b6f405bebeb2e4383e39a01d1e1.tar.bz2
rneovim-0e97d3d4ee013b6f405bebeb2e4383e39a01d1e1.zip
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
-rw-r--r--src/nvim/os/fs.c9
1 files changed, 8 insertions, 1 deletions
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;
}