From 85e1a565606d04626966321f63db53005d4b162b Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 30 Jul 2016 18:14:04 +0300 Subject: os/fileio: Allow certain failures during file_fsync MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit According to the documentation fsync() may fail with EROFS or EINVAL if “file descriptor is bound to a special file which does not support synchronization” (e.g. /dev/stderr). This condition is completely valid in this case since main point of `file_fsync()` is dumping buffered input. --- src/nvim/os/fileio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/nvim/os/fileio.c') diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index cf5bfd60ae..02b471ef7e 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -153,7 +153,11 @@ int file_fsync(FileDescriptor *const fp) fp->_error = 0; return error; } - return os_fsync(fp->fd); + const int error = os_fsync(fp->fd); + if (error != UV_EINVAL && error != UV_EROFS) { + return error; + } + return 0; } /// Buffer used for writing -- cgit From 222d98310a3b196cf21ca5885765b2ddca9195b6 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sat, 30 Jul 2016 18:14:25 +0300 Subject: os/fileio: Support appending to a file --- src/nvim/os/fileio.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/nvim/os/fileio.c') diff --git a/src/nvim/os/fileio.c b/src/nvim/os/fileio.c index 02b471ef7e..775f2bd449 100644 --- a/src/nvim/os/fileio.c +++ b/src/nvim/os/fileio.c @@ -62,6 +62,8 @@ int file_open(FileDescriptor *const ret_fp, const char *const fname, FLAG(flags, kFileCreate, O_CREAT|O_WRONLY, kTrue, !(flags & kFileCreateOnly)); FLAG(flags, kFileTruncate, O_TRUNC|O_WRONLY, kTrue, !(flags & kFileCreateOnly)); + FLAG(flags, kFileAppend, O_APPEND|O_WRONLY, kTrue, + !(flags & kFileCreateOnly)); FLAG(flags, kFileReadOnly, O_RDONLY, kFalse, wr != kTrue); #ifdef O_NOFOLLOW FLAG(flags, kFileNoSymlink, O_NOFOLLOW, kNone, true); -- cgit