Source-Changes-HG archive

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

[src/trunk]: src/sys/compat Remove Alpha's compat_linux dependency on compat_...



details:   https://anonhg.NetBSD.org/src/rev/84e4e6aa01ff
branches:  trunk
changeset: 449805:84e4e6aa01ff
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Mar 24 16:24:19 2019 +0000

description:
Remove Alpha's compat_linux dependency on compat_osf1. Each function is
copied as-is from compat_osf1 with no functional change. Discussed on
tech-kern@, ok @thorpej.

diffstat:

 sys/compat/linux/arch/alpha/files.linux_alpha |    3 +-
 sys/compat/linux/arch/alpha/linux_osf1.c      |  785 ++++++++++++++++++++++++++
 sys/compat/linux/arch/alpha/linux_osf1.h      |  222 +++++++
 sys/compat/linux/arch/alpha/syscalls.master   |   33 +-
 sys/compat/osf1/files.osf1                    |   18 +-
 5 files changed, 1035 insertions(+), 26 deletions(-)

diffs (truncated from 1204 to 300 lines):

diff -r e5c3182bc416 -r 84e4e6aa01ff sys/compat/linux/arch/alpha/files.linux_alpha
--- a/sys/compat/linux/arch/alpha/files.linux_alpha     Sun Mar 24 15:58:32 2019 +0000
+++ b/sys/compat/linux/arch/alpha/files.linux_alpha     Sun Mar 24 16:24:19 2019 +0000
@@ -1,8 +1,9 @@
-#      $NetBSD: files.linux_alpha,v 1.9 2011/05/31 20:53:13 njoly Exp $
+#      $NetBSD: files.linux_alpha,v 1.10 2019/03/24 16:24:19 maxv Exp $
 #
 # Config file description for alpha-dependent Linux compat code.
 
 file   compat/linux/arch/alpha/linux_machdep.c         compat_linux
+file   compat/linux/arch/alpha/linux_osf1.c            compat_linux
 file   compat/linux/arch/alpha/linux_pipe.c            compat_linux
 file   compat/linux/arch/alpha/linux_syscalls.c        compat_linux
 file   compat/linux/arch/alpha/linux_sysent.c          compat_linux
