xref: /aosp_15_r20/external/musl/src/unistd/pwritev.c (revision c9945492fdd68bbe62686c5b452b4dc1be3f8453)
1 #define _GNU_SOURCE
2 #include <sys/uio.h>
3 #include <unistd.h>
4 #include <fcntl.h>
5 #include "syscall.h"
6 
pwritev(int fd,const struct iovec * iov,int count,off_t ofs)7 ssize_t pwritev(int fd, const struct iovec *iov, int count, off_t ofs)
8 {
9 	if (ofs == -1) ofs--;
10 	int r = __syscall_cp(SYS_pwritev2, fd, iov, count,
11 		(long)(ofs), (long)(ofs>>32), RWF_NOAPPEND);
12 	if (r != -EOPNOTSUPP && r != -ENOSYS)
13 		return __syscall_ret(r);
14 	if (fcntl(fd, F_GETFL) & O_APPEND)
15 		return __syscall_ret(-EOPNOTSUPP);
16 	return syscall_cp(SYS_pwritev, fd, iov, count,
17 		(long)(ofs), (long)(ofs>>32));
18 }
19