Source-Changes-HG archive

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

[src/trunk]: src/sys/compat/netbsd32 move mmap(), compat 40 mount(), pipe() a...



details:   https://anonhg.NetBSD.org/src/rev/400b458f8292
branches:  trunk
changeset: 837865:400b458f8292
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon Dec 24 21:27:05 2018 +0000

description:
move mmap(), compat 40 mount(), pipe() and getfh() into their own files
as the implementation is non trivial or is compat.  mark old mount()
properly instead of manually #if'ing ito to ENOSYS.

diffstat:

 sys/compat/netbsd32/files.netbsd32               |    5 +-
 sys/compat/netbsd32/netbsd32_compat_40.c         |   63 ++++++++
 sys/compat/netbsd32/netbsd32_fd.c                |  132 +++++++++++++++++
 sys/compat/netbsd32/netbsd32_netbsd.c            |  177 +----------------------
 sys/compat/netbsd32/netbsd32_syscalls.c          |    8 +-
 sys/compat/netbsd32/netbsd32_syscalls_autoload.c |    4 +-
 sys/compat/netbsd32/netbsd32_sysent.c            |   10 +-
 sys/compat/netbsd32/netbsd32_systrace_args.c     |    4 +-
 sys/compat/netbsd32/netbsd32_vm.c                |   95 ++++++++++++
 sys/compat/netbsd32/syscalls.master              |    4 +-
 10 files changed, 311 insertions(+), 191 deletions(-)

diffs (truncated from 687 to 300 lines):

diff -r 104216aa192d -r 400b458f8292 sys/compat/netbsd32/files.netbsd32
--- a/sys/compat/netbsd32/files.netbsd32        Mon Dec 24 21:15:59 2018 +0000
+++ b/sys/compat/netbsd32/files.netbsd32        Mon Dec 24 21:27:05 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.netbsd32,v 1.40 2018/12/24 20:44:39 mrg Exp $
+#      $NetBSD: files.netbsd32,v 1.41 2018/12/24 21:27:05 mrg Exp $
 #
 # config file description for machine-independent netbsd32 compat code.
 # included by ports that need it.
@@ -13,6 +13,7 @@
 file   compat/netbsd32/netbsd32_netbsd.c       compat_netbsd32
 file   compat/netbsd32/netbsd32_event.c        compat_netbsd32
 file   compat/netbsd32/netbsd32_execve.c       compat_netbsd32
+file   compat/netbsd32/netbsd32_fd.c           compat_netbsd32
 file   compat/netbsd32/netbsd32_fs.c           compat_netbsd32
 file   compat/netbsd32/netbsd32_ioctl.c        compat_netbsd32
 file   compat/netbsd32/netbsd32_ipc.c          compat_netbsd32
@@ -31,6 +32,7 @@
 file   compat/netbsd32/netbsd32_sysctl.c       compat_netbsd32
 file   compat/netbsd32/netbsd32_time.c         compat_netbsd32
 file   compat/netbsd32/netbsd32_wait.c         compat_netbsd32
+file   compat/netbsd32/netbsd32_vm.c           compat_netbsd32
 file   compat/netbsd32/netbsd32_sysent.c       compat_netbsd32
 file   compat/netbsd32/netbsd32_syscalls.c     compat_netbsd32 & syscall_debug
 
@@ -42,6 +44,7 @@
 file   compat/netbsd32/netbsd32_compat_20.c    compat_netbsd32 & compat_20
 file   compat/netbsd32/netbsd32_compat_30.c    compat_netbsd32 & compat_30
 file   compat/netbsd32/netbsd32_compat_43.c    compat_netbsd32 & (compat_43 | compat_sunos | compat_linux32)
+file   compat/netbsd32/netbsd32_compat_40.c    compat_netbsd32 & compat_40
 file   compat/netbsd32/netbsd32_compat_50.c    compat_netbsd32 & compat_50
 file   compat/netbsd32/netbsd32_compat_50_sysv.c compat_netbsd32 & compat_50 &
                                                (sysvmsg | sysvsem | sysvshm)