diff -r e5c3182bc416 -r 84e4e6aa01ff sys/compat/linux/arch/alpha/linux_osf1.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/compat/linux/arch/alpha/linux_osf1.c  Sun Mar 24 16:24:19 2019 +0000
@@ -0,0 +1,785 @@
+/*     $NetBSD: linux_osf1.c,v 1.1 2019/03/24 16:24:19 maxv Exp $      */
+
+/*
+ * Copyright (c) 1999 Christopher G. Demetriou.  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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by Christopher G. Demetriou
+ *     for the NetBSD Project.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: linux_osf1.c,v 1.1 2019/03/24 16:24:19 maxv Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/vnode.h>
+#include <sys/wait.h>
+#include <sys/select.h>
+#include <sys/syscallargs.h>
+#include <sys/vfs_syscalls.h>
+
+#include <machine/alpha.h>
+#include <machine/cpuconf.h>
+#include <machine/rpb.h>
+#include <machine/fpu.h>
+
+#include <compat/common/compat_util.h>
+#include <compat/linux/common/linux_types.h>
+#include <compat/linux/common/linux_signal.h>
+#include <compat/linux/arch/alpha/linux_signal.h>
+#include <compat/linux/arch/alpha/linux_osf1.h>
+#include <compat/linux/linux_syscallargs.h>
+
+#include <net/if.h>
+#include <netinet/in.h>
+
+#include <nfs/rpcv2.h>
+#include <nfs/nfsproto.h>
+#include <nfs/nfs.h>
+#include <nfs/nfsmount.h>
+
+#include <ufs/ufs/quota.h>
+#include <ufs/ufs/ufsmount.h>
+
+#include <machine/vmparam.h>
+
+const struct emul_flags_xtab osf1_wait_options_xtab[] = {
+    {  OSF1_WNOHANG,           OSF1_WNOHANG,           WNOHANG         },
+    {  OSF1_WUNTRACED,         OSF1_WUNTRACED,         WUNTRACED       },
+    {  0                                                               }
+};
+
+const struct emul_flags_xtab osf1_nfs_mount_flags_xtab[] = {
+    {  OSF1_NFSMNT_SOFT,       OSF1_NFSMNT_SOFT,       NFSMNT_SOFT,    },
+    {  OSF1_NFSMNT_WSIZE,      OSF1_NFSMNT_WSIZE,      NFSMNT_WSIZE,   },
+    {  OSF1_NFSMNT_RSIZE,      OSF1_NFSMNT_RSIZE,      NFSMNT_RSIZE,   },
+    {  OSF1_NFSMNT_TIMEO,      OSF1_NFSMNT_TIMEO,      NFSMNT_TIMEO,   },
+    {  OSF1_NFSMNT_RETRANS,    OSF1_NFSMNT_RETRANS,    NFSMNT_RETRANS, },
+#if 0 /* no equivalent; needs special handling, see below */
+    {  OSF1_NFSMNT_HOSTNAME,   OSF1_NFSMNT_HOSTNAME,   ???,            },
+#endif
+    {  OSF1_NFSMNT_INT,        OSF1_NFSMNT_INT,        NFSMNT_INT,     },
+    {  OSF1_NFSMNT_NOCONN,     OSF1_NFSMNT_NOCONN,     NFSMNT_NOCONN,  },
+#if 0 /* no equivalents */
+    {  OSF1_NFSMNT_NOAC,       OSF1_NFSMNT_NOAC,       ???,            },
+    {  OSF1_NFSMNT_ACREGMIN,   OSF1_NFSMNT_ACREGMIN,   ???,            },
+    {  OSF1_NFSMNT_ACREGMAX,   OSF1_NFSMNT_ACREGMAX,   ???,            },
+    {  OSF1_NFSMNT_ACDIRMIN,   OSF1_NFSMNT_ACDIRMIN,   ???,            },
+    {  OSF1_NFSMNT_ACDIRMAX,   OSF1_NFSMNT_ACDIRMAX,   ???,            },
+    {  OSF1_NFSMNT_NOCTO,      OSF1_NFSMNT_NOCTO,      ???,            },
+    {  OSF1_NFSMNT_POSIX,      OSF1_NFSMNT_POSIX,      ???,            },
+    {  OSF1_NFSMNT_AUTO,       OSF1_NFSMNT_AUTO,       ???,            },
+    {  OSF1_NFSMNT_SEC,        OSF1_NFSMNT_SEC,        ???,            },
+    {  OSF1_NFSMNT_TCP,        OSF1_NFSMNT_TCP,        ???,            },
+    {  OSF1_NFSMNT_PROPLIST,   OSF1_NFSMNT_PROPLIST,   ???,            },
+#endif
+    {  0                                                               }
+};
+
+static void
+osf1_cvt_rusage_from_native(const struct rusage *ru, struct osf1_rusage *oru)
+{
+
+       oru->ru_utime.tv_sec = ru->ru_utime.tv_sec;
+       oru->ru_utime.tv_usec = ru->ru_utime.tv_usec;
+
+       oru->ru_stime.tv_sec = ru->ru_stime.tv_sec;
+       oru->ru_stime.tv_usec = ru->ru_stime.tv_usec;
+
+       oru->ru_maxrss = ru->ru_maxrss;
+       oru->ru_ixrss = ru->ru_ixrss;
+       oru->ru_idrss = ru->ru_idrss;
+       oru->ru_isrss = ru->ru_isrss;
+       oru->ru_minflt = ru->ru_minflt;
+       oru->ru_majflt = ru->ru_majflt;
+       oru->ru_nswap = ru->ru_nswap;
+       oru->ru_inblock = ru->ru_inblock;
+       oru->ru_oublock = ru->ru_oublock;
+       oru->ru_msgsnd = ru->ru_msgsnd;
+       oru->ru_msgrcv = ru->ru_msgrcv;
+       oru->ru_nsignals = ru->ru_nsignals;
+       oru->ru_nvcsw = ru->ru_nvcsw;
+       oru->ru_nivcsw = ru->ru_nivcsw;
+}
+
+static void
+osf1_cvt_statfs_from_native(const struct statvfs *bsfs, struct osf1_statfs *osfs)
+{
+
+       memset(osfs, 0, sizeof (struct osf1_statfs));
+       if (!strncmp(MOUNT_FFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename)))
+               osfs->f_type = OSF1_MOUNT_UFS;
+       else if (!strncmp(MOUNT_NFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename)))
+               osfs->f_type = OSF1_MOUNT_NFS;
+       else if (!strncmp(MOUNT_MFS, bsfs->f_fstypename, sizeof(bsfs->f_fstypename)))
+               osfs->f_type = OSF1_MOUNT_MFS;
+       else
+               /* uh oh...  XXX = PC, CDFS, PROCFS, etc. */
+               osfs->f_type = OSF1_MOUNT_ADDON;
+       osfs->f_flags = bsfs->f_flag;           /* XXX translate */
+       osfs->f_fsize = bsfs->f_frsize;
+       osfs->f_bsize = bsfs->f_bsize;
+       osfs->f_blocks = bsfs->f_blocks;
+       osfs->f_bfree = bsfs->f_bfree;
+       osfs->f_bavail = bsfs->f_bavail;
+       osfs->f_files = bsfs->f_files;
+       osfs->f_ffree = bsfs->f_ffree;
+       memcpy(&osfs->f_fsid, &bsfs->f_fsidx, sizeof osfs->f_fsid);
+       /* osfs->f_spare zeroed above */
+       memcpy(osfs->f_mntonname, bsfs->f_mntonname, sizeof osfs->f_mntonname);
+       memcpy(osfs->f_mntfromname, bsfs->f_mntfromname,
+           sizeof osfs->f_mntfromname);
+       /* XXX osfs->f_xxx should be filled in... */
+}
+
+/* --------------------------------------------------------------------- */
+
+int
+linux_sys_osf1_wait4(struct lwp *l, const struct linux_sys_osf1_wait4_args *uap, register_t *retval)
+{
+       struct osf1_rusage osf1_rusage;
+       struct rusage netbsd_rusage;
+       unsigned long leftovers;
+       int error, status;
+       int options = SCARG(uap, options);
+       int pid = SCARG(uap, pid);
+
+       /* translate options */
+       options = emul_flags_translate(osf1_wait_options_xtab,
+           options, &leftovers);
+       if (leftovers != 0)
+               return (EINVAL);
+
+       error = do_sys_wait(&pid, &status, options,
+           SCARG(uap, rusage) != NULL ? &netbsd_rusage : NULL);
+
+       retval[0] = pid;
+       if (pid == 0)
+               return error;
+
+       if (SCARG(uap, rusage)) {
+               osf1_cvt_rusage_from_native(&netbsd_rusage, &osf1_rusage);
+               error = copyout(&osf1_rusage, SCARG(uap, rusage),
+                   sizeof osf1_rusage);
+       }
+
+       if (error == 0 && SCARG(uap, status))
+               error = copyout(&status, SCARG(uap, status), sizeof(status));
+
+       return error;
+}
+
+#define        OSF1_MNT_WAIT           0x1
+#define        OSF1_MNT_NOWAIT         0x2
+
+#define        OSF1_MNT_FORCE          0x1
+#define        OSF1_MNT_NOFORCE        0x2
+
+/* acceptable flags for various calls */
+#define        OSF1_GETFSSTAT_FLAGS    (OSF1_MNT_WAIT|OSF1_MNT_NOWAIT)
+#define        OSF1_MOUNT_FLAGS        0xffffffff                      /* XXX */
+#define        OSF1_UNMOUNT_FLAGS      (OSF1_MNT_FORCE|OSF1_MNT_NOFORCE)
+
+static int
+osf1_mount_mfs(struct lwp *l, const struct linux_sys_osf1_mount_args *uap)
+{
+       struct osf1_mfs_args osf_ma;
+       struct mfs_args bsd_ma;
+       int error;
+       register_t dummy;
+
+       if ((error = copyin(SCARG(uap, data), &osf_ma, sizeof osf_ma)))
+               return error;
+
+       memset(&bsd_ma, 0, sizeof bsd_ma);
+       bsd_ma.fspec = osf_ma.name;
+       /* XXX export args */
+       bsd_ma.base = osf_ma.base;
+       bsd_ma.size = osf_ma.size;
+
+       return do_sys_mount(l, "mfs", UIO_SYSSPACE, SCARG(uap, path),
+           SCARG(uap, flags), &bsd_ma, UIO_SYSSPACE, sizeof bsd_ma, &dummy);
+}
+
+static int
+osf1_mount_nfs(struct lwp *l, const struct linux_sys_osf1_mount_args *uap)
+{
+       struct osf1_nfs_args osf_na;
+       struct nfs_args bsd_na;
+       int error;
+       unsigned long leftovers;
+       register_t dummy;
+
+       if ((error = copyin(SCARG(uap, data), &osf_na, sizeof osf_na)))
+               return error;
+
+       memset(&bsd_na, 0, sizeof bsd_na);
+       bsd_na.addr = (struct sockaddr *)osf_na.addr;
+       bsd_na.addrlen = sizeof (struct sockaddr_in);
+       bsd_na.fh = osf_na.fh;
+
+        /* translate flags */
+        bsd_na.flags = emul_flags_translate(osf1_nfs_mount_flags_xtab,
+            osf_na.flags, &leftovers);
+       if (leftovers & OSF1_NFSMNT_HOSTNAME) {
+               leftovers &= ~OSF1_NFSMNT_HOSTNAME;
+               bsd_na.hostname = osf_na.hostname;
+       } else {
+               /* XXX FILL IN HOST NAME WITH IPADDR? */
+       }
+       if (leftovers & OSF1_NFSMNT_TCP) {
+               leftovers &= ~OSF1_NFSMNT_TCP;
+               bsd_na.sotype = SOCK_DGRAM;
+               bsd_na.proto = 0;
+       } else {
+               bsd_na.sotype = SOCK_STREAM;
+               bsd_na.proto = 0;
+       }
+        if (leftovers != 0)
+                return (EINVAL);
+
+       /* copy structure elements based on flags */
+       if (bsd_na.flags & NFSMNT_WSIZE)
+               bsd_na.wsize = osf_na.wsize;
+       if (bsd_na.flags & NFSMNT_RSIZE)
+               bsd_na.rsize = osf_na.rsize;
+       if (bsd_na.flags & NFSMNT_TIMEO)
+               bsd_na.timeo = osf_na.timeo;
+       if (bsd_na.flags & NFSMNT_RETRANS)
+               bsd_na.retrans = osf_na.retrans;
+
+       return do_sys_mount(l, "nfs", UIO_SYSSPACE, SCARG(uap, path),
+           SCARG(uap, flags), &bsd_na, UIO_SYSSPACE, sizeof bsd_na, &dummy);
+}



Home | Main Index | Thread Index | Old Index