Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/thorpej-futex]: src/sys/compat/linux/common Add suppport for Linux pread...



details:   https://anonhg.NetBSD.org/src/rev/2b0a3bef9e8c
branches:  thorpej-futex
changeset: 961136:2b0a3bef9e8c
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Dec 17 03:14:15 2020 +0000

description:
Add suppport for Linux preadv(2) and pwritev(2).  Same as native, except
for the silly way that the offset argument is passed in.

diffstat:

 sys/compat/linux/arch/alpha/syscalls.master   |  10 ++-
 sys/compat/linux/arch/amd64/syscalls.master   |  10 ++-
 sys/compat/linux/arch/arm/syscalls.master     |  10 ++-
 sys/compat/linux/arch/i386/syscalls.master    |  10 ++-
 sys/compat/linux/arch/m68k/syscalls.master    |  10 ++-
 sys/compat/linux/arch/mips/syscalls.master    |  10 ++-
 sys/compat/linux/arch/powerpc/syscalls.master |  10 ++-
 sys/compat/linux/common/linux_file.c          |  71 ++++++++++++++++++++++++++-
 8 files changed, 118 insertions(+), 23 deletions(-)

diffs (267 lines):

diff -r 9f67bf40b33b -r 2b0a3bef9e8c sys/compat/linux/arch/alpha/syscalls.master
--- a/sys/compat/linux/arch/alpha/syscalls.master       Thu Dec 17 03:05:50 2020 +0000
+++ b/sys/compat/linux/arch/alpha/syscalls.master       Thu Dec 17 03:14:15 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.97.2.1 2020/12/15 14:07:20 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.97.2.2 2020/12/17 03:14:15 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
diff -r 9f67bf40b33b -r 2b0a3bef9e8c sys/compat/linux/arch/amd64/syscalls.master
--- a/sys/compat/linux/arch/amd64/syscalls.master       Thu Dec 17 03:05:50 2020 +0000
+++ b/sys/compat/linux/arch/amd64/syscalls.master       Thu Dec 17 03:14:15 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.62.2.1 2020/12/15 14:07:20 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.62.2.2 2020/12/17 03:14:15 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, \
diff -r 9f67bf40b33b -r 2b0a3bef9e8c sys/compat/linux/arch/arm/syscalls.master
--- a/sys/compat/linux/arch/arm/syscalls.master Thu Dec 17 03:05:50 2020 +0000
+++ b/sys/compat/linux/arch/arm/syscalls.master Thu Dec 17 03:14:15 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.69.2.1 2020/12/15 14:07:21 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.69.2.2 2020/12/17 03:14:15 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, \
diff -r 9f67bf40b33b -r 2b0a3bef9e8c sys/compat/linux/arch/i386/syscalls.master
--- a/sys/compat/linux/arch/i386/syscalls.master        Thu Dec 17 03:05:50 2020 +0000
+++ b/sys/compat/linux/arch/i386/syscalls.master        Thu Dec 17 03:14:15 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.124.2.1 2020/12/15 14:07:21 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.124.2.2 2020/12/17 03:14:15 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
diff -r 9f67bf40b33b -r 2b0a3bef9e8c sys/compat/linux/arch/m68k/syscalls.master
--- a/sys/compat/linux/arch/m68k/syscalls.master        Thu Dec 17 03:05:50 2020 +0000
+++ b/sys/compat/linux/arch/m68k/syscalls.master        Thu Dec 17 03:14:15 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.95.2.1 2020/12/15 14:07:21 thorpej Exp $
+       $NetBSD: syscalls.master,v 1.95.2.2 2020/12/17 03:14:15 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
diff -r 9f67bf40b33b -r 2b0a3bef9e8c sys/compat/linux/arch/mips/syscalls.master
--- a/sys/compat/linux/arch/mips/syscalls.master        Thu Dec 17 03:05:50 2020 +0000
+++ b/sys/compat/linux/arch/mips/syscalls.master        Thu Dec 17 03:14:15 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.68.2.1 2020/12/15 14:07:21 thorpej Exp $  
+       $NetBSD: syscalls.master,v 1.68.2.2 2020/12/17 03:14:15 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, \
diff -r 9f67bf40b33b -r 2b0a3bef9e8c sys/compat/linux/arch/powerpc/syscalls.master
--- a/sys/compat/linux/arch/powerpc/syscalls.master     Thu Dec 17 03:05:50 2020 +0000
+++ b/sys/compat/linux/arch/powerpc/syscalls.master     Thu Dec 17 03:14:15 2020 +0000
@@ -1,4 +1,4 @@
-       $NetBSD: syscalls.master,v 1.74.2.1 2020/12/15 14:07:21 thorpej Exp $  
+       $NetBSD: syscalls.master,v 1.74.2.2 2020/12/17 03:14:16 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
diff -r 9f67bf40b33b -r 2b0a3bef9e8c sys/compat/linux/common/linux_file.c
--- a/sys/compat/linux/common/linux_file.c      Thu Dec 17 03:05:50 2020 +0000
+++ b/sys/compat/linux/common/linux_file.c      Thu Dec 17 03:14:15 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_file.c,v 1.118 2020/05/23 23:42:41 ad Exp $      */
+/*     $NetBSD: linux_file.c,v 1.118.2.1 2020/12/17 03:14:16 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.118 2020/05/23 23:42:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_file.c,v 1.118.2.1 2020/12/17 03:14:16 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -136,6 +136,23 @@
        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.
@@ -784,6 +801,56 @@
        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)



Home | Main Index | Thread Index | Old Index