summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorptrcnull <git@ptrcnull.me>2022-07-13 04:58:08 +0200
committerAnna Wilcox <awilcox@wilcox-tech.com>2024-10-22 18:49:03 +0000
commit73b40546d59c6bebd782aeaa15a6bdc8109485bd (patch)
treeef800a6421a4d2f865a6f964bdc5c860ec411d1f
parent5f3f23455481dfded84206d4ad15c7578c210f17 (diff)
downloadgcompat-73b40546d59c6bebd782aeaa15a6bdc8109485bd.tar.gz
gcompat-73b40546d59c6bebd782aeaa15a6bdc8109485bd.tar.bz2
gcompat-73b40546d59c6bebd782aeaa15a6bdc8109485bd.tar.xz
gcompat-73b40546d59c6bebd782aeaa15a6bdc8109485bd.zip
uio: add pwritev64v2 and preadv64v2
-rw-r--r--Makefile1
-rw-r--r--libgcompat/uio.c32
2 files changed, 33 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 426513f..641249b 100644
--- a/Makefile
+++ b/Makefile
@@ -34,6 +34,7 @@ LIBGCOMPAT_SRC = \
libgcompat/syslog.c \
libgcompat/time.c \
libgcompat/ucontext.c \
+ libgcompat/uio.c \
libgcompat/unistd.c \
libgcompat/utmp.c \
libgcompat/version.c \
diff --git a/libgcompat/uio.c b/libgcompat/uio.c
new file mode 100644
index 0000000..797cb3a
--- /dev/null
+++ b/libgcompat/uio.c
@@ -0,0 +1,32 @@
+#include <sys/syscall.h>
+#include <sys/uio.h> /* iovec, pwritev, preadv */
+#include <errno.h> /* errno */
+#include <unistd.h> /* syscall */
+
+ssize_t pwritev64v2(int fd, const struct iovec *iov, int count, off_t ofs, int flags)
+{
+ if (flags != 0) {
+ errno = ENOTSUP;
+ return -1;
+ }
+
+ if (ofs == -1) {
+ return writev(fd, iov, count);
+ }
+
+ return syscall(__NR_pwritev2, fd, iov, count, ofs);
+}
+
+ssize_t preadv64v2(int fd, const struct iovec *iov, int count, off_t ofs, int flags)
+{
+ if (flags != 0) {
+ errno = ENOTSUP;
+ return -1;
+ }
+
+ if (ofs == -1) {
+ return readv(fd, iov, count);
+ }
+
+ return syscall(__NR_preadv2, fd, iov, count, ofs);
+}