diff -r 104216aa192d -r 400b458f8292 sys/compat/netbsd32/netbsd32_compat_40.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/netbsd32/netbsd32_compat_40.c  Mon Dec 24 21:27:05 2018 +0000
@@ -0,0 +1,63 @@
+/*     $NetBSD: netbsd32_compat_40.c,v 1.2 2018/12/24 21:27:05 mrg Exp $       */
+
+/*
+ * Copyright (c) 1998, 2001, 2008, 2018 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: NetBSD: netbsd32_netbsd.c,v 1.221 2018/12/24 20:44:39 mrg Exp $
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_compat_40.c,v 1.2 2018/12/24 21:27:05 mrg Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <compat/netbsd32/netbsd32.h>
+#include <compat/netbsd32/netbsd32_syscall.h>
+#include <compat/netbsd32/netbsd32_syscallargs.h>
+#include <compat/netbsd32/netbsd32_conv.h>
+
+int
+compat_40_netbsd32_mount(struct lwp *l,
+                        const struct compat_40_netbsd32_mount_args *uap,
+                        register_t *retval)
+{
+       /* {
+               syscallarg(const netbsd32_charp) type;
+               syscallarg(const netbsd32_charp) path;
+               syscallarg(int) flags;
+               syscallarg(netbsd32_voidp) data;
+       } */
+       struct compat_40_sys_mount_args ua;
+
+       NETBSD32TOP_UAP(type, const char);
+       NETBSD32TOP_UAP(path, const char);
+       NETBSD32TO64_UAP(flags);
+       NETBSD32TOP_UAP(data, void);
+
+       return compat_40_sys_mount(l, &ua, retval);
+}
diff -r 104216aa192d -r 400b458f8292 sys/compat/netbsd32/netbsd32_fd.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/netbsd32/netbsd32_fd.c Mon Dec 24 21:27:05 2018 +0000
@@ -0,0 +1,132 @@
+/*     $NetBSD: netbsd32_fd.c,v 1.1 2018/12/24 21:27:05 mrg Exp $      */
+
+/*
+ * Copyright (c) 1998, 2001, 2008, 2018 Matthew R. Green
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * from: NetBSD: netbsd32_netbsd.c,v 1.221 2018/12/24 20:44:39 mrg Exp
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_fd.c,v 1.1 2018/12/24 21:27:05 mrg Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/filedesc.h>
+#include <sys/namei.h>
+#include <sys/vnode.h>
+#include <sys/vfs_syscalls.h>
+#include <sys/kauth.h>
+
+#include <compat/netbsd32/netbsd32.h>
+#include <compat/netbsd32/netbsd32_syscall.h>
+#include <compat/netbsd32/netbsd32_syscallargs.h>
+#include <compat/netbsd32/netbsd32_conv.h>
+
+
+int
+netbsd32___getfh30(struct lwp *l, const struct netbsd32___getfh30_args *uap, register_t *retval)
+{
+       /* {
+               syscallarg(const netbsd32_charp) fname;
+               syscallarg(netbsd32_fhandlep_t) fhp;
+               syscallarg(netbsd32_size_tp) fh_size;
+       } */
+       struct vnode *vp;
+       fhandle_t *fh;
+       int error;
+       struct pathbuf *pb;
+       struct nameidata nd;
+       netbsd32_size_t usz32, sz32;
+       size_t sz;
+
+       /*
+        * Must be super user
+        */
+       error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FILEHANDLE,
+           0, NULL, NULL, NULL);
+       if (error)
+               return error;
+
+       error = pathbuf_copyin(SCARG_P32(uap, fname), &pb);
+       if (error) {
+               return error;
+       }
+
+       NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | TRYEMULROOT, pb);
+       error = namei(&nd);
+       if (error) {
+               pathbuf_destroy(pb);
+               return error;
+       }
+       vp = nd.ni_vp;
+       pathbuf_destroy(pb);
+
+       error = vfs_composefh_alloc(vp, &fh);
+       vput(vp);
+       if (error != 0) {
+               return error;
+       }
+       error = copyin(SCARG_P32(uap, fh_size), &usz32, sizeof(usz32));
+       if (error != 0) {
+               goto out;
+       }
+       sz = FHANDLE_SIZE(fh);
+       sz32 = sz;
+
+       error = copyout(&sz32, SCARG_P32(uap, fh_size), sizeof(sz32));
+       if (error != 0) {
+               goto out;
+       }
+       if (usz32 >= sz32) {
+               error = copyout(fh, SCARG_P32(uap, fhp), sz);
+       } else {
+               error = E2BIG;
+       }
+out:
+       vfs_composefh_free(fh);
+       return error;
+}
+
+int
+netbsd32_pipe2(struct lwp *l, const struct netbsd32_pipe2_args *uap,
+              register_t *retval)
+{
+       /* {
+               syscallarg(netbsd32_intp) fildes;
+               syscallarg(int) flags;
+       } */
+       int fd[2], error;
+
+       error = pipe1(l, fd, SCARG(uap, flags));
+       if (error != 0)
+               return error;
+
+       error = copyout(fd, SCARG_P32(uap, fildes), sizeof(fd));
+       if (error != 0)
+               return error;
+
+       retval[0] = 0;
+       return 0;
+}
diff -r 104216aa192d -r 400b458f8292 sys/compat/netbsd32/netbsd32_netbsd.c
--- a/sys/compat/netbsd32/netbsd32_netbsd.c     Mon Dec 24 21:15:59 2018 +0000
+++ b/sys/compat/netbsd32/netbsd32_netbsd.c     Mon Dec 24 21:27:05 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: netbsd32_netbsd.c,v 1.221 2018/12/24 20:44:39 mrg Exp $        */
+/*     $NetBSD: netbsd32_netbsd.c,v 1.222 2018/12/24 21:27:05 mrg Exp $        */
 
 /*
  * Copyright (c) 1998, 2001, 2008, 2018 Matthew R. Green
@@ -27,15 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.221 2018/12/24 20:44:39 mrg Exp $");
-
-/*
- * below are all the standard NetBSD system calls, in the 32bit
- * environment, with the necessary conversions to 64bit before calling
- * the real syscall.  anything that needs special attention is handled
- * elsewhere - this file should only contain structure assignment and
- * calls to the original function.
- */
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.222 2018/12/24 21:27:05 mrg Exp $");
 
 /*
  * below are all the standard NetBSD system calls, in the 32bit
@@ -73,13 +65,11 @@
 #include <sys/trace.h>
 #include <sys/resourcevar.h>
 #include <sys/pool.h>
-#include <sys/vnode.h>
 #include <sys/file.h>
 #include <sys/filedesc.h>
 #include <sys/namei.h>
 #include <sys/dirent.h>
 #include <sys/quotactl.h>
-#include <sys/kauth.h>
 #include <sys/vfs_syscalls.h>
 
 #include <uvm/uvm_extern.h>
@@ -365,30 +355,6 @@
        return sys_obreak(l, &ua, retval);
 }
 
-// XXX move into compat_40
-int
-netbsd32_mount(struct lwp *l, const struct netbsd32_mount_args *uap, register_t *retval)
-{
-#ifdef COMPAT_40
-       /* {
-               syscallarg(const netbsd32_charp) type;
-               syscallarg(const netbsd32_charp) path;
-               syscallarg(int) flags;
-               syscallarg(netbsd32_voidp) data;
-       } */
-       struct compat_40_sys_mount_args ua;
-
-       NETBSD32TOP_UAP(type, const char);
-       NETBSD32TOP_UAP(path, const char);
-       NETBSD32TO64_UAP(flags);
-       NETBSD32TOP_UAP(data, void);
-
-       return compat_40_sys_mount(l, &ua, retval);
-#else



Home | Main Index | Thread Index | Old Index