Module Name: src
Committed By: thorpej
Date: Mon Sep 20 02:20:03 UTC 2021
Modified Files:
src/sys/compat/linux/arch/alpha: syscalls.master
src/sys/compat/linux/arch/amd64: syscalls.master
src/sys/compat/linux/arch/arm: syscalls.master
src/sys/compat/linux/arch/i386: syscalls.master
src/sys/compat/linux/arch/m68k: syscalls.master
src/sys/compat/linux/arch/mips: syscalls.master
src/sys/compat/linux/arch/powerpc: syscalls.master
src/sys/compat/linux/common: linux_file.c
src/sys/compat/linux32/arch/amd64: syscalls.master
src/sys/compat/linux32/common: linux32_misc.c
Log Message:
Add preadv(2) and pwritev(2) system calls to COMPAT_LINUX and COMPAT_LINUX32.
To generate a diff of this commit:
cvs rdiff -u -r1.100 -r1.101 src/sys/compat/linux/arch/alpha/syscalls.master
cvs rdiff -u -r1.65 -r1.66 src/sys/compat/linux/arch/amd64/syscalls.master
cvs rdiff -u -r1.72 -r1.73 src/sys/compat/linux/arch/arm/syscalls.master
cvs rdiff -u -r1.127 -r1.128 src/sys/compat/linux/arch/i386/syscalls.master
cvs rdiff -u -r1.98 -r1.99 src/sys/compat/linux/arch/m68k/syscalls.master
cvs rdiff -u -r1.71 -r1.72 src/sys/compat/linux/arch/mips/syscalls.master
cvs rdiff -u -r1.77 -r1.78 src/sys/compat/linux/arch/powerpc/syscalls.master
cvs rdiff -u -r1.119 -r1.120 src/sys/compat/linux/common/linux_file.c
cvs rdiff -u -r1.74 -r1.75 src/sys/compat/linux32/arch/amd64/syscalls.master
cvs rdiff -u -r1.32 -r1.33 src/sys/compat/linux32/common/linux32_misc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/compat/linux/arch/alpha/syscalls.master
diff -u src/sys/compat/linux/arch/alpha/syscalls.master:1.100 src/sys/compat/linux/arch/alpha/syscalls.master:1.101
--- src/sys/compat/linux/arch/alpha/syscalls.master:1.100 Mon Sep 20 00:09:01 2021
+++ src/sys/compat/linux/arch/alpha/syscalls.master Mon Sep 20 02:20:02 2021
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.100 2021/09/20 00:09:01 thorpej Exp $
+ $NetBSD: syscalls.master,v 1.101 2021/09/20 02:20:02 thorpej Exp $
;
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@@ -784,8 +784,12 @@
487 STD { int|linux_sys||dup3(int from, int to, int flags); }
488 STD { int|linux_sys||pipe2(int *pfds, int flags); }
489 UNIMPL inotify_init1
-490 UNIMPL preadv
-491 UNIMPL pwritev
+490 STD { int|linux_sys||preadv(int fd, \
+ const struct iovec *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
+491 STD { int|linux_sys||pwritev(int fd, \
+ const struct iovcnt *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
492 UNIMPL rt_tgsigqueueinfo
493 UNIMPL perf_counter_open
494 UNIMPL fanotify_init
Index: src/sys/compat/linux/arch/amd64/syscalls.master
diff -u src/sys/compat/linux/arch/amd64/syscalls.master:1.65 src/sys/compat/linux/arch/amd64/syscalls.master:1.66
--- src/sys/compat/linux/arch/amd64/syscalls.master:1.65 Mon Sep 20 00:09:01 2021
+++ src/sys/compat/linux/arch/amd64/syscalls.master Mon Sep 20 02:20:02 2021
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.65 2021/09/20 00:09:01 thorpej Exp $
+ $NetBSD: syscalls.master,v 1.66 2021/09/20 02:20:02 thorpej Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@@ -539,8 +539,12 @@
292 STD { int|linux_sys||dup3(int from, int to, int flags); }
293 STD { int|linux_sys||pipe2(int *pfds, int flags); }
294 UNIMPL inotify_init1
-295 UNIMPL preadv
-296 UNIMPL pwritev
+295 STD { int|linux_sys||preadv(int fd, \
+ const struct iovec *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
+296 STD { int|linux_sys||pwritev(int fd, \
+ const struct iovcnt *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
297 UNIMPL rt_tgsigqueueinfo
298 UNIMPL perf_counter_open
299 STD { int|linux_sys||recvmmsg(int s, \
Index: src/sys/compat/linux/arch/arm/syscalls.master
diff -u src/sys/compat/linux/arch/arm/syscalls.master:1.72 src/sys/compat/linux/arch/arm/syscalls.master:1.73
--- src/sys/compat/linux/arch/arm/syscalls.master:1.72 Mon Sep 20 00:09:01 2021
+++ src/sys/compat/linux/arch/arm/syscalls.master Mon Sep 20 02:20:02 2021
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.72 2021/09/20 00:09:01 thorpej Exp $
+ $NetBSD: syscalls.master,v 1.73 2021/09/20 02:20:02 thorpej Exp $
; Derived from sys/compat/linux/arch/*/syscalls.master
; and from Linux 2.4.12 arch/arm/kernel/calls.S
@@ -579,8 +579,12 @@
358 STD { int|linux_sys||dup3(int from, int to, int flags); }
359 STD { int|linux_sys||pipe2(int *pfds, int flags); }
360 UNIMPL inotify_init1
-361 UNIMPL preadv
-362 UNIMPL pwritev
+361 STD { int|linux_sys||preadv(int fd, \
+ const struct iovec *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
+362 STD { int|linux_sys||pwritev(int fd, \
+ const struct iovcnt *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
363 UNIMPL rt_tgsigqueueinfo
364 UNIMPL perf_counter_open
365 STD { int|linux_sys||recvmmsg(int s, \
Index: src/sys/compat/linux/arch/i386/syscalls.master
diff -u src/sys/compat/linux/arch/i386/syscalls.master:1.127 src/sys/compat/linux/arch/i386/syscalls.master:1.128
--- src/sys/compat/linux/arch/i386/syscalls.master:1.127 Mon Sep 20 00:09:01 2021
+++ src/sys/compat/linux/arch/i386/syscalls.master Mon Sep 20 02:20:02 2021
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.127 2021/09/20 00:09:01 thorpej Exp $
+ $NetBSD: syscalls.master,v 1.128 2021/09/20 02:20:02 thorpej Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@@ -546,8 +546,12 @@
330 STD { int|linux_sys||dup3(int from, int to, int flags); }
331 STD { int|linux_sys||pipe2( int *pfds, int flags); }
332 UNIMPL inotify_init1
-333 UNIMPL preadv
-334 UNIMPL pwritev
+333 STD { int|linux_sys||preadv(int fd, \
+ const struct iovec *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
+334 STD { int|linux_sys||pwritev(int fd, \
+ const struct iovcnt *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
335 UNIMPL rt_tgsigqueueinfo
336 UNIMPL perf_counter_open
337 UNIMPL recvmmsg
Index: src/sys/compat/linux/arch/m68k/syscalls.master
diff -u src/sys/compat/linux/arch/m68k/syscalls.master:1.98 src/sys/compat/linux/arch/m68k/syscalls.master:1.99
--- src/sys/compat/linux/arch/m68k/syscalls.master:1.98 Mon Sep 20 00:09:01 2021
+++ src/sys/compat/linux/arch/m68k/syscalls.master Mon Sep 20 02:20:02 2021
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.98 2021/09/20 00:09:01 thorpej Exp $
+ $NetBSD: syscalls.master,v 1.99 2021/09/20 02:20:02 thorpej Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@@ -564,8 +564,12 @@
326 STD { int|linux_sys||dup3(int from, int to, int flags); }
327 STD { int|linux_sys||pipe2(int *pfds, int flags); }
328 UNIMPL inotify_init1
-329 UNIMPL preadv
-330 UNIMPL pwritev
+329 STD { int|linux_sys||preadv(int fd, \
+ const struct iovec *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
+330 STD { int|linux_sys||pwritev(int fd, \
+ const struct iovcnt *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
331 UNIMPL rt_tgsigqueueinfo
332 UNIMPL perf_counter_open
333 UNIMPL set_thread_area
Index: src/sys/compat/linux/arch/mips/syscalls.master
diff -u src/sys/compat/linux/arch/mips/syscalls.master:1.71 src/sys/compat/linux/arch/mips/syscalls.master:1.72
--- src/sys/compat/linux/arch/mips/syscalls.master:1.71 Mon Sep 20 00:09:01 2021
+++ src/sys/compat/linux/arch/mips/syscalls.master Mon Sep 20 02:20:02 2021
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.71 2021/09/20 00:09:01 thorpej Exp $
+ $NetBSD: syscalls.master,v 1.72 2021/09/20 02:20:02 thorpej Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@@ -553,8 +553,12 @@
327 STD { int|linux_sys||dup3(int from, int to, int flags); }
328 STD { int|linux_sys||pipe2(int *pfds, int flags); }
329 UNIMPL inotify_init1
-330 UNIMPL preadv
-331 UNIMPL pwritev
+330 STD { int|linux_sys||preadv(int fd, \
+ const struct iovec *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
+331 STD { int|linux_sys||pwritev(int fd, \
+ const struct iovcnt *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
332 UNIMPL rt_tgsigqueueinfo
333 UNIMPL perf_event_open
334 STD { int|linux_sys||accept4(int s, \
Index: src/sys/compat/linux/arch/powerpc/syscalls.master
diff -u src/sys/compat/linux/arch/powerpc/syscalls.master:1.77 src/sys/compat/linux/arch/powerpc/syscalls.master:1.78
--- src/sys/compat/linux/arch/powerpc/syscalls.master:1.77 Mon Sep 20 00:09:01 2021
+++ src/sys/compat/linux/arch/powerpc/syscalls.master Mon Sep 20 02:20:02 2021
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.77 2021/09/20 00:09:01 thorpej Exp $
+ $NetBSD: syscalls.master,v 1.78 2021/09/20 02:20:02 thorpej Exp $
; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
@@ -553,8 +553,12 @@
317 STD { int|linux_sys||pipe2(int *pfds, int flags); }
318 UNIMPL inotify_init1
319 UNIMPL perf_event_open
-320 UNIMPL preadv
-321 UNIMPL pwritev
+320 STD { int|linux_sys||preadv(int fd, \
+ const struct iovec *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
+321 STD { int|linux_sys||pwritev(int fd, \
+ const struct iovcnt *iovp, int iovcnt, \
+ unsigned long off_lo, unsigned long off_hi); }
322 UNIMPL rt_tgsigqueueinfo
323 UNIMPL fanotify_init
324 UNIMPL fanotify_mark
Index: src/sys/compat/linux/common/linux_file.c
diff -u src/sys/compat/linux/common/linux_file.c:1.119 src/sys/compat/linux/common/linux_file.c:1.120
--- src/sys/compat/linux/common/linux_file.c:1.119 Tue Sep 7 11:43:04 2021
+++ src/sys/compat/linux/common/linux_file.c Mon Sep 20 02:20:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_file.c,v 1.119 2021/09/07 11:43:04 riastradh Exp $ */
+/* $NetBSD: linux_file.c,v 1.120 2021/09/20 02:20:03 thorpej Exp $ */
/*-
* Copyright (c) 1995, 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.119 2021/09/07 11:43:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.120 2021/09/20 02:20:03 thorpej Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -136,6 +136,23 @@ bsd_to_linux_ioflags(int bflags)
return res;
}
+static inline off_t
+linux_hilo_to_off_t(unsigned long hi, unsigned long lo)
+{
+#ifdef _LP64
+ /*
+ * Linux discards the "hi" portion on LP64 platforms; even though
+ * glibc puts of the upper 32-bits of the offset into the "hi"
+ * argument regardless, the "lo" argument has all the bits in
+ * this case.
+ */
+ (void) hi;
+ return (off_t)lo;
+#else
+ return (((off_t)hi) << 32) | lo;
+#endif /* _LP64 */
+}
+
/*
* creat(2) is an obsolete function, but it's present as a Linux
* system call, so let's deal with it.
@@ -785,6 +802,56 @@ linux_sys_pwrite(struct lwp *l, const st
return sys_pwrite(l, &pra, retval);
}
+/*
+ * preadv(2)
+ */
+int
+linux_sys_preadv(struct lwp *l, const struct linux_sys_preadv_args *uap,
+ register_t *retval)
+{
+ /* {
+ syscallarg(int) fd;
+ syscallarg(const struct iovec *) iovp;
+ syscallarg(int) iovcnt;
+ syscallarg(unsigned long) off_lo;
+ syscallarg(unsigned long) off_hi;
+ } */
+ struct sys_preadv_args ua;
+
+ SCARG(&ua, fd) = SCARG(uap, fd);
+ SCARG(&ua, iovp) = SCARG(uap, iovp);
+ SCARG(&ua, iovcnt) = SCARG(uap, iovcnt);
+ SCARG(&ua, PAD) = 0;
+ SCARG(&ua, offset) = linux_hilo_to_off_t(SCARG(uap, off_hi),
+ SCARG(uap, off_lo));
+ return sys_preadv(l, &ua, retval);
+}
+
+/*
+ * pwritev(2)
+ */
+int
+linux_sys_pwritev(struct lwp *l, const struct linux_sys_pwritev_args *uap,
+ register_t *retval)
+{
+ /* {
+ syscallarg(int) fd;
+ syscallarg(const struct iovec *) iovp;
+ syscallarg(int) iovcnt;
+ syscallarg(unsigned long) off_lo;
+ syscallarg(unsigned long) off_hi;
+ } */
+ struct sys_pwritev_args ua;
+
+ SCARG(&ua, fd) = SCARG(uap, fd);
+ SCARG(&ua, iovp) = (const void *)SCARG(uap, iovp);
+ SCARG(&ua, iovcnt) = SCARG(uap, iovcnt);
+ SCARG(&ua, PAD) = 0;
+ SCARG(&ua, offset) = linux_hilo_to_off_t(SCARG(uap, off_hi),
+ SCARG(uap, off_lo));
+ return sys_pwritev(l, &ua, retval);
+}
+
int
linux_sys_dup3(struct lwp *l, const struct linux_sys_dup3_args *uap,
register_t *retval)
Index: src/sys/compat/linux32/arch/amd64/syscalls.master
diff -u src/sys/compat/linux32/arch/amd64/syscalls.master:1.74 src/sys/compat/linux32/arch/amd64/syscalls.master:1.75
--- src/sys/compat/linux32/arch/amd64/syscalls.master:1.74 Mon Sep 20 00:09:02 2021
+++ src/sys/compat/linux32/arch/amd64/syscalls.master Mon Sep 20 02:20:03 2021
@@ -1,4 +1,4 @@
- $NetBSD: syscalls.master,v 1.74 2021/09/20 00:09:02 thorpej Exp $
+ $NetBSD: syscalls.master,v 1.75 2021/09/20 02:20:03 thorpej Exp $
; NetBSD i386 COMPAT_LINUX32 system call name/number "master" file.
; (See syscalls.conf to see what it is processed into.)
@@ -567,8 +567,12 @@
330 STD { int|linux32_sys||dup3(int from, int to, int flags); }
331 STD { int|linux32_sys||pipe2(netbsd32_intp fd, int flags); }
332 UNIMPL inotify_init1
-333 UNIMPL preadv
-334 UNIMPL pwritev
+333 STD { int|linux32_sys||preadv(int fd, \
+ const netbsd32_iovecp_t iovp, int iovcnt, \
+ netbsd32_u_long off_lo, netbsd32_u_long off_hi); }
+334 STD { int|linux32_sys||pwritev(int fd, \
+ const netbsd32_iovecp_t iovp, int iovcnt, \
+ netbsd32_u_long off_lo, netbsd32_u_long off_hi); }
335 UNIMPL rt_tgsigqueueinfo
336 UNIMPL perf_counter_open
337 UNIMPL recvmmsg
Index: src/sys/compat/linux32/common/linux32_misc.c
diff -u src/sys/compat/linux32/common/linux32_misc.c:1.32 src/sys/compat/linux32/common/linux32_misc.c:1.33
--- src/sys/compat/linux32/common/linux32_misc.c:1.32 Mon Sep 20 00:09:02 2021
+++ src/sys/compat/linux32/common/linux32_misc.c Mon Sep 20 02:20:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_misc.c,v 1.32 2021/09/20 00:09:02 thorpej Exp $ */
+/* $NetBSD: linux32_misc.c,v 1.33 2021/09/20 02:20:03 thorpej Exp $ */
/*-
* Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.32 2021/09/20 00:09:02 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.33 2021/09/20 02:20:03 thorpej Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -380,3 +380,53 @@ linux32_sys_eventfd2(struct lwp *l, cons
return linux_sys_eventfd2(l, &ua, retval);
}
+
+static inline off_t
+linux32_hilo_to_off_t(unsigned long hi, unsigned long lo)
+{
+ return (((off_t)hi) << 32) | lo;
+}
+
+int
+linux32_sys_preadv(struct lwp *l, const struct linux32_sys_preadv_args *uap,
+ register_t *retval)
+{
+ /* {
+ syscallarg(int) fd;
+ syscallarg(const netbsd32_iovecp_t) iovp;
+ syscallarg(int) iovcnt;
+ syscallarg(netbsd32_u_long) off_lo;
+ syscallarg(netbsd32_u_long) off_hi;
+ } */
+ struct netbsd32_preadv_args ua;
+
+ SCARG(&ua, fd) = SCARG(uap, fd);
+ SCARG(&ua, iovp) = SCARG(uap, iovp);
+ SCARG(&ua, iovcnt) = SCARG(uap, iovcnt);
+ SCARG(&ua, PAD) = 0;
+ SCARG(&ua, offset) = linux32_hilo_to_off_t(SCARG(uap, off_hi),
+ SCARG(uap, off_lo));
+ return netbsd32_preadv(l, &ua, retval);
+}
+
+int
+linux32_sys_pwritev(struct lwp *l, const struct linux32_sys_pwritev_args *uap,
+ register_t *retval)
+{
+ /* {
+ syscallarg(int) fd;
+ syscallarg(const netbsd32_iovecp_t) iovp;
+ syscallarg(int) iovcnt;
+ syscallarg(netbsd32_u_long) off_lo;
+ syscallarg(netbsd32_u_long) off_hi;
+ } */
+ struct netbsd32_pwritev_args ua;
+
+ SCARG(&ua, fd) = SCARG(uap, fd);
+ SCARG(&ua, iovp) = SCARG(uap, iovp);
+ SCARG(&ua, iovcnt) = SCARG(uap, iovcnt);
+ SCARG(&ua, PAD) = 0;
+ SCARG(&ua, offset) = linux32_hilo_to_off_t(SCARG(uap, off_hi),
+ SCARG(uap, off_lo));
+ return netbsd32_pwritev(l, &ua, retval);
+}