From 20716634a8ca6a55523e494658a4169e33d6d118 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Fri, 15 Mar 2019 18:45:39 -0700 Subject: [PATCH] ircd::fs: Improve condition for RWF_APPEND/pwritev2() -1 offset value. --- ircd/fs.cc | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ircd/fs.cc b/ircd/fs.cc index 42b41a5f8..c4e795e8f 100644 --- a/ircd/fs.cc +++ b/ircd/fs.cc @@ -821,20 +821,16 @@ ircd::fs::append(const string_view &path, // the -1. Otherwise, we don't keep flags in userspace and we // don't check the fd for whether it was opened with O_APPEND // so the user may just have to eat the cost of an extra lseek(). -#ifdef HAVE_PWRITEV2 +#if defined(HAVE_PWRITEV2) && defined(RWF_APPEND) size_t ircd::fs::append(const fd &fd, const const_buffers &bufs, const write_opts &opts_) { auto opts(opts_); - - #if defined(RWF_APPEND) if(support_append) opts.offset = -1; - #endif - - if(!opts.offset) + else if(!opts.offset || opts.offset == -1) opts.offset = syscall(::lseek, fd, 0, SEEK_END); return write(fd, bufs, opts);