diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/unistd/pwrite.c | 11 | ||||
| -rw-r--r-- | src/unistd/pwritev.c | 10 | 
2 files changed, 20 insertions, 1 deletions
diff --git a/src/unistd/pwrite.c b/src/unistd/pwrite.c index 869b69f0..a008b3ec 100644 --- a/src/unistd/pwrite.c +++ b/src/unistd/pwrite.c @@ -1,7 +1,18 @@ +#define _GNU_SOURCE  #include <unistd.h> +#include <sys/uio.h> +#include <fcntl.h>  #include "syscall.h"  ssize_t pwrite(int fd, const void *buf, size_t size, off_t ofs)  { +	if (ofs == -1) ofs--; +	int r = __syscall_cp(SYS_pwritev2, fd, +		(&(struct iovec){ .iov_base = (void *)buf, .iov_len = size }), +		1, (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_pwrite, fd, buf, size, __SYSCALL_LL_PRW(ofs));  } diff --git a/src/unistd/pwritev.c b/src/unistd/pwritev.c index becf9deb..44a53d85 100644 --- a/src/unistd/pwritev.c +++ b/src/unistd/pwritev.c @@ -1,10 +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));  }  | 
