about summary refs log tree commit diff
path: root/src/unistd/pwritev.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/unistd/pwritev.c')
-rw-r--r--src/unistd/pwritev.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/unistd/pwritev.c b/src/unistd/pwritev.c
index f5a612c4..44a53d85 100644
--- a/src/unistd/pwritev.c
+++ b/src/unistd/pwritev.c
@@ -1,12 +1,18 @@
-#define _BSD_SOURCE
+#define _GNU_SOURCE
 #include <sys/uio.h>
 #include <unistd.h>
+#include <fcntl.h>
 #include "syscall.h"
 
 ssize_t pwritev(int fd, const struct iovec *iov, int count, off_t ofs)
 {
+	if (ofs == -1) ofs--;
+	int r = __syscall_cp(SYS_pwritev2, fd, iov, count,
+		(long)(ofs), (long)(ofs>>32), RWF_NOAPPEND);
+	if (r != -EOPNOTSUPP && r != -ENOSYS)
+		return __syscall_ret(r);
+	if (fcntl(fd, F_GETFL) & O_APPEND)
+		return __syscall_ret(-EOPNOTSUPP);
 	return syscall_cp(SYS_pwritev, fd, iov, count,
 		(long)(ofs), (long)(ofs>>32));
 }
-
-weak_alias(pwritev, pwritev64);