summaryrefslogtreecommitdiff
path: root/sys/compat
diff options
context:
space:
mode:
authorkstailey <kstailey@cvs.openbsd.org>1999-09-12 14:15:18 +0000
committerkstailey <kstailey@cvs.openbsd.org>1999-09-12 14:15:18 +0000
commit4bd103c4353ae5c84c7366c63e8dc83c82437cdc (patch)
treef892dd5dcb3b772c932c6d8b6bce9c6b0fa6ac0b /sys/compat
parent3ce2c3853e88f4a74866322d7fcc5f644595f04c (diff)
Add COMPAT_NETBSD. Currently only works for ELF64. Many missing system calls.
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/netbsd/Makefile13
-rw-r--r--sys/compat/netbsd/files.netbsd17
-rw-r--r--sys/compat/netbsd/netbsd_exec.c117
-rw-r--r--sys/compat/netbsd/netbsd_exec.h49
-rw-r--r--sys/compat/netbsd/netbsd_getcwd.c606
-rw-r--r--sys/compat/netbsd/netbsd_stat.c206
-rw-r--r--sys/compat/netbsd/netbsd_stat.h118
-rw-r--r--sys/compat/netbsd/netbsd_types.h44
-rw-r--r--sys/compat/netbsd/netbsd_util.h54
-rw-r--r--sys/compat/netbsd/syscalls.conf12
-rw-r--r--sys/compat/netbsd/syscalls.master622
11 files changed, 1858 insertions, 0 deletions
diff --git a/sys/compat/netbsd/Makefile b/sys/compat/netbsd/Makefile
new file mode 100644
index 00000000000..994cb4cd64c
--- /dev/null
+++ b/sys/compat/netbsd/Makefile
@@ -0,0 +1,13 @@
+# $OpenBSD: Makefile,v 1.1 1999/09/12 14:15:16 kstailey Exp $
+
+SYS= ../..
+DEP= syscalls.conf syscalls.master ${SYS}/kern/makesyscalls.sh
+OBJS= netbsd_sysent.c netbsd_syscalls.c \
+ netbsd_syscall.h netbsd_syscallargs.h
+
+${OBJS}: ${DEP}
+ -mv -f netbsd_sysent.c netbsd_sysent.c.bak
+ -mv -f netbsd_syscalls.c netbsd_syscalls.c.bak
+ -mv -f netbsd_syscall.h netbsd_syscall.h.bak
+ -mv -f netbsd_syscallargs.h netbsd_syscallargs.h.bak
+ sh ${SYS}/kern/makesyscalls.sh syscalls.conf syscalls.master
diff --git a/sys/compat/netbsd/files.netbsd b/sys/compat/netbsd/files.netbsd
new file mode 100644
index 00000000000..0cd8ea95014
--- /dev/null
+++ b/sys/compat/netbsd/files.netbsd
@@ -0,0 +1,17 @@
+# $OpenBSD: files.netbsd,v 1.1 1999/09/12 14:15:16 kstailey Exp $
+#
+# Config.new file description for machine-independent NetBSD compat code.
+# Included by ports that need it.
+
+# ports should define any machine-specific files they need in their
+# own file lists.
+
+file compat/netbsd/netbsd_exec.c compat_netbsd
+file compat/netbsd/netbsd_stat.c compat_netbsd
+file compat/netbsd/netbsd_getcwd.c compat_netbsd
+# file compat/netbsd/netbsd_file.c compat_netbsd
+# file compat/netbsd/netbsd_ioctl.c compat_netbsd
+# file compat/netbsd/netbsd_misc.c compat_netbsd
+# file compat/netbsd/netbsd_ptrace.c compat_netbsd
+file compat/netbsd/netbsd_sysent.c compat_netbsd
+file compat/netbsd/netbsd_syscalls.c compat_netbsd
diff --git a/sys/compat/netbsd/netbsd_exec.c b/sys/compat/netbsd/netbsd_exec.c
new file mode 100644
index 00000000000..abac7f8e5a9
--- /dev/null
+++ b/sys/compat/netbsd/netbsd_exec.c
@@ -0,0 +1,117 @@
+/* $OpenBSD: netbsd_exec.c,v 1.1 1999/09/12 14:15:16 kstailey Exp $ */
+/* $NetBSD: svr4_exec.c,v 1.16 1995/10/14 20:24:20 christos Exp $ */
+
+/*
+ * Copyright (c) 1994 Christos Zoulas
+ * 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. 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/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/signalvar.h>
+#include <sys/malloc.h>
+#include <sys/exec.h>
+#include <sys/exec_elf.h>
+#include <sys/exec_olf.h>
+
+#include <sys/mman.h>
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/vm_map.h>
+
+#include <machine/cpu.h>
+#include <machine/reg.h>
+#if 0
+#include <machine/netbsd_machdep.h>
+#endif
+
+#include <compat/netbsd/netbsd_util.h>
+#include <compat/netbsd/netbsd_syscall.h>
+#include <compat/netbsd/netbsd_exec.h>
+
+static void *netbsd_copyargs __P((struct exec_package *, struct ps_strings *,
+ void *, void *));
+
+const char netbsd_emul_path[] = "/emul/netbsd";
+extern char sigcode[], esigcode[];
+extern struct sysent netbsd_sysent[];
+extern char *netbsd_syscallnames[];
+
+struct emul emul_elf64_netbsd = {
+ "netbsd",
+ NULL,
+ sendsig,
+ NETBSD_SYS_syscall,
+ NETBSD_SYS_MAXSYSCALL,
+ netbsd_sysent,
+ netbsd_syscallnames,
+ 0,
+ netbsd_copyargs,
+ setregs,
+ exec_elf64_fixup,
+ sigcode,
+ esigcode,
+};
+
+static void *
+netbsd_copyargs(pack, arginfo, stack, argp)
+ struct exec_package *pack;
+ struct ps_strings *arginfo;
+ void *stack;
+ void *argp;
+{
+ AuxInfo *a;
+
+ if (!(a = (AuxInfo *)elf64_copyargs(pack, arginfo, stack, argp)))
+ return (NULL);
+ return (a);
+}
+
+int
+netbsd_elf64_probe(p, epp, itp, pos, os)
+ struct proc *p;
+ struct exec_package *epp;
+ char *itp;
+ u_long *pos;
+ u_int8_t *os;
+{
+ char *bp;
+ int error;
+ size_t len;
+
+ if (itp[0]) {
+ if ((error = emul_find(p, NULL, netbsd_emul_path, itp, &bp, 0)))
+ return (error);
+ if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
+ return (error);
+ free(bp, M_TEMP);
+ }
+ epp->ep_emul = &emul_elf64_netbsd;
+ *pos = ELF64_NO_ADDR;
+ if (*os == OOS_NULL)
+ *os = OOS_NETBSD;
+ return (0);
+}
diff --git a/sys/compat/netbsd/netbsd_exec.h b/sys/compat/netbsd/netbsd_exec.h
new file mode 100644
index 00000000000..cdd9994d8f2
--- /dev/null
+++ b/sys/compat/netbsd/netbsd_exec.h
@@ -0,0 +1,49 @@
+/* $OpenBSD: netbsd_exec.h,v 1.1 1999/09/12 14:15:16 kstailey Exp $ */
+
+/*-
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. 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 the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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: @(#)exec.h 8.1 (Berkeley) 6/11/93
+ * from: imgact_aout.h,v 1.2 1994/12/30 08:06:19 bde Exp
+ */
+
+#ifndef _NETBSD_EXEC_H
+#define _NETBSD_EXEC_H
+
+int exec_netbsd_aout_makecmds __P((struct proc *, struct exec_package *));
+
+#ifdef _KERN_DO_ELF64
+int netbsd_elf64_probe __P((struct proc *, struct exec_package *, char *,
+ u_long *, u_int8_t *));
+#endif
+
+#endif /* !_NETBSD_EXEC_H */
diff --git a/sys/compat/netbsd/netbsd_getcwd.c b/sys/compat/netbsd/netbsd_getcwd.c
new file mode 100644
index 00000000000..8177c8c7001
--- /dev/null
+++ b/sys/compat/netbsd/netbsd_getcwd.c
@@ -0,0 +1,606 @@
+/* $OpenBSD: netbsd_getcwd.c,v 1.1 1999/09/12 14:15:16 kstailey Exp $ */
+/* $NetBSD: vfs_getcwd.c,v 1.3.2.3 1999/07/11 10:24:09 sommerfeld Exp $ */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Bill Sommerfeld.
+ *
+ * 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 the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/vnode.h>
+#include <sys/mount.h>
+#include <sys/proc.h>
+int proc_isunder __P((struct proc *, struct proc*)); /* missing from proc.h */
+#include <sys/uio.h>
+#include <sys/malloc.h>
+#include <sys/dirent.h>
+#include <ufs/ufs/dir.h> /* XXX only for DIRBLKSIZ */
+
+#include <compat/netbsd/netbsd_syscallargs.h>
+
+static int
+netbsd_getcwd_scandir __P((struct vnode **, struct vnode **,
+ char **, char *, struct proc *));
+static int
+netbsd_getcwd_getcache __P((struct vnode **, struct vnode **,
+ char **, char *));
+static int
+netbsd_getcwd_common __P((struct vnode *, struct vnode *,
+ char **, char *, int, int, struct proc *));
+
+static int
+netbsd_vn_isunder __P((struct vnode *, struct vnode *, struct proc *));
+
+#define DIRENT_MINSIZE (sizeof(struct dirent) - (MAXNAMLEN+1) + 4)
+
+/*
+ * Vnode variable naming conventions in this file:
+ *
+ * rvp: the current root we're aiming towards.
+ * lvp, *lvpp: the "lower" vnode
+ * uvp, *uvpp: the "upper" vnode.
+ *
+ * Since all the vnodes we're dealing with are directories, and the
+ * lookups are going *up* in the filesystem rather than *down*, the
+ * usual "pvp" (parent) or "dvp" (directory) naming conventions are
+ * too confusing.
+ */
+
+/*
+ * XXX Will infinite loop in certain cases if a directory read reliably
+ * returns EINVAL on last block.
+ * XXX is EINVAL the right thing to return if a directory is malformed?
+ */
+
+/*
+ * XXX Untested vs. mount -o union; probably does the wrong thing.
+ */
+
+/*
+ * Find parent vnode of *lvpp, return in *uvpp
+ *
+ * If we care about the name, scan it looking for name of directory
+ * entry pointing at lvp.
+ *
+ * Place the name in the buffer which starts at bufp, immediately
+ * before *bpp, and move bpp backwards to point at the start of it.
+ *
+ * On entry, *lvpp is a locked vnode reference; on exit, it is vput and NULL'ed
+ * On exit, *uvpp is either NULL or is a locked vnode reference.
+ */
+static int
+netbsd_getcwd_scandir(lvpp, uvpp, bpp, bufp, p)
+ struct vnode **lvpp;
+ struct vnode **uvpp;
+ char **bpp;
+ char *bufp;
+ struct proc *p;
+{
+ int error = 0;
+ int eofflag;
+ off_t off;
+ int tries;
+ struct uio uio;
+ struct iovec iov;
+ char *dirbuf = NULL;
+ int dirbuflen;
+ ino_t fileno;
+ struct vattr va;
+ struct vnode *uvp = NULL;
+ struct vnode *lvp = *lvpp;
+ struct componentname cn;
+ int len, reclen;
+ tries = 0;
+
+ /*
+ * If we want the filename, get some info we need while the
+ * current directory is still locked.
+ */
+ if (bufp != NULL) {
+ error = VOP_GETATTR(lvp, &va, p->p_ucred, p);
+ if (error) {
+ vput(lvp);
+ *lvpp = NULL;
+ *uvpp = NULL;
+ return error;
+ }
+ }
+
+ /*
+ * Ok, we have to do it the hard way..
+ * Next, get parent vnode using lookup of ..
+ */
+ cn.cn_nameiop = LOOKUP;
+ cn.cn_flags = ISLASTCN | ISDOTDOT | RDONLY;
+ cn.cn_proc = p;
+ cn.cn_cred = p->p_ucred;
+ cn.cn_pnbuf = NULL;
+ cn.cn_nameptr = "..";
+ cn.cn_namelen = 2;
+ cn.cn_hash = 0;
+ cn.cn_consume = 0;
+
+ /*
+ * At this point, lvp is locked and will be unlocked by the lookup.
+ * On successful return, *uvpp will be locked
+ */
+ error = VOP_LOOKUP(lvp, uvpp, &cn);
+ if (error) {
+ vput(lvp);
+ *lvpp = NULL;
+ *uvpp = NULL;
+ return error;
+ }
+ uvp = *uvpp;
+
+ /* If we don't care about the pathname, we're done */
+ if (bufp == NULL) {
+ vrele(lvp);
+ *lvpp = NULL;
+ return 0;
+ }
+
+ fileno = va.va_fileid;
+
+ dirbuflen = DIRBLKSIZ;
+ if (dirbuflen < va.va_blocksize)
+ dirbuflen = va.va_blocksize;
+ dirbuf = (char *)malloc(dirbuflen, M_TEMP, M_WAITOK);
+
+#if 0
+unionread:
+#endif
+ off = 0;
+ do {
+ /* call VOP_READDIR of parent */
+ iov.iov_base = dirbuf;
+ iov.iov_len = dirbuflen;
+
+ uio.uio_iov = &iov;
+ uio.uio_iovcnt = 1;
+ uio.uio_offset = off;
+ uio.uio_resid = dirbuflen;
+ uio.uio_segflg = UIO_SYSSPACE;
+ uio.uio_rw = UIO_READ;
+ uio.uio_procp = p;
+
+ eofflag = 0;
+
+ error = VOP_READDIR(uvp, &uio, p->p_ucred, &eofflag, 0, 0);
+
+ off = uio.uio_offset;
+
+ /*
+ * Try again if NFS tosses its cookies.
+ * XXX this can still loop forever if the directory is busted
+ * such that the second or subsequent page of it always
+ * returns EINVAL
+ */
+ if ((error == EINVAL) && (tries < 3)) {
+ off = 0;
+ tries++;
+ continue; /* once more, with feeling */
+ }
+
+ if (!error) {
+ char *cpos;
+ struct dirent *dp;
+
+ cpos = dirbuf;
+ tries = 0;
+
+ /* scan directory page looking for matching vnode */
+ for (len = (dirbuflen - uio.uio_resid); len > 0; len -= reclen) {
+ dp = (struct dirent *) cpos;
+ reclen = dp->d_reclen;
+
+ /* check for malformed directory.. */
+ if (reclen < DIRENT_MINSIZE) {
+ error = EINVAL;
+ goto out;
+ }
+ /*
+ * XXX should perhaps do VOP_LOOKUP to
+ * check that we got back to the right place,
+ * but getting the locking games for that
+ * right would be heinous.
+ */
+ if ((dp->d_type != DT_WHT) &&
+ (dp->d_fileno == fileno)) {
+ char *bp = *bpp;
+ bp -= dp->d_namlen;
+
+ if (bp <= bufp) {
+ error = ERANGE;
+ goto out;
+ }
+ memcpy(bp, dp->d_name, dp->d_namlen);
+ error = 0;
+ *bpp = bp;
+ goto out;
+ }
+ cpos += reclen;
+ }
+ }
+ } while (!eofflag);
+#if 0
+ /*
+ * Deal with mount -o union, which unions only the
+ * root directory of the mount.
+ */
+ if ((uvp->v_flag & VROOT) &&
+ (uvp->v_mount->mnt_flag & MNT_UNION)) {
+ struct vnode *tvp = uvp;
+ uvp = uvp->v_mount->mnt_vnodecovered;
+ vput(tvp);
+ VREF(uvp);
+ *uvpp = uvp;
+ error = vn_lock(uvp, LK_EXCLUSIVE | LK_RETRY);
+ if (error != 0) {
+ vrele(uvp);
+ *uvpp = uvp = NULL;
+ goto out;
+ }
+ goto unionread;
+ }
+#endif
+ error = ENOENT;
+
+out:
+ vrele(lvp);
+ *lvpp = NULL;
+ free(dirbuf, M_TEMP);
+ return error;
+}
+
+/*
+ * Look in the vnode-to-name reverse cache to see if
+ * we can find things the easy way.
+ *
+ * XXX vget failure path is untested.
+ *
+ * On entry, *lvpp is a locked vnode reference.
+ * On exit, one of the following is the case:
+ * 0) Both *lvpp and *uvpp are NULL and failure is returned.
+ * 1) *uvpp is NULL, *lvpp remains locked and -1 is returned (cache miss)
+ * 2) *uvpp is a locked vnode reference, *lvpp is vput and NULL'ed
+ * and 0 is returned (cache hit)
+ */
+
+static int
+netbsd_getcwd_getcache(lvpp, uvpp, bpp, bufp)
+ struct vnode **lvpp, **uvpp;
+ char **bpp;
+ char *bufp;
+{
+#ifdef notyet
+ struct vnode *lvp, *uvp = NULL;
+ int error;
+ int vpid;
+
+ lvp = *lvpp;
+
+ /*
+ * This returns 0 on a cache hit, -1 on a clean cache miss,
+ * or an errno on other failure.
+ */
+ error = cache_revlookup(lvp, uvpp, bpp, bufp);
+ if (error) {
+ if (error != -1) {
+ vput(lvp);
+ *lvpp = NULL;
+ *uvpp = NULL;
+ }
+ return error;
+ }
+ uvp = *uvpp;
+ vpid = uvp->v_id;
+
+ /*
+ * Since we're going up, we have to release the current lock
+ * before we take the parent lock.
+ */
+
+ VOP_UNLOCK(lvp, 0);
+
+ error = vget(uvp, LK_EXCLUSIVE | LK_RETRY);
+ if (error != 0)
+ *uvpp = NULL;
+ /*
+ * Verify that vget succeeded, and check that vnode capability
+ * didn't change while we were waiting for the lock.
+ */
+ if (error || (vpid != uvp->v_id)) {
+ /*
+ * Oops, we missed. If the vget failed, or the
+ * capability changed, try to get our lock back; if
+ * that works, tell caller to try things the hard way,
+ * otherwise give up.
+ */
+ if (!error) vput(uvp);
+ *uvpp = NULL;
+
+ error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY);
+
+ if (!error)
+ return -1;
+ }
+ vrele(lvp);
+ *lvpp = NULL;
+ return error;
+#endif /* notyet */
+ return (-1);
+}
+
+/*
+ * common routine shared by sys___getcwd() and netbsd_vn_isunder()
+ */
+
+#define GETCWD_CHECK_ACCESS 0x0001
+
+static int
+netbsd_getcwd_common (lvp, rvp, bpp, bufp, limit, flags, p)
+ struct vnode *lvp;
+ struct vnode *rvp;
+ char **bpp;
+ char *bufp;
+ int limit;
+ int flags;
+ struct proc *p;
+{
+ struct filedesc *fdp = p->p_fd;
+ struct vnode *uvp = NULL;
+ char *bp = NULL;
+ int error;
+ int perms = VEXEC;
+
+ if (rvp == NULL) {
+ rvp = fdp->fd_rdir;
+ if (rvp == NULL)
+ rvp = rootvnode;
+ }
+
+ VREF(rvp);
+ VREF(lvp);
+
+ /*
+ * Error handling invariant:
+ * Before a `goto out':
+ * lvp is either NULL, or locked and held.
+ * uvp is either NULL, or locked and held.
+ */
+
+ error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, p);
+ if (error) {
+ vrele(lvp);
+ lvp = NULL;
+ goto out;
+ }
+ if (bufp)
+ bp = *bpp;
+ /*
+ * this loop will terminate when one of the following happens:
+ * - we hit the root
+ * - getdirentries or lookup fails
+ * - we run out of space in the buffer.
+ */
+ if (lvp == rvp) {
+ if (bp)
+ *(--bp) = '/';
+ goto out;
+ }
+ do {
+ if (lvp->v_type != VDIR) {
+ error = ENOTDIR;
+ goto out;
+ }
+
+ /*
+ * access check here is optional, depending on
+ * whether or not caller cares.
+ */
+ if (flags & GETCWD_CHECK_ACCESS) {
+ error = VOP_ACCESS(lvp, perms, p->p_ucred, p);
+ if (error)
+ goto out;
+ perms = VEXEC|VREAD;
+ }
+
+ /*
+ * step up if we're a covered vnode..
+ */
+ while (lvp->v_flag & VROOT) {
+ struct vnode *tvp;
+
+ if (lvp == rvp)
+ goto out;
+
+ tvp = lvp;
+ lvp = lvp->v_mount->mnt_vnodecovered;
+ vput(tvp);
+ /*
+ * hodie natus est radici frater
+ */
+ if (lvp == NULL) {
+ error = ENOENT;
+ goto out;
+ }
+ VREF(lvp);
+ error = vn_lock(lvp, LK_EXCLUSIVE | LK_RETRY, p);
+ if (error != 0) {
+ vrele(lvp);
+ lvp = NULL;
+ goto out;
+ }
+ }
+ /*
+ * Look in the name cache; if that fails, look in the
+ * directory..
+ */
+ error = netbsd_getcwd_getcache(&lvp, &uvp, &bp, bufp);
+ if (error == -1)
+ error = netbsd_getcwd_scandir(&lvp, &uvp, &bp, bufp, p);
+ if (error)
+ goto out;
+#if DIAGNOSTIC
+ if (lvp != NULL)
+ panic("getcwd: oops, forgot to null lvp");
+ if (bufp && (bp <= bufp)) {
+ panic("getcwd: oops, went back too far");
+ }
+#endif
+ if (bp)
+ *(--bp) = '/';
+ lvp = uvp;
+ uvp = NULL;
+ limit--;
+ } while ((lvp != rvp) && (limit > 0));
+
+out:
+ if (bpp)
+ *bpp = bp;
+ if (uvp)
+ vput(uvp);
+ if (lvp)
+ vput(lvp);
+ vrele(rvp);
+ return error;
+}
+
+/*
+ * Check if one directory can be found inside another in the directory
+ * hierarchy.
+ *
+ * Intended to be used in chroot, chdir, fchdir, etc., to ensure that
+ * chroot() actually means something.
+ */
+static int
+netbsd_vn_isunder(lvp, rvp, p)
+ struct vnode *lvp;
+ struct vnode *rvp;
+ struct proc *p;
+{
+ int error;
+
+ error = netbsd_getcwd_common (lvp, rvp, NULL, NULL, MAXPATHLEN/2, 0, p);
+
+ if (!error)
+ return 1;
+ else
+ return 0;
+}
+
+/*
+ * Returns true if proc p1's root directory equal to or under p2's
+ * root directory.
+ *
+ * Intended to be used from ptrace/procfs sorts of things.
+ */
+
+int proc_isunder (p1, p2)
+ struct proc *p1;
+ struct proc *p2;
+{
+ struct vnode *r1 = p1->p_fd->fd_rdir;
+ struct vnode *r2 = p2->p_fd->fd_rdir;
+
+ if (r1 == NULL)
+ return (r2 == NULL);
+ else if (r2 == NULL)
+ return 1;
+ else
+ return netbsd_vn_isunder(r1, r2, p2);
+}
+
+/*
+ * Find pathname of process's current directory.
+ *
+ * Use vfs vnode-to-name reverse cache; if that fails, fall back
+ * to reading directory contents.
+ */
+
+int netbsd_sys___getcwd(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct netbsd_sys___getcwd_args /* {
+ syscallarg(char *) bufp;
+ syscallarg(size_t) length;
+ } */ *uap = v;
+
+ int error;
+ char *path;
+ char *bp, *bend;
+ int len = SCARG(uap, length);
+ int lenused;
+
+ if (len > MAXPATHLEN*4)
+ len = MAXPATHLEN*4;
+ else if (len < 2)
+ return ERANGE;
+
+ path = (char *)malloc(len, M_TEMP, M_WAITOK);
+ if (!path)
+ return ENOMEM;
+
+ bp = &path[len];
+ bend = bp;
+ *(--bp) = '\0';
+
+ /*
+ * 5th argument here is "max number of vnodes to traverse".
+ * Since each entry takes up at least 2 bytes in the output buffer,
+ * limit it to N/2 vnodes for an N byte buffer.
+ */
+ error = netbsd_getcwd_common (p->p_fd->fd_cdir, NULL, &bp, path, len/2,
+ GETCWD_CHECK_ACCESS, p);
+
+ if (error)
+ goto out;
+ lenused = bend - bp;
+ *retval = lenused;
+ /* put the result into user buffer */
+ error = copyout(bp, SCARG(uap, bufp), lenused);
+
+out:
+ free(path, M_TEMP);
+ return error;
+}
diff --git a/sys/compat/netbsd/netbsd_stat.c b/sys/compat/netbsd/netbsd_stat.c
new file mode 100644
index 00000000000..eb97d3e6bf1
--- /dev/null
+++ b/sys/compat/netbsd/netbsd_stat.c
@@ -0,0 +1,206 @@
+/* $OpenBSD: netbsd_stat.c,v 1.1 1999/09/12 14:15:16 kstailey Exp $ */
+/*
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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 the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+ *
+ * @(#)vfs_syscalls.c 8.42 (Berkeley) 7/31/95
+ */
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/proc.h>
+#include <sys/socketvar.h>
+#include <sys/stat.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/vnode.h>
+#include <compat/netbsd/netbsd_types.h>
+#include <compat/netbsd/netbsd_stat.h>
+#include <compat/netbsd/netbsd_syscallargs.h>
+
+static void openbsd_to_netbsd_stat __P((struct stat *, struct netbsd_stat *));
+
+static void
+openbsd_to_netbsd_stat(obst, nbst)
+ struct stat *obst;
+ struct netbsd_stat *nbst;
+{
+ bzero(nbst, sizeof(*nbst));
+ nbst->st_dev = obst->st_dev;
+ nbst->st_ino = obst->st_ino;
+ nbst->st_mode = obst->st_mode;
+ nbst->st_nlink = obst->st_nlink;
+ nbst->st_uid = obst->st_uid;
+ nbst->st_gid = obst->st_gid;
+ nbst->st_rdev = obst->st_rdev;
+#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
+ nbst->st_atimespec.tv_sec = obst->st_atimespec.tv_sec;
+ nbst->st_atimespec.tv_nsec = obst->st_atimespec.tv_nsec;
+ nbst->st_mtimespec.tv_sec = obst->st_mtimespec.tv_sec;
+ nbst->st_mtimespec.tv_nsec = obst->st_mtimespec.tv_nsec;
+ nbst->st_ctimespec.tv_sec = obst->st_ctimespec.tv_sec;
+ nbst->st_ctimespec.tv_nsec = obst->st_ctimespec.tv_nsec;
+#else
+ nbst->st_atime = obst->st_atime;
+ nbst->st_atimensec = obst->st_atimensec;
+ nbst->st_mtime = obst->st_mtime;
+ nbst->st_mtimensec = obst->st_mtimensec;
+ nbst->st_ctime = obst->st_ctime;
+ nbst->st_ctimensec = obst->st_ctimensec;
+#endif
+ nbst->st_size = obst->st_size;
+ nbst->st_blocks = obst->st_blocks;
+ nbst->st_blksize = obst->st_blksize;
+ nbst->st_flags = obst->st_flags;
+ nbst->st_gen = obst->st_gen;
+ memcpy(nbst->st_qspare, obst->st_qspare, sizeof(nbst->st_qspare));
+}
+
+/*
+ * Get file status; this version follows links.
+ */
+/* ARGSUSED */
+int
+netbsd_sys___stat13(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct netbsd_sys___stat13_args /* {
+ syscallarg(const char *) path;
+ syscallarg(struct netbsd_stat *) nsb;
+ } */ *uap = v;
+ struct netbsd_stat nsb;
+ struct stat sb;
+ int error;
+ struct nameidata nd;
+
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
+ SCARG(uap, path), p);
+ if ((error = namei(&nd)) != 0)
+ return (error);
+ error = vn_stat(nd.ni_vp, &sb, p);
+ vput(nd.ni_vp);
+ if (error)
+ return (error);
+ /* Don't let non-root see generation numbers (for NFS security) */
+ if (suser(p->p_ucred, &p->p_acflag))
+ sb.st_gen = 0;
+ openbsd_to_netbsd_stat(&sb, &nsb);
+ error = copyout(&nsb, SCARG(uap, ub), sizeof(nsb));
+ return (error);
+}
+
+/*
+ * Get file status; this version does not follow links.
+ */
+/* ARGSUSED */
+int
+netbsd_sys___lstat13(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct netbsd_sys___lstat13_args /* {
+ syscallarg(const char *) path;
+ syscallarg(struct netbsd_stat *) nsb;
+ } */ *uap = v;
+ struct netbsd_stat nsb;
+ struct stat sb;
+ int error;
+ struct nameidata nd;
+
+ NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE,
+ SCARG(uap, path), p);
+ if ((error = namei(&nd)) != 0)
+ return (error);
+ error = vn_stat(nd.ni_vp, &sb, p);
+ vput(nd.ni_vp);
+ if (error)
+ return (error);
+ /* Don't let non-root see generation numbers (for NFS security) */
+ if (suser(p->p_ucred, &p->p_acflag))
+ sb.st_gen = 0;
+ openbsd_to_netbsd_stat(&sb, &nsb);
+ error = copyout(&nsb, SCARG(uap, ub), sizeof(nsb));
+ return (error);
+}
+
+/*
+ * Return status information about a file descriptor.
+ */
+/* ARGSUSED */
+int
+netbsd_sys___fstat13(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct netbsd_sys___fstat13_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct netbsd_stat *) nsb;
+ } */ *uap = v;
+ int fd = SCARG(uap, fd);
+ register struct filedesc *fdp = p->p_fd;
+ register struct file *fp;
+ struct netbsd_stat nsb;
+ struct stat sb;
+ int error;
+
+ if ((u_int)fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fd]) == NULL)
+ return (EBADF);
+ switch (fp->f_type) {
+
+ case DTYPE_VNODE:
+ error = vn_stat((struct vnode *)fp->f_data, &sb, p);
+ break;
+
+ case DTYPE_SOCKET:
+ error = soo_stat((struct socket *)fp->f_data, &sb);
+ break;
+
+ default:
+ panic("fstat");
+ /*NOTREACHED*/
+ }
+ if (error)
+ return (error);
+ openbsd_to_netbsd_stat(&sb, &nsb);
+ error = copyout(&nsb, SCARG(uap, ub), sizeof(nsb));
+ return (error);
+}
diff --git a/sys/compat/netbsd/netbsd_stat.h b/sys/compat/netbsd/netbsd_stat.h
new file mode 100644
index 00000000000..364e6176255
--- /dev/null
+++ b/sys/compat/netbsd/netbsd_stat.h
@@ -0,0 +1,118 @@
+/* $OpenBSD: netbsd_stat.h,v 1.1 1999/09/12 14:15:16 kstailey Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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 the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+ *
+ * @(#)stat.h 8.12 (Berkeley) 8/17/94
+ */
+
+struct netbsd_stat12 { /* NetBSD-1.2 stat struct */
+ dev_t st_dev; /* inode's device */
+ ino_t st_ino; /* inode's number */
+ u_int16_t st_mode; /* inode protection mode */
+ u_int16_t st_nlink; /* number of hard links */
+ uid_t st_uid; /* user ID of the file's owner */
+ gid_t st_gid; /* group ID of the file's group */
+ dev_t st_rdev; /* device type */
+ struct timespec st_atimespec;/* time of last access */
+ struct timespec st_mtimespec;/* time of last data modification */
+ struct timespec st_ctimespec;/* time of last file status change */
+ off_t st_size; /* file size, in bytes */
+ int64_t st_blocks; /* blocks allocated for file */
+ u_int32_t st_blksize; /* optimal blocksize for I/O */
+ u_int32_t st_flags; /* user defined flags for file */
+ u_int32_t st_gen; /* file generation number */
+ int32_t st_lspare;
+ int64_t st_qspare[2];
+};
+
+/*
+ * On systems with 8 byte longs and 4 byte time_ts, padding the time_ts
+ * is required in order to have a consistent ABI. This is because the
+ * stat structure used to contain timespecs, which had different
+ * alignment constraints than a time_t and a long alone. The padding
+ * should be removed the next time the stat structure ABI is changed.
+ * (This will happen whever we change to 8 byte time_t.)
+ */
+#if defined(__alpha__) /* XXX XXX XXX */
+#define __STATPAD(x) int x;
+#else
+#define __STATPAD(x) /* nothing */
+#endif
+
+struct netbsd_stat {
+ dev_t st_dev; /* inode's device */
+ ino_t st_ino; /* inode's number */
+ mode_t st_mode; /* inode protection mode */
+ nlink_t st_nlink; /* number of hard links */
+ uid_t st_uid; /* user ID of the file's owner */
+ gid_t st_gid; /* group ID of the file's group */
+ dev_t st_rdev; /* device type */
+#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
+ struct timespec st_atimespec;/* time of last access */
+ struct timespec st_mtimespec;/* time of last data modification */
+ struct timespec st_ctimespec;/* time of last file status change */
+#else
+ __STATPAD(__pad0)
+ time_t st_atime; /* time of last access */
+ __STATPAD(__pad1)
+ long st_atimensec; /* nsec of last access */
+ time_t st_mtime; /* time of last data modification */
+ __STATPAD(__pad2)
+ long st_mtimensec; /* nsec of last data modification */
+ time_t st_ctime; /* time of last file status change */
+ __STATPAD(__pad3)
+ long st_ctimensec; /* nsec of last file status change */
+#endif
+ off_t st_size; /* file size, in bytes */
+ netbsd_blkcnt_t st_blocks; /* blocks allocated for file */
+ netbsd_blksize_t st_blksize; /* optimal blocksize for I/O */
+ u_int32_t st_flags; /* user defined flags for file */
+ u_int32_t st_gen; /* file generation number */
+ int64_t st_qspare[2];
+};
+
+#undef __STATPAD
+
+#if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
+#define st_atime st_atimespec.tv_sec
+#define st_atimensec st_atimespec.tv_nsec
+#define st_mtime st_mtimespec.tv_sec
+#define st_mtimensec st_mtimespec.tv_nsec
+#define st_ctime st_ctimespec.tv_sec
+#define st_ctimensec st_ctimespec.tv_nsec
+#endif
diff --git a/sys/compat/netbsd/netbsd_types.h b/sys/compat/netbsd/netbsd_types.h
new file mode 100644
index 00000000000..89aaa47aefb
--- /dev/null
+++ b/sys/compat/netbsd/netbsd_types.h
@@ -0,0 +1,44 @@
+/* $OpenBSD: netbsd_types.h,v 1.1 1999/09/12 14:15:17 kstailey Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1991, 1993, 1994
+ * The Regents of the University of California. All rights reserved.
+ * (c) UNIX System Laboratories, Inc.
+ * All or some portions of this file are derived from material licensed
+ * to the University of California by American Telephone and Telegraph
+ * Co. or Unix System Laboratories, Inc. and are reproduced herein with
+ * the permission of UNIX System Laboratories, Inc.
+ *
+ * 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 the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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.
+ *
+ * @(#)types.h 8.4 (Berkeley) 1/21/94
+ */
+
+typedef int64_t netbsd_blkcnt_t; /* fs block count */
+typedef u_int32_t netbsd_blksize_t; /* fs optimal block size */
diff --git a/sys/compat/netbsd/netbsd_util.h b/sys/compat/netbsd/netbsd_util.h
new file mode 100644
index 00000000000..a486d203adb
--- /dev/null
+++ b/sys/compat/netbsd/netbsd_util.h
@@ -0,0 +1,54 @@
+/* $OpenBSD: netbsd_util.h,v 1.1 1999/09/12 14:15:17 kstailey Exp $ */
+/* $NetBSD: freebsd_util.h,v 1.1 1995/10/10 01:19:38 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1994 Christos Zoulas
+ * Copyright (c) 1995 Frank van der Linden
+ * 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. 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.
+ *
+ * from: svr4_util.h,v 1.5 1994/11/18 02:54:31 christos Exp
+ * from: linux_util.h,v 1.3 1995/04/07 22:23:27 fvdl Exp
+ */
+
+/*
+ * This file is pretty much the same as Christos' svr4_util.h
+ * This file is pretty much the same as Fvdl's linux_util.h
+ * (for now).
+ */
+
+#ifndef _NETBSD_UTIL_H_
+#define _NETBSD_UTIL_H_
+
+#include <compat/common/compat_util.h>
+
+extern const char netbsd_emul_path[];
+
+#define NETBSD_CHECK_ALT_EXIST(p, sgp, path) \
+ CHECK_ALT_EXIST(p, sgp, netbsd_emul_path, path)
+
+#define NETBSD_CHECK_ALT_CREAT(p, sgp, path) \
+ CHECK_ALT_CREAT(p, sgp, netbsd_emul_path, path)
+
+#endif /* !_NETBSD_UTIL_H_ */
diff --git a/sys/compat/netbsd/syscalls.conf b/sys/compat/netbsd/syscalls.conf
new file mode 100644
index 00000000000..9bf218ccdb2
--- /dev/null
+++ b/sys/compat/netbsd/syscalls.conf
@@ -0,0 +1,12 @@
+# $OpenBSD: syscalls.conf,v 1.1 1999/09/12 14:15:17 kstailey Exp $
+
+sysnames="netbsd_syscalls.c"
+sysnumhdr="netbsd_syscall.h"
+syssw="netbsd_sysent.c"
+sysarghdr="netbsd_syscallargs.h"
+compatopts=""
+libcompatopts=""
+
+switchname="netbsd_sysent"
+namesname="netbsd_syscallnames"
+constprefix="NETBSD_SYS_"
diff --git a/sys/compat/netbsd/syscalls.master b/sys/compat/netbsd/syscalls.master
new file mode 100644
index 00000000000..8ffacbb99e8
--- /dev/null
+++ b/sys/compat/netbsd/syscalls.master
@@ -0,0 +1,622 @@
+; $OpenBSD: syscalls.master,v 1.1 1999/09/12 14:15:17 kstailey Exp $
+
+; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
+
+; OpenBSD COMPAT_FREEBSD system call name/number "master" file.
+; (See syscalls.conf to see what it is processed into.)
+;
+; Fields: number type [type-dependent ...]
+; number system call number, must be in order
+; type one of STD, OBSOL, UNIMPL, NODEF, NOARGS, or one of
+; the compatibility options defined in syscalls.conf.
+;
+; types:
+; STD always included
+; OBSOL obsolete, not included in system
+; UNIMPL unimplemented, not included in system
+; NODEF included, but don't define the syscall number
+; NOARGS included, but don't define the syscall args structure
+; INDIR included, but don't define the syscall args structure,
+; and allow it to be "really" varargs.
+;
+; The compat options are defined in the syscalls.conf file, and the
+; compat option name is prefixed to the syscall name. Other than
+; that, they're like NODEF (for 'compat' options), or STD (for
+; 'libcompat' options).
+;
+; The type-dependent arguments are as follows:
+; For STD, NODEF, NOARGS, and compat syscalls:
+; { pseudo-proto } [alias]
+; For other syscalls:
+; [comment]
+;
+; #ifdef's, etc. may be included, and are copied to the output files.
+; #include's are copied to the syscall switch definition file only.
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signal.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <sys/poll.h>
+
+#include <compat/netbsd/netbsd_types.h>
+#include <compat/netbsd/netbsd_stat.h>
+#include <compat/netbsd/netbsd_syscallargs.h>
+
+#include <machine/netbsd_machdep.h>
+
+; Reserved/unimplemented system calls in the range 0-150 inclusive
+; are reserved for use in future Berkeley releases.
+; Additional system calls implemented in vendor and other
+; redistributions should be placed in the reserved range at the end
+; of the current calls.
+
+0 INDIR { int sys_syscall(int number, ...); }
+1 NOARGS { void sys_exit(int rval); }
+2 NOARGS { int sys_fork(void); }
+3 NOARGS { ssize_t sys_read(int fd, void *buf, size_t nbyte); }
+4 NOARGS { ssize_t sys_write(int fd, const void *buf, \
+ size_t nbyte); }
+; XXX int mode vs. mode_t mode
+5 NOARGS { int sys_open(const char *path, \
+ int flags, ... int mode); }
+6 NOARGS { int sys_close(int fd); }
+7 NOARGS { int sys_wait4(int pid, int *status, int options, \
+ struct rusage *rusage); }
+; XXX int mode vs. mode_t mode
+8 NOARGS { int compat_43_sys_creat(char *path, \
+ int mode); } ocreat
+9 NOARGS { int sys_link(const char *path, const char *link); }
+10 NOARGS { int sys_unlink(const char *path); }
+11 OBSOL execv
+12 NOARGS { int sys_chdir(const char *path); }
+13 NOARGS { int sys_fchdir(int fd); }
+; XXX int mode vs. mode_t mode
+14 NOARGS { int sys_mknod(const char *path, int mode, \
+ dev_t dev); }
+; XXX int mode vs. mode_t mode
+15 NOARGS { int sys_chmod(const char *path, int mode); }
+16 NOARGS { int sys_chown(const char *path, uid_t uid, \
+ gid_t gid); }
+17 NOARGS { int sys_obreak(char *nsize); } break
+18 NOARGS { int sys_ogetfsstat(struct statfs *buf, long bufsize, \
+ int flags); }
+19 NOARGS { long sys_lseek(int fd, long offset, int whence); } \
+ olseek
+20 NOARGS { pid_t sys_getpid(void); }
+21 NOARGS { int sys_mount(const char *type, const char *path, \
+ int flags, void *data); }
+22 NOARGS { int sys_unmount(const char *path, int flags); }
+23 NOARGS { int sys_setuid(uid_t uid); }
+24 NOARGS { uid_t sys_getuid(void); }
+25 NOARGS { uid_t sys_geteuid(void); }
+26 NOARGS { int sys_ptrace(int req, pid_t pid, caddr_t addr, \
+ int data); }
+27 NOARGS { ssize_t sys_recvmsg(int s, struct msghdr *msg, \
+ int flags); }
+28 NOARGS { ssize_t sys_sendmsg(int s, \
+ const struct msghdr *msg, int flags); }
+; XXX unsigned int *fromlenaddr vs. socklen_t *fromlenaddr
+29 NOARGS { ssize_t sys_recvfrom(int s, void *buf, size_t len, \
+ int flags, struct sockaddr *from, \
+ socklen_t *fromlenaddr); }
+; XXX unsigned int *fromlenaddr vs. socklen_t *fromlenaddr
+30 NOARGS { int sys_accept(int s, struct sockaddr *name, \
+ socklen_t *anamelen); }
+; XXX unsigned int *alen vs. int *alen
+31 NOARGS { int sys_getpeername(int fdes, struct sockaddr *asa, \
+ int *alen); }
+32 NOARGS { int sys_getsockname(int fdes, struct sockaddr *asa, \
+ socklen_t *alen); }
+33 NOARGS { int sys_access(const char *path, int flags); }
+; XXX u_long flags vs. u_int flags
+34 NOARGS { int sys_chflags(const char *path, u_int flags); }
+; XXX u_long flags vs. u_int flags
+35 NOARGS { int sys_fchflags(int fd, u_int flags); }
+36 NOARGS { void sys_sync(void); }
+37 NOARGS { int sys_kill(int pid, int signum); }
+; XXX struct stat43 *ub vs. struct ostat *ub
+38 NOARGS { int sys_stat(const char *path, struct ostat *ub); } \
+ ostat
+39 NOARGS { pid_t sys_getppid(void); }
+; XXX struct stat43 *ub vs. struct ostat *ub
+40 NOARGS { int sys_lstat(char *path, \
+ struct ostat *ub); } olstat
+41 NOARGS { int sys_dup(int fd); }
+42 NOARGS { int sys_opipe(void); }
+43 NOARGS { gid_t sys_getegid(void); }
+44 NOARGS { int sys_profil(caddr_t samples, size_t size, \
+ u_long offset, u_int scale); }
+#ifdef KTRACE
+45 NOARGS { int sys_ktrace(const char *fname, int ops, \
+ int facs, pid_t pid); }
+#else
+45 UNIMPL ktrace
+#endif
+46 NOARGS { int sys_sigaction(int signum, \
+ const struct sigaction *nsa, \
+ struct sigaction *osa); }
+47 NOARGS { gid_t sys_getgid(void); }
+48 NOARGS { int sys_sigprocmask(int how, sigset_t mask); }
+49 NOARGS { int sys_getlogin(char *namebuf, u_int namelen); }
+50 NOARGS { int sys_setlogin(const char *namebuf); }
+51 NOARGS { int sys_acct(const char *path); }
+52 NOARGS { int sys_sigpending(void); }
+53 NOARGS { int sys_sigaltstack(const struct sigaltstack *nss, \
+ struct sigaltstack *oss); }
+54 NOARGS { int sys_ioctl(int fd, \
+ u_long com, ... void *data); }
+55 NOARGS { int sys_reboot(int opt); }
+56 NOARGS { int sys_revoke(const char *path); }
+57 NOARGS { int sys_symlink(const char *path, \
+ const char *link); }
+58 NOARGS { int sys_readlink(const char *path, char *buf, \
+ size_t count); }
+59 NOARGS { int sys_execve(const char *path, \
+ char * const *argp, char * const *envp); }
+60 NOARGS { int sys_umask(int newmask); }
+61 NOARGS { int sys_chroot(const char *path); }
+62 NOARGS { int sys_fstat(int fd, struct ostat *sb); } ofstat
+63 NOARGS { int compat_43_sys_getkerninfo(int op, char *where, \
+ int *size, int arg); } ogetkerninfo
+64 NOARGS { int compat_43_sys_getpagesize(void); } ogetpagesize
+65 NOARGS { int sys_omsync(caddr_t addr, size_t len); }
+66 NOARGS { int sys_vfork(void); }
+67 OBSOL vread
+68 OBSOL vwrite
+69 NOARGS { int sys_sbrk(int incr); }
+70 NOARGS { int sys_sstk(int incr); }
+71 NOARGS { int sys_mmap(caddr_t addr, size_t len, int prot, \
+ int flags, int fd, long pos); } ommap
+72 NOARGS { int sys_ovadvise(int anom); } vadvise
+73 NOARGS { int sys_munmap(void *addr, size_t len); }
+74 NOARGS { int sys_mprotect(void *addr, size_t len, \
+ int prot); }
+75 NOARGS { int sys_madvise(void *addr, size_t len, \
+ int behav); }
+76 OBSOL vhangup
+77 OBSOL vlimit
+78 NOARGS { int sys_mincore(void *addr, size_t len, \
+ char *vec); }
+79 NOARGS { int sys_getgroups(int gidsetsize, \
+ gid_t *gidset); }
+80 NOARGS { int sys_setgroups(int gidsetsize, \
+ const gid_t *gidset); }
+81 NOARGS { int sys_getpgrp(void); }
+82 NOARGS { int sys_setpgid(pid_t pid, int pgid); }
+83 NOARGS { int sys_setitimer(int which, \
+ const struct itimerval *itv, \
+ struct itimerval *oitv); }
+84 NOARGS { int compat_43_sys_wait(void); } owait
+85 NOARGS { int sys_swapon(const char *name); }
+86 NOARGS { int sys_getitimer(int which, \
+ struct itimerval *itv); }
+87 NOARGS { int compat_43_sys_gethostname(char *hostname, \
+ u_int len); } ogethostname
+88 NOARGS { int compat_43_sys_sethostname(char *hostname, \
+ u_int len); } osethostname
+89 NOARGS { int compat_43_sys_getdtablesize(void); } \
+ ogetdtablesize
+90 NOARGS { int sys_dup2(int from, int to); }
+91 UNIMPL getdopt
+92 NOARGS { int sys_fcntl(int fd, int cmd, ... void *arg); }
+93 NOARGS { int sys_select(int nd, fd_set *in, fd_set *ou, \
+ fd_set *ex, struct timeval *tv); }
+94 UNIMPL setdopt
+95 NOARGS { int sys_fsync(int fd); }
+96 NOARGS { int sys_setpriority(int which, int who, int prio); }
+97 NOARGS { int sys_socket(int domain, int type, int protocol); }
+98 NOARGS { int sys_connect(int s, const struct sockaddr *name, \
+ socklen_t namelen); }
+99 NOARGS { int sys_accept(int s, caddr_t name, \
+ int *anamelen); } oaccept
+100 NOARGS { int sys_getpriority(int which, int who); }
+101 NOARGS { int compat_43_sys_send(int s, caddr_t buf, int len, \
+ int flags); } osend
+102 NOARGS { int compat_43_sys_recv(int s, caddr_t buf, int len, \
+ int flags); } orecv
+103 NOARGS { int sys_sigreturn(struct sigcontext *sigcntxp); }
+104 NOARGS { int sys_bind(int s, const struct sockaddr *name, \
+ socklen_t namelen); }
+105 NOARGS { int sys_setsockopt(int s, int level, int name, \
+ const void *val, socklen_t valsize); }
+106 NOARGS { int sys_listen(int s, int backlog); }
+107 OBSOL vtimes
+108 NOARGS { int compat_43_sys_sigvec(int signum, \
+ struct sigvec *nsv, struct sigvec *osv); } osigvec
+109 NOARGS { int compat_43_sys_sigblock(int mask); } osigblock
+110 NOARGS { int compat_43_sys_sigsetmask(int mask); } osigsetmask
+111 NOARGS { int sys_sigsuspend(int mask); }
+112 NOARGS { int compat_43_sys_sigstack(struct sigstack *nss, \
+ struct sigstack *oss); } osigstack
+113 NOARGS { int compat_43_sys_recvmsg(int s, \
+ struct omsghdr *msg, int flags); } orecvmsg
+114 NOARGS { int compat_43_sys_sendmsg(int s, caddr_t msg, \
+ int flags); } osendmsg
+#ifdef TRACE
+115 NOARGS { int sys_vtrace(int request, int value); }
+#else
+115 OBSOL vtrace
+#endif
+116 NOARGS { int sys_gettimeofday(struct timeval *tp, \
+ struct timezone *tzp); }
+117 NOARGS { int sys_getrusage(int who, struct rusage *rusage); }
+118 NOARGS { int sys_getsockopt(int s, int level, int name, \
+ void *val, socklen_t *avalsize); }
+119 OBSOL resuba
+120 NOARGS { ssize_t sys_readv(int fd, \
+ const struct iovec *iovp, int iovcnt); }
+121 NOARGS { ssize_t sys_writev(int fd, \
+ const struct iovec *iovp, int iovcnt); }
+122 NOARGS { int sys_settimeofday(const struct timeval *tv, \
+ const struct timezone *tzp); }
+123 NOARGS { int sys_fchown(int fd, uid_t uid, gid_t gid); }
+124 NOARGS { int sys_fchmod(int fd, int mode); }
+125 NOARGS { int compat_43_sys_recvfrom(int s, caddr_t buf, \
+ size_t len, int flags, caddr_t from, \
+ int *fromlenaddr); } orecvfrom
+126 NOARGS { int compat_43_sys_setreuid(int ruid, int euid); } \
+ osetreuid
+127 NOARGS { int compat_43_sys_setregid(int rgid, int egid); } \
+ osetregid
+128 NOARGS { int sys_rename(const char *from, const char *to); }
+129 NOARGS { int compat_43_sys_truncate(char *path, \
+ long length); } otruncate
+130 NOARGS { int compat_43_sys_ftruncate(int fd, long length); } \
+ oftruncate
+131 NOARGS { int sys_flock(int fd, int how); }
+132 NOARGS { int sys_mkfifo(const char *path, int mode); }
+133 NOARGS { ssize_t sys_sendto(int s, const void *buf, \
+ size_t len, int flags, const struct sockaddr *to, \
+ socklen_t tolen); }
+134 NOARGS { int sys_shutdown(int s, int how); }
+135 NOARGS { int sys_socketpair(int domain, int type, \
+ int protocol, int *rsv); }
+136 NOARGS { int sys_mkdir(const char *path, int mode); }
+137 NOARGS { int sys_rmdir(const char *path); }
+138 NOARGS { int sys_utimes(const char *path, \
+ const struct timeval *tptr); }
+139 OBSOL 4.2 sigreturn
+140 NOARGS { int sys_adjtime(const struct timeval *delta, \
+ struct timeval *olddelta); }
+141 NOARGS { int compat_43_sys_getpeername(int fdes, caddr_t asa, \
+ int *alen); } ogetpeername
+142 NOARGS { int32_t compat_43_sys_gethostid(void); } ogethostid
+143 NOARGS { int compat_43_sys_sethostid(int32_t hostid); } \
+ osethostid
+144 NOARGS { int compat_43_sys_getrlimit(u_int which, \
+ struct ogetrlimit *rlp); } ogetrlimit
+145 NOARGS { int compat_43_sys_setrlimit(u_int which, \
+ struct ogetrlimit *rlp); } osetrlimit
+146 NOARGS { int compat_43_sys_killpg(int pgid, int signum); } \
+ okillpg
+147 NOARGS { int sys_setsid(void); }
+148 NOARGS { int sys_quotactl(const char *path, int cmd, \
+ int uid, char *arg); }
+149 NOARGS { int compat_43_sys_quota(void); } oquota
+150 NOARGS { int compat_43_sys_getsockname(int fdec, caddr_t asa, \
+ int *alen); } ogetsockname
+
+; Syscalls 151-180 inclusive are reserved for vendor-specific
+; system calls. (This includes various calls added for compatibity
+; with other Unix variants.)
+; Some of these calls are now supported by BSD...
+151 UNIMPL
+152 UNIMPL
+153 UNIMPL
+154 UNIMPL
+#if defined(NFSCLIENT) || defined(NFSSERVER)
+155 NOARGS { int sys_nfssvc(int flag, void *argp); }
+#else
+155 UNIMPL
+#endif
+156 NOARGS { int compat_43_sys_getdirentries(int fd, char *buf, \
+ u_int count, long *basep); } ogetdirentries
+157 NOARGS { int sys_ostatfs(char *path, struct ostatfs *buf); }
+158 NOARGS { int sys_ofstatfs(int fd, struct ostatfs *buf); }
+159 UNIMPL
+160 UNIMPL
+#if defined(NFSCLIENT) || defined(NFSSERVER)
+161 NOARGS { int sys_getfh(const char *fname, fhandle_t *fhp); }
+#else
+161 UNIMPL getfh
+#endif
+162 NOARGS { int compat_09_sys_getdomainname(char *domainname, \
+ int len); } ogetdomainname
+163 NOARGS { int compat_09_sys_setdomainname(char *domainname, \
+ int len); } osetdomainname
+164 NOARGS { int compat_09_sys_uname(struct outsname *name); } \
+ ouname
+165 NOARGS { int sys_sysarch(int op, char *parms); }
+166 UNIMPL
+167 UNIMPL
+168 UNIMPL
+; XXX more generally, never on machines where sizeof(void *) != sizeof(int)
+#if defined(SYSVSEM) && !defined(alpha)
+169 NOARGS { int sys_semsys(int which, int a2, int a3, int a4, \
+ int a5); } osemsys
+#else
+169 UNIMPL 1.0 semsys
+#endif
+; XXX more generally, never on machines where sizeof(void *) != sizeof(int)
+#if defined(SYSVMSG) && !defined(alpha)
+170 NOARGS { int sys_msgsys(int which, int a2, int a3, int a4, \
+ int a5, int a6); } omsgsys
+#else
+170 UNIMPL 1.0 msgsys
+#endif
+; XXX more generally, never on machines where sizeof(void *) != sizeof(int)
+#if defined(SYSVSHM) && !defined(alpha)
+171 NOARGS { int compat_10_sys_shmsys(int which, int a2, int a3, \
+ int a4); }
+#else
+171 UNIMPL 1.0 shmsys
+#endif
+172 UNIMPL
+173 UNIMPL
+174 UNIMPL
+#ifdef NTP
+175 NOARGS { int sys_ntp_gettime(struct ntptimeval *ntvp); }
+176 NOARGS { int sys_ntp_adjtime(struct timex *tp); }
+#else
+175 UNIMPL ntp_gettime
+176 UNIMPL ntp_adjtime
+#endif
+177 UNIMPL
+178 UNIMPL
+179 UNIMPL
+180 UNIMPL
+
+; Syscalls 181-199 are used by/reserved for BSD
+181 NOARGS { int sys_setgid(gid_t gid); }
+182 NOARGS { int sys_setegid(gid_t egid); }
+183 NOARGS { int sys_seteuid(uid_t euid); }
+#ifdef LFS
+184 NOARGS { int lfs_bmapv(fsid_t *fsidp, \
+ struct block_info *blkiov, int blkcnt); }
+185 NOARGS { int lfs_markv(fsid_t *fsidp, \
+ struct block_info *blkiov, int blkcnt); }
+186 NOARGS { int lfs_segclean(fsid_t *fsidp, u_long segment); }
+187 NOARGS { int lfs_segwait(fsid_t *fsidp, struct timeval *tv); }
+#else
+184 UNIMPL
+185 UNIMPL
+186 UNIMPL
+187 UNIMPL
+#endif
+188 NOARGS { int sys_stat(const char *path, struct stat *ub); }
+189 NOARGS { int sys_fstat(int fd, struct stat12 *sb); }
+190 NOARGS { int sys_lstat(const char *path, struct stat *ub); }
+191 NOARGS { long sys_pathconf(const char *path, int name); }
+192 NOARGS { long sys_fpathconf(int fd, int name); }
+193 NOARGS { int sys_swapctl(int cmd, const void *arg, int misc); }
+194 NOARGS { int sys_getrlimit(int which, \
+ struct rlimit *rlp); }
+195 NOARGS { int sys_setrlimit(int which, \
+ const struct rlimit *rlp); }
+196 NOARGS { int sys_getdirentries(int fd, char *buf, \
+ int count, long *basep); }
+197 NOARGS { void *sys_mmap(void *addr, size_t len, int prot, \
+ int flags, int fd, long pad, off_t pos); }
+198 INDIR { quad_t sys___syscall(quad_t num, ...); }
+199 NOARGS { off_t sys_lseek(int fd, int pad, off_t offset, \
+ int whence); }
+200 NOARGS { int sys_truncate(const char *path, int pad, \
+ off_t length); }
+201 NOARGS { int sys_ftruncate(int fd, int pad, off_t length); }
+202 NOARGS { int sys___sysctl(int *name, u_int namelen, \
+ void *old, size_t *oldlenp, void *new, \
+ size_t newlen); }
+203 NOARGS { int sys_mlock(const void *addr, size_t len); }
+204 NOARGS { int sys_munlock(const void *addr, size_t len); }
+205 NOARGS { int sys_undelete(const char *path); }
+206 NOARGS { int sys_futimes(int fd, \
+ const struct timeval *tptr); }
+207 NOARGS { int sys_getpgid(pid_t pid); }
+208 NOARGS { int sys_xfspioctl(int operation, char *a_pathP, \
+ int a_opcode, struct ViceIoctl *a_paramsP, \
+ int a_followSymlinks); }
+; XXX u_int nfds vs. unsigned long nfds
+209 NOARGS { int sys_poll(struct pollfd *fds, \
+ unsigned long nfds, int timeout); }
+;
+; Syscalls 210-219 are reserved for dynamically loaded syscalls
+;
+#ifdef LKM
+210 NODEF { int sys_lkmnosys(void); }
+211 NODEF { int sys_lkmnosys(void); }
+212 NODEF { int sys_lkmnosys(void); }
+213 NODEF { int sys_lkmnosys(void); }
+214 NODEF { int sys_lkmnosys(void); }
+215 NODEF { int sys_lkmnosys(void); }
+216 NODEF { int sys_lkmnosys(void); }
+217 NODEF { int sys_lkmnosys(void); }
+218 NODEF { int sys_lkmnosys(void); }
+219 NODEF { int sys_lkmnosys(void); }
+#else /* !LKM */
+210 UNIMPL
+211 UNIMPL
+212 UNIMPL
+213 UNIMPL
+214 UNIMPL
+215 UNIMPL
+216 UNIMPL
+217 UNIMPL
+218 UNIMPL
+219 UNIMPL
+#endif /* !LKM */
+; System calls 220-240 are reserved for use by OpenBSD
+#ifdef SYSVSEM
+220 NOARGS { int sys___osemctl(int semid, int semnum, int cmd, \
+ union semun *arg); }
+221 NOARGS { int sys_semget(key_t key, int nsems, int semflg); }
+222 NOARGS { int sys_semop(int semid, struct sembuf *sops, \
+ u_int nsops); }
+223 NOARGS { int sys_semconfig(int flag); }
+#else
+220 UNIMPL semctl
+221 UNIMPL semget
+222 UNIMPL semop
+223 UNIMPL semconfig
+#endif
+#ifdef SYSVMSG
+224 NOARGS { int sys_omsgctl(int msqid, int cmd, \
+ struct omsqid_ds *buf); }
+225 NOARGS { int sys_msgget(key_t key, int msgflg); }
+226 NOARGS { int sys_msgsnd(int msqid, const void *msgp, size_t msgsz, \
+ int msgflg); }
+227 NOARGS { int sys_msgrcv(int msqid, void *msgp, size_t msgsz, \
+ long msgtyp, int msgflg); }
+#else
+224 UNIMPL msgctl
+225 UNIMPL msgget
+226 UNIMPL msgsnd
+227 UNIMPL msgrcv
+#endif
+#ifdef SYSVSHM
+228 NOARGS { void *sys_shmat(int shmid, const void *shmaddr, \
+ int shmflg); }
+229 NOARGS { int sys_oshmctl(int shmid, int cmd, \
+ struct oshmid_ds *buf); }
+230 NOARGS { int sys_shmdt(const void *shmaddr); }
+231 NOARGS { int sys_shmget(key_t key, int size, int shmflg); }
+#else
+228 UNIMPL shmat
+229 UNIMPL shmctl
+230 UNIMPL shmdt
+231 UNIMPL shmget
+#endif
+232 NOARGS { int sys_clock_gettime(clockid_t clock_id, \
+ struct timespec *tp); }
+233 NOARGS { int sys_clock_settime(clockid_t clock_id, \
+ const struct timespec *tp); }
+234 NOARGS { int sys_clock_getres(clockid_t clock_id, \
+ struct timespec *tp); }
+235 UNIMPL timer_create
+236 UNIMPL timer_delete
+237 UNIMPL timer_settime
+238 UNIMPL timer_gettime
+239 UNIMPL timer_getoverrun
+;
+; System calls 240-249 are reserved for other IEEE Std1003.1b syscalls
+;
+240 NOARGS { int sys_nanosleep(const struct timespec *rqtp, \
+ struct timespec *rmtp); }
+241 UNIMPL
+;241 STD { int sys_fdatasync(int fd); }
+242 UNIMPL
+243 UNIMPL
+244 UNIMPL
+245 UNIMPL
+246 UNIMPL
+247 UNIMPL
+248 UNIMPL
+249 UNIMPL
+250 UNIMPL
+251 UNIMPL
+252 UNIMPL
+253 UNIMPL
+254 UNIMPL
+255 UNIMPL
+256 UNIMPL
+#ifdef SYSVSEM
+257 NOARGS { int sys___semctl(int semid, int semnum, int cmd, \
+ union semun *arg); }
+#else
+257 UNIMPL
+#endif
+#ifdef SYSVSHM
+258 NOARGS { int sys_shmctl(int shmid, int cmd, \
+ struct shmid_ds *buf); }
+#else
+258 UNIMPL
+#endif
+#ifdef SYSVMSG
+259 NOARGS { int sys_msgctl(int msqid, int cmd, \
+ struct msqid_ds *buf); }
+#else
+259 UNIMPL
+#endif
+260 UNIMPL
+261 UNIMPL
+262 UNIMPL
+263 UNIMPL
+264 UNIMPL
+265 UNIMPL
+266 UNIMPL
+267 UNIMPL
+268 UNIMPL
+269 UNIMPL
+270 UNIMPL
+;270 STD { int sys___posix_rename(const char *from, \
+; const char *to); }
+271 UNIMPL
+;271 STD { int sys_swapctl(int cmd, const void *arg, int misc); }
+272 UNIMPL
+;272 STD { int sys_getdents(int fd, char *buf, size_t count); }
+273 NOARGS { int sys_minherit(void *addr, size_t len, \
+ int inherit); }
+274 UNIMPL
+;274 STD { int sys_lchmod(const char *path, mode_t mode); }
+275 NOARGS { int sys_lchown(const char *path, uid_t uid, \
+ gid_t gid); }
+276 UNIMPL
+;276 STD { int sys_lutimes(const char *path, \
+; const struct timeval *tptr); }
+277 NOARGS { int sys_msync(void *addr, size_t len, int flags); }
+278 STD { int netbsd_sys___stat13(const char *path, \
+ struct netbsd_stat *ub); }
+279 STD { int netbsd_sys___fstat13(int fd, \
+ struct netbsd_stat *ub); }
+280 STD { int netbsd_sys___lstat13(const char *path, \
+ struct netbsd_stat *ub); }
+281 UNIMPL
+;281 STD { int sys___sigaltstack14( \
+; const struct sigaltstack *nss, \
+; struct sigaltstack *oss); }
+282 UNIMPL
+;282 STD { int sys___vfork14(void); }
+283 UNIMPL
+;283 STD { int sys___posix_chown(const char *path, uid_t uid, \
+; gid_t gid); }
+284 UNIMPL
+;284 STD { int sys___posix_fchown(int fd, uid_t uid, \
+; gid_t gid); }
+285 UNIMPL
+;285 STD { int sys___posix_lchown(const char *path, uid_t uid, \
+; gid_t gid); }
+286 NOARGS { int sys_getsid(pid_t pid); }
+287 UNIMPL
+#ifdef KTRACE
+288 UNIMPL
+;288 STD { int sys_fktrace(const int fd, int ops, \
+; int facs, int pid); }
+#else
+288 UNIMPL
+#endif
+289 UNIMPL
+;289 STD { ssize_t sys_preadv(int fd, \
+; const struct iovec *iovp, int iovcnt, \
+; int pad, off_t offset); }
+290 UNIMPL
+;290 STD { ssize_t sys_pwritev(int fd, \
+; const struct iovec *iovp, int iovcnt, \
+; int pad, off_t offset); }
+291 UNIMPL
+;291 STD { int netbsd_sys___sigaction14(int signum, \
+; const struct sigaction *nsa, \
+; struct sigaction *osa); }
+292 UNIMPL
+;292 STD { int sys___sigpending14(sigset_t *set); }
+293 UNIMPL
+;293 STD { int sys___sigprocmask14(int how, \
+; const sigset_t *set, \
+; sigset_t *oset); }
+294 UNIMPL
+;294 STD { int sys___sigsuspend14(const sigset_t *set); }
+295 UNIMPL
+;295 STD { int sys___sigreturn14(struct sigcontext *sigcntxp); }
+296 STD { int netbsd_sys___getcwd(char *bufp, size_t length); }
+297 UNIMPL
+;297 STD { int sys_fchroot(int fd); }