summaryrefslogtreecommitdiff
path: root/sys/compat
diff options
context:
space:
mode:
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/common/Makefile23
-rw-r--r--sys/compat/common/Makefile.inc37
-rw-r--r--sys/compat/common/compat_tty.c451
-rw-r--r--sys/compat/common/compat_util.c177
-rw-r--r--sys/compat/common/compat_util.h71
-rw-r--r--sys/compat/common/kern_exit_43.c113
-rw-r--r--sys/compat/common/kern_info_09.c130
-rw-r--r--sys/compat/common/kern_info_43.c228
-rw-r--r--sys/compat/common/kern_ipc_10.c243
-rw-r--r--sys/compat/common/kern_prot_43.c125
-rw-r--r--sys/compat/common/kern_resource_43.c102
-rw-r--r--sys/compat/common/kern_sig_43.c213
-rw-r--r--sys/compat/common/uipc_syscalls_43.c306
-rw-r--r--sys/compat/common/vfs_syscalls_43.c510
-rw-r--r--sys/compat/freebsd/Makefile13
-rw-r--r--sys/compat/freebsd/files.freebsd15
-rw-r--r--sys/compat/freebsd/freebsd_exec.c112
-rw-r--r--sys/compat/freebsd/freebsd_exec.h99
-rw-r--r--sys/compat/freebsd/freebsd_file.c598
-rw-r--r--sys/compat/freebsd/freebsd_ioctl.c66
-rw-r--r--sys/compat/freebsd/freebsd_ioctl.h37
-rw-r--r--sys/compat/freebsd/freebsd_misc.c101
-rw-r--r--sys/compat/freebsd/freebsd_ptrace.c158
-rw-r--r--sys/compat/freebsd/freebsd_ptrace.h67
-rw-r--r--sys/compat/freebsd/freebsd_rtprio.h62
-rw-r--r--sys/compat/freebsd/freebsd_syscall.h196
-rw-r--r--sys/compat/freebsd/freebsd_syscallargs.h409
-rw-r--r--sys/compat/freebsd/freebsd_syscalls.c268
-rw-r--r--sys/compat/freebsd/freebsd_sysent.c511
-rw-r--r--sys/compat/freebsd/freebsd_timex.h302
-rw-r--r--sys/compat/freebsd/freebsd_util.h53
-rw-r--r--sys/compat/freebsd/syscalls.conf12
-rw-r--r--sys/compat/freebsd/syscalls.master400
-rw-r--r--sys/compat/hpux/files.hpux14
-rw-r--r--sys/compat/hpux/hpux.h310
-rw-r--r--sys/compat/hpux/hpux_compat.c2164
-rw-r--r--sys/compat/hpux/hpux_exec.h63
-rw-r--r--sys/compat/hpux/hpux_net.c317
-rw-r--r--sys/compat/hpux/hpux_sig.c437
-rw-r--r--sys/compat/hpux/hpux_syscall.h151
-rw-r--r--sys/compat/hpux/hpux_syscallargs.h475
-rw-r--r--sys/compat/hpux/hpux_syscalls.c356
-rw-r--r--sys/compat/hpux/hpux_sysent.c702
-rw-r--r--sys/compat/hpux/hpux_termio.h192
-rw-r--r--sys/compat/hpux/hpux_tty.c548
-rw-r--r--sys/compat/hpux/hpux_util.h41
-rw-r--r--sys/compat/hpux/syscalls.conf12
-rw-r--r--sys/compat/hpux/syscalls.master439
-rw-r--r--sys/compat/ibcs2/TODO7
-rw-r--r--sys/compat/ibcs2/files.ibcs219
-rw-r--r--sys/compat/ibcs2/ibcs2_dirent.h52
-rw-r--r--sys/compat/ibcs2/ibcs2_errno.c118
-rw-r--r--sys/compat/ibcs2/ibcs2_errno.h153
-rw-r--r--sys/compat/ibcs2/ibcs2_exec.c728
-rw-r--r--sys/compat/ibcs2/ibcs2_exec.h285
-rw-r--r--sys/compat/ibcs2/ibcs2_fcntl.c322
-rw-r--r--sys/compat/ibcs2/ibcs2_fcntl.h76
-rw-r--r--sys/compat/ibcs2/ibcs2_grp.h43
-rw-r--r--sys/compat/ibcs2/ibcs2_ioctl.c504
-rw-r--r--sys/compat/ibcs2/ibcs2_ipc.c442
-rw-r--r--sys/compat/ibcs2/ibcs2_misc.c1398
-rw-r--r--sys/compat/ibcs2/ibcs2_mount.h41
-rw-r--r--sys/compat/ibcs2/ibcs2_pwd.h48
-rw-r--r--sys/compat/ibcs2/ibcs2_signal.c492
-rw-r--r--sys/compat/ibcs2/ibcs2_signal.h105
-rw-r--r--sys/compat/ibcs2/ibcs2_socksys.c131
-rw-r--r--sys/compat/ibcs2/ibcs2_socksys.h118
-rw-r--r--sys/compat/ibcs2/ibcs2_stat.c274
-rw-r--r--sys/compat/ibcs2/ibcs2_stat.h89
-rw-r--r--sys/compat/ibcs2/ibcs2_statfs.h48
-rw-r--r--sys/compat/ibcs2/ibcs2_stropts.h48
-rw-r--r--sys/compat/ibcs2/ibcs2_syscall.h97
-rw-r--r--sys/compat/ibcs2/ibcs2_syscallargs.h434
-rw-r--r--sys/compat/ibcs2/ibcs2_syscalls.c198
-rw-r--r--sys/compat/ibcs2/ibcs2_sysent.c409
-rw-r--r--sys/compat/ibcs2/ibcs2_termios.h235
-rw-r--r--sys/compat/ibcs2/ibcs2_time.h50
-rw-r--r--sys/compat/ibcs2/ibcs2_timeb.h45
-rw-r--r--sys/compat/ibcs2/ibcs2_types.h54
-rw-r--r--sys/compat/ibcs2/ibcs2_unistd.h75
-rw-r--r--sys/compat/ibcs2/ibcs2_ustat.h46
-rw-r--r--sys/compat/ibcs2/ibcs2_util.h52
-rw-r--r--sys/compat/ibcs2/ibcs2_utime.h41
-rw-r--r--sys/compat/ibcs2/ibcs2_utsname.h45
-rw-r--r--sys/compat/ibcs2/ibcs2_wait.h47
-rw-r--r--sys/compat/ibcs2/syscalls.conf12
-rw-r--r--sys/compat/ibcs2/syscalls.master258
-rw-r--r--sys/compat/linux/Makefile11
-rw-r--r--sys/compat/linux/files.linux18
-rw-r--r--sys/compat/linux/linux_dirent.h49
-rw-r--r--sys/compat/linux/linux_errno.h158
-rw-r--r--sys/compat/linux/linux_error.c177
-rw-r--r--sys/compat/linux/linux_exec.c502
-rw-r--r--sys/compat/linux/linux_exec.h74
-rw-r--r--sys/compat/linux/linux_fcntl.h90
-rw-r--r--sys/compat/linux/linux_file.c795
-rw-r--r--sys/compat/linux/linux_ioctl.c656
-rw-r--r--sys/compat/linux/linux_ioctl.h278
-rw-r--r--sys/compat/linux/linux_ipc.c707
-rw-r--r--sys/compat/linux/linux_ipc.h64
-rw-r--r--sys/compat/linux/linux_ipccall.h54
-rw-r--r--sys/compat/linux/linux_misc.c1105
-rw-r--r--sys/compat/linux/linux_mmap.h53
-rw-r--r--sys/compat/linux/linux_msg.h93
-rw-r--r--sys/compat/linux/linux_sem.h72
-rw-r--r--sys/compat/linux/linux_shm.h63
-rw-r--r--sys/compat/linux/linux_signal.c501
-rw-r--r--sys/compat/linux/linux_signal.h95
-rw-r--r--sys/compat/linux/linux_socket.c704
-rw-r--r--sys/compat/linux/linux_socket.h107
-rw-r--r--sys/compat/linux/linux_socketcall.h162
-rw-r--r--sys/compat/linux/linux_sockio.h40
-rw-r--r--sys/compat/linux/linux_syscall.h120
-rw-r--r--sys/compat/linux/linux_syscallargs.h433
-rw-r--r--sys/compat/linux/linux_syscalls.c165
-rw-r--r--sys/compat/linux/linux_sysent.c325
-rw-r--r--sys/compat/linux/linux_types.h151
-rw-r--r--sys/compat/linux/linux_util.h48
-rw-r--r--sys/compat/linux/syscalls.conf12
-rw-r--r--sys/compat/linux/syscalls.master235
-rw-r--r--sys/compat/osf1/Makefile11
-rw-r--r--sys/compat/osf1/README.dynamic77
-rw-r--r--sys/compat/osf1/README.mach-traps58
-rw-r--r--sys/compat/osf1/README.syscalls160
-rw-r--r--sys/compat/osf1/files.osf114
-rw-r--r--sys/compat/osf1/osf1_ioctl.c211
-rw-r--r--sys/compat/osf1/osf1_misc.c937
-rw-r--r--sys/compat/osf1/osf1_mount.c479
-rw-r--r--sys/compat/osf1/osf1_signal.c557
-rw-r--r--sys/compat/osf1/osf1_signal.h80
-rw-r--r--sys/compat/osf1/osf1_syscall.h115
-rw-r--r--sys/compat/osf1/osf1_syscallargs.h289
-rw-r--r--sys/compat/osf1/osf1_syscalls.c270
-rw-r--r--sys/compat/osf1/osf1_sysent.c541
-rw-r--r--sys/compat/osf1/osf1_util.h1
-rw-r--r--sys/compat/osf1/syscalls.conf12
-rw-r--r--sys/compat/osf1/syscalls.master338
-rw-r--r--sys/compat/sunos/exec.h48
-rw-r--r--sys/compat/sunos/files.sunos13
-rw-r--r--sys/compat/sunos/sunos.h143
-rw-r--r--sys/compat/sunos/sunos_dirent.h46
-rw-r--r--sys/compat/sunos/sunos_exec.c266
-rw-r--r--sys/compat/sunos/sunos_ioctl.c785
-rw-r--r--sys/compat/sunos/sunos_misc.c1279
-rw-r--r--sys/compat/sunos/sunos_syscall.h157
-rw-r--r--sys/compat/sunos/sunos_syscallargs.h362
-rw-r--r--sys/compat/sunos/sunos_syscalls.c220
-rw-r--r--sys/compat/sunos/sunos_sysent.c445
-rw-r--r--sys/compat/sunos/sunos_util.h41
-rw-r--r--sys/compat/sunos/syscalls.conf12
-rw-r--r--sys/compat/sunos/syscalls.master303
-rw-r--r--sys/compat/svr4/files.svr423
-rw-r--r--sys/compat/svr4/svr4_dirent.h45
-rw-r--r--sys/compat/svr4/svr4_errno.h171
-rw-r--r--sys/compat/svr4/svr4_error.c120
-rw-r--r--sys/compat/svr4/svr4_exec.c132
-rw-r--r--sys/compat/svr4/svr4_exec.h67
-rw-r--r--sys/compat/svr4/svr4_fcntl.c450
-rw-r--r--sys/compat/svr4/svr4_fcntl.h110
-rw-r--r--sys/compat/svr4/svr4_filio.c110
-rw-r--r--sys/compat/svr4/svr4_filio.h44
-rw-r--r--sys/compat/svr4/svr4_fuser.h53
-rw-r--r--sys/compat/svr4/svr4_hrt.h86
-rw-r--r--sys/compat/svr4/svr4_ioctl.c135
-rw-r--r--sys/compat/svr4/svr4_ioctl.h57
-rw-r--r--sys/compat/svr4/svr4_misc.c1199
-rw-r--r--sys/compat/svr4/svr4_net.c171
-rw-r--r--sys/compat/svr4/svr4_poll.h50
-rw-r--r--sys/compat/svr4/svr4_siginfo.h110
-rw-r--r--sys/compat/svr4/svr4_signal.c645
-rw-r--r--sys/compat/svr4/svr4_signal.h128
-rw-r--r--sys/compat/svr4/svr4_sockio.c144
-rw-r--r--sys/compat/svr4/svr4_sockio.h92
-rw-r--r--sys/compat/svr4/svr4_sockmod.h78
-rw-r--r--sys/compat/svr4/svr4_stat.c503
-rw-r--r--sys/compat/svr4/svr4_stat.h71
-rw-r--r--sys/compat/svr4/svr4_statvfs.h54
-rw-r--r--sys/compat/svr4/svr4_stream.c971
-rw-r--r--sys/compat/svr4/svr4_stropts.h126
-rw-r--r--sys/compat/svr4/svr4_syscall.h110
-rw-r--r--sys/compat/svr4/svr4_syscallargs.h369
-rw-r--r--sys/compat/svr4/svr4_syscalls.c208
-rw-r--r--sys/compat/svr4/svr4_sysconfig.h61
-rw-r--r--sys/compat/svr4/svr4_sysent.c430
-rw-r--r--sys/compat/svr4/svr4_systeminfo.h45
-rw-r--r--sys/compat/svr4/svr4_termios.c547
-rw-r--r--sys/compat/svr4/svr4_termios.h217
-rw-r--r--sys/compat/svr4/svr4_time.h36
-rw-r--r--sys/compat/svr4/svr4_timod.h60
-rw-r--r--sys/compat/svr4/svr4_ttold.c287
-rw-r--r--sys/compat/svr4/svr4_ttold.h121
-rw-r--r--sys/compat/svr4/svr4_types.h57
-rw-r--r--sys/compat/svr4/svr4_ucontext.h76
-rw-r--r--sys/compat/svr4/svr4_ulimit.h40
-rw-r--r--sys/compat/svr4/svr4_ustat.h42
-rw-r--r--sys/compat/svr4/svr4_util.h46
-rw-r--r--sys/compat/svr4/svr4_utsname.h44
-rw-r--r--sys/compat/svr4/svr4_wait.h55
-rw-r--r--sys/compat/svr4/syscalls.conf12
-rw-r--r--sys/compat/svr4/syscalls.master276
-rw-r--r--sys/compat/ultrix/files.ultrix11
-rw-r--r--sys/compat/ultrix/syscalls.conf12
-rw-r--r--sys/compat/ultrix/syscalls.master355
-rw-r--r--sys/compat/ultrix/ultrix_misc.c598
-rw-r--r--sys/compat/ultrix/ultrix_syscall.h156
-rw-r--r--sys/compat/ultrix/ultrix_syscallargs.h257
-rw-r--r--sys/compat/ultrix/ultrix_syscalls.c276
-rw-r--r--sys/compat/ultrix/ultrix_sysent.c565
208 files changed, 47769 insertions, 0 deletions
diff --git a/sys/compat/common/Makefile b/sys/compat/common/Makefile
new file mode 100644
index 00000000000..63bc7ec2d36
--- /dev/null
+++ b/sys/compat/common/Makefile
@@ -0,0 +1,23 @@
+# $NetBSD: Makefile,v 1.3 1995/06/28 03:00:20 cgd Exp $
+
+LIB= compat
+NOPIC=
+
+.PATH: ${COMPATREL}${COMPATDIR}
+
+CC= ${COMPATCC}
+CFLAGS+= ${COMPATCFLAGS:S@-I.@-I${COMPATREL}.@g}
+
+SRCS= compat_tty.c compat_util.c kern_exit_43.c kern_info_09.c \
+ kern_info_43.c kern_prot_43.c kern_resource_43.c kern_sig_43.c \
+ uipc_syscalls_43.c vfs_syscalls_43.c
+
+# really, all machines were sizeof(int) != sizeof(long)
+.if (${MACHINE_ARCH} != "alpha")
+SRCS+= kern_ipc_10.c
+.endif
+
+install:
+
+
+.include <bsd.lib.mk>
diff --git a/sys/compat/common/Makefile.inc b/sys/compat/common/Makefile.inc
new file mode 100644
index 00000000000..db613f2cb81
--- /dev/null
+++ b/sys/compat/common/Makefile.inc
@@ -0,0 +1,37 @@
+# $NetBSD: Makefile.inc,v 1.2 1995/06/26 03:27:15 christos Exp $
+#
+# NOTE: $S must correspond to the top of the 'sys' tree
+
+COMPATDIR= $S/compat/common
+
+COMPATDST?= lib/compat
+COMPATREL?= ../../
+COMPATLIB= ${COMPATDST}/libcompat.a
+COMPATLIB_PROF= ${COMPATDST}/libcompat_p.a
+
+${COMPATLIB}: .NOTMAIN __always_make_compatlib
+ @echo making sure the compat library is up to date...
+ @(cd ${COMPATDST} && ${MAKE} -f ${COMPATREL}${COMPATDIR}/Makefile \
+ COMPATCC="${CC}" \
+ COMPATCFLAGS="${CFLAGS}" \
+ COMPATREL="${COMPATREL}" \
+ COMPATDIR="${COMPATDIR}" libcompat.a)
+
+${COMPATLIB_PROF}: .NOTMAIN __always_make_compatlib
+ @echo making sure the profiled compat library is up to date...
+ @(cd ${COMPATDST} && ${MAKE} -f ${COMPATREL}${COMPATDIR}/Makefile \
+ COMPATCC="${CC}" \
+ COMPATCFLAGS="${CFLAGS}" \
+ COMPATREL="${COMPATREL}" \
+ COMPATDIR="${COMPATDIR}" libcompat_p.a)
+
+clean:: .NOTMAIN __always_make_compatlib
+ @echo cleaning the compat library objects
+ @(cd ${COMPATDST} && ${MAKE} -f ${COMPATREL}${COMPATDIR}/Makefile \
+ COMPATCC="${CC}" \
+ COMPATCFLAGS="${CFLAGS}" \
+ COMPATREL="${COMPATREL}" \
+ COMPATDIR="${COMPATDIR}" clean)
+
+__always_make_compatlib: .NOTMAIN
+ @([ -d ${COMPATDST} ] || mkdir -p ${COMPATDST})
diff --git a/sys/compat/common/compat_tty.c b/sys/compat/common/compat_tty.c
new file mode 100644
index 00000000000..485c21379f4
--- /dev/null
+++ b/sys/compat/common/compat_tty.c
@@ -0,0 +1,451 @@
+/* $NetBSD: compat_tty.c,v 1.1 1995/06/24 20:16:01 christos Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1991, 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.
+ *
+ * @(#)tty_compat.c 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * mapping routines for old line discipline (yuck)
+ */
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/ioctl.h>
+#include <sys/proc.h>
+#include <sys/tty.h>
+#include <sys/termios.h>
+#include <sys/file.h>
+#include <sys/conf.h>
+#include <sys/kernel.h>
+#include <sys/syslog.h>
+#include <sys/ioctl_compat.h>
+
+int ttydebug = 0;
+
+static struct speedtab compatspeeds[] = {
+#define MAX_SPEED 17
+ { 115200, 17 },
+ { 57600, 16 },
+ { 38400, 15 },
+ { 19200, 14 },
+ { 9600, 13 },
+ { 4800, 12 },
+ { 2400, 11 },
+ { 1800, 10 },
+ { 1200, 9 },
+ { 600, 8 },
+ { 300, 7 },
+ { 200, 6 },
+ { 150, 5 },
+ { 134, 4 },
+ { 110, 3 },
+ { 75, 2 },
+ { 50, 1 },
+ { 0, 0 },
+ { -1, -1 },
+};
+static int compatspcodes[] = {
+ 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
+ 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200
+};
+
+/*ARGSUSED*/
+ttcompat(tp, com, data, flag, p)
+ register struct tty *tp;
+ u_long com;
+ caddr_t data;
+ int flag;
+ struct proc *p;
+{
+
+ switch (com) {
+ case TIOCGETP: {
+ register struct sgttyb *sg = (struct sgttyb *)data;
+ register u_char *cc = tp->t_cc;
+ register speed;
+
+ speed = ttspeedtab(tp->t_ospeed, compatspeeds);
+ sg->sg_ospeed = (speed == -1) ? MAX_SPEED : speed;
+ if (tp->t_ispeed == 0)
+ sg->sg_ispeed = sg->sg_ospeed;
+ else {
+ speed = ttspeedtab(tp->t_ispeed, compatspeeds);
+ sg->sg_ispeed = (speed == -1) ? MAX_SPEED : speed;
+ }
+ sg->sg_erase = cc[VERASE];
+ sg->sg_kill = cc[VKILL];
+ sg->sg_flags = ttcompatgetflags(tp);
+ break;
+ }
+
+ case TIOCSETP:
+ case TIOCSETN: {
+ register struct sgttyb *sg = (struct sgttyb *)data;
+ struct termios term;
+ int speed;
+
+ term = tp->t_termios;
+ if ((speed = sg->sg_ispeed) > MAX_SPEED || speed < 0)
+ term.c_ispeed = speed;
+ else
+ term.c_ispeed = compatspcodes[speed];
+ if ((speed = sg->sg_ospeed) > MAX_SPEED || speed < 0)
+ term.c_ospeed = speed;
+ else
+ term.c_ospeed = compatspcodes[speed];
+ term.c_cc[VERASE] = sg->sg_erase;
+ term.c_cc[VKILL] = sg->sg_kill;
+ tp->t_flags = (ttcompatgetflags(tp)&0xffff0000) | (sg->sg_flags&0xffff);
+ ttcompatsetflags(tp, &term);
+ return (ttioctl(tp, com == TIOCSETP ? TIOCSETAF : TIOCSETA,
+ (caddr_t)&term, flag, p));
+ }
+
+ case TIOCGETC: {
+ struct tchars *tc = (struct tchars *)data;
+ register u_char *cc = tp->t_cc;
+
+ tc->t_intrc = cc[VINTR];
+ tc->t_quitc = cc[VQUIT];
+ tc->t_startc = cc[VSTART];
+ tc->t_stopc = cc[VSTOP];
+ tc->t_eofc = cc[VEOF];
+ tc->t_brkc = cc[VEOL];
+ break;
+ }
+ case TIOCSETC: {
+ struct tchars *tc = (struct tchars *)data;
+ register u_char *cc = tp->t_cc;
+
+ cc[VINTR] = tc->t_intrc;
+ cc[VQUIT] = tc->t_quitc;
+ cc[VSTART] = tc->t_startc;
+ cc[VSTOP] = tc->t_stopc;
+ cc[VEOF] = tc->t_eofc;
+ cc[VEOL] = tc->t_brkc;
+ if (tc->t_brkc == -1)
+ cc[VEOL2] = _POSIX_VDISABLE;
+ break;
+ }
+ case TIOCSLTC: {
+ struct ltchars *ltc = (struct ltchars *)data;
+ register u_char *cc = tp->t_cc;
+
+ cc[VSUSP] = ltc->t_suspc;
+ cc[VDSUSP] = ltc->t_dsuspc;
+ cc[VREPRINT] = ltc->t_rprntc;
+ cc[VDISCARD] = ltc->t_flushc;
+ cc[VWERASE] = ltc->t_werasc;
+ cc[VLNEXT] = ltc->t_lnextc;
+ break;
+ }
+ case TIOCGLTC: {
+ struct ltchars *ltc = (struct ltchars *)data;
+ register u_char *cc = tp->t_cc;
+
+ ltc->t_suspc = cc[VSUSP];
+ ltc->t_dsuspc = cc[VDSUSP];
+ ltc->t_rprntc = cc[VREPRINT];
+ ltc->t_flushc = cc[VDISCARD];
+ ltc->t_werasc = cc[VWERASE];
+ ltc->t_lnextc = cc[VLNEXT];
+ break;
+ }
+ case TIOCLBIS:
+ case TIOCLBIC:
+ case TIOCLSET: {
+ struct termios term;
+ long flags;
+
+ term = tp->t_termios;
+ flags = ttcompatgetflags(tp);
+ switch (com) {
+ case TIOCLSET:
+ tp->t_flags = (flags&0xffff) | (*(int *)data<<16);
+ break;
+ case TIOCLBIS:
+ tp->t_flags = flags | (*(int *)data<<16);
+ break;
+ case TIOCLBIC:
+ tp->t_flags = flags & ~(*(int *)data<<16);
+ break;
+ }
+ ttcompatsetlflags(tp, &term);
+ return (ttioctl(tp, TIOCSETA, (caddr_t)&term, flag, p));
+ }
+ case TIOCLGET:
+ *(int *)data = ttcompatgetflags(tp)>>16;
+ if (ttydebug)
+ printf("CLGET: returning %x\n", *(int *)data);
+ break;
+
+ case OTIOCGETD:
+ *(int *)data = tp->t_line ? tp->t_line : 2;
+ break;
+
+ case OTIOCSETD: {
+ int ldisczero = 0;
+
+ return (ttioctl(tp, TIOCSETD,
+ *(int *)data == 2 ? (caddr_t)&ldisczero : data, flag,
+ p));
+ }
+
+ case OTIOCCONS:
+ *(int *)data = 1;
+ return (ttioctl(tp, TIOCCONS, data, flag, p));
+
+ case TIOCHPCL:
+ tp->t_cflag |= HUPCL;
+ break;
+
+ case TIOCGSID:
+ if (tp->t_session == NULL)
+ return ENOTTY;
+
+ if (tp->t_session->s_leader == NULL)
+ return ENOTTY;
+
+ *(int *) data = tp->t_session->s_leader->p_pid;
+ break;
+
+ default:
+ return (-1);
+ }
+ return (0);
+}
+
+ttcompatgetflags(tp)
+ register struct tty *tp;
+{
+ register long iflag = tp->t_iflag;
+ register long lflag = tp->t_lflag;
+ register long oflag = tp->t_oflag;
+ register long cflag = tp->t_cflag;
+ register flags = 0;
+
+ if (iflag & IXOFF)
+ flags |= TANDEM;
+ if (iflag & ICRNL || oflag & ONLCR)
+ flags |= CRMOD;
+ if (cflag & PARENB) {
+ if (iflag & INPCK) {
+ if (cflag & PARODD)
+ flags |= ODDP;
+ else
+ flags |= EVENP;
+ } else
+ flags |= EVENP | ODDP;
+ } else {
+ if ((tp->t_flags & LITOUT) && !(oflag & OPOST))
+ flags |= LITOUT;
+ if (tp->t_flags & PASS8)
+ flags |= PASS8;
+ }
+
+ if ((lflag & ICANON) == 0) {
+ /* fudge */
+ if (iflag&IXON || lflag&ISIG || lflag&IEXTEN || cflag&PARENB)
+ flags |= CBREAK;
+ else
+ flags |= RAW;
+ }
+ if (cflag & MDMBUF)
+ flags |= MDMBUF;
+ if ((cflag & HUPCL) == 0)
+ flags |= NOHANG;
+ if (oflag & OXTABS)
+ flags |= XTABS;
+ if (lflag & ECHOE)
+ flags |= CRTERA|CRTBS;
+ if (lflag & ECHOKE)
+ flags |= CRTKIL|CRTBS;
+ if (lflag & ECHOPRT)
+ flags |= PRTERA;
+ if (lflag & ECHOCTL)
+ flags |= CTLECH;
+ if ((iflag & IXANY) == 0)
+ flags |= DECCTQ;
+ flags |= lflag & (ECHO|TOSTOP|FLUSHO|PENDIN|NOFLSH);
+ if (ttydebug)
+ printf("getflags: %x\n", flags);
+ return (flags);
+}
+
+ttcompatsetflags(tp, t)
+ register struct tty *tp;
+ register struct termios *t;
+{
+ register flags = tp->t_flags;
+ register long iflag = t->c_iflag;
+ register long oflag = t->c_oflag;
+ register long lflag = t->c_lflag;
+ register long cflag = t->c_cflag;
+
+ if (flags & TANDEM)
+ iflag |= IXOFF;
+ else
+ iflag &= ~IXOFF;
+ if (flags & ECHO)
+ lflag |= ECHO;
+ else
+ lflag &= ~ECHO;
+ if (flags & CRMOD) {
+ iflag |= ICRNL;
+ oflag |= ONLCR;
+ } else {
+ iflag &= ~ICRNL;
+ oflag &= ~ONLCR;
+ }
+ if (flags & XTABS)
+ oflag |= OXTABS;
+ else
+ oflag &= ~OXTABS;
+
+
+ if (flags & RAW) {
+ iflag &= IXOFF;
+ lflag &= ~(ISIG|ICANON|IEXTEN);
+ } else {
+ iflag |= BRKINT|IXON|IMAXBEL;
+ lflag |= ISIG|IEXTEN;
+ if (flags & CBREAK)
+ lflag &= ~ICANON;
+ else
+ lflag |= ICANON;
+ }
+
+ switch (flags & ANYP) {
+ case EVENP:
+ iflag |= INPCK;
+ cflag &= ~PARODD;
+ break;
+ case ODDP:
+ iflag |= INPCK;
+ cflag |= PARODD;
+ break;
+ default:
+ iflag &= ~INPCK;
+ break;
+ }
+
+ if (flags & (RAW|LITOUT|PASS8)) {
+ cflag &= ~(CSIZE|PARENB);
+ cflag |= CS8;
+ if ((flags & (RAW|PASS8)) == 0)
+ iflag |= ISTRIP;
+ else
+ iflag &= ~ISTRIP;
+ if ((flags & (RAW|LITOUT)) == 0)
+ oflag |= OPOST;
+ else
+ oflag &= ~OPOST;
+ } else {
+ cflag &= ~CSIZE;
+ cflag |= CS7|PARENB;
+ iflag |= ISTRIP;
+ oflag |= OPOST;
+ }
+
+ t->c_iflag = iflag;
+ t->c_oflag = oflag;
+ t->c_lflag = lflag;
+ t->c_cflag = cflag;
+}
+
+ttcompatsetlflags(tp, t)
+ register struct tty *tp;
+ register struct termios *t;
+{
+ register flags = tp->t_flags;
+ register long iflag = t->c_iflag;
+ register long oflag = t->c_oflag;
+ register long lflag = t->c_lflag;
+ register long cflag = t->c_cflag;
+
+ /* Nothing we can do with CRTBS. */
+ if (flags & PRTERA)
+ lflag |= ECHOPRT;
+ else
+ lflag &= ~ECHOPRT;
+ if (flags & CRTERA)
+ lflag |= ECHOE;
+ else
+ lflag &= ~ECHOE;
+ /* Nothing we can do with TILDE. */
+ if (flags & MDMBUF)
+ cflag |= MDMBUF;
+ else
+ cflag &= ~MDMBUF;
+ if (flags & NOHANG)
+ cflag &= ~HUPCL;
+ else
+ cflag |= HUPCL;
+ if (flags & CRTKIL)
+ lflag |= ECHOKE;
+ else
+ lflag &= ~ECHOKE;
+ if (flags & CTLECH)
+ lflag |= ECHOCTL;
+ else
+ lflag &= ~ECHOCTL;
+ if ((flags & DECCTQ) == 0)
+ iflag |= IXANY;
+ else
+ iflag &= ~IXANY;
+ lflag &= ~(TOSTOP|FLUSHO|PENDIN|NOFLSH);
+ lflag |= flags&(TOSTOP|FLUSHO|PENDIN|NOFLSH);
+
+ if (flags & (RAW|LITOUT|PASS8)) {
+ cflag &= ~(CSIZE|PARENB);
+ cflag |= CS8;
+ if ((flags & (RAW|PASS8)) == 0)
+ iflag |= ISTRIP;
+ else
+ iflag &= ~ISTRIP;
+ if ((flags & (RAW|LITOUT)) == 0)
+ oflag |= OPOST;
+ else
+ oflag &= ~OPOST;
+ } else {
+ cflag &= ~CSIZE;
+ cflag |= CS7|PARENB;
+ iflag |= ISTRIP;
+ oflag |= OPOST;
+ }
+
+ t->c_iflag = iflag;
+ t->c_oflag = oflag;
+ t->c_lflag = lflag;
+ t->c_cflag = cflag;
+}
diff --git a/sys/compat/common/compat_util.c b/sys/compat/common/compat_util.c
new file mode 100644
index 00000000000..0f42413ef00
--- /dev/null
+++ b/sys/compat/common/compat_util.c
@@ -0,0 +1,177 @@
+/* $NetBSD: compat_util.c,v 1.2 1995/06/26 19:27:17 christos 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.
+ *
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/vnode.h>
+
+#include <compat/common/compat_util.h>
+
+/*
+ * Search an alternate path before passing pathname arguments on
+ * to system calls. Useful for keeping a separate 'emulation tree'.
+ *
+ * If cflag is set, we check if an attempt can be made to create
+ * the named file, i.e. we check if the directory it should
+ * be in exists.
+ */
+int
+emul_find(p, sgp, prefix, path, pbuf, cflag)
+ struct proc *p;
+ caddr_t *sgp; /* Pointer to stackgap memory */
+ const char *prefix;
+ char *path;
+ char **pbuf;
+ int cflag;
+{
+ struct nameidata nd;
+ struct nameidata ndroot;
+ struct vattr vat;
+ struct vattr vatroot;
+ int error;
+ char *ptr, *buf, *cp;
+ const char *pr;
+ size_t sz, len;
+
+ buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
+ *pbuf = path;
+
+ for (ptr = buf, pr = prefix; (*ptr = *pr) != '\0'; ptr++, pr++)
+ continue;
+
+ sz = MAXPATHLEN - (ptr - buf);
+
+ /*
+ * If sgp is not given then the path is already in kernel space
+ */
+ if (sgp == NULL)
+ error = copystr(path, ptr, sz, &len);
+ else
+ error = copyinstr(path, ptr, sz, &len);
+
+ if (error) {
+ free(buf, M_TEMP);
+ return error;
+ }
+
+ if (*ptr != '/') {
+ free(buf, M_TEMP);
+ return EINVAL;
+ }
+
+ /*
+ * We know that there is a / somewhere in this pathname.
+ * Search backwards for it, to find the file's parent dir
+ * to see if it exists in the alternate tree. If it does,
+ * and we want to create a file (cflag is set). We don't
+ * need to worry about the root comparison in this case.
+ */
+
+ if (cflag) {
+ for (cp = &ptr[len] - 1; *cp != '/'; cp--);
+ *cp = '\0';
+
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p);
+
+ if ((error = namei(&nd)) != 0) {
+ free(buf, M_TEMP);
+ return error;
+ }
+
+ *cp = '/';
+ }
+ else {
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, buf, p);
+
+ if ((error = namei(&nd)) != 0) {
+ free(buf, M_TEMP);
+ return error;
+ }
+
+ /*
+ * We now compare the vnode of the emulation root to the one
+ * vnode asked. If they resolve to be the same, then we
+ * ignore the match so that the real root gets used.
+ * This avoids the problem of traversing "../.." to find the
+ * root directory and never finding it, because "/" resolves
+ * to the emulation root directory. This is expensive :-(
+ */
+ /* XXX: prototype should have const here for NDINIT */
+ NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE,
+ (char *) prefix, p);
+
+ if ((error = namei(&ndroot)) != 0) {
+ /* Cannot happen! */
+ free(buf, M_TEMP);
+ vrele(nd.ni_vp);
+ return error;
+ }
+
+ if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) {
+ goto done;
+ }
+
+ if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p))
+ != 0) {
+ goto done;
+ }
+
+ if (vat.va_fsid == vatroot.va_fsid &&
+ vat.va_fileid == vatroot.va_fileid) {
+ error = ENOENT;
+ goto done;
+ }
+
+ }
+ if (sgp == NULL)
+ *pbuf = buf;
+ else {
+ sz = &ptr[len] - buf;
+ *pbuf = stackgap_alloc(sgp, sz + 1);
+ error = copyout(buf, *pbuf, sz);
+ free(buf, M_TEMP);
+ }
+
+
+done:
+ vrele(nd.ni_vp);
+ if (!cflag)
+ vrele(ndroot.ni_vp);
+ return error;
+}
diff --git a/sys/compat/common/compat_util.h b/sys/compat/common/compat_util.h
new file mode 100644
index 00000000000..b1d1e96515c
--- /dev/null
+++ b/sys/compat/common/compat_util.h
@@ -0,0 +1,71 @@
+/* $NetBSD: compat_util.h,v 1.1 1995/06/24 20:16:05 christos 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.
+ *
+ */
+
+#ifndef _COMPAT_UTIL_H_
+#define _COMPAT_UTIL_H_
+
+#include <machine/vmparam.h>
+#include <sys/exec.h>
+#include <sys/cdefs.h>
+#include <sys/proc.h>
+
+static __inline caddr_t stackgap_init __P((struct emul *));
+static __inline void *stackgap_alloc __P((caddr_t *, size_t));
+
+static __inline caddr_t
+stackgap_init(e)
+ struct emul *e;
+{
+#define szsigcode ((caddr_t)(e->e_esigcode - e->e_sigcode))
+ return STACKGAPBASE;
+}
+
+
+static __inline void *
+stackgap_alloc(sgp, sz)
+ caddr_t *sgp;
+ size_t sz;
+{
+ void *p = (void *) *sgp;
+ *sgp += ALIGN(sz);
+ return p;
+}
+
+int emul_find __P((struct proc *, caddr_t *, const char *, char *,
+ char **, int));
+
+#define CHECK_ALT_EXIST(p, sgp, root, path) \
+ emul_find(p, sgp, root, path, &(path), 0)
+
+#define CHECK_ALT_CREAT(p, sgp, root, path) \
+ emul_find(p, sgp, root, path, &(path), 1)
+
+#endif /* !_COMPAT_UTIL_H_ */
diff --git a/sys/compat/common/kern_exit_43.c b/sys/compat/common/kern_exit_43.c
new file mode 100644
index 00000000000..cbfd9a84141
--- /dev/null
+++ b/sys/compat/common/kern_exit_43.c
@@ -0,0 +1,113 @@
+/* $NetBSD: kern_exit_43.c,v 1.3 1995/10/07 06:26:20 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1991, 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.
+ *
+ * @(#)kern_exit.c 8.7 (Berkeley) 2/12/94
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/map.h>
+#include <sys/ioctl.h>
+#include <sys/proc.h>
+#include <sys/tty.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/buf.h>
+#include <sys/wait.h>
+#include <sys/file.h>
+#include <sys/vnode.h>
+#include <sys/syslog.h>
+#include <sys/malloc.h>
+#include <sys/resourcevar.h>
+#include <sys/ptrace.h>
+#include <sys/acct.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <machine/cpu.h>
+#include <machine/reg.h>
+#include <machine/psl.h>
+#include <compat/common/compat_util.h>
+
+#include <vm/vm.h>
+#include <vm/vm_kern.h>
+#ifdef m68k
+#include <machine/frame.h>
+#define GETPS(rp) ((struct frame *)(rp))->f_sr
+#else
+#define GETPS(rp) (rp)[PS]
+#endif
+
+int
+compat_43_sys_wait(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ caddr_t sg = stackgap_init(p->p_emul);
+ int error;
+
+ struct sys_wait4_args /* {
+ syscallarg(int) pid;
+ syscallarg(int *) status;
+ syscallarg(int) options;
+ syscallarg(struct rusage *) rusage;
+ } */ a;
+
+#ifdef PSL_ALLCC
+ if ((GETPS(p->p_md.md_regs) & PSL_ALLCC) != PSL_ALLCC) {
+ SCARG(&a, options) = 0;
+ SCARG(&a, rusage) = NULL;
+ } else {
+ SCARG(&a, options) = p->p_md.md_regs[R0];
+ SCARG(&a, rusage) = (struct rusage *)p->p_md.md_regs[R1];
+ }
+#else
+ SCARG(&a, options) = 0;
+ SCARG(&a, rusage) = NULL;
+#endif
+ SCARG(&a, pid) = WAIT_ANY;
+ SCARG(&a, status) = stackgap_alloc(&sg, sizeof(SCARG(&a, status)));
+ if ((error = sys_wait4(p, &a, retval)) != 0)
+ return error;
+ return copyin(SCARG(&a, status), &retval[1], sizeof(retval[1]));
+}
diff --git a/sys/compat/common/kern_info_09.c b/sys/compat/common/kern_info_09.c
new file mode 100644
index 00000000000..0d04cae2475
--- /dev/null
+++ b/sys/compat/common/kern_info_09.c
@@ -0,0 +1,130 @@
+/* $NetBSD: kern_info_09.c,v 1.3 1995/10/07 06:26:23 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1991, 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.
+ *
+ * @(#)subr_xxx.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/syslog.h>
+#include <sys/unistd.h>
+#include <vm/vm.h>
+#include <sys/sysctl.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+/* ARGSUSED */
+int
+compat_09_sys_getdomainname(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_09_sys_getdomainname_args /* {
+ syscallarg(char *) domainname;
+ syscallarg(int) len;
+ } */ *uap = v;
+ int name;
+
+ name = KERN_DOMAINNAME;
+ return (kern_sysctl(&name, 1, SCARG(uap, domainname),
+ &SCARG(uap, len), 0, 0));
+}
+
+
+/* ARGSUSED */
+int
+compat_09_sys_setdomainname(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_09_sys_setdomainname_args /* {
+ syscallarg(char *) domainname;
+ syscallarg(int) len;
+ } */ *uap = v;
+ int name;
+ int error;
+
+ if (error = suser(p->p_ucred, &p->p_acflag))
+ return (error);
+ name = KERN_DOMAINNAME;
+ return (kern_sysctl(&name, 1, 0, 0, SCARG(uap, domainname),
+ SCARG(uap, len)));
+}
+
+struct outsname {
+ char sysname[32];
+ char nodename[32];
+ char release[32];
+ char version[32];
+ char machine[32];
+};
+
+/* ARGSUSED */
+int
+compat_09_sys_uname(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_09_sys_uname_args /* {
+ syscallarg(struct outsname *) name;
+ } */ *uap = v;
+ struct outsname outsname;
+ char *cp, *dp, *ep;
+ extern char ostype[], osrelease[];
+
+ strncpy(outsname.sysname, ostype, sizeof(outsname.sysname));
+ strncpy(outsname.nodename, hostname, sizeof(outsname.nodename));
+ strncpy(outsname.release, osrelease, sizeof(outsname.release));
+ dp = outsname.version;
+ ep = &outsname.version[sizeof(outsname.version) - 1];
+ for (cp = version; *cp && *cp != '('; cp++)
+ ;
+ for (cp++; *cp && *cp != ')' && dp < ep; cp++)
+ *dp++ = *cp;
+ for (; *cp && *cp != '#'; cp++)
+ ;
+ for (; *cp && *cp != ':' && dp < ep; cp++)
+ *dp++ = *cp;
+ *dp = '\0';
+ strncpy(outsname.machine, MACHINE, sizeof(outsname.machine));
+ return (copyout((caddr_t)&outsname, (caddr_t)SCARG(uap, name),
+ sizeof(struct outsname)));
+}
diff --git a/sys/compat/common/kern_info_43.c b/sys/compat/common/kern_info_43.c
new file mode 100644
index 00000000000..c9281661a45
--- /dev/null
+++ b/sys/compat/common/kern_info_43.c
@@ -0,0 +1,228 @@
+/* $NetBSD: kern_info_43.c,v 1.3 1995/10/07 06:26:24 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1991, 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.
+ *
+ * @(#)subr_xxx.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/vnode.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <sys/malloc.h>
+#include <sys/syslog.h>
+#include <sys/unistd.h>
+#include <sys/resourcevar.h>
+#include <vm/vm.h>
+#include <sys/sysctl.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+int
+compat_43_sys_getdtablesize(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+
+ *retval = min((int)p->p_rlimit[RLIMIT_NOFILE].rlim_cur, maxfiles);
+ return (0);
+}
+
+
+/* ARGSUSED */
+int
+compat_43_sys_gethostid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+
+ *(int32_t *)retval = hostid;
+ return (0);
+}
+
+
+/*ARGSUSED*/
+int
+compat_43_sys_gethostname(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_43_sys_gethostname_args /* {
+ syscallarg(char *) hostname;
+ syscallarg(u_int) len;
+ } */ *uap = v;
+ int name;
+
+ name = KERN_HOSTNAME;
+ return (kern_sysctl(&name, 1, SCARG(uap, hostname), &SCARG(uap, len),
+ 0, 0));
+}
+
+#define KINFO_PROC (0<<8)
+#define KINFO_RT (1<<8)
+#define KINFO_VNODE (2<<8)
+#define KINFO_FILE (3<<8)
+#define KINFO_METER (4<<8)
+#define KINFO_LOADAVG (5<<8)
+#define KINFO_CLOCKRATE (6<<8)
+
+int
+compat_43_sys_getkerninfo(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_getkerninfo_args /* {
+ syscallarg(int) op;
+ syscallarg(char *) where;
+ syscallarg(int *) size;
+ syscallarg(int) arg;
+ } */ *uap = v;
+ int error, name[5];
+ size_t size;
+
+ if (SCARG(uap, size) && (error = copyin((caddr_t)SCARG(uap, size),
+ (caddr_t)&size, sizeof(size))))
+ return (error);
+
+ switch (SCARG(uap, op) & 0xff00) {
+
+ case KINFO_RT:
+ name[0] = PF_ROUTE;
+ name[1] = 0;
+ name[2] = (SCARG(uap, op) & 0xff0000) >> 16;
+ name[3] = SCARG(uap, op) & 0xff;
+ name[4] = SCARG(uap, arg);
+ error =
+ net_sysctl(name, 5, SCARG(uap, where), &size, NULL, 0, p);
+ break;
+
+ case KINFO_VNODE:
+ name[0] = KERN_VNODE;
+ error =
+ kern_sysctl(name, 1, SCARG(uap, where), &size, NULL, 0, p);
+ break;
+
+ case KINFO_PROC:
+ name[0] = KERN_PROC;
+ name[1] = SCARG(uap, op) & 0xff;
+ name[2] = SCARG(uap, arg);
+ error =
+ kern_sysctl(name, 3, SCARG(uap, where), &size, NULL, 0, p);
+ break;
+
+ case KINFO_FILE:
+ name[0] = KERN_FILE;
+ error =
+ kern_sysctl(name, 1, SCARG(uap, where), &size, NULL, 0, p);
+ break;
+
+ case KINFO_METER:
+ name[0] = VM_METER;
+ error =
+ vm_sysctl(name, 1, SCARG(uap, where), &size, NULL, 0, p);
+ break;
+
+ case KINFO_LOADAVG:
+ name[0] = VM_LOADAVG;
+ error =
+ vm_sysctl(name, 1, SCARG(uap, where), &size, NULL, 0, p);
+ break;
+
+ case KINFO_CLOCKRATE:
+ name[0] = KERN_CLOCKRATE;
+ error =
+ kern_sysctl(name, 1, SCARG(uap, where), &size, NULL, 0, p);
+ break;
+
+ default:
+ return (EOPNOTSUPP);
+ }
+ if (error)
+ return (error);
+ *retval = size;
+ if (SCARG(uap, size))
+ error = copyout((caddr_t)&size, (caddr_t)SCARG(uap, size),
+ sizeof(size));
+ return (error);
+}
+
+
+/* ARGSUSED */
+int
+compat_43_sys_sethostid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_43_sys_sethostid_args /* {
+ syscallarg(int32_t) hostid;
+ } */ *uap = v;
+ int error;
+
+ if (error = suser(p->p_ucred, &p->p_acflag))
+ return (error);
+ hostid = SCARG(uap, hostid);
+ return (0);
+}
+
+
+/* ARGSUSED */
+int
+compat_43_sys_sethostname(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_43_sys_sethostname_args *uap = v;
+ int name;
+ int error;
+
+ if (error = suser(p->p_ucred, &p->p_acflag))
+ return (error);
+ name = KERN_HOSTNAME;
+ return (kern_sysctl(&name, 1, 0, 0, SCARG(uap, hostname),
+ SCARG(uap, len)));
+}
diff --git a/sys/compat/common/kern_ipc_10.c b/sys/compat/common/kern_ipc_10.c
new file mode 100644
index 00000000000..f0ad88f2c3c
--- /dev/null
+++ b/sys/compat/common/kern_ipc_10.c
@@ -0,0 +1,243 @@
+/* $NetBSD: kern_ipc_10.c,v 1.4 1995/10/07 06:26:25 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1994 Adam Glass and Charles Hannum. 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 Adam Glass and Charles
+ * Hannum.
+ * 4. The names of the authors may not be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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/kernel.h>
+#include <sys/proc.h>
+#include <sys/sem.h>
+#include <sys/malloc.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <vm/vm.h>
+#include <vm/vm_map.h>
+#include <vm/vm_map.h>
+#include <vm/vm_kern.h>
+
+#ifdef SYSVSEM
+int
+compat_10_sys_semsys(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_10_sys_semsys_args /* {
+ syscallarg(int) which;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(int) a4;
+ syscallarg(int) a5;
+ } */ *uap = v;
+ struct sys___semctl_args /* {
+ syscallarg(int) semid;
+ syscallarg(int) semnum;
+ syscallarg(int) cmd;
+ syscallarg(union semun *) arg;
+ } */ __semctl_args;
+ struct sys_semget_args /* {
+ syscallarg(key_t) key;
+ syscallarg(int) nsems;
+ syscallarg(int) semflg;
+ } */ semget_args;
+ struct sys_semop_args /* {
+ syscallarg(int) semid;
+ syscallarg(struct sembuf *) sops;
+ syscallarg(u_int) nsops;
+ } */ semop_args;
+ struct sys_semconfig_args /* {
+ syscallarg(int) flag;
+ } */ semconfig_args;
+
+ switch (SCARG(uap, which)) {
+ case 0: /* __semctl() */
+ SCARG(&__semctl_args, semid) = SCARG(uap, a2);
+ SCARG(&__semctl_args, semnum) = SCARG(uap, a3);
+ SCARG(&__semctl_args, cmd) = SCARG(uap, a4);
+ SCARG(&__semctl_args, arg) = (union semun *)SCARG(uap, a5);
+ return (sys___semctl(p, &__semctl_args, retval));
+
+ case 1: /* semget() */
+ SCARG(&semget_args, key) = SCARG(uap, a2);
+ SCARG(&semget_args, nsems) = SCARG(uap, a3);
+ SCARG(&semget_args, semflg) = SCARG(uap, a4);
+ return (sys_semget(p, &semget_args, retval));
+
+ case 2: /* semop() */
+ SCARG(&semop_args, semid) = SCARG(uap, a2);
+ SCARG(&semop_args, sops) = (struct sembuf *)SCARG(uap, a3);
+ SCARG(&semop_args, nsops) = SCARG(uap, a4);
+ return (sys_semop(p, &semop_args, retval));
+
+ case 3: /* semconfig() */
+ SCARG(&semconfig_args, flag) = SCARG(uap, a2);
+ return (sys_semconfig(p, &semconfig_args, retval));
+
+ default:
+ return (EINVAL);
+ }
+}
+#endif
+
+#ifdef SYSVSHM
+int
+compat_10_sys_shmsys(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_10_sys_shmsys_args /* {
+ syscallarg(int) which;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(int) a4;
+ } */ *uap = v;
+ struct sys_shmat_args /* {
+ syscallarg(int) shmid;
+ syscallarg(void *) shmaddr;
+ syscallarg(int) shmflg;
+ } */ shmat_args;
+ struct sys_shmctl_args /* {
+ syscallarg(int) shmid;
+ syscallarg(int) cmd;
+ syscallarg(struct shmid_ds *) buf;
+ } */ shmctl_args;
+ struct sys_shmdt_args /* {
+ syscallarg(void *) shmaddr;
+ } */ shmdt_args;
+ struct sys_shmget_args /* {
+ syscallarg(key_t) key;
+ syscallarg(int) size;
+ syscallarg(int) shmflg;
+ } */ shmget_args;
+
+ switch (SCARG(uap, which)) {
+ case 0: /* shmat() */
+ SCARG(&shmat_args, shmid) = SCARG(uap, a2);
+ SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a3);
+ SCARG(&shmat_args, shmflg) = SCARG(uap, a4);
+ return (sys_shmat(p, &shmat_args, retval));
+
+ case 1: /* shmctl() */
+ SCARG(&shmctl_args, shmid) = SCARG(uap, a2);
+ SCARG(&shmctl_args, cmd) = SCARG(uap, a3);
+ SCARG(&shmctl_args, buf) = (struct shmid_ds *)SCARG(uap, a4);
+ return (sys_shmctl(p, &shmctl_args, retval));
+
+ case 2: /* shmdt() */
+ SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a2);
+ return (sys_shmdt(p, &shmdt_args, retval));
+
+ case 3: /* shmget() */
+ SCARG(&shmget_args, key) = SCARG(uap, a2);
+ SCARG(&shmget_args, size) = SCARG(uap, a3);
+ SCARG(&shmget_args, shmflg) = SCARG(uap, a4);
+ return (sys_shmget(p, &shmget_args, retval));
+
+ default:
+ return (EINVAL);
+ }
+}
+#endif
+
+#ifdef SYSVMSG
+int
+compat_10_sys_msgsys(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_10_sys_msgsys_args /* {
+ syscallarg(int) which;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(int) a4;
+ syscallarg(int) a5;
+ syscallarg(int) a6;
+ } */ *uap = v;
+ struct sys_msgctl_args /* {
+ syscallarg(int) msqid;
+ syscallarg(int) cmd;
+ syscallarg(struct msqid_ds *) buf;
+ } */ msgctl_args;
+ struct sys_msgget_args /* {
+ syscallarg(key_t) key;
+ syscallarg(int) msgflg;
+ } */ msgget_args;
+ struct sys_msgsnd_args /* {
+ syscallarg(int) msqid;
+ syscallarg(void *) msgp;
+ syscallarg(size_t) msgsz;
+ syscallarg(int) msgflg;
+ } */ msgsnd_args;
+ struct sys_msgrcv_args /* {
+ syscallarg(int) msqid;
+ syscallarg(void *) msgp;
+ syscallarg(size_t) msgsz;
+ syscallarg(long) msgtyp;
+ syscallarg(int) msgflg;
+ } */ msgrcv_args;
+
+ switch (SCARG(uap, which)) {
+ case 0: /* msgctl()*/
+ SCARG(&msgctl_args, msqid) = SCARG(uap, a2);
+ SCARG(&msgctl_args, cmd) = SCARG(uap, a3);
+ SCARG(&msgctl_args, buf) =
+ (struct msqid_ds *)SCARG(uap, a4);
+ return (sys_msgctl(p, &msgctl_args, retval));
+
+ case 1: /* msgget() */
+ SCARG(&msgget_args, key) = SCARG(uap, a2);
+ SCARG(&msgget_args, msgflg) = SCARG(uap, a3);
+ return (sys_msgget(p, &msgget_args, retval));
+
+ case 2: /* msgsnd() */
+ SCARG(&msgsnd_args, msqid) = SCARG(uap, a2);
+ SCARG(&msgsnd_args, msgp) = (void *)SCARG(uap, a3);
+ SCARG(&msgsnd_args, msgsz) = SCARG(uap, a4);
+ SCARG(&msgsnd_args, msgflg) = SCARG(uap, a5);
+ return (sys_msgsnd(p, &msgsnd_args, retval));
+
+ case 3: /* msgrcv() */
+ SCARG(&msgrcv_args, msqid) = SCARG(uap, a2);
+ SCARG(&msgrcv_args, msgp) = (void *)SCARG(uap, a3);
+ SCARG(&msgrcv_args, msgsz) = SCARG(uap, a4);
+ SCARG(&msgrcv_args, msgtyp) = SCARG(uap, a5);
+ SCARG(&msgrcv_args, msgflg) = SCARG(uap, a6);
+ return (sys_msgrcv(p, &msgrcv_args, retval));
+
+ default:
+ return (EINVAL);
+ }
+}
+#endif
diff --git a/sys/compat/common/kern_prot_43.c b/sys/compat/common/kern_prot_43.c
new file mode 100644
index 00000000000..2bb328b9d7f
--- /dev/null
+++ b/sys/compat/common/kern_prot_43.c
@@ -0,0 +1,125 @@
+/* $NetBSD: kern_prot_43.c,v 1.3 1995/10/07 06:26:27 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1990, 1991, 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.
+ *
+ * @(#)kern_prot.c 8.6 (Berkeley) 1/21/94
+ */
+
+#include <sys/param.h>
+#include <sys/acct.h>
+#include <sys/systm.h>
+#include <sys/ucred.h>
+#include <sys/proc.h>
+#include <sys/timeb.h>
+#include <sys/times.h>
+#include <sys/malloc.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+/* ARGSUSED */
+int
+compat_43_sys_setregid(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_43_sys_setregid_args /* {
+ syscallarg(int) rgid;
+ syscallarg(int) egid;
+ } */ *uap = v;
+ struct sys_setegid_args segidargs;
+ struct sys_setgid_args sgidargs;
+
+ /*
+ * There are five cases, described above in osetreuid()
+ */
+ if (SCARG(uap, rgid) == (gid_t)-1) {
+ if (SCARG(uap, egid) == (gid_t)-1)
+ return (0); /* -1, -1 */
+ SCARG(&segidargs, egid) = SCARG(uap, egid); /* -1, N */
+ return (sys_setegid(p, &segidargs, retval));
+ }
+ if (SCARG(uap, egid) == (gid_t)-1) {
+ SCARG(&segidargs, egid) = SCARG(uap, rgid); /* N, -1 */
+ return (sys_setegid(p, &segidargs, retval));
+ }
+ SCARG(&sgidargs, gid) = SCARG(uap, rgid); /* N, N and N, M */
+ return (sys_setgid(p, &sgidargs, retval));
+}
+
+/* ARGSUSED */
+int
+compat_43_sys_setreuid(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_43_sys_setreuid_args /* {
+ syscallarg(int) ruid;
+ syscallarg(int) euid;
+ } */ *uap = v;
+ struct sys_seteuid_args seuidargs;
+ struct sys_setuid_args suidargs;
+
+ /*
+ * There are five cases, and we attempt to emulate them in
+ * the following fashion:
+ * -1, -1: return 0. This is correct emulation.
+ * -1, N: call seteuid(N). This is correct emulation.
+ * N, -1: if we called setuid(N), our euid would be changed
+ * to N as well. the theory is that we don't want to
+ * revoke root access yet, so we call seteuid(N)
+ * instead. This is incorrect emulation, but often
+ * suffices enough for binary compatibility.
+ * N, N: call setuid(N). This is correct emulation.
+ * N, M: call setuid(N). This is close to correct emulation.
+ */
+ if (SCARG(uap, ruid) == (uid_t)-1) {
+ if (SCARG(uap, euid) == (uid_t)-1)
+ return (0); /* -1, -1 */
+ SCARG(&seuidargs, euid) = SCARG(uap, euid); /* -1, N */
+ return (sys_seteuid(p, &seuidargs, retval));
+ }
+ if (SCARG(uap, euid) == (uid_t)-1) {
+ SCARG(&seuidargs, euid) = SCARG(uap, ruid); /* N, -1 */
+ return (sys_seteuid(p, &seuidargs, retval));
+ }
+ SCARG(&suidargs, uid) = SCARG(uap, ruid); /* N, N and N, M */
+ return (sys_setuid(p, &suidargs, retval));
+}
diff --git a/sys/compat/common/kern_resource_43.c b/sys/compat/common/kern_resource_43.c
new file mode 100644
index 00000000000..1fc2bdbb19f
--- /dev/null
+++ b/sys/compat/common/kern_resource_43.c
@@ -0,0 +1,102 @@
+/* $NetBSD: kern_resource_43.c,v 1.3 1995/10/07 06:26:28 mycroft Exp $ */
+
+/*-
+ * Copyright (c) 1982, 1986, 1991, 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.
+ *
+ * @(#)kern_resource.c 8.5 (Berkeley) 1/21/94
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/file.h>
+#include <sys/resourcevar.h>
+#include <sys/malloc.h>
+#include <sys/proc.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <vm/vm.h>
+
+/* ARGSUSED */
+int
+compat_43_sys_getrlimit(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_getrlimit_args /* {
+ syscallarg(u_int) which;
+ syscallarg(struct ogetrlimit *) rlp;
+ } */ *uap = v;
+ struct orlimit olim;
+
+ if (SCARG(uap, which) >= RLIM_NLIMITS)
+ return (EINVAL);
+ olim.rlim_cur = p->p_rlimit[SCARG(uap, which)].rlim_cur;
+ if (olim.rlim_cur == -1)
+ olim.rlim_cur = 0x7fffffff;
+ olim.rlim_max = p->p_rlimit[SCARG(uap, which)].rlim_max;
+ if (olim.rlim_max == -1)
+ olim.rlim_max = 0x7fffffff;
+ return (copyout((caddr_t)&olim, (caddr_t)SCARG(uap, rlp),
+ sizeof(olim)));
+}
+
+/* ARGSUSED */
+int
+compat_43_sys_setrlimit(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_43_sys_setrlimit_args /* {
+ syscallarg(u_int) which;
+ syscallarg(struct ogetrlimit *) rlp;
+ } */ *uap = v;
+ struct orlimit olim;
+ struct rlimit lim;
+ int error;
+
+ if (error = copyin((caddr_t)SCARG(uap, rlp), (caddr_t)&olim,
+ sizeof (struct orlimit)))
+ return (error);
+ lim.rlim_cur = olim.rlim_cur;
+ lim.rlim_max = olim.rlim_max;
+ return (dosetrlimit(p, SCARG(uap, which), &lim));
+}
diff --git a/sys/compat/common/kern_sig_43.c b/sys/compat/common/kern_sig_43.c
new file mode 100644
index 00000000000..f11be5dcd89
--- /dev/null
+++ b/sys/compat/common/kern_sig_43.c
@@ -0,0 +1,213 @@
+/* $NetBSD: kern_sig_43.c,v 1.5 1995/10/07 06:26:29 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1991, 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.
+ *
+ * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94
+ */
+
+#include <sys/param.h>
+#include <sys/signalvar.h>
+#include <sys/resourcevar.h>
+#include <sys/namei.h>
+#include <sys/vnode.h>
+#include <sys/proc.h>
+#include <sys/systm.h>
+#include <sys/timeb.h>
+#include <sys/times.h>
+#include <sys/buf.h>
+#include <sys/acct.h>
+#include <sys/file.h>
+#include <sys/kernel.h>
+#include <sys/wait.h>
+#include <sys/ktrace.h>
+#include <sys/syslog.h>
+#include <sys/stat.h>
+#include <sys/core.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <machine/cpu.h>
+
+#include <vm/vm.h>
+#include <sys/user.h> /* for coredump */
+
+int
+compat_43_sys_sigblock(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_43_sys_sigblock_args /* {
+ syscallarg(int) mask;
+ } */ *uap = v;
+
+ (void) splhigh();
+ *retval = p->p_sigmask;
+ p->p_sigmask |= SCARG(uap, mask) &~ sigcantmask;
+ (void) spl0();
+ return (0);
+}
+
+
+int
+compat_43_sys_sigsetmask(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_43_sys_sigsetmask_args /* {
+ syscallarg(int) mask;
+ } */ *uap = v;
+
+ (void) splhigh();
+ *retval = p->p_sigmask;
+ p->p_sigmask = SCARG(uap, mask) &~ sigcantmask;
+ (void) spl0();
+ return (0);
+}
+
+
+/* ARGSUSED */
+int
+compat_43_sys_sigstack(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_sigstack_args /* {
+ syscallarg(struct sigstack *) nss;
+ syscallarg(struct sigstack *) oss;
+ } */ *uap = v;
+ struct sigstack ss;
+ struct sigacts *psp;
+ int error = 0;
+
+ psp = p->p_sigacts;
+ ss.ss_sp = psp->ps_sigstk.ss_base;
+ ss.ss_onstack = psp->ps_sigstk.ss_flags & SS_ONSTACK;
+ if (SCARG(uap, oss) && (error = copyout((caddr_t)&ss,
+ (caddr_t)SCARG(uap, oss), sizeof (struct sigstack))))
+ return (error);
+ if (SCARG(uap, nss) == 0)
+ return (0);
+ if (error = copyin((caddr_t)SCARG(uap, nss), (caddr_t)&ss,
+ sizeof (ss)))
+ return (error);
+ psp->ps_flags |= SAS_ALTSTACK;
+ psp->ps_sigstk.ss_base = ss.ss_sp;
+ psp->ps_sigstk.ss_size = 0;
+ psp->ps_sigstk.ss_flags |= ss.ss_onstack & SS_ONSTACK;
+ return (0);
+}
+
+/*
+ * Generalized interface signal handler, 4.3-compatible.
+ */
+/* ARGSUSED */
+int
+compat_43_sys_sigvec(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_sigvec_args /* {
+ syscallarg(int) signum;
+ syscallarg(struct sigvec *) nsv;
+ syscallarg(struct sigvec *) osv;
+ } */ *uap = v;
+ struct sigvec vec;
+ register struct sigacts *ps = p->p_sigacts;
+ register struct sigvec *sv;
+ register int signum;
+ int bit, error;
+
+ signum = SCARG(uap, signum);
+ if (signum <= 0 || signum >= NSIG ||
+ signum == SIGKILL || signum == SIGSTOP)
+ return (EINVAL);
+ sv = &vec;
+ if (SCARG(uap, osv)) {
+ *(sig_t *)&sv->sv_handler = ps->ps_sigact[signum];
+ sv->sv_mask = ps->ps_catchmask[signum];
+ bit = sigmask(signum);
+ sv->sv_flags = 0;
+ if ((ps->ps_sigonstack & bit) != 0)
+ sv->sv_flags |= SV_ONSTACK;
+ if ((ps->ps_sigintr & bit) != 0)
+ sv->sv_flags |= SV_INTERRUPT;
+ if ((ps->ps_sigreset & bit) != 0)
+ sv->sv_flags |= SV_RESETHAND;
+ if (p->p_flag & P_NOCLDSTOP)
+ sv->sv_flags |= SA_NOCLDSTOP;
+ sv->sv_mask &= ~bit;
+ if (error = copyout((caddr_t)sv, (caddr_t)SCARG(uap, osv),
+ sizeof (vec)))
+ return (error);
+ }
+ if (SCARG(uap, nsv)) {
+ if (error = copyin((caddr_t)SCARG(uap, nsv), (caddr_t)sv,
+ sizeof (vec)))
+ return (error);
+ sv->sv_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */
+ setsigvec(p, signum, (struct sigaction *)sv);
+ }
+ return (0);
+}
+
+
+/* ARGSUSED */
+int
+compat_43_sys_killpg(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_killpg_args /* {
+ syscallarg(int) pgid;
+ syscallarg(int) signum;
+ } */ *uap = v;
+
+#ifdef COMPAT_09
+ SCARG(uap, pgid) = (short) SCARG(uap, pgid);
+#endif
+
+ if ((u_int)SCARG(uap, signum) >= NSIG)
+ return (EINVAL);
+ return (killpg1(p, SCARG(uap, signum), SCARG(uap, pgid), 0));
+}
diff --git a/sys/compat/common/uipc_syscalls_43.c b/sys/compat/common/uipc_syscalls_43.c
new file mode 100644
index 00000000000..941253de46d
--- /dev/null
+++ b/sys/compat/common/uipc_syscalls_43.c
@@ -0,0 +1,306 @@
+/* $NetBSD: uipc_syscalls_43.c,v 1.3 1995/10/07 06:26:30 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1990, 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.
+ *
+ * @(#)uipc_syscalls.c 8.4 (Berkeley) 2/21/94
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <sys/malloc.h>
+#include <sys/syslog.h>
+#include <sys/unistd.h>
+#include <sys/resourcevar.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#define MSG_COMPAT 0x8000 /* XXX */
+
+int
+compat_43_sys_accept(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sys_accept_args /* {
+ syscallarg(int) s;
+ syscallarg(caddr_t) name;
+ syscallarg(int *) anamelen;
+ } */ *uap = v;
+ int error;
+
+ if ((error = sys_accept(p, uap, retval)) != 0)
+ return error;
+
+ if (SCARG(uap, name)) {
+ struct sockaddr sa;
+
+ if ((error = copyin(SCARG(uap, name), &sa, sizeof(sa))) != 0)
+ return error;
+
+ ((struct osockaddr*) &sa)->sa_family = sa.sa_family;
+
+ if ((error = copyout(&sa, SCARG(uap, name), sizeof(sa))) != 0)
+ return error;
+ }
+ return 0;
+}
+
+
+int
+compat_43_sys_getpeername(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sys_getpeername_args /* {
+ syscallarg(int) fdes;
+ syscallarg(caddr_t) asa;
+ syscallarg(int *) alen;
+ } */ *uap = v;
+ struct sockaddr sa;
+
+ int error;
+
+ if ((error = sys_getpeername(p, uap, retval)) != 0)
+ return error;
+
+ if ((error = copyin(SCARG(uap, asa), &sa, sizeof(sa))) != 0)
+ return error;
+
+ ((struct osockaddr*) &sa)->sa_family = sa.sa_family;
+
+ if ((error = copyout(&sa, SCARG(uap, asa), sizeof(sa))) != 0)
+ return error;
+
+ return 0;
+}
+
+
+int
+compat_43_sys_getsockname(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sys_getsockname_args /* {
+ syscallarg(int) fdes;
+ syscallarg(caddr_t) asa;
+ syscallarg(int *) alen;
+ } */ *uap = v;
+ struct sockaddr sa;
+ int error;
+
+ if ((error = sys_getsockname(p, uap, retval)) != 0)
+ return error;
+
+ if ((error = copyin(SCARG(uap, asa), &sa, sizeof(sa))) != 0)
+ return error;
+
+ ((struct osockaddr*) &sa)->sa_family = sa.sa_family;
+
+ if ((error = copyout(&sa, SCARG(uap, asa), sizeof(sa))) != 0)
+ return error;
+
+ return 0;
+}
+
+
+int
+compat_43_sys_recv(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_recv_args /* {
+ syscallarg(int) s;
+ syscallarg(caddr_t) buf;
+ syscallarg(int) len;
+ syscallarg(int) flags;
+ } */ *uap = v;
+ struct msghdr msg;
+ struct iovec aiov;
+
+ msg.msg_name = 0;
+ msg.msg_namelen = 0;
+ msg.msg_iov = &aiov;
+ msg.msg_iovlen = 1;
+ aiov.iov_base = SCARG(uap, buf);
+ aiov.iov_len = SCARG(uap, len);
+ msg.msg_control = 0;
+ msg.msg_flags = SCARG(uap, flags);
+ return (recvit(p, SCARG(uap, s), &msg, (caddr_t)0, retval));
+}
+
+
+int
+compat_43_sys_recvfrom(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sys_recvfrom_args /* {
+ syscallarg(int) s;
+ syscallarg(caddr_t) buf;
+ syscallarg(size_t) len;
+ syscallarg(int) flags;
+ syscallarg(caddr_t) from;
+ syscallarg(int *) fromlenaddr;
+ } */ *uap = v;
+
+ SCARG(uap, flags) |= MSG_COMPAT;
+ return (sys_recvfrom(p, uap, retval));
+}
+
+
+/*
+ * Old recvmsg. This code takes advantage of the fact that the old msghdr
+ * overlays the new one, missing only the flags, and with the (old) access
+ * rights where the control fields are now.
+ */
+int
+compat_43_sys_recvmsg(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_recvmsg_args /* {
+ syscallarg(int) s;
+ syscallarg(struct omsghdr *) msg;
+ syscallarg(int) flags;
+ } */ *uap = v;
+ struct msghdr msg;
+ struct iovec aiov[UIO_SMALLIOV], *iov;
+ int error;
+
+ if (error = copyin((caddr_t)SCARG(uap, msg), (caddr_t)&msg,
+ sizeof (struct omsghdr)))
+ return (error);
+ if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
+ if ((u_int)msg.msg_iovlen >= UIO_MAXIOV)
+ return (EMSGSIZE);
+ MALLOC(iov, struct iovec *,
+ sizeof(struct iovec) * (u_int)msg.msg_iovlen, M_IOV,
+ M_WAITOK);
+ } else
+ iov = aiov;
+ msg.msg_flags = SCARG(uap, flags) | MSG_COMPAT;
+ if (error = copyin((caddr_t)msg.msg_iov, (caddr_t)iov,
+ (unsigned)(msg.msg_iovlen * sizeof (struct iovec))))
+ goto done;
+ msg.msg_iov = iov;
+ error = recvit(p, SCARG(uap, s), &msg,
+ (caddr_t)&SCARG(uap, msg)->msg_namelen, retval);
+
+ if (msg.msg_controllen && error == 0)
+ error = copyout((caddr_t)&msg.msg_controllen,
+ (caddr_t)&SCARG(uap, msg)->msg_accrightslen, sizeof (int));
+done:
+ if (iov != aiov)
+ FREE(iov, M_IOV);
+ return (error);
+}
+
+int
+compat_43_sys_send(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_send_args /* {
+ syscallarg(int) s;
+ syscallarg(caddr_t) buf;
+ syscallarg(int) len;
+ syscallarg(int) flags;
+ } */ *uap = v;
+ struct msghdr msg;
+ struct iovec aiov;
+
+ msg.msg_name = 0;
+ msg.msg_namelen = 0;
+ msg.msg_iov = &aiov;
+ msg.msg_iovlen = 1;
+ aiov.iov_base = SCARG(uap, buf);
+ aiov.iov_len = SCARG(uap, len);
+ msg.msg_control = 0;
+ msg.msg_flags = 0;
+ return (sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval));
+}
+
+int
+compat_43_sys_sendmsg(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_sendmsg_args /* {
+ syscallarg(int) s;
+ syscallarg(caddr_t) msg;
+ syscallarg(int) flags;
+ } */ *uap = v;
+ struct msghdr msg;
+ struct iovec aiov[UIO_SMALLIOV], *iov;
+ int error;
+
+ if (error = copyin(SCARG(uap, msg), (caddr_t)&msg,
+ sizeof (struct omsghdr)))
+ return (error);
+ if ((u_int)msg.msg_iovlen >= UIO_SMALLIOV) {
+ if ((u_int)msg.msg_iovlen >= UIO_MAXIOV)
+ return (EMSGSIZE);
+ MALLOC(iov, struct iovec *,
+ sizeof(struct iovec) * (u_int)msg.msg_iovlen, M_IOV,
+ M_WAITOK);
+ } else
+ iov = aiov;
+ if (error = copyin((caddr_t)msg.msg_iov, (caddr_t)iov,
+ (unsigned)(msg.msg_iovlen * sizeof (struct iovec))))
+ goto done;
+ msg.msg_flags = MSG_COMPAT;
+ msg.msg_iov = iov;
+ error = sendit(p, SCARG(uap, s), &msg, SCARG(uap, flags), retval);
+done:
+ if (iov != aiov)
+ FREE(iov, M_IOV);
+ return (error);
+}
diff --git a/sys/compat/common/vfs_syscalls_43.c b/sys/compat/common/vfs_syscalls_43.c
new file mode 100644
index 00000000000..b834a9eda84
--- /dev/null
+++ b/sys/compat/common/vfs_syscalls_43.c
@@ -0,0 +1,510 @@
+/* $NetBSD: vfs_syscalls_43.c,v 1.3 1995/10/07 06:26:31 mycroft 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.28 (Berkeley) 12/10/94
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/vnode.h>
+#include <sys/namei.h>
+#include <sys/dirent.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <sys/malloc.h>
+#include <sys/syslog.h>
+#include <sys/unistd.h>
+#include <sys/resourcevar.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+/*
+ * Convert from an old to a new stat structure.
+ */
+static int
+cvtstat(st, ost)
+ struct stat *st;
+ struct ostat *ost;
+{
+
+ ost->st_dev = st->st_dev;
+ ost->st_ino = st->st_ino;
+ ost->st_mode = st->st_mode;
+ ost->st_nlink = st->st_nlink;
+ ost->st_uid = st->st_uid;
+ ost->st_gid = st->st_gid;
+ ost->st_rdev = st->st_rdev;
+ if (st->st_size < (quad_t)1 << 32)
+ ost->st_size = st->st_size;
+ else
+ ost->st_size = -2;
+ ost->st_atime = st->st_atime;
+ ost->st_mtime = st->st_mtime;
+ ost->st_ctime = st->st_ctime;
+ ost->st_blksize = st->st_blksize;
+ ost->st_blocks = st->st_blocks;
+ ost->st_flags = st->st_flags;
+ ost->st_gen = st->st_gen;
+}
+
+/*
+ * Get file status; this version follows links.
+ */
+/* ARGSUSED */
+int
+compat_43_sys_stat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_stat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct ostat *) ub;
+ } */ *uap = v;
+ struct stat sb;
+ struct ostat osb;
+ int error;
+ struct nameidata nd;
+
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
+ SCARG(uap, path), p);
+ if (error = namei(&nd))
+ return (error);
+ error = vn_stat(nd.ni_vp, &sb, p);
+ vput(nd.ni_vp);
+ if (error)
+ return (error);
+ cvtstat(&sb, &osb);
+ error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb));
+ return (error);
+}
+
+
+/*
+ * Get file status; this version does not follow links.
+ */
+/* ARGSUSED */
+int
+compat_43_sys_lstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_lstat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct ostat *) ub;
+ } */ *uap = v;
+ struct vnode *vp, *dvp;
+ struct stat sb, sb1;
+ struct ostat osb;
+ int error;
+ struct nameidata nd;
+
+ NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKPARENT, UIO_USERSPACE,
+ SCARG(uap, path), p);
+ if (error = namei(&nd))
+ return (error);
+ /*
+ * For symbolic links, always return the attributes of its
+ * containing directory, except for mode, size, and links.
+ */
+ vp = nd.ni_vp;
+ dvp = nd.ni_dvp;
+ if (vp->v_type != VLNK) {
+ if (dvp == vp)
+ vrele(dvp);
+ else
+ vput(dvp);
+ error = vn_stat(vp, &sb, p);
+ vput(vp);
+ if (error)
+ return (error);
+ } else {
+ error = vn_stat(dvp, &sb, p);
+ vput(dvp);
+ if (error) {
+ vput(vp);
+ return (error);
+ }
+ error = vn_stat(vp, &sb1, p);
+ vput(vp);
+ if (error)
+ return (error);
+ sb.st_mode &= ~S_IFDIR;
+ sb.st_mode |= S_IFLNK;
+ sb.st_nlink = sb1.st_nlink;
+ sb.st_size = sb1.st_size;
+ sb.st_blocks = sb1.st_blocks;
+ }
+ cvtstat(&sb, &osb);
+ error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb));
+ return (error);
+}
+
+
+/*
+ * Return status information about a file descriptor.
+ */
+/* ARGSUSED */
+compat_43_sys_fstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_fstat_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct ostat *) sb;
+ } */ *uap = v;
+ int fd = SCARG(uap, fd);
+ register struct filedesc *fdp = p->p_fd;
+ register struct file *fp;
+ struct stat ub;
+ struct ostat oub;
+ 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, &ub, p);
+ break;
+
+ case DTYPE_SOCKET:
+ error = soo_stat((struct socket *)fp->f_data, &ub);
+ break;
+
+ default:
+ panic("ofstat");
+ /*NOTREACHED*/
+ }
+ cvtstat(&ub, &oub);
+ if (error == 0)
+ error = copyout((caddr_t)&oub, (caddr_t)SCARG(uap, sb),
+ sizeof (oub));
+ return (error);
+}
+
+
+/*
+ * Truncate a file given a file descriptor.
+ */
+/* ARGSUSED */
+int
+compat_43_sys_ftruncate(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_ftruncate_args /* {
+ syscallarg(int) fd;
+ syscallarg(long) length;
+ } */ *uap = v;
+ struct sys_ftruncate_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) pad;
+ syscallarg(off_t) length;
+ } */ nuap;
+
+ SCARG(&nuap, fd) = SCARG(uap, fd);
+ SCARG(&nuap, length) = SCARG(uap, length);
+ return (sys_ftruncate(p, &nuap, retval));
+}
+
+/*
+ * Truncate a file given its path name.
+ */
+/* ARGSUSED */
+int
+compat_43_sys_truncate(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_truncate_args /* {
+ syscallarg(char *) path;
+ syscallarg(long) length;
+ } */ *uap = v;
+ struct sys_truncate_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) pad;
+ syscallarg(off_t) length;
+ } */ nuap;
+
+ SCARG(&nuap, path) = SCARG(uap, path);
+ SCARG(&nuap, length) = SCARG(uap, length);
+ return (sys_truncate(p, &nuap, retval));
+}
+
+
+/*
+ * Reposition read/write file offset.
+ */
+int
+compat_43_sys_lseek(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_lseek_args /* {
+ syscallarg(int) fd;
+ syscallarg(long) offset;
+ syscallarg(int) whence;
+ } */ *uap = v;
+ struct sys_lseek_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) pad;
+ syscallarg(off_t) offset;
+ syscallarg(int) whence;
+ } */ nuap;
+ off_t qret;
+ int error;
+
+ SCARG(&nuap, fd) = SCARG(uap, fd);
+ SCARG(&nuap, offset) = SCARG(uap, offset);
+ SCARG(&nuap, whence) = SCARG(uap, whence);
+ error = sys_lseek(p, &nuap, (register_t *)&qret);
+ *(long *)retval = qret;
+ return (error);
+}
+
+
+/*
+ * Create a file.
+ */
+int
+compat_43_sys_creat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_creat_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ struct sys_open_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+ } */ nuap;
+
+ SCARG(&nuap, path) = SCARG(uap, path);
+ SCARG(&nuap, mode) = SCARG(uap, mode);
+ SCARG(&nuap, flags) = O_WRONLY | O_CREAT | O_TRUNC;
+ return (sys_open(p, &nuap, retval));
+}
+
+/*ARGSUSED*/
+int
+compat_43_sys_quota(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+
+ return (ENOSYS);
+}
+
+
+/*
+ * Read a block of directory entries in a file system independent format.
+ */
+int
+compat_43_sys_getdirentries(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_43_sys_getdirentries_args /* {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(u_int) count;
+ syscallarg(long *) basep;
+ } */ *uap = v;
+ register struct vnode *vp;
+ struct file *fp;
+ struct uio auio, kuio;
+ struct iovec aiov, kiov;
+ struct dirent *dp, *edp;
+ caddr_t dirbuf;
+ int error, eofflag, readcnt;
+ long loff;
+
+ if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
+ return (error);
+ if ((fp->f_flag & FREAD) == 0)
+ return (EBADF);
+ vp = (struct vnode *)fp->f_data;
+unionread:
+ if (vp->v_type != VDIR)
+ return (EINVAL);
+ aiov.iov_base = SCARG(uap, buf);
+ aiov.iov_len = SCARG(uap, count);
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_rw = UIO_READ;
+ auio.uio_segflg = UIO_USERSPACE;
+ auio.uio_procp = p;
+ auio.uio_resid = SCARG(uap, count);
+ VOP_LOCK(vp);
+ loff = auio.uio_offset = fp->f_offset;
+# if (BYTE_ORDER != LITTLE_ENDIAN)
+ if (vp->v_mount->mnt_maxsymlinklen <= 0) {
+ error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag,
+ (u_long *)0, 0);
+ fp->f_offset = auio.uio_offset;
+ } else
+# endif
+ {
+ kuio = auio;
+ kuio.uio_iov = &kiov;
+ kuio.uio_segflg = UIO_SYSSPACE;
+ kiov.iov_len = SCARG(uap, count);
+ MALLOC(dirbuf, caddr_t, SCARG(uap, count), M_TEMP, M_WAITOK);
+ kiov.iov_base = dirbuf;
+ error = VOP_READDIR(vp, &kuio, fp->f_cred, &eofflag,
+ (u_long *)0, 0);
+ fp->f_offset = kuio.uio_offset;
+ if (error == 0) {
+ readcnt = SCARG(uap, count) - kuio.uio_resid;
+ edp = (struct dirent *)&dirbuf[readcnt];
+ for (dp = (struct dirent *)dirbuf; dp < edp; ) {
+# if (BYTE_ORDER == LITTLE_ENDIAN)
+ /*
+ * The expected low byte of
+ * dp->d_namlen is our dp->d_type.
+ * The high MBZ byte of dp->d_namlen
+ * is our dp->d_namlen.
+ */
+ dp->d_type = dp->d_namlen;
+ dp->d_namlen = 0;
+# else
+ /*
+ * The dp->d_type is the high byte
+ * of the expected dp->d_namlen,
+ * so must be zero'ed.
+ */
+ dp->d_type = 0;
+# endif
+ if (dp->d_reclen > 0) {
+ dp = (struct dirent *)
+ ((char *)dp + dp->d_reclen);
+ } else {
+ error = EIO;
+ break;
+ }
+ }
+ if (dp >= edp)
+ error = uiomove(dirbuf, readcnt, &auio);
+ }
+ FREE(dirbuf, M_TEMP);
+ }
+ VOP_UNLOCK(vp);
+ if (error)
+ return (error);
+
+#ifdef UNION
+{
+ extern int (**union_vnodeop_p)();
+ extern struct vnode *union_dircache __P((struct vnode *));
+
+ if ((SCARG(uap, count) == auio.uio_resid) &&
+ (vp->v_op == union_vnodeop_p)) {
+ struct vnode *lvp;
+
+ lvp = union_dircache(vp);
+ if (lvp != NULLVP) {
+ struct vattr va;
+
+ /*
+ * If the directory is opaque,
+ * then don't show lower entries
+ */
+ error = VOP_GETATTR(vp, &va, fp->f_cred, p);
+ if (va.va_flags & OPAQUE) {
+ vput(lvp);
+ lvp = NULL;
+ }
+ }
+
+ if (lvp != NULLVP) {
+ error = VOP_OPEN(lvp, FREAD, fp->f_cred, p);
+ VOP_UNLOCK(lvp);
+
+ if (error) {
+ vrele(lvp);
+ return (error);
+ }
+ fp->f_data = (caddr_t) lvp;
+ fp->f_offset = 0;
+ error = vn_close(vp, FREAD, fp->f_cred, p);
+ if (error)
+ return (error);
+ vp = lvp;
+ goto unionread;
+ }
+ }
+}
+#endif /* UNION */
+
+ if ((SCARG(uap, count) == auio.uio_resid) &&
+ (vp->v_flag & VROOT) &&
+ (vp->v_mount->mnt_flag & MNT_UNION)) {
+ struct vnode *tvp = vp;
+ vp = vp->v_mount->mnt_vnodecovered;
+ VREF(vp);
+ fp->f_data = (caddr_t) vp;
+ fp->f_offset = 0;
+ vrele(tvp);
+ goto unionread;
+ }
+ error = copyout((caddr_t)&loff, (caddr_t)SCARG(uap, basep),
+ sizeof(long));
+ *retval = SCARG(uap, count) - auio.uio_resid;
+ return (error);
+}
diff --git a/sys/compat/freebsd/Makefile b/sys/compat/freebsd/Makefile
new file mode 100644
index 00000000000..961d1becd44
--- /dev/null
+++ b/sys/compat/freebsd/Makefile
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1 1995/10/10 01:19:24 mycroft Exp $
+
+SYS= ../..
+DEP= syscalls.conf syscalls.master ${SYS}/kern/makesyscalls.sh
+OBJS= freebsd_sysent.c freebsd_syscalls.c \
+ freebsd_syscall.h freebsd_syscallargs.h
+
+${OBJS}: ${DEP}
+ -mv -f freebsd_sysent.c freebsd_sysent.c.bak
+ -mv -f freebsd_syscalls.c freebsd_syscalls.c.bak
+ -mv -f freebsd_syscall.h freebsd_syscall.h.bak
+ -mv -f freebsd_syscallargs.h freebsd_syscallargs.h.bak
+ sh ${SYS}/kern/makesyscalls.sh syscalls.conf syscalls.master
diff --git a/sys/compat/freebsd/files.freebsd b/sys/compat/freebsd/files.freebsd
new file mode 100644
index 00000000000..0de0af26033
--- /dev/null
+++ b/sys/compat/freebsd/files.freebsd
@@ -0,0 +1,15 @@
+# $NetBSD: files.freebsd,v 1.1 1995/10/10 01:19:26 mycroft Exp $
+#
+# Config.new file description for machine-independent FreeBSD compat code.
+# Included by ports that need it.
+
+# ports should define any machine-specific files they need in their
+# own file lists.
+
+file compat/freebsd/freebsd_exec.c compat_freebsd
+file compat/freebsd/freebsd_file.c compat_freebsd
+file compat/freebsd/freebsd_ioctl.c compat_freebsd
+file compat/freebsd/freebsd_misc.c compat_freebsd
+file compat/freebsd/freebsd_ptrace.c compat_freebsd
+file compat/freebsd/freebsd_sysent.c compat_freebsd
+file compat/freebsd/freebsd_syscalls.c compat_freebsd
diff --git a/sys/compat/freebsd/freebsd_exec.c b/sys/compat/freebsd/freebsd_exec.c
new file mode 100644
index 00000000000..1d7f27d26b5
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_exec.c
@@ -0,0 +1,112 @@
+/* $NetBSD: freebsd_exec.c,v 1.1 1995/10/10 01:19:27 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1993, 1994 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.
+ * 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/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/malloc.h>
+#include <sys/vnode.h>
+#include <sys/exec.h>
+#include <sys/resourcevar.h>
+#include <vm/vm.h>
+
+#include <machine/freebsd_machdep.h>
+
+#include <compat/freebsd/freebsd_syscall.h>
+#include <compat/freebsd/freebsd_exec.h>
+
+extern struct sysent freebsd_sysent[];
+extern char *freebsd_syscallnames[];
+
+struct emul emul_freebsd = {
+ "freebsd",
+ NULL,
+ freebsd_sendsig,
+ FREEBSD_SYS_syscall,
+ FREEBSD_SYS_MAXSYSCALL,
+ freebsd_sysent,
+ freebsd_syscallnames,
+ 0,
+ copyargs,
+ setregs,
+ freebsd_sigcode,
+ freebsd_esigcode,
+};
+
+/*
+ * exec_aout_makecmds(): Check if it's an a.out-format executable.
+ *
+ * Given a proc pointer and an exec package pointer, see if the referent
+ * of the epp is in a.out format. First check 'standard' magic numbers for
+ * this architecture. If that fails, try a cpu-dependent hook.
+ *
+ * This function, in the former case, or the hook, in the latter, is
+ * responsible for creating a set of vmcmds which can be used to build
+ * the process's vm space and inserting them into the exec package.
+ */
+
+int
+exec_freebsd_aout_makecmds(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ u_long midmag;
+ int error = ENOEXEC;
+ struct exec *execp = epp->ep_hdr;
+
+ if (epp->ep_hdrvalid < sizeof(struct exec))
+ return ENOEXEC;
+
+ midmag = FREEBSD_N_GETMID(*execp) << 16 | FREEBSD_N_GETMAGIC(*execp);
+
+ /* assume FreeBSD's MID_MACHINE and [ZQNO]MAGIC is same as NetBSD's */
+ switch (midmag) {
+ case (MID_MACHINE << 16) | ZMAGIC:
+ error = cpu_exec_aout_prep_oldzmagic(p, epp);
+ break;
+ case (MID_MACHINE << 16) | QMAGIC:
+ error = exec_aout_prep_zmagic(p, epp);
+ break;
+ case (MID_MACHINE << 16) | NMAGIC:
+ error = exec_aout_prep_nmagic(p, epp);
+ break;
+ case (MID_MACHINE << 16) | OMAGIC:
+ error = exec_aout_prep_omagic(p, epp);
+ break;
+ }
+ if (error == 0)
+ epp->ep_emul = &emul_freebsd;
+ else
+ kill_vmcmds(&epp->ep_vmcmds);
+
+ return error;
+}
diff --git a/sys/compat/freebsd/freebsd_exec.h b/sys/compat/freebsd/freebsd_exec.h
new file mode 100644
index 00000000000..f5501626f8a
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_exec.h
@@ -0,0 +1,99 @@
+/*-
+ * 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 _FREEBSD_EXEC_H
+#define _FREEBSD_EXEC_H
+
+#define FREEBSD_N_GETMAGIC(ex) \
+ ( (ex).a_midmag & 0xffff )
+#define FREEBSD_N_GETMID(ex) \
+ ( ((ex).a_midmag >> 16) & 0x03ff )
+#define FREEBSD_N_GETFLAG(ex) \
+ ( ((ex).a_midmag >> 26) & 0x3f )
+#define FREEBSD_N_SETMAGIC(ex,mag,mid,flag) \
+ ( (ex).a_midmag = (((flag) & 0x3f) <<26) | (((mid) & 0x03ff) << 16) | \
+ ((mag) & 0xffff) )
+
+#define FREEBSD_N_ALIGN(ex,x) \
+ (FREEBSD_N_GETMAGIC(ex) == ZMAGIC || \
+ FREEBSD_N_GETMAGIC(ex) == QMAGIC ? \
+ ((x) + FREEBSD___LDPGSZ - 1) & \
+ ~(unsigned long)(FREEBSD___LDPGSZ - 1) : (x))
+
+/* Valid magic number check. */
+#define FREEBSD_N_BADMAG(ex) \
+ (FREEBSD_N_GETMAGIC(ex) != OMAGIC && \
+ FREEBSD_N_GETMAGIC(ex) != NMAGIC && \
+ FREEBSD_N_GETMAGIC(ex) != ZMAGIC && \
+ FREEBSD_N_GETMAGIC(ex) != QMAGIC)
+
+/* Address of the bottom of the text segment. */
+#define FREEBSD_N_TXTADDR(ex) \
+ ((FREEBSD_N_GETMAGIC(ex) == OMAGIC || \
+ FREEBSD_N_GETMAGIC(ex) == NMAGIC || \
+ FREEBSD_N_GETMAGIC(ex) == ZMAGIC) ? 0 : __LDPGSZ)
+
+/* Address of the bottom of the data segment. */
+#define FREEBSD_N_DATADDR(ex) \
+ FREEBSD_N_ALIGN(ex, FREEBSD_N_TXTADDR(ex) + (ex).a_text)
+
+/* Text segment offset. */
+#define FREEBSD_N_TXTOFF(ex) \
+ (FREEBSD_N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : \
+ FREEBSD_N_GETMAGIC(ex) == QMAGIC ? 0 : sizeof(struct exec))
+
+/* Data segment offset. */
+#define FREEBSD_N_DATOFF(ex) \
+ FREEBSD_N_ALIGN(ex, FREEBSD_N_TXTOFF(ex) + (ex).a_text)
+
+/* Relocation table offset. */
+#define FREEBSD_N_RELOFF(ex) \
+ FREEBSD_N_ALIGN(ex, FREEBSD_N_DATOFF(ex) + (ex).a_data)
+
+/* Symbol table offset. */
+#define FREEBSD_N_SYMOFF(ex) \
+ (FREEBSD_N_RELOFF(ex) + (ex).a_trsize + (ex).a_drsize)
+
+/* String table offset. */
+#define FREEBSD_N_STROFF(ex) (FREEBSD_N_SYMOFF(ex) + (ex).a_syms)
+
+#define FREEBSD_AOUT_HDR_SIZE sizeof(struct exec)
+
+int exec_freebsd_aout_makecmds __P((struct proc *, struct exec_package *));
+
+extern char freebsd_sigcode[], freebsd_esigcode[];
+
+#endif /* !_FREEBSD_EXEC_H */
diff --git a/sys/compat/freebsd/freebsd_file.c b/sys/compat/freebsd/freebsd_file.c
new file mode 100644
index 00000000000..c0487897249
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_file.c
@@ -0,0 +1,598 @@
+/* $NetBSD: freebsd_file.c,v 1.1 1995/10/10 01:19:30 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ *
+ * from: linux_file.c,v 1.3 1995/04/04 04:21:30 mycroft Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/malloc.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/freebsd/freebsd_syscallargs.h>
+#include <compat/freebsd/freebsd_util.h>
+
+#define ARRAY_LENGTH(array) (sizeof(array)/sizeof(array[0]))
+
+const char freebsd_emul_path[] = "/emul/freebsd";
+
+static char *
+convert_from_freebsd_mount_type(type)
+ int type;
+{
+ static char *netbsd_mount_type[] = {
+ NULL, /* 0 = MOUNT_NONE */
+ "ufs", /* 1 = UNIX "Fast" Filesystem */
+ "nfs", /* 2 = Network Filesystem */
+ "mfs", /* 3 = Memory Filesystem */
+ "msdos", /* 4 = MSDOS Filesystem */
+ "lfs", /* 5 = Log-based Filesystem */
+ "lofs", /* 6 = Loopback filesystem */
+ "fdesc", /* 7 = File Descriptor Filesystem */
+ "portal", /* 8 = Portal Filesystem */
+ "null", /* 9 = Minimal Filesystem Layer */
+ "umap", /* 10 = User/Group Identifier Remapping Filesystem */
+ "kernfs", /* 11 = Kernel Information Filesystem */
+ "procfs", /* 12 = /proc Filesystem */
+ "afs", /* 13 = Andrew Filesystem */
+ "cd9660", /* 14 = ISO9660 (aka CDROM) Filesystem */
+ "union", /* 15 = Union (translucent) Filesystem */
+ NULL, /* 16 = "devfs" - existing device Filesystem */
+#if 0 /* These filesystems don't exist in FreeBSD */
+ "adosfs", /* ?? = AmigaDOS Filesystem */
+#endif
+ };
+
+ if (type < 0 || type >= ARRAY_LENGTH(netbsd_mount_type))
+ return (NULL);
+ return (netbsd_mount_type[type]);
+}
+
+int
+freebsd_sys_mount(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_mount_args /* {
+ syscallarg(int) type;
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(caddr_t) data;
+ } */ *uap = v;
+ int error;
+ char *type, *s;
+ caddr_t sg = stackgap_init(p->p_emul);
+ struct sys_mount_args bma;
+
+ if ((type = convert_from_freebsd_mount_type(SCARG(uap, type))) == NULL)
+ return ENODEV;
+ s = stackgap_alloc(&sg, MFSNAMELEN + 1);
+ if (error = copyout(type, s, strlen(type) + 1))
+ return error;
+ SCARG(&bma, type) = s;
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ SCARG(&bma, path) = SCARG(uap, path);
+ SCARG(&bma, flags) = SCARG(uap, flags);
+ SCARG(&bma, data) = SCARG(uap, data);
+ return sys_mount(p, &bma, retval);
+}
+
+/*
+ * The following syscalls are only here because of the alternate path check.
+ */
+
+/* XXX - UNIX domain: int freebsd_sys_bind(int s, caddr_t name, int namelen); */
+/* XXX - UNIX domain: int freebsd_sys_connect(int s, caddr_t name, int namelen); */
+
+
+int
+freebsd_sys_open(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_open_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ if (SCARG(uap, flags) & O_CREAT)
+ FREEBSD_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+ else
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_open(p, uap, retval);
+}
+
+int
+compat_43_freebsd_sys_creat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_43_freebsd_sys_creat_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+ return compat_43_sys_creat(p, uap, retval);
+}
+
+int
+freebsd_sys_link(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_link_args /* {
+ syscallarg(char *) path;
+ syscallarg(char *) link;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ FREEBSD_CHECK_ALT_CREAT(p, &sg, SCARG(uap, link));
+ return sys_link(p, uap, retval);
+}
+
+int
+freebsd_sys_unlink(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_unlink_args /* {
+ syscallarg(char *) path;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_unlink(p, uap, retval);
+}
+
+int
+freebsd_sys_chdir(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_chdir_args /* {
+ syscallarg(char *) path;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_chdir(p, uap, retval);
+}
+
+int
+freebsd_sys_mknod(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_mknod_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ syscallarg(int) dev;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+ return sys_mknod(p, uap, retval);
+}
+
+int
+freebsd_sys_chmod(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_chmod_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_chmod(p, uap, retval);
+}
+
+int
+freebsd_sys_chown(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_chown_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) uid;
+ syscallarg(int) gid;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_chown(p, uap, retval);
+}
+
+int
+freebsd_sys_unmount(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_unmount_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_unmount(p, uap, retval);
+}
+
+int
+freebsd_sys_access(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_access_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_access(p, uap, retval);
+}
+
+int
+freebsd_sys_chflags(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_chflags_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_chflags(p, uap, retval);
+}
+
+int
+compat_43_freebsd_sys_stat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_43_freebsd_sys_stat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct ostat *) ub;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return compat_43_sys_stat(p, uap, retval);
+}
+
+int
+compat_43_freebsd_sys_lstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_43_freebsd_sys_lstat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct ostat *) ub;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return compat_43_sys_lstat(p, uap, retval);
+}
+
+int
+freebsd_sys_revoke(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_revoke_args /* {
+ syscallarg(char *) path;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_revoke(p, uap, retval);
+}
+
+int
+freebsd_sys_symlink(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_symlink_args /* {
+ syscallarg(char *) path;
+ syscallarg(char *) link;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ FREEBSD_CHECK_ALT_CREAT(p, &sg, SCARG(uap, link));
+ return sys_symlink(p, uap, retval);
+}
+
+int
+freebsd_sys_readlink(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_readlink_args /* {
+ syscallarg(char *) path;
+ syscallarg(char *) buf;
+ syscallarg(int) count;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_readlink(p, uap, retval);
+}
+
+int
+freebsd_sys_execve(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_execve_args /* {
+ syscallarg(char *) path;
+ syscallarg(char **) argp;
+ syscallarg(char **) envp;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_execve(p, uap, retval);
+}
+
+int
+freebsd_sys_chroot(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_chroot_args /* {
+ syscallarg(char *) path;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_chroot(p, uap, retval);
+}
+
+int
+freebsd_sys_rename(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_rename_args /* {
+ syscallarg(char *) from;
+ syscallarg(char *) to;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, from));
+ FREEBSD_CHECK_ALT_CREAT(p, &sg, SCARG(uap, to));
+ return sys_rename(p, uap, retval);
+}
+
+int
+compat_43_freebsd_sys_truncate(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_43_freebsd_sys_truncate_args /* {
+ syscallarg(char *) path;
+ syscallarg(long) length;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return compat_43_sys_truncate(p, uap, retval);
+}
+
+int
+freebsd_sys_mkfifo(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_mkfifo_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+ return sys_mkfifo(p, uap, retval);
+}
+
+int
+freebsd_sys_mkdir(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_mkdir_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+ return sys_mkdir(p, uap, retval);
+}
+
+int
+freebsd_sys_rmdir(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_rmdir_args /* {
+ syscallarg(char *) path;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_rmdir(p, uap, retval);
+}
+
+int
+freebsd_sys_statfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_stat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct statfs *) buf;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_statfs(p, uap, retval);
+}
+
+#ifdef NFSCLIENT
+int
+freebsd_sys_getfh(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_getfh_args /* {
+ syscallarg(char *) fname;
+ syscallarg(fhandle_t *) fhp;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, fname));
+ return sys_getfh(p, uap, retval);
+}
+#endif /* NFSCLIENT */
+
+int
+freebsd_sys_stat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_stat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct stat *) ub;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_stat(p, uap, retval);
+}
+
+int
+freebsd_sys_lstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_lstat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct stat *) ub;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_lstat(p, uap, retval);
+}
+
+int
+freebsd_sys_pathconf(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_pathconf_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) name;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_pathconf(p, uap, retval);
+}
+
+int
+freebsd_sys_truncate(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_truncate_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) pad;
+ syscallarg(off_t) length;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ FREEBSD_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_truncate(p, uap, retval);
+}
diff --git a/sys/compat/freebsd/freebsd_ioctl.c b/sys/compat/freebsd/freebsd_ioctl.c
new file mode 100644
index 00000000000..b20ab8e0e7c
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_ioctl.c
@@ -0,0 +1,66 @@
+/* $NetBSD: freebsd_ioctl.c,v 1.1 1995/10/10 01:19:31 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/mount.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/freebsd/freebsd_syscallargs.h>
+#include <compat/freebsd/freebsd_util.h>
+#include <compat/freebsd/freebsd_ioctl.h>
+
+int
+freebsd_sys_ioctl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_ioctl_args /* {
+ syscallarg(int) fd;
+ syscallarg(u_long) com;
+ syscallarg(caddr_t) data;
+ } */ *uap = v;
+
+ /*
+ * XXX - <sys/cdio.h>'s incompatibility
+ * _IO('c', 25..27, *): incompatible
+ * _IO('c', 28... , *): not exist
+ */
+ /* XXX - <sys/mtio.h> */
+ /* XXX - <sys/scsiio.h> */
+ /* XXX - should convert machine dependent ioctl()s */
+ return sys_ioctl(p, uap, retval);
+}
diff --git a/sys/compat/freebsd/freebsd_ioctl.h b/sys/compat/freebsd/freebsd_ioctl.h
new file mode 100644
index 00000000000..106dd33603a
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_ioctl.h
@@ -0,0 +1,37 @@
+/* $NetBSD: freebsd_ioctl.h,v 1.1 1995/10/10 01:19:32 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _FREEBSD_IOCTL_H
+#define _FREEBSD_IOCTL_H
+
+#endif /* !_FREEBSD_IOCTL_H */
diff --git a/sys/compat/freebsd/freebsd_misc.c b/sys/compat/freebsd/freebsd_misc.c
new file mode 100644
index 00000000000..4692fedc17e
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_misc.c
@@ -0,0 +1,101 @@
+/* $NetBSD: freebsd_misc.c,v 1.1 1995/10/10 01:19:33 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+/*
+ * FreeBSD compatibility module. Try to deal with various FreeBSD system calls.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/mount.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/freebsd/freebsd_syscallargs.h>
+#include <compat/freebsd/freebsd_util.h>
+#include <compat/freebsd/freebsd_rtprio.h>
+#include <compat/freebsd/freebsd_timex.h>
+
+int
+freebsd_sys_msync(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_msync_args /* {
+ syscallarg(caddr_t) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) flags;
+ } */ *uap = v;
+ struct sys_msync_args bma;
+
+ /*
+ * FreeBSD-2.0-RELEASE's msync(2) is compatible with NetBSD's.
+ * FreeBSD-2.0.5-RELEASE's msync(2) has addtional argument `flags',
+ * but syscall number is not changed. :-<
+ */
+ SCARG(&bma, addr) = SCARG(uap, addr);
+ SCARG(&bma, len) = SCARG(uap, len);
+ return sys_msync(p, &bma, retval); /* XXX - simply ignores `flags' */
+}
+
+/* just a place holder */
+
+int
+freebsd_sys_rtprio(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_rtprio_args /* {
+ syscallarg(int) function;
+ syscallarg(pid_t) pid;
+ syscallarg(struct freebsd_rtprio *) rtp;
+ } */ *uap = v;
+
+ return ENOSYS; /* XXX */
+}
+
+int
+freebsd_ntp_adjtime(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_ntp_adjtime_args /* {
+ syscallarg(struct freebsd_timex *) tp;
+ } */ *uap = v;
+
+ return ENOSYS; /* XXX */
+}
diff --git a/sys/compat/freebsd/freebsd_ptrace.c b/sys/compat/freebsd/freebsd_ptrace.c
new file mode 100644
index 00000000000..424caf59b19
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_ptrace.c
@@ -0,0 +1,158 @@
+/* $NetBSD: freebsd_ptrace.c,v 1.1 1995/10/10 01:19:34 mycroft Exp $ */
+
+/*-
+ * Copyright (c) 1994 Christopher G. Demetriou. All rights reserved.
+ * 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.
+ *
+ * from: @(#)sys_process.c 8.1 (Berkeley) 6/10/93
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/errno.h>
+#include <sys/ptrace.h>
+#include <sys/uio.h>
+#include <sys/user.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <machine/reg.h>
+#include <machine/freebsd_machdep.h>
+
+#include <compat/freebsd/freebsd_syscallargs.h>
+#include <compat/freebsd/freebsd_util.h>
+#include <compat/freebsd/freebsd_ptrace.h>
+
+/*
+ * Process debugging system call.
+ */
+int
+freebsd_sys_ptrace(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct freebsd_sys_ptrace_args /* {
+ syscallarg(int) req;
+ syscallarg(pid_t) pid;
+ syscallarg(caddr_t) addr;
+ syscallarg(int) data;
+ } */ *uap = v;
+ int error;
+ caddr_t sg;
+ struct {
+ struct reg regs;
+ struct fpreg fpregs;
+ } *nrp;
+ struct sys_ptrace_args npa;
+ struct freebsd_ptrace_reg fr;
+
+ switch (SCARG(uap, req)) {
+#ifdef PT_STEP
+ case FREEBSD_PT_STEP:
+ SCARG(&npa, req) = PT_STEP;
+ SCARG(&npa, pid) = SCARG(uap, pid);
+ SCARG(&npa, addr) = SCARG(uap, addr);
+ SCARG(&npa, data) = SCARG(uap, data);
+ return sys_ptrace(p, &npa, retval);
+#endif
+ case FREEBSD_PT_TRACE_ME:
+ case FREEBSD_PT_READ_I:
+ case FREEBSD_PT_READ_D:
+ case FREEBSD_PT_WRITE_I:
+ case FREEBSD_PT_WRITE_D:
+ case FREEBSD_PT_CONTINUE:
+ case FREEBSD_PT_KILL:
+ /* These requests are compatible with NetBSD */
+ return sys_ptrace(p, uap, retval);
+
+ case FREEBSD_PT_READ_U:
+ case FREEBSD_PT_WRITE_U:
+ sg = stackgap_init(p->p_emul);
+ nrp = stackgap_alloc(&sg, sizeof(*nrp));
+#ifdef PT_GETREGS
+ SCARG(&npa, req) = PT_GETREGS;
+ SCARG(&npa, pid) = SCARG(uap, pid);
+ SCARG(&npa, addr) = (caddr_t)&nrp->regs;
+ if ((error = sys_ptrace(p, &npa, retval)) != 0)
+ return error;
+#endif
+#ifdef PT_GETFPREGS
+ SCARG(&npa, req) = PT_GETFPREGS;
+ SCARG(&npa, pid) = SCARG(uap, pid);
+ SCARG(&npa, addr) = (caddr_t)&nrp->fpregs;
+ if ((error = sys_ptrace(p, &npa, retval)) != 0)
+ return error;
+#endif
+ netbsd_to_freebsd_ptrace_regs(&nrp->regs, &nrp->fpregs, &fr);
+ switch (SCARG(uap, req)) {
+ case FREEBSD_PT_READ_U:
+ return freebsd_ptrace_getregs(&fr, SCARG(uap, addr),
+ retval);
+
+ case FREEBSD_PT_WRITE_U:
+ if (error = freebsd_ptrace_setregs(&fr,
+ SCARG(uap, addr), SCARG(uap, data)))
+ return error;
+ freebsd_to_netbsd_ptrace_regs(&fr,
+ &nrp->regs, &nrp->fpregs);
+#ifdef PT_SETREGS
+ SCARG(&npa, req) = PT_SETREGS;
+ SCARG(&npa, pid) = SCARG(uap, pid);
+ SCARG(&npa, addr) = (caddr_t)&nrp->regs;
+ if ((error = sys_ptrace(p, &npa, retval)) != 0)
+ return error;
+#endif
+#ifdef PT_SETFPREGS
+ SCARG(&npa, req) = PT_SETFPREGS;
+ SCARG(&npa, pid) = SCARG(uap, pid);
+ SCARG(&npa, addr) = (caddr_t)&nrp->fpregs;
+ if ((error = sys_ptrace(p, &npa, retval)) != 0)
+ return error;
+#endif
+ return 0;
+ }
+
+ default: /* It was not a legal request. */
+ return (EINVAL);
+ }
+
+#ifdef DIAGNOSTIC
+ panic("freebsd_ptrace: impossible");
+#endif
+}
diff --git a/sys/compat/freebsd/freebsd_ptrace.h b/sys/compat/freebsd/freebsd_ptrace.h
new file mode 100644
index 00000000000..6c3f3bc29e2
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_ptrace.h
@@ -0,0 +1,67 @@
+/*-
+ * Copyright (c) 1984, 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.
+ *
+ * @(#)ptrace.h 8.2 (Berkeley) 1/4/94
+ * $Id: freebsd_ptrace.h,v 1.1 1995/10/18 08:52:13 deraadt Exp $
+ */
+
+#ifndef _FREEBSD_PTRACE_H_
+#define _FREEBSD_PTRACE_H_
+
+#define FREEBSD_PT_TRACE_ME 0 /* child declares it's being traced */
+#define FREEBSD_PT_READ_I 1 /* read word in child's I space */
+#define FREEBSD_PT_READ_D 2 /* read word in child's D space */
+#define FREEBSD_PT_READ_U 3 /* read word in child's user structure */
+#define FREEBSD_PT_WRITE_I 4 /* write word in child's I space */
+#define FREEBSD_PT_WRITE_D 5 /* write word in child's D space */
+#define FREEBSD_PT_WRITE_U 6 /* write word in child's user structure */
+#define FREEBSD_PT_CONTINUE 7 /* continue the child */
+#define FREEBSD_PT_KILL 8 /* kill the child process */
+#define FREEBSD_PT_STEP 9 /* single step the child */
+
+#ifdef notdef
+#define FREEBSD_PT_ATTACH 10 /* trace some running process */
+#define FREEBSD_PT_DETACH 11 /* stop tracing a process */
+#endif
+
+#define FREEBSD_PT_FIRSTMACH 32 /* for machine-specific requests */
+
+void netbsd_to_freebsd_ptrace_regs __P((struct reg *, struct fpreg *,
+ struct freebsd_ptrace_reg *));
+void freebsd_to_netbsd_ptrace_regs __P((struct freebsd_ptrace_reg *,
+ struct reg *, struct fpreg *));
+int freebsd_ptrace_getregs __P((struct freebsd_ptrace_reg *, caddr_t,
+ register_t *));
+int freebsd_ptrace_setregs __P((struct freebsd_ptrace_reg *, caddr_t,
+ int));
+
+#endif /* !_FREEBSD_PTRACE_H_ */
diff --git a/sys/compat/freebsd/freebsd_rtprio.h b/sys/compat/freebsd/freebsd_rtprio.h
new file mode 100644
index 00000000000..4f7b8c63359
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_rtprio.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 1994, Henrik Vestergaard Draboel
+ * 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 (name).
+ * 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 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 AUTHOR 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: rtprio.h,v 1.2 1994/10/02 04:45:59 davidg Exp
+ */
+
+#ifndef _FREEBSD_RTPRIO_H
+#define _FREEBSD_RTPRIO_H
+
+/*
+ * Process realtime-priority specifications to rtprio.
+ */
+
+/* priority types */
+#define FREEBSD_RTP_PRIO_REALTIME 0
+#define FREEBSD_RTP_PRIO_NORMAL 1
+#define FREEBSD_RTP_PRIO_IDLE 2
+
+/* priority range */
+#define FREEBSD_RTP_PRIO_MIN 0 /* Highest priority */
+#define FREEBSD_RTP_PRIO_MAX 31 /* Lowest priority */
+
+/*
+ * rtprio() syscall functions
+ */
+#define FREEBSD_RTP_LOOKUP 0
+#define FREEBSD_RTP_SET 1
+
+#ifndef LOCORE
+struct freebsd_rtprio {
+ u_short type;
+ u_short prio;
+};
+#endif
+#endif /* !_FREEBSD_RTPRIO_H */
diff --git a/sys/compat/freebsd/freebsd_syscall.h b/sys/compat/freebsd/freebsd_syscall.h
new file mode 100644
index 00000000000..950d7035cc5
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_syscall.h
@@ -0,0 +1,196 @@
+/*
+ * System call numbers.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.2 1995/10/10 01:34:37 mycroft Exp
+ */
+
+#define FREEBSD_SYS_syscall 0
+#define FREEBSD_SYS_exit 1
+#define FREEBSD_SYS_fork 2
+#define FREEBSD_SYS_read 3
+#define FREEBSD_SYS_write 4
+#define FREEBSD_SYS_open 5
+#define FREEBSD_SYS_close 6
+#define FREEBSD_SYS_wait4 7
+#define FREEBSD_SYS_ocreat 8
+#define FREEBSD_SYS_link 9
+#define FREEBSD_SYS_unlink 10
+ /* 11 is obsolete execv */
+#define FREEBSD_SYS_chdir 12
+#define FREEBSD_SYS_fchdir 13
+#define FREEBSD_SYS_mknod 14
+#define FREEBSD_SYS_chmod 15
+#define FREEBSD_SYS_chown 16
+#define FREEBSD_SYS_break 17
+#define FREEBSD_SYS_getfsstat 18
+#define FREEBSD_SYS_olseek 19
+#define FREEBSD_SYS_getpid 20
+#define FREEBSD_SYS_mount 21
+#define FREEBSD_SYS_unmount 22
+#define FREEBSD_SYS_setuid 23
+#define FREEBSD_SYS_getuid 24
+#define FREEBSD_SYS_geteuid 25
+#define FREEBSD_SYS_ptrace 26
+#define FREEBSD_SYS_recvmsg 27
+#define FREEBSD_SYS_sendmsg 28
+#define FREEBSD_SYS_recvfrom 29
+#define FREEBSD_SYS_accept 30
+#define FREEBSD_SYS_getpeername 31
+#define FREEBSD_SYS_getsockname 32
+#define FREEBSD_SYS_access 33
+#define FREEBSD_SYS_chflags 34
+#define FREEBSD_SYS_fchflags 35
+#define FREEBSD_SYS_sync 36
+#define FREEBSD_SYS_kill 37
+#define FREEBSD_SYS_ostat 38
+#define FREEBSD_SYS_getppid 39
+#define FREEBSD_SYS_olstat 40
+#define FREEBSD_SYS_dup 41
+#define FREEBSD_SYS_pipe 42
+#define FREEBSD_SYS_getegid 43
+#define FREEBSD_SYS_profil 44
+#define FREEBSD_SYS_ktrace 45
+#define FREEBSD_SYS_sigaction 46
+#define FREEBSD_SYS_getgid 47
+#define FREEBSD_SYS_sigprocmask 48
+#define FREEBSD_SYS_getlogin 49
+#define FREEBSD_SYS_setlogin 50
+#define FREEBSD_SYS_acct 51
+#define FREEBSD_SYS_sigpending 52
+#define FREEBSD_SYS_sigaltstack 53
+#define FREEBSD_SYS_ioctl 54
+#define FREEBSD_SYS_reboot 55
+#define FREEBSD_SYS_revoke 56
+#define FREEBSD_SYS_symlink 57
+#define FREEBSD_SYS_readlink 58
+#define FREEBSD_SYS_execve 59
+#define FREEBSD_SYS_umask 60
+#define FREEBSD_SYS_chroot 61
+#define FREEBSD_SYS_ofstat 62
+#define FREEBSD_SYS_ogetkerninfo 63
+#define FREEBSD_SYS_ogetpagesize 64
+#define FREEBSD_SYS_msync 65
+#define FREEBSD_SYS_vfork 66
+ /* 67 is obsolete vread */
+ /* 68 is obsolete vwrite */
+#define FREEBSD_SYS_sbrk 69
+#define FREEBSD_SYS_sstk 70
+#define FREEBSD_SYS_ommap 71
+#define FREEBSD_SYS_vadvise 72
+#define FREEBSD_SYS_munmap 73
+#define FREEBSD_SYS_mprotect 74
+#define FREEBSD_SYS_madvise 75
+ /* 76 is obsolete vhangup */
+ /* 77 is obsolete vlimit */
+#define FREEBSD_SYS_mincore 78
+#define FREEBSD_SYS_getgroups 79
+#define FREEBSD_SYS_setgroups 80
+#define FREEBSD_SYS_getpgrp 81
+#define FREEBSD_SYS_setpgid 82
+#define FREEBSD_SYS_setitimer 83
+#define FREEBSD_SYS_owait 84
+#define FREEBSD_SYS_swapon 85
+#define FREEBSD_SYS_getitimer 86
+#define FREEBSD_SYS_ogethostname 87
+#define FREEBSD_SYS_osethostname 88
+#define FREEBSD_SYS_ogetdtablesize 89
+#define FREEBSD_SYS_dup2 90
+#define FREEBSD_SYS_fcntl 92
+#define FREEBSD_SYS_select 93
+#define FREEBSD_SYS_fsync 95
+#define FREEBSD_SYS_setpriority 96
+#define FREEBSD_SYS_socket 97
+#define FREEBSD_SYS_connect 98
+#define FREEBSD_SYS_oaccept 99
+#define FREEBSD_SYS_getpriority 100
+#define FREEBSD_SYS_osend 101
+#define FREEBSD_SYS_orecv 102
+#define FREEBSD_SYS_sigreturn 103
+#define FREEBSD_SYS_bind 104
+#define FREEBSD_SYS_setsockopt 105
+#define FREEBSD_SYS_listen 106
+ /* 107 is obsolete vtimes */
+#define FREEBSD_SYS_osigvec 108
+#define FREEBSD_SYS_osigblock 109
+#define FREEBSD_SYS_osigsetmask 110
+#define FREEBSD_SYS_sigsuspend 111
+#define FREEBSD_SYS_osigstack 112
+#define FREEBSD_SYS_orecvmsg 113
+#define FREEBSD_SYS_osendmsg 114
+#define FREEBSD_SYS_vtrace 115
+ /* 115 is obsolete vtrace */
+#define FREEBSD_SYS_gettimeofday 116
+#define FREEBSD_SYS_getrusage 117
+#define FREEBSD_SYS_getsockopt 118
+ /* 119 is obsolete resuba */
+#define FREEBSD_SYS_readv 120
+#define FREEBSD_SYS_writev 121
+#define FREEBSD_SYS_settimeofday 122
+#define FREEBSD_SYS_fchown 123
+#define FREEBSD_SYS_fchmod 124
+#define FREEBSD_SYS_orecvfrom 125
+#define FREEBSD_SYS_osetreuid 126
+#define FREEBSD_SYS_osetregid 127
+#define FREEBSD_SYS_rename 128
+#define FREEBSD_SYS_otruncate 129
+#define FREEBSD_SYS_oftruncate 130
+#define FREEBSD_SYS_flock 131
+#define FREEBSD_SYS_mkfifo 132
+#define FREEBSD_SYS_sendto 133
+#define FREEBSD_SYS_shutdown 134
+#define FREEBSD_SYS_socketpair 135
+#define FREEBSD_SYS_mkdir 136
+#define FREEBSD_SYS_rmdir 137
+#define FREEBSD_SYS_utimes 138
+ /* 139 is obsolete 4.2 sigreturn */
+#define FREEBSD_SYS_adjtime 140
+#define FREEBSD_SYS_ogetpeername 141
+#define FREEBSD_SYS_ogethostid 142
+#define FREEBSD_SYS_osethostid 143
+#define FREEBSD_SYS_ogetrlimit 144
+#define FREEBSD_SYS_osetrlimit 145
+#define FREEBSD_SYS_okillpg 146
+#define FREEBSD_SYS_setsid 147
+#define FREEBSD_SYS_quotactl 148
+#define FREEBSD_SYS_oquota 149
+#define FREEBSD_SYS_ogetsockname 150
+#define FREEBSD_SYS_nfssvc 155
+#define FREEBSD_SYS_ogetdirentries 156
+#define FREEBSD_SYS_statfs 157
+#define FREEBSD_SYS_fstatfs 158
+#define FREEBSD_SYS_getfh 161
+#define FREEBSD_SYS_getdomainname 162
+#define FREEBSD_SYS_setdomainname 163
+#define FREEBSD_SYS_uname 164
+#define FREEBSD_SYS_sysarch 165
+#define FREEBSD_SYS_rtprio 166
+#define FREEBSD_SYS_semsys 169
+#define FREEBSD_SYS_msgsys 170
+#define FREEBSD_SYS_shmsys 171
+#define FREEBSD_SYS_freebsd_ntp_adjtime 176
+#define FREEBSD_SYS_setgid 181
+#define FREEBSD_SYS_setegid 182
+#define FREEBSD_SYS_seteuid 183
+#define FREEBSD_SYS_lfs_bmapv 184
+#define FREEBSD_SYS_lfs_markv 185
+#define FREEBSD_SYS_lfs_segclean 186
+#define FREEBSD_SYS_lfs_segwait 187
+#define FREEBSD_SYS_stat 188
+#define FREEBSD_SYS_fstat 189
+#define FREEBSD_SYS_lstat 190
+#define FREEBSD_SYS_pathconf 191
+#define FREEBSD_SYS_fpathconf 192
+#define FREEBSD_SYS_getrlimit 194
+#define FREEBSD_SYS_setrlimit 195
+#define FREEBSD_SYS_getdirentries 196
+#define FREEBSD_SYS_mmap 197
+#define FREEBSD_SYS___syscall 198
+#define FREEBSD_SYS_lseek 199
+#define FREEBSD_SYS_truncate 200
+#define FREEBSD_SYS_ftruncate 201
+#define FREEBSD_SYS___sysctl 202
+#define FREEBSD_SYS_mlock 203
+#define FREEBSD_SYS_munlock 204
+#define FREEBSD_SYS_undelete 205
+#define FREEBSD_SYS_MAXSYSCALL 220
diff --git a/sys/compat/freebsd/freebsd_syscallargs.h b/sys/compat/freebsd/freebsd_syscallargs.h
new file mode 100644
index 00000000000..c5282a88374
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_syscallargs.h
@@ -0,0 +1,409 @@
+/*
+ * System call argument lists.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.2 1995/10/10 01:34:37 mycroft Exp
+ */
+
+#define syscallarg(x) union { x datum; register_t pad; }
+
+struct freebsd_sys_open_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+};
+
+struct compat_43_freebsd_sys_creat_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct freebsd_sys_link_args {
+ syscallarg(char *) path;
+ syscallarg(char *) link;
+};
+
+struct freebsd_sys_unlink_args {
+ syscallarg(char *) path;
+};
+
+struct freebsd_sys_chdir_args {
+ syscallarg(char *) path;
+};
+
+struct freebsd_sys_mknod_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ syscallarg(int) dev;
+};
+
+struct freebsd_sys_chmod_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct freebsd_sys_chown_args {
+ syscallarg(char *) path;
+ syscallarg(int) uid;
+ syscallarg(int) gid;
+};
+
+struct freebsd_sys_mount_args {
+ syscallarg(int) type;
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(caddr_t) data;
+};
+
+struct freebsd_sys_unmount_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+};
+
+struct freebsd_sys_ptrace_args {
+ syscallarg(int) req;
+ syscallarg(pid_t) pid;
+ syscallarg(caddr_t) addr;
+ syscallarg(int) data;
+};
+
+struct freebsd_sys_access_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+};
+
+struct freebsd_sys_chflags_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+};
+
+struct compat_43_freebsd_sys_stat_args {
+ syscallarg(char *) path;
+ syscallarg(struct ostat *) ub;
+};
+
+struct compat_43_freebsd_sys_lstat_args {
+ syscallarg(char *) path;
+ syscallarg(struct ostat *) ub;
+};
+
+struct freebsd_sys_ioctl_args {
+ syscallarg(int) fd;
+ syscallarg(u_long) com;
+ syscallarg(caddr_t) data;
+};
+
+struct freebsd_sys_revoke_args {
+ syscallarg(char *) path;
+};
+
+struct freebsd_sys_symlink_args {
+ syscallarg(char *) path;
+ syscallarg(char *) link;
+};
+
+struct freebsd_sys_readlink_args {
+ syscallarg(char *) path;
+ syscallarg(char *) buf;
+ syscallarg(int) count;
+};
+
+struct freebsd_sys_execve_args {
+ syscallarg(char *) path;
+ syscallarg(char **) argp;
+ syscallarg(char **) envp;
+};
+
+struct freebsd_sys_chroot_args {
+ syscallarg(char *) path;
+};
+
+struct freebsd_sys_msync_args {
+ syscallarg(caddr_t) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) flags;
+};
+
+struct freebsd_sys_sigreturn_args {
+ syscallarg(struct freebsd_sigcontext *) scp;
+};
+
+struct freebsd_sys_rename_args {
+ syscallarg(char *) from;
+ syscallarg(char *) to;
+};
+
+struct compat_43_freebsd_sys_truncate_args {
+ syscallarg(char *) path;
+ syscallarg(long) length;
+};
+
+struct freebsd_sys_mkfifo_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct freebsd_sys_mkdir_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct freebsd_sys_rmdir_args {
+ syscallarg(char *) path;
+};
+
+struct freebsd_sys_statfs_args {
+ syscallarg(char *) path;
+ syscallarg(struct statfs *) buf;
+};
+
+struct freebsd_sys_getfh_args {
+ syscallarg(char *) fname;
+ syscallarg(fhandle_t *) fhp;
+};
+
+struct freebsd_sys_rtprio_args {
+ syscallarg(int) function;
+ syscallarg(pid_t) pid;
+ syscallarg(struct freebsd_rtprio *) rtp;
+};
+
+struct freebsd_ntp_adjtime_args {
+ syscallarg(struct freebsd_timex *) tp;
+};
+
+struct freebsd_sys_stat_args {
+ syscallarg(char *) path;
+ syscallarg(struct stat *) ub;
+};
+
+struct freebsd_sys_lstat_args {
+ syscallarg(char *) path;
+ syscallarg(struct stat *) ub;
+};
+
+struct freebsd_sys_pathconf_args {
+ syscallarg(char *) path;
+ syscallarg(int) name;
+};
+
+struct freebsd_sys_truncate_args {
+ syscallarg(char *) path;
+ syscallarg(int) pad;
+ syscallarg(off_t) length;
+};
+
+struct freebsd_sys_undelete_args {
+ syscallarg(char *) path;
+};
+
+/*
+ * System call prototypes.
+ */
+
+int sys_nosys __P((struct proc *, void *, register_t *));
+int sys_exit __P((struct proc *, void *, register_t *));
+int sys_fork __P((struct proc *, void *, register_t *));
+int sys_read __P((struct proc *, void *, register_t *));
+int sys_write __P((struct proc *, void *, register_t *));
+int freebsd_sys_open __P((struct proc *, void *, register_t *));
+int sys_close __P((struct proc *, void *, register_t *));
+int sys_wait4 __P((struct proc *, void *, register_t *));
+int compat_43_freebsd_sys_creat __P((struct proc *, void *, register_t *));
+int freebsd_sys_link __P((struct proc *, void *, register_t *));
+int freebsd_sys_unlink __P((struct proc *, void *, register_t *));
+int freebsd_sys_chdir __P((struct proc *, void *, register_t *));
+int sys_fchdir __P((struct proc *, void *, register_t *));
+int freebsd_sys_mknod __P((struct proc *, void *, register_t *));
+int freebsd_sys_chmod __P((struct proc *, void *, register_t *));
+int freebsd_sys_chown __P((struct proc *, void *, register_t *));
+int sys_obreak __P((struct proc *, void *, register_t *));
+int sys_getfsstat __P((struct proc *, void *, register_t *));
+int compat_43_sys_lseek __P((struct proc *, void *, register_t *));
+int sys_getpid __P((struct proc *, void *, register_t *));
+int freebsd_sys_mount __P((struct proc *, void *, register_t *));
+int freebsd_sys_unmount __P((struct proc *, void *, register_t *));
+int sys_setuid __P((struct proc *, void *, register_t *));
+int sys_getuid __P((struct proc *, void *, register_t *));
+int sys_geteuid __P((struct proc *, void *, register_t *));
+int freebsd_sys_ptrace __P((struct proc *, void *, register_t *));
+int sys_recvmsg __P((struct proc *, void *, register_t *));
+int sys_sendmsg __P((struct proc *, void *, register_t *));
+int sys_recvfrom __P((struct proc *, void *, register_t *));
+int sys_accept __P((struct proc *, void *, register_t *));
+int sys_getpeername __P((struct proc *, void *, register_t *));
+int sys_getsockname __P((struct proc *, void *, register_t *));
+int freebsd_sys_access __P((struct proc *, void *, register_t *));
+int freebsd_sys_chflags __P((struct proc *, void *, register_t *));
+int sys_fchflags __P((struct proc *, void *, register_t *));
+int sys_sync __P((struct proc *, void *, register_t *));
+int sys_kill __P((struct proc *, void *, register_t *));
+int compat_43_freebsd_sys_stat __P((struct proc *, void *, register_t *));
+int getppid __P((struct proc *, void *, register_t *));
+int compat_43_freebsd_sys_lstat __P((struct proc *, void *, register_t *));
+int sys_dup __P((struct proc *, void *, register_t *));
+int sys_pipe __P((struct proc *, void *, register_t *));
+int sys_getegid __P((struct proc *, void *, register_t *));
+int sys_profil __P((struct proc *, void *, register_t *));
+#ifdef KTRACE
+int sys_ktrace __P((struct proc *, void *, register_t *));
+#else
+#endif
+int sys_sigaction __P((struct proc *, void *, register_t *));
+int sys_getgid __P((struct proc *, void *, register_t *));
+int sys_sigprocmask __P((struct proc *, void *, register_t *));
+int sys_getlogin __P((struct proc *, void *, register_t *));
+int sys_setlogin __P((struct proc *, void *, register_t *));
+int sys_acct __P((struct proc *, void *, register_t *));
+int sys_sigpending __P((struct proc *, void *, register_t *));
+int sys_sigaltstack __P((struct proc *, void *, register_t *));
+int freebsd_sys_ioctl __P((struct proc *, void *, register_t *));
+int sys_reboot __P((struct proc *, void *, register_t *));
+int freebsd_sys_revoke __P((struct proc *, void *, register_t *));
+int freebsd_sys_symlink __P((struct proc *, void *, register_t *));
+int freebsd_sys_readlink __P((struct proc *, void *, register_t *));
+int freebsd_sys_execve __P((struct proc *, void *, register_t *));
+int sys_umask __P((struct proc *, void *, register_t *));
+int freebsd_sys_chroot __P((struct proc *, void *, register_t *));
+int compat_43_sys_fstat __P((struct proc *, void *, register_t *));
+int compat_43_sys_getkerninfo __P((struct proc *, void *, register_t *));
+int compat_43_sys_getpagesize __P((struct proc *, void *, register_t *));
+int freebsd_sys_msync __P((struct proc *, void *, register_t *));
+int sys_vfork __P((struct proc *, void *, register_t *));
+int sys_sbrk __P((struct proc *, void *, register_t *));
+int sys_sstk __P((struct proc *, void *, register_t *));
+int compat_43_sys_mmap __P((struct proc *, void *, register_t *));
+int sys_ovadvise __P((struct proc *, void *, register_t *));
+int sys_munmap __P((struct proc *, void *, register_t *));
+int sys_mprotect __P((struct proc *, void *, register_t *));
+int sys_madvise __P((struct proc *, void *, register_t *));
+int sys_mincore __P((struct proc *, void *, register_t *));
+int sys_getgroups __P((struct proc *, void *, register_t *));
+int sys_setgroups __P((struct proc *, void *, register_t *));
+int sys_getpgrp __P((struct proc *, void *, register_t *));
+int sys_setpgid __P((struct proc *, void *, register_t *));
+int sys_setitimer __P((struct proc *, void *, register_t *));
+int compat_43_sys_wait __P((struct proc *, void *, register_t *));
+int sys_swapon __P((struct proc *, void *, register_t *));
+int sys_getitimer __P((struct proc *, void *, register_t *));
+int compat_43_sys_gethostname __P((struct proc *, void *, register_t *));
+int compat_43_sys_sethostname __P((struct proc *, void *, register_t *));
+int compat_43_sys_getdtablesize __P((struct proc *, void *, register_t *));
+int sys_dup2 __P((struct proc *, void *, register_t *));
+int sys_fcntl __P((struct proc *, void *, register_t *));
+int sys_select __P((struct proc *, void *, register_t *));
+int sys_fsync __P((struct proc *, void *, register_t *));
+int sys_setpriority __P((struct proc *, void *, register_t *));
+int sys_socket __P((struct proc *, void *, register_t *));
+int sys_connect __P((struct proc *, void *, register_t *));
+int compat_43_sys_accept __P((struct proc *, void *, register_t *));
+int sys_getpriority __P((struct proc *, void *, register_t *));
+int compat_43_sys_send __P((struct proc *, void *, register_t *));
+int compat_43_sys_recv __P((struct proc *, void *, register_t *));
+int freebsd_sys_sigreturn __P((struct proc *, void *, register_t *));
+int sys_bind __P((struct proc *, void *, register_t *));
+int sys_setsockopt __P((struct proc *, void *, register_t *));
+int sys_listen __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigvec __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigblock __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigsetmask __P((struct proc *, void *, register_t *));
+int sys_sigsuspend __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigstack __P((struct proc *, void *, register_t *));
+int compat_43_sys_recvmsg __P((struct proc *, void *, register_t *));
+int compat_43_sys_sendmsg __P((struct proc *, void *, register_t *));
+#ifdef TRACE
+int sys_vtrace __P((struct proc *, void *, register_t *));
+#else
+#endif
+int sys_gettimeofday __P((struct proc *, void *, register_t *));
+int sys_getrusage __P((struct proc *, void *, register_t *));
+int sys_getsockopt __P((struct proc *, void *, register_t *));
+int sys_readv __P((struct proc *, void *, register_t *));
+int sys_writev __P((struct proc *, void *, register_t *));
+int sys_settimeofday __P((struct proc *, void *, register_t *));
+int sys_fchown __P((struct proc *, void *, register_t *));
+int sys_fchmod __P((struct proc *, void *, register_t *));
+int compat_43_sys_recvfrom __P((struct proc *, void *, register_t *));
+int compat_43_sys_setreuid __P((struct proc *, void *, register_t *));
+int compat_43_sys_setregid __P((struct proc *, void *, register_t *));
+int freebsd_sys_rename __P((struct proc *, void *, register_t *));
+int compat_43_freebsd_sys_truncate __P((struct proc *, void *, register_t *));
+int compat_43_sys_ftruncate __P((struct proc *, void *, register_t *));
+int sys_flock __P((struct proc *, void *, register_t *));
+int freebsd_sys_mkfifo __P((struct proc *, void *, register_t *));
+int sys_sendto __P((struct proc *, void *, register_t *));
+int sys_shutdown __P((struct proc *, void *, register_t *));
+int sys_socketpair __P((struct proc *, void *, register_t *));
+int freebsd_sys_mkdir __P((struct proc *, void *, register_t *));
+int freebsd_sys_rmdir __P((struct proc *, void *, register_t *));
+int sys_utimes __P((struct proc *, void *, register_t *));
+int sys_adjtime __P((struct proc *, void *, register_t *));
+int compat_43_sys_getpeername __P((struct proc *, void *, register_t *));
+int compat_43_sys_gethostid __P((struct proc *, void *, register_t *));
+int compat_43_sys_sethostid __P((struct proc *, void *, register_t *));
+int compat_43_sys_getrlimit __P((struct proc *, void *, register_t *));
+int compat_43_sys_setrlimit __P((struct proc *, void *, register_t *));
+int compat_43_sys_killpg __P((struct proc *, void *, register_t *));
+int sys_setsid __P((struct proc *, void *, register_t *));
+int sys_quotactl __P((struct proc *, void *, register_t *));
+int compat_43_sys_quota __P((struct proc *, void *, register_t *));
+int compat_43_sys_getsockname __P((struct proc *, void *, register_t *));
+#if defined(NFSCLIENT) || defined(NFSSERVER)
+int sys_nfssvc __P((struct proc *, void *, register_t *));
+#else
+#endif
+int compat_43_sys_getdirentries __P((struct proc *, void *, register_t *));
+int freebsd_sys_statfs __P((struct proc *, void *, register_t *));
+int sys_fstatfs __P((struct proc *, void *, register_t *));
+#ifdef NFSCLIENT
+int freebsd_sys_getfh __P((struct proc *, void *, register_t *));
+#else
+#endif
+int compat_09_sys_getdomainname __P((struct proc *, void *, register_t *));
+int compat_09_sys_setdomainname __P((struct proc *, void *, register_t *));
+int compat_09_sys_uname __P((struct proc *, void *, register_t *));
+int sys_sysarch __P((struct proc *, void *, register_t *));
+int freebsd_sys_rtprio __P((struct proc *, void *, register_t *));
+#if defined(SYSVSEM) && !defined(alpha)
+int compat_10_sys_semsys __P((struct proc *, void *, register_t *));
+#else
+#endif
+#if defined(SYSVMSG) && !defined(alpha)
+int compat_10_sys_msgsys __P((struct proc *, void *, register_t *));
+#else
+#endif
+#if defined(SYSVSHM) && !defined(alpha)
+int compat_10_sys_shmsys __P((struct proc *, void *, register_t *));
+#else
+#endif
+int freebsd_ntp_adjtime __P((struct proc *, void *, register_t *));
+int sys_setgid __P((struct proc *, void *, register_t *));
+int sys_setegid __P((struct proc *, void *, register_t *));
+int sys_seteuid __P((struct proc *, void *, register_t *));
+#ifdef LFS
+int lfs_bmapv __P((struct proc *, void *, register_t *));
+int lfs_markv __P((struct proc *, void *, register_t *));
+int lfs_segclean __P((struct proc *, void *, register_t *));
+int lfs_segwait __P((struct proc *, void *, register_t *));
+#else
+#endif
+int freebsd_sys_stat __P((struct proc *, void *, register_t *));
+int sys_fstat __P((struct proc *, void *, register_t *));
+int freebsd_sys_lstat __P((struct proc *, void *, register_t *));
+int freebsd_sys_pathconf __P((struct proc *, void *, register_t *));
+int sys_fpathconf __P((struct proc *, void *, register_t *));
+int sys_getrlimit __P((struct proc *, void *, register_t *));
+int sys_setrlimit __P((struct proc *, void *, register_t *));
+int sys_getdirentries __P((struct proc *, void *, register_t *));
+int sys_mmap __P((struct proc *, void *, register_t *));
+int sys_nosys __P((struct proc *, void *, register_t *));
+int sys_lseek __P((struct proc *, void *, register_t *));
+int freebsd_sys_truncate __P((struct proc *, void *, register_t *));
+int sys_ftruncate __P((struct proc *, void *, register_t *));
+int sys___sysctl __P((struct proc *, void *, register_t *));
+int sys_mlock __P((struct proc *, void *, register_t *));
+int sys_munlock __P((struct proc *, void *, register_t *));
+#ifdef FREEBSD_BASED_ON_44LITE_R2
+int freebsd_sys_undelete __P((struct proc *, void *, register_t *));
+#else
+#endif
diff --git a/sys/compat/freebsd/freebsd_syscalls.c b/sys/compat/freebsd/freebsd_syscalls.c
new file mode 100644
index 00000000000..0131c0fbcf7
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_syscalls.c
@@ -0,0 +1,268 @@
+/*
+ * System call names.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.2 1995/10/10 01:34:37 mycroft Exp
+ */
+
+char *freebsd_syscallnames[] = {
+ "syscall", /* 0 = syscall */
+ "exit", /* 1 = exit */
+ "fork", /* 2 = fork */
+ "read", /* 3 = read */
+ "write", /* 4 = write */
+ "open", /* 5 = open */
+ "close", /* 6 = close */
+ "wait4", /* 7 = wait4 */
+ "ocreat", /* 8 = ocreat */
+ "link", /* 9 = link */
+ "unlink", /* 10 = unlink */
+ "#11 (obsolete execv)", /* 11 = obsolete execv */
+ "chdir", /* 12 = chdir */
+ "fchdir", /* 13 = fchdir */
+ "mknod", /* 14 = mknod */
+ "chmod", /* 15 = chmod */
+ "chown", /* 16 = chown */
+ "break", /* 17 = break */
+ "getfsstat", /* 18 = getfsstat */
+ "olseek", /* 19 = olseek */
+ "getpid", /* 20 = getpid */
+ "mount", /* 21 = mount */
+ "unmount", /* 22 = unmount */
+ "setuid", /* 23 = setuid */
+ "getuid", /* 24 = getuid */
+ "geteuid", /* 25 = geteuid */
+ "ptrace", /* 26 = ptrace */
+ "recvmsg", /* 27 = recvmsg */
+ "sendmsg", /* 28 = sendmsg */
+ "recvfrom", /* 29 = recvfrom */
+ "accept", /* 30 = accept */
+ "getpeername", /* 31 = getpeername */
+ "getsockname", /* 32 = getsockname */
+ "access", /* 33 = access */
+ "chflags", /* 34 = chflags */
+ "fchflags", /* 35 = fchflags */
+ "sync", /* 36 = sync */
+ "kill", /* 37 = kill */
+ "ostat", /* 38 = ostat */
+ "getppid", /* 39 = getppid */
+ "olstat", /* 40 = olstat */
+ "dup", /* 41 = dup */
+ "pipe", /* 42 = pipe */
+ "getegid", /* 43 = getegid */
+ "profil", /* 44 = profil */
+#ifdef KTRACE
+ "ktrace", /* 45 = ktrace */
+#else
+ "#45 (unimplemented ktrace)", /* 45 = unimplemented ktrace */
+#endif
+ "sigaction", /* 46 = sigaction */
+ "getgid", /* 47 = getgid */
+ "sigprocmask", /* 48 = sigprocmask */
+ "getlogin", /* 49 = getlogin */
+ "setlogin", /* 50 = setlogin */
+ "acct", /* 51 = acct */
+ "sigpending", /* 52 = sigpending */
+ "sigaltstack", /* 53 = sigaltstack */
+ "ioctl", /* 54 = ioctl */
+ "reboot", /* 55 = reboot */
+ "revoke", /* 56 = revoke */
+ "symlink", /* 57 = symlink */
+ "readlink", /* 58 = readlink */
+ "execve", /* 59 = execve */
+ "umask", /* 60 = umask */
+ "chroot", /* 61 = chroot */
+ "ofstat", /* 62 = ofstat */
+ "ogetkerninfo", /* 63 = ogetkerninfo */
+ "ogetpagesize", /* 64 = ogetpagesize */
+ "msync", /* 65 = msync */
+ "vfork", /* 66 = vfork */
+ "#67 (obsolete vread)", /* 67 = obsolete vread */
+ "#68 (obsolete vwrite)", /* 68 = obsolete vwrite */
+ "sbrk", /* 69 = sbrk */
+ "sstk", /* 70 = sstk */
+ "ommap", /* 71 = ommap */
+ "vadvise", /* 72 = vadvise */
+ "munmap", /* 73 = munmap */
+ "mprotect", /* 74 = mprotect */
+ "madvise", /* 75 = madvise */
+ "#76 (obsolete vhangup)", /* 76 = obsolete vhangup */
+ "#77 (obsolete vlimit)", /* 77 = obsolete vlimit */
+ "mincore", /* 78 = mincore */
+ "getgroups", /* 79 = getgroups */
+ "setgroups", /* 80 = setgroups */
+ "getpgrp", /* 81 = getpgrp */
+ "setpgid", /* 82 = setpgid */
+ "setitimer", /* 83 = setitimer */
+ "owait", /* 84 = owait */
+ "swapon", /* 85 = swapon */
+ "getitimer", /* 86 = getitimer */
+ "ogethostname", /* 87 = ogethostname */
+ "osethostname", /* 88 = osethostname */
+ "ogetdtablesize", /* 89 = ogetdtablesize */
+ "dup2", /* 90 = dup2 */
+ "#91 (unimplemented getdopt)", /* 91 = unimplemented getdopt */
+ "fcntl", /* 92 = fcntl */
+ "select", /* 93 = select */
+ "#94 (unimplemented setdopt)", /* 94 = unimplemented setdopt */
+ "fsync", /* 95 = fsync */
+ "setpriority", /* 96 = setpriority */
+ "socket", /* 97 = socket */
+ "connect", /* 98 = connect */
+ "oaccept", /* 99 = oaccept */
+ "getpriority", /* 100 = getpriority */
+ "osend", /* 101 = osend */
+ "orecv", /* 102 = orecv */
+ "sigreturn", /* 103 = sigreturn */
+ "bind", /* 104 = bind */
+ "setsockopt", /* 105 = setsockopt */
+ "listen", /* 106 = listen */
+ "#107 (obsolete vtimes)", /* 107 = obsolete vtimes */
+ "osigvec", /* 108 = osigvec */
+ "osigblock", /* 109 = osigblock */
+ "osigsetmask", /* 110 = osigsetmask */
+ "sigsuspend", /* 111 = sigsuspend */
+ "osigstack", /* 112 = osigstack */
+ "orecvmsg", /* 113 = orecvmsg */
+ "osendmsg", /* 114 = osendmsg */
+#ifdef TRACE
+ "vtrace", /* 115 = vtrace */
+#else
+ "#115 (obsolete vtrace)", /* 115 = obsolete vtrace */
+#endif
+ "gettimeofday", /* 116 = gettimeofday */
+ "getrusage", /* 117 = getrusage */
+ "getsockopt", /* 118 = getsockopt */
+ "#119 (obsolete resuba)", /* 119 = obsolete resuba */
+ "readv", /* 120 = readv */
+ "writev", /* 121 = writev */
+ "settimeofday", /* 122 = settimeofday */
+ "fchown", /* 123 = fchown */
+ "fchmod", /* 124 = fchmod */
+ "orecvfrom", /* 125 = orecvfrom */
+ "osetreuid", /* 126 = osetreuid */
+ "osetregid", /* 127 = osetregid */
+ "rename", /* 128 = rename */
+ "otruncate", /* 129 = otruncate */
+ "oftruncate", /* 130 = oftruncate */
+ "flock", /* 131 = flock */
+ "mkfifo", /* 132 = mkfifo */
+ "sendto", /* 133 = sendto */
+ "shutdown", /* 134 = shutdown */
+ "socketpair", /* 135 = socketpair */
+ "mkdir", /* 136 = mkdir */
+ "rmdir", /* 137 = rmdir */
+ "utimes", /* 138 = utimes */
+ "#139 (obsolete 4.2 sigreturn)", /* 139 = obsolete 4.2 sigreturn */
+ "adjtime", /* 140 = adjtime */
+ "ogetpeername", /* 141 = ogetpeername */
+ "ogethostid", /* 142 = ogethostid */
+ "osethostid", /* 143 = osethostid */
+ "ogetrlimit", /* 144 = ogetrlimit */
+ "osetrlimit", /* 145 = osetrlimit */
+ "okillpg", /* 146 = okillpg */
+ "setsid", /* 147 = setsid */
+ "quotactl", /* 148 = quotactl */
+ "oquota", /* 149 = oquota */
+ "ogetsockname", /* 150 = ogetsockname */
+ "#151 (unimplemented)", /* 151 = unimplemented */
+ "#152 (unimplemented)", /* 152 = unimplemented */
+ "#153 (unimplemented)", /* 153 = unimplemented */
+ "#154 (unimplemented)", /* 154 = unimplemented */
+#if defined(NFSCLIENT) || defined(NFSSERVER)
+ "nfssvc", /* 155 = nfssvc */
+#else
+ "#155 (unimplemented)", /* 155 = unimplemented */
+#endif
+ "ogetdirentries", /* 156 = ogetdirentries */
+ "statfs", /* 157 = statfs */
+ "fstatfs", /* 158 = fstatfs */
+ "#159 (unimplemented)", /* 159 = unimplemented */
+ "#160 (unimplemented)", /* 160 = unimplemented */
+#ifdef NFSCLIENT
+ "getfh", /* 161 = getfh */
+#else
+ "#161 (unimplemented getfh)", /* 161 = unimplemented getfh */
+#endif
+ "getdomainname", /* 162 = getdomainname */
+ "setdomainname", /* 163 = setdomainname */
+ "uname", /* 164 = uname */
+ "sysarch", /* 165 = sysarch */
+ "rtprio", /* 166 = rtprio */
+ "#167 (unimplemented)", /* 167 = unimplemented */
+ "#168 (unimplemented)", /* 168 = unimplemented */
+#if defined(SYSVSEM) && !defined(alpha)
+ "semsys", /* 169 = semsys */
+#else
+ "#169 (unimplemented 1.0 semsys)", /* 169 = unimplemented 1.0 semsys */
+#endif
+#if defined(SYSVMSG) && !defined(alpha)
+ "msgsys", /* 170 = msgsys */
+#else
+ "#170 (unimplemented 1.0 msgsys)", /* 170 = unimplemented 1.0 msgsys */
+#endif
+#if defined(SYSVSHM) && !defined(alpha)
+ "shmsys", /* 171 = shmsys */
+#else
+ "#171 (unimplemented 1.0 shmsys)", /* 171 = unimplemented 1.0 shmsys */
+#endif
+ "#172 (unimplemented)", /* 172 = unimplemented */
+ "#173 (unimplemented)", /* 173 = unimplemented */
+ "#174 (unimplemented)", /* 174 = unimplemented */
+ "#175 (unimplemented)", /* 175 = unimplemented */
+ "freebsd_ntp_adjtime", /* 176 = freebsd_ntp_adjtime */
+ "#177 (unimplemented)", /* 177 = unimplemented */
+ "#178 (unimplemented)", /* 178 = unimplemented */
+ "#179 (unimplemented)", /* 179 = unimplemented */
+ "#180 (unimplemented)", /* 180 = unimplemented */
+ "setgid", /* 181 = setgid */
+ "setegid", /* 182 = setegid */
+ "seteuid", /* 183 = seteuid */
+#ifdef LFS
+ "lfs_bmapv", /* 184 = lfs_bmapv */
+ "lfs_markv", /* 185 = lfs_markv */
+ "lfs_segclean", /* 186 = lfs_segclean */
+ "lfs_segwait", /* 187 = lfs_segwait */
+#else
+ "#184 (unimplemented)", /* 184 = unimplemented */
+ "#185 (unimplemented)", /* 185 = unimplemented */
+ "#186 (unimplemented)", /* 186 = unimplemented */
+ "#187 (unimplemented)", /* 187 = unimplemented */
+#endif
+ "stat", /* 188 = stat */
+ "fstat", /* 189 = fstat */
+ "lstat", /* 190 = lstat */
+ "pathconf", /* 191 = pathconf */
+ "fpathconf", /* 192 = fpathconf */
+ "#193 (unimplemented)", /* 193 = unimplemented */
+ "getrlimit", /* 194 = getrlimit */
+ "setrlimit", /* 195 = setrlimit */
+ "getdirentries", /* 196 = getdirentries */
+ "mmap", /* 197 = mmap */
+ "__syscall", /* 198 = __syscall */
+ "lseek", /* 199 = lseek */
+ "truncate", /* 200 = truncate */
+ "ftruncate", /* 201 = ftruncate */
+ "__sysctl", /* 202 = __sysctl */
+ "mlock", /* 203 = mlock */
+ "munlock", /* 204 = munlock */
+#ifdef FREEBSD_BASED_ON_44LITE_R2
+ "undelete", /* 205 = undelete */
+#else
+ "#205 (unimplemented)", /* 205 = unimplemented */
+#endif
+ "#206 (unimplemented)", /* 206 = unimplemented */
+ "#207 (unimplemented)", /* 207 = unimplemented */
+ "#208 (unimplemented)", /* 208 = unimplemented */
+ "#209 (unimplemented)", /* 209 = unimplemented */
+ "#210 (unimplemented)", /* 210 = unimplemented */
+ "#211 (unimplemented)", /* 211 = unimplemented */
+ "#212 (unimplemented)", /* 212 = unimplemented */
+ "#213 (unimplemented)", /* 213 = unimplemented */
+ "#214 (unimplemented)", /* 214 = unimplemented */
+ "#215 (unimplemented)", /* 215 = unimplemented */
+ "#216 (unimplemented)", /* 216 = unimplemented */
+ "#217 (unimplemented)", /* 217 = unimplemented */
+ "#218 (unimplemented)", /* 218 = unimplemented */
+ "#219 (unimplemented)", /* 219 = unimplemented */
+};
diff --git a/sys/compat/freebsd/freebsd_sysent.c b/sys/compat/freebsd/freebsd_sysent.c
new file mode 100644
index 00000000000..c27f763b7c3
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_sysent.c
@@ -0,0 +1,511 @@
+/*
+ * System call switch table.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.2 1995/10/10 01:34:37 mycroft Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signal.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <compat/freebsd/freebsd_syscallargs.h>
+#include <machine/freebsd_machdep.h>
+
+#define s(type) sizeof(type)
+
+struct sysent freebsd_sysent[] = {
+ { 0, 0,
+ sys_nosys }, /* 0 = syscall */
+ { 1, s(struct sys_exit_args),
+ sys_exit }, /* 1 = exit */
+ { 0, 0,
+ sys_fork }, /* 2 = fork */
+ { 3, s(struct sys_read_args),
+ sys_read }, /* 3 = read */
+ { 3, s(struct sys_write_args),
+ sys_write }, /* 4 = write */
+ { 3, s(struct freebsd_sys_open_args),
+ freebsd_sys_open }, /* 5 = open */
+ { 1, s(struct sys_close_args),
+ sys_close }, /* 6 = close */
+ { 4, s(struct sys_wait4_args),
+ sys_wait4 }, /* 7 = wait4 */
+ { 2, s(struct compat_43_freebsd_sys_creat_args),
+ compat_43_freebsd_sys_creat }, /* 8 = ocreat */
+ { 2, s(struct freebsd_sys_link_args),
+ freebsd_sys_link }, /* 9 = link */
+ { 1, s(struct freebsd_sys_unlink_args),
+ freebsd_sys_unlink }, /* 10 = unlink */
+ { 0, 0,
+ sys_nosys }, /* 11 = obsolete execv */
+ { 1, s(struct freebsd_sys_chdir_args),
+ freebsd_sys_chdir }, /* 12 = chdir */
+ { 1, s(struct sys_fchdir_args),
+ sys_fchdir }, /* 13 = fchdir */
+ { 3, s(struct freebsd_sys_mknod_args),
+ freebsd_sys_mknod }, /* 14 = mknod */
+ { 2, s(struct freebsd_sys_chmod_args),
+ freebsd_sys_chmod }, /* 15 = chmod */
+ { 3, s(struct freebsd_sys_chown_args),
+ freebsd_sys_chown }, /* 16 = chown */
+ { 1, s(struct sys_obreak_args),
+ sys_obreak }, /* 17 = break */
+ { 3, s(struct sys_getfsstat_args),
+ sys_getfsstat }, /* 18 = getfsstat */
+ { 3, s(struct compat_43_sys_lseek_args),
+ compat_43_sys_lseek }, /* 19 = olseek */
+ { 0, 0,
+ sys_getpid }, /* 20 = getpid */
+ { 4, s(struct freebsd_sys_mount_args),
+ freebsd_sys_mount }, /* 21 = mount */
+ { 2, s(struct freebsd_sys_unmount_args),
+ freebsd_sys_unmount }, /* 22 = unmount */
+ { 1, s(struct sys_setuid_args),
+ sys_setuid }, /* 23 = setuid */
+ { 0, 0,
+ sys_getuid }, /* 24 = getuid */
+ { 0, 0,
+ sys_geteuid }, /* 25 = geteuid */
+ { 4, s(struct freebsd_sys_ptrace_args),
+ freebsd_sys_ptrace }, /* 26 = ptrace */
+ { 3, s(struct sys_recvmsg_args),
+ sys_recvmsg }, /* 27 = recvmsg */
+ { 3, s(struct sys_sendmsg_args),
+ sys_sendmsg }, /* 28 = sendmsg */
+ { 6, s(struct sys_recvfrom_args),
+ sys_recvfrom }, /* 29 = recvfrom */
+ { 3, s(struct sys_accept_args),
+ sys_accept }, /* 30 = accept */
+ { 3, s(struct sys_getpeername_args),
+ sys_getpeername }, /* 31 = getpeername */
+ { 3, s(struct sys_getsockname_args),
+ sys_getsockname }, /* 32 = getsockname */
+ { 2, s(struct freebsd_sys_access_args),
+ freebsd_sys_access }, /* 33 = access */
+ { 2, s(struct freebsd_sys_chflags_args),
+ freebsd_sys_chflags }, /* 34 = chflags */
+ { 2, s(struct sys_fchflags_args),
+ sys_fchflags }, /* 35 = fchflags */
+ { 0, 0,
+ sys_sync }, /* 36 = sync */
+ { 2, s(struct sys_kill_args),
+ sys_kill }, /* 37 = kill */
+ { 2, s(struct compat_43_freebsd_sys_stat_args),
+ compat_43_freebsd_sys_stat }, /* 38 = ostat */
+ { 0, 0,
+ getppid }, /* 39 = getppid */
+ { 2, s(struct compat_43_freebsd_sys_lstat_args),
+ compat_43_freebsd_sys_lstat }, /* 40 = olstat */
+ { 1, s(struct sys_dup_args),
+ sys_dup }, /* 41 = dup */
+ { 0, 0,
+ sys_pipe }, /* 42 = pipe */
+ { 0, 0,
+ sys_getegid }, /* 43 = getegid */
+ { 4, s(struct sys_profil_args),
+ sys_profil }, /* 44 = profil */
+#ifdef KTRACE
+ { 4, s(struct sys_ktrace_args),
+ sys_ktrace }, /* 45 = ktrace */
+#else
+ { 0, 0,
+ sys_nosys }, /* 45 = unimplemented ktrace */
+#endif
+ { 3, s(struct sys_sigaction_args),
+ sys_sigaction }, /* 46 = sigaction */
+ { 0, 0,
+ sys_getgid }, /* 47 = getgid */
+ { 2, s(struct sys_sigprocmask_args),
+ sys_sigprocmask }, /* 48 = sigprocmask */
+ { 2, s(struct sys_getlogin_args),
+ sys_getlogin }, /* 49 = getlogin */
+ { 1, s(struct sys_setlogin_args),
+ sys_setlogin }, /* 50 = setlogin */
+ { 1, s(struct sys_acct_args),
+ sys_acct }, /* 51 = acct */
+ { 0, 0,
+ sys_sigpending }, /* 52 = sigpending */
+ { 2, s(struct sys_sigaltstack_args),
+ sys_sigaltstack }, /* 53 = sigaltstack */
+ { 3, s(struct freebsd_sys_ioctl_args),
+ freebsd_sys_ioctl }, /* 54 = ioctl */
+ { 1, s(struct sys_reboot_args),
+ sys_reboot }, /* 55 = reboot */
+ { 1, s(struct freebsd_sys_revoke_args),
+ freebsd_sys_revoke }, /* 56 = revoke */
+ { 2, s(struct freebsd_sys_symlink_args),
+ freebsd_sys_symlink }, /* 57 = symlink */
+ { 3, s(struct freebsd_sys_readlink_args),
+ freebsd_sys_readlink }, /* 58 = readlink */
+ { 3, s(struct freebsd_sys_execve_args),
+ freebsd_sys_execve }, /* 59 = execve */
+ { 1, s(struct sys_umask_args),
+ sys_umask }, /* 60 = umask */
+ { 1, s(struct freebsd_sys_chroot_args),
+ freebsd_sys_chroot }, /* 61 = chroot */
+ { 2, s(struct compat_43_sys_fstat_args),
+ compat_43_sys_fstat }, /* 62 = ofstat */
+ { 4, s(struct compat_43_sys_getkerninfo_args),
+ compat_43_sys_getkerninfo }, /* 63 = ogetkerninfo */
+ { 0, 0,
+ compat_43_sys_getpagesize }, /* 64 = ogetpagesize */
+ { 3, s(struct freebsd_sys_msync_args),
+ freebsd_sys_msync }, /* 65 = msync */
+ { 0, 0,
+ sys_vfork }, /* 66 = vfork */
+ { 0, 0,
+ sys_nosys }, /* 67 = obsolete vread */
+ { 0, 0,
+ sys_nosys }, /* 68 = obsolete vwrite */
+ { 1, s(struct sys_sbrk_args),
+ sys_sbrk }, /* 69 = sbrk */
+ { 1, s(struct sys_sstk_args),
+ sys_sstk }, /* 70 = sstk */
+ { 6, s(struct compat_43_sys_mmap_args),
+ compat_43_sys_mmap }, /* 71 = ommap */
+ { 1, s(struct sys_ovadvise_args),
+ sys_ovadvise }, /* 72 = vadvise */
+ { 2, s(struct sys_munmap_args),
+ sys_munmap }, /* 73 = munmap */
+ { 3, s(struct sys_mprotect_args),
+ sys_mprotect }, /* 74 = mprotect */
+ { 3, s(struct sys_madvise_args),
+ sys_madvise }, /* 75 = madvise */
+ { 0, 0,
+ sys_nosys }, /* 76 = obsolete vhangup */
+ { 0, 0,
+ sys_nosys }, /* 77 = obsolete vlimit */
+ { 3, s(struct sys_mincore_args),
+ sys_mincore }, /* 78 = mincore */
+ { 2, s(struct sys_getgroups_args),
+ sys_getgroups }, /* 79 = getgroups */
+ { 2, s(struct sys_setgroups_args),
+ sys_setgroups }, /* 80 = setgroups */
+ { 0, 0,
+ sys_getpgrp }, /* 81 = getpgrp */
+ { 2, s(struct sys_setpgid_args),
+ sys_setpgid }, /* 82 = setpgid */
+ { 3, s(struct sys_setitimer_args),
+ sys_setitimer }, /* 83 = setitimer */
+ { 0, 0,
+ compat_43_sys_wait }, /* 84 = owait */
+ { 1, s(struct sys_swapon_args),
+ sys_swapon }, /* 85 = swapon */
+ { 2, s(struct sys_getitimer_args),
+ sys_getitimer }, /* 86 = getitimer */
+ { 2, s(struct compat_43_sys_gethostname_args),
+ compat_43_sys_gethostname }, /* 87 = ogethostname */
+ { 2, s(struct compat_43_sys_sethostname_args),
+ compat_43_sys_sethostname }, /* 88 = osethostname */
+ { 0, 0,
+ compat_43_sys_getdtablesize }, /* 89 = ogetdtablesize */
+ { 2, s(struct sys_dup2_args),
+ sys_dup2 }, /* 90 = dup2 */
+ { 0, 0,
+ sys_nosys }, /* 91 = unimplemented getdopt */
+ { 3, s(struct sys_fcntl_args),
+ sys_fcntl }, /* 92 = fcntl */
+ { 5, s(struct sys_select_args),
+ sys_select }, /* 93 = select */
+ { 0, 0,
+ sys_nosys }, /* 94 = unimplemented setdopt */
+ { 1, s(struct sys_fsync_args),
+ sys_fsync }, /* 95 = fsync */
+ { 3, s(struct sys_setpriority_args),
+ sys_setpriority }, /* 96 = setpriority */
+ { 3, s(struct sys_socket_args),
+ sys_socket }, /* 97 = socket */
+ { 3, s(struct sys_connect_args),
+ sys_connect }, /* 98 = connect */
+ { 3, s(struct compat_43_sys_accept_args),
+ compat_43_sys_accept }, /* 99 = oaccept */
+ { 2, s(struct sys_getpriority_args),
+ sys_getpriority }, /* 100 = getpriority */
+ { 4, s(struct compat_43_sys_send_args),
+ compat_43_sys_send }, /* 101 = osend */
+ { 4, s(struct compat_43_sys_recv_args),
+ compat_43_sys_recv }, /* 102 = orecv */
+ { 1, s(struct freebsd_sys_sigreturn_args),
+ freebsd_sys_sigreturn }, /* 103 = sigreturn */
+ { 3, s(struct sys_bind_args),
+ sys_bind }, /* 104 = bind */
+ { 5, s(struct sys_setsockopt_args),
+ sys_setsockopt }, /* 105 = setsockopt */
+ { 2, s(struct sys_listen_args),
+ sys_listen }, /* 106 = listen */
+ { 0, 0,
+ sys_nosys }, /* 107 = obsolete vtimes */
+ { 3, s(struct compat_43_sys_sigvec_args),
+ compat_43_sys_sigvec }, /* 108 = osigvec */
+ { 1, s(struct compat_43_sys_sigblock_args),
+ compat_43_sys_sigblock }, /* 109 = osigblock */
+ { 1, s(struct compat_43_sys_sigsetmask_args),
+ compat_43_sys_sigsetmask }, /* 110 = osigsetmask */
+ { 1, s(struct sys_sigsuspend_args),
+ sys_sigsuspend }, /* 111 = sigsuspend */
+ { 2, s(struct compat_43_sys_sigstack_args),
+ compat_43_sys_sigstack }, /* 112 = osigstack */
+ { 3, s(struct compat_43_sys_recvmsg_args),
+ compat_43_sys_recvmsg }, /* 113 = orecvmsg */
+ { 3, s(struct compat_43_sys_sendmsg_args),
+ compat_43_sys_sendmsg }, /* 114 = osendmsg */
+#ifdef TRACE
+ { 2, s(struct sys_vtrace_args),
+ sys_vtrace }, /* 115 = vtrace */
+#else
+ { 0, 0,
+ sys_nosys }, /* 115 = obsolete vtrace */
+#endif
+ { 2, s(struct sys_gettimeofday_args),
+ sys_gettimeofday }, /* 116 = gettimeofday */
+ { 2, s(struct sys_getrusage_args),
+ sys_getrusage }, /* 117 = getrusage */
+ { 5, s(struct sys_getsockopt_args),
+ sys_getsockopt }, /* 118 = getsockopt */
+ { 0, 0,
+ sys_nosys }, /* 119 = obsolete resuba */
+ { 3, s(struct sys_readv_args),
+ sys_readv }, /* 120 = readv */
+ { 3, s(struct sys_writev_args),
+ sys_writev }, /* 121 = writev */
+ { 2, s(struct sys_settimeofday_args),
+ sys_settimeofday }, /* 122 = settimeofday */
+ { 3, s(struct sys_fchown_args),
+ sys_fchown }, /* 123 = fchown */
+ { 2, s(struct sys_fchmod_args),
+ sys_fchmod }, /* 124 = fchmod */
+ { 6, s(struct compat_43_sys_recvfrom_args),
+ compat_43_sys_recvfrom }, /* 125 = orecvfrom */
+ { 2, s(struct compat_43_sys_setreuid_args),
+ compat_43_sys_setreuid }, /* 126 = osetreuid */
+ { 2, s(struct compat_43_sys_setregid_args),
+ compat_43_sys_setregid }, /* 127 = osetregid */
+ { 2, s(struct freebsd_sys_rename_args),
+ freebsd_sys_rename }, /* 128 = rename */
+ { 2, s(struct compat_43_freebsd_sys_truncate_args),
+ compat_43_freebsd_sys_truncate }, /* 129 = otruncate */
+ { 2, s(struct compat_43_sys_ftruncate_args),
+ compat_43_sys_ftruncate }, /* 130 = oftruncate */
+ { 2, s(struct sys_flock_args),
+ sys_flock }, /* 131 = flock */
+ { 2, s(struct freebsd_sys_mkfifo_args),
+ freebsd_sys_mkfifo }, /* 132 = mkfifo */
+ { 6, s(struct sys_sendto_args),
+ sys_sendto }, /* 133 = sendto */
+ { 2, s(struct sys_shutdown_args),
+ sys_shutdown }, /* 134 = shutdown */
+ { 4, s(struct sys_socketpair_args),
+ sys_socketpair }, /* 135 = socketpair */
+ { 2, s(struct freebsd_sys_mkdir_args),
+ freebsd_sys_mkdir }, /* 136 = mkdir */
+ { 1, s(struct freebsd_sys_rmdir_args),
+ freebsd_sys_rmdir }, /* 137 = rmdir */
+ { 2, s(struct sys_utimes_args),
+ sys_utimes }, /* 138 = utimes */
+ { 0, 0,
+ sys_nosys }, /* 139 = obsolete 4.2 sigreturn */
+ { 2, s(struct sys_adjtime_args),
+ sys_adjtime }, /* 140 = adjtime */
+ { 3, s(struct compat_43_sys_getpeername_args),
+ compat_43_sys_getpeername }, /* 141 = ogetpeername */
+ { 0, 0,
+ compat_43_sys_gethostid }, /* 142 = ogethostid */
+ { 1, s(struct compat_43_sys_sethostid_args),
+ compat_43_sys_sethostid }, /* 143 = osethostid */
+ { 2, s(struct compat_43_sys_getrlimit_args),
+ compat_43_sys_getrlimit }, /* 144 = ogetrlimit */
+ { 2, s(struct compat_43_sys_setrlimit_args),
+ compat_43_sys_setrlimit }, /* 145 = osetrlimit */
+ { 2, s(struct compat_43_sys_killpg_args),
+ compat_43_sys_killpg }, /* 146 = okillpg */
+ { 0, 0,
+ sys_setsid }, /* 147 = setsid */
+ { 4, s(struct sys_quotactl_args),
+ sys_quotactl }, /* 148 = quotactl */
+ { 0, 0,
+ compat_43_sys_quota }, /* 149 = oquota */
+ { 3, s(struct compat_43_sys_getsockname_args),
+ compat_43_sys_getsockname }, /* 150 = ogetsockname */
+ { 0, 0,
+ sys_nosys }, /* 151 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 152 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 153 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 154 = unimplemented */
+#if defined(NFSCLIENT) || defined(NFSSERVER)
+ { 2, s(struct sys_nfssvc_args),
+ sys_nfssvc }, /* 155 = nfssvc */
+#else
+ { 0, 0,
+ sys_nosys }, /* 155 = unimplemented */
+#endif
+ { 4, s(struct compat_43_sys_getdirentries_args),
+ compat_43_sys_getdirentries }, /* 156 = ogetdirentries */
+ { 2, s(struct freebsd_sys_statfs_args),
+ freebsd_sys_statfs }, /* 157 = statfs */
+ { 2, s(struct sys_fstatfs_args),
+ sys_fstatfs }, /* 158 = fstatfs */
+ { 0, 0,
+ sys_nosys }, /* 159 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 160 = unimplemented */
+#ifdef NFSCLIENT
+ { 2, s(struct freebsd_sys_getfh_args),
+ freebsd_sys_getfh }, /* 161 = getfh */
+#else
+ { 0, 0,
+ sys_nosys }, /* 161 = unimplemented getfh */
+#endif
+ { 2, s(struct compat_09_sys_getdomainname_args),
+ compat_09_sys_getdomainname }, /* 162 = getdomainname */
+ { 2, s(struct compat_09_sys_setdomainname_args),
+ compat_09_sys_setdomainname }, /* 163 = setdomainname */
+ { 1, s(struct compat_09_sys_uname_args),
+ compat_09_sys_uname }, /* 164 = uname */
+ { 2, s(struct sys_sysarch_args),
+ sys_sysarch }, /* 165 = sysarch */
+ { 3, s(struct freebsd_sys_rtprio_args),
+ freebsd_sys_rtprio }, /* 166 = rtprio */
+ { 0, 0,
+ sys_nosys }, /* 167 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 168 = unimplemented */
+#if defined(SYSVSEM) && !defined(alpha)
+ { 5, s(struct compat_10_sys_semsys_args),
+ compat_10_sys_semsys }, /* 169 = semsys */
+#else
+ { 0, 0,
+ sys_nosys }, /* 169 = unimplemented 1.0 semsys */
+#endif
+#if defined(SYSVMSG) && !defined(alpha)
+ { 6, s(struct compat_10_sys_msgsys_args),
+ compat_10_sys_msgsys }, /* 170 = msgsys */
+#else
+ { 0, 0,
+ sys_nosys }, /* 170 = unimplemented 1.0 msgsys */
+#endif
+#if defined(SYSVSHM) && !defined(alpha)
+ { 4, s(struct compat_10_sys_shmsys_args),
+ compat_10_sys_shmsys }, /* 171 = shmsys */
+#else
+ { 0, 0,
+ sys_nosys }, /* 171 = unimplemented 1.0 shmsys */
+#endif
+ { 0, 0,
+ sys_nosys }, /* 172 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 173 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 174 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 175 = unimplemented */
+ { 1, s(struct freebsd_ntp_adjtime_args),
+ freebsd_ntp_adjtime }, /* 176 = freebsd_ntp_adjtime */
+ { 0, 0,
+ sys_nosys }, /* 177 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 178 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 179 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 180 = unimplemented */
+ { 1, s(struct sys_setgid_args),
+ sys_setgid }, /* 181 = setgid */
+ { 1, s(struct sys_setegid_args),
+ sys_setegid }, /* 182 = setegid */
+ { 1, s(struct sys_seteuid_args),
+ sys_seteuid }, /* 183 = seteuid */
+#ifdef LFS
+ { 3, s(struct lfs_bmapv_args),
+ lfs_bmapv }, /* 184 = lfs_bmapv */
+ { 3, s(struct lfs_markv_args),
+ lfs_markv }, /* 185 = lfs_markv */
+ { 2, s(struct lfs_segclean_args),
+ lfs_segclean }, /* 186 = lfs_segclean */
+ { 2, s(struct lfs_segwait_args),
+ lfs_segwait }, /* 187 = lfs_segwait */
+#else
+ { 0, 0,
+ sys_nosys }, /* 184 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 185 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 186 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 187 = unimplemented */
+#endif
+ { 2, s(struct freebsd_sys_stat_args),
+ freebsd_sys_stat }, /* 188 = stat */
+ { 2, s(struct sys_fstat_args),
+ sys_fstat }, /* 189 = fstat */
+ { 2, s(struct freebsd_sys_lstat_args),
+ freebsd_sys_lstat }, /* 190 = lstat */
+ { 2, s(struct freebsd_sys_pathconf_args),
+ freebsd_sys_pathconf }, /* 191 = pathconf */
+ { 2, s(struct sys_fpathconf_args),
+ sys_fpathconf }, /* 192 = fpathconf */
+ { 0, 0,
+ sys_nosys }, /* 193 = unimplemented */
+ { 2, s(struct sys_getrlimit_args),
+ sys_getrlimit }, /* 194 = getrlimit */
+ { 2, s(struct sys_setrlimit_args),
+ sys_setrlimit }, /* 195 = setrlimit */
+ { 4, s(struct sys_getdirentries_args),
+ sys_getdirentries }, /* 196 = getdirentries */
+ { 7, s(struct sys_mmap_args),
+ sys_mmap }, /* 197 = mmap */
+ { 0, 0,
+ sys_nosys }, /* 198 = __syscall */
+ { 4, s(struct sys_lseek_args),
+ sys_lseek }, /* 199 = lseek */
+ { 3, s(struct freebsd_sys_truncate_args),
+ freebsd_sys_truncate }, /* 200 = truncate */
+ { 3, s(struct sys_ftruncate_args),
+ sys_ftruncate }, /* 201 = ftruncate */
+ { 6, s(struct sys___sysctl_args),
+ sys___sysctl }, /* 202 = __sysctl */
+ { 2, s(struct sys_mlock_args),
+ sys_mlock }, /* 203 = mlock */
+ { 2, s(struct sys_munlock_args),
+ sys_munlock }, /* 204 = munlock */
+#ifdef FREEBSD_BASED_ON_44LITE_R2
+ { 1, s(struct freebsd_sys_undelete_args),
+ freebsd_sys_undelete }, /* 205 = undelete */
+#else
+ { 0, 0,
+ sys_nosys }, /* 205 = unimplemented */
+#endif
+ { 0, 0,
+ sys_nosys }, /* 206 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 207 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 208 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 209 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 210 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 211 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 212 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 213 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 214 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 215 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 216 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 217 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 218 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 219 = unimplemented */
+};
+
diff --git a/sys/compat/freebsd/freebsd_timex.h b/sys/compat/freebsd/freebsd_timex.h
new file mode 100644
index 00000000000..90174f4ec56
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_timex.h
@@ -0,0 +1,302 @@
+/******************************************************************************
+ * *
+ * Copyright (c) David L. Mills 1993, 1994 *
+ * *
+ * Permission to use, copy, modify, and distribute this software and its *
+ * documentation for any purpose and without fee is hereby granted, provided *
+ * that the above copyright notice appears in all copies and that both the *
+ * copyright notice and this permission notice appear in supporting *
+ * documentation, and that the name University of Delaware not be used in *
+ * advertising or publicity pertaining to distribution of the software *
+ * without specific, written prior permission. The University of Delaware *
+ * makes no representations about the suitability this software for any *
+ * purpose. It is provided "as is" without express or implied warranty. *
+ * *
+ ******************************************************************************/
+
+/*
+ * Modification history timex.h
+ *
+ * 19 Mar 94 David L. Mills
+ * Moved defines from kernel routines to header file and added new
+ * defines for PPS phase-lock loop.
+ *
+ * 20 Feb 94 David L. Mills
+ * Revised status codes and structures for external clock and PPS
+ * signal discipline.
+ *
+ * 28 Nov 93 David L. Mills
+ * Adjusted parameters to improve stability and increase poll
+ * interval.
+ *
+ * 17 Sep 93 David L. Mills
+ * Created file
+ */
+/*
+ * This header file defines the Network Time Protocol (NTP) interfaces
+ * for user and daemon application programs. These are implemented using
+ * private syscalls and data structures and require specific kernel
+ * support.
+ *
+ * NAME
+ * ntp_gettime - NTP user application interface
+ *
+ * SYNOPSIS
+ * #include <sys/timex.h>
+ *
+ * int syscall(SYS_ntp_gettime, tptr)
+ *
+ * int SYS_ntp_gettime defined in syscall.h header file
+ * struct ntptimeval *tptr pointer to ntptimeval structure
+ *
+ * NAME
+ * ntp_adjtime - NTP daemon application interface
+ *
+ * SYNOPSIS
+ * #include <sys/timex.h>
+ *
+ * int syscall(SYS_ntp_adjtime, mode, tptr)
+ *
+ * int SYS_ntp_adjtime defined in syscall.h header file
+ * struct timex *tptr pointer to timex structure
+ *
+ */
+#ifndef _FREEBSD_TIMEX_H
+#define _FREEBSD_TIMEX_H 1
+
+#ifndef MSDOS /* Microsoft specific */
+#include <sys/syscall.h>
+#endif /* MSDOS */
+
+/*
+ * The following defines establish the engineering parameters of the
+ * phase-lock loop (PLL) model used in the kernel implementation. These
+ * parameters have been carefully chosen by analysis for good stability
+ * and wide dynamic range.
+ *
+ * The hz variable is defined in the kernel build environment. It
+ * establishes the timer interrupt frequency, 100 Hz for the SunOS
+ * kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the OSF/1
+ * kernel. SHIFT_HZ expresses the same value as the nearest power of two
+ * in order to avoid hardware multiply operations.
+ *
+ * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
+ * for a slightly underdamped convergence characteristic.
+ *
+ * MAXTC establishes the maximum time constant of the PLL. With the
+ * SHIFT_KG and SHIFT_KF values given and a time constant range from
+ * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
+ * respectively.
+ */
+#define SHIFT_HZ 7 /* log2(hz) */
+#define SHIFT_KG 6 /* phase factor (shift) */
+#define SHIFT_KF 16 /* frequency factor (shift) */
+#define MAXTC 6 /* maximum time constant (shift) */
+
+/*
+ * The following defines establish the scaling of the various variables
+ * used by the PLL. They are chosen to allow the greatest precision
+ * possible without overflow of a 32-bit word.
+ *
+ * SHIFT_SCALE defines the scaling (shift) of the time_phase variable,
+ * which serves as a an extension to the low-order bits of the system
+ * clock variable time.tv_usec.
+ *
+ * SHIFT_UPDATE defines the scaling (shift) of the time_offset variable,
+ * which represents the current time offset with respect to standard
+ * time.
+ *
+ * SHIFT_USEC defines the scaling (shift) of the time_freq and
+ * time_tolerance variables, which represent the current frequency
+ * offset and maximum frequency tolerance.
+ *
+ * FINEUSEC is 1 us in SHIFT_UPDATE units of the time_phase variable.
+ */
+#define SHIFT_SCALE 23 /* phase scale (shift) */
+#define SHIFT_UPDATE (SHIFT_KG + MAXTC) /* time offset scale (shift) */
+#define SHIFT_USEC 16 /* frequency offset scale (shift) */
+#define FINEUSEC (1L << SHIFT_SCALE) /* 1 us in phase units */
+
+/*
+ * The following defines establish the performance envelope of the PLL.
+ * They insure it operates within predefined limits, in order to satisfy
+ * correctness assertions. An excursion which exceeds these bounds is
+ * clamped to the bound and operation proceeds accordingly. In practice,
+ * this can occur only if something has failed or is operating out of
+ * tolerance, but otherwise the PLL continues to operate in a stable
+ * mode.
+ *
+ * MAXPHASE must be set greater than or equal to CLOCK.MAX (128 ms), as
+ * defined in the NTP specification. CLOCK.MAX establishes the maximum
+ * time offset allowed before the system time is reset, rather than
+ * incrementally adjusted. Here, the maximum offset is clamped to
+ * MAXPHASE only in order to prevent overflow errors due to defective
+ * protocol implementations.
+ *
+ * MAXFREQ is the maximum frequency tolerance of the CPU clock
+ * oscillator plus the maximum slew rate allowed by the protocol. It
+ * should be set to at least the frequency tolerance of the oscillator
+ * plus 100 ppm for vernier frequency adjustments. If the kernel
+ * PPS discipline code is configured (PPS_SYNC), the oscillator time and
+ * frequency are disciplined to an external source, presumably with
+ * negligible time and frequency error relative to UTC, and MAXFREQ can
+ * be reduced.
+ *
+ * MAXTIME is the maximum jitter tolerance of the PPS signal if the
+ * kernel PPS discipline code is configured (PPS_SYNC).
+ *
+ * MINSEC and MAXSEC define the lower and upper bounds on the interval
+ * between protocol updates.
+ */
+#define MAXPHASE 128000L /* max phase error (us) */
+#ifdef PPS_SYNC
+#define MAXFREQ (100L << SHIFT_USEC) /* max freq error (100 ppm) */
+#define MAXTIME (200L << PPS_AVG) /* max PPS error (jitter) (200 us) */
+#else
+#define MAXFREQ (200L << SHIFT_USEC) /* max freq error (200 ppm) */
+#endif /* PPS_SYNC */
+#define MINSEC 16L /* min interval between updates (s) */
+#define MAXSEC 1200L /* max interval between updates (s) */
+
+#ifdef PPS_SYNC
+/*
+ * The following defines are used only if a pulse-per-second (PPS)
+ * signal is available and connected via a modem control lead, such as
+ * produced by the optional ppsclock feature incorporated in the Sun
+ * asynch driver. They establish the design parameters of the frequency-
+ * lock loop used to discipline the CPU clock oscillator to the PPS
+ * signal.
+ *
+ * PPS_AVG is the averaging factor for the frequency loop, as well as
+ * the time and frequency dispersion.
+ *
+ * PPS_SHIFT and PPS_SHIFTMAX specify the minimum and maximum
+ * calibration intervals, respectively, in seconds as a power of two.
+ *
+ * PPS_VALID is the maximum interval before the PPS signal is considered
+ * invalid and protocol updates used directly instead.
+ *
+ * MAXGLITCH is the maximum interval before a time offset of more than
+ * MAXTIME is believed.
+ */
+#define PPS_AVG 2 /* pps averaging constant (shift) */
+#define PPS_SHIFT 2 /* min interval duration (s) (shift) */
+#define PPS_SHIFTMAX 8 /* max interval duration (s) (shift) */
+#define PPS_VALID 120 /* pps signal watchdog max (s) */
+#define MAXGLITCH 30 /* pps signal glitch max (s) */
+#endif /* PPS_SYNC */
+
+/*
+ * The following defines and structures define the user interface for
+ * the ntp_gettime() and ntp_adjtime() system calls.
+ *
+ * Control mode codes (timex.modes)
+ */
+#define MOD_OFFSET 0x0001 /* set time offset */
+#define MOD_FREQUENCY 0x0002 /* set frequency offset */
+#define MOD_MAXERROR 0x0004 /* set maximum time error */
+#define MOD_ESTERROR 0x0008 /* set estimated time error */
+#define MOD_STATUS 0x0010 /* set clock status bits */
+#define MOD_TIMECONST 0x0020 /* set pll time constant */
+#define MOD_CLKB 0x4000 /* set clock B */
+#define MOD_CLKA 0x8000 /* set clock A */
+
+/*
+ * Status codes (timex.status)
+ */
+#define STA_PLL 0x0001 /* enable PLL updates (rw) */
+#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */
+#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */
+
+#define STA_INS 0x0010 /* insert leap (rw) */
+#define STA_DEL 0x0020 /* delete leap (rw) */
+#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */
+
+#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */
+#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */
+#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */
+#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
+
+#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
+
+#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
+ STA_PPSERROR | STA_CLOCKERR) /* read-only bits */
+
+/*
+ * Clock states (time_state)
+ */
+#define TIME_OK 0 /* no leap second warning */
+#define TIME_INS 1 /* insert leap second warning */
+#define TIME_DEL 2 /* delete leap second warning */
+#define TIME_OOP 3 /* leap second in progress */
+#define TIME_WAIT 4 /* leap second has occured */
+#define TIME_ERROR 5 /* clock not synchronized */
+
+/*
+ * NTP user interface (ntp_gettime()) - used to read kernel clock values
+ *
+ * Note: maximum error = NTP synch distance = dispersion + delay / 2;
+ * estimated error = NTP dispersion.
+ */
+struct freebsd_ntptimeval {
+ struct timeval time; /* current time (ro) */
+ long maxerror; /* maximum error (us) (ro) */
+ long esterror; /* estimated error (us) (ro) */
+ int time_state; /* what ntp_gettime returns */
+};
+
+/*
+ * NTP daemon interface - (ntp_adjtime()) used to discipline CPU clock
+ * oscillator
+ */
+struct freebsd_timex {
+ unsigned int modes; /* clock mode bits (wo) */
+ long offset; /* time offset (us) (rw) */
+ long freq; /* frequency offset (scaled ppm) (rw) */
+ long maxerror; /* maximum error (us) (rw) */
+ long esterror; /* estimated error (us) (rw) */
+ int status; /* clock status bits (rw) */
+ long constant; /* pll time constant (rw) */
+ long precision; /* clock precision (us) (ro) */
+ long tolerance; /* clock frequency tolerance (scaled
+ * ppm) (ro) */
+ /*
+ * The following read-only structure members are implemented
+ * only if the PPS signal discipline is configured in the
+ * kernel.
+ */
+ long ppsfreq; /* pps frequency (scaled ppm) (ro) */
+ long jitter; /* pps jitter (us) (ro) */
+ int shift; /* interval duration (s) (shift) (ro) */
+ long stabil; /* pps stability (scaled ppm) (ro) */
+ long jitcnt; /* jitter limit exceeded (ro) */
+ long calcnt; /* calibration intervals (ro) */
+ long errcnt; /* calibration errors (ro) */
+ long stbcnt; /* stability limit exceeded (ro) */
+
+};
+#ifdef __FreeBSD__
+
+/*
+ * sysctl identifiers underneath kern.ntp_pll
+ */
+#define NTP_PLL_GETTIME 1 /* used by ntp_gettime() */
+#define NTP_PLL_MAXID 2 /* number of valid ids */
+
+#define NTP_PLL_NAMES { \
+ { 0, 0 }, \
+ { "gettime", CTLTYPE_STRUCT }, \
+ }
+
+#ifndef _KERNEL
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+extern int ntp_gettime __P((struct ntptimeval *));
+extern int ntp_adjtime __P((struct timex *));
+__END_DECLS
+
+#endif /* not _KERNEL */
+
+#endif /* __FreeBSD__ */
+#endif /* _FREEBSD_TIMEX_H */
diff --git a/sys/compat/freebsd/freebsd_util.h b/sys/compat/freebsd/freebsd_util.h
new file mode 100644
index 00000000000..612e5e35fb8
--- /dev/null
+++ b/sys/compat/freebsd/freebsd_util.h
@@ -0,0 +1,53 @@
+/* $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 _FREEBSD_UTIL_H_
+#define _FREEBSD_UTIL_H_
+
+#include <compat/common/compat_util.h>
+
+extern const char freebsd_emul_path[];
+
+#define FREEBSD_CHECK_ALT_EXIST(p, sgp, path) \
+ CHECK_ALT_EXIST(p, sgp, freebsd_emul_path, path)
+
+#define FREEBSD_CHECK_ALT_CREAT(p, sgp, path) \
+ CHECK_ALT_CREAT(p, sgp, freebsd_emul_path, path)
+
+#endif /* !_FREEBSD_UTIL_H_ */
diff --git a/sys/compat/freebsd/syscalls.conf b/sys/compat/freebsd/syscalls.conf
new file mode 100644
index 00000000000..12354c09868
--- /dev/null
+++ b/sys/compat/freebsd/syscalls.conf
@@ -0,0 +1,12 @@
+# $NetBSD: syscalls.conf,v 1.2 1995/10/10 01:20:55 mycroft Exp $
+
+sysnames="freebsd_syscalls.c"
+sysnumhdr="freebsd_syscall.h"
+syssw="freebsd_sysent.c"
+sysarghdr="freebsd_syscallargs.h"
+compatopts=""
+libcompatopts=""
+
+switchname="freebsd_sysent"
+namesname="freebsd_syscallnames"
+constprefix="FREEBSD_SYS_"
diff --git a/sys/compat/freebsd/syscalls.master b/sys/compat/freebsd/syscalls.master
new file mode 100644
index 00000000000..9f0b22bc1f9
--- /dev/null
+++ b/sys/compat/freebsd/syscalls.master
@@ -0,0 +1,400 @@
+ $NetBSD: syscalls.master,v 1.2 1995/10/10 01:34:37 mycroft Exp $
+
+; from: @(#)syscalls.master 8.2 (Berkeley) 1/13/94
+
+; NetBSD 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
+;
+; 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 <compat/freebsd/freebsd_syscallargs.h>
+
+#include <machine/freebsd_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 NOARGS { int sys_nosys(void); } syscall
+1 NOARGS { int sys_exit(int rval); }
+2 NOARGS { int sys_fork(void); }
+3 NOARGS { int sys_read(int fd, char *buf, u_int nbyte); }
+4 NOARGS { int sys_write(int fd, char *buf, u_int nbyte); }
+5 STD { int freebsd_sys_open(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); }
+8 STD { int compat_43_freebsd_sys_creat(char *path, \
+ int mode); } ocreat
+9 STD { int freebsd_sys_link(char *path, char *link); }
+10 STD { int freebsd_sys_unlink(char *path); }
+11 OBSOL execv
+12 STD { int freebsd_sys_chdir(char *path); }
+13 NOARGS { int sys_fchdir(int fd); }
+14 STD { int freebsd_sys_mknod(char *path, int mode, \
+ int dev); }
+15 STD { int freebsd_sys_chmod(char *path, int mode); }
+16 STD { int freebsd_sys_chown(char *path, int uid, int gid); }
+17 NOARGS { int sys_obreak(char *nsize); } break
+18 NOARGS { int sys_getfsstat(struct statfs *buf, long bufsize, \
+ int flags); }
+19 NOARGS { long compat_43_sys_lseek(int fd, long offset, \
+ int whence); } olseek
+20 NOARGS { pid_t sys_getpid(void); }
+21 STD { int freebsd_sys_mount(int type, char *path, \
+ int flags, caddr_t data); }
+22 STD { int freebsd_sys_unmount(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 STD { int freebsd_sys_ptrace(int req, pid_t pid, \
+ caddr_t addr, int data); }
+27 NOARGS { int sys_recvmsg(int s, struct msghdr *msg, \
+ int flags); }
+28 NOARGS { int sys_sendmsg(int s, caddr_t msg, int flags); }
+29 NOARGS { int sys_recvfrom(int s, caddr_t buf, size_t len, \
+ int flags, caddr_t from, int *fromlenaddr); }
+30 NOARGS { int sys_accept(int s, caddr_t name, int *anamelen); }
+31 NOARGS { int sys_getpeername(int fdes, caddr_t asa, \
+ int *alen); }
+32 NOARGS { int sys_getsockname(int fdes, caddr_t asa, \
+ int *alen); }
+33 STD { int freebsd_sys_access(char *path, int flags); }
+34 STD { int freebsd_sys_chflags(char *path, int flags); }
+35 NOARGS { int sys_fchflags(int fd, int flags); }
+36 NOARGS { int sys_sync(void); }
+37 NOARGS { int sys_kill(int pid, int signum); }
+38 STD { int compat_43_freebsd_sys_stat(char *path, \
+ struct ostat *ub); } ostat
+39 NOARGS { pid_t getppid(void); }
+40 STD { int compat_43_freebsd_sys_lstat(char *path, \
+ struct ostat *ub); } olstat
+41 NOARGS { int sys_dup(u_int fd); }
+42 NOARGS { int sys_pipe(void); }
+43 NOARGS { gid_t sys_getegid(void); }
+44 NOARGS { int sys_profil(caddr_t samples, u_int size, \
+ u_int offset, u_int scale); }
+#ifdef KTRACE
+45 NOARGS { int sys_ktrace(char *fname, int ops, int facs, \
+ int pid); }
+#else
+45 UNIMPL ktrace
+#endif
+46 NOARGS { int sys_sigaction(int signum, 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(char *namebuf); }
+51 NOARGS { int sys_acct(char *path); }
+52 NOARGS { int sys_sigpending(void); }
+53 NOARGS { int sys_sigaltstack(struct sigaltstack *nss, \
+ struct sigaltstack *oss); }
+54 STD { int freebsd_sys_ioctl(int fd, u_long com, \
+ caddr_t data); }
+55 NOARGS { int sys_reboot(int opt); }
+56 STD { int freebsd_sys_revoke(char *path); }
+57 STD { int freebsd_sys_symlink(char *path, char *link); }
+58 STD { int freebsd_sys_readlink(char *path, char *buf, \
+ int count); }
+59 STD { int freebsd_sys_execve(char *path, char **argp, \
+ char **envp); }
+60 NOARGS { int sys_umask(int newmask); }
+61 STD { int freebsd_sys_chroot(char *path); }
+62 NOARGS { int compat_43_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 STD { int freebsd_sys_msync(caddr_t addr, size_t len, \
+ int flags); }
+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 compat_43_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(caddr_t addr, size_t len); }
+74 NOARGS { int sys_mprotect(caddr_t addr, size_t len, \
+ int prot); }
+75 NOARGS { int sys_madvise(caddr_t addr, size_t len, \
+ int behav); }
+76 OBSOL vhangup
+77 OBSOL vlimit
+78 NOARGS { int sys_mincore(caddr_t addr, size_t len, char *vec); }
+79 NOARGS { int sys_getgroups(u_int gidsetsize, gid_t *gidset); }
+80 NOARGS { int sys_setgroups(u_int gidsetsize, gid_t *gidset); }
+81 NOARGS { int sys_getpgrp(void); }
+82 NOARGS { int sys_setpgid(int pid, int pgid); }
+83 NOARGS { int sys_setitimer(u_int which, \
+ struct itimerval *itv, struct itimerval *oitv); }
+84 NOARGS { int compat_43_sys_wait(void); } owait
+85 NOARGS { int sys_swapon(char *name); }
+86 NOARGS { int sys_getitimer(u_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(u_int from, u_int to); }
+91 UNIMPL getdopt
+92 NOARGS { int sys_fcntl(int fd, int cmd, void *arg); }
+93 NOARGS { int sys_select(u_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, caddr_t name, int namelen); }
+99 NOARGS { int compat_43_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 STD { int freebsd_sys_sigreturn( \
+ struct freebsd_sigcontext *scp); }
+104 NOARGS { int sys_bind(int s, caddr_t name, int namelen); }
+105 NOARGS { int sys_setsockopt(int s, int level, int name, \
+ caddr_t val, int 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, \
+ caddr_t val, int *avalsize); }
+119 OBSOL resuba
+120 NOARGS { int sys_readv(int fd, struct iovec *iovp, \
+ u_int iovcnt); }
+121 NOARGS { int sys_writev(int fd, struct iovec *iovp, \
+ u_int iovcnt); }
+122 NOARGS { int sys_settimeofday(struct timeval *tv, \
+ struct timezone *tzp); }
+123 NOARGS { int sys_fchown(int fd, int uid, int 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 STD { int freebsd_sys_rename(char *from, char *to); }
+129 STD { int compat_43_freebsd_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 STD { int freebsd_sys_mkfifo(char *path, int mode); }
+133 NOARGS { int sys_sendto(int s, caddr_t buf, size_t len, \
+ int flags, caddr_t to, int tolen); }
+134 NOARGS { int sys_shutdown(int s, int how); }
+135 NOARGS { int sys_socketpair(int domain, int type, \
+ int protocol, int *rsv); }
+136 STD { int freebsd_sys_mkdir(char *path, int mode); }
+137 STD { int freebsd_sys_rmdir(char *path); }
+138 NOARGS { int sys_utimes(char *path, struct timeval *tptr); }
+139 OBSOL 4.2 sigreturn
+140 NOARGS { int sys_adjtime(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(char *path, int cmd, int uid, \
+ caddr_t 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, caddr_t argp); }
+#else
+155 UNIMPL
+#endif
+156 NOARGS { int compat_43_sys_getdirentries(int fd, char *buf, \
+ u_int count, long *basep); } ogetdirentries
+157 STD { int freebsd_sys_statfs(char *path, \
+ struct statfs *buf); }
+158 NOARGS { int sys_fstatfs(int fd, struct statfs *buf); }
+159 UNIMPL
+160 UNIMPL
+#ifdef NFSCLIENT
+161 STD { int freebsd_sys_getfh(char *fname, fhandle_t *fhp); }
+#else
+161 UNIMPL getfh
+#endif
+162 NOARGS { int compat_09_sys_getdomainname(char *domainname, \
+ int len); }
+163 NOARGS { int compat_09_sys_setdomainname(char *domainname, \
+ int len); }
+164 NOARGS { int compat_09_sys_uname(struct outsname *name); }
+165 NOARGS { int sys_sysarch(int op, char *parms); }
+166 STD { int freebsd_sys_rtprio(int function, pid_t pid, \
+ struct freebsd_rtprio *rtp); }
+167 UNIMPL
+168 UNIMPL
+; XXX more generally, never on machines where sizeof(void *) != sizeof(int)
+#if defined(SYSVSEM) && !defined(alpha)
+169 NOARGS { int compat_10_sys_semsys(int which, int a2, int a3, \
+ int a4, int a5); }
+#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 compat_10_sys_msgsys(int which, int a2, int a3, \
+ int a4, int a5, int a6); }
+#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
+175 UNIMPL
+176 STD { int freebsd_ntp_adjtime(struct freebsd_timex *tp); }
+177 UNIMPL
+178 UNIMPL
+179 UNIMPL
+180 UNIMPL
+
+; Syscalls 180-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 STD { int freebsd_sys_stat(char *path, struct stat *ub); }
+189 NOARGS { int sys_fstat(int fd, struct stat *sb); }
+190 STD { int freebsd_sys_lstat(char *path, struct stat *ub); }
+191 STD { int freebsd_sys_pathconf(char *path, int name); }
+192 NOARGS { int sys_fpathconf(int fd, int name); }
+193 UNIMPL
+194 NOARGS { int sys_getrlimit(u_int which, struct rlimit *rlp); }
+195 NOARGS { int sys_setrlimit(u_int which, struct rlimit *rlp); }
+196 NOARGS { int sys_getdirentries(int fd, char *buf, \
+ u_int count, long *basep); }
+197 NOARGS { caddr_t sys_mmap(caddr_t addr, size_t len, int prot, \
+ int flags, int fd, long pad, off_t pos); }
+198 NOARGS { int sys_nosys(void); } __syscall
+199 NOARGS { off_t sys_lseek(int fd, int pad, off_t offset, \
+ int whence); }
+200 STD { int freebsd_sys_truncate(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(caddr_t addr, size_t len); }
+204 NOARGS { int sys_munlock(caddr_t addr, size_t len); }
+#ifdef FREEBSD_BASED_ON_44LITE_R2
+205 STD { int freebsd_sys_undelete(char *path); }
+#else
+205 UNIMPL
+#endif
+206 UNIMPL
+207 UNIMPL
+208 UNIMPL
+209 UNIMPL
+;
+; Syscalls 210-219 are reserved for dynamically loaded syscalls
+;
+210 UNIMPL
+211 UNIMPL
+212 UNIMPL
+213 UNIMPL
+214 UNIMPL
+215 UNIMPL
+216 UNIMPL
+217 UNIMPL
+218 UNIMPL
+219 UNIMPL
diff --git a/sys/compat/hpux/files.hpux b/sys/compat/hpux/files.hpux
new file mode 100644
index 00000000000..a95e7509382
--- /dev/null
+++ b/sys/compat/hpux/files.hpux
@@ -0,0 +1,14 @@
+# $NetBSD: files.hpux,v 1.1 1995/05/10 16:45:27 christos Exp $
+#
+# Config.new file description for machine-independent HPUX compat code.
+# Included by ports that need it.
+
+# ports should define any machine-specific files they need in their
+# own file lists.
+
+file compat/hpux/hpux_compat.c compat_hpux
+file compat/hpux/hpux_net.c compat_hpux
+file compat/hpux/hpux_sig.c compat_hpux
+file compat/hpux/hpux_syscalls.c compat_hpux
+file compat/hpux/hpux_sysent.c compat_hpux
+file compat/hpux/hpux_tty.c compat_hpux
diff --git a/sys/compat/hpux/hpux.h b/sys/compat/hpux/hpux.h
new file mode 100644
index 00000000000..b4ec592f366
--- /dev/null
+++ b/sys/compat/hpux/hpux.h
@@ -0,0 +1,310 @@
+/* $NetBSD: hpux.h,v 1.8 1995/05/10 16:45:29 christos Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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: Utah $Hdr: hpux.h 1.33 93/08/05$
+ *
+ * @(#)hpux.h 8.4 (Berkeley) 2/13/94
+ */
+
+#include <compat/hpux/hpux_exec.h>
+
+/* HP-UX style UTSNAME struct used by uname syscall */
+
+struct hpux_utsname {
+ char sysname[9];
+ char nodename[9];
+ char release[9];
+ char version[9];
+ char machine[9];
+ char idnumber[15];
+};
+
+/* HP-UX style "old" IOCTLs */
+
+struct hpux_sgttyb {
+ char sg_ispeed;
+ char sg_ospeed;
+ char sg_erase;
+ char sg_kill;
+ int sg_flags; /* only a short in BSD */
+};
+
+#define V7_HUPCL 00001
+#define V7_XTABS 00002
+#define V7_NOAL 04000
+
+#define HPUXTIOCGETP _IOR('t', 8, struct hpux_sgttyb)
+#define HPUXTIOCSETP _IOW('t', 9, struct hpux_sgttyb)
+
+/* 6.5 job control related ioctls which need to be mapped */
+
+#define HPUXTIOCSLTC _IOW('T', 23, struct ltchars)
+#define HPUXTIOCGLTC _IOR('T', 24, struct ltchars)
+#define HPUXTIOCLBIS _IOW('T', 25, int)
+#define HPUXTIOCLBIC _IOW('T', 26, int)
+#define HPUXTIOCLSET _IOW('T', 27, int)
+#define HPUXTIOCLGET _IOR('T', 28, int)
+# define HPUXLTOSTOP 0000001
+#define HPUXTIOCSPGRP _IOW('T', 29, int)
+#define HPUXTIOCGPGRP _IOR('T', 30, int)
+#define HPUXTIOCCONS _IO('t', 104)
+#define HPUXTIOCSWINSZ _IOW('t', 106, struct winsize)
+#define HPUXTIOCGWINSZ _IOR('t', 107, struct winsize)
+
+/* non-blocking IO--doesn't interfere with O_NDELAY */
+#define HPUXFIOSNBIO _IOW('f', 126, int)
+
+/* HP-UX stat structure */
+
+#define bsdtohpuxdev(d) ((major(d) << 24) | minor(d))
+
+struct hpux_stat {
+ long hst_dev;
+ u_long hst_ino;
+ u_short hst_mode;
+ short hst_nlink;
+ u_short hst_uid;
+ u_short hst_gid;
+ long hst_rdev;
+ long hst_size;
+ time_t hst_atime;
+ int hst_spare1;
+ time_t hst_mtime;
+ int hst_spare2;
+ time_t hst_ctime;
+ int hst_spare3;
+ long hst_blksize;
+ long hst_blocks;
+ u_int hst_remote;
+ long hst_netdev;
+ u_long hst_netino;
+ long hst_spare4[9];
+};
+
+/* from old timeb.h */
+struct hpux_otimeb {
+ time_t time;
+ u_short millitm;
+ short timezone;
+ short dstflag;
+};
+
+/* ye ole stat structure */
+struct hpux_ostat {
+ u_short hst_dev;
+ u_short hst_ino;
+ u_short hst_mode;
+ short hst_nlink;
+ short hst_uid;
+ short hst_gid;
+ u_short hst_rdev;
+ int hst_size;
+ int hst_atime;
+ int hst_mtime;
+ int hst_ctime;
+};
+/*
+ * Skeletal 6.X HP-UX user structure info for ptrace() mapping.
+ * Yes, this is as bogus as it gets...
+ */
+
+/* 6.0/6.2 offsets */
+#define ooHU_AROFF 0x004
+#define ooHU_TSOFF 0x092
+#define ooHU_EDOFF 0x91E
+#define ooHU_FPOFF 0xA66
+
+/* 6.5 offsets */
+#define oHU_AROFF 0x004
+#define oHU_TSOFF 0x0B2
+#define oHU_EDOFF 0x93A
+#define oHU_FPOFF 0xA86
+
+/* 7.X offsets */
+#define HU_AROFF 0x004
+#define HU_TSOFF 0x0B4
+#define HU_EDOFF 0x8C8
+#define HU_FPOFF 0xA28
+
+#define HU_PAD1 (HU_AROFF)
+#define HU_PAD2 (HU_TSOFF-HU_AROFF-4)
+#define HU_PAD3 (HU_EDOFF-HU_TSOFF-12)
+#define HU_PAD4 (HU_FPOFF-HU_EDOFF-sizeof(struct hpux_exec))
+
+struct hpux_user {
+ u_char whocares1[HU_PAD1]; /* +0x000 */
+ int *hpuxu_ar0; /* +0x004 */
+ u_char whocares2[HU_PAD2]; /* +0x008 */
+ int hpuxu_tsize; /* +0x0B2 */
+ int hpuxu_dsize; /* +0x0B6 */
+ int hpuxu_ssize; /* +0x0BA */
+ u_char whocares3[HU_PAD3]; /* +0x0BE */
+ struct hpux_exec hpuxu_exdata; /* +0x93A */
+ u_char whocares4[HU_PAD4]; /* +0x95E */
+ struct hpux_fp { /* +0xA66 */
+ int hpfp_save[54];
+ int hpfp_ctrl[3];
+ int hpfp_reg[24];
+ } hpuxu_fp;
+ short hpuxu_dragon; /* +0xBCA */
+};
+
+/* HP-UX compat file flags */
+#define HPUXNDELAY 00000004
+#define HPUXFCREAT 00000400
+#define HPUXFTRUNC 00001000
+#define HPUXFEXCL 00002000
+#define HPUXFSYNCIO 00100000
+#define HPUXNONBLOCK 00200000
+#define HPUXFREMOTE 01000000
+
+/* HP-UX fcntl file locking */
+struct hpux_flock {
+ short hl_type;
+ short hl_whence;
+ long hl_start;
+ long hl_len;
+ long hl_pid;
+};
+
+#define HPUXF_GETLK 7
+#define HPUXF_SETLK 8
+#define HPUXF_SETLKW 9
+
+#define HPUXF_RDLCK 1
+#define HPUXF_WRLCK 2
+#define HPUXF_UNLCK 3
+
+/* HP-UX only sysV shmctl() commands */
+#define SHM_LOCK 3 /* Lock segment in core */
+#define SHM_UNLOCK 4 /* Unlock segment */
+
+/* SHM stuff reflecting POSIX types */
+struct hpux_ipc_perm {
+ long uid; /* owner's user id */
+ long gid; /* owner's group id */
+ long cuid; /* creator's user id */
+ long cgid; /* creator's group id */
+ u_short mode; /* access modes */
+ u_short seq; /* slot usage sequence number */
+ long key; /* key */
+};
+
+struct hpux_shmid_ds {
+ struct hpux_ipc_perm shm_perm; /* operation permission struct */
+ int shm_segsz; /* segment size (bytes) */
+ struct pte *shm_ptbl; /* ptr to associated page table */
+ long shm_lpid; /* pid of last shmop */
+ long shm_cpid; /* pid of creator */
+ u_short shm_nattch; /* current # attached */
+ u_short shm_cnattch; /* in memory # attached */
+ time_t shm_atime; /* last shmat time */
+ time_t shm_dtime; /* last shmdt time */
+ time_t shm_ctime; /* last change time */
+ /* actually longer */
+};
+
+/* HP-UX rtprio values */
+#define RTPRIO_MIN 0
+#define RTPRIO_MAX 127
+#define RTPRIO_NOCHG 1000
+#define RTPRIO_RTOFF 1001
+
+/* HP-UX only sigvec sv_flags values */
+#define HPUXSV_RESET 000000004
+
+/*
+ * HP-UX returns SIGILL instead of SIGFPE for the CHK and TRAPV exceptions.
+ * It also returns different u_code values for certain illegal instruction
+ * and floating point exceptions. Here are the proper HP-UX u_code values
+ * (numbers from hpux 6.2 manual pages).
+ */
+
+/* SIGILL codes */
+#define HPUX_ILL_ILLINST_TRAP 0 /* T_ILLINST+USER */
+#define HPUX_ILL_CHK_TRAP 6 /* T_CHKINST+USER */
+#define HPUX_ILL_TRAPV_TRAP 7 /* T_TRAPVINST+USER */
+#define HPUX_ILL_PRIV_TRAP 8 /* T_PRIVINST+USER */
+
+/* SIGFPE codes */
+#define HPUX_FPE_INTDIV_TRAP 5 /* T_ZERODIV+USER */
+
+/* HP-UX POSIX signal stuff implementation */
+typedef struct __hpux_sigset_t { long sigset[8]; } hpux_sigset_t;
+struct hpux_sigaction {
+ void (*sa_handler)();
+ hpux_sigset_t sa_mask;
+ int sa_flags;
+};
+#define HPUXSA_ONSTACK 1
+#define HPUXSA_RESETHAND 4
+#define HPUXSA_NOCLDSTOP 8
+
+#define HPUXSIG_BLOCK 0 /* block specified signal set */
+#define HPUXSIG_UNBLOCK 1 /* unblock specified signal set */
+#define HPUXSIG_SETMASK 2 /* set specified signal set */
+
+/* sysconf stuff */
+#define HPUX_SYSCONF_CLKTICK 2
+#define HPUX_SYSCONF_OPENMAX 4
+#define HPUX_SYSCONF_CPUTYPE 10001
+#define HPUX_SYSCONF_CPUM020 0x20C
+#define HPUX_SYSCONF_CPUM030 0x20D
+#define HPUX_SYSCONF_CPUM040 0x20E
+#define HPUX_SYSCONF_CPUPA10 0x20B
+#define HPUX_SYSCONF_CPUPA11 0x210
+
+/* mmap stuff */
+#define HPUXMAP_FIXED 0x04
+#define HPUXMAP_REPLACE 0x08
+#define HPUXMAP_ANON 0x10
+
+/* rlimit stuff */
+#define HPUXRLIMIT_NOFILE 6
+
+/*
+ * In BSD EAGAIN and EWOULDBLOCK are the same error code.
+ * However, for HP-UX we must split them out to seperate codes.
+ * The easiest way to do this was to check the return value of
+ * BSD routines which are known to return EAGAIN (but never
+ * EWOULDBLOCK) and change it to the pseudo-code OEAGAIN when
+ * we see it. The error translation table will them map that
+ * code to the HP-UX EAGAIN value.
+ */
+#define OEAGAIN 82
diff --git a/sys/compat/hpux/hpux_compat.c b/sys/compat/hpux/hpux_compat.c
new file mode 100644
index 00000000000..bc127ad804c
--- /dev/null
+++ b/sys/compat/hpux/hpux_compat.c
@@ -0,0 +1,2164 @@
+/* $NetBSD: hpux_compat.c,v 1.19 1995/10/07 06:26:34 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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: Utah $Hdr: hpux_compat.c 1.64 93/08/05$
+ *
+ * @(#)hpux_compat.c 8.4 (Berkeley) 2/13/94
+ */
+
+/*
+ * Various HP-UX compatibility routines
+ */
+
+#ifndef COMPAT_43
+#define COMPAT_43
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signalvar.h>
+#include <sys/kernel.h>
+#include <sys/filedesc.h>
+#include <sys/proc.h>
+#include <sys/buf.h>
+#include <sys/wait.h>
+#include <sys/file.h>
+#include <sys/namei.h>
+#include <sys/vnode.h>
+#include <sys/ioctl.h>
+#include <sys/ptrace.h>
+#include <sys/stat.h>
+#include <sys/syslog.h>
+#include <sys/malloc.h>
+#include <sys/mount.h>
+#include <sys/ipc.h>
+#include <sys/user.h>
+#include <sys/mman.h>
+
+#include <machine/cpu.h>
+#include <machine/reg.h>
+#include <machine/psl.h>
+#include <machine/vmparam.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/hpux/hpux.h>
+#include <compat/hpux/hpux_util.h>
+#include <compat/hpux/hpux_termio.h>
+#include <compat/hpux/hpux_syscall.h>
+#include <compat/hpux/hpux_syscallargs.h>
+
+#ifdef DEBUG
+int unimpresponse = 0;
+#endif
+
+/* 6.0 and later style context */
+#if defined(HP380)
+char hpux_040context[] =
+ "standalone HP-MC68040 HP-MC68881 HP-MC68020 HP-MC68010 localroot default";
+#endif
+#ifdef FPCOPROC
+char hpux_context[] =
+ "standalone HP-MC68881 HP-MC68020 HP-MC68010 localroot default";
+#else
+char hpux_context[] =
+ "standalone HP-MC68020 HP-MC68010 localroot default";
+#endif
+
+#define NERR 83
+#define BERR 1000
+
+/* indexed by BSD errno */
+int bsdtohpuxerrnomap[NERR] = {
+/*00*/ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+/*10*/ 10, 45, 12, 13, 14, 15, 16, 17, 18, 19,
+/*20*/ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
+/*30*/ 30, 31, 32, 33, 34, 246, 245, 244, 216, 217,
+/*40*/ 218, 219, 220, 221, 222, 223, 224, 225, 226, 227,
+/*50*/ 228, 229, 230, 231, 232, 233, 234, 235, 236, 237,
+/*60*/ 238, 239, 249, 248, 241, 242, 247,BERR,BERR,BERR,
+/*70*/ 70, 71,BERR,BERR,BERR,BERR,BERR, 46, 251,BERR,
+/*80*/ BERR,BERR, 11
+};
+
+extern char sigcode[], esigcode[];
+extern struct sysent hpux_sysent[];
+extern char *hpux_syscallnames[];
+
+struct emul emul_hpux = {
+ "hpux",
+ bsdtohpuxerrnomap,
+ sendsig,
+ HPUX_SYS_syscall,
+ HPUX_SYS_MAXSYSCALL,
+ hpux_sysent,
+ hpux_syscallnames,
+ 0,
+ copyargs,
+ setregs,
+ sigcode,
+ esigcode,
+};
+
+/*
+ * HP-UX fork and vfork need to map the EAGAIN return value appropriately.
+ */
+int
+hpux_sys_fork(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_fork_args *uap = v;
+ int error;
+
+ error = sys_fork(p, (struct fork_args *) uap, retval);
+ if (error == EAGAIN)
+ error = OEAGAIN;
+ return (error);
+}
+
+int
+hpux_sys_vfork(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_vfork_args *uap = v;
+ int error;
+
+ error = sys_vfork(p, (struct vfork_args *) uap, retval);
+ if (error == EAGAIN)
+ error = OEAGAIN;
+ return (error);
+}
+
+int
+hpux_sys_execv(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_execv_args *uap = v;
+ struct sys_execve_args ap;
+
+ SCARG(&ap, path) = SCARG(uap, path);
+ SCARG(&ap, argp) = SCARG(uap, argp);
+ SCARG(&ap, envp) = NULL;
+
+ return sys_execve(p, &ap, retval);
+}
+
+/*
+ * HP-UX versions of wait and wait3 actually pass the parameters
+ * (status pointer, options, rusage) into the kernel rather than
+ * handling it in the C library stub. We also need to map any
+ * termination signal from BSD to HP-UX.
+ */
+int
+hpux_sys_wait3(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_wait3_args *uap = v;
+
+ /* rusage pointer must be zero */
+ if (SCARG(uap, rusage))
+ return (EINVAL);
+#if __mc68k__
+ p->p_md.md_regs[PS] = PSL_ALLCC;
+ p->p_md.md_regs[R0] = SCARG(uap, options);
+ p->p_md.md_regs[R1] = SCARG(uap, rusage);
+#endif
+
+ return (hpux_sys_wait(p, uap, retval));
+}
+
+int
+hpux_sys_wait(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_wait_args *uap = v;
+ struct sys_wait4_args w4;
+ int error;
+ int sig;
+ size_t sz = sizeof(*SCARG(&w4, status));
+ int status;
+
+ SCARG(&w4, rusage) = NULL;
+ SCARG(&w4, options) = 0;
+
+ if (SCARG(uap, status) == NULL) {
+ caddr_t sg = stackgap_init(p->p_emul);
+ SCARG(&w4, status) = stackgap_alloc(&sg, sz);
+ }
+ else
+ SCARG(&w4, status) = SCARG(uap, status);
+
+ SCARG(&w4, pid) = WAIT_ANY;
+
+ error = sys_wait4(p, &w4, retval);
+ /*
+ * HP-UX wait always returns EINTR when interrupted by a signal
+ * (well, unless its emulating a BSD process, but we don't bother...)
+ */
+ if (error == ERESTART)
+ error = EINTR;
+ if (error)
+ return error;
+
+ if ((error = copyin(SCARG(&w4, status), &status, sizeof(status))) != 0)
+ return error;
+
+ sig = status & 0xFF;
+ if (sig == WSTOPPED) {
+ sig = (status >> 8) & 0xFF;
+ retval[1] = (bsdtohpuxsig(sig) << 8) | WSTOPPED;
+ } else if (sig)
+ retval[1] = (status & 0xFF00) |
+ bsdtohpuxsig(sig & 0x7F) | (sig & 0x80);
+
+ if (SCARG(uap, status) == NULL)
+ return error;
+ else
+ return copyout(&retval[1],
+ SCARG(uap, status), sizeof(retval[1]));
+}
+
+int
+hpux_sys_waitpid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_waitpid_args *uap = v;
+ int rv, sig, xstat, error;
+
+ SCARG(uap, rusage) = 0;
+ error = sys_wait4(p, uap, retval);
+ /*
+ * HP-UX wait always returns EINTR when interrupted by a signal
+ * (well, unless its emulating a BSD process, but we don't bother...)
+ */
+ if (error == ERESTART)
+ error = EINTR;
+ if (error)
+ return (error);
+
+ if (SCARG(uap, status)) {
+ /*
+ * Wait4 already wrote the status out to user space,
+ * pull it back, change the signal portion, and write
+ * it back out.
+ */
+ rv = fuword((caddr_t)SCARG(uap, status));
+ if (WIFSTOPPED(rv)) {
+ sig = WSTOPSIG(rv);
+ rv = W_STOPCODE(bsdtohpuxsig(sig));
+ } else if (WIFSIGNALED(rv)) {
+ sig = WTERMSIG(rv);
+ xstat = WEXITSTATUS(rv);
+ rv = W_EXITCODE(xstat, bsdtohpuxsig(sig)) |
+ WCOREDUMP(rv);
+ }
+ (void)suword((caddr_t)SCARG(uap, status), rv);
+ }
+ return (error);
+}
+
+/*
+ * Old creat system call.
+ */
+int
+hpux_sys_creat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_creat_args *uap = v;
+ struct sys_open_args oap;
+
+ SCARG(&oap, path) = SCARG(uap, path);
+ SCARG(&oap, flags) = O_WRONLY | O_CREAT | O_TRUNC;
+ SCARG(&oap, mode) = SCARG(uap, mode);
+
+ return sys_open(p, &oap, retval);
+}
+
+/*
+ * XXX extensions to the fd_ofileflags flags.
+ * Hate to put this there, but they do need to be per-file.
+ */
+#define UF_NONBLOCK_ON 0x10
+#define UF_FNDELAY_ON 0x20
+#define UF_FIONBIO_ON 0x40
+
+/*
+ * Must remap some bits in the mode mask.
+ * O_CREAT, O_TRUNC, and O_EXCL must be remapped,
+ * O_NONBLOCK is remapped and remembered,
+ * O_FNDELAY is remembered,
+ * O_SYNCIO is removed entirely.
+ */
+int
+hpux_sys_open(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_open_args *uap = v;
+ int mode, error;
+
+ mode = SCARG(uap, mode);
+ SCARG(uap, mode) &=
+ ~(HPUXNONBLOCK|HPUXFSYNCIO|HPUXFEXCL|HPUXFTRUNC|HPUXFCREAT);
+ if (mode & HPUXFCREAT) {
+ /*
+ * simulate the pre-NFS behavior that opening a
+ * file for READ+CREATE ignores the CREATE (unless
+ * EXCL is set in which case we will return the
+ * proper error).
+ */
+ if ((mode & HPUXFEXCL) || (FFLAGS(mode) & FWRITE))
+ SCARG(uap, mode) |= O_CREAT;
+ }
+ if (mode & HPUXFTRUNC)
+ SCARG(uap, mode) |= O_TRUNC;
+ if (mode & HPUXFEXCL)
+ SCARG(uap, mode) |= O_EXCL;
+ if (mode & HPUXNONBLOCK)
+ SCARG(uap, mode) |= O_NDELAY;
+ error = sys_open(p, (struct open_args *) uap, retval);
+ /*
+ * Record non-blocking mode for fcntl, read, write, etc.
+ */
+ if (error == 0 && (SCARG(uap, mode) & O_NDELAY))
+ p->p_fd->fd_ofileflags[*retval] |=
+ (mode & HPUXNONBLOCK) ? UF_NONBLOCK_ON : UF_FNDELAY_ON;
+ return (error);
+}
+
+int
+hpux_sys_fcntl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_fcntl_args *uap = v;
+ int mode, error, flg = F_POSIX;
+ struct file *fp;
+ char *pop;
+ struct hpux_flock hfl;
+ struct flock fl;
+ struct vnode *vp;
+
+ if ((unsigned)SCARG(uap, fd) >= p->p_fd->fd_nfiles ||
+ (fp = p->p_fd->fd_ofiles[SCARG(uap, fd)]) == NULL)
+ return (EBADF);
+ pop = &p->p_fd->fd_ofileflags[SCARG(uap, fd)];
+ switch (SCARG(uap, cmd)) {
+ case F_SETFL:
+ if (SCARG(uap, arg) & HPUXNONBLOCK)
+ *pop |= UF_NONBLOCK_ON;
+ else
+ *pop &= ~UF_NONBLOCK_ON;
+ if (SCARG(uap, arg) & HPUXNDELAY)
+ *pop |= UF_FNDELAY_ON;
+ else
+ *pop &= ~UF_FNDELAY_ON;
+ if (*pop & (UF_NONBLOCK_ON|UF_FNDELAY_ON|UF_FIONBIO_ON))
+ SCARG(uap, arg) |= FNONBLOCK;
+ else
+ SCARG(uap, arg) &= ~FNONBLOCK;
+ SCARG(uap, arg) &= ~(HPUXNONBLOCK|HPUXFSYNCIO|HPUXFREMOTE);
+ break;
+ case F_GETFL:
+ case F_DUPFD:
+ case F_GETFD:
+ case F_SETFD:
+ break;
+
+ case HPUXF_SETLKW:
+ flg |= F_WAIT;
+ /* Fall into F_SETLK */
+
+ case HPUXF_SETLK:
+ if (fp->f_type != DTYPE_VNODE)
+ return (EBADF);
+ vp = (struct vnode *)fp->f_data;
+ /* Copy in the lock structure */
+ error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&hfl,
+ sizeof (hfl));
+ if (error)
+ return (error);
+ fl.l_start = hfl.hl_start;
+ fl.l_len = hfl.hl_len;
+ fl.l_pid = hfl.hl_pid;
+ fl.l_type = hfl.hl_type;
+ fl.l_whence = hfl.hl_whence;
+ if (fl.l_whence == SEEK_CUR)
+ fl.l_start += fp->f_offset;
+ switch (fl.l_type) {
+
+ case F_RDLCK:
+ if ((fp->f_flag & FREAD) == 0)
+ return (EBADF);
+ p->p_flag |= P_ADVLOCK;
+ return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg));
+
+ case F_WRLCK:
+ if ((fp->f_flag & FWRITE) == 0)
+ return (EBADF);
+ p->p_flag |= P_ADVLOCK;
+ return (VOP_ADVLOCK(vp, (caddr_t)p, F_SETLK, &fl, flg));
+
+ case F_UNLCK:
+ return (VOP_ADVLOCK(vp, (caddr_t)p, F_UNLCK, &fl,
+ F_POSIX));
+
+ default:
+ return (EINVAL);
+ }
+
+ case F_GETLK:
+ if (fp->f_type != DTYPE_VNODE)
+ return (EBADF);
+ vp = (struct vnode *)fp->f_data;
+ /* Copy in the lock structure */
+ error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&hfl,
+ sizeof (hfl));
+ if (error)
+ return (error);
+ fl.l_start = hfl.hl_start;
+ fl.l_len = hfl.hl_len;
+ fl.l_pid = hfl.hl_pid;
+ fl.l_type = hfl.hl_type;
+ fl.l_whence = hfl.hl_whence;
+ if (fl.l_whence == SEEK_CUR)
+ fl.l_start += fp->f_offset;
+ if (error = VOP_ADVLOCK(vp, (caddr_t)p, F_GETLK, &fl, F_POSIX))
+ return (error);
+ hfl.hl_start = fl.l_start;
+ hfl.hl_len = fl.l_len;
+ hfl.hl_pid = fl.l_pid;
+ hfl.hl_type = fl.l_type;
+ hfl.hl_whence = fl.l_whence;
+ return (copyout((caddr_t)&hfl, (caddr_t)SCARG(uap, arg),
+ sizeof (hfl)));
+
+ default:
+ return (EINVAL);
+ }
+ error = sys_fcntl(p, uap, retval);
+ if (error == 0 && SCARG(uap, cmd) == F_GETFL) {
+ mode = *retval;
+ *retval &= ~(O_CREAT|O_TRUNC|O_EXCL);
+ if (mode & FNONBLOCK) {
+ if (*pop & UF_NONBLOCK_ON)
+ *retval |= HPUXNONBLOCK;
+ if ((*pop & UF_FNDELAY_ON) == 0)
+ *retval &= ~HPUXNDELAY;
+ }
+ if (mode & O_CREAT)
+ *retval |= HPUXFCREAT;
+ if (mode & O_TRUNC)
+ *retval |= HPUXFTRUNC;
+ if (mode & O_EXCL)
+ *retval |= HPUXFEXCL;
+ }
+ return (error);
+}
+
+/*
+ * Read and write calls. Same as BSD except for non-blocking behavior.
+ * There are three types of non-blocking reads/writes in HP-UX checked
+ * in the following order:
+ *
+ * O_NONBLOCK: return -1 and errno == EAGAIN
+ * O_NDELAY: return 0
+ * FIOSNBIO: return -1 and errno == EWOULDBLOCK
+ */
+int
+hpux_sys_read(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_read_args *uap = v;
+ int error;
+
+ error = sys_read(p, (struct sys_read_args *) uap, retval);
+ if (error == EWOULDBLOCK) {
+ char *fp = &p->p_fd->fd_ofileflags[SCARG(uap, fd)];
+
+ if (*fp & UF_NONBLOCK_ON) {
+ *retval = -1;
+ error = OEAGAIN;
+ } else if (*fp & UF_FNDELAY_ON) {
+ *retval = 0;
+ error = 0;
+ }
+ }
+ return (error);
+}
+
+int
+hpux_sys_write(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_write_args *uap = v;
+ int error;
+
+ error = sys_write(p, (struct sys_write_args *) uap, retval);
+ if (error == EWOULDBLOCK) {
+ char *fp = &p->p_fd->fd_ofileflags[SCARG(uap, fd)];
+
+ if (*fp & UF_NONBLOCK_ON) {
+ *retval = -1;
+ error = OEAGAIN;
+ } else if (*fp & UF_FNDELAY_ON) {
+ *retval = 0;
+ error = 0;
+ }
+ }
+ return (error);
+}
+
+int
+hpux_sys_readv(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_readv_args *uap = v;
+ int error;
+
+ error = sys_readv(p, (struct sys_readv_args *) uap, retval);
+ if (error == EWOULDBLOCK) {
+ char *fp = &p->p_fd->fd_ofileflags[SCARG(uap, fd)];
+
+ if (*fp & UF_NONBLOCK_ON) {
+ *retval = -1;
+ error = OEAGAIN;
+ } else if (*fp & UF_FNDELAY_ON) {
+ *retval = 0;
+ error = 0;
+ }
+ }
+ return (error);
+}
+
+int
+hpux_sys_writev(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_writev_args *uap = v;
+ int error;
+
+ error = sys_writev(p, (struct sys_writev_args *) uap, retval);
+ if (error == EWOULDBLOCK) {
+ char *fp = &p->p_fd->fd_ofileflags[SCARG(uap, fd)];
+
+ if (*fp & UF_NONBLOCK_ON) {
+ *retval = -1;
+ error = OEAGAIN;
+ } else if (*fp & UF_FNDELAY_ON) {
+ *retval = 0;
+ error = 0;
+ }
+ }
+ return (error);
+}
+
+/*
+ * 4.3bsd dup allows dup2 to come in on the same syscall entry
+ * and hence allows two arguments. HP-UX dup has only one arg.
+ */
+int
+hpux_sys_dup(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_dup_args *uap = v;
+ register struct filedesc *fdp = p->p_fd;
+ struct file *fp;
+ int fd, error;
+
+ if (((unsigned)SCARG(uap, fd)) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
+ return (EBADF);
+ if (error = fdalloc(p, 0, &fd))
+ return (error);
+ fdp->fd_ofiles[fd] = fp;
+ fdp->fd_ofileflags[fd] =
+ fdp->fd_ofileflags[SCARG(uap, fd)] &~ UF_EXCLOSE;
+ fp->f_count++;
+ if (fd > fdp->fd_lastfile)
+ fdp->fd_lastfile = fd;
+ *retval = fd;
+ return (0);
+}
+
+/*
+ * XXX: This belongs in hpux_machdep.c !!
+ */
+int
+hpux_sys_utssys(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_utssys_args *uap = v;
+ register int i;
+ int error;
+ struct hpux_utsname ut;
+ extern char ostype[], hostname[], osrelease[], version[], machine[];
+
+ switch (SCARG(uap, request)) {
+ /* uname */
+ case 0:
+ bzero(&ut, sizeof(ut));
+
+ strncpy(ut.sysname, ostype, sizeof(ut.sysname));
+ ut.sysname[sizeof(ut.sysname) - 1] = '\0';
+
+ /* copy hostname (sans domain) to nodename */
+ for (i = 0; i < 8 && hostname[i] != '.'; i++)
+ ut.nodename[i] = hostname[i];
+ ut.nodename[i] = '\0';
+
+ strncpy(ut.release, osrelease, sizeof(ut.release));
+ ut.release[sizeof(ut.release) - 1] = '\0';
+
+ strncpy(ut.version, version, sizeof(ut.version));
+ ut.version[sizeof(ut.version) - 1] = '\0';
+
+ strncpy(ut.machine, "9000/3?0", sizeof(ut.machine));
+ ut.machine[sizeof(ut.machine) - 1] = '\0';
+
+ /* fill in machine type */
+#ifdef HP_320
+ switch (machineid) {
+ case HP_320:
+ ut.machine[6] = '2';
+ break;
+ /* includes 318 and 319 */
+ case HP_330:
+ ut.machine[6] = '3';
+ break;
+ case HP_340:
+ ut.machine[6] = '4';
+ break;
+ case HP_350:
+ ut.machine[6] = '5';
+ break;
+ case HP_360:
+ ut.machine[6] = '6';
+ break;
+ case HP_370:
+ ut.machine[6] = '7';
+ break;
+ /* includes 345 */
+ case HP_375:
+ ut.machine[6] = '7';
+ ut.machine[7] = '5';
+ break;
+ /* includes 425 */
+ case HP_380:
+ ut.machine[6] = '8';
+ break;
+ case HP_433:
+ ut.machine[5] = '4';
+ ut.machine[6] = '3';
+ ut.machine[7] = '3';
+ break;
+ }
+#endif
+
+ error = copyout((caddr_t)&ut,
+ (caddr_t)SCARG(uap, uts), sizeof(ut));
+ break;
+
+ /* gethostname */
+ case 5:
+ /* SCARG(uap, dev) is length */
+ if (SCARG(uap, dev) > hostnamelen + 1)
+ SCARG(uap, dev) = hostnamelen + 1;
+ error = copyout((caddr_t)hostname, (caddr_t)SCARG(uap, uts),
+ SCARG(uap, dev));
+ break;
+
+ case 1: /* ?? */
+ case 2: /* ustat */
+ case 3: /* ?? */
+ case 4: /* sethostname */
+ default:
+ error = EINVAL;
+ break;
+ }
+ return (error);
+}
+
+/*
+ * XXX: This belongs in hpux_machdep.c !!
+ */
+int
+hpux_sys_sysconf(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_sysconf_args *uap = v;
+ switch (SCARG(uap, name)) {
+
+ /* clock ticks per second */
+ case HPUX_SYSCONF_CLKTICK:
+ *retval = hz;
+ break;
+
+ /* open files */
+ case HPUX_SYSCONF_OPENMAX:
+ *retval = NOFILE;
+ break;
+
+ /* architecture */
+ case HPUX_SYSCONF_CPUTYPE:
+#ifdef HP_320
+ switch (machineid) {
+ case HP_320:
+ case HP_330:
+ case HP_350:
+ *retval = HPUX_SYSCONF_CPUM020;
+ break;
+ case HP_340:
+ case HP_360:
+ case HP_370:
+ case HP_375:
+ *retval = HPUX_SYSCONF_CPUM030;
+ break;
+ case HP_380:
+ case HP_433:
+ *retval = HPUX_SYSCONF_CPUM040;
+ break;
+ }
+#else
+ *retval = HPUX_SYSCONF_CPUM020;
+#endif
+ break;
+ default:
+ uprintf("HP-UX sysconf(%d) not implemented\n",
+ SCARG(uap, name));
+ return (EINVAL);
+ }
+ return (0);
+}
+
+int
+hpux_sys_stat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_stat_args *uap = v;
+
+ return (hpux_stat1(SCARG(uap, path), SCARG(uap, sb), FOLLOW, p));
+}
+
+int
+hpux_sys_lstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_lstat_args *uap = v;
+
+ return (hpux_stat1(SCARG(uap, path), SCARG(uap, sb), NOFOLLOW, p));
+}
+
+int
+hpux_sys_fstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_fstat_args *uap = v;
+ register struct filedesc *fdp = p->p_fd;
+ register struct file *fp;
+ struct stat sb;
+ int error;
+
+ if (((unsigned)SCARG(uap, fd)) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[SCARG(uap, 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, p);
+ break;
+
+ default:
+ panic("fstat");
+ /*NOTREACHED*/
+ }
+ /* is this right for sockets?? */
+ if (error == 0)
+ error = bsdtohpuxstat(&sb, SCARG(uap, sb));
+ return (error);
+}
+
+int
+hpux_sys_ulimit(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_ulimit_args *uap = v;
+ struct rlimit *limp;
+ int error = 0;
+
+ limp = &p->p_rlimit[RLIMIT_FSIZE];
+ switch (SCARG(uap, cmd)) {
+ case 2:
+ SCARG(uap, newlimit) *= 512;
+ if (SCARG(uap, newlimit) > limp->rlim_max &&
+ (error = suser(p->p_ucred, &p->p_acflag)))
+ break;
+ limp->rlim_cur = limp->rlim_max = SCARG(uap, newlimit);
+ /* else fall into... */
+
+ case 1:
+ *retval = limp->rlim_max / 512;
+ break;
+
+ case 3:
+ limp = &p->p_rlimit[RLIMIT_DATA];
+ *retval = ctob(p->p_vmspace->vm_tsize) + limp->rlim_max;
+ break;
+
+ default:
+ error = EINVAL;
+ break;
+ }
+ return (error);
+}
+
+/*
+ * Map "real time" priorities 0 (high) thru 127 (low) into nice
+ * values -16 (high) thru -1 (low).
+ */
+int
+hpux_sys_rtprio(cp, v, retval)
+ struct proc *cp;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_rtprio_args *uap = v;
+ struct proc *p;
+ int nice, error;
+
+ if (SCARG(uap, prio) < RTPRIO_MIN && SCARG(uap, prio) > RTPRIO_MAX &&
+ SCARG(uap, prio) != RTPRIO_NOCHG &&
+ SCARG(uap, prio) != RTPRIO_RTOFF)
+ return (EINVAL);
+ if (SCARG(uap, pid) == 0)
+ p = cp;
+ else if ((p = pfind(SCARG(uap, pid))) == 0)
+ return (ESRCH);
+ nice = p->p_nice;
+ if (nice < NZERO)
+ *retval = (nice + 16) << 3;
+ else
+ *retval = RTPRIO_RTOFF;
+ switch (SCARG(uap, prio)) {
+
+ case RTPRIO_NOCHG:
+ return (0);
+
+ case RTPRIO_RTOFF:
+ if (nice >= NZERO)
+ return (0);
+ nice = NZERO;
+ break;
+
+ default:
+ nice = (SCARG(uap, prio) >> 3) - 16;
+ break;
+ }
+ error = donice(cp, p, nice);
+ if (error == EACCES)
+ error = EPERM;
+ return (error);
+}
+
+/*
+ * XXX: This belongs in hpux_machdep.c !!
+ */
+int
+hpux_sys_advise(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_advise_args *uap = v;
+ int error = 0;
+
+#ifdef hp300
+ switch (SCARG(uap, arg)) {
+ case 0:
+ p->p_md.md_flags |= MDP_HPUXMMAP;
+ break;
+ case 1:
+ ICIA();
+ break;
+ case 2:
+ DCIA();
+ break;
+ default:
+ error = EINVAL;
+ break;
+ }
+#endif
+ return (error);
+}
+
+int
+hpux_sys_ptrace(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_ptrace_args *uap = v;
+ int error, isps = 0;
+ struct proc *cp;
+
+ switch (SCARG(uap, req)) {
+ /* map signal */
+#if defined(PT_STEP) || defined(PT_CONTINUE)
+# ifdef PT_STEP
+ case PT_STEP:
+# endif
+# ifdef PT_CONTINUE
+ case PT_CONTINUE:
+# endif
+ if (SCARG(uap, data)) {
+ SCARG(uap, data) = hpuxtobsdsig(SCARG(uap, data));
+ if (SCARG(uap, data) == 0)
+ SCARG(uap, data) = NSIG;
+ }
+ break;
+#endif
+ /* map u-area offset */
+#if defined(PT_READ_U) || defined(PT_WRITE_U)
+# ifdef PT_READ_U
+ case PT_READ_U:
+# endif
+# ifdef PT_WRITE_U
+ case PT_WRITE_U:
+# endif
+ /*
+ * Big, cheezy hack: hpuxtobsduoff is really intended
+ * to be called in the child context (procxmt) but we
+ * do it here in the parent context to avoid hacks in
+ * the MI sys_process.c file. This works only because
+ * we can access the child's md_regs pointer and it
+ * has the correct value (the child has already trapped
+ * into the kernel).
+ */
+ if ((cp = pfind(SCARG(uap, pid))) == 0)
+ return (ESRCH);
+ SCARG(uap, addr) =
+ (int *)hpuxtobsduoff(SCARG(uap, addr), &isps, cp);
+
+ /*
+ * Since HP-UX PS is only 16-bits in ar0, requests
+ * to write PS actually contain the PS in the high word
+ * and the high half of the PC (the following register)
+ * in the low word. Move the PS value to where BSD
+ * expects it.
+ */
+ if (isps && SCARG(uap, req) == PT_WRITE_U)
+ SCARG(uap, data) >>= 16;
+ break;
+#endif
+ }
+
+ error = sys_ptrace(p, uap, retval);
+ /*
+ * Align PS as HP-UX expects it (see WRITE_U comment above).
+ * Note that we do not return the high part of PC like HP-UX
+ * would, but the HP-UX debuggers don't require it.
+ */
+#ifdef PT_READ_U
+ if (isps && error == 0 && SCARG(uap, req) == PT_READ_U)
+ *retval <<= 16;
+#endif
+ return (error);
+}
+
+#ifdef SYSVSHM
+#include <sys/shm.h>
+
+int
+hpux_sys_shmctl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_shmctl_args *uap = v;
+
+ return (hpux_shmctl1(p, (struct hpux_shmctl_args *) uap, retval, 0));
+}
+
+int
+hpux_sys_nshmctl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval; /* struct hpux_nshmctl_args * */
+{
+ struct hpux_sys_nshmctl_args *uap = v;
+
+ return (hpux_shmctl1(p, (struct hpux_shmctl_args *) uap, retval, 1));
+}
+
+/*
+ * Handle HP-UX specific commands.
+ */
+int
+hpux_shmctl1(p, uap, retval, isnew)
+ struct proc *p;
+ struct hpux_sys_shmctl_args *uap;
+ register_t *retval;
+ int isnew;
+{
+ register struct shmid_ds *shp;
+ register struct ucred *cred = p->p_ucred;
+ struct hpux_shmid_ds sbuf;
+ int error;
+ extern struct shmid_ds *shm_find_segment_by_shmid __P((int));
+
+ if ((shp = shm_find_segment_by_shmid(SCARG(uap, shmid))) == NULL)
+ return EINVAL;
+
+ switch (SCARG(uap, cmd)) {
+ case SHM_LOCK:
+ case SHM_UNLOCK:
+ /* don't really do anything, but make them think we did */
+ if (cred->cr_uid && cred->cr_uid != shp->shm_perm.uid &&
+ cred->cr_uid != shp->shm_perm.cuid)
+ return (EPERM);
+ return (0);
+
+ case IPC_STAT:
+ if (!isnew)
+ break;
+ error = ipcperm(cred, &shp->shm_perm, IPC_R);
+ if (error == 0) {
+ sbuf.shm_perm.uid = shp->shm_perm.uid;
+ sbuf.shm_perm.gid = shp->shm_perm.gid;
+ sbuf.shm_perm.cuid = shp->shm_perm.cuid;
+ sbuf.shm_perm.cgid = shp->shm_perm.cgid;
+ sbuf.shm_perm.mode = shp->shm_perm.mode;
+ sbuf.shm_perm.seq = shp->shm_perm.seq;
+ sbuf.shm_perm.key = shp->shm_perm.key;
+ sbuf.shm_segsz = shp->shm_segsz;
+ sbuf.shm_ptbl = shp->shm_internal; /* XXX */
+ sbuf.shm_lpid = shp->shm_lpid;
+ sbuf.shm_cpid = shp->shm_cpid;
+ sbuf.shm_nattch = shp->shm_nattch;
+ sbuf.shm_cnattch = shp->shm_nattch; /* XXX */
+ sbuf.shm_atime = shp->shm_atime;
+ sbuf.shm_dtime = shp->shm_dtime;
+ sbuf.shm_ctime = shp->shm_ctime;
+ error = copyout((caddr_t)&sbuf, SCARG(uap, buf),
+ sizeof sbuf);
+ }
+ return (error);
+
+ case IPC_SET:
+ if (!isnew)
+ break;
+ if (cred->cr_uid && cred->cr_uid != shp->shm_perm.uid &&
+ cred->cr_uid != shp->shm_perm.cuid) {
+ return (EPERM);
+ }
+ error = copyin(SCARG(uap, buf), (caddr_t)&sbuf, sizeof sbuf);
+ if (error == 0) {
+ shp->shm_perm.uid = sbuf.shm_perm.uid;
+ shp->shm_perm.gid = sbuf.shm_perm.gid;
+ shp->shm_perm.mode = (shp->shm_perm.mode & ~0777)
+ | (sbuf.shm_perm.mode & 0777);
+ shp->shm_ctime = time.tv_sec;
+ }
+ return (error);
+ }
+ return (sys_shmctl(p, uap, retval));
+}
+#endif
+
+/*
+ * HP-UX mmap() emulation (mainly for shared library support).
+ */
+int
+hpux_sys_mmap(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_mmap_args *uap = v;
+ struct sys_mmap_args /* {
+ syscallarg(caddr_t) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) prot;
+ syscallarg(int) flags;
+ syscallarg(int) fd;
+ syscallarg(long) pad;
+ syscallarg(off_t) pos;
+ } */ nargs;
+
+ SCARG(&nargs, addr) = SCARG(uap, addr);
+ SCARG(&nargs, len) = SCARG(uap, len);
+ SCARG(&nargs, prot) = SCARG(uap, prot);
+ SCARG(&nargs, flags) = SCARG(uap, flags) &
+ ~(HPUXMAP_FIXED|HPUXMAP_REPLACE|HPUXMAP_ANON);
+ if (SCARG(uap, flags) & HPUXMAP_FIXED)
+ SCARG(&nargs, flags) |= MAP_FIXED;
+ if (SCARG(uap, flags) & HPUXMAP_ANON)
+ SCARG(&nargs, flags) |= MAP_ANON;
+ SCARG(&nargs, fd) = (SCARG(&nargs, flags) & MAP_ANON) ? -1 : SCARG(uap, fd);
+ SCARG(&nargs, pos) = SCARG(uap, pos);
+
+ return (sys_mmap(p, &nargs, retval));
+}
+
+hpux_stat1(fname, hsb, follow, p)
+ char *fname;
+ struct hpux_stat *hsb;
+ int follow;
+ struct proc *p;
+{
+ int error;
+ struct stat sb;
+ struct nameidata nd;
+
+ NDINIT(&nd, LOOKUP, follow | LOCKLEAF, UIO_USERSPACE, fname, p);
+ if (error = namei(&nd))
+ return (error);
+ error = vn_stat(nd.ni_vp, &sb, p);
+ vput(nd.ni_vp);
+ if (error == 0)
+ error = bsdtohpuxstat(&sb, hsb);
+ return (error);
+}
+
+#ifdef hp300
+#include "grf.h"
+#define NHIL 1 /* XXX */
+#endif
+
+#if NGRF > 0
+extern int grfopen __P((dev_t dev, int oflags, int devtype, struct proc *p));
+#endif
+
+#if NHIL > 0
+extern int hilopen __P((dev_t dev, int oflags, int devtype, struct proc *p));
+#endif
+
+#include <sys/conf.h>
+
+int
+bsdtohpuxstat(sb, hsb)
+ struct stat *sb;
+ struct hpux_stat *hsb;
+{
+ struct hpux_stat ds;
+
+ bzero((caddr_t)&ds, sizeof(ds));
+ ds.hst_dev = (u_short)sb->st_dev;
+ ds.hst_ino = (u_long)sb->st_ino;
+ ds.hst_mode = sb->st_mode;
+ ds.hst_nlink = sb->st_nlink;
+ ds.hst_uid = (u_short)sb->st_uid;
+ ds.hst_gid = (u_short)sb->st_gid;
+ ds.hst_rdev = bsdtohpuxdev(sb->st_rdev);
+
+ /* XXX: I don't want to talk about it... */
+ if ((sb->st_mode & S_IFMT) == S_IFCHR)
+#if NGRF > 0
+ if (cdevsw[major(sb->st_rdev)].d_open == grfopen)
+ ds.hst_rdev = grfdevno(sb->st_rdev);
+ else
+#endif
+#if NHIL > 0
+ if (cdevsw[major(sb->st_rdev)].d_open == hilopen)
+ ds.hst_rdev = hildevno(sb->st_rdev);
+#endif
+
+ if (sb->st_size < (quad_t)1 << 32)
+ ds.hst_size = (long)sb->st_size;
+ else
+ ds.hst_size = -2;
+ ds.hst_atime = sb->st_atime;
+ ds.hst_mtime = sb->st_mtime;
+ ds.hst_ctime = sb->st_ctime;
+ ds.hst_blksize = sb->st_blksize;
+ ds.hst_blocks = sb->st_blocks;
+ return(copyout((caddr_t)&ds, (caddr_t)hsb, sizeof(ds)));
+}
+
+int
+hpuxtobsdioctl(com)
+ u_long com;
+{
+ switch (com) {
+ case HPUXTIOCSLTC:
+ com = TIOCSLTC; break;
+ case HPUXTIOCGLTC:
+ com = TIOCGLTC; break;
+ case HPUXTIOCSPGRP:
+ com = TIOCSPGRP; break;
+ case HPUXTIOCGPGRP:
+ com = TIOCGPGRP; break;
+ case HPUXTIOCLBIS:
+ com = TIOCLBIS; break;
+ case HPUXTIOCLBIC:
+ com = TIOCLBIC; break;
+ case HPUXTIOCLSET:
+ com = TIOCLSET; break;
+ case HPUXTIOCLGET:
+ com = TIOCLGET; break;
+ case HPUXTIOCGWINSZ:
+ com = TIOCGWINSZ; break;
+ case HPUXTIOCSWINSZ:
+ com = TIOCSWINSZ; break;
+ }
+ return(com);
+}
+
+/*
+ * HP-UX ioctl system call. The differences here are:
+ * IOC_IN also means IOC_VOID if the size portion is zero.
+ * no FIOCLEX/FIONCLEX/FIOASYNC/FIOGETOWN/FIOSETOWN
+ * the sgttyb struct is 2 bytes longer
+ */
+int
+hpux_sys_ioctl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_ioctl_args *uap = v;
+ register struct filedesc *fdp = p->p_fd;
+ register struct file *fp;
+ register int com, error;
+ register u_int size;
+ caddr_t memp = 0;
+#define STK_PARAMS 128
+ char stkbuf[STK_PARAMS];
+ caddr_t dt = stkbuf;
+
+ com = SCARG(uap, com);
+
+#ifdef COMPAT_HPUX_6X
+ /* XXX */
+ if (com == HPUXTIOCGETP || com == HPUXTIOCSETP)
+ return (getsettty(p, SCARG(uap, fd), com, SCARG(uap, data)));
+#endif
+
+ if (((unsigned)SCARG(uap, fd)) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
+ return (EBADF);
+ if ((fp->f_flag & (FREAD|FWRITE)) == 0)
+ return (EBADF);
+
+ /*
+ * Interpret high order word to find
+ * amount of data to be copied to/from the
+ * user's address space.
+ */
+ size = IOCPARM_LEN(com);
+ if (size > IOCPARM_MAX)
+ return (ENOTTY);
+ if (size > sizeof (stkbuf)) {
+ memp = (caddr_t)malloc((u_long)size, M_IOCTLOPS, M_WAITOK);
+ dt = memp;
+ }
+ if (com&IOC_IN) {
+ if (size) {
+ error = copyin(SCARG(uap, data), dt, (u_int)size);
+ if (error) {
+ if (memp)
+ free(memp, M_IOCTLOPS);
+ return (error);
+ }
+ } else
+ *(caddr_t *)dt = SCARG(uap, data);
+ } else if ((com&IOC_OUT) && size)
+ /*
+ * Zero the buffer so the user always
+ * gets back something deterministic.
+ */
+ bzero(dt, size);
+ else if (com&IOC_VOID)
+ *(caddr_t *)dt = SCARG(uap, data);
+
+ switch (com) {
+
+ case HPUXFIOSNBIO:
+ {
+ char *ofp = &fdp->fd_ofileflags[SCARG(uap, fd)];
+ int tmp;
+
+ if (*(int *)dt)
+ *ofp |= UF_FIONBIO_ON;
+ else
+ *ofp &= ~UF_FIONBIO_ON;
+ /*
+ * Only set/clear if O_NONBLOCK/FNDELAY not in effect
+ */
+ if ((*ofp & (UF_NONBLOCK_ON|UF_FNDELAY_ON)) == 0) {
+ tmp = *ofp & UF_FIONBIO_ON;
+ error = (*fp->f_ops->fo_ioctl)(fp, FIONBIO,
+ (caddr_t)&tmp, p);
+ }
+ break;
+ }
+
+ case HPUXTIOCCONS:
+ *(int *)dt = 1;
+ error = (*fp->f_ops->fo_ioctl)(fp, TIOCCONS, dt, p);
+ break;
+
+ /* BSD-style job control ioctls */
+ case HPUXTIOCLBIS:
+ case HPUXTIOCLBIC:
+ case HPUXTIOCLSET:
+ *(int *)dt &= HPUXLTOSTOP;
+ if (*(int *)dt & HPUXLTOSTOP)
+ *(int *)dt = LTOSTOP;
+ /* fall into */
+
+ /* simple mapping cases */
+ case HPUXTIOCLGET:
+ case HPUXTIOCSLTC:
+ case HPUXTIOCGLTC:
+ case HPUXTIOCSPGRP:
+ case HPUXTIOCGPGRP:
+ case HPUXTIOCGWINSZ:
+ case HPUXTIOCSWINSZ:
+ error = (*fp->f_ops->fo_ioctl)
+ (fp, hpuxtobsdioctl(com), dt, p);
+ if (error == 0 && com == HPUXTIOCLGET) {
+ *(int *)dt &= LTOSTOP;
+ if (*(int *)dt & LTOSTOP)
+ *(int *)dt = HPUXLTOSTOP;
+ }
+ break;
+
+ /* SYS 5 termio and POSIX termios */
+ case HPUXTCGETA:
+ case HPUXTCSETA:
+ case HPUXTCSETAW:
+ case HPUXTCSETAF:
+ case HPUXTCGETATTR:
+ case HPUXTCSETATTR:
+ case HPUXTCSETATTRD:
+ case HPUXTCSETATTRF:
+ error = hpux_termio(SCARG(uap, fd), com, dt, p);
+ break;
+
+ default:
+ error = (*fp->f_ops->fo_ioctl)(fp, com, dt, p);
+ break;
+ }
+ /*
+ * Copy any data to user, size was
+ * already set and checked above.
+ */
+ if (error == 0 && (com&IOC_OUT) && size)
+ error = copyout(dt, SCARG(uap, data), (u_int)size);
+ if (memp)
+ free(memp, M_IOCTLOPS);
+ return (error);
+}
+
+/*
+ * XXX: This should be in hpux_machdep.c !!
+ */
+/*
+ * Man page lies, behaviour here is based on observed behaviour.
+ */
+int
+hpux_sys_getcontext(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_getcontext_args *uap = v;
+ int error = 0;
+ register int len;
+
+#ifdef HP380
+ if (machineid == HP_380) {
+ len = min(SCARG(uap, len), sizeof(hpux_040context));
+ if (len)
+ error = copyout(hpux_040context, SCARG(uap, buf), len);
+ if (error == 0)
+ *retval = sizeof(hpux_040context);
+ return (error);
+ }
+#endif
+ len = min(SCARG(uap, len), sizeof(hpux_context));
+ if (len)
+ error = copyout(hpux_context, SCARG(uap, buf), (u_int)len);
+ if (error == 0)
+ *retval = sizeof(hpux_context);
+ return (error);
+}
+
+/*
+ * This is the equivalent of BSD getpgrp but with more restrictions.
+ * Note we do not check the real uid or "saved" uid.
+ */
+int
+hpux_sys_getpgrp2(cp, v, retval)
+ struct proc *cp;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_getpgrp2_args *uap = v;
+ register struct proc *p;
+
+ if (SCARG(uap, pid) == 0)
+ SCARG(uap, pid) = cp->p_pid;
+ p = pfind(SCARG(uap, pid));
+ if (p == 0)
+ return (ESRCH);
+ if (cp->p_ucred->cr_uid && p->p_ucred->cr_uid != cp->p_ucred->cr_uid &&
+ !inferior(p))
+ return (EPERM);
+ *retval = p->p_pgid;
+ return (0);
+}
+
+/*
+ * This is the equivalent of BSD setpgrp but with more restrictions.
+ * Note we do not check the real uid or "saved" uid or pgrp.
+ */
+int
+hpux_sys_setpgrp2(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_setpgrp2_args *uap = v;
+
+ /* empirically determined */
+ if (SCARG(uap, pgid) < 0 || SCARG(uap, pgid) >= 30000)
+ return (EINVAL);
+ return (sys_setpgid(p, uap, retval));
+}
+
+/*
+ * XXX Same as BSD setre[ug]id right now. Need to consider saved ids.
+ */
+int
+hpux_sys_setresuid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_setresuid_args *uap = v;
+
+ return (compat_43_sys_setreuid(p, uap, retval));
+}
+
+int
+hpux_sys_setresgid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_setresgid_args *uap = v;
+
+ return (compat_43_sys_setregid(p, uap, retval));
+}
+
+int
+hpux_sys_getrlimit(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_getrlimit_args *uap = v;
+ struct compat_43_sys_getrlimit_args ap;
+
+ if (SCARG(uap, which) > HPUXRLIMIT_NOFILE)
+ return (EINVAL);
+ if (SCARG(uap, which) == HPUXRLIMIT_NOFILE)
+ SCARG(uap, which) = RLIMIT_NOFILE;
+
+ SCARG(&ap, which) = SCARG(uap, which);
+ SCARG(&ap, rlp) = SCARG(uap, rlp);
+
+ return (compat_43_sys_getrlimit(p, uap, retval));
+}
+
+int
+hpux_sys_setrlimit(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_setrlimit_args *uap = v;
+ struct compat_43_sys_setrlimit_args ap;
+
+ if (SCARG(uap, which) > HPUXRLIMIT_NOFILE)
+ return (EINVAL);
+ if (SCARG(uap, which) == HPUXRLIMIT_NOFILE)
+ SCARG(uap, which) = RLIMIT_NOFILE;
+
+ SCARG(&ap, which) = SCARG(uap, which);
+ SCARG(&ap, rlp) = SCARG(uap, rlp);
+
+ return (compat_43_sys_setrlimit(p, uap, retval));
+}
+
+/*
+ * XXX: simple recognition hack to see if we can make grmd work.
+ */
+int
+hpux_sys_lockf(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_lockf_args *uap = v;
+
+ return (0);
+}
+
+int
+hpux_sys_getaccess(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_getaccess_args *uap = v;
+ int lgroups[NGROUPS];
+ int error = 0;
+ register struct ucred *cred;
+ register struct vnode *vp;
+ struct nameidata nd;
+
+ /*
+ * Build an appropriate credential structure
+ */
+ cred = crdup(p->p_ucred);
+ switch (SCARG(uap, uid)) {
+ case 65502: /* UID_EUID */
+ break;
+ case 65503: /* UID_RUID */
+ cred->cr_uid = p->p_cred->p_ruid;
+ break;
+ case 65504: /* UID_SUID */
+ error = EINVAL;
+ break;
+ default:
+ if (SCARG(uap, uid) > 65504)
+ error = EINVAL;
+ cred->cr_uid = SCARG(uap, uid);
+ break;
+ }
+ switch (SCARG(uap, ngroups)) {
+ case -1: /* NGROUPS_EGID */
+ cred->cr_ngroups = 1;
+ break;
+ case -5: /* NGROUPS_EGID_SUPP */
+ break;
+ case -2: /* NGROUPS_RGID */
+ cred->cr_ngroups = 1;
+ cred->cr_gid = p->p_cred->p_rgid;
+ break;
+ case -6: /* NGROUPS_RGID_SUPP */
+ cred->cr_gid = p->p_cred->p_rgid;
+ break;
+ case -3: /* NGROUPS_SGID */
+ case -7: /* NGROUPS_SGID_SUPP */
+ error = EINVAL;
+ break;
+ case -4: /* NGROUPS_SUPP */
+ if (cred->cr_ngroups > 1)
+ cred->cr_gid = cred->cr_groups[1];
+ else
+ error = EINVAL;
+ break;
+ default:
+ if (SCARG(uap, ngroups) > 0 && SCARG(uap, ngroups) <= NGROUPS)
+ error = copyin((caddr_t)SCARG(uap, gidset),
+ (caddr_t)&lgroups[0],
+ SCARG(uap, ngroups) *
+ sizeof(lgroups[0]));
+ else
+ error = EINVAL;
+ if (error == 0) {
+ int gid;
+
+ for (gid = 0; gid < SCARG(uap, ngroups); gid++)
+ cred->cr_groups[gid] = lgroups[gid];
+ cred->cr_ngroups = SCARG(uap, ngroups);
+ }
+ break;
+ }
+ /*
+ * Lookup file using caller's effective IDs.
+ */
+ if (error == 0) {
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
+ SCARG(uap, path), p);
+ error = namei(&nd);
+ }
+ if (error) {
+ crfree(cred);
+ return (error);
+ }
+ /*
+ * Use the constructed credentials for access checks.
+ */
+ vp = nd.ni_vp;
+ *retval = 0;
+ if (VOP_ACCESS(vp, VREAD, cred, p) == 0)
+ *retval |= R_OK;
+ if (vn_writechk(vp) == 0 && VOP_ACCESS(vp, VWRITE, cred, p) == 0)
+ *retval |= W_OK;
+ /* XXX we return X_OK for root on VREG even if not */
+ if (VOP_ACCESS(vp, VEXEC, cred, p) == 0)
+ *retval |= X_OK;
+ vput(vp);
+ crfree(cred);
+ return (error);
+}
+
+/*
+ * XXX: This needs to be in hpux_machdep.c !!
+ */
+extern char kstack[];
+#define UOFF(f) ((int)&((struct user *)0)->f)
+#define HPUOFF(f) ((int)&((struct hpux_user *)0)->f)
+
+/* simplified FP structure */
+struct bsdfp {
+ int save[54];
+ int reg[24];
+ int ctrl[3];
+};
+
+/*
+ * Brutal hack! Map HP-UX u-area offsets into BSD k-stack offsets.
+ */
+hpuxtobsduoff(off, isps, p)
+ int *off, *isps;
+ struct proc *p;
+{
+#ifdef hp300
+ register int *ar0 = p->p_md.md_regs;
+ struct hpux_fp *hp;
+ struct bsdfp *bp;
+ register u_int raddr;
+
+ *isps = 0;
+
+ /* u_ar0 field; procxmt puts in U_ar0 */
+ if ((int)off == HPUOFF(hpuxu_ar0))
+ return(UOFF(U_ar0));
+
+#ifdef FPCOPROC
+ /* FP registers from PCB */
+ hp = (struct hpux_fp *)HPUOFF(hpuxu_fp);
+ bp = (struct bsdfp *)UOFF(u_pcb.pcb_fpregs);
+ if (off >= hp->hpfp_ctrl && off < &hp->hpfp_ctrl[3])
+ return((int)&bp->ctrl[off - hp->hpfp_ctrl]);
+ if (off >= hp->hpfp_reg && off < &hp->hpfp_reg[24])
+ return((int)&bp->reg[off - hp->hpfp_reg]);
+#endif
+
+ /*
+ * Everything else we recognize comes from the kernel stack,
+ * so we convert off to an absolute address (if not already)
+ * for simplicity.
+ */
+ if (off < (int *)ctob(UPAGES))
+ off = (int *)((u_int)off + (u_int)kstack);
+
+ /*
+ * General registers.
+ * We know that the HP-UX registers are in the same order as ours.
+ * The only difference is that their PS is 2 bytes instead of a
+ * padded 4 like ours throwing the alignment off.
+ */
+ if (off >= ar0 && off < &ar0[18]) {
+ /*
+ * PS: return low word and high word of PC as HP-UX would
+ * (e.g. &u.u_ar0[16.5]).
+ *
+ * XXX we don't do this since HP-UX adb doesn't rely on
+ * it and passing such an offset to procxmt will cause
+ * it to fail anyway. Instead, we just set the offset
+ * to PS and let hpux_ptrace() shift up the value returned.
+ */
+ if (off == &ar0[PS]) {
+#if 0
+ raddr = (u_int) &((short *)ar0)[PS*2+1];
+#else
+ raddr = (u_int) &ar0[(int)(off - ar0)];
+#endif
+ *isps = 1;
+ }
+ /*
+ * PC: off will be &u.u_ar0[16.5] since HP-UX saved PS
+ * is only 16 bits.
+ */
+ else if (off == (int *)&(((short *)ar0)[PS*2+1]))
+ raddr = (u_int) &ar0[PC];
+ /*
+ * D0-D7, A0-A7: easy
+ */
+ else
+ raddr = (u_int) &ar0[(int)(off - ar0)];
+ return((int)(raddr - (u_int)kstack));
+ }
+#endif
+ /* everything else */
+ return(-1);
+}
+
+/*
+ * Kludge up a uarea dump so that HP-UX debuggers can find out
+ * what they need. IMPORTANT NOTE: we do not EVEN attempt to
+ * convert the entire user struct.
+ */
+int
+hpux_dumpu(vp, cred)
+ struct vnode *vp;
+ struct ucred *cred;
+{
+ int error = 0;
+#ifdef hp300
+ struct proc *p = curproc;
+ struct hpux_user *faku;
+ struct bsdfp *bp;
+ short *foop;
+
+ faku = (struct hpux_user *)malloc((u_long)ctob(1), M_TEMP, M_WAITOK);
+ /*
+ * Make sure there is no mistake about this
+ * being a real user structure.
+ */
+ bzero((caddr_t)faku, ctob(1));
+ /*
+ * Fill in the process sizes.
+ */
+ faku->hpuxu_tsize = p->p_vmspace->vm_tsize;
+ faku->hpuxu_dsize = p->p_vmspace->vm_dsize;
+ faku->hpuxu_ssize = p->p_vmspace->vm_ssize;
+ /*
+ * Fill in the exec header for CDB.
+ * This was saved back in exec(). As far as I can tell CDB
+ * only uses this information to verify that a particular
+ * core file goes with a particular binary.
+ */
+ bcopy((caddr_t)p->p_addr->u_md.md_exec,
+ (caddr_t)&faku->hpuxu_exdata, sizeof (struct hpux_exec));
+ /*
+ * Adjust user's saved registers (on kernel stack) to reflect
+ * HP-UX order. Note that HP-UX saves the SR as 2 bytes not 4
+ * so we have to move it up.
+ */
+ faku->hpuxu_ar0 = p->p_md.md_regs;
+ foop = (short *) p->p_md.md_regs;
+ foop[32] = foop[33];
+ foop[33] = foop[34];
+ foop[34] = foop[35];
+#ifdef FPCOPROC
+ /*
+ * Copy 68881 registers from our PCB format to HP-UX format
+ */
+ bp = (struct bsdfp *) &p->p_addr->u_pcb.pcb_fpregs;
+ bcopy((caddr_t)bp->save, (caddr_t)faku->hpuxu_fp.hpfp_save,
+ sizeof(bp->save));
+ bcopy((caddr_t)bp->ctrl, (caddr_t)faku->hpuxu_fp.hpfp_ctrl,
+ sizeof(bp->ctrl));
+ bcopy((caddr_t)bp->reg, (caddr_t)faku->hpuxu_fp.hpfp_reg,
+ sizeof(bp->reg));
+#endif
+ /*
+ * Slay the dragon
+ */
+ faku->hpuxu_dragon = -1;
+ /*
+ * Dump this artfully constructed page in place of the
+ * user struct page.
+ */
+ error = vn_rdwr(UIO_WRITE, vp, (caddr_t)faku, ctob(1), (off_t)0,
+ UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred,
+ (int *)NULL, p);
+ /*
+ * Dump the remaining UPAGES-1 pages normally
+ */
+ if (!error)
+ error = vn_rdwr(UIO_WRITE, vp, kstack + ctob(1),
+ ctob(UPAGES-1), (off_t)ctob(1), UIO_SYSSPACE,
+ IO_NODELOCKED|IO_UNIT, cred, (int *)NULL, p);
+ free((caddr_t)faku, M_TEMP);
+#endif
+ return(error);
+}
+
+/*
+ * The remaining routines are essentially the same as those in kern_xxx.c
+ * and vfs_xxx.c as defined under "#ifdef COMPAT". We replicate them here
+ * to avoid COMPAT_HPUX dependencies in those files and to make sure that
+ * HP-UX compatibility still works even when COMPAT is not defined.
+ *
+ * These are still needed as of HP-UX 7.05.
+ */
+#ifdef COMPAT_HPUX_6X
+
+#define HPUX_HZ 50
+
+#include "sys/times.h"
+
+
+/*
+ * SYS V style setpgrp()
+ */
+int
+compat_hpux_6x_sys_setpgrp(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_hpux_6x_sys_setpgrp_args *uap = v;
+
+ if (p->p_pid != p->p_pgid)
+ enterpgrp(p, p->p_pid, 0);
+ *retval = p->p_pgid;
+ return (0);
+}
+
+int
+compat_hpux_6x_sys_time(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_hpux_6x_sys_time_args *uap = v;
+
+ int error = 0;
+ struct timeval tv;
+
+ microtime(&tv);
+ if (SCARG(uap, t))
+ error = copyout(&tv.tv_sec, SCARG(uap, t),
+ sizeof(*(SCARG(uap, t))));
+
+ *retval = (int) tv.tv_sec;
+ return error;
+}
+
+int
+compat_hpux_6x_sys_stime(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_hpux_6x_sys_stime_args *uap = v;
+ struct timeval tv;
+ int s, error;
+
+ tv.tv_sec = SCARG(uap, time);
+ tv.tv_usec = 0;
+ if (error = suser(p->p_ucred, &p->p_acflag))
+ return (error);
+
+ /* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
+ boottime.tv_sec += tv.tv_sec - time.tv_sec;
+ s = splhigh(); time = tv; splx(s);
+ resettodr();
+ return (0);
+}
+
+int
+compat_hpux_6x_sys_ftime(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_hpux_6x_sys_ftime_args *uap = v;
+ struct hpux_otimeb tb;
+ int s;
+
+ s = splhigh();
+ tb.time = time.tv_sec;
+ tb.millitm = time.tv_usec / 1000;
+ splx(s);
+ tb.timezone = tz.tz_minuteswest;
+ tb.dstflag = tz.tz_dsttime;
+ return (copyout((caddr_t)&tb, (caddr_t)SCARG(uap, tp), sizeof (tb)));
+}
+
+int
+compat_hpux_6x_sys_alarm(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_hpux_6x_sys_alarm_args *uap = v;
+ int s = splhigh();
+
+ untimeout(realitexpire, (caddr_t)p);
+ timerclear(&p->p_realtimer.it_interval);
+ *retval = 0;
+ if (timerisset(&p->p_realtimer.it_value) &&
+ timercmp(&p->p_realtimer.it_value, &time, >))
+ *retval = p->p_realtimer.it_value.tv_sec - time.tv_sec;
+ if (SCARG(uap, deltat) == 0) {
+ timerclear(&p->p_realtimer.it_value);
+ splx(s);
+ return (0);
+ }
+ p->p_realtimer.it_value = time;
+ p->p_realtimer.it_value.tv_sec += SCARG(uap, deltat);
+ timeout(realitexpire, (caddr_t)p, hzto(&p->p_realtimer.it_value));
+ splx(s);
+ return (0);
+}
+
+int
+compat_hpux_6x_sys_nice(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_hpux_6x_sys_nice_args *uap = v;
+ int error;
+
+ error = donice(p, p, (p->p_nice-NZERO)+SCARG(uap, nval));
+ if (error == 0)
+ *retval = p->p_nice - NZERO;
+ return (error);
+}
+
+int
+compat_hpux_6x_sys_times(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_hpux_6x_sys_times_args *uap = v;
+ struct timeval ru, rs;
+ struct tms atms;
+ int error;
+
+ calcru(p, &ru, &rs, NULL);
+ atms.tms_utime = hpux_scale(&ru);
+ atms.tms_stime = hpux_scale(&rs);
+ atms.tms_cutime = hpux_scale(&p->p_stats->p_cru.ru_utime);
+ atms.tms_cstime = hpux_scale(&p->p_stats->p_cru.ru_stime);
+ error = copyout((caddr_t)&atms, (caddr_t)SCARG(uap, tms),
+ sizeof (atms));
+ if (error == 0)
+ *(time_t *)retval = hpux_scale(&time) - hpux_scale(&boottime);
+ return (error);
+}
+
+/*
+ * Doesn't exactly do what the documentation says.
+ * What we really do is return 1/HPUX_HZ-th of a second since that
+ * is what HP-UX returns.
+ */
+int
+hpux_scale(tvp)
+ register struct timeval *tvp;
+{
+ return (tvp->tv_sec * HPUX_HZ + tvp->tv_usec * HPUX_HZ / 1000000);
+}
+
+/*
+ * Set IUPD and IACC times on file.
+ * Can't set ICHG.
+ */
+int
+compat_hpux_6x_sys_utime(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_hpux_6x_sys_utime_args *uap = v;
+ register struct vnode *vp;
+ struct vattr vattr;
+ time_t tv[2];
+ int error;
+ struct nameidata nd;
+
+ if (SCARG(uap, tptr)) {
+ error = copyin((caddr_t)SCARG(uap, tptr), (caddr_t)tv,
+ sizeof (tv));
+ if (error)
+ return (error);
+ } else
+ tv[0] = tv[1] = time.tv_sec;
+ vattr_null(&vattr);
+ vattr.va_atime.ts_sec = tv[0];
+ vattr.va_atime.ts_nsec = 0;
+ vattr.va_mtime.ts_sec = tv[1];
+ vattr.va_mtime.ts_nsec = 0;
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
+ SCARG(uap, fname), p);
+ if (error = namei(&nd))
+ return (error);
+ vp = nd.ni_vp;
+ if (vp->v_mount->mnt_flag & MNT_RDONLY)
+ error = EROFS;
+ else
+ error = VOP_SETATTR(vp, &vattr, nd.ni_cnd.cn_cred, p);
+ vput(vp);
+ return (error);
+}
+
+int
+compat_hpux_6x_sys_pause(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_hpux_6x_sys_pause_args *uap = v;
+
+ (void) tsleep(kstack, PPAUSE | PCATCH, "pause", 0);
+ /* always return EINTR rather than ERESTART... */
+ return (EINTR);
+}
+
+/*
+ * The old fstat system call.
+ */
+int
+compat_hpux_6x_sys_fstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_hpux_6x_sys_fstat_args *uap = v;
+ register struct filedesc *fdp = p->p_fd;
+ struct file *fp;
+
+ if (((unsigned)SCARG(uap, fd)) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
+ return (EBADF);
+ if (fp->f_type != DTYPE_VNODE)
+ return (EINVAL);
+ return (compat_hpux_6x_stat1((struct vnode *)fp->f_data,
+ SCARG(uap, sb), p));
+}
+
+/*
+ * Old stat system call. This version follows links.
+ */
+int
+compat_hpux_6x_sys_stat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct compat_hpux_6x_sys_stat_args *uap = v;
+ int error;
+ struct nameidata nd;
+
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
+ SCARG(uap, path), p);
+ if (error = namei(&nd))
+ return (error);
+ error = compat_hpux_6x_stat1(nd.ni_vp, SCARG(uap, sb), p);
+ vput(nd.ni_vp);
+ return (error);
+}
+
+int
+compat_hpux_6x_stat1(vp, ub, p)
+ struct vnode *vp;
+ struct hpux_ostat *ub;
+ struct proc *p;
+{
+ struct hpux_ostat ohsb;
+ struct stat sb;
+ int error;
+
+ error = vn_stat(vp, &sb, p);
+ if (error)
+ return (error);
+
+ ohsb.hst_dev = sb.st_dev;
+ ohsb.hst_ino = sb.st_ino;
+ ohsb.hst_mode = sb.st_mode;
+ ohsb.hst_nlink = sb.st_nlink;
+ ohsb.hst_uid = sb.st_uid;
+ ohsb.hst_gid = sb.st_gid;
+ ohsb.hst_rdev = sb.st_rdev;
+ if (sb.st_size < (quad_t)1 << 32)
+ ohsb.hst_size = sb.st_size;
+ else
+ ohsb.hst_size = -2;
+ ohsb.hst_atime = sb.st_atime;
+ ohsb.hst_mtime = sb.st_mtime;
+ ohsb.hst_ctime = sb.st_ctime;
+ return (copyout((caddr_t)&ohsb, (caddr_t)ub, sizeof(ohsb)));
+}
+#endif
diff --git a/sys/compat/hpux/hpux_exec.h b/sys/compat/hpux/hpux_exec.h
new file mode 100644
index 00000000000..3f524c2b9e0
--- /dev/null
+++ b/sys/compat/hpux/hpux_exec.h
@@ -0,0 +1,63 @@
+/* $NetBSD: hpux_exec.h,v 1.5 1994/10/26 02:45:16 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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: Utah $Hdr: hpux_exec.h 1.6 92/01/20$
+ *
+ * @(#)hpux_exec.h 8.1 (Berkeley) 6/10/93
+ */
+
+/*
+ * HPUX a.out header format
+ */
+struct hpux_exec {
+ long ha_magic; /* magic number */
+ short ha_version; /* version ID */
+ short ha_pad0; /* doesn't matter */
+ long ha_misc; /* misc. info */
+unsigned long ha_text; /* size of text segment */
+unsigned long ha_data; /* size of initialized data */
+unsigned long ha_bss; /* size of uninitialized data */
+unsigned long ha_pad2[5]; /* doesn't matter */
+unsigned long ha_entry; /* entry point */
+unsigned long ha_pad3[4]; /* doesn't matter */
+};
+
+#define HPUXM_VALID 0x00000001
+#define HPUXM_STKWT 0x02000000
+#define HPUXM_DATAWT 0x04000000
diff --git a/sys/compat/hpux/hpux_net.c b/sys/compat/hpux/hpux_net.c
new file mode 100644
index 00000000000..e23a58a80fa
--- /dev/null
+++ b/sys/compat/hpux/hpux_net.c
@@ -0,0 +1,317 @@
+/* $NetBSD: hpux_net.c,v 1.12 1995/10/07 06:26:37 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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: Utah $Hdr: hpux_net.c 1.8 93/08/02$
+ *
+ * @(#)hpux_net.c 8.2 (Berkeley) 9/9/93
+ */
+
+/*
+ * Network related HP-UX compatibility routines
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/time.h>
+#include <sys/errno.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/mbuf.h>
+#include <sys/mount.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <sys/uio.h>
+#include <sys/ktrace.h>
+#include <sys/syscallargs.h>
+
+#include <compat/hpux/hpux.h>
+#include <compat/hpux/hpux_syscallargs.h>
+#include <compat/hpux/hpux_util.h>
+
+
+#define syscallarg(x) union { x datum; register_t pad; }
+
+struct hpux_sys_setsockopt_args {
+ syscallarg(int) s;
+ syscallarg(int) level;
+ syscallarg(int) name;
+ syscallarg(caddr_t) val;
+ syscallarg(int) valsize;
+};
+
+struct hpux_sys_getsockopt_args {
+ syscallarg(int) s;
+ syscallarg(int) level;
+ syscallarg(int) name;
+ syscallarg(caddr_t) val;
+ syscallarg(int *) avalsize;
+};
+
+int hpux_sys_setsockopt __P((struct proc *, void *, register_t *));
+int hpux_sys_getsockopt __P((struct proc *, void *, register_t *));
+
+
+#define MINBSDIPCCODE 0x3EE
+#define NUMBSDIPC 32
+
+/*
+ * HPUX netioctl() to BSD syscall map.
+ * Indexed by callno - MINBSDIPCCODE
+ */
+
+struct hpuxtobsdipc {
+ int (*rout)();
+ int nargs;
+} hpuxtobsdipc[NUMBSDIPC] = {
+ { sys_socket, 3 }, /* 3ee */
+ { sys_listen, 2 }, /* 3ef */
+ { sys_bind, 3 }, /* 3f0 */
+ { compat_43_sys_accept, 3 }, /* 3f1 */
+ { sys_connect, 3 }, /* 3f2 */
+ { compat_43_sys_recv, 4 }, /* 3f3 */
+ { compat_43_sys_send, 4 }, /* 3f4 */
+ { sys_shutdown, 2 }, /* 3f5 */
+ { compat_43_sys_getsockname, 3 }, /* 3f6 */
+ { hpux_sys_setsockopt, 5 }, /* 3f7 */
+ { sys_sendto, 6 }, /* 3f8 */
+ { compat_43_sys_recvfrom, 6 }, /* 3f9 */
+ { compat_43_sys_getpeername, 3 }, /* 3fa */
+ { NULL, 0 }, /* 3fb */
+ { NULL, 0 }, /* 3fc */
+ { NULL, 0 }, /* 3fd */
+ { NULL, 0 }, /* 3fe */
+ { NULL, 0 }, /* 3ff */
+ { NULL, 0 }, /* 400 */
+ { NULL, 0 }, /* 401 */
+ { NULL, 0 }, /* 402 */
+ { NULL, 0 }, /* 403 */
+ { NULL, 0 }, /* 404 */
+ { NULL, 0 }, /* 405 */
+ { NULL, 0 }, /* 406 */
+ { NULL, 0 }, /* 407 */
+ { NULL, 0 }, /* 408 */
+ { NULL, 0 }, /* 409 */
+ { NULL, 0 }, /* 40a */
+ { hpux_sys_getsockopt, 5 }, /* 40b */
+ { NULL, 0 }, /* 40c */
+ { NULL, 0 }, /* 40d */
+};
+
+/*
+ * Single system call entry to BSD style IPC.
+ * Gleened from disassembled libbsdipc.a syscall entries.
+ */
+int
+hpux_sys_netioctl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_netioctl_args *uap = v;
+ int *args, i;
+ register int code;
+ int error;
+
+ args = SCARG(uap, args);
+ code = SCARG(uap, call) - MINBSDIPCCODE;
+ if (code < 0 || code >= NUMBSDIPC || hpuxtobsdipc[code].rout == NULL)
+ return (EINVAL);
+ if ((i = hpuxtobsdipc[code].nargs * sizeof (int)) &&
+ (error = copyin((caddr_t)args, (caddr_t)uap, (u_int)i))) {
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_SYSCALL))
+ ktrsyscall(p->p_tracep, code + MINBSDIPCCODE,
+ hpuxtobsdipc[code].nargs,
+ (register_t *)uap);
+#endif
+ return (error);
+ }
+#ifdef KTRACE
+ if (KTRPOINT(p, KTR_SYSCALL))
+ ktrsyscall(p->p_tracep, code + MINBSDIPCCODE,
+ hpuxtobsdipc[code].nargs,
+ (register_t *)uap);
+#endif
+ return ((*hpuxtobsdipc[code].rout)(p, uap, retval));
+}
+
+int
+socksetsize(size, m)
+ int size;
+ struct mbuf *m;
+{
+ register int tmp;
+
+ if (size < sizeof(int)) {
+ switch(size) {
+ case 1:
+ tmp = (int) *mtod(m, char *);
+ break;
+ case 2:
+ tmp = (int) *mtod(m, short *);
+ break;
+ case 3:
+ tmp = (((int) *mtod(m, int *)) >> 8) & 0xffffff;
+ break;
+ }
+ *mtod(m, int *) = tmp;
+ m->m_len = sizeof(int);
+ } else {
+ m->m_len = size;
+ }
+}
+
+/* ARGSUSED */
+hpux_sys_setsockopt(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_setsockopt_args *uap = v;
+ struct file *fp;
+ struct mbuf *m = NULL;
+ int tmp, error;
+
+ if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ return (error);
+ if (SCARG(uap, valsize) > MLEN)
+ return (EINVAL);
+ if (SCARG(uap, val)) {
+ m = m_get(M_WAIT, MT_SOOPTS);
+ if (m == NULL)
+ return (ENOBUFS);
+ if (error = copyin(SCARG(uap, val), mtod(m, caddr_t),
+ (u_int)SCARG(uap, valsize))) {
+ (void) m_free(m);
+ return (error);
+ }
+ if (SCARG(uap, name) == SO_LINGER) {
+ tmp = *mtod(m, int *);
+ mtod(m, struct linger *)->l_onoff = 1;
+ mtod(m, struct linger *)->l_linger = tmp;
+ m->m_len = sizeof(struct linger);
+ } else
+ socksetsize(SCARG(uap, valsize), m);
+ } else if (SCARG(uap, name) == ~SO_LINGER) {
+ m = m_get(M_WAIT, MT_SOOPTS);
+ if (m) {
+ SCARG(uap, name) = SO_LINGER;
+ mtod(m, struct linger *)->l_onoff = 0;
+ m->m_len = sizeof(struct linger);
+ }
+ }
+ return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
+ SCARG(uap, name), m));
+}
+
+/* ARGSUSED */
+int
+hpux_sys_setsockopt2(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_setsockopt2_args *uap = v;
+ struct file *fp;
+ struct mbuf *m = NULL;
+ int error;
+
+ if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ return (error);
+ if (SCARG(uap, valsize) > MLEN)
+ return (EINVAL);
+ if (SCARG(uap, val)) {
+ m = m_get(M_WAIT, MT_SOOPTS);
+ if (m == NULL)
+ return (ENOBUFS);
+ if (error = copyin(SCARG(uap, val), mtod(m, caddr_t),
+ (u_int)SCARG(uap, valsize))) {
+ (void) m_free(m);
+ return (error);
+ }
+ socksetsize(SCARG(uap, valsize), m);
+ }
+ return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
+ SCARG(uap, name), m));
+}
+
+int
+hpux_sys_getsockopt(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_getsockopt_args *uap = v;
+ struct file *fp;
+ struct mbuf *m = NULL;
+ int valsize, error;
+
+ if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ return (error);
+ if (SCARG(uap, val)) {
+ if (error = copyin((caddr_t)SCARG(uap, avalsize),
+ (caddr_t)&valsize, sizeof (valsize)))
+ return (error);
+ } else
+ valsize = 0;
+ if (error = sogetopt((struct socket *)fp->f_data, SCARG(uap, level),
+ SCARG(uap, name), &m))
+ goto bad;
+ if (SCARG(uap, val) && valsize && m != NULL) {
+ if (SCARG(uap, name) == SO_LINGER) {
+ if (mtod(m, struct linger *)->l_onoff)
+ *mtod(m, int *) = mtod(m, struct linger *)->l_linger;
+ else
+ *mtod(m, int *) = 0;
+ m->m_len = sizeof(int);
+ }
+ if (valsize > m->m_len)
+ valsize = m->m_len;
+ error = copyout(mtod(m, caddr_t), SCARG(uap, val),
+ (u_int)valsize);
+ if (error == 0)
+ error = copyout((caddr_t)&valsize,
+ (caddr_t)SCARG(uap, avalsize), sizeof (valsize));
+ }
+bad:
+ if (m != NULL)
+ (void) m_free(m);
+ return (error);
+}
diff --git a/sys/compat/hpux/hpux_sig.c b/sys/compat/hpux/hpux_sig.c
new file mode 100644
index 00000000000..8443e5ae282
--- /dev/null
+++ b/sys/compat/hpux/hpux_sig.c
@@ -0,0 +1,437 @@
+/* $NetBSD: hpux_sig.c,v 1.14 1995/10/07 06:26:38 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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: Utah $Hdr: hpux_sig.c 1.4 92/01/20$
+ *
+ * @(#)hpux_sig.c 8.2 (Berkeley) 9/23/93
+ */
+
+/*
+ * Signal related HPUX compatibility routines
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/signalvar.h>
+
+#include <compat/hpux/hpux.h>
+#include <compat/hpux/hpux_syscallargs.h>
+
+/* indexed by HPUX signal number - 1 */
+char hpuxtobsdsigmap[NSIG] = {
+/*01*/ SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGTRAP, SIGIOT, SIGEMT, SIGFPE,
+/*09*/ SIGKILL, SIGBUS, SIGSEGV, SIGSYS, SIGPIPE, SIGALRM, SIGTERM, SIGUSR1,
+/*17*/ SIGUSR2, SIGCHLD, 0, SIGVTALRM,SIGPROF, SIGIO, SIGWINCH, SIGSTOP,
+/*25*/ SIGTSTP, SIGCONT,SIGTTIN, SIGTTOU, SIGURG, 0, 0, 0
+};
+
+/* indexed by BSD signal number - 1 */
+char bsdtohpuxsigmap[NSIG] = {
+/*01*/ 1, 2, 3, 4, 5, 6, 7, 8,
+/*09*/ 9, 10, 11, 12, 13, 14, 15, 29,
+/*17*/ 24, 25, 26, 18, 27, 28, 22, 0,
+/*25*/ 0, 20, 21, 23, 0, 16, 17, 0
+};
+
+/*
+ * XXX: In addition to mapping the signal number we also have
+ * to see if the "old" style signal mechinism is needed.
+ * If so, we set the OUSIG flag. This is not really correct
+ * as under HP-UX "old" style handling can be set on a per
+ * signal basis and we are setting it for all signals in one
+ * swell foop. I suspect we can get away with this since I
+ * doubt any program of interest mixes the two semantics.
+ */
+int
+hpux_sys_sigvec(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_sigvec_args *uap = v;
+ struct sigvec vec;
+ register struct sigacts *ps = p->p_sigacts;
+ register struct sigvec *sv;
+ register int sig;
+ int bit, error;
+
+ sig = hpuxtobsdsig(SCARG(uap, signo));
+ if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
+ return (EINVAL);
+ sv = &vec;
+ if (SCARG(uap, osv)) {
+ sv->sv_handler = ps->ps_sigact[sig];
+ sv->sv_mask = ps->ps_catchmask[sig];
+ bit = sigmask(sig);
+ sv->sv_flags = 0;
+ if ((ps->ps_sigonstack & bit) != 0)
+ sv->sv_flags |= SV_ONSTACK;
+ if ((ps->ps_sigintr & bit) != 0)
+ sv->sv_flags |= SV_INTERRUPT;
+ if ((ps->ps_sigreset & bit) != 0)
+ sv->sv_flags |= HPUXSV_RESET;
+ sv->sv_mask &= ~bit;
+ error = copyout((caddr_t)sv, (caddr_t)SCARG(uap, osv),
+ sizeof (vec));
+ if (error)
+ return (error);
+ }
+ if (SCARG(uap, nsv)) {
+ error = copyin((caddr_t)SCARG(uap, nsv), (caddr_t)sv,
+ sizeof (vec));
+ if (error)
+ return (error);
+ if (sig == SIGCONT && sv->sv_handler == SIG_IGN)
+ return (EINVAL);
+ sv->sv_flags ^= SA_RESTART;
+ setsigvec(p, sig, (struct sigaction *)sv);
+#if 0
+/* XXX -- SOUSIG no longer exists, do something here */
+ if (sv->sv_flags & HPUXSV_RESET)
+ p->p_flag |= SOUSIG; /* XXX */
+#endif
+ }
+ return (0);
+}
+
+int
+hpux_sys_sigblock(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_sigblock_args *uap = v;
+
+ (void) splhigh();
+ *retval = bsdtohpuxmask(p->p_sigmask);
+ p->p_sigmask |= hpuxtobsdmask(SCARG(uap, mask)) &~ sigcantmask;
+ (void) spl0();
+ return (0);
+}
+
+int
+hpux_sys_sigsetmask(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_sigsetmask_args *uap = v;
+
+ (void) splhigh();
+ *retval = bsdtohpuxmask(p->p_sigmask);
+ p->p_sigmask = hpuxtobsdmask(SCARG(uap, mask)) &~ sigcantmask;
+ (void) spl0();
+ return (0);
+}
+
+int
+hpux_sys_sigpause(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_sigpause_args *uap = v;
+
+ SCARG(uap, mask) = hpuxtobsdmask(SCARG(uap, mask));
+ return (sys_sigsuspend(p, uap, retval));
+}
+
+/* not totally correct, but close enuf' */
+int
+hpux_sys_kill(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_kill_args *uap = v;
+
+ if (SCARG(uap, signo)) {
+ SCARG(uap, signo) = hpuxtobsdsig(SCARG(uap, signo));
+ if (SCARG(uap, signo) == 0)
+ SCARG(uap, signo) = NSIG;
+ }
+ return (sys_kill(p, uap, retval));
+}
+
+/*
+ * The following (sigprocmask, sigpending, sigsuspend, sigaction are
+ * POSIX calls. Under BSD, the library routine dereferences the sigset_t
+ * pointers before traping. Not so under HP-UX.
+ */
+
+/*
+ * Manipulate signal mask.
+ * Note that we receive new mask, not pointer,
+ * and return old mask as return value;
+ * the library stub does the rest.
+ */
+int
+hpux_sys_sigprocmask(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_sigprocmask_args *uap = v;
+ int mask, error = 0;
+ hpux_sigset_t sigset;
+
+ /*
+ * Copy out old mask first to ensure no errors.
+ * (proc sigmask should not be changed if call fails for any reason)
+ */
+ if (SCARG(uap, oset)) {
+ bzero((caddr_t)&sigset, sizeof(sigset));
+ sigset.sigset[0] = bsdtohpuxmask(p->p_sigmask);
+ if (copyout((caddr_t)&sigset, (caddr_t)SCARG(uap, oset),
+ sizeof(sigset)))
+ return (EFAULT);
+ }
+ if (SCARG(uap, set)) {
+ if (copyin((caddr_t)SCARG(uap, set), (caddr_t)&sigset,
+ sizeof(sigset)))
+ return (EFAULT);
+ mask = hpuxtobsdmask(sigset.sigset[0]);
+ (void) splhigh();
+ switch (SCARG(uap, how)) {
+ case HPUXSIG_BLOCK:
+ p->p_sigmask |= mask &~ sigcantmask;
+ break;
+ case HPUXSIG_UNBLOCK:
+ p->p_sigmask &= ~mask;
+ break;
+ case HPUXSIG_SETMASK:
+ p->p_sigmask = mask &~ sigcantmask;
+ break;
+ default:
+ error = EINVAL;
+ break;
+ }
+ (void) spl0();
+ }
+ return (error);
+}
+
+int
+hpux_sys_sigpending(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_sigpending_args *uap = v;
+ hpux_sigset_t sigset;
+
+ sigset.sigset[0] = bsdtohpuxmask(p->p_siglist);
+ return (copyout((caddr_t)&sigset, (caddr_t)SCARG(uap, set),
+ sizeof(sigset)));
+}
+
+int
+hpux_sys_sigsuspend(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct hpux_sys_sigsuspend_args *uap = v;
+ register struct sigacts *ps = p->p_sigacts;
+ hpux_sigset_t sigset;
+ int mask;
+
+ if (copyin((caddr_t)SCARG(uap, set), (caddr_t)&sigset, sizeof(sigset)))
+ return (EFAULT);
+ mask = hpuxtobsdmask(sigset.sigset[0]);
+ ps->ps_oldmask = p->p_sigmask;
+ ps->ps_flags |= SAS_OLDMASK;
+ p->p_sigmask = mask &~ sigcantmask;
+ (void) tsleep((caddr_t)ps, PPAUSE | PCATCH, "pause", 0);
+ /* always return EINTR rather than ERESTART... */
+ return (EINTR);
+}
+
+int
+hpux_sys_sigaction(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct hpux_sys_sigaction_args *uap = v;
+ struct hpux_sigaction action;
+ register struct sigacts *ps = p->p_sigacts;
+ register struct hpux_sigaction *sa;
+ register int sig;
+ int bit;
+
+ sig = hpuxtobsdsig(SCARG(uap, signo));
+ if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
+ return (EINVAL);
+
+ sa = &action;
+ if (SCARG(uap, osa)) {
+ sa->sa_handler = ps->ps_sigact[sig];
+ bzero((caddr_t)&sa->sa_mask, sizeof(sa->sa_mask));
+ sa->sa_mask.sigset[0] = bsdtohpuxmask(ps->ps_catchmask[sig]);
+ bit = sigmask(sig);
+ sa->sa_flags = 0;
+ if ((ps->ps_sigonstack & bit) != 0)
+ sa->sa_flags |= HPUXSA_ONSTACK;
+ if ((ps->ps_sigreset & bit) != 0)
+ sa->sa_flags |= HPUXSA_RESETHAND;
+ if (p->p_flag & P_NOCLDSTOP)
+ sa->sa_flags |= HPUXSA_NOCLDSTOP;
+ if (copyout((caddr_t)sa, (caddr_t)SCARG(uap, osa),
+ sizeof (action)))
+ return (EFAULT);
+ }
+ if (SCARG(uap, nsa)) {
+ struct sigaction act;
+
+ if (copyin((caddr_t)SCARG(uap, nsa), (caddr_t)sa,
+ sizeof (action)))
+ return (EFAULT);
+ if (sig == SIGCONT && sa->sa_handler == SIG_IGN)
+ return (EINVAL);
+ /*
+ * Create a sigaction struct for setsigvec
+ */
+ act.sa_handler = sa->sa_handler;
+ act.sa_mask = hpuxtobsdmask(sa->sa_mask.sigset[0]);
+ act.sa_flags == SA_RESTART;
+ if (sa->sa_flags & HPUXSA_ONSTACK)
+ act.sa_flags |= SA_ONSTACK;
+ if (sa->sa_flags & HPUXSA_NOCLDSTOP)
+ act.sa_flags |= SA_NOCLDSTOP;
+ setsigvec(p, sig, &act);
+#if 0
+/* XXX -- SOUSIG no longer exists, do something here */
+ if (sa->sa_flags & HPUXSA_RESETHAND)
+ p->p_flag |= SOUSIG; /* XXX */
+#endif
+ }
+ return (0);
+}
+
+#ifdef COMPAT_HPUX_6X
+int
+compat_hpux_6x_sys_ssig(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_hpux_6x_sys_ssig_args *uap = v;
+ register int a;
+ struct sigaction vec;
+ register struct sigaction *sa = &vec;
+
+ a = hpuxtobsdsig(SCARG(uap, signo));
+ sa->sa_handler = SCARG(uap, fun);
+ /*
+ * Kill processes trying to use job control facilities
+ * (this'll help us find any vestiges of the old stuff).
+ */
+ if ((a &~ 0377) ||
+ (sa->sa_handler != SIG_DFL && sa->sa_handler != SIG_IGN &&
+ ((int)sa->sa_handler) & 1)) {
+ psignal(p, SIGSYS);
+ return (0);
+ }
+ if (a <= 0 || a >= NSIG || a == SIGKILL || a == SIGSTOP ||
+ a == SIGCONT && sa->sa_handler == SIG_IGN)
+ return (EINVAL);
+ sa->sa_mask = 0;
+ sa->sa_flags = 0;
+ *retval = (int)p->p_sigacts->ps_sigact[a];
+ setsigvec(p, a, sa);
+#if 0
+ p->p_flag |= SOUSIG; /* mark as simulating old stuff */
+#endif
+ return (0);
+}
+#endif
+
+/* signal numbers: convert from HPUX to BSD */
+int
+hpuxtobsdsig(sig)
+ register int sig;
+{
+ if (--sig < 0 || sig >= NSIG)
+ return(0);
+ return((int)hpuxtobsdsigmap[sig]);
+}
+
+/* signal numbers: convert from BSD to HPUX */
+int
+bsdtohpuxsig(sig)
+ register int sig;
+{
+ if (--sig < 0 || sig >= NSIG)
+ return(0);
+ return((int)bsdtohpuxsigmap[sig]);
+}
+
+/* signal masks: convert from HPUX to BSD (not pretty or fast) */
+int
+hpuxtobsdmask(mask)
+ register int mask;
+{
+ register int nmask, sig, nsig;
+
+ if (mask == 0 || mask == -1)
+ return(mask);
+ nmask = 0;
+ for (sig = 1; sig < NSIG; sig++)
+ if ((mask & sigmask(sig)) && (nsig = hpuxtobsdsig(sig)))
+ nmask |= sigmask(nsig);
+ return(nmask);
+}
+
+int
+bsdtohpuxmask(mask)
+ register int mask;
+{
+ register int nmask, sig, nsig;
+
+ if (mask == 0 || mask == -1)
+ return(mask);
+ nmask = 0;
+ for (sig = 1; sig < NSIG; sig++)
+ if ((mask & sigmask(sig)) && (nsig = bsdtohpuxsig(sig)))
+ nmask |= sigmask(nsig);
+ return(nmask);
+}
diff --git a/sys/compat/hpux/hpux_syscall.h b/sys/compat/hpux/hpux_syscall.h
new file mode 100644
index 00000000000..9d1924965e4
--- /dev/null
+++ b/sys/compat/hpux/hpux_syscall.h
@@ -0,0 +1,151 @@
+/*
+ * System call numbers.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.8 1995/10/07 06:26:42 mycroft Exp
+ */
+
+#define HPUX_SYS_syscall 0
+#define HPUX_SYS_exit 1
+#define HPUX_SYS_fork 2
+#define HPUX_SYS_read 3
+#define HPUX_SYS_write 4
+#define HPUX_SYS_open 5
+#define HPUX_SYS_close 6
+#define HPUX_SYS_wait 7
+#define HPUX_SYS_creat 8
+#define HPUX_SYS_link 9
+#define HPUX_SYS_unlink 10
+#define HPUX_SYS_execv 11
+#define HPUX_SYS_chdir 12
+ /* 13 is compat_hpux_6x time */
+#define HPUX_SYS_mknod 14
+#define HPUX_SYS_chmod 15
+#define HPUX_SYS_chown 16
+#define HPUX_SYS_obreak 17
+ /* 18 is compat_hpux_6x stat */
+#define HPUX_SYS_lseek 19
+#define HPUX_SYS_getpid 20
+#define HPUX_SYS_setuid 23
+#define HPUX_SYS_getuid 24
+ /* 25 is compat_hpux_6x stime */
+#define HPUX_SYS_ptrace 26
+ /* 27 is compat_hpux_6x alarm */
+ /* 28 is compat_hpux_6x fstat */
+ /* 29 is compat_hpux_6x pause */
+ /* 30 is compat_hpux_6x utime */
+ /* 31 is compat_hpux_6x stty */
+ /* 32 is compat_hpux_6x gtty */
+#define HPUX_SYS_access 33
+ /* 34 is compat_hpux_6x nice */
+ /* 35 is compat_hpux_6x ftime */
+#define HPUX_SYS_sync 36
+#define HPUX_SYS_kill 37
+#define HPUX_SYS_stat 38
+ /* 39 is compat_hpux_6x setpgrp */
+#define HPUX_SYS_lstat 40
+#define HPUX_SYS_dup 41
+#define HPUX_SYS_pipe 42
+ /* 43 is compat_hpux_6x times */
+#define HPUX_SYS_profil 44
+#define HPUX_SYS_setgid 46
+#define HPUX_SYS_getgid 47
+ /* 48 is compat_hpux_6x ssig */
+#define HPUX_SYS_ioctl 54
+#define HPUX_SYS_symlink 56
+#define HPUX_SYS_utssys 57
+#define HPUX_SYS_readlink 58
+#define HPUX_SYS_execve 59
+#define HPUX_SYS_umask 60
+#define HPUX_SYS_chroot 61
+#define HPUX_SYS_fcntl 62
+#define HPUX_SYS_ulimit 63
+#define HPUX_SYS_vfork 66
+#define HPUX_SYS_vread 67
+#define HPUX_SYS_vwrite 68
+#define HPUX_SYS_mmap 71
+#define HPUX_SYS_munmap 73
+#define HPUX_SYS_mprotect 74
+#define HPUX_SYS_getgroups 79
+#define HPUX_SYS_setgroups 80
+#define HPUX_SYS_getpgrp2 81
+#define HPUX_SYS_setpgrp2 82
+#define HPUX_SYS_setitimer 83
+#define HPUX_SYS_wait3 84
+#define HPUX_SYS_getitimer 86
+#define HPUX_SYS_dup2 90
+#define HPUX_SYS_fstat 92
+#define HPUX_SYS_select 93
+#define HPUX_SYS_fsync 95
+#define HPUX_SYS_sigreturn 103
+#define HPUX_SYS_sigvec 108
+#define HPUX_SYS_sigblock 109
+#define HPUX_SYS_sigsetmask 110
+#define HPUX_SYS_sigpause 111
+#define HPUX_SYS_sigstack 112
+#define HPUX_SYS_gettimeofday 116
+#define HPUX_SYS_readv 120
+#define HPUX_SYS_writev 121
+#define HPUX_SYS_settimeofday 122
+#define HPUX_SYS_fchown 123
+#define HPUX_SYS_fchmod 124
+#define HPUX_SYS_setresuid 126
+#define HPUX_SYS_setresgid 127
+#define HPUX_SYS_rename 128
+#define HPUX_SYS_truncate 129
+#define HPUX_SYS_ftruncate 130
+#define HPUX_SYS_sysconf 132
+#define HPUX_SYS_mkdir 136
+#define HPUX_SYS_rmdir 137
+#define HPUX_SYS_getrlimit 144
+#define HPUX_SYS_setrlimit 145
+#define HPUX_SYS_rtprio 152
+#define HPUX_SYS_netioctl 154
+#define HPUX_SYS_lockf 155
+#define HPUX_SYS_semget 156
+#define HPUX_SYS___semctl 157
+#define HPUX_SYS_semop 158
+#define HPUX_SYS_msgget 159
+#define HPUX_SYS_msgctl 160
+#define HPUX_SYS_msgsnd 161
+#define HPUX_SYS_msgrcv 162
+#define HPUX_SYS_shmget 163
+#define HPUX_SYS_shmctl 164
+#define HPUX_SYS_shmat 165
+#define HPUX_SYS_shmdt 166
+#define HPUX_SYS_advise 167
+#define HPUX_SYS_getcontext 174
+#define HPUX_SYS_getaccess 190
+#define HPUX_SYS_waitpid 200
+#define HPUX_SYS_pathconf 225
+#define HPUX_SYS_fpathconf 226
+#define HPUX_SYS_getdirentries 231
+#define HPUX_SYS_getdomainname 232
+#define HPUX_SYS_setdomainname 236
+#define HPUX_SYS_sigaction 239
+#define HPUX_SYS_sigprocmask 240
+#define HPUX_SYS_sigpending 241
+#define HPUX_SYS_sigsuspend 242
+#define HPUX_SYS_getdtablesize 268
+#define HPUX_SYS_fchdir 272
+#define HPUX_SYS_accept 275
+#define HPUX_SYS_bind 276
+#define HPUX_SYS_connect 277
+#define HPUX_SYS_getpeername 278
+#define HPUX_SYS_getsockname 279
+#define HPUX_SYS_getsockopt 280
+#define HPUX_SYS_listen 281
+#define HPUX_SYS_recv 282
+#define HPUX_SYS_recvfrom 283
+#define HPUX_SYS_recvmsg 284
+#define HPUX_SYS_send 285
+#define HPUX_SYS_sendmsg 286
+#define HPUX_SYS_sendto 287
+#define HPUX_SYS_setsockopt2 288
+#define HPUX_SYS_shutdown 289
+#define HPUX_SYS_socket 290
+#define HPUX_SYS_socketpair 291
+#define HPUX_SYS_nsemctl 312
+#define HPUX_SYS_nmsgctl 313
+#define HPUX_SYS_nshmctl 314
+#define HPUX_SYS_MAXSYSCALL 315
diff --git a/sys/compat/hpux/hpux_syscallargs.h b/sys/compat/hpux/hpux_syscallargs.h
new file mode 100644
index 00000000000..63af42f3115
--- /dev/null
+++ b/sys/compat/hpux/hpux_syscallargs.h
@@ -0,0 +1,475 @@
+/*
+ * System call argument lists.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.8 1995/10/07 06:26:42 mycroft Exp
+ */
+
+#define syscallarg(x) union { x datum; register_t pad; }
+
+struct hpux_sys_read_args {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(u_int) nbyte;
+};
+
+struct hpux_sys_write_args {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(u_int) nbyte;
+};
+
+struct hpux_sys_open_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+};
+
+struct hpux_sys_wait_args {
+ syscallarg(int *) status;
+};
+
+struct hpux_sys_creat_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct hpux_sys_execv_args {
+ syscallarg(char *) path;
+ syscallarg(char **) argp;
+};
+
+struct compat_hpux_6x_sys_time_args {
+ syscallarg(time_t *) t;
+};
+
+struct compat_hpux_6x_sys_stat_args {
+ syscallarg(char *) path;
+ syscallarg(struct hpux_ostat *) sb;
+};
+
+struct compat_hpux_6x_sys_stime_args {
+ syscallarg(int) time;
+};
+
+struct hpux_sys_ptrace_args {
+ syscallarg(int) req;
+ syscallarg(int) pid;
+ syscallarg(int *) addr;
+ syscallarg(int) data;
+};
+
+struct compat_hpux_6x_sys_alarm_args {
+ syscallarg(int) deltat;
+};
+
+struct compat_hpux_6x_sys_fstat_args {
+ syscallarg(int) fd;
+ syscallarg(struct hpux_ostat *) sb;
+};
+
+struct compat_hpux_6x_sys_utime_args {
+ syscallarg(char *) fname;
+ syscallarg(time_t *) tptr;
+};
+
+struct compat_hpux_6x_sys_stty_args {
+ syscallarg(int) fd;
+ syscallarg(caddr_t) arg;
+};
+
+struct compat_hpux_6x_sys_gtty_args {
+ syscallarg(int) fd;
+ syscallarg(caddr_t) arg;
+};
+
+struct compat_hpux_6x_sys_nice_args {
+ syscallarg(int) nval;
+};
+
+struct compat_hpux_6x_sys_ftime_args {
+ syscallarg(struct hpux_timeb *) tp;
+};
+
+struct hpux_sys_kill_args {
+ syscallarg(pid_t) pid;
+ syscallarg(int) signo;
+};
+
+struct hpux_sys_stat_args {
+ syscallarg(char *) path;
+ syscallarg(struct hpux_stat *) sb;
+};
+
+struct hpux_sys_lstat_args {
+ syscallarg(char *) path;
+ syscallarg(struct hpux_stat *) sb;
+};
+
+struct hpux_sys_dup_args {
+ syscallarg(int) fd;
+};
+
+struct compat_hpux_6x_sys_times_args {
+ syscallarg(struct tms *) tms;
+};
+
+struct compat_hpux_6x_sys_ssig_args {
+ syscallarg(int) signo;
+ syscallarg(sig_t) fun;
+};
+
+struct hpux_sys_ioctl_args {
+ syscallarg(int) fd;
+ syscallarg(int) com;
+ syscallarg(caddr_t) data;
+};
+
+struct hpux_sys_utssys_args {
+ syscallarg(struct hpux_utsname *) uts;
+ syscallarg(int) dev;
+ syscallarg(int) request;
+};
+
+struct hpux_sys_fcntl_args {
+ syscallarg(int) fd;
+ syscallarg(int) cmd;
+ syscallarg(int) arg;
+};
+
+struct hpux_sys_ulimit_args {
+ syscallarg(int) cmd;
+ syscallarg(int) newlimit;
+};
+
+struct hpux_sys_mmap_args {
+ syscallarg(caddr_t) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) prot;
+ syscallarg(int) flags;
+ syscallarg(int) fd;
+ syscallarg(long) pos;
+};
+
+struct hpux_sys_getpgrp2_args {
+ syscallarg(pid_t) pid;
+};
+
+struct hpux_sys_setpgrp2_args {
+ syscallarg(pid_t) pid;
+ syscallarg(pid_t) pgid;
+};
+
+struct hpux_sys_wait3_args {
+ syscallarg(int *) status;
+ syscallarg(int) options;
+ syscallarg(int) rusage;
+};
+
+struct hpux_sys_fstat_args {
+ syscallarg(int) fd;
+ syscallarg(struct hpux_stat *) sb;
+};
+
+struct hpux_sys_sigvec_args {
+ syscallarg(int) signo;
+ syscallarg(struct sigvec *) nsv;
+ syscallarg(struct sigvec *) osv;
+};
+
+struct hpux_sys_sigblock_args {
+ syscallarg(int) mask;
+};
+
+struct hpux_sys_sigsetmask_args {
+ syscallarg(int) mask;
+};
+
+struct hpux_sys_sigpause_args {
+ syscallarg(int) mask;
+};
+
+struct hpux_sys_readv_args {
+ syscallarg(int) fd;
+ syscallarg(struct iovec *) iovp;
+ syscallarg(u_int) iovcnt;
+};
+
+struct hpux_sys_writev_args {
+ syscallarg(int) fd;
+ syscallarg(struct iovec *) iovp;
+ syscallarg(u_int) iovcnt;
+};
+
+struct hpux_sys_setresuid_args {
+ syscallarg(uid_t) r;
+ syscallarg(uid_t) e;
+ syscallarg(uid_t) s;
+};
+
+struct hpux_sys_setresgid_args {
+ syscallarg(gid_t) r;
+ syscallarg(gid_t) e;
+ syscallarg(gid_t) s;
+};
+
+struct hpux_sys_sysconf_args {
+ syscallarg(int) name;
+};
+
+struct hpux_sys_getrlimit_args {
+ syscallarg(u_int) which;
+ syscallarg(struct ogetrlimit *) rlp;
+};
+
+struct hpux_sys_setrlimit_args {
+ syscallarg(u_int) which;
+ syscallarg(struct ogetrlimit *) rlp;
+};
+
+struct hpux_sys_rtprio_args {
+ syscallarg(pid_t) pid;
+ syscallarg(int) prio;
+};
+
+struct hpux_sys_netioctl_args {
+ syscallarg(int) call;
+ syscallarg(int *) args;
+};
+
+struct hpux_sys_lockf_args {
+ syscallarg(int) fd;
+ syscallarg(int) func;
+ syscallarg(long) size;
+};
+
+struct hpux_sys_shmctl_args {
+ syscallarg(int) shmid;
+ syscallarg(int) cmd;
+ syscallarg(caddr_t) buf;
+};
+
+struct hpux_sys_advise_args {
+ syscallarg(int) arg;
+};
+
+struct hpux_sys_getcontext_args {
+ syscallarg(char *) buf;
+ syscallarg(int) len;
+};
+
+struct hpux_sys_getaccess_args {
+ syscallarg(char *) path;
+ syscallarg(uid_t) uid;
+ syscallarg(int) ngroups;
+ syscallarg(gid_t *) gidset;
+ syscallarg(void *) label;
+ syscallarg(void *) privs;
+};
+
+struct hpux_sys_waitpid_args {
+ syscallarg(pid_t) pid;
+ syscallarg(int *) status;
+ syscallarg(int) options;
+ syscallarg(struct rusage *) rusage;
+};
+
+struct hpux_sys_sigaction_args {
+ syscallarg(int) signo;
+ syscallarg(struct hpux_sigaction *) nsa;
+ syscallarg(struct hpux_sigaction *) osa;
+};
+
+struct hpux_sys_sigprocmask_args {
+ syscallarg(int) how;
+ syscallarg(hpux_sigset_t *) set;
+ syscallarg(hpux_sigset_t *) oset;
+};
+
+struct hpux_sys_sigpending_args {
+ syscallarg(hpux_sigset_t *) set;
+};
+
+struct hpux_sys_sigsuspend_args {
+ syscallarg(hpux_sigset_t *) set;
+};
+
+struct hpux_sys_setsockopt2_args {
+ syscallarg(int) s;
+ syscallarg(int) level;
+ syscallarg(int) name;
+ syscallarg(caddr_t) val;
+ syscallarg(int) valsize;
+};
+
+struct hpux_sys_nshmctl_args {
+ syscallarg(int) shmid;
+ syscallarg(int) cmd;
+ syscallarg(caddr_t) buf;
+};
+
+/*
+ * System call prototypes.
+ */
+
+int sys_nosys __P((struct proc *, void *, register_t *));
+int sys_exit __P((struct proc *, void *, register_t *));
+int hpux_sys_fork __P((struct proc *, void *, register_t *));
+int hpux_sys_read __P((struct proc *, void *, register_t *));
+int hpux_sys_write __P((struct proc *, void *, register_t *));
+int hpux_sys_open __P((struct proc *, void *, register_t *));
+int sys_close __P((struct proc *, void *, register_t *));
+int hpux_sys_wait __P((struct proc *, void *, register_t *));
+int hpux_sys_creat __P((struct proc *, void *, register_t *));
+int sys_link __P((struct proc *, void *, register_t *));
+int sys_unlink __P((struct proc *, void *, register_t *));
+int hpux_sys_execv __P((struct proc *, void *, register_t *));
+int sys_chdir __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_time __P((struct proc *, void *, register_t *));
+int sys_mknod __P((struct proc *, void *, register_t *));
+int sys_chmod __P((struct proc *, void *, register_t *));
+int sys_chown __P((struct proc *, void *, register_t *));
+int sys_obreak __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_stat __P((struct proc *, void *, register_t *));
+int compat_43_sys_lseek __P((struct proc *, void *, register_t *));
+int sys_getpid __P((struct proc *, void *, register_t *));
+int sys_setuid __P((struct proc *, void *, register_t *));
+int sys_getuid __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_stime __P((struct proc *, void *, register_t *));
+int hpux_sys_ptrace __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_alarm __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_fstat __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_pause __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_utime __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_stty __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_gtty __P((struct proc *, void *, register_t *));
+int sys_access __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_nice __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_ftime __P((struct proc *, void *, register_t *));
+int sys_sync __P((struct proc *, void *, register_t *));
+int hpux_sys_kill __P((struct proc *, void *, register_t *));
+int hpux_sys_stat __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_setpgrp __P((struct proc *, void *, register_t *));
+int hpux_sys_lstat __P((struct proc *, void *, register_t *));
+int hpux_sys_dup __P((struct proc *, void *, register_t *));
+int sys_pipe __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_times __P((struct proc *, void *, register_t *));
+int sys_profil __P((struct proc *, void *, register_t *));
+int sys_setgid __P((struct proc *, void *, register_t *));
+int sys_getgid __P((struct proc *, void *, register_t *));
+int compat_hpux_6x_sys_ssig __P((struct proc *, void *, register_t *));
+int hpux_sys_ioctl __P((struct proc *, void *, register_t *));
+int sys_symlink __P((struct proc *, void *, register_t *));
+int hpux_sys_utssys __P((struct proc *, void *, register_t *));
+int sys_readlink __P((struct proc *, void *, register_t *));
+int sys_execve __P((struct proc *, void *, register_t *));
+int sys_umask __P((struct proc *, void *, register_t *));
+int sys_chroot __P((struct proc *, void *, register_t *));
+int hpux_sys_fcntl __P((struct proc *, void *, register_t *));
+int hpux_sys_ulimit __P((struct proc *, void *, register_t *));
+int hpux_sys_vfork __P((struct proc *, void *, register_t *));
+int hpux_sys_read __P((struct proc *, void *, register_t *));
+int hpux_sys_write __P((struct proc *, void *, register_t *));
+int hpux_sys_mmap __P((struct proc *, void *, register_t *));
+int sys_munmap __P((struct proc *, void *, register_t *));
+int sys_mprotect __P((struct proc *, void *, register_t *));
+int sys_getgroups __P((struct proc *, void *, register_t *));
+int sys_setgroups __P((struct proc *, void *, register_t *));
+int hpux_sys_getpgrp2 __P((struct proc *, void *, register_t *));
+int hpux_sys_setpgrp2 __P((struct proc *, void *, register_t *));
+int sys_setitimer __P((struct proc *, void *, register_t *));
+int hpux_sys_wait3 __P((struct proc *, void *, register_t *));
+int sys_getitimer __P((struct proc *, void *, register_t *));
+int sys_dup2 __P((struct proc *, void *, register_t *));
+int hpux_sys_fstat __P((struct proc *, void *, register_t *));
+int sys_select __P((struct proc *, void *, register_t *));
+int sys_fsync __P((struct proc *, void *, register_t *));
+int sys_sigreturn __P((struct proc *, void *, register_t *));
+int hpux_sys_sigvec __P((struct proc *, void *, register_t *));
+int hpux_sys_sigblock __P((struct proc *, void *, register_t *));
+int hpux_sys_sigsetmask __P((struct proc *, void *, register_t *));
+int hpux_sys_sigpause __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigstack __P((struct proc *, void *, register_t *));
+int sys_gettimeofday __P((struct proc *, void *, register_t *));
+int hpux_sys_readv __P((struct proc *, void *, register_t *));
+int hpux_sys_writev __P((struct proc *, void *, register_t *));
+int sys_settimeofday __P((struct proc *, void *, register_t *));
+int sys_fchown __P((struct proc *, void *, register_t *));
+int sys_fchmod __P((struct proc *, void *, register_t *));
+int hpux_sys_setresuid __P((struct proc *, void *, register_t *));
+int hpux_sys_setresgid __P((struct proc *, void *, register_t *));
+int sys_rename __P((struct proc *, void *, register_t *));
+int compat_43_sys_truncate __P((struct proc *, void *, register_t *));
+int compat_43_sys_ftruncate __P((struct proc *, void *, register_t *));
+int hpux_sys_sysconf __P((struct proc *, void *, register_t *));
+int sys_mkdir __P((struct proc *, void *, register_t *));
+int sys_rmdir __P((struct proc *, void *, register_t *));
+int hpux_sys_getrlimit __P((struct proc *, void *, register_t *));
+int hpux_sys_setrlimit __P((struct proc *, void *, register_t *));
+int hpux_sys_rtprio __P((struct proc *, void *, register_t *));
+int hpux_sys_netioctl __P((struct proc *, void *, register_t *));
+int hpux_sys_lockf __P((struct proc *, void *, register_t *));
+#ifdef SYSVSEM
+int sys_semget __P((struct proc *, void *, register_t *));
+int sys___semctl __P((struct proc *, void *, register_t *));
+int sys_semop __P((struct proc *, void *, register_t *));
+#else
+#endif
+#ifdef SYSVMSG
+int sys_msgget __P((struct proc *, void *, register_t *));
+int sys_msgctl __P((struct proc *, void *, register_t *));
+int sys_msgsnd __P((struct proc *, void *, register_t *));
+int sys_msgrcv __P((struct proc *, void *, register_t *));
+#else
+#endif
+#ifdef SYSVSHM
+int sys_shmget __P((struct proc *, void *, register_t *));
+int hpux_sys_shmctl __P((struct proc *, void *, register_t *));
+int sys_shmat __P((struct proc *, void *, register_t *));
+int sys_shmdt __P((struct proc *, void *, register_t *));
+#else
+#endif
+int hpux_sys_advise __P((struct proc *, void *, register_t *));
+int hpux_sys_getcontext __P((struct proc *, void *, register_t *));
+int hpux_sys_getaccess __P((struct proc *, void *, register_t *));
+int hpux_sys_waitpid __P((struct proc *, void *, register_t *));
+int sys_pathconf __P((struct proc *, void *, register_t *));
+int sys_fpathconf __P((struct proc *, void *, register_t *));
+int compat_43_sys_getdirentries __P((struct proc *, void *, register_t *));
+int compat_09_sys_getdomainname __P((struct proc *, void *, register_t *));
+int compat_09_sys_setdomainname __P((struct proc *, void *, register_t *));
+int hpux_sys_sigaction __P((struct proc *, void *, register_t *));
+int hpux_sys_sigprocmask __P((struct proc *, void *, register_t *));
+int hpux_sys_sigpending __P((struct proc *, void *, register_t *));
+int hpux_sys_sigsuspend __P((struct proc *, void *, register_t *));
+int compat_43_sys_getdtablesize __P((struct proc *, void *, register_t *));
+int sys_fchdir __P((struct proc *, void *, register_t *));
+int compat_43_sys_accept __P((struct proc *, void *, register_t *));
+int sys_bind __P((struct proc *, void *, register_t *));
+int sys_connect __P((struct proc *, void *, register_t *));
+int compat_43_sys_getpeername __P((struct proc *, void *, register_t *));
+int compat_43_sys_getsockname __P((struct proc *, void *, register_t *));
+int sys_getsockopt __P((struct proc *, void *, register_t *));
+int sys_listen __P((struct proc *, void *, register_t *));
+int compat_43_sys_recv __P((struct proc *, void *, register_t *));
+int compat_43_sys_recvfrom __P((struct proc *, void *, register_t *));
+int compat_43_sys_recvmsg __P((struct proc *, void *, register_t *));
+int compat_43_sys_send __P((struct proc *, void *, register_t *));
+int compat_43_sys_sendmsg __P((struct proc *, void *, register_t *));
+int sys_sendto __P((struct proc *, void *, register_t *));
+int hpux_sys_setsockopt2 __P((struct proc *, void *, register_t *));
+int sys_shutdown __P((struct proc *, void *, register_t *));
+int sys_socket __P((struct proc *, void *, register_t *));
+int sys_socketpair __P((struct proc *, void *, register_t *));
+#ifdef SYSVSEM
+int sys___semctl __P((struct proc *, void *, register_t *));
+#else
+#endif
+#ifdef SYSVMSG
+int sys_msgctl __P((struct proc *, void *, register_t *));
+#else
+#endif
+#ifdef SYSVSHM
+int hpux_sys_nshmctl __P((struct proc *, void *, register_t *));
+#else
+#endif
diff --git a/sys/compat/hpux/hpux_syscalls.c b/sys/compat/hpux/hpux_syscalls.c
new file mode 100644
index 00000000000..58930283148
--- /dev/null
+++ b/sys/compat/hpux/hpux_syscalls.c
@@ -0,0 +1,356 @@
+/*
+ * System call names.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.8 1995/10/07 06:26:42 mycroft Exp
+ */
+
+char *hpux_syscallnames[] = {
+ "syscall", /* 0 = syscall */
+ "exit", /* 1 = exit */
+ "fork", /* 2 = fork */
+ "read", /* 3 = read */
+ "write", /* 4 = write */
+ "open", /* 5 = open */
+ "close", /* 6 = close */
+ "wait", /* 7 = wait */
+ "creat", /* 8 = creat */
+ "link", /* 9 = link */
+ "unlink", /* 10 = unlink */
+ "execv", /* 11 = execv */
+ "chdir", /* 12 = chdir */
+ "compat_hpux_6x_time", /* 13 = compat_hpux_6x time */
+ "mknod", /* 14 = mknod */
+ "chmod", /* 15 = chmod */
+ "chown", /* 16 = chown */
+ "obreak", /* 17 = obreak */
+ "compat_hpux_6x_stat", /* 18 = compat_hpux_6x stat */
+ "lseek", /* 19 = lseek */
+ "getpid", /* 20 = getpid */
+ "#21 (unimplemented mount)", /* 21 = unimplemented mount */
+ "#22 (unimplemented umount)", /* 22 = unimplemented umount */
+ "setuid", /* 23 = setuid */
+ "getuid", /* 24 = getuid */
+ "compat_hpux_6x_stime", /* 25 = compat_hpux_6x stime */
+ "ptrace", /* 26 = ptrace */
+ "compat_hpux_6x_alarm", /* 27 = compat_hpux_6x alarm */
+ "compat_hpux_6x_fstat", /* 28 = compat_hpux_6x fstat */
+ "compat_hpux_6x_pause", /* 29 = compat_hpux_6x pause */
+ "compat_hpux_6x_utime", /* 30 = compat_hpux_6x utime */
+ "compat_hpux_6x_stty", /* 31 = compat_hpux_6x stty */
+ "compat_hpux_6x_gtty", /* 32 = compat_hpux_6x gtty */
+ "access", /* 33 = access */
+ "compat_hpux_6x_nice", /* 34 = compat_hpux_6x nice */
+ "compat_hpux_6x_ftime", /* 35 = compat_hpux_6x ftime */
+ "sync", /* 36 = sync */
+ "kill", /* 37 = kill */
+ "stat", /* 38 = stat */
+ "compat_hpux_6x_setpgrp", /* 39 = compat_hpux_6x setpgrp */
+ "lstat", /* 40 = lstat */
+ "dup", /* 41 = dup */
+ "pipe", /* 42 = pipe */
+ "compat_hpux_6x_times", /* 43 = compat_hpux_6x times */
+ "profil", /* 44 = profil */
+ "#45 (unimplemented ki_syscall)", /* 45 = unimplemented ki_syscall */
+ "setgid", /* 46 = setgid */
+ "getgid", /* 47 = getgid */
+ "compat_hpux_6x_ssig", /* 48 = compat_hpux_6x ssig */
+ "#49 (unimplemented reserved for USG)", /* 49 = unimplemented reserved for USG */
+ "#50 (unimplemented reserved for USG)", /* 50 = unimplemented reserved for USG */
+ "#51 (unimplemented acct)", /* 51 = unimplemented acct */
+ "#52 (unimplemented)", /* 52 = unimplemented */
+ "#53 (unimplemented)", /* 53 = unimplemented */
+ "ioctl", /* 54 = ioctl */
+ "#55 (unimplemented reboot)", /* 55 = unimplemented reboot */
+ "symlink", /* 56 = symlink */
+ "utssys", /* 57 = utssys */
+ "readlink", /* 58 = readlink */
+ "execve", /* 59 = execve */
+ "umask", /* 60 = umask */
+ "chroot", /* 61 = chroot */
+ "fcntl", /* 62 = fcntl */
+ "ulimit", /* 63 = ulimit */
+ "#64 (unimplemented)", /* 64 = unimplemented */
+ "#65 (unimplemented)", /* 65 = unimplemented */
+ "vfork", /* 66 = vfork */
+ "vread", /* 67 = vread */
+ "vwrite", /* 68 = vwrite */
+ "#69 (unimplemented)", /* 69 = unimplemented */
+ "#70 (unimplemented)", /* 70 = unimplemented */
+ "mmap", /* 71 = mmap */
+ "#72 (unimplemented)", /* 72 = unimplemented */
+ "munmap", /* 73 = munmap */
+ "mprotect", /* 74 = mprotect */
+ "#75 (unimplemented)", /* 75 = unimplemented */
+ "#76 (unimplemented)", /* 76 = unimplemented */
+ "#77 (unimplemented)", /* 77 = unimplemented */
+ "#78 (unimplemented)", /* 78 = unimplemented */
+ "getgroups", /* 79 = getgroups */
+ "setgroups", /* 80 = setgroups */
+ "getpgrp2", /* 81 = getpgrp2 */
+ "setpgrp2", /* 82 = setpgrp2 */
+ "setitimer", /* 83 = setitimer */
+ "wait3", /* 84 = wait3 */
+ "#85 (unimplemented swapon)", /* 85 = unimplemented swapon */
+ "getitimer", /* 86 = getitimer */
+ "#87 (unimplemented)", /* 87 = unimplemented */
+ "#88 (unimplemented)", /* 88 = unimplemented */
+ "#89 (unimplemented)", /* 89 = unimplemented */
+ "dup2", /* 90 = dup2 */
+ "#91 (unimplemented)", /* 91 = unimplemented */
+ "fstat", /* 92 = fstat */
+ "select", /* 93 = select */
+ "#94 (unimplemented)", /* 94 = unimplemented */
+ "fsync", /* 95 = fsync */
+ "#96 (unimplemented)", /* 96 = unimplemented */
+ "#97 (unimplemented)", /* 97 = unimplemented */
+ "#98 (unimplemented)", /* 98 = unimplemented */
+ "#99 (unimplemented)", /* 99 = unimplemented */
+ "#100 (unimplemented)", /* 100 = unimplemented */
+ "#101 (unimplemented)", /* 101 = unimplemented */
+ "#102 (unimplemented)", /* 102 = unimplemented */
+ "sigreturn", /* 103 = sigreturn */
+ "#104 (unimplemented)", /* 104 = unimplemented */
+ "#105 (unimplemented)", /* 105 = unimplemented */
+ "#106 (unimplemented)", /* 106 = unimplemented */
+ "#107 (unimplemented)", /* 107 = unimplemented */
+ "sigvec", /* 108 = sigvec */
+ "sigblock", /* 109 = sigblock */
+ "sigsetmask", /* 110 = sigsetmask */
+ "sigpause", /* 111 = sigpause */
+ "sigstack", /* 112 = sigstack */
+ "#113 (unimplemented)", /* 113 = unimplemented */
+ "#114 (unimplemented)", /* 114 = unimplemented */
+ "#115 (unimplemented)", /* 115 = unimplemented */
+ "gettimeofday", /* 116 = gettimeofday */
+ "#117 (unimplemented)", /* 117 = unimplemented */
+ "#118 (unimplemented)", /* 118 = unimplemented */
+ "#119 (unimplemented io_stub)", /* 119 = unimplemented io_stub */
+ "readv", /* 120 = readv */
+ "writev", /* 121 = writev */
+ "settimeofday", /* 122 = settimeofday */
+ "fchown", /* 123 = fchown */
+ "fchmod", /* 124 = fchmod */
+ "#125 (unimplemented)", /* 125 = unimplemented */
+ "setresuid", /* 126 = setresuid */
+ "setresgid", /* 127 = setresgid */
+ "rename", /* 128 = rename */
+ "truncate", /* 129 = truncate */
+ "ftruncate", /* 130 = ftruncate */
+ "#131 (unimplemented)", /* 131 = unimplemented */
+ "sysconf", /* 132 = sysconf */
+ "#133 (unimplemented)", /* 133 = unimplemented */
+ "#134 (unimplemented)", /* 134 = unimplemented */
+ "#135 (unimplemented)", /* 135 = unimplemented */
+ "mkdir", /* 136 = mkdir */
+ "rmdir", /* 137 = rmdir */
+ "#138 (unimplemented)", /* 138 = unimplemented */
+ "#139 (unimplemented)", /* 139 = unimplemented */
+ "#140 (unimplemented)", /* 140 = unimplemented */
+ "#141 (unimplemented)", /* 141 = unimplemented */
+ "#142 (unimplemented)", /* 142 = unimplemented */
+ "#143 (unimplemented)", /* 143 = unimplemented */
+ "getrlimit", /* 144 = getrlimit */
+ "setrlimit", /* 145 = setrlimit */
+ "#146 (unimplemented)", /* 146 = unimplemented */
+ "#147 (unimplemented)", /* 147 = unimplemented */
+ "#148 (unimplemented)", /* 148 = unimplemented */
+ "#149 (unimplemented)", /* 149 = unimplemented */
+ "#150 (unimplemented)", /* 150 = unimplemented */
+ "#151 (unimplemented privgrp)", /* 151 = unimplemented privgrp */
+ "rtprio", /* 152 = rtprio */
+ "#153 (unimplemented plock)", /* 153 = unimplemented plock */
+ "netioctl", /* 154 = netioctl */
+ "lockf", /* 155 = lockf */
+#ifdef SYSVSEM
+ "semget", /* 156 = semget */
+ "__semctl", /* 157 = __semctl */
+ "semop", /* 158 = semop */
+#else
+ "#156 (unimplemented semget)", /* 156 = unimplemented semget */
+ "#157 (unimplemented semctl)", /* 157 = unimplemented semctl */
+ "#158 (unimplemented semop)", /* 158 = unimplemented semop */
+#endif
+#ifdef SYSVMSG
+ "msgget", /* 159 = msgget */
+ "msgctl", /* 160 = msgctl */
+ "msgsnd", /* 161 = msgsnd */
+ "msgrcv", /* 162 = msgrcv */
+#else
+ "#159 (unimplemented msgget)", /* 159 = unimplemented msgget */
+ "#160 (unimplemented msgctl)", /* 160 = unimplemented msgctl */
+ "#161 (unimplemented msgsnd)", /* 161 = unimplemented msgsnd */
+ "#162 (unimplemented msgrcv)", /* 162 = unimplemented msgrcv */
+#endif
+#ifdef SYSVSHM
+ "shmget", /* 163 = shmget */
+ "shmctl", /* 164 = shmctl */
+ "shmat", /* 165 = shmat */
+ "shmdt", /* 166 = shmdt */
+#else
+ "#163 (unimplemented shmget)", /* 163 = unimplemented shmget */
+ "#164 (unimplemented shmctl)", /* 164 = unimplemented shmctl */
+ "#165 (unimplemented shmat)", /* 165 = unimplemented shmat */
+ "#166 (unimplemented shmdt)", /* 166 = unimplemented shmdt */
+#endif
+ "advise", /* 167 = advise */
+ "#168 (unimplemented nsp_init)", /* 168 = unimplemented nsp_init */
+ "#169 (unimplemented cluster)", /* 169 = unimplemented cluster */
+ "#170 (unimplemented mkrnod)", /* 170 = unimplemented mkrnod */
+ "#171 (unimplemented)", /* 171 = unimplemented */
+ "#172 (unimplemented unsp_open)", /* 172 = unimplemented unsp_open */
+ "#173 (unimplemented)", /* 173 = unimplemented */
+ "getcontext", /* 174 = getcontext */
+ "#175 (unimplemented)", /* 175 = unimplemented */
+ "#176 (unimplemented)", /* 176 = unimplemented */
+ "#177 (unimplemented)", /* 177 = unimplemented */
+ "#178 (unimplemented lsync)", /* 178 = unimplemented lsync */
+ "#179 (unimplemented)", /* 179 = unimplemented */
+ "#180 (unimplemented mysite)", /* 180 = unimplemented mysite */
+ "#181 (unimplemented sitels)", /* 181 = unimplemented sitels */
+ "#182 (unimplemented)", /* 182 = unimplemented */
+ "#183 (unimplemented)", /* 183 = unimplemented */
+ "#184 (unimplemented dskless_stats)", /* 184 = unimplemented dskless_stats */
+ "#185 (unimplemented)", /* 185 = unimplemented */
+ "#186 (unimplemented setacl)", /* 186 = unimplemented setacl */
+ "#187 (unimplemented fsetacl)", /* 187 = unimplemented fsetacl */
+ "#188 (unimplemented getacl)", /* 188 = unimplemented getacl */
+ "#189 (unimplemented fgetacl)", /* 189 = unimplemented fgetacl */
+ "getaccess", /* 190 = getaccess */
+ "#191 (unimplemented getaudid)", /* 191 = unimplemented getaudid */
+ "#192 (unimplemented setaudid)", /* 192 = unimplemented setaudid */
+ "#193 (unimplemented getaudproc)", /* 193 = unimplemented getaudproc */
+ "#194 (unimplemented setaudproc)", /* 194 = unimplemented setaudproc */
+ "#195 (unimplemented getevent)", /* 195 = unimplemented getevent */
+ "#196 (unimplemented setevent)", /* 196 = unimplemented setevent */
+ "#197 (unimplemented audwrite)", /* 197 = unimplemented audwrite */
+ "#198 (unimplemented audswitch)", /* 198 = unimplemented audswitch */
+ "#199 (unimplemented audctl)", /* 199 = unimplemented audctl */
+ "waitpid", /* 200 = waitpid */
+ "#201 (unimplemented)", /* 201 = unimplemented */
+ "#202 (unimplemented)", /* 202 = unimplemented */
+ "#203 (unimplemented)", /* 203 = unimplemented */
+ "#204 (unimplemented)", /* 204 = unimplemented */
+ "#205 (unimplemented)", /* 205 = unimplemented */
+ "#206 (unimplemented)", /* 206 = unimplemented */
+ "#207 (unimplemented)", /* 207 = unimplemented */
+ "#208 (unimplemented)", /* 208 = unimplemented */
+ "#209 (unimplemented)", /* 209 = unimplemented */
+ "#210 (unimplemented)", /* 210 = unimplemented */
+ "#211 (unimplemented)", /* 211 = unimplemented */
+ "#212 (unimplemented)", /* 212 = unimplemented */
+ "#213 (unimplemented)", /* 213 = unimplemented */
+ "#214 (unimplemented)", /* 214 = unimplemented */
+ "#215 (unimplemented)", /* 215 = unimplemented */
+ "#216 (unimplemented)", /* 216 = unimplemented */
+ "#217 (unimplemented)", /* 217 = unimplemented */
+ "#218 (unimplemented)", /* 218 = unimplemented */
+ "#219 (unimplemented)", /* 219 = unimplemented */
+ "#220 (unimplemented)", /* 220 = unimplemented */
+ "#221 (unimplemented)", /* 221 = unimplemented */
+ "#222 (unimplemented)", /* 222 = unimplemented */
+ "#223 (unimplemented)", /* 223 = unimplemented */
+ "#224 (unimplemented)", /* 224 = unimplemented */
+ "pathconf", /* 225 = pathconf */
+ "fpathconf", /* 226 = fpathconf */
+ "#227 (unimplemented)", /* 227 = unimplemented */
+ "#228 (unimplemented)", /* 228 = unimplemented */
+ "#229 (unimplemented async_daemon)", /* 229 = unimplemented async_daemon */
+ "#230 (unimplemented nfs_fcntl)", /* 230 = unimplemented nfs_fcntl */
+ "getdirentries", /* 231 = getdirentries */
+ "getdomainname", /* 232 = getdomainname */
+ "#233 (unimplemented nfs_getfh)", /* 233 = unimplemented nfs_getfh */
+ "#234 (unimplemented vfsmount)", /* 234 = unimplemented vfsmount */
+ "#235 (unimplemented nfs_svc)", /* 235 = unimplemented nfs_svc */
+ "setdomainname", /* 236 = setdomainname */
+ "#237 (unimplemented statfs)", /* 237 = unimplemented statfs */
+ "#238 (unimplemented fstatfs)", /* 238 = unimplemented fstatfs */
+ "sigaction", /* 239 = sigaction */
+ "sigprocmask", /* 240 = sigprocmask */
+ "sigpending", /* 241 = sigpending */
+ "sigsuspend", /* 242 = sigsuspend */
+ "#243 (unimplemented fsctl)", /* 243 = unimplemented fsctl */
+ "#244 (unimplemented)", /* 244 = unimplemented */
+ "#245 (unimplemented pstat)", /* 245 = unimplemented pstat */
+ "#246 (unimplemented)", /* 246 = unimplemented */
+ "#247 (unimplemented)", /* 247 = unimplemented */
+ "#248 (unimplemented)", /* 248 = unimplemented */
+ "#249 (unimplemented)", /* 249 = unimplemented */
+ "#250 (unimplemented)", /* 250 = unimplemented */
+ "#251 (unimplemented)", /* 251 = unimplemented */
+ "#252 (unimplemented)", /* 252 = unimplemented */
+ "#253 (unimplemented)", /* 253 = unimplemented */
+ "#254 (unimplemented)", /* 254 = unimplemented */
+ "#255 (unimplemented)", /* 255 = unimplemented */
+ "#256 (unimplemented)", /* 256 = unimplemented */
+ "#257 (unimplemented)", /* 257 = unimplemented */
+ "#258 (unimplemented)", /* 258 = unimplemented */
+ "#259 (unimplemented)", /* 259 = unimplemented */
+ "#260 (unimplemented)", /* 260 = unimplemented */
+ "#261 (unimplemented)", /* 261 = unimplemented */
+ "#262 (unimplemented)", /* 262 = unimplemented */
+ "#263 (unimplemented)", /* 263 = unimplemented */
+ "#264 (unimplemented)", /* 264 = unimplemented */
+ "#265 (unimplemented)", /* 265 = unimplemented */
+ "#266 (unimplemented)", /* 266 = unimplemented */
+ "#267 (unimplemented)", /* 267 = unimplemented */
+ "getdtablesize", /* 268 = getdtablesize */
+ "#269 (unimplemented)", /* 269 = unimplemented */
+ "#270 (unimplemented)", /* 270 = unimplemented */
+ "#271 (unimplemented)", /* 271 = unimplemented */
+ "fchdir", /* 272 = fchdir */
+ "#273 (unimplemented)", /* 273 = unimplemented */
+ "#274 (unimplemented)", /* 274 = unimplemented */
+ "accept", /* 275 = accept */
+ "bind", /* 276 = bind */
+ "connect", /* 277 = connect */
+ "getpeername", /* 278 = getpeername */
+ "getsockname", /* 279 = getsockname */
+ "getsockopt", /* 280 = getsockopt */
+ "listen", /* 281 = listen */
+ "recv", /* 282 = recv */
+ "recvfrom", /* 283 = recvfrom */
+ "recvmsg", /* 284 = recvmsg */
+ "send", /* 285 = send */
+ "sendmsg", /* 286 = sendmsg */
+ "sendto", /* 287 = sendto */
+ "setsockopt2", /* 288 = setsockopt2 */
+ "shutdown", /* 289 = shutdown */
+ "socket", /* 290 = socket */
+ "socketpair", /* 291 = socketpair */
+ "#292 (unimplemented)", /* 292 = unimplemented */
+ "#293 (unimplemented)", /* 293 = unimplemented */
+ "#294 (unimplemented)", /* 294 = unimplemented */
+ "#295 (unimplemented)", /* 295 = unimplemented */
+ "#296 (unimplemented)", /* 296 = unimplemented */
+ "#297 (unimplemented)", /* 297 = unimplemented */
+ "#298 (unimplemented)", /* 298 = unimplemented */
+ "#299 (unimplemented)", /* 299 = unimplemented */
+ "#300 (unimplemented)", /* 300 = unimplemented */
+ "#301 (unimplemented)", /* 301 = unimplemented */
+ "#302 (unimplemented)", /* 302 = unimplemented */
+ "#303 (unimplemented)", /* 303 = unimplemented */
+ "#304 (unimplemented)", /* 304 = unimplemented */
+ "#305 (unimplemented)", /* 305 = unimplemented */
+ "#306 (unimplemented)", /* 306 = unimplemented */
+ "#307 (unimplemented)", /* 307 = unimplemented */
+ "#308 (unimplemented)", /* 308 = unimplemented */
+ "#309 (unimplemented)", /* 309 = unimplemented */
+ "#310 (unimplemented)", /* 310 = unimplemented */
+ "#311 (unimplemented)", /* 311 = unimplemented */
+#ifdef SYSVSEM
+ "nsemctl", /* 312 = nsemctl */
+#else
+ "#312 (unimplemented semctl)", /* 312 = unimplemented semctl */
+#endif
+#ifdef SYSVMSG
+ "nmsgctl", /* 313 = nmsgctl */
+#else
+ "#313 (unimplemented msgctl)", /* 313 = unimplemented msgctl */
+#endif
+#ifdef SYSVSHM
+ "nshmctl", /* 314 = nshmctl */
+#else
+ "#314 (unimplemented shmctl)", /* 314 = unimplemented shmctl */
+#endif
+};
diff --git a/sys/compat/hpux/hpux_sysent.c b/sys/compat/hpux/hpux_sysent.c
new file mode 100644
index 00000000000..bad0ac8abd6
--- /dev/null
+++ b/sys/compat/hpux/hpux_sysent.c
@@ -0,0 +1,702 @@
+/*
+ * System call switch table.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.8 1995/10/07 06:26:42 mycroft Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signal.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <compat/hpux/hpux.h>
+#include <compat/hpux/hpux_syscallargs.h>
+
+#ifdef COMPAT_HPUX_6X
+#define compat_hpux_6x(func) __CONCAT(compat_hpux_6x_,func)
+#else
+#define compat_hpux_6x(func) sys_nosys
+#endif
+
+#define s(type) sizeof(type)
+
+struct sysent hpux_sysent[] = {
+ { 0, 0,
+ sys_nosys }, /* 0 = syscall */
+ { 1, s(struct sys_exit_args),
+ sys_exit }, /* 1 = exit */
+ { 0, 0,
+ hpux_sys_fork }, /* 2 = fork */
+ { 3, s(struct hpux_sys_read_args),
+ hpux_sys_read }, /* 3 = read */
+ { 3, s(struct hpux_sys_write_args),
+ hpux_sys_write }, /* 4 = write */
+ { 3, s(struct hpux_sys_open_args),
+ hpux_sys_open }, /* 5 = open */
+ { 1, s(struct sys_close_args),
+ sys_close }, /* 6 = close */
+ { 1, s(struct hpux_sys_wait_args),
+ hpux_sys_wait }, /* 7 = wait */
+ { 2, s(struct hpux_sys_creat_args),
+ hpux_sys_creat }, /* 8 = creat */
+ { 2, s(struct sys_link_args),
+ sys_link }, /* 9 = link */
+ { 1, s(struct sys_unlink_args),
+ sys_unlink }, /* 10 = unlink */
+ { 2, s(struct hpux_sys_execv_args),
+ hpux_sys_execv }, /* 11 = execv */
+ { 1, s(struct sys_chdir_args),
+ sys_chdir }, /* 12 = chdir */
+ { 1, s(struct compat_hpux_6x_sys_time_args),
+ compat_hpux_6x(sys_time) }, /* 13 = compat_hpux_6x time */
+ { 3, s(struct sys_mknod_args),
+ sys_mknod }, /* 14 = mknod */
+ { 2, s(struct sys_chmod_args),
+ sys_chmod }, /* 15 = chmod */
+ { 3, s(struct sys_chown_args),
+ sys_chown }, /* 16 = chown */
+ { 1, s(struct sys_obreak_args),
+ sys_obreak }, /* 17 = obreak */
+ { 2, s(struct compat_hpux_6x_sys_stat_args),
+ compat_hpux_6x(sys_stat) }, /* 18 = compat_hpux_6x stat */
+ { 3, s(struct compat_43_sys_lseek_args),
+ compat_43_sys_lseek }, /* 19 = lseek */
+ { 0, 0,
+ sys_getpid }, /* 20 = getpid */
+ { 0, 0,
+ sys_nosys }, /* 21 = unimplemented mount */
+ { 0, 0,
+ sys_nosys }, /* 22 = unimplemented umount */
+ { 1, s(struct sys_setuid_args),
+ sys_setuid }, /* 23 = setuid */
+ { 0, 0,
+ sys_getuid }, /* 24 = getuid */
+ { 1, s(struct compat_hpux_6x_sys_stime_args),
+ compat_hpux_6x(sys_stime) }, /* 25 = compat_hpux_6x stime */
+ { 4, s(struct hpux_sys_ptrace_args),
+ hpux_sys_ptrace }, /* 26 = ptrace */
+ { 1, s(struct compat_hpux_6x_sys_alarm_args),
+ compat_hpux_6x(sys_alarm) }, /* 27 = compat_hpux_6x alarm */
+ { 2, s(struct compat_hpux_6x_sys_fstat_args),
+ compat_hpux_6x(sys_fstat) }, /* 28 = compat_hpux_6x fstat */
+ { 0, 0,
+ compat_hpux_6x(sys_pause) }, /* 29 = compat_hpux_6x pause */
+ { 2, s(struct compat_hpux_6x_sys_utime_args),
+ compat_hpux_6x(sys_utime) }, /* 30 = compat_hpux_6x utime */
+ { 2, s(struct compat_hpux_6x_sys_stty_args),
+ compat_hpux_6x(sys_stty) }, /* 31 = compat_hpux_6x stty */
+ { 2, s(struct compat_hpux_6x_sys_gtty_args),
+ compat_hpux_6x(sys_gtty) }, /* 32 = compat_hpux_6x gtty */
+ { 2, s(struct sys_access_args),
+ sys_access }, /* 33 = access */
+ { 1, s(struct compat_hpux_6x_sys_nice_args),
+ compat_hpux_6x(sys_nice) }, /* 34 = compat_hpux_6x nice */
+ { 1, s(struct compat_hpux_6x_sys_ftime_args),
+ compat_hpux_6x(sys_ftime) }, /* 35 = compat_hpux_6x ftime */
+ { 0, 0,
+ sys_sync }, /* 36 = sync */
+ { 2, s(struct hpux_sys_kill_args),
+ hpux_sys_kill }, /* 37 = kill */
+ { 2, s(struct hpux_sys_stat_args),
+ hpux_sys_stat }, /* 38 = stat */
+ { 0, 0,
+ compat_hpux_6x(sys_setpgrp) }, /* 39 = compat_hpux_6x setpgrp */
+ { 2, s(struct hpux_sys_lstat_args),
+ hpux_sys_lstat }, /* 40 = lstat */
+ { 1, s(struct hpux_sys_dup_args),
+ hpux_sys_dup }, /* 41 = dup */
+ { 0, 0,
+ sys_pipe }, /* 42 = pipe */
+ { 1, s(struct compat_hpux_6x_sys_times_args),
+ compat_hpux_6x(sys_times) }, /* 43 = compat_hpux_6x times */
+ { 4, s(struct sys_profil_args),
+ sys_profil }, /* 44 = profil */
+ { 0, 0,
+ sys_nosys }, /* 45 = unimplemented ki_syscall */
+ { 1, s(struct sys_setgid_args),
+ sys_setgid }, /* 46 = setgid */
+ { 0, 0,
+ sys_getgid }, /* 47 = getgid */
+ { 2, s(struct compat_hpux_6x_sys_ssig_args),
+ compat_hpux_6x(sys_ssig) }, /* 48 = compat_hpux_6x ssig */
+ { 0, 0,
+ sys_nosys }, /* 49 = unimplemented reserved for USG */
+ { 0, 0,
+ sys_nosys }, /* 50 = unimplemented reserved for USG */
+ { 0, 0,
+ sys_nosys }, /* 51 = unimplemented acct */
+ { 0, 0,
+ sys_nosys }, /* 52 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 53 = unimplemented */
+ { 3, s(struct hpux_sys_ioctl_args),
+ hpux_sys_ioctl }, /* 54 = ioctl */
+ { 0, 0,
+ sys_nosys }, /* 55 = unimplemented reboot */
+ { 2, s(struct sys_symlink_args),
+ sys_symlink }, /* 56 = symlink */
+ { 3, s(struct hpux_sys_utssys_args),
+ hpux_sys_utssys }, /* 57 = utssys */
+ { 3, s(struct sys_readlink_args),
+ sys_readlink }, /* 58 = readlink */
+ { 3, s(struct sys_execve_args),
+ sys_execve }, /* 59 = execve */
+ { 1, s(struct sys_umask_args),
+ sys_umask }, /* 60 = umask */
+ { 1, s(struct sys_chroot_args),
+ sys_chroot }, /* 61 = chroot */
+ { 3, s(struct hpux_sys_fcntl_args),
+ hpux_sys_fcntl }, /* 62 = fcntl */
+ { 2, s(struct hpux_sys_ulimit_args),
+ hpux_sys_ulimit }, /* 63 = ulimit */
+ { 0, 0,
+ sys_nosys }, /* 64 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 65 = unimplemented */
+ { 0, 0,
+ hpux_sys_vfork }, /* 66 = vfork */
+ { 3, s(struct hpux_sys_read_args),
+ hpux_sys_read }, /* 67 = vread */
+ { 3, s(struct hpux_sys_write_args),
+ hpux_sys_write }, /* 68 = vwrite */
+ { 0, 0,
+ sys_nosys }, /* 69 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 70 = unimplemented */
+ { 6, s(struct hpux_sys_mmap_args),
+ hpux_sys_mmap }, /* 71 = mmap */
+ { 0, 0,
+ sys_nosys }, /* 72 = unimplemented */
+ { 2, s(struct sys_munmap_args),
+ sys_munmap }, /* 73 = munmap */
+ { 3, s(struct sys_mprotect_args),
+ sys_mprotect }, /* 74 = mprotect */
+ { 0, 0,
+ sys_nosys }, /* 75 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 76 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 77 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 78 = unimplemented */
+ { 2, s(struct sys_getgroups_args),
+ sys_getgroups }, /* 79 = getgroups */
+ { 2, s(struct sys_setgroups_args),
+ sys_setgroups }, /* 80 = setgroups */
+ { 1, s(struct hpux_sys_getpgrp2_args),
+ hpux_sys_getpgrp2 }, /* 81 = getpgrp2 */
+ { 2, s(struct hpux_sys_setpgrp2_args),
+ hpux_sys_setpgrp2 }, /* 82 = setpgrp2 */
+ { 3, s(struct sys_setitimer_args),
+ sys_setitimer }, /* 83 = setitimer */
+ { 3, s(struct hpux_sys_wait3_args),
+ hpux_sys_wait3 }, /* 84 = wait3 */
+ { 0, 0,
+ sys_nosys }, /* 85 = unimplemented swapon */
+ { 2, s(struct sys_getitimer_args),
+ sys_getitimer }, /* 86 = getitimer */
+ { 0, 0,
+ sys_nosys }, /* 87 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 88 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 89 = unimplemented */
+ { 2, s(struct sys_dup2_args),
+ sys_dup2 }, /* 90 = dup2 */
+ { 0, 0,
+ sys_nosys }, /* 91 = unimplemented */
+ { 2, s(struct hpux_sys_fstat_args),
+ hpux_sys_fstat }, /* 92 = fstat */
+ { 5, s(struct sys_select_args),
+ sys_select }, /* 93 = select */
+ { 0, 0,
+ sys_nosys }, /* 94 = unimplemented */
+ { 1, s(struct sys_fsync_args),
+ sys_fsync }, /* 95 = fsync */
+ { 0, 0,
+ sys_nosys }, /* 96 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 97 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 98 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 99 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 100 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 101 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 102 = unimplemented */
+ { 1, s(struct sys_sigreturn_args),
+ sys_sigreturn }, /* 103 = sigreturn */
+ { 0, 0,
+ sys_nosys }, /* 104 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 105 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 106 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 107 = unimplemented */
+ { 3, s(struct hpux_sys_sigvec_args),
+ hpux_sys_sigvec }, /* 108 = sigvec */
+ { 1, s(struct hpux_sys_sigblock_args),
+ hpux_sys_sigblock }, /* 109 = sigblock */
+ { 1, s(struct hpux_sys_sigsetmask_args),
+ hpux_sys_sigsetmask }, /* 110 = sigsetmask */
+ { 1, s(struct hpux_sys_sigpause_args),
+ hpux_sys_sigpause }, /* 111 = sigpause */
+ { 2, s(struct compat_43_sys_sigstack_args),
+ compat_43_sys_sigstack }, /* 112 = sigstack */
+ { 0, 0,
+ sys_nosys }, /* 113 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 114 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 115 = unimplemented */
+ { 1, s(struct sys_gettimeofday_args),
+ sys_gettimeofday }, /* 116 = gettimeofday */
+ { 0, 0,
+ sys_nosys }, /* 117 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 118 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 119 = unimplemented io_stub */
+ { 3, s(struct hpux_sys_readv_args),
+ hpux_sys_readv }, /* 120 = readv */
+ { 3, s(struct hpux_sys_writev_args),
+ hpux_sys_writev }, /* 121 = writev */
+ { 2, s(struct sys_settimeofday_args),
+ sys_settimeofday }, /* 122 = settimeofday */
+ { 3, s(struct sys_fchown_args),
+ sys_fchown }, /* 123 = fchown */
+ { 2, s(struct sys_fchmod_args),
+ sys_fchmod }, /* 124 = fchmod */
+ { 0, 0,
+ sys_nosys }, /* 125 = unimplemented */
+ { 3, s(struct hpux_sys_setresuid_args),
+ hpux_sys_setresuid }, /* 126 = setresuid */
+ { 3, s(struct hpux_sys_setresgid_args),
+ hpux_sys_setresgid }, /* 127 = setresgid */
+ { 2, s(struct sys_rename_args),
+ sys_rename }, /* 128 = rename */
+ { 2, s(struct compat_43_sys_truncate_args),
+ compat_43_sys_truncate }, /* 129 = truncate */
+ { 2, s(struct compat_43_sys_ftruncate_args),
+ compat_43_sys_ftruncate }, /* 130 = ftruncate */
+ { 0, 0,
+ sys_nosys }, /* 131 = unimplemented */
+ { 1, s(struct hpux_sys_sysconf_args),
+ hpux_sys_sysconf }, /* 132 = sysconf */
+ { 0, 0,
+ sys_nosys }, /* 133 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 134 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 135 = unimplemented */
+ { 2, s(struct sys_mkdir_args),
+ sys_mkdir }, /* 136 = mkdir */
+ { 1, s(struct sys_rmdir_args),
+ sys_rmdir }, /* 137 = rmdir */
+ { 0, 0,
+ sys_nosys }, /* 138 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 139 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 140 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 141 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 142 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 143 = unimplemented */
+ { 2, s(struct hpux_sys_getrlimit_args),
+ hpux_sys_getrlimit }, /* 144 = getrlimit */
+ { 2, s(struct hpux_sys_setrlimit_args),
+ hpux_sys_setrlimit }, /* 145 = setrlimit */
+ { 0, 0,
+ sys_nosys }, /* 146 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 147 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 148 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 149 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 150 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 151 = unimplemented privgrp */
+ { 2, s(struct hpux_sys_rtprio_args),
+ hpux_sys_rtprio }, /* 152 = rtprio */
+ { 0, 0,
+ sys_nosys }, /* 153 = unimplemented plock */
+ { 2, s(struct hpux_sys_netioctl_args),
+ hpux_sys_netioctl }, /* 154 = netioctl */
+ { 3, s(struct hpux_sys_lockf_args),
+ hpux_sys_lockf }, /* 155 = lockf */
+#ifdef SYSVSEM
+ { 3, s(struct sys_semget_args),
+ sys_semget }, /* 156 = semget */
+ { 4, s(struct sys___semctl_args),
+ sys___semctl }, /* 157 = __semctl */
+ { 3, s(struct sys_semop_args),
+ sys_semop }, /* 158 = semop */
+#else
+ { 0, 0,
+ sys_nosys }, /* 156 = unimplemented semget */
+ { 0, 0,
+ sys_nosys }, /* 157 = unimplemented semctl */
+ { 0, 0,
+ sys_nosys }, /* 158 = unimplemented semop */
+#endif
+#ifdef SYSVMSG
+ { 2, s(struct sys_msgget_args),
+ sys_msgget }, /* 159 = msgget */
+ { 3, s(struct sys_msgctl_args),
+ sys_msgctl }, /* 160 = msgctl */
+ { 4, s(struct sys_msgsnd_args),
+ sys_msgsnd }, /* 161 = msgsnd */
+ { 5, s(struct sys_msgrcv_args),
+ sys_msgrcv }, /* 162 = msgrcv */
+#else
+ { 0, 0,
+ sys_nosys }, /* 159 = unimplemented msgget */
+ { 0, 0,
+ sys_nosys }, /* 160 = unimplemented msgctl */
+ { 0, 0,
+ sys_nosys }, /* 161 = unimplemented msgsnd */
+ { 0, 0,
+ sys_nosys }, /* 162 = unimplemented msgrcv */
+#endif
+#ifdef SYSVSHM
+ { 3, s(struct sys_shmget_args),
+ sys_shmget }, /* 163 = shmget */
+ { 3, s(struct hpux_sys_shmctl_args),
+ hpux_sys_shmctl }, /* 164 = shmctl */
+ { 3, s(struct sys_shmat_args),
+ sys_shmat }, /* 165 = shmat */
+ { 1, s(struct sys_shmdt_args),
+ sys_shmdt }, /* 166 = shmdt */
+#else
+ { 0, 0,
+ sys_nosys }, /* 163 = unimplemented shmget */
+ { 0, 0,
+ sys_nosys }, /* 164 = unimplemented shmctl */
+ { 0, 0,
+ sys_nosys }, /* 165 = unimplemented shmat */
+ { 0, 0,
+ sys_nosys }, /* 166 = unimplemented shmdt */
+#endif
+ { 1, s(struct hpux_sys_advise_args),
+ hpux_sys_advise }, /* 167 = advise */
+ { 0, 0,
+ sys_nosys }, /* 168 = unimplemented nsp_init */
+ { 0, 0,
+ sys_nosys }, /* 169 = unimplemented cluster */
+ { 0, 0,
+ sys_nosys }, /* 170 = unimplemented mkrnod */
+ { 0, 0,
+ sys_nosys }, /* 171 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 172 = unimplemented unsp_open */
+ { 0, 0,
+ sys_nosys }, /* 173 = unimplemented */
+ { 2, s(struct hpux_sys_getcontext_args),
+ hpux_sys_getcontext }, /* 174 = getcontext */
+ { 0, 0,
+ sys_nosys }, /* 175 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 176 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 177 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 178 = unimplemented lsync */
+ { 0, 0,
+ sys_nosys }, /* 179 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 180 = unimplemented mysite */
+ { 0, 0,
+ sys_nosys }, /* 181 = unimplemented sitels */
+ { 0, 0,
+ sys_nosys }, /* 182 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 183 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 184 = unimplemented dskless_stats */
+ { 0, 0,
+ sys_nosys }, /* 185 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 186 = unimplemented setacl */
+ { 0, 0,
+ sys_nosys }, /* 187 = unimplemented fsetacl */
+ { 0, 0,
+ sys_nosys }, /* 188 = unimplemented getacl */
+ { 0, 0,
+ sys_nosys }, /* 189 = unimplemented fgetacl */
+ { 6, s(struct hpux_sys_getaccess_args),
+ hpux_sys_getaccess }, /* 190 = getaccess */
+ { 0, 0,
+ sys_nosys }, /* 191 = unimplemented getaudid */
+ { 0, 0,
+ sys_nosys }, /* 192 = unimplemented setaudid */
+ { 0, 0,
+ sys_nosys }, /* 193 = unimplemented getaudproc */
+ { 0, 0,
+ sys_nosys }, /* 194 = unimplemented setaudproc */
+ { 0, 0,
+ sys_nosys }, /* 195 = unimplemented getevent */
+ { 0, 0,
+ sys_nosys }, /* 196 = unimplemented setevent */
+ { 0, 0,
+ sys_nosys }, /* 197 = unimplemented audwrite */
+ { 0, 0,
+ sys_nosys }, /* 198 = unimplemented audswitch */
+ { 0, 0,
+ sys_nosys }, /* 199 = unimplemented audctl */
+ { 4, s(struct hpux_sys_waitpid_args),
+ hpux_sys_waitpid }, /* 200 = waitpid */
+ { 0, 0,
+ sys_nosys }, /* 201 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 202 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 203 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 204 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 205 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 206 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 207 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 208 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 209 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 210 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 211 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 212 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 213 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 214 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 215 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 216 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 217 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 218 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 219 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 220 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 221 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 222 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 223 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 224 = unimplemented */
+ { 2, s(struct sys_pathconf_args),
+ sys_pathconf }, /* 225 = pathconf */
+ { 2, s(struct sys_fpathconf_args),
+ sys_fpathconf }, /* 226 = fpathconf */
+ { 0, 0,
+ sys_nosys }, /* 227 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 228 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 229 = unimplemented async_daemon */
+ { 0, 0,
+ sys_nosys }, /* 230 = unimplemented nfs_fcntl */
+ { 4, s(struct compat_43_sys_getdirentries_args),
+ compat_43_sys_getdirentries }, /* 231 = getdirentries */
+ { 2, s(struct compat_09_sys_getdomainname_args),
+ compat_09_sys_getdomainname }, /* 232 = getdomainname */
+ { 0, 0,
+ sys_nosys }, /* 233 = unimplemented nfs_getfh */
+ { 0, 0,
+ sys_nosys }, /* 234 = unimplemented vfsmount */
+ { 0, 0,
+ sys_nosys }, /* 235 = unimplemented nfs_svc */
+ { 2, s(struct compat_09_sys_setdomainname_args),
+ compat_09_sys_setdomainname }, /* 236 = setdomainname */
+ { 0, 0,
+ sys_nosys }, /* 237 = unimplemented statfs */
+ { 0, 0,
+ sys_nosys }, /* 238 = unimplemented fstatfs */
+ { 3, s(struct hpux_sys_sigaction_args),
+ hpux_sys_sigaction }, /* 239 = sigaction */
+ { 3, s(struct hpux_sys_sigprocmask_args),
+ hpux_sys_sigprocmask }, /* 240 = sigprocmask */
+ { 1, s(struct hpux_sys_sigpending_args),
+ hpux_sys_sigpending }, /* 241 = sigpending */
+ { 1, s(struct hpux_sys_sigsuspend_args),
+ hpux_sys_sigsuspend }, /* 242 = sigsuspend */
+ { 0, 0,
+ sys_nosys }, /* 243 = unimplemented fsctl */
+ { 0, 0,
+ sys_nosys }, /* 244 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 245 = unimplemented pstat */
+ { 0, 0,
+ sys_nosys }, /* 246 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 247 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 248 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 249 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 250 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 251 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 252 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 253 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 254 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 255 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 256 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 257 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 258 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 259 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 260 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 261 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 262 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 263 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 264 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 265 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 266 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 267 = unimplemented */
+ { 0, 0,
+ compat_43_sys_getdtablesize }, /* 268 = getdtablesize */
+ { 0, 0,
+ sys_nosys }, /* 269 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 270 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 271 = unimplemented */
+ { 1, s(struct sys_fchdir_args),
+ sys_fchdir }, /* 272 = fchdir */
+ { 0, 0,
+ sys_nosys }, /* 273 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 274 = unimplemented */
+ { 3, s(struct compat_43_sys_accept_args),
+ compat_43_sys_accept }, /* 275 = accept */
+ { 3, s(struct sys_bind_args),
+ sys_bind }, /* 276 = bind */
+ { 3, s(struct sys_connect_args),
+ sys_connect }, /* 277 = connect */
+ { 3, s(struct compat_43_sys_getpeername_args),
+ compat_43_sys_getpeername }, /* 278 = getpeername */
+ { 3, s(struct compat_43_sys_getsockname_args),
+ compat_43_sys_getsockname }, /* 279 = getsockname */
+ { 5, s(struct sys_getsockopt_args),
+ sys_getsockopt }, /* 280 = getsockopt */
+ { 2, s(struct sys_listen_args),
+ sys_listen }, /* 281 = listen */
+ { 4, s(struct compat_43_sys_recv_args),
+ compat_43_sys_recv }, /* 282 = recv */
+ { 6, s(struct compat_43_sys_recvfrom_args),
+ compat_43_sys_recvfrom }, /* 283 = recvfrom */
+ { 3, s(struct compat_43_sys_recvmsg_args),
+ compat_43_sys_recvmsg }, /* 284 = recvmsg */
+ { 4, s(struct compat_43_sys_send_args),
+ compat_43_sys_send }, /* 285 = send */
+ { 3, s(struct compat_43_sys_sendmsg_args),
+ compat_43_sys_sendmsg }, /* 286 = sendmsg */
+ { 6, s(struct sys_sendto_args),
+ sys_sendto }, /* 287 = sendto */
+ { 5, s(struct hpux_sys_setsockopt2_args),
+ hpux_sys_setsockopt2 }, /* 288 = setsockopt2 */
+ { 2, s(struct sys_shutdown_args),
+ sys_shutdown }, /* 289 = shutdown */
+ { 3, s(struct sys_socket_args),
+ sys_socket }, /* 290 = socket */
+ { 4, s(struct sys_socketpair_args),
+ sys_socketpair }, /* 291 = socketpair */
+ { 0, 0,
+ sys_nosys }, /* 292 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 293 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 294 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 295 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 296 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 297 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 298 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 299 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 300 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 301 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 302 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 303 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 304 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 305 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 306 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 307 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 308 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 309 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 310 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 311 = unimplemented */
+#ifdef SYSVSEM
+ { 4, s(struct sys___semctl_args),
+ sys___semctl }, /* 312 = nsemctl */
+#else
+ { 0, 0,
+ sys_nosys }, /* 312 = unimplemented semctl */
+#endif
+#ifdef SYSVMSG
+ { 3, s(struct sys_msgctl_args),
+ sys_msgctl }, /* 313 = nmsgctl */
+#else
+ { 0, 0,
+ sys_nosys }, /* 313 = unimplemented msgctl */
+#endif
+#ifdef SYSVSHM
+ { 3, s(struct hpux_sys_nshmctl_args),
+ hpux_sys_nshmctl }, /* 314 = nshmctl */
+#else
+ { 0, 0,
+ sys_nosys }, /* 314 = unimplemented shmctl */
+#endif
+};
+
diff --git a/sys/compat/hpux/hpux_termio.h b/sys/compat/hpux/hpux_termio.h
new file mode 100644
index 00000000000..ec446acd16e
--- /dev/null
+++ b/sys/compat/hpux/hpux_termio.h
@@ -0,0 +1,192 @@
+/* $NetBSD: hpux_termio.h,v 1.6 1994/10/26 02:45:20 cgd Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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: Utah $Hdr: hpux_termio.h 1.1 90/07/09$
+ *
+ * @(#)hpux_termio.h 8.1 (Berkeley) 6/10/93
+ */
+
+/* HP-UX termio stuff */
+
+#define HPUXNCC 8
+
+/* control characters */
+#define HPUXVINTR 0
+#define HPUXVQUIT 1
+#define HPUXVERASE 2
+#define HPUXVKILL 3
+#define HPUXVEOF 4
+#define HPUXVEOL 5
+#define HPUXVMIN 4
+#define HPUXVTIME 5
+#define HPUXVEOL2 6
+#define HPUXVSWTCH 7
+
+/* input modes */
+#define TIO_IGNBRK 0x00000001 /* 0000001 */
+#define TIO_BRKINT 0x00000002 /* 0000002 */
+#define TIO_IGNPAR 0x00000004 /* 0000004 */
+#define TIO_PARMRK 0x00000008 /* 0000010 */
+#define TIO_INPCK 0x00000010 /* 0000020 */
+#define TIO_ISTRIP 0x00000020 /* 0000040 */
+#define TIO_INLCR 0x00000040 /* 0000100 */
+#define TIO_IGNCR 0x00000080 /* 0000200 */
+#define TIO_ICRNL 0x00000100 /* 0000400 */
+#define TIO_IUCLC 0x00000200 /* 0001000 */
+#define TIO_IXON 0x00000400 /* 0002000 */
+#define TIO_IXANY 0x00000800 /* 0004000 */
+#define TIO_IXOFF 0x00001000 /* 0010000 */
+#define TIO_IENQAK 0x00002000 /* 0020000 */
+
+/* output modes */
+#define TIO_OPOST 0x00000001 /* 0000001 */
+#define TIO_OLCUC 0x00000002 /* 0000002 */
+#define TIO_ONLCR 0x00000004 /* 0000004 */
+#define TIO_OCRNL 0x00000008 /* 0000010 */
+#define TIO_ONOCR 0x00000010 /* 0000020 */
+#define TIO_ONLRET 0x00000020 /* 0000040 */
+#define TIO_OFILL 0x00000040 /* 0000100 */
+#define TIO_OFDEL 0x00000080 /* 0000200 */
+#define TIO_NLDLY 0x00000100 /* 0000400 */
+#define TIO_NL0 0
+#define TIO_NL1 0x00000100 /* 0000400 */
+#define TIO_CRDLY 0x00000600 /* 0003000 */
+#define TIO_CR0 0
+#define TIO_CR1 0x00000200 /* 0001000 */
+#define TIO_CR2 0x00000400 /* 0002000 */
+#define TIO_CR3 0x00000600 /* 0003000 */
+#define TIO_TABDLY 0x00001800 /* 0014000 */
+#define TIO_TAB0 0
+#define TIO_TAB1 0x00000800 /* 0004000 */
+#define TIO_TAB2 0x00001000 /* 0010000 */
+#define TIO_TAB3 0x00001800 /* 0014000 */
+#define TIO_BSDLY 0x00002000 /* 0020000 */
+#define TIO_BS0 0
+#define TIO_BS1 0x00002000 /* 0020000 */
+#define TIO_VTDLY 0x00004000 /* 0040000 */
+#define TIO_VT0 0
+#define TIO_VT1 0x00004000 /* 0040000 */
+#define TIO_FFDLY 0x00008000 /* 0100000 */
+#define TIO_FF0 0
+#define TIO_FF1 0x00008000 /* 0100000 */
+
+/* control modes */
+#define TIO_CBAUD 0x0000001f /* 0000037 */
+#define TIO_B0 0
+#define TIO_B50 0x00000001 /* 0000001 */
+#define TIO_B75 0x00000002 /* 0000002 */
+#define TIO_B110 0x00000003 /* 0000003 */
+#define TIO_B134 0x00000004 /* 0000004 */
+#define TIO_B150 0x00000005 /* 0000005 */
+#define TIO_B200 0x00000006 /* 0000006 */
+#define TIO_B300 0x00000007 /* 0000007 */
+#define TIO_B600 0x00000008 /* 0000010 */
+#define TIO_B900 0x00000009 /* 0000011 */
+#define TIO_B1200 0x0000000a /* 0000012 */
+#define TIO_B1800 0x0000000b /* 0000013 */
+#define TIO_B2400 0x0000000c /* 0000014 */
+#define TIO_B3600 0x0000000d /* 0000015 */
+#define TIO_B4800 0x0000000e /* 0000016 */
+#define TIO_B7200 0x0000000f /* 0000017 */
+#define TIO_B9600 0x00000010 /* 0000020 */
+#define TIO_B19200 0x00000011 /* 0000021 */
+#define TIO_B38400 0x00000012 /* 0000022 */
+#define TIO_EXTA 0x0000001e /* 0000036 */
+#define TIO_EXTB 0x0000001f /* 0000037 */
+#define TIO_CSIZE 0x00000060 /* 0000140 */
+#define TIO_CS5 0
+#define TIO_CS6 0x00000020 /* 0000040 */
+#define TIO_CS7 0x00000040 /* 0000100 */
+#define TIO_CS8 0x00000060 /* 0000140 */
+#define TIO_CSTOPB 0x00000080 /* 0000200 */
+#define TIO_CREAD 0x00000100 /* 0000400 */
+#define TIO_PARENB 0x00000200 /* 0001000 */
+#define TIO_PARODD 0x00000400 /* 0002000 */
+#define TIO_HUPCL 0x00000800 /* 0004000 */
+#define TIO_CLOCAL 0x00001000 /* 0010000 */
+#define TIO_CRTS 0x00002000 /* 0020000 */ /* Obsolete */
+
+/* line discipline 0 modes */
+#define TIO_ISIG 0x00000001 /* 0000001 */
+#define TIO_ICANON 0x00000002 /* 0000002 */
+#define TIO_XCASE 0x00000004 /* 0000004 */
+#define TIO_ECHO 0x00000008 /* 0000010 */
+#define TIO_ECHOE 0x00000010 /* 0000020 */
+#define TIO_ECHOK 0x00000020 /* 0000040 */
+#define TIO_ECHONL 0x00000040 /* 0000100 */
+#define TIO_NOFLSH 0x00000080 /* 0000200 */
+
+struct hpux_termio {
+ u_short c_iflag; /* input modes */
+ u_short c_oflag; /* output modes */
+ u_short c_cflag; /* control modes */
+ u_short c_lflag; /* line discipline modes */
+ char c_line; /* line discipline */
+ u_char c_cc[HPUXNCC]; /* control chars */
+};
+
+#define HPUXTCGETA _IOR('T', 1, struct hpux_termio)
+#define HPUXTCSETA _IOW('T', 2, struct hpux_termio)
+#define HPUXTCSETAW _IOW('T', 3, struct hpux_termio)
+#define HPUXTCSETAF _IOW('T', 4, struct hpux_termio)
+
+/* HP-UX termios stuff */
+
+#define HPUXNCCS 16
+
+/* control characters */
+#define HPUXVMINS 11 /* different than termio */
+#define HPUXVTIMES 12 /* different than termio */
+#define HPUXVSUSP 13
+#define HPUXVSTART 14
+#define HPUXVSTOP 15
+
+struct hpux_termios {
+ u_int c_iflag; /* input modes */
+ u_int c_oflag; /* output modes */
+ u_int c_cflag; /* control modes */
+ u_int c_lflag; /* line discipline modes */
+ u_int c_reserved; /* future use */
+ u_char c_cc[HPUXNCCS]; /* control chars */
+};
+
+#define HPUXTCGETATTR _IOR('T', 16, struct hpux_termios)
+#define HPUXTCSETATTR _IOW('T', 17, struct hpux_termios)
+#define HPUXTCSETATTRD _IOW('T', 18, struct hpux_termios)
+#define HPUXTCSETATTRF _IOW('T', 19, struct hpux_termios)
diff --git a/sys/compat/hpux/hpux_tty.c b/sys/compat/hpux/hpux_tty.c
new file mode 100644
index 00000000000..d95e1731b5f
--- /dev/null
+++ b/sys/compat/hpux/hpux_tty.c
@@ -0,0 +1,548 @@
+/* $NetBSD: hpux_tty.c,v 1.11 1995/10/07 06:26:40 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1988 University of Utah.
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * the Systems Programming Group of the University of Utah Computer
+ * Science Department.
+ *
+ * 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: Utah $Hdr: hpux_tty.c 1.14 93/08/05$
+ *
+ * @(#)hpux_tty.c 8.3 (Berkeley) 1/12/94
+ */
+
+/*
+ * stty/gtty/termio emulation stuff
+ */
+
+#ifndef COMPAT_43
+#define COMPAT_43
+#endif
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/proc.h>
+#include <sys/tty.h>
+#include <sys/file.h>
+#include <sys/conf.h>
+#include <sys/buf.h>
+#include <sys/kernel.h>
+
+#include <compat/hpux/hpux.h>
+#include <compat/hpux/hpux_termio.h>
+#include <compat/hpux/hpux_syscallargs.h>
+
+/*
+ * Map BSD/POSIX style termios info to and from SYS5 style termio stuff.
+ */
+int
+hpux_termio(fd, com, data, p)
+ int fd, com;
+ caddr_t data;
+ struct proc *p;
+{
+ struct file *fp;
+ struct termios tios;
+ struct hpux_termios htios;
+ int line, error, (*ioctlrout)();
+ int newi = 0;
+
+ fp = p->p_fd->fd_ofiles[fd];
+ ioctlrout = fp->f_ops->fo_ioctl;
+ switch (com) {
+ case HPUXTCGETATTR:
+ newi = 1;
+ /* fall into ... */
+ case HPUXTCGETA:
+ /*
+ * Get BSD terminal state
+ */
+ if (error = (*ioctlrout)(fp, TIOCGETA, (caddr_t)&tios, p))
+ break;
+ bzero((char *)&htios, sizeof htios);
+ /*
+ * Set iflag.
+ * Same through ICRNL, no BSD equivs for IUCLC, IENQAK
+ */
+ htios.c_iflag = tios.c_iflag & 0x1ff;
+ if (tios.c_iflag & IXON)
+ htios.c_iflag |= TIO_IXON;
+ if (tios.c_iflag & IXOFF)
+ htios.c_iflag |= TIO_IXOFF;
+ if (tios.c_iflag & IXANY)
+ htios.c_iflag |= TIO_IXANY;
+ /*
+ * Set oflag.
+ * No BSD equivs for OLCUC/OCRNL/ONOCR/ONLRET/OFILL/OFDEL
+ * or any of the delays.
+ */
+ if (tios.c_oflag & OPOST)
+ htios.c_oflag |= TIO_OPOST;
+ if (tios.c_oflag & ONLCR)
+ htios.c_oflag |= TIO_ONLCR;
+ if (tios.c_oflag & OXTABS)
+ htios.c_oflag |= TIO_TAB3;
+ /*
+ * Set cflag.
+ * Baud from ospeed, rest from cflag.
+ */
+ htios.c_cflag = bsdtohpuxbaud(tios.c_ospeed);
+ switch (tios.c_cflag & CSIZE) {
+ case CS5:
+ htios.c_cflag |= TIO_CS5; break;
+ case CS6:
+ htios.c_cflag |= TIO_CS6; break;
+ case CS7:
+ htios.c_cflag |= TIO_CS7; break;
+ case CS8:
+ htios.c_cflag |= TIO_CS8; break;
+ }
+ if (tios.c_cflag & CSTOPB)
+ htios.c_cflag |= TIO_CSTOPB;
+ if (tios.c_cflag & CREAD)
+ htios.c_cflag |= TIO_CREAD;
+ if (tios.c_cflag & PARENB)
+ htios.c_cflag |= TIO_PARENB;
+ if (tios.c_cflag & PARODD)
+ htios.c_cflag |= TIO_PARODD;
+ if (tios.c_cflag & HUPCL)
+ htios.c_cflag |= TIO_HUPCL;
+ if (tios.c_cflag & CLOCAL)
+ htios.c_cflag |= TIO_CLOCAL;
+ /*
+ * Set lflag.
+ * No BSD equiv for XCASE.
+ */
+ if (tios.c_lflag & ECHOE)
+ htios.c_lflag |= TIO_ECHOE;
+ if (tios.c_lflag & ECHOK)
+ htios.c_lflag |= TIO_ECHOK;
+ if (tios.c_lflag & ECHO)
+ htios.c_lflag |= TIO_ECHO;
+ if (tios.c_lflag & ECHONL)
+ htios.c_lflag |= TIO_ECHONL;
+ if (tios.c_lflag & ISIG)
+ htios.c_lflag |= TIO_ISIG;
+ if (tios.c_lflag & ICANON)
+ htios.c_lflag |= TIO_ICANON;
+ if (tios.c_lflag & NOFLSH)
+ htios.c_lflag |= TIO_NOFLSH;
+ /*
+ * Line discipline
+ */
+ if (!newi) {
+ line = 0;
+ (void) (*ioctlrout)(fp, TIOCGETD, (caddr_t)&line, p);
+ htios.c_reserved = line;
+ }
+ /*
+ * Set editing chars.
+ * No BSD equiv for VSWTCH.
+ */
+ htios.c_cc[HPUXVINTR] = tios.c_cc[VINTR];
+ htios.c_cc[HPUXVQUIT] = tios.c_cc[VQUIT];
+ htios.c_cc[HPUXVERASE] = tios.c_cc[VERASE];
+ htios.c_cc[HPUXVKILL] = tios.c_cc[VKILL];
+ htios.c_cc[HPUXVEOF] = tios.c_cc[VEOF];
+ htios.c_cc[HPUXVEOL] = tios.c_cc[VEOL];
+ htios.c_cc[HPUXVEOL2] = tios.c_cc[VEOL2];
+ htios.c_cc[HPUXVSWTCH] = 0;
+#if 1
+ /*
+ * XXX since VMIN and VTIME are not implemented,
+ * we need to return something reasonable.
+ * Otherwise a GETA/SETA combo would always put
+ * the tty in non-blocking mode (since VMIN == VTIME == 0).
+ */
+ if (fp->f_flag & FNONBLOCK) {
+ htios.c_cc[HPUXVMINS] = 0;
+ htios.c_cc[HPUXVTIMES] = 0;
+ } else {
+ htios.c_cc[HPUXVMINS] = 6;
+ htios.c_cc[HPUXVTIMES] = 1;
+ }
+#else
+ htios.c_cc[HPUXVMINS] = tios.c_cc[VMIN];
+ htios.c_cc[HPUXVTIMES] = tios.c_cc[VTIME];
+#endif
+ htios.c_cc[HPUXVSUSP] = tios.c_cc[VSUSP];
+ htios.c_cc[HPUXVSTART] = tios.c_cc[VSTART];
+ htios.c_cc[HPUXVSTOP] = tios.c_cc[VSTOP];
+ if (newi)
+ bcopy((char *)&htios, data, sizeof htios);
+ else
+ termiostotermio(&htios, (struct hpux_termio *)data);
+ break;
+
+ case HPUXTCSETATTR:
+ case HPUXTCSETATTRD:
+ case HPUXTCSETATTRF:
+ newi = 1;
+ /* fall into ... */
+ case HPUXTCSETA:
+ case HPUXTCSETAW:
+ case HPUXTCSETAF:
+ /*
+ * Get old characteristics and determine if we are a tty.
+ */
+ if (error = (*ioctlrout)(fp, TIOCGETA, (caddr_t)&tios, p))
+ break;
+ if (newi)
+ bcopy(data, (char *)&htios, sizeof htios);
+ else
+ termiototermios((struct termio *)data, &htios, &tios);
+ /*
+ * Set iflag.
+ * Same through ICRNL, no HP-UX equiv for IMAXBEL
+ */
+ tios.c_iflag &= ~(IXON|IXOFF|IXANY|0x1ff);
+ tios.c_iflag |= htios.c_iflag & 0x1ff;
+ if (htios.c_iflag & TIO_IXON)
+ tios.c_iflag |= IXON;
+ if (htios.c_iflag & TIO_IXOFF)
+ tios.c_iflag |= IXOFF;
+ if (htios.c_iflag & TIO_IXANY)
+ tios.c_iflag |= IXANY;
+ /*
+ * Set oflag.
+ * No HP-UX equiv for ONOEOT
+ */
+ tios.c_oflag &= ~(OPOST|ONLCR|OXTABS);
+ if (htios.c_oflag & TIO_OPOST)
+ tios.c_oflag |= OPOST;
+ if (htios.c_oflag & TIO_ONLCR)
+ tios.c_oflag |= ONLCR;
+ if (htios.c_oflag & TIO_TAB3)
+ tios.c_oflag |= OXTABS;
+ /*
+ * Set cflag.
+ * No HP-UX equiv for CCTS_OFLOW/CCTS_IFLOW/MDMBUF
+ */
+ tios.c_cflag &=
+ ~(CSIZE|CSTOPB|CREAD|PARENB|PARODD|HUPCL|CLOCAL);
+ switch (htios.c_cflag & TIO_CSIZE) {
+ case TIO_CS5:
+ tios.c_cflag |= CS5; break;
+ case TIO_CS6:
+ tios.c_cflag |= CS6; break;
+ case TIO_CS7:
+ tios.c_cflag |= CS7; break;
+ case TIO_CS8:
+ tios.c_cflag |= CS8; break;
+ }
+ if (htios.c_cflag & TIO_CSTOPB)
+ tios.c_cflag |= CSTOPB;
+ if (htios.c_cflag & TIO_CREAD)
+ tios.c_cflag |= CREAD;
+ if (htios.c_cflag & TIO_PARENB)
+ tios.c_cflag |= PARENB;
+ if (htios.c_cflag & TIO_PARODD)
+ tios.c_cflag |= PARODD;
+ if (htios.c_cflag & TIO_HUPCL)
+ tios.c_cflag |= HUPCL;
+ if (htios.c_cflag & TIO_CLOCAL)
+ tios.c_cflag |= CLOCAL;
+ /*
+ * Set lflag.
+ * No HP-UX equiv for ECHOKE/ECHOPRT/ECHOCTL
+ * IEXTEN treated as part of ICANON
+ */
+ tios.c_lflag &= ~(ECHOE|ECHOK|ECHO|ISIG|ICANON|IEXTEN|NOFLSH);
+ if (htios.c_lflag & TIO_ECHOE)
+ tios.c_lflag |= ECHOE;
+ if (htios.c_lflag & TIO_ECHOK)
+ tios.c_lflag |= ECHOK;
+ if (htios.c_lflag & TIO_ECHO)
+ tios.c_lflag |= ECHO;
+ if (htios.c_lflag & TIO_ECHONL)
+ tios.c_lflag |= ECHONL;
+ if (htios.c_lflag & TIO_ISIG)
+ tios.c_lflag |= ISIG;
+ if (htios.c_lflag & TIO_ICANON)
+ tios.c_lflag |= (ICANON|IEXTEN);
+ if (htios.c_lflag & TIO_NOFLSH)
+ tios.c_lflag |= NOFLSH;
+ /*
+ * Set editing chars.
+ * No HP-UX equivs of VWERASE/VREPRINT/VDSUSP/VLNEXT
+ * /VDISCARD/VSTATUS/VERASE2
+ */
+ tios.c_cc[VINTR] = htios.c_cc[HPUXVINTR];
+ tios.c_cc[VQUIT] = htios.c_cc[HPUXVQUIT];
+ tios.c_cc[VERASE] = htios.c_cc[HPUXVERASE];
+ tios.c_cc[VKILL] = htios.c_cc[HPUXVKILL];
+ tios.c_cc[VEOF] = htios.c_cc[HPUXVEOF];
+ tios.c_cc[VEOL] = htios.c_cc[HPUXVEOL];
+ tios.c_cc[VEOL2] = htios.c_cc[HPUXVEOL2];
+ tios.c_cc[VMIN] = htios.c_cc[HPUXVMINS];
+ tios.c_cc[VTIME] = htios.c_cc[HPUXVTIMES];
+ tios.c_cc[VSUSP] = htios.c_cc[HPUXVSUSP];
+ tios.c_cc[VSTART] = htios.c_cc[HPUXVSTART];
+ tios.c_cc[VSTOP] = htios.c_cc[HPUXVSTOP];
+
+ /*
+ * Set the new stuff
+ */
+ if (com == HPUXTCSETA || com == HPUXTCSETATTR)
+ com = TIOCSETA;
+ else if (com == HPUXTCSETAW || com == HPUXTCSETATTRD)
+ com = TIOCSETAW;
+ else
+ com = TIOCSETAF;
+ error = (*ioctlrout)(fp, com, (caddr_t)&tios, p);
+ if (error == 0) {
+ /*
+ * Set line discipline
+ */
+ if (!newi) {
+ line = htios.c_reserved;
+ (void) (*ioctlrout)(fp, TIOCSETD,
+ (caddr_t)&line, p);
+ }
+ /*
+ * Set non-blocking IO if VMIN == VTIME == 0, clear
+ * if not. Should handle the other cases as well.
+ * Note it isn't correct to just turn NBIO off like
+ * we do as it could be on as the result of a fcntl
+ * operation.
+ *
+ * XXX - wouldn't need to do this at all if VMIN/VTIME
+ * were implemented.
+ */
+ {
+ struct hpux_sys_fcntl_args {
+ int fdes, cmd, arg;
+ } args;
+ int flags, nbio;
+
+ nbio = (htios.c_cc[HPUXVMINS] == 0 &&
+ htios.c_cc[HPUXVTIMES] == 0);
+ if (nbio && (fp->f_flag & FNONBLOCK) == 0 ||
+ !nbio && (fp->f_flag & FNONBLOCK)) {
+ args.fdes = fd;
+ args.cmd = F_GETFL;
+ args.arg = 0;
+ (void) hpux_sys_fcntl(p, &args, &flags);
+ if (nbio)
+ flags |= HPUXNDELAY;
+ else
+ flags &= ~HPUXNDELAY;
+ args.cmd = F_SETFL;
+ args.arg = flags;
+ (void) hpux_sys_fcntl(p, &args, &flags);
+ }
+ }
+ }
+ break;
+
+ default:
+ error = EINVAL;
+ break;
+ }
+ return(error);
+}
+
+int
+termiototermios(tio, tios, bsdtios)
+ struct hpux_termio *tio;
+ struct hpux_termios *tios;
+ struct termios *bsdtios;
+{
+ int i;
+
+ bzero((char *)tios, sizeof *tios);
+ tios->c_iflag = tio->c_iflag;
+ tios->c_oflag = tio->c_oflag;
+ tios->c_cflag = tio->c_cflag;
+ tios->c_lflag = tio->c_lflag;
+ tios->c_reserved = tio->c_line;
+ for (i = 0; i <= HPUXVSWTCH; i++)
+ tios->c_cc[i] = tio->c_cc[i];
+ if (tios->c_lflag & TIO_ICANON) {
+ tios->c_cc[HPUXVEOF] = tio->c_cc[HPUXVEOF];
+ tios->c_cc[HPUXVEOL] = tio->c_cc[HPUXVEOL];
+ tios->c_cc[HPUXVMINS] = 0;
+ tios->c_cc[HPUXVTIMES] = 0;
+ } else {
+ tios->c_cc[HPUXVEOF] = 0;
+ tios->c_cc[HPUXVEOL] = 0;
+ tios->c_cc[HPUXVMINS] = tio->c_cc[HPUXVMIN];
+ tios->c_cc[HPUXVTIMES] = tio->c_cc[HPUXVTIME];
+ }
+ tios->c_cc[HPUXVSUSP] = bsdtios->c_cc[VSUSP];
+ tios->c_cc[HPUXVSTART] = bsdtios->c_cc[VSTART];
+ tios->c_cc[HPUXVSTOP] = bsdtios->c_cc[VSTOP];
+}
+
+int
+termiostotermio(tios, tio)
+ struct hpux_termios *tios;
+ struct hpux_termio *tio;
+{
+ int i;
+
+ tio->c_iflag = tios->c_iflag;
+ tio->c_oflag = tios->c_oflag;
+ tio->c_cflag = tios->c_cflag;
+ tio->c_lflag = tios->c_lflag;
+ tio->c_line = tios->c_reserved;
+ for (i = 0; i <= HPUXVSWTCH; i++)
+ tio->c_cc[i] = tios->c_cc[i];
+ if (tios->c_lflag & TIO_ICANON) {
+ tio->c_cc[HPUXVEOF] = tios->c_cc[HPUXVEOF];
+ tio->c_cc[HPUXVEOL] = tios->c_cc[HPUXVEOL];
+ } else {
+ tio->c_cc[HPUXVMIN] = tios->c_cc[HPUXVMINS];
+ tio->c_cc[HPUXVTIME] = tios->c_cc[HPUXVTIMES];
+ }
+}
+
+int
+bsdtohpuxbaud(bsdspeed)
+ long bsdspeed;
+{
+ switch (bsdspeed) {
+ case B0: return(TIO_B0);
+ case B50: return(TIO_B50);
+ case B75: return(TIO_B75);
+ case B110: return(TIO_B110);
+ case B134: return(TIO_B134);
+ case B150: return(TIO_B150);
+ case B200: return(TIO_B200);
+ case B300: return(TIO_B300);
+ case B600: return(TIO_B600);
+ case B1200: return(TIO_B1200);
+ case B1800: return(TIO_B1800);
+ case B2400: return(TIO_B2400);
+ case B4800: return(TIO_B4800);
+ case B9600: return(TIO_B9600);
+ case B19200: return(TIO_B19200);
+ case B38400: return(TIO_B38400);
+ default: return(TIO_B0);
+ }
+}
+
+int
+hpuxtobsdbaud(hpux_speed)
+ int hpux_speed;
+{
+ static char hpuxtobsdbaudtab[32] = {
+ B0, B50, B75, B110, B134, B150, B200, B300,
+ B600, B0, B1200, B1800, B2400, B0, B4800, B0,
+ B9600, B19200, B38400, B0, B0, B0, B0, B0,
+ B0, B0, B0, B0, B0, B0, EXTA, EXTB
+ };
+
+ return(hpuxtobsdbaudtab[hpux_speed & TIO_CBAUD]);
+}
+
+#ifdef COMPAT_HPUX_6X
+
+int
+compat_hpux_6x_sys_gtty(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_hpux_6x_sys_gtty_args *uap = v;
+
+ return (getsettty(p, SCARG(uap, fd), HPUXTIOCGETP, SCARG(uap, arg)));
+}
+
+int
+compat_hpux_6x_sys_stty(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct compat_hpux_6x_sys_stty_args *uap = v;
+
+ return (getsettty(p, SCARG(uap, fd), HPUXTIOCSETP, SCARG(uap, arg)));
+}
+
+/*
+ * Simplified version of ioctl() for use by
+ * gtty/stty and TIOCGETP/TIOCSETP.
+ */
+int
+getsettty(p, fdes, com, cmarg)
+ struct proc *p;
+ int fdes, com;
+ caddr_t cmarg;
+{
+ register struct filedesc *fdp = p->p_fd;
+ register struct file *fp;
+ struct hpux_sgttyb hsb;
+ struct sgttyb sb;
+ int error;
+
+ if (((unsigned)fdes) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fdes]) == NULL)
+ return (EBADF);
+ if ((fp->f_flag & (FREAD|FWRITE)) == 0)
+ return (EBADF);
+ if (com == HPUXTIOCSETP) {
+ if (error = copyin(cmarg, (caddr_t)&hsb, sizeof hsb))
+ return (error);
+ sb.sg_ispeed = hsb.sg_ispeed;
+ sb.sg_ospeed = hsb.sg_ospeed;
+ sb.sg_erase = hsb.sg_erase;
+ sb.sg_kill = hsb.sg_kill;
+ sb.sg_flags = hsb.sg_flags & ~(V7_HUPCL|V7_XTABS|V7_NOAL);
+ if (hsb.sg_flags & V7_XTABS)
+ sb.sg_flags |= XTABS;
+ if (hsb.sg_flags & V7_HUPCL)
+ (void)(*fp->f_ops->fo_ioctl)
+ (fp, TIOCHPCL, (caddr_t)0, p);
+ com = TIOCSETP;
+ } else {
+ bzero((caddr_t)&hsb, sizeof hsb);
+ com = TIOCGETP;
+ }
+ error = (*fp->f_ops->fo_ioctl)(fp, com, (caddr_t)&sb, p);
+ if (error == 0 && com == TIOCGETP) {
+ hsb.sg_ispeed = sb.sg_ispeed;
+ hsb.sg_ospeed = sb.sg_ospeed;
+ hsb.sg_erase = sb.sg_erase;
+ hsb.sg_kill = sb.sg_kill;
+ hsb.sg_flags = sb.sg_flags & ~(V7_HUPCL|V7_XTABS|V7_NOAL);
+ if (sb.sg_flags & XTABS)
+ hsb.sg_flags |= V7_XTABS;
+ error = copyout((caddr_t)&hsb, cmarg, sizeof hsb);
+ }
+ return (error);
+}
+#endif
diff --git a/sys/compat/hpux/hpux_util.h b/sys/compat/hpux/hpux_util.h
new file mode 100644
index 00000000000..bd59abddaac
--- /dev/null
+++ b/sys/compat/hpux/hpux_util.h
@@ -0,0 +1,41 @@
+/* $NetBSD: hpux_util.h,v 1.2 1995/06/24 20:17:57 christos Exp $ */
+
+/*
+ * Copyright (c) 1995 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.
+ */
+
+#ifndef _HPUX_UTIL_H_
+#define _HPUX_UTIL_H_
+
+#include <compat/common/compat_util.h>
+
+#ifdef DEBUG_HPUX
+#define DPRINTF(a) printf a;
+#else
+#define DPRINTF(a)
+#endif
+
+#endif /* !_HPUX_UTIL_H_ */
diff --git a/sys/compat/hpux/syscalls.conf b/sys/compat/hpux/syscalls.conf
new file mode 100644
index 00000000000..27cb8450905
--- /dev/null
+++ b/sys/compat/hpux/syscalls.conf
@@ -0,0 +1,12 @@
+# $NetBSD: syscalls.conf,v 1.1 1995/05/10 16:45:46 christos Exp $
+
+sysnames="hpux_syscalls.c"
+sysnumhdr="hpux_syscall.h"
+syssw="hpux_sysent.c"
+sysarghdr="hpux_syscallargs.h"
+compatopts="compat_hpux_6x"
+libcompatopts=""
+
+switchname="hpux_sysent"
+namesname="hpux_syscallnames"
+constprefix="HPUX_SYS_"
diff --git a/sys/compat/hpux/syscalls.master b/sys/compat/hpux/syscalls.master
new file mode 100644
index 00000000000..aadc7871f9d
--- /dev/null
+++ b/sys/compat/hpux/syscalls.master
@@ -0,0 +1,439 @@
+ $NetBSD: syscalls.master,v 1.8 1995/10/07 06:26:42 mycroft Exp $
+
+; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
+
+; NetBSD COMPAT_HPUX 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
+;
+; 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 <compat/hpux/hpux.h>
+#include <compat/hpux/hpux_syscallargs.h>
+
+0 NOARGS { int sys_nosys(void); } syscall
+1 NOARGS { int sys_exit(int rval); }
+2 STD { int hpux_sys_fork(void); }
+3 STD { int hpux_sys_read(int fd, char *buf, u_int nbyte); }
+4 STD { int hpux_sys_write(int fd, char *buf, u_int nbyte); }
+5 STD { int hpux_sys_open(char *path, int flags, int mode); }
+6 NOARGS { int sys_close(int fd); }
+7 STD { int hpux_sys_wait(int *status); }
+8 STD { int hpux_sys_creat(char *path, int mode); }
+9 NOARGS { int sys_link(char *path, char *link); }
+10 NOARGS { int sys_unlink(char *path); }
+11 STD { int hpux_sys_execv(char * path, char * * argp); }
+12 NOARGS { int sys_chdir(char *path); }
+13 COMPAT_HPUX_6X { int sys_time(time_t *t); }
+14 NOARGS { int sys_mknod(char *path, int mode, int dev); }
+15 NOARGS { int sys_chmod(char *path, int mode); }
+16 NOARGS { int sys_chown(char *path, int uid, int gid); }
+17 NOARGS { int sys_obreak(char *nsize); }
+18 COMPAT_HPUX_6X { int sys_stat(char *path, struct hpux_ostat *sb); }
+19 NOARGS { long compat_43_sys_lseek(int fd, long offset, \
+ int whence); }
+20 NOARGS { pid_t sys_getpid(void); }
+21 UNIMPL mount
+22 UNIMPL umount
+23 NOARGS { int sys_setuid(uid_t uid); }
+24 NOARGS { uid_t sys_getuid(void); }
+25 COMPAT_HPUX_6X { int sys_stime(int time); }
+26 STD { int hpux_sys_ptrace(int req, int pid, int *addr, \
+ int data); }
+27 COMPAT_HPUX_6X { int sys_alarm(int deltat); }
+28 COMPAT_HPUX_6X { int sys_fstat(int fd, struct hpux_ostat *sb); }
+29 COMPAT_HPUX_6X { int sys_pause(void); }
+30 COMPAT_HPUX_6X { int sys_utime(char *fname, time_t *tptr); }
+31 COMPAT_HPUX_6X { int sys_stty(int fd, caddr_t arg); }
+32 COMPAT_HPUX_6X { int sys_gtty(int fd, caddr_t arg); }
+33 NOARGS { int sys_access(char *path, int flags); }
+34 COMPAT_HPUX_6X { int sys_nice(int nval); }
+35 COMPAT_HPUX_6X { int sys_ftime(struct hpux_timeb *tp); }
+36 NOARGS { int sys_sync(void); }
+37 STD { int hpux_sys_kill(pid_t pid, int signo); }
+38 STD { int hpux_sys_stat(char *path, struct hpux_stat *sb); }
+39 COMPAT_HPUX_6X { int sys_setpgrp(void); }
+40 STD { int hpux_sys_lstat(char *path, struct hpux_stat *sb); }
+41 STD { int hpux_sys_dup(int fd); }
+42 NOARGS { int sys_pipe(void); }
+43 COMPAT_HPUX_6X { int sys_times(struct tms *tms); }
+44 NOARGS { int sys_profil(caddr_t samples, u_int size, \
+ u_int offset, u_int scale); }
+
+45 UNIMPL ki_syscall
+46 NOARGS { int sys_setgid(gid_t gid); }
+47 NOARGS { gid_t sys_getgid(void); }
+48 COMPAT_HPUX_6X { int sys_ssig(int signo, sig_t fun); }
+49 UNIMPL reserved for USG
+50 UNIMPL reserved for USG
+51 UNIMPL acct
+52 UNIMPL
+53 UNIMPL
+54 STD { int hpux_sys_ioctl(int fd, int com, caddr_t data); }
+55 UNIMPL reboot
+56 NOARGS { int sys_symlink(char *path, char *link); }
+57 STD { int hpux_sys_utssys(struct hpux_utsname *uts, \
+ int dev, int request); }
+58 NOARGS { int sys_readlink(char *path, char *buf, int count); }
+59 NOARGS { int sys_execve(char *path, char **argp, \
+ char **envp); }
+60 NOARGS { int sys_umask(int newmask); }
+61 NOARGS { int sys_chroot(char *path); }
+62 STD { int hpux_sys_fcntl(int fd, int cmd, int arg); }
+63 STD { int hpux_sys_ulimit(int cmd, int newlimit); }
+64 UNIMPL
+65 UNIMPL
+66 STD { int hpux_sys_vfork(void); }
+67 NOARGS { int hpux_sys_read(int fd, char *buf, u_int nbyte); } vread
+68 NOARGS { int hpux_sys_write(int fd, char *buf, u_int nbyte); } vwrite
+69 UNIMPL
+70 UNIMPL
+71 STD { int hpux_sys_mmap(caddr_t addr, size_t len, \
+ int prot, int flags, int fd, long pos); }
+72 UNIMPL
+73 NOARGS { int sys_munmap(caddr_t addr, size_t len); }
+74 NOARGS { int sys_mprotect(caddr_t addr, size_t len, \
+ int prot); }
+75 UNIMPL
+76 UNIMPL
+77 UNIMPL
+78 UNIMPL
+79 NOARGS { int sys_getgroups(u_int gidsetsize, gid_t *gidset); }
+80 NOARGS { int sys_setgroups(u_int gidsetsize, gid_t *gidset); }
+81 STD { int hpux_sys_getpgrp2(pid_t pid); }
+82 STD { int hpux_sys_setpgrp2(pid_t pid, pid_t pgid); }
+83 NOARGS { int sys_setitimer(u_int which, \
+ struct itimerval *itv, struct itimerval *oitv); }
+84 STD { int hpux_sys_wait3(int *status, int options, \
+ int rusage); }
+85 UNIMPL swapon
+86 NOARGS { int sys_getitimer(u_int which, \
+ struct itimerval *itv); }
+87 UNIMPL
+88 UNIMPL
+89 UNIMPL
+90 NOARGS { int sys_dup2(u_int from, u_int to); }
+91 UNIMPL
+92 STD { int hpux_sys_fstat(int fd, struct hpux_stat *sb); }
+93 NOARGS { int sys_select(u_int nd, fd_set *in, fd_set *ou, \
+ fd_set *ex, struct timeval *tv); }
+94 UNIMPL
+95 NOARGS { int sys_fsync(int fd); }
+96 UNIMPL
+97 UNIMPL
+98 UNIMPL
+99 UNIMPL
+100 UNIMPL
+101 UNIMPL
+102 UNIMPL
+103 NOARGS { int sys_sigreturn(struct sigcontext *sigcntxp); }
+104 UNIMPL
+105 UNIMPL
+106 UNIMPL
+107 UNIMPL
+108 STD { int hpux_sys_sigvec(int signo, struct sigvec *nsv, \
+ struct sigvec *osv); }
+109 STD { int hpux_sys_sigblock(int mask); }
+110 STD { int hpux_sys_sigsetmask(int mask); }
+111 STD { int hpux_sys_sigpause(int mask); }
+112 NOARGS { int compat_43_sys_sigstack(struct sigstack *nss, \
+ struct sigstack *oss); }
+113 UNIMPL
+114 UNIMPL
+115 UNIMPL
+116 NOARGS { int sys_gettimeofday(struct timeval *tp); }
+117 UNIMPL
+118 UNIMPL
+119 UNIMPL io_stub
+120 STD { int hpux_sys_readv(int fd, struct iovec *iovp, \
+ u_int iovcnt); }
+121 STD { int hpux_sys_writev(int fd, struct iovec *iovp, \
+ u_int iovcnt); }
+122 NOARGS { int sys_settimeofday(struct timeval *tv, \
+ struct timezone *tzp); }
+123 NOARGS { int sys_fchown(int fd, int uid, int gid); }
+124 NOARGS { int sys_fchmod(int fd, int mode); }
+125 UNIMPL
+126 STD { int hpux_sys_setresuid(uid_t r, uid_t e, uid_t s); }
+127 STD { int hpux_sys_setresgid(gid_t r, gid_t e, gid_t s); }
+128 NOARGS { int sys_rename(char *from, char *to); }
+129 NOARGS { int compat_43_sys_truncate(char *path, long length); }
+130 NOARGS { int compat_43_sys_ftruncate(int fd, long length); }
+131 UNIMPL
+132 STD { int hpux_sys_sysconf(int name); }
+133 UNIMPL
+134 UNIMPL
+135 UNIMPL
+136 NOARGS { int sys_mkdir(char *path, int mode); }
+137 NOARGS { int sys_rmdir(char *path); }
+138 UNIMPL
+139 UNIMPL
+140 UNIMPL
+141 UNIMPL
+142 UNIMPL
+143 UNIMPL
+144 STD { int hpux_sys_getrlimit(u_int which, \
+ struct ogetrlimit *rlp); }
+145 STD { int hpux_sys_setrlimit(u_int which, \
+ struct ogetrlimit *rlp); }
+146 UNIMPL
+147 UNIMPL
+148 UNIMPL
+149 UNIMPL
+150 UNIMPL
+151 UNIMPL privgrp
+152 STD { int hpux_sys_rtprio(pid_t pid, int prio); }
+153 UNIMPL plock
+154 STD { int hpux_sys_netioctl(int call, int *args); }
+155 STD { int hpux_sys_lockf(int fd, int func, long size); }
+#ifdef SYSVSEM
+156 NOARGS { int sys_semget(key_t key, int nsems, int semflg); }
+157 NOARGS { int sys___semctl(int semid, int semnum, int cmd, \
+ union semun *arg); }
+158 NOARGS { int sys_semop(int semid, struct sembuf *sops, \
+ u_int nsops); }
+#else
+156 UNIMPL semget
+157 UNIMPL semctl
+158 UNIMPL semop
+#endif
+#ifdef SYSVMSG
+159 NOARGS { int sys_msgget(key_t key, int msgflg); }
+160 NOARGS { int sys_msgctl(int msqid, int cmd, \
+ struct msqid_ds *buf); }
+161 NOARGS { int sys_msgsnd(int msqid, void *msgp, size_t msgsz, \
+ int msgflg); }
+162 NOARGS { int sys_msgrcv(int msqid, void *msgp, size_t msgsz, \
+ long msgtyp, int msgflg); }
+#else
+159 UNIMPL msgget
+160 UNIMPL msgctl
+161 UNIMPL msgsnd
+162 UNIMPL msgrcv
+#endif
+#ifdef SYSVSHM
+163 NOARGS { int sys_shmget(key_t key, int size, int shmflg); }
+164 STD { int hpux_sys_shmctl(int shmid, int cmd, \
+ caddr_t buf); }
+165 NOARGS { int sys_shmat(int shmid, void *shmaddr, int shmflg); }
+166 NOARGS { int sys_shmdt(void *shmaddr); }
+#else
+163 UNIMPL shmget
+164 UNIMPL shmctl
+165 UNIMPL shmat
+166 UNIMPL shmdt
+#endif
+167 STD { int hpux_sys_advise(int arg); }
+168 UNIMPL nsp_init
+169 UNIMPL cluster
+170 UNIMPL mkrnod
+171 UNIMPL
+172 UNIMPL unsp_open
+173 UNIMPL
+174 STD { int hpux_sys_getcontext(char *buf, int len); }
+175 UNIMPL
+176 UNIMPL
+177 UNIMPL
+178 UNIMPL lsync
+179 UNIMPL
+180 UNIMPL mysite
+181 UNIMPL sitels
+182 UNIMPL
+183 UNIMPL
+184 UNIMPL dskless_stats
+185 UNIMPL
+186 UNIMPL setacl
+187 UNIMPL fsetacl
+188 UNIMPL getacl
+189 UNIMPL fgetacl
+190 STD { int hpux_sys_getaccess(char *path, uid_t uid, \
+ int ngroups, gid_t *gidset, void *label, \
+ void *privs); }
+191 UNIMPL getaudid
+192 UNIMPL setaudid
+193 UNIMPL getaudproc
+194 UNIMPL setaudproc
+195 UNIMPL getevent
+196 UNIMPL setevent
+197 UNIMPL audwrite
+198 UNIMPL audswitch
+199 UNIMPL audctl
+200 STD { int hpux_sys_waitpid(pid_t pid, int *status, \
+ int options, struct rusage *rusage); }
+201 UNIMPL
+202 UNIMPL
+203 UNIMPL
+204 UNIMPL
+205 UNIMPL
+206 UNIMPL
+207 UNIMPL
+208 UNIMPL
+209 UNIMPL
+210 UNIMPL
+211 UNIMPL
+212 UNIMPL
+213 UNIMPL
+214 UNIMPL
+215 UNIMPL
+216 UNIMPL
+217 UNIMPL
+218 UNIMPL
+219 UNIMPL
+220 UNIMPL
+221 UNIMPL
+222 UNIMPL
+223 UNIMPL
+224 UNIMPL
+225 NOARGS { int sys_pathconf(char *path, int name); }
+226 NOARGS { int sys_fpathconf(int fd, int name); }
+227 UNIMPL
+228 UNIMPL
+229 UNIMPL async_daemon
+230 UNIMPL nfs_fcntl
+231 NOARGS { int compat_43_sys_getdirentries(int fd, char *buf, \
+ u_int count, long *basep); }
+232 NOARGS { int compat_09_sys_getdomainname(char *domainname, \
+ int len); }
+233 UNIMPL nfs_getfh
+234 UNIMPL vfsmount
+235 UNIMPL nfs_svc
+236 NOARGS { int compat_09_sys_setdomainname(char *domainname, \
+ int len); }
+237 UNIMPL statfs
+238 UNIMPL fstatfs
+239 STD { int hpux_sys_sigaction(int signo, \
+ struct hpux_sigaction *nsa, \
+ struct hpux_sigaction *osa); }
+240 STD { int hpux_sys_sigprocmask(int how, \
+ hpux_sigset_t *set, hpux_sigset_t *oset); }
+241 STD { int hpux_sys_sigpending(hpux_sigset_t *set); }
+242 STD { int hpux_sys_sigsuspend(hpux_sigset_t *set); }
+243 UNIMPL fsctl
+244 UNIMPL
+245 UNIMPL pstat
+246 UNIMPL
+247 UNIMPL
+248 UNIMPL
+249 UNIMPL
+250 UNIMPL
+251 UNIMPL
+252 UNIMPL
+253 UNIMPL
+254 UNIMPL
+255 UNIMPL
+256 UNIMPL
+257 UNIMPL
+258 UNIMPL
+259 UNIMPL
+260 UNIMPL
+261 UNIMPL
+262 UNIMPL
+263 UNIMPL
+264 UNIMPL
+265 UNIMPL
+266 UNIMPL
+267 UNIMPL
+268 NOARGS { int compat_43_sys_getdtablesize(void); }
+269 UNIMPL
+270 UNIMPL
+271 UNIMPL
+272 NOARGS { int sys_fchdir(int fd); }
+273 UNIMPL
+274 UNIMPL
+275 NOARGS { int compat_43_sys_accept(int s, caddr_t name, \
+ int *anamelen); }
+276 NOARGS { int sys_bind(int s, caddr_t name, int namelen); }
+277 NOARGS { int sys_connect(int s, caddr_t name, int namelen); }
+278 NOARGS { int compat_43_sys_getpeername(int fdes, caddr_t asa, \
+ int *alen); }
+279 NOARGS { int compat_43_sys_getsockname(int fdec, caddr_t asa, \
+ int *alen); }
+280 NOARGS { int sys_getsockopt(int s, int level, int name, \
+ caddr_t val, int *avalsize); }
+281 NOARGS { int sys_listen(int s, int backlog); }
+282 NOARGS { int compat_43_sys_recv(int s, caddr_t buf, int len, \
+ int flags); }
+283 NOARGS { int compat_43_sys_recvfrom(int s, caddr_t buf, \
+ size_t len, int flags, caddr_t from, \
+ int *fromlenaddr); }
+284 NOARGS { int compat_43_sys_recvmsg(int s, \
+ struct omsghdr *msg, int flags); }
+285 NOARGS { int compat_43_sys_send(int s, caddr_t buf, int len, \
+ int flags); }
+286 NOARGS { int compat_43_sys_sendmsg(int s, caddr_t msg, \
+ int flags); }
+287 NOARGS { int sys_sendto(int s, caddr_t buf, size_t len, \
+ int flags, caddr_t to, int tolen); }
+288 STD { int hpux_sys_setsockopt2(int s, int level, int name, \
+ caddr_t val, int valsize); }
+289 NOARGS { int sys_shutdown(int s, int how); }
+290 NOARGS { int sys_socket(int domain, int type, int protocol); }
+291 NOARGS { int sys_socketpair(int domain, int type, \
+ int protocol, int *rsv); }
+292 UNIMPL
+293 UNIMPL
+294 UNIMPL
+295 UNIMPL
+296 UNIMPL
+297 UNIMPL
+298 UNIMPL
+299 UNIMPL
+300 UNIMPL
+301 UNIMPL
+302 UNIMPL
+303 UNIMPL
+304 UNIMPL
+305 UNIMPL
+306 UNIMPL
+307 UNIMPL
+308 UNIMPL
+309 UNIMPL
+310 UNIMPL
+311 UNIMPL
+#ifdef SYSVSEM
+312 NOARGS { int sys___semctl(int semid, int semnum, int cmd, \
+ union semun *arg); } nsemctl
+#else
+312 UNIMPL semctl
+#endif
+#ifdef SYSVMSG
+313 NOARGS { int sys_msgctl(int msqid, int cmd, \
+ struct msqid_ds *buf); } nmsgctl
+#else
+313 UNIMPL msgctl
+#endif
+#ifdef SYSVSHM
+314 STD { int hpux_sys_nshmctl(int shmid, int cmd, \
+ caddr_t buf); }
+#else
+314 UNIMPL shmctl
+#endif
diff --git a/sys/compat/ibcs2/TODO b/sys/compat/ibcs2/TODO
new file mode 100644
index 00000000000..ddfa3362424
--- /dev/null
+++ b/sys/compat/ibcs2/TODO
@@ -0,0 +1,7 @@
+$NetBSD: TODO,v 1.3 1995/03/14 15:12:17 scottb Exp $
+
+* handle directory reads for filenames > 14 char
+
+* finish implementing ioctl()'s:
+
+ IBCS2_TCSBRK, IBCS2_TCXONC, IBCS2_TCFLSH
diff --git a/sys/compat/ibcs2/files.ibcs2 b/sys/compat/ibcs2/files.ibcs2
new file mode 100644
index 00000000000..3ba153a95be
--- /dev/null
+++ b/sys/compat/ibcs2/files.ibcs2
@@ -0,0 +1,19 @@
+# $NetBSD: files.ibcs2,v 1.3 1995/08/14 01:34:09 mycroft Exp $
+#
+# Config.new file description for machine-independent IBCS-2 compat code.
+# Included by ports that need it.
+
+# ports should define any machine-specific files they need in their
+# own file lists.
+
+file compat/ibcs2/ibcs2_errno.c compat_ibcs2
+file compat/ibcs2/ibcs2_exec.c compat_ibcs2
+file compat/ibcs2/ibcs2_fcntl.c compat_ibcs2
+file compat/ibcs2/ibcs2_ioctl.c compat_ibcs2
+file compat/ibcs2/ibcs2_ipc.c compat_ibcs2
+file compat/ibcs2/ibcs2_misc.c compat_ibcs2
+file compat/ibcs2/ibcs2_signal.c compat_ibcs2
+file compat/ibcs2/ibcs2_socksys.c compat_ibcs2
+file compat/ibcs2/ibcs2_stat.c compat_ibcs2
+file compat/ibcs2/ibcs2_syscalls.c compat_ibcs2
+file compat/ibcs2/ibcs2_sysent.c compat_ibcs2
diff --git a/sys/compat/ibcs2/ibcs2_dirent.h b/sys/compat/ibcs2/ibcs2_dirent.h
new file mode 100644
index 00000000000..a54165732fe
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_dirent.h
@@ -0,0 +1,52 @@
+/* $NetBSD: ibcs2_dirent.h,v 1.3 1995/10/09 11:23:57 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+
+#ifndef _IBCS2_DIRENT_H
+#define _IBCS2_DIRENT_H 1
+
+#include <compat/ibcs2/ibcs2_types.h>
+
+#define IBCS2_MAXNAMLEN 512
+
+struct ibcs2_dirent {
+ ibcs2_ino_t d_ino;
+ short d_pad;
+ ibcs2_off_t d_off;
+ u_short d_reclen;
+ char d_name[IBCS2_MAXNAMLEN + 1];
+};
+
+#define IBCS2_NAMEOFF(dp) ((char *)&(dp)->d_name - (char *)dp)
+#define IBCS2_RECLEN(de,namlen) ALIGN((IBCS2_NAMEOFF(de) + (namlen) + 1))
+
+#endif /* _IBCS2_DIRENT_H */
diff --git a/sys/compat/ibcs2/ibcs2_errno.c b/sys/compat/ibcs2/ibcs2_errno.c
new file mode 100644
index 00000000000..48cb88eb9c1
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_errno.c
@@ -0,0 +1,118 @@
+/*
+ * ibcs2_errno.c
+ * Copyright (c) 1995 Scott Bartram
+ * 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 Scott Bartram.
+ * 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 <compat/ibcs2/ibcs2_errno.h>
+
+int bsd2ibcs_errno[] = {
+ 0, /* 0 */
+ IBCS2_EPERM, /* 1 */
+ IBCS2_ENOENT, /* 2 */
+ IBCS2_ESRCH, /* 3 */
+ IBCS2_EINTR, /* 4 */
+ IBCS2_EIO, /* 5 */
+ IBCS2_ENXIO, /* 6 */
+ IBCS2_E2BIG, /* 7 */
+ IBCS2_ENOEXEC, /* 8 */
+ IBCS2_EBADF, /* 9 */
+ IBCS2_ECHILD, /* 10 */
+ IBCS2_EDEADLK, /* 11 */
+ IBCS2_ENOMEM, /* 12 */
+ IBCS2_EACCES, /* 13 */
+ IBCS2_EFAULT, /* 14 */
+ IBCS2_ENOTBLK, /* 15 */
+ IBCS2_EBUSY, /* 16 */
+ IBCS2_EEXIST, /* 17 */
+ IBCS2_EXDEV, /* 18 */
+ IBCS2_ENODEV, /* 19 */
+ IBCS2_ENOTDIR, /* 20 */
+ IBCS2_EISDIR, /* 21 */
+ IBCS2_EINVAL, /* 22 */
+ IBCS2_ENFILE, /* 23 */
+ IBCS2_EMFILE, /* 24 */
+ IBCS2_ENOTTY, /* 25 */
+ IBCS2_ETXTBSY, /* 26 */
+ IBCS2_EFBIG, /* 27 */
+ IBCS2_ENOSPC, /* 28 */
+ IBCS2_ESPIPE, /* 29 */
+ IBCS2_EROFS, /* 30 */
+ IBCS2_EMLINK, /* 31 */
+ IBCS2_EPIPE, /* 32 */
+ IBCS2_EDOM, /* 33 */
+ IBCS2_ERANGE, /* 34 */
+ IBCS2_EAGAIN, /* 35 */
+ IBCS2_EINPROGRESS, /* 36 */
+ IBCS2_EALREADY, /* 37 */
+ IBCS2_ENOTSOCK, /* 38 */
+ IBCS2_EDESTADDRREQ, /* 39 */
+ IBCS2_EMSGSIZE, /* 40 */
+ IBCS2_EPROTOTYPE, /* 41 */
+ IBCS2_ENOPROTOOPT, /* 42 */
+ IBCS2_EPROTONOSUPPORT, /* 43 */
+ IBCS2_ESOCKTNOSUPPORT, /* 44 */
+ IBCS2_EOPNOTSUPP, /* 45 */
+ IBCS2_EPFNOSUPPORT, /* 46 */
+ IBCS2_EAFNOSUPPORT, /* 47 */
+ IBCS2_EADDRINUSE, /* 48 */
+ IBCS2_EADDRNOTAVAIL, /* 49 */
+ IBCS2_ENETDOWN, /* 50 */
+ IBCS2_ENETUNREACH, /* 51 */
+ IBCS2_ENETRESET, /* 52 */
+ IBCS2_ECONNABORTED, /* 53 */
+ IBCS2_ECONNRESET, /* 54 */
+ IBCS2_ENOBUFS, /* 55 */
+ IBCS2_EISCONN, /* 56 */
+ IBCS2_ENOTCONN, /* 57 */
+ IBCS2_ESHUTDOWN, /* 58 */
+ IBCS2_ETOOMANYREFS, /* 59 */
+ IBCS2_ETIMEDOUT, /* 60 */
+ IBCS2_ECONNREFUSED, /* 61 */
+ IBCS2_ELOOP, /* 62 */
+ IBCS2_ENAMETOOLONG, /* 63 */
+ IBCS2_EHOSTDOWN, /* 64 */
+ IBCS2_EHOSTUNREACH, /* 65 */
+ IBCS2_ENOTEMPTY, /* 66 */
+ 0, /* 67 */
+ 0, /* 68 */
+ 0, /* 69 */
+ IBCS2_ESTALE, /* 70 */
+ IBCS2_EREMOTE, /* 71 */
+ 0, /* 72 */
+ 0, /* 73 */
+ 0, /* 74 */
+ 0, /* 75 */
+ 0, /* 76 */
+ IBCS2_ENOLCK, /* 77 */
+ IBCS2_ENOSYS, /* 78 */
+ 0, /* 79 */
+ 0, /* 80 */
+ 0, /* 81 */
+};
+
diff --git a/sys/compat/ibcs2/ibcs2_errno.h b/sys/compat/ibcs2/ibcs2_errno.h
new file mode 100644
index 00000000000..30ed8241ae2
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_errno.h
@@ -0,0 +1,153 @@
+/*
+ * ibcs2_errno.h
+ * Copyright (c) 1995 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_ERRNO_H
+#define _IBCS2_ERRNO_H
+
+#define _SCO_NET 1
+
+#define IBCS2_EPERM 1
+#define IBCS2_ENOENT 2
+#define IBCS2_ESRCH 3
+#define IBCS2_EINTR 4
+#define IBCS2_EIO 5
+#define IBCS2_ENXIO 6
+#define IBCS2_E2BIG 7
+#define IBCS2_ENOEXEC 8
+#define IBCS2_EBADF 9
+#define IBCS2_ECHILD 10
+#define IBCS2_EAGAIN 11
+#define IBCS2_ENOMEM 12
+#define IBCS2_EACCES 13
+#define IBCS2_EFAULT 14
+#define IBCS2_ENOTBLK 15
+#define IBCS2_EBUSY 16
+#define IBCS2_EEXIST 17
+#define IBCS2_EXDEV 18
+#define IBCS2_ENODEV 19
+#define IBCS2_ENOTDIR 20
+#define IBCS2_EISDIR 21
+#define IBCS2_EINVAL 22
+#define IBCS2_ENFILE 23
+#define IBCS2_EMFILE 24
+#define IBCS2_ENOTTY 25
+#define IBCS2_ETXTBSY 26
+#define IBCS2_EFBIG 27
+#define IBCS2_ENOSPC 28
+#define IBCS2_ESPIPE 29
+#define IBCS2_EROFS 30
+#define IBCS2_EMLINK 31
+#define IBCS2_EPIPE 32
+#define IBCS2_EDOM 33
+#define IBCS2_ERANGE 34
+#define IBCS2_ENOMSG 35
+#define IBCS2_EIDRM 36
+#define IBCS2_ECHRNG 37
+#define IBCS2_EL2NSYNC 38
+#define IBCS2_EL3HLT 39
+#define IBCS2_EL3RST 40
+#define IBCS2_ELNRNG 41
+#define IBCS2_EUNATCH 42
+#define IBCS2_ENOCSI 43
+#define IBCS2_EL2HLT 44
+#define IBCS2_EDEADLK 45
+#define IBCS2_ENOLCK 46
+#define IBCS2_ENOSTR 60
+#define IBCS2_ENODATA 61
+#define IBCS2_ETIME 62
+#define IBCS2_ENOSR 63
+#define IBCS2_ENONET 64
+#define IBCS2_ENOPKG 65
+#define IBCS2_EREMOTE 66
+#define IBCS2_ENOLINK 67
+#define IBCS2_EADV 68
+#define IBCS2_ESRMNT 69
+#define IBCS2_ECOMM 70
+#define IBCS2_EPROTO 71
+#define IBCS2_EMULTIHOP 74
+#define IBCS2_ELBIN 75
+#define IBCS2_EDOTDOT 76
+#define IBCS2_EBADMSG 77
+#define IBCS2_ENAMETOOLONG 78
+#define IBCS2_EOVERFLOW 79
+#define IBCS2_ENOTUNIQ 80
+#define IBCS2_EBADFD 81
+#define IBCS2_EREMCHG 82
+#define IBCS2_EILSEQ 88
+#define IBCS2_ENOSYS 89
+
+#if defined(_SCO_NET) /* not strict iBCS2 */
+#define IBCS2_EWOULDBLOCK 90
+#define IBCS2_EINPROGRESS 91
+#define IBCS2_EALREADY 92
+#define IBCS2_ENOTSOCK 93
+#define IBCS2_EDESTADDRREQ 94
+#define IBCS2_EMSGSIZE 95
+#define IBCS2_EPROTOTYPE 96
+#define IBCS2_EPROTONOSUPPORT 97
+#define IBCS2_ESOCKTNOSUPPORT 98
+#define IBCS2_EOPNOTSUPP 99
+#define IBCS2_EPFNOSUPPORT 100
+#define IBCS2_EAFNOSUPPORT 101
+#define IBCS2_EADDRINUSE 102
+#define IBCS2_EADDRNOTAVAIL 103
+#define IBCS2_ENETDOWN 104
+#define IBCS2_ENETUNREACH 105
+#define IBCS2_ENETRESET 106
+#define IBCS2_ECONNABORTED 107
+#define IBCS2_ECONNRESET 108
+#define IBCS2_ENOBUFS IBCS2_ENOSR
+#define IBCS2_EISCONN 110
+#define IBCS2_ENOTCONN 111
+#define IBCS2_ESHUTDOWN 112
+#define IBCS2_ETOOMANYREFS 113
+#define IBCS2_ETIMEDOUT 114
+#define IBCS2_ECONNREFUSED 115
+#define IBCS2_EHOSTDOWN 116
+#define IBCS2_EHOSTUNREACH 117
+#define IBCS2_ENOPROTOOPT 118
+#define IBCS2_ENOTEMPTY 145
+#define IBCS2_ELOOP 150
+#else
+#define IBCS2_ELOOP 90
+#define IBCS2_EWOULDBLOCK 90
+#define IBCS2_ERESTART 91
+#define IBCS2_ESTRPIPE 92
+#define IBCS2_ENOTEMPTY 93
+#define IBCS2_EUSERS 94
+#endif
+
+#define IBCS2_ESTALE 151
+#define IBCS2_EIORESID 500
+
+extern int bsd2ibcs_errno[];
+
+#endif /* _IBCS2_ERRNO_H */
diff --git a/sys/compat/ibcs2/ibcs2_exec.c b/sys/compat/ibcs2/ibcs2_exec.c
new file mode 100644
index 00000000000..1e69c9d6101
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_exec.c
@@ -0,0 +1,728 @@
+/* $NetBSD: ibcs2_exec.c,v 1.10 1995/06/24 20:18:55 christos Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Scott Bartram
+ * Copyright (c) 1994 Adam Glass
+ * Copyright (c) 1993, 1994 Christopher G. Demetriou
+ * All rights reserved.
+ *
+ * originally from kern/exec_ecoff.c
+ *
+ * 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 Scott Bartram.
+ * 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/param.h>
+#include <sys/systm.h>
+#include <sys/proc.h>
+#include <sys/malloc.h>
+#include <sys/vnode.h>
+#include <sys/resourcevar.h>
+#include <sys/namei.h>
+#include <vm/vm.h>
+
+#include <compat/ibcs2/ibcs2_types.h>
+#include <compat/ibcs2/ibcs2_exec.h>
+#include <compat/ibcs2/ibcs2_util.h>
+#include <compat/ibcs2/ibcs2_syscall.h>
+
+int exec_ibcs2_coff_prep_omagic __P((struct proc *, struct exec_package *,
+ struct coff_filehdr *,
+ struct coff_aouthdr *));
+int exec_ibcs2_coff_prep_nmagic __P((struct proc *, struct exec_package *,
+ struct coff_filehdr *,
+ struct coff_aouthdr *));
+int exec_ibcs2_coff_prep_zmagic __P((struct proc *, struct exec_package *,
+ struct coff_filehdr *,
+ struct coff_aouthdr *));
+int exec_ibcs2_coff_setup_stack __P((struct proc *, struct exec_package *));
+void cpu_exec_ibcs2_coff_setup __P((int, struct proc *, struct exec_package *,
+ void *));
+
+int exec_ibcs2_xout_prep_nmagic __P((struct proc *, struct exec_package *,
+ struct xexec *, struct xext *));
+int exec_ibcs2_xout_prep_zmagic __P((struct proc *, struct exec_package *,
+ struct xexec *, struct xext *));
+int exec_ibcs2_xout_setup_stack __P((struct proc *, struct exec_package *));
+int coff_load_shlib __P((struct proc *, char *, struct exec_package *));
+
+extern int bsd2ibcs_errno[];
+extern struct sysent ibcs2_sysent[];
+extern char *ibcs2_syscallnames[];
+extern void ibcs2_sendsig __P((sig_t, int, int, u_long));
+extern char sigcode[], esigcode[];
+
+const char ibcs2_emul_path[] = "/emul/ibcs2";
+
+struct emul emul_ibcs2 = {
+ "ibcs2",
+ bsd2ibcs_errno,
+ ibcs2_sendsig,
+ 0,
+ IBCS2_SYS_MAXSYSCALL,
+ ibcs2_sysent,
+ ibcs2_syscallnames,
+ 0,
+ copyargs,
+ setregs,
+ sigcode,
+ esigcode,
+};
+
+/*
+ * exec_ibcs2_coff_makecmds(): Check if it's an coff-format executable.
+ *
+ * Given a proc pointer and an exec package pointer, see if the referent
+ * of the epp is in coff format. Check 'standard' magic numbers for
+ * this architecture. If that fails, return failure.
+ *
+ * This function is responsible for creating a set of vmcmds which can be
+ * used to build the process's vm space and inserting them into the exec
+ * package.
+ */
+
+int
+exec_ibcs2_coff_makecmds(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ u_long midmag, magic;
+ u_short mid;
+ int error;
+ struct coff_filehdr *fp = epp->ep_hdr;
+ struct coff_aouthdr *ap;
+
+ if (epp->ep_hdrvalid < COFF_HDR_SIZE)
+ return ENOEXEC;
+
+ if (COFF_BADMAG(fp))
+ return ENOEXEC;
+
+ ap = epp->ep_hdr + sizeof(struct coff_filehdr);
+ switch (ap->a_magic) {
+ case COFF_OMAGIC:
+ error = exec_ibcs2_coff_prep_omagic(p, epp, fp, ap);
+ break;
+ case COFF_NMAGIC:
+ error = exec_ibcs2_coff_prep_nmagic(p, epp, fp, ap);
+ break;
+ case COFF_ZMAGIC:
+ error = exec_ibcs2_coff_prep_zmagic(p, epp, fp, ap);
+ break;
+ default:
+ return ENOEXEC;
+ }
+
+ if (error == 0)
+ epp->ep_emul = &emul_ibcs2;
+
+ if (error)
+ kill_vmcmds(&epp->ep_vmcmds);
+
+bad:
+ return error;
+}
+
+/*
+ * exec_ibcs2_coff_setup_stack(): Set up the stack segment for a coff
+ * executable.
+ *
+ * Note that the ep_ssize parameter must be set to be the current stack
+ * limit; this is adjusted in the body of execve() to yield the
+ * appropriate stack segment usage once the argument length is
+ * calculated.
+ *
+ * This function returns an int for uniformity with other (future) formats'
+ * stack setup functions. They might have errors to return.
+ */
+
+int
+exec_ibcs2_coff_setup_stack(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ /* DPRINTF(("enter exec_ibcs2_coff_setup_stack\n")); */
+
+ epp->ep_maxsaddr = USRSTACK - MAXSSIZ;
+ epp->ep_minsaddr = USRSTACK;
+ epp->ep_ssize = p->p_rlimit[RLIMIT_STACK].rlim_cur;
+
+ /*
+ * set up commands for stack. note that this takes *two*, one to
+ * map the part of the stack which we can access, and one to map
+ * the part which we can't.
+ *
+ * arguably, it could be made into one, but that would require the
+ * addition of another mapping proc, which is unnecessary
+ *
+ * note that in memory, things assumed to be: 0 ....... ep_maxsaddr
+ * <stack> ep_minsaddr
+ */
+ /* DPRINTF(("VMCMD: addr %x size %d\n", epp->ep_maxsaddr,
+ (epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr)); */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero,
+ ((epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr),
+ epp->ep_maxsaddr, NULLVP, 0, VM_PROT_NONE);
+ /* DPRINTF(("VMCMD: addr %x size %d\n",
+ epp->ep_minsaddr - epp->ep_ssize,
+ epp->ep_ssize)); */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, epp->ep_ssize,
+ (epp->ep_minsaddr - epp->ep_ssize), NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ return 0;
+}
+
+
+/*
+ * exec_ibcs2_coff_prep_omagic(): Prepare a COFF OMAGIC binary's exec package
+ */
+
+int
+exec_ibcs2_coff_prep_omagic(p, epp, fp, ap)
+ struct proc *p;
+ struct exec_package *epp;
+ struct coff_filehdr *fp;
+ struct coff_aouthdr *ap;
+{
+ epp->ep_taddr = COFF_SEGMENT_ALIGN(ap, ap->a_tstart);
+ epp->ep_tsize = ap->a_tsize;
+ epp->ep_daddr = COFF_SEGMENT_ALIGN(ap, ap->a_dstart);
+ epp->ep_dsize = ap->a_dsize;
+ epp->ep_entry = ap->a_entry;
+
+ /* set up command for text and data segments */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
+ ap->a_tsize + ap->a_dsize, epp->ep_taddr, epp->ep_vp,
+ COFF_TXTOFF(fp, ap),
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ /* set up command for bss segment */
+ if (ap->a_bsize > 0)
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, ap->a_bsize,
+ COFF_SEGMENT_ALIGN(ap, ap->a_dstart + ap->a_dsize),
+ NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ return exec_ibcs2_coff_setup_stack(p, epp);
+}
+
+/*
+ * exec_ibcs2_coff_prep_nmagic(): Prepare a 'native' NMAGIC COFF binary's exec
+ * package.
+ */
+
+int
+exec_ibcs2_coff_prep_nmagic(p, epp, fp, ap)
+ struct proc *p;
+ struct exec_package *epp;
+ struct coff_filehdr *fp;
+ struct coff_aouthdr *ap;
+{
+ epp->ep_taddr = COFF_SEGMENT_ALIGN(ap, ap->a_tstart);
+ epp->ep_tsize = ap->a_tsize;
+ epp->ep_daddr = COFF_ROUND(ap->a_dstart, COFF_LDPGSZ);
+ epp->ep_dsize = ap->a_dsize;
+ epp->ep_entry = ap->a_entry;
+
+ /* set up command for text segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, epp->ep_tsize,
+ epp->ep_taddr, epp->ep_vp, COFF_TXTOFF(fp, ap),
+ VM_PROT_READ|VM_PROT_EXECUTE);
+
+ /* set up command for data segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, epp->ep_dsize,
+ epp->ep_daddr, epp->ep_vp, COFF_DATOFF(fp, ap),
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ /* set up command for bss segment */
+ if (ap->a_bsize > 0)
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, ap->a_bsize,
+ COFF_SEGMENT_ALIGN(ap, ap->a_dstart + ap->a_dsize),
+ NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ return exec_ibcs2_coff_setup_stack(p, epp);
+}
+
+/*
+ * coff_find_section - load specified section header
+ *
+ * TODO - optimize by reading all section headers in at once
+ */
+
+static int
+coff_find_section(p, vp, fp, sh, s_type)
+ struct proc *p;
+ struct vnode *vp;
+ struct coff_filehdr *fp;
+ struct coff_scnhdr *sh;
+ int s_type;
+{
+ int i, pos, resid, siz, error;
+
+ pos = COFF_HDR_SIZE;
+ for (i = 0; i < fp->f_nscns; i++, pos += sizeof(struct coff_scnhdr)) {
+ siz = sizeof(struct coff_scnhdr);
+ if (error = vn_rdwr(UIO_READ, vp, (caddr_t) sh,
+ siz, pos,
+ UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred,
+ &resid, p)) {
+ DPRINTF(("section hdr %d read error %d\n", i, error));
+ return error;
+ }
+ siz -= resid;
+ if (siz != sizeof(struct coff_scnhdr)) {
+ DPRINTF(("incomplete read: hdr %d ask=%d, rem=%d got %d\n",
+ s_type, sizeof(struct coff_scnhdr),
+ resid, siz));
+ return ENOEXEC;
+ }
+ /* DPRINTF(("found section: %x\n", sh->s_flags)); */
+ if (sh->s_flags == s_type)
+ return 0;
+ }
+ return ENOEXEC;
+}
+
+/*
+ * exec_ibcs2_coff_prep_zmagic(): Prepare a COFF ZMAGIC binary's exec package
+ *
+ * First, set the various offsets/lengths in the exec package.
+ *
+ * Then, mark the text image busy (so it can be demand paged) or error
+ * out if this is not possible. Finally, set up vmcmds for the
+ * text, data, bss, and stack segments.
+ */
+
+int
+exec_ibcs2_coff_prep_zmagic(p, epp, fp, ap)
+ struct proc *p;
+ struct exec_package *epp;
+ struct coff_filehdr *fp;
+ struct coff_aouthdr *ap;
+{
+ int error;
+ u_long offset;
+ long dsize, baddr, bsize;
+ struct coff_scnhdr sh;
+
+ /* DPRINTF(("enter exec_ibcs2_coff_prep_zmagic\n")); */
+
+ /* set up command for text segment */
+ error = coff_find_section(p, epp->ep_vp, fp, &sh, COFF_STYP_TEXT);
+ if (error) {
+ DPRINTF(("can't find text section: %d\n", error));
+ return error;
+ }
+ /* DPRINTF(("COFF text addr %x size %d offset %d\n", sh.s_vaddr,
+ sh.s_size, sh.s_scnptr)); */
+ epp->ep_taddr = COFF_ALIGN(sh.s_vaddr);
+ offset = sh.s_scnptr - (sh.s_vaddr - epp->ep_taddr);
+ epp->ep_tsize = sh.s_size + (sh.s_vaddr - epp->ep_taddr);
+
+#ifdef notyet
+ /*
+ * check if vnode is in open for writing, because we want to
+ * demand-page out of it. if it is, don't do it, for various
+ * reasons
+n */
+ if ((ap->a_tsize != 0 || ap->a_dsize != 0) &&
+ epp->ep_vp->v_writecount != 0) {
+#ifdef DIAGNOSTIC
+ if (epp->ep_vp->v_flag & VTEXT)
+ panic("exec: a VTEXT vnode has writecount != 0\n");
+#endif
+ return ETXTBSY;
+ }
+ epp->ep_vp->v_flag |= VTEXT;
+#endif
+
+ /* DPRINTF(("VMCMD: addr %x size %d offset %d\n", epp->ep_taddr,
+ epp->ep_tsize, offset)); */
+#ifdef notyet
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, epp->ep_tsize,
+ epp->ep_taddr, epp->ep_vp, offset,
+ VM_PROT_READ|VM_PROT_EXECUTE);
+#else
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, epp->ep_tsize,
+ epp->ep_taddr, epp->ep_vp, offset,
+ VM_PROT_READ|VM_PROT_EXECUTE);
+#endif
+
+ /* set up command for data segment */
+ error = coff_find_section(p, epp->ep_vp, fp, &sh, COFF_STYP_DATA);
+ if (error) {
+ DPRINTF(("can't find data section: %d\n", error));
+ return error;
+ }
+ /* DPRINTF(("COFF data addr %x size %d offset %d\n", sh.s_vaddr,
+ sh.s_size, sh.s_scnptr)); */
+ epp->ep_daddr = COFF_ALIGN(sh.s_vaddr);
+ offset = sh.s_scnptr - (sh.s_vaddr - epp->ep_daddr);
+ dsize = sh.s_size + (sh.s_vaddr - epp->ep_daddr);
+ epp->ep_dsize = dsize + ap->a_bsize;
+
+ /* DPRINTF(("VMCMD: addr %x size %d offset %d\n", epp->ep_daddr,
+ dsize, offset)); */
+#ifdef notyet
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, dsize,
+ epp->ep_daddr, epp->ep_vp, offset,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+#else
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
+ dsize, epp->ep_daddr, epp->ep_vp, offset,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+#endif
+
+ /* set up command for bss segment */
+ baddr = round_page(epp->ep_daddr + dsize);
+ bsize = epp->ep_daddr + epp->ep_dsize - baddr;
+ if (bsize > 0) {
+ /* DPRINTF(("VMCMD: addr %x size %d offset %d\n",
+ baddr, bsize, 0)); */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero,
+ bsize, baddr, NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+ }
+
+ /* load any shared libraries */
+ error = coff_find_section(p, epp->ep_vp, fp, &sh, COFF_STYP_SHLIB);
+ if (!error) {
+ int resid;
+ struct coff_slhdr *slhdr;
+ char buf[128], *bufp; /* FIXME */
+ int len = sh.s_size, path_index, entry_len;
+
+ /* DPRINTF(("COFF shlib size %d offset %d\n",
+ sh.s_size, sh.s_scnptr)); */
+
+ error = vn_rdwr(UIO_READ, epp->ep_vp, (caddr_t) buf,
+ len, sh.s_scnptr,
+ UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred,
+ &resid, p);
+ if (error) {
+ DPRINTF(("shlib section read error %d\n", error));
+ return ENOEXEC;
+ }
+ bufp = buf;
+ while (len) {
+ slhdr = (struct coff_slhdr *)bufp;
+ path_index = slhdr->path_index * sizeof(long);
+ entry_len = slhdr->entry_len * sizeof(long);
+
+ /* DPRINTF(("path_index: %d entry_len: %d name: %s\n",
+ path_index, entry_len, slhdr->sl_name)); */
+
+ error = coff_load_shlib(p, slhdr->sl_name, epp);
+ if (error)
+ return ENOEXEC;
+ bufp += entry_len;
+ len -= entry_len;
+ }
+ }
+
+ /* set up entry point */
+ epp->ep_entry = ap->a_entry;
+
+#if 0
+ DPRINTF(("text addr: %x size: %d data addr: %x size: %d entry: %x\n",
+ epp->ep_taddr, epp->ep_tsize,
+ epp->ep_daddr, epp->ep_dsize,
+ epp->ep_entry));
+#endif
+
+ return exec_ibcs2_coff_setup_stack(p, epp);
+}
+
+int
+coff_load_shlib(p, path, epp)
+ struct proc *p;
+ char *path;
+ struct exec_package *epp;
+{
+ int error, siz, resid;
+ int taddr, tsize, daddr, dsize, offset;
+ struct nameidata nd;
+ struct coff_filehdr fh, *fhp = &fh;
+ struct coff_scnhdr sh, *shp = &sh;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ /*
+ * 1. open shlib file
+ * 2. read filehdr
+ * 3. map text, data, and bss out of it using VM_*
+ */
+ IBCS2_CHECK_ALT_EXIST(p, &sg, path);
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, p);
+ /* first get the vnode */
+ if (error = namei(&nd)) {
+ DPRINTF(("coff_load_shlib: can't find library %s\n", path));
+ return error;
+ }
+
+ siz = sizeof(struct coff_filehdr);
+ if (error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t) fhp, siz, 0,
+ UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred,
+ &resid, p)) {
+ DPRINTF(("filehdr read error %d\n", error));
+ vrele(nd.ni_vp);
+ return error;
+ }
+ siz -= resid;
+ if (siz != sizeof(struct coff_filehdr)) {
+ DPRINTF(("coff_load_shlib: incomplete read: ask=%d, rem=%d got %d\n",
+ sizeof(struct coff_filehdr), resid, siz));
+ vrele(nd.ni_vp);
+ return ENOEXEC;
+ }
+
+ /* load text */
+ error = coff_find_section(p, nd.ni_vp, fhp, shp, COFF_STYP_TEXT);
+ if (error) {
+ DPRINTF(("can't find shlib text section\n"));
+ vrele(nd.ni_vp);
+ return error;
+ }
+ /* DPRINTF(("COFF text addr %x size %d offset %d\n", sh.s_vaddr,
+ sh.s_size, sh.s_scnptr)); */
+ taddr = COFF_ALIGN(shp->s_vaddr);
+ offset = shp->s_scnptr - (shp->s_vaddr - taddr);
+ tsize = shp->s_size + (shp->s_vaddr - taddr);
+ /* DPRINTF(("VMCMD: addr %x size %d offset %d\n", taddr, tsize, offset)); */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, tsize, taddr,
+ nd.ni_vp, offset,
+ VM_PROT_READ|VM_PROT_EXECUTE);
+
+ /* load data */
+ error = coff_find_section(p, nd.ni_vp, fhp, shp, COFF_STYP_DATA);
+ if (error) {
+ DPRINTF(("can't find shlib data section\n"));
+ vrele(nd.ni_vp);
+ return error;
+ }
+ /* DPRINTF(("COFF data addr %x size %d offset %d\n", shp->s_vaddr,
+ shp->s_size, shp->s_scnptr)); */
+ daddr = COFF_ALIGN(shp->s_vaddr);
+ offset = shp->s_scnptr - (shp->s_vaddr - daddr);
+ dsize = shp->s_size + (shp->s_vaddr - daddr);
+ /* epp->ep_dsize = dsize + ap->a_bsize; */
+
+ /* DPRINTF(("VMCMD: addr %x size %d offset %d\n", daddr, dsize, offset)); */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
+ dsize, daddr, nd.ni_vp, offset,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ /* load bss */
+ error = coff_find_section(p, nd.ni_vp, fhp, shp, COFF_STYP_BSS);
+ if (!error) {
+ int baddr = round_page(daddr + dsize);
+ int bsize = daddr + dsize + shp->s_size - baddr;
+ if (bsize > 0) {
+ /* DPRINTF(("VMCMD: addr %x size %d offset %d\n",
+ baddr, bsize, 0)); */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero,
+ bsize, baddr, NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+ }
+ }
+ vrele(nd.ni_vp);
+
+ return 0;
+}
+
+int
+exec_ibcs2_xout_makecmds(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ u_long midmag, magic;
+ u_short mid;
+ int error;
+ struct xexec *xp = epp->ep_hdr;
+ struct xext *xep;
+
+ if (epp->ep_hdrvalid < XOUT_HDR_SIZE)
+ return ENOEXEC;
+
+ if ((xp->x_magic != XOUT_MAGIC) || (xp->x_cpu != XC_386))
+ return ENOEXEC;
+ if ((xp->x_renv & (XE_ABS | XE_VMOD)) || !(xp->x_renv & XE_EXEC))
+ return ENOEXEC;
+
+ xep = epp->ep_hdr + sizeof(struct xexec);
+#ifdef notyet
+ if (xp->x_renv & XE_PURE)
+ error = exec_ibcs2_xout_prep_zmagic(p, epp, xp, xep);
+ else
+#endif
+ error = exec_ibcs2_xout_prep_nmagic(p, epp, xp, xep);
+
+ if (error == 0)
+ epp->ep_emul = &emul_ibcs2;
+
+ if (error)
+ kill_vmcmds(&epp->ep_vmcmds);
+
+ return error;
+}
+
+/*
+ * exec_ibcs2_xout_prep_nmagic(): Prepare a pure x.out binary's exec package
+ *
+ */
+
+int
+exec_ibcs2_xout_prep_nmagic(p, epp, xp, xep)
+ struct proc *p;
+ struct exec_package *epp;
+ struct xexec *xp;
+ struct xext *xep;
+{
+ int error, resid, nseg, i;
+ long baddr, bsize;
+ struct xseg *xs;
+
+ /* read in segment table */
+ xs = (struct xseg *)malloc(xep->xe_segsize, M_TEMP, M_WAITOK);
+ error = vn_rdwr(UIO_READ, epp->ep_vp, (caddr_t)xs,
+ xep->xe_segsize, xep->xe_segpos,
+ UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred,
+ &resid, p);
+ if (error) {
+ DPRINTF(("segment table read error %d\n", error));
+ free(xs, M_TEMP);
+ return ENOEXEC;
+ }
+
+ for (nseg = xep->xe_segsize / sizeof(*xs), i = 0; i < nseg; i++) {
+ switch (xs[i].xs_type) {
+ case XS_TTEXT: /* text segment */
+
+ DPRINTF(("text addr %x psize %d vsize %d off %d\n",
+ xs[i].xs_rbase, xs[i].xs_psize,
+ xs[i].xs_vsize, xs[i].xs_filpos));
+
+ epp->ep_taddr = xs[i].xs_rbase; /* XXX - align ??? */
+ epp->ep_tsize = xs[i].xs_vsize;
+
+ DPRINTF(("VMCMD: addr %x size %d offset %d\n",
+ epp->ep_taddr, epp->ep_tsize,
+ xs[i].xs_filpos));
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
+ epp->ep_tsize, epp->ep_taddr,
+ epp->ep_vp, xs[i].xs_filpos,
+ VM_PROT_READ|VM_PROT_EXECUTE);
+ break;
+
+ case XS_TDATA: /* data segment */
+
+ DPRINTF(("data addr %x psize %d vsize %d off %d\n",
+ xs[i].xs_rbase, xs[i].xs_psize,
+ xs[i].xs_vsize, xs[i].xs_filpos));
+
+ epp->ep_daddr = xs[i].xs_rbase; /* XXX - align ??? */
+ epp->ep_dsize = xs[i].xs_vsize;
+
+ DPRINTF(("VMCMD: addr %x size %d offset %d\n",
+ epp->ep_daddr, xs[i].xs_psize,
+ xs[i].xs_filpos));
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
+ xs[i].xs_psize, epp->ep_daddr,
+ epp->ep_vp, xs[i].xs_filpos,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ /* set up command for bss segment */
+ baddr = round_page(epp->ep_daddr + xs[i].xs_psize);
+ bsize = epp->ep_daddr + epp->ep_dsize - baddr;
+ if (bsize > 0) {
+ DPRINTF(("VMCMD: bss addr %x size %d off %d\n",
+ baddr, bsize, 0));
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero,
+ bsize, baddr, NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|
+ VM_PROT_EXECUTE);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ /* set up entry point */
+ epp->ep_entry = xp->x_entry;
+
+ DPRINTF(("text addr: %x size: %d data addr: %x size: %d entry: %x\n",
+ epp->ep_taddr, epp->ep_tsize,
+ epp->ep_daddr, epp->ep_dsize,
+ epp->ep_entry));
+
+ free(xs, M_TEMP);
+ return exec_ibcs2_xout_setup_stack(p, epp);
+}
+
+/*
+ * exec_ibcs2_xout_setup_stack(): Set up the stack segment for a x.out
+ * executable.
+ *
+ * Note that the ep_ssize parameter must be set to be the current stack
+ * limit; this is adjusted in the body of execve() to yield the
+ * appropriate stack segment usage once the argument length is
+ * calculated.
+ *
+ * This function returns an int for uniformity with other (future) formats'
+ * stack setup functions. They might have errors to return.
+ */
+
+int
+exec_ibcs2_xout_setup_stack(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ epp->ep_maxsaddr = USRSTACK - MAXSSIZ;
+ epp->ep_minsaddr = USRSTACK;
+ epp->ep_ssize = p->p_rlimit[RLIMIT_STACK].rlim_cur;
+
+ /*
+ * set up commands for stack. note that this takes *two*, one to
+ * map the part of the stack which we can access, and one to map
+ * the part which we can't.
+ *
+ * arguably, it could be made into one, but that would require the
+ * addition of another mapping proc, which is unnecessary
+ *
+ * note that in memory, things assumed to be: 0 ....... ep_maxsaddr
+ * <stack> ep_minsaddr
+ */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero,
+ ((epp->ep_minsaddr - epp->ep_ssize) - epp->ep_maxsaddr),
+ epp->ep_maxsaddr, NULLVP, 0, VM_PROT_NONE);
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, epp->ep_ssize,
+ (epp->ep_minsaddr - epp->ep_ssize), NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ return 0;
+}
diff --git a/sys/compat/ibcs2/ibcs2_exec.h b/sys/compat/ibcs2/ibcs2_exec.h
new file mode 100644
index 00000000000..8af9491b77f
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_exec.h
@@ -0,0 +1,285 @@
+/* $NetBSD: ibcs2_exec.h,v 1.4 1995/03/14 15:12:24 scottb Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Scott Bartram
+ * All rights reserved.
+ *
+ * adapted from sys/sys/exec_ecoff.h
+ * based on Intel iBCS2
+ *
+ * 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.
+ */
+
+#ifndef _IBCS2_EXEC_H_
+#define _IBCS2_EXEC_H_
+
+/*
+ * COFF file header
+ */
+
+struct coff_filehdr {
+ u_short f_magic; /* magic number */
+ u_short f_nscns; /* # of sections */
+ long f_timdat; /* timestamp */
+ long f_symptr; /* file offset of symbol table */
+ long f_nsyms; /* # of symbol table entries */
+ u_short f_opthdr; /* size of optional header */
+ u_short f_flags; /* flags */
+};
+
+/* f_magic flags */
+#define COFF_MAGIC_I386 0x14c
+
+/* f_flags */
+#define COFF_F_RELFLG 0x1
+#define COFF_F_EXEC 0x2
+#define COFF_F_LNNO 0x4
+#define COFF_F_LSYMS 0x8
+#define COFF_F_SWABD 0x40
+#define COFF_F_AR16WR 0x80
+#define COFF_F_AR32WR 0x100
+
+/*
+ * COFF system header
+ */
+
+struct coff_aouthdr {
+ short a_magic;
+ short a_vstamp;
+ long a_tsize;
+ long a_dsize;
+ long a_bsize;
+ long a_entry;
+ long a_tstart;
+ long a_dstart;
+};
+
+/* magic */
+#define COFF_OMAGIC 0407 /* text not write-protected; data seg
+ is contiguous with text */
+#define COFF_NMAGIC 0410 /* text is write-protected; data starts
+ at next seg following text */
+#define COFF_ZMAGIC 0413 /* text and data segs are aligned for
+ direct paging */
+#define COFF_SMAGIC 0443 /* shared lib */
+
+/*
+ * COFF section header
+ */
+
+struct coff_scnhdr {
+ char s_name[8];
+ long s_paddr;
+ long s_vaddr;
+ long s_size;
+ long s_scnptr;
+ long s_relptr;
+ long s_lnnoptr;
+ u_short s_nreloc;
+ u_short s_nlnno;
+ long s_flags;
+};
+
+/* s_flags */
+#define COFF_STYP_REG 0x00
+#define COFF_STYP_DSECT 0x01
+#define COFF_STYP_NOLOAD 0x02
+#define COFF_STYP_GROUP 0x04
+#define COFF_STYP_PAD 0x08
+#define COFF_STYP_COPY 0x10
+#define COFF_STYP_TEXT 0x20
+#define COFF_STYP_DATA 0x40
+#define COFF_STYP_BSS 0x80
+#define COFF_STYP_INFO 0x200
+#define COFF_STYP_OVER 0x400
+#define COFF_STYP_SHLIB 0x800
+
+/*
+ * COFF shared library header
+ */
+
+struct coff_slhdr {
+ long entry_len; /* in words */
+ long path_index; /* in words */
+ char sl_name[1];
+};
+
+#define COFF_ROUND(val, by) (((val) + by - 1) & ~(by - 1))
+
+#define COFF_ALIGN(a) ((a) & ~(COFF_LDPGSZ - 1))
+
+#define COFF_HDR_SIZE \
+ (sizeof(struct coff_filehdr) + sizeof(struct coff_aouthdr))
+
+#define COFF_BLOCK_ALIGN(ap, value) \
+ (ap->a_magic == COFF_ZMAGIC ? COFF_ROUND(value, COFF_LDPGSZ) : \
+ value)
+
+#define COFF_TXTOFF(fp, ap) \
+ (ap->a_magic == COFF_ZMAGIC ? 0 : \
+ COFF_ROUND(COFF_HDR_SIZE + fp->f_nscns * \
+ sizeof(struct coff_scnhdr), COFF_SEGMENT_ALIGNMENT(ap)))
+
+#define COFF_DATOFF(fp, ap) \
+ (COFF_BLOCK_ALIGN(ap, COFF_TXTOFF(fp, ap) + ap->a_tsize))
+
+#define COFF_SEGMENT_ALIGN(ap, value) \
+ (COFF_ROUND(value, (ap->a_magic == COFF_ZMAGIC ? COFF_LDPGSZ : \
+ COFF_SEGMENT_ALIGNMENT(ap))))
+
+#define COFF_LDPGSZ 4096
+
+#define COFF_SEGMENT_ALIGNMENT(ap) 4
+
+#define COFF_BADMAG(ex) (ex->f_magic != COFF_MAGIC_I386)
+
+#define IBCS2_HIGH_SYSCALL(n) (((n) & 0x7f) == 0x28)
+#define IBCS2_CVT_HIGH_SYSCALL(n) (((n) >> 8) + 128)
+
+struct exec_package;
+int exec_ibcs2_coff_makecmds __P((struct proc *, struct exec_package *));
+
+/*
+ * x.out (XENIX)
+ */
+
+struct xexec {
+ u_short x_magic; /* magic number */
+ u_short x_ext; /* size of extended header */
+ long x_text; /* ignored */
+ long x_data; /* ignored */
+ long x_bss; /* ignored */
+ long x_syms; /* ignored */
+ long x_reloc; /* ignored */
+ long x_entry; /* executable entry point */
+ char x_cpu; /* processor type */
+ char x_relsym; /* ignored */
+ u_short x_renv; /* flags */
+};
+
+/* x_magic flags */
+#define XOUT_MAGIC 0x0206
+
+/* x_cpu flags */
+#define XC_386 0x004a /* 386, word-swapped */
+
+/* x_renv flags */
+#define XE_V5 0xc000
+#define XE_SEG 0x0800
+#define XE_ABS 0x0400
+#define XE_ITER 0x0200
+#define XE_VMOD 0x0100
+#define XE_FPH 0x0080
+#define XE_LTEXT 0x0040
+#define XE_LDATA 0x0020
+#define XE_OVER 0x0010
+#define XE_FS 0x0008
+#define XE_PURE 0x0004
+#define XE_SEP 0x0002
+#define XE_EXEC 0x0001
+
+/*
+ * x.out extended header
+ */
+
+struct xext {
+ long xe_trsize; /* ignored */
+ long xe_drsize; /* ignored */
+ long xe_tbase; /* ignored */
+ long xe_dbase; /* ignored */
+ long xe_stksize; /* stack size if XE_FS set in x_renv */
+ long xe_segpos; /* offset of segment table */
+ long xe_segsize; /* segment table size */
+ long xe_mdtpos; /* ignored */
+ long xe_mdtsize; /* ignored */
+ char xe_mdttype; /* ignored */
+ char xe_pagesize; /* ignored */
+ char xe_ostype; /* ignored */
+ char xe_osvers; /* ignored */
+ u_short xe_eseg; /* ignored */
+ u_short xe_sres; /* ignored */
+};
+
+/*
+ * x.out segment table
+ */
+
+struct xseg {
+ u_short xs_type; /* segment type */
+ u_short xs_attr; /* attribute flags */
+ u_short xs_seg; /* segment selector number */
+ char xs_align; /* ignored */
+ char xs_cres; /* ignored */
+ long xs_filpos; /* offset of this segment */
+ long xs_psize; /* physical segment size */
+ long xs_vsize; /* virtual segment size */
+ long xs_rbase; /* relocation base address */
+ u_short xs_noff; /* ignored */
+ u_short xs_sres; /* ignored */
+ long xs_lres; /* ignored */
+};
+
+/* xs_type flags */
+#define XS_TNULL 0 /* unused */
+#define XS_TTEXT 1 /* text (read-only) */
+#define XS_TDATA 2 /* data (read-write) */
+#define XS_TSYMS 3 /* symbol table (noload) */
+#define XS_TREL 4 /* relocation segment (noload) */
+#define XS_TSESTR 5 /* string table (noload) */
+#define XS_TGRPS 6 /* group segment (noload) */
+
+#define XS_TIDATA 64
+#define XS_TTSS 65
+#define XS_TLFIX 66
+#define XS_TDNAME 67
+#define XS_TDTEXT 68
+#define XS_TDFIX 69
+#define XS_TOVTAB 70
+#define XS_T71 71
+#define XS_TSYSTR 72
+
+/* xs_attr flags */
+#define XS_AMEM 0x8000 /* memory image */
+#define XS_AITER 0x0001 /* iteration records */
+#define XS_AHUGE 0x0002 /* unused */
+#define XS_ABSS 0x0004 /* uninitialized data */
+#define XS_APURE 0x0008 /* read-only (sharable) segment */
+#define XS_AEDOWN 0x0010 /* expand down memory segment */
+#define XS_APRIV 0x0020 /* unused */
+#define XS_A32BIT 0x0040 /* 32-bit text/data */
+
+/*
+ * x.out iteration record
+ */
+
+struct xiter {
+ long xi_size; /* text/data size */
+ long xi_rep; /* number of replications */
+ long xi_offset; /* offset within segment to replicated data */
+};
+
+#define XOUT_HDR_SIZE (sizeof(struct xexec) + sizeof(struct xext))
+
+int exec_ibcs2_xout_makecmds __P((struct proc *, struct exec_package *));
+
+#endif /* !_IBCS2_EXEC_H_ */
diff --git a/sys/compat/ibcs2/ibcs2_fcntl.c b/sys/compat/ibcs2/ibcs2_fcntl.c
new file mode 100644
index 00000000000..c299034e76a
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_fcntl.c
@@ -0,0 +1,322 @@
+/*
+ * Copyright (c) 1995 Scott Bartram
+ * 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/namei.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/malloc.h>
+#include <sys/syscallargs.h>
+
+#include <compat/ibcs2/ibcs2_types.h>
+#include <compat/ibcs2/ibcs2_fcntl.h>
+#include <compat/ibcs2/ibcs2_signal.h>
+#include <compat/ibcs2/ibcs2_syscallargs.h>
+#include <compat/ibcs2/ibcs2_util.h>
+
+static int
+cvt_o_flags(flags)
+ int flags;
+{
+ int r = 0;
+
+ /* convert mode into NetBSD mode */
+ if (flags & IBCS2_O_WRONLY) r |= O_WRONLY;
+ if (flags & IBCS2_O_RDWR) r |= O_RDWR;
+ if (flags & (IBCS2_O_NDELAY | IBCS2_O_NONBLOCK)) r |= O_NONBLOCK;
+ if (flags & IBCS2_O_APPEND) r |= O_APPEND;
+ if (flags & IBCS2_O_SYNC) r |= O_FSYNC;
+ if (flags & IBCS2_O_CREAT) r |= O_CREAT;
+ if (flags & IBCS2_O_TRUNC) r |= O_TRUNC;
+ if (flags & IBCS2_O_EXCL) r |= O_EXCL;
+ return r;
+}
+
+static void
+cvt_flock2iflock(flp, iflp)
+ struct flock *flp;
+ struct ibcs2_flock *iflp;
+{
+ switch (flp->l_type) {
+ case F_RDLCK:
+ iflp->l_type = IBCS2_F_RDLCK;
+ break;
+ case F_WRLCK:
+ iflp->l_type = IBCS2_F_WRLCK;
+ break;
+ case F_UNLCK:
+ iflp->l_type = IBCS2_F_UNLCK;
+ break;
+ }
+ iflp->l_whence = (short)flp->l_whence;
+ iflp->l_start = (ibcs2_off_t)flp->l_start;
+ iflp->l_len = (ibcs2_off_t)flp->l_len;
+ iflp->l_sysid = 0;
+ iflp->l_pid = (ibcs2_pid_t)flp->l_pid;
+}
+
+static void
+cvt_iflock2flock(iflp, flp)
+ struct ibcs2_flock *iflp;
+ struct flock *flp;
+{
+ flp->l_start = (off_t)iflp->l_start;
+ flp->l_len = (off_t)iflp->l_len;
+ flp->l_pid = (pid_t)iflp->l_pid;
+ switch (iflp->l_type) {
+ case IBCS2_F_RDLCK:
+ flp->l_type = F_RDLCK;
+ break;
+ case IBCS2_F_WRLCK:
+ flp->l_type = F_WRLCK;
+ break;
+ case IBCS2_F_UNLCK:
+ flp->l_type = F_UNLCK;
+ break;
+ }
+ flp->l_whence = iflp->l_whence;
+}
+
+/* convert iBCS2 mode into NetBSD mode */
+static int
+ioflags2oflags(flags)
+ int flags;
+{
+ int r = 0;
+
+ if (flags & IBCS2_O_RDONLY) r |= O_RDONLY;
+ if (flags & IBCS2_O_WRONLY) r |= O_WRONLY;
+ if (flags & IBCS2_O_RDWR) r |= O_RDWR;
+ if (flags & IBCS2_O_NDELAY) r |= O_NONBLOCK;
+ if (flags & IBCS2_O_APPEND) r |= O_APPEND;
+ if (flags & IBCS2_O_SYNC) r |= O_FSYNC;
+ if (flags & IBCS2_O_NONBLOCK) r |= O_NONBLOCK;
+ if (flags & IBCS2_O_CREAT) r |= O_CREAT;
+ if (flags & IBCS2_O_TRUNC) r |= O_TRUNC;
+ if (flags & IBCS2_O_EXCL) r |= O_EXCL;
+ if (flags & IBCS2_O_NOCTTY) r |= O_NOCTTY;
+ return r;
+}
+
+/* convert NetBSD mode into iBCS2 mode */
+static int
+oflags2ioflags(flags)
+ int flags;
+{
+ int r = 0;
+
+ if (flags & O_RDONLY) r |= IBCS2_O_RDONLY;
+ if (flags & O_WRONLY) r |= IBCS2_O_WRONLY;
+ if (flags & O_RDWR) r |= IBCS2_O_RDWR;
+ if (flags & O_NDELAY) r |= IBCS2_O_NONBLOCK;
+ if (flags & O_APPEND) r |= IBCS2_O_APPEND;
+ if (flags & O_FSYNC) r |= IBCS2_O_SYNC;
+ if (flags & O_NONBLOCK) r |= IBCS2_O_NONBLOCK;
+ if (flags & O_CREAT) r |= IBCS2_O_CREAT;
+ if (flags & O_TRUNC) r |= IBCS2_O_TRUNC;
+ if (flags & O_EXCL) r |= IBCS2_O_EXCL;
+ if (flags & O_NOCTTY) r |= IBCS2_O_NOCTTY;
+ return r;
+}
+
+int
+ibcs2_sys_open(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_open_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ int noctty = SCARG(uap, flags) & IBCS2_O_NOCTTY;
+ int ret;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ SCARG(uap, flags) = cvt_o_flags(SCARG(uap, flags));
+ if (SCARG(uap, flags) & O_CREAT)
+ IBCS2_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+ else
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ ret = sys_open(p, uap, retval);
+
+ if (!ret && !noctty && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
+ struct filedesc *fdp = p->p_fd;
+ struct file *fp = fdp->fd_ofiles[*retval];
+
+ /* ignore any error, just give it a try */
+ if (fp->f_type == DTYPE_VNODE)
+ (fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, (caddr_t) 0, p);
+ }
+ return ret;
+}
+
+int
+ibcs2_sys_creat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_creat_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ struct sys_open_args cup;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, mode) = SCARG(uap, mode);
+ SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC;
+ return sys_open(p, &cup, retval);
+}
+
+int
+ibcs2_sys_access(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_access_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ } */ *uap = v;
+ struct sys_access_args cup;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, flags) = SCARG(uap, flags);
+ return sys_access(p, &cup, retval);
+}
+
+int
+ibcs2_sys_fcntl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_fcntl_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) cmd;
+ syscallarg(char *) arg;
+ } */ *uap = v;
+ int error;
+ struct sys_fcntl_args fa;
+ struct flock *flp;
+ struct ibcs2_flock ifl;
+
+ switch(SCARG(uap, cmd)) {
+ case IBCS2_F_DUPFD:
+ SCARG(&fa, fd) = SCARG(uap, fd);
+ SCARG(&fa, cmd) = F_DUPFD;
+ SCARG(&fa, arg) = SCARG(uap, arg);
+ return sys_fcntl(p, &fa, retval);
+ case IBCS2_F_GETFD:
+ SCARG(&fa, fd) = SCARG(uap, fd);
+ SCARG(&fa, cmd) = F_GETFD;
+ SCARG(&fa, arg) = SCARG(uap, arg);
+ return sys_fcntl(p, &fa, retval);
+ case IBCS2_F_SETFD:
+ SCARG(&fa, fd) = SCARG(uap, fd);
+ SCARG(&fa, cmd) = F_SETFD;
+ SCARG(&fa, arg) = SCARG(uap, arg);
+ return sys_fcntl(p, &fa, retval);
+ case IBCS2_F_GETFL:
+ SCARG(&fa, fd) = SCARG(uap, fd);
+ SCARG(&fa, cmd) = F_GETFL;
+ SCARG(&fa, arg) = SCARG(uap, arg);
+ error = sys_fcntl(p, &fa, retval);
+ if (error)
+ return error;
+ *retval = oflags2ioflags(*retval);
+ return error;
+ case IBCS2_F_SETFL:
+ SCARG(&fa, fd) = SCARG(uap, fd);
+ SCARG(&fa, cmd) = F_SETFL;
+ SCARG(&fa, arg) = (void *)ioflags2oflags(SCARG(uap, arg));
+ return sys_fcntl(p, &fa, retval);
+
+ case IBCS2_F_GETLK:
+ {
+ caddr_t sg = stackgap_init(p->p_emul);
+ flp = stackgap_alloc(&sg, sizeof(*flp));
+ error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&ifl,
+ ibcs2_flock_len);
+ if (error)
+ return error;
+ cvt_iflock2flock(&ifl, flp);
+ SCARG(&fa, fd) = SCARG(uap, fd);
+ SCARG(&fa, cmd) = F_GETLK;
+ SCARG(&fa, arg) = (void *)flp;
+ error = sys_fcntl(p, &fa, retval);
+ if (error)
+ return error;
+ cvt_flock2iflock(flp, &ifl);
+ return copyout((caddr_t)&ifl, (caddr_t)SCARG(uap, arg),
+ ibcs2_flock_len);
+ }
+
+ case IBCS2_F_SETLK:
+ {
+ caddr_t sg = stackgap_init(p->p_emul);
+ flp = stackgap_alloc(&sg, sizeof(*flp));
+ error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&ifl,
+ ibcs2_flock_len);
+ if (error)
+ return error;
+ cvt_iflock2flock(&ifl, flp);
+ SCARG(&fa, fd) = SCARG(uap, fd);
+ SCARG(&fa, cmd) = F_SETLK;
+ SCARG(&fa, arg) = (void *)flp;
+ return sys_fcntl(p, &fa, retval);
+ }
+
+ case IBCS2_F_SETLKW:
+ {
+ caddr_t sg = stackgap_init(p->p_emul);
+ flp = stackgap_alloc(&sg, sizeof(*flp));
+ error = copyin((caddr_t)SCARG(uap, arg), (caddr_t)&ifl,
+ ibcs2_flock_len);
+ if (error)
+ return error;
+ cvt_iflock2flock(&ifl, flp);
+ SCARG(&fa, fd) = SCARG(uap, fd);
+ SCARG(&fa, cmd) = F_SETLKW;
+ SCARG(&fa, arg) = (void *)flp;
+ return sys_fcntl(p, &fa, retval);
+ }
+ }
+ return ENOSYS;
+}
diff --git a/sys/compat/ibcs2/ibcs2_fcntl.h b/sys/compat/ibcs2/ibcs2_fcntl.h
new file mode 100644
index 00000000000..b75537cb66f
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_fcntl.h
@@ -0,0 +1,76 @@
+/* $NetBSD: ibcs2_fcntl.h,v 1.2 1994/10/26 02:52:54 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_FCNTL_H
+#define _IBCS2_FCNTL_H 1
+
+#include <compat/ibcs2/ibcs2_types.h>
+
+#define IBCS2_O_RDONLY 0x0000
+#define IBCS2_O_WRONLY 0x0001
+#define IBCS2_O_RDWR 0x0002
+#define IBCS2_O_NDELAY 0x0004
+#define IBCS2_O_APPEND 0x0008
+#define IBCS2_O_SYNC 0x0010
+#define IBCS2_O_NONBLOCK 0x0080
+#define IBCS2_O_CREAT 0x0100
+#define IBCS2_O_TRUNC 0x0200
+#define IBCS2_O_EXCL 0x0400
+#define IBCS2_O_NOCTTY 0x0800
+
+#define IBCS2_F_DUPFD 0
+#define IBCS2_F_GETFD 1
+#define IBCS2_F_SETFD 2
+#define IBCS2_F_GETFL 3
+#define IBCS2_F_SETFL 4
+#define IBCS2_F_GETLK 5
+#define IBCS2_F_SETLK 6
+#define IBCS2_F_SETLKW 7
+
+struct ibcs2_flock {
+ short l_type;
+ short l_whence;
+ ibcs2_off_t l_start;
+ ibcs2_off_t l_len;
+ short l_sysid;
+ ibcs2_pid_t l_pid;
+};
+#define ibcs2_flock_len (sizeof(struct ibcs2_flock))
+
+#define IBCS2_F_RDLCK 1
+#define IBCS2_F_WRLCK 2
+#define IBCS2_F_UNLCK 3
+
+#define IBCS2_O_ACCMODE 3
+#define IBCS2_FD_CLOEXEC 1
+
+#endif /* _IBCS2_FCNTL_H */
diff --git a/sys/compat/ibcs2/ibcs2_grp.h b/sys/compat/ibcs2/ibcs2_grp.h
new file mode 100644
index 00000000000..587101f743f
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_grp.h
@@ -0,0 +1,43 @@
+/* $NetBSD: ibcs2_grp.h,v 1.2 1994/10/26 02:52:55 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_GRP_H
+#define _IBCS2_GRP_H
+
+struct ibcs2_group {
+ char *gr_name;
+ char *gr_passwd;
+ char *gr_gid;
+ char **gr_mem;
+};
+
+#endif /* _IBCS2_GRP_H */
diff --git a/sys/compat/ibcs2/ibcs2_ioctl.c b/sys/compat/ibcs2/ibcs2_ioctl.c
new file mode 100644
index 00000000000..f5b4763ecd5
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_ioctl.c
@@ -0,0 +1,504 @@
+/* $NetBSD: ibcs2_ioctl.c,v 1.9 1995/10/10 02:35:16 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Scott Bartram
+ * All rights reserved.
+ *
+ * based on compat/sunos/sun_ioctl.c
+ *
+ * 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. 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/namei.h>
+#include <sys/dir.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/reboot.h>
+#include <sys/resource.h>
+#include <sys/resourcevar.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/socket.h>
+#include <sys/termios.h>
+#include <sys/time.h>
+#include <sys/times.h>
+#include <sys/tty.h>
+#include <sys/vnode.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <sys/utsname.h>
+#include <sys/unistd.h>
+
+#include <net/if.h>
+#include <sys/syscallargs.h>
+
+#include <compat/ibcs2/ibcs2_types.h>
+#include <compat/ibcs2/ibcs2_signal.h>
+#include <compat/ibcs2/ibcs2_socksys.h>
+#include <compat/ibcs2/ibcs2_stropts.h>
+#include <compat/ibcs2/ibcs2_syscallargs.h>
+#include <compat/ibcs2/ibcs2_termios.h>
+#include <compat/ibcs2/ibcs2_util.h>
+
+/*
+ * iBCS2 ioctl calls.
+ */
+
+static struct speedtab sptab[] = {
+ { 0, 0 },
+ { 50, 1 },
+ { 75, 2 },
+ { 110, 3 },
+ { 134, 4 },
+ { 135, 4 },
+ { 150, 5 },
+ { 200, 6 },
+ { 300, 7 },
+ { 600, 8 },
+ { 1200, 9 },
+ { 1800, 10 },
+ { 2400, 11 },
+ { 4800, 12 },
+ { 9600, 13 },
+ { 19200, 14 },
+ { 38400, 15 },
+ { -1, -1 }
+};
+
+static u_long s2btab[] = {
+ 0,
+ 50,
+ 75,
+ 110,
+ 134,
+ 150,
+ 200,
+ 300,
+ 600,
+ 1200,
+ 1800,
+ 2400,
+ 4800,
+ 9600,
+ 19200,
+ 38400,
+};
+
+static void
+stios2btios(st, bt)
+ struct ibcs2_termios *st;
+ struct termios *bt;
+{
+ register u_long l, r;
+
+ l = st->c_iflag; r = 0;
+ if (l & IBCS2_IGNBRK) r |= IGNBRK;
+ if (l & IBCS2_BRKINT) r |= BRKINT;
+ if (l & IBCS2_IGNPAR) r |= IGNPAR;
+ if (l & IBCS2_PARMRK) r |= PARMRK;
+ if (l & IBCS2_INPCK) r |= INPCK;
+ if (l & IBCS2_ISTRIP) r |= ISTRIP;
+ if (l & IBCS2_INLCR) r |= INLCR;
+ if (l & IBCS2_IGNCR) r |= IGNCR;
+ if (l & IBCS2_ICRNL) r |= ICRNL;
+ if (l & IBCS2_IXON) r |= IXON;
+ if (l & IBCS2_IXANY) r |= IXANY;
+ if (l & IBCS2_IXOFF) r |= IXOFF;
+ if (l & IBCS2_IMAXBEL) r |= IMAXBEL;
+ bt->c_iflag = r;
+
+ l = st->c_oflag; r = 0;
+ if (l & IBCS2_OPOST) r |= OPOST;
+ if (l & IBCS2_ONLCR) r |= ONLCR;
+ if (l & IBCS2_TAB3) r |= OXTABS;
+ bt->c_oflag = r;
+
+ l = st->c_cflag; r = 0;
+ switch (l & IBCS2_CSIZE) {
+ case IBCS2_CS5: r |= CS5; break;
+ case IBCS2_CS6: r |= CS6; break;
+ case IBCS2_CS7: r |= CS7; break;
+ case IBCS2_CS8: r |= CS8; break;
+ }
+ if (l & IBCS2_CSTOPB) r |= CSTOPB;
+ if (l & IBCS2_CREAD) r |= CREAD;
+ if (l & IBCS2_PARENB) r |= PARENB;
+ if (l & IBCS2_PARODD) r |= PARODD;
+ if (l & IBCS2_HUPCL) r |= HUPCL;
+ if (l & IBCS2_CLOCAL) r |= CLOCAL;
+ bt->c_cflag = r;
+
+ l = st->c_lflag; r = 0;
+ if (l & IBCS2_ISIG) r |= ISIG;
+ if (l & IBCS2_ICANON) r |= ICANON;
+ if (l & IBCS2_ECHO) r |= ECHO;
+ if (l & IBCS2_ECHOE) r |= ECHOE;
+ if (l & IBCS2_ECHOK) r |= ECHOK;
+ if (l & IBCS2_ECHONL) r |= ECHONL;
+ if (l & IBCS2_NOFLSH) r |= NOFLSH;
+ if (l & IBCS2_TOSTOP) r |= TOSTOP;
+ bt->c_lflag = r;
+
+ bt->c_ispeed = bt->c_ospeed = s2btab[l & 0x0000000f];
+
+ bt->c_cc[VINTR] =
+ st->c_cc[IBCS2_VINTR] ? st->c_cc[IBCS2_VINTR] : _POSIX_VDISABLE;
+ bt->c_cc[VQUIT] =
+ st->c_cc[IBCS2_VQUIT] ? st->c_cc[IBCS2_VQUIT] : _POSIX_VDISABLE;
+ bt->c_cc[VERASE] =
+ st->c_cc[IBCS2_VERASE] ? st->c_cc[IBCS2_VERASE] : _POSIX_VDISABLE;
+ bt->c_cc[VKILL] =
+ st->c_cc[IBCS2_VKILL] ? st->c_cc[IBCS2_VKILL] : _POSIX_VDISABLE;
+ if (bt->c_lflag & ICANON) {
+ bt->c_cc[VEOF] =
+ st->c_cc[IBCS2_VEOF] ? st->c_cc[IBCS2_VEOF] : _POSIX_VDISABLE;
+ bt->c_cc[VEOL] =
+ st->c_cc[IBCS2_VEOL] ? st->c_cc[IBCS2_VEOL] : _POSIX_VDISABLE;
+ } else {
+ bt->c_cc[VMIN] = st->c_cc[IBCS2_VMIN];
+ bt->c_cc[VTIME] = st->c_cc[IBCS2_VTIME];
+ }
+ bt->c_cc[VEOL2] =
+ st->c_cc[IBCS2_VEOL2] ? st->c_cc[IBCS2_VEOL2] : _POSIX_VDISABLE;
+#if 0
+ bt->c_cc[VSWTCH] =
+ st->c_cc[IBCS2_VSWTCH] ? st->c_cc[IBCS2_VSWTCH] : _POSIX_VDISABLE;
+#endif
+ bt->c_cc[VSTART] =
+ st->c_cc[IBCS2_VSTART] ? st->c_cc[IBCS2_VSTART] : _POSIX_VDISABLE;
+ bt->c_cc[VSTOP] =
+ st->c_cc[IBCS2_VSTOP] ? st->c_cc[IBCS2_VSTOP] : _POSIX_VDISABLE;
+ bt->c_cc[VSUSP] =
+ st->c_cc[IBCS2_VSUSP] ? st->c_cc[IBCS2_VSUSP] : _POSIX_VDISABLE;
+ bt->c_cc[VDSUSP] = _POSIX_VDISABLE;
+ bt->c_cc[VREPRINT] = _POSIX_VDISABLE;
+ bt->c_cc[VDISCARD] = _POSIX_VDISABLE;
+ bt->c_cc[VWERASE] = _POSIX_VDISABLE;
+ bt->c_cc[VLNEXT] = _POSIX_VDISABLE;
+ bt->c_cc[VSTATUS] = _POSIX_VDISABLE;
+}
+
+static void
+btios2stios(bt, st)
+ struct termios *bt;
+ struct ibcs2_termios *st;
+{
+ register u_long l, r;
+
+ l = bt->c_iflag; r = 0;
+ if (l & IGNBRK) r |= IBCS2_IGNBRK;
+ if (l & BRKINT) r |= IBCS2_BRKINT;
+ if (l & IGNPAR) r |= IBCS2_IGNPAR;
+ if (l & PARMRK) r |= IBCS2_PARMRK;
+ if (l & INPCK) r |= IBCS2_INPCK;
+ if (l & ISTRIP) r |= IBCS2_ISTRIP;
+ if (l & INLCR) r |= IBCS2_INLCR;
+ if (l & IGNCR) r |= IBCS2_IGNCR;
+ if (l & ICRNL) r |= IBCS2_ICRNL;
+ if (l & IXON) r |= IBCS2_IXON;
+ if (l & IXANY) r |= IBCS2_IXANY;
+ if (l & IXOFF) r |= IBCS2_IXOFF;
+ if (l & IMAXBEL) r |= IBCS2_IMAXBEL;
+ st->c_iflag = r;
+
+ l = bt->c_oflag; r = 0;
+ if (l & OPOST) r |= IBCS2_OPOST;
+ if (l & ONLCR) r |= IBCS2_ONLCR;
+ if (l & OXTABS) r |= IBCS2_TAB3;
+ st->c_oflag = r;
+
+ l = bt->c_cflag; r = 0;
+ switch (l & CSIZE) {
+ case CS5: r |= IBCS2_CS5; break;
+ case CS6: r |= IBCS2_CS6; break;
+ case CS7: r |= IBCS2_CS7; break;
+ case CS8: r |= IBCS2_CS8; break;
+ }
+ if (l & CSTOPB) r |= IBCS2_CSTOPB;
+ if (l & CREAD) r |= IBCS2_CREAD;
+ if (l & PARENB) r |= IBCS2_PARENB;
+ if (l & PARODD) r |= IBCS2_PARODD;
+ if (l & HUPCL) r |= IBCS2_HUPCL;
+ if (l & CLOCAL) r |= IBCS2_CLOCAL;
+ st->c_cflag = r;
+
+ l = bt->c_lflag; r = 0;
+ if (l & ISIG) r |= IBCS2_ISIG;
+ if (l & ICANON) r |= IBCS2_ICANON;
+ if (l & ECHO) r |= IBCS2_ECHO;
+ if (l & ECHOE) r |= IBCS2_ECHOE;
+ if (l & ECHOK) r |= IBCS2_ECHOK;
+ if (l & ECHONL) r |= IBCS2_ECHONL;
+ if (l & NOFLSH) r |= IBCS2_NOFLSH;
+ if (l & TOSTOP) r |= IBCS2_TOSTOP;
+ st->c_lflag = r;
+
+ l = ttspeedtab(bt->c_ospeed, sptab);
+ if (l >= 0)
+ st->c_cflag |= l;
+
+ st->c_cc[IBCS2_VINTR] =
+ bt->c_cc[VINTR] != _POSIX_VDISABLE ? bt->c_cc[VINTR] : 0;
+ st->c_cc[IBCS2_VQUIT] =
+ bt->c_cc[VQUIT] != _POSIX_VDISABLE ? bt->c_cc[VQUIT] : 0;
+ st->c_cc[IBCS2_VERASE] =
+ bt->c_cc[VERASE] != _POSIX_VDISABLE ? bt->c_cc[VERASE] : 0;
+ st->c_cc[IBCS2_VKILL] =
+ bt->c_cc[VKILL] != _POSIX_VDISABLE ? bt->c_cc[VKILL] : 0;
+ if (bt->c_lflag & ICANON) {
+ st->c_cc[IBCS2_VEOF] =
+ bt->c_cc[VEOF] != _POSIX_VDISABLE ? bt->c_cc[VEOF] : 0;
+ st->c_cc[IBCS2_VEOL] =
+ bt->c_cc[VEOL] != _POSIX_VDISABLE ? bt->c_cc[VEOL] : 0;
+ } else {
+ st->c_cc[IBCS2_VMIN] = bt->c_cc[VMIN];
+ st->c_cc[IBCS2_VTIME] = bt->c_cc[VTIME];
+ }
+ st->c_cc[IBCS2_VEOL2] =
+ bt->c_cc[VEOL2] != _POSIX_VDISABLE ? bt->c_cc[VEOL2] : 0;
+ st->c_cc[IBCS2_VSWTCH] =
+ 0;
+ st->c_cc[IBCS2_VSUSP] =
+ bt->c_cc[VSUSP] != _POSIX_VDISABLE ? bt->c_cc[VSUSP] : 0;
+ st->c_cc[IBCS2_VSTART] =
+ bt->c_cc[VSTART] != _POSIX_VDISABLE ? bt->c_cc[VSTART] : 0;
+ st->c_cc[IBCS2_VSTOP] =
+ bt->c_cc[VSTOP] != _POSIX_VDISABLE ? bt->c_cc[VSTOP] : 0;
+
+ st->c_line = 0;
+}
+
+static void
+stios2stio(ts, t)
+ struct ibcs2_termios *ts;
+ struct ibcs2_termio *t;
+{
+
+ t->c_iflag = ts->c_iflag;
+ t->c_oflag = ts->c_oflag;
+ t->c_cflag = ts->c_cflag;
+ t->c_lflag = ts->c_lflag;
+ t->c_line = ts->c_line;
+ bcopy(ts->c_cc, t->c_cc, IBCS2_NCC);
+}
+
+static void
+stio2stios(t, ts)
+ struct ibcs2_termio *t;
+ struct ibcs2_termios *ts;
+{
+
+ ts->c_iflag = t->c_iflag;
+ ts->c_oflag = t->c_oflag;
+ ts->c_cflag = t->c_cflag;
+ ts->c_lflag = t->c_lflag;
+ ts->c_line = t->c_line;
+ bcopy(t->c_cc, ts->c_cc, IBCS2_NCC);
+}
+
+int
+ibcs2_sys_ioctl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_ioctl_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) cmd;
+ syscallarg(caddr_t) data;
+ } */ *uap = v;
+ struct filedesc *fdp = p->p_fd;
+ struct file *fp;
+ int (*ctl)();
+ int error;
+
+ if (SCARG(uap, fd) < 0 || SCARG(uap, fd) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) {
+ DPRINTF(("ibcs2_ioctl(%d): bad fd %d ", p->p_pid,
+ SCARG(uap, fd)));
+ return EBADF;
+ }
+
+ if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
+ DPRINTF(("ibcs2_ioctl(%d): bad fp flag ", p->p_pid));
+ return EBADF;
+ }
+
+ ctl = fp->f_ops->fo_ioctl;
+
+ switch (SCARG(uap, cmd)) {
+ case IBCS2_TCGETA:
+ case IBCS2_XCGETA:
+ case IBCS2_OXCGETA:
+ {
+ struct termios bts;
+ struct ibcs2_termios sts;
+ struct ibcs2_termio st;
+
+ if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0)
+ return error;
+
+ btios2stios (&bts, &sts);
+ if (SCARG(uap, cmd) == IBCS2_TCGETA) {
+ stios2stio (&sts, &st);
+ error = copyout((caddr_t)&st, SCARG(uap, data),
+ sizeof (st));
+ if (error)
+ DPRINTF(("ibcs2_ioctl(%d): copyout failed ",
+ p->p_pid));
+ return error;
+ } else
+ return copyout((caddr_t)&sts, SCARG(uap, data),
+ sizeof (sts));
+ /*NOTREACHED*/
+ }
+
+ case IBCS2_TCSETA:
+ case IBCS2_TCSETAW:
+ case IBCS2_TCSETAF:
+ {
+ struct termios bts;
+ struct ibcs2_termios sts;
+ struct ibcs2_termio st;
+
+ if ((error = copyin(SCARG(uap, data), (caddr_t)&st,
+ sizeof(st))) != 0) {
+ DPRINTF(("ibcs2_ioctl(%d): TCSET copyin failed ",
+ p->p_pid));
+ return error;
+ }
+
+ /* get full BSD termios so we don't lose information */
+ if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0) {
+ DPRINTF(("ibcs2_ioctl(%d): TCSET ctl failed fd %d ",
+ p->p_pid, SCARG(uap, fd)));
+ return error;
+ }
+
+ /*
+ * convert to iBCS2 termios, copy in information from
+ * termio, and convert back, then set new values.
+ */
+ btios2stios(&bts, &sts);
+ stio2stios(&st, &sts);
+ stios2btios(&sts, &bts);
+
+ return (*ctl)(fp, SCARG(uap, cmd) - IBCS2_TCSETA + TIOCSETA,
+ (caddr_t)&bts, p);
+ }
+
+ case IBCS2_XCSETA:
+ case IBCS2_XCSETAW:
+ case IBCS2_XCSETAF:
+ {
+ struct termios bts;
+ struct ibcs2_termios sts;
+
+ if ((error = copyin(SCARG(uap, data), (caddr_t)&sts,
+ sizeof (sts))) != 0) {
+ return error;
+ }
+ stios2btios (&sts, &bts);
+ return (*ctl)(fp, SCARG(uap, cmd) - IBCS2_XCSETA + TIOCSETA,
+ (caddr_t)&bts, p);
+ }
+
+ case IBCS2_OXCSETA:
+ case IBCS2_OXCSETAW:
+ case IBCS2_OXCSETAF:
+ {
+ struct termios bts;
+ struct ibcs2_termios sts;
+
+ if ((error = copyin(SCARG(uap, data), (caddr_t)&sts,
+ sizeof (sts))) != 0) {
+ return error;
+ }
+ stios2btios (&sts, &bts);
+ return (*ctl)(fp, SCARG(uap, cmd) - IBCS2_OXCSETA + TIOCSETA,
+ (caddr_t)&bts, p);
+ }
+
+ case IBCS2_TCSBRK:
+ DPRINTF(("ibcs2_ioctl(%d): TCSBRK ", p->p_pid));
+ return ENOSYS;
+
+ case IBCS2_TCXONC:
+ DPRINTF(("ibcs2_ioctl(%d): TCXONC ", p->p_pid));
+ return ENOSYS;
+
+ case IBCS2_TCFLSH:
+ DPRINTF(("ibcs2_ioctl(%d): TCFLSH ", p->p_pid));
+ return ENOSYS;
+
+ case IBCS2_TIOCGWINSZ:
+ SCARG(uap, cmd) = TIOCGWINSZ;
+ return sys_ioctl(p, uap, retval);
+
+ case IBCS2_TIOCSWINSZ:
+ SCARG(uap, cmd) = TIOCSWINSZ;
+ return sys_ioctl(p, uap, retval);
+
+ case IBCS2_TIOCGPGRP:
+ return copyout((caddr_t)&p->p_pgrp->pg_id, SCARG(uap, data),
+ sizeof(p->p_pgrp->pg_id));
+
+ case IBCS2_TIOCSPGRP: /* XXX - is uap->data a pointer to pgid? */
+ {
+ struct sys_setpgid_args sa;
+
+ SCARG(&sa, pid) = 0;
+ SCARG(&sa, pgid) = (int)SCARG(uap, data);
+ if (error = sys_setpgid(p, &sa, retval))
+ return error;
+ return 0;
+ }
+
+ case IBCS2_TCGETSC: /* SCO console - get scancode flags */
+ return ENOSYS;
+
+ case IBCS2_TCSETSC: /* SCO console - set scancode flags */
+ return ENOSYS;
+
+ case IBCS2_SIOCSOCKSYS:
+ return ibcs2_socksys(p, uap, retval);
+
+ case IBCS2_I_NREAD: /* STREAMS */
+ SCARG(uap, cmd) = FIONREAD;
+ return sys_ioctl(p, uap, retval);
+
+ default:
+ DPRINTF(("ibcs2_ioctl(%d): unknown cmd 0x%lx ",
+ p->p_pid, SCARG(uap, cmd)));
+ return ENOSYS;
+ }
+ return ENOSYS;
+}
+
diff --git a/sys/compat/ibcs2/ibcs2_ipc.c b/sys/compat/ibcs2/ibcs2_ipc.c
new file mode 100644
index 00000000000..d8cc2e2844c
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_ipc.c
@@ -0,0 +1,442 @@
+/*
+ * Copyright (c) 1995 Scott Bartram
+ * 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. 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/namei.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/ipc.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/reboot.h>
+#include <sys/resource.h>
+#include <sys/resourcevar.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/times.h>
+#include <sys/vnode.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <sys/utsname.h>
+#include <sys/unistd.h>
+#include <sys/msg.h>
+#include <sys/sem.h>
+#include <sys/shm.h>
+#include <sys/syscallargs.h>
+
+#include <vm/vm.h>
+
+#include <compat/ibcs2/ibcs2_types.h>
+#include <compat/ibcs2/ibcs2_signal.h>
+#include <compat/ibcs2/ibcs2_syscallargs.h>
+#include <compat/ibcs2/ibcs2_util.h>
+
+#define IBCS2_IPC_RMID 0
+#define IBCS2_IPC_SET 1
+#define IBCS2_IPC_STAT 2
+
+/*
+ * iBCS2 msgsys call
+ */
+
+struct ibcs2_msqid_ds {
+ struct ipc_perm msg_perm;
+ struct msg *msg_first;
+ struct msg *msg_last;
+ u_short msg_cbytes;
+ u_short msg_qnum;
+ u_short msg_qbytes;
+ u_short msg_lspid;
+ u_short msg_lrpid;
+ ibcs2_time_t msg_stime;
+ ibcs2_time_t msg_rtime;
+ ibcs2_time_t msg_ctime;
+};
+
+static void
+cvt_msqid2imsqid(bp, ibp)
+struct msqid_ds *bp;
+struct ibcs2_msqid_ds *ibp;
+{
+ ibp->msg_perm = bp->msg_perm;
+ ibp->msg_first = bp->msg_first;
+ ibp->msg_last = bp->msg_last;
+ ibp->msg_cbytes = (u_short)bp->msg_cbytes;
+ ibp->msg_qnum = (u_short)bp->msg_qnum;
+ ibp->msg_qbytes = (u_short)bp->msg_qbytes;
+ ibp->msg_lspid = (u_short)bp->msg_lspid;
+ ibp->msg_lrpid = (u_short)bp->msg_lrpid;
+ ibp->msg_stime = bp->msg_stime;
+ ibp->msg_rtime = bp->msg_rtime;
+ ibp->msg_ctime = bp->msg_ctime;
+ return;
+}
+
+static void
+cvt_imsqid2msqid(ibp, bp)
+struct ibcs2_msqid_ds *ibp;
+struct msqid_ds *bp;
+{
+ bp->msg_perm = ibp->msg_perm;
+ bp->msg_first = ibp->msg_first;
+ bp->msg_last = ibp->msg_last;
+ bp->msg_cbytes = ibp->msg_cbytes;
+ bp->msg_qnum = ibp->msg_qnum;
+ bp->msg_qbytes = ibp->msg_qbytes;
+ bp->msg_lspid = ibp->msg_lspid;
+ bp->msg_lrpid = ibp->msg_lrpid;
+ bp->msg_stime = ibp->msg_stime;
+ bp->msg_rtime = ibp->msg_rtime;
+ bp->msg_ctime = ibp->msg_ctime;
+ return;
+}
+
+int
+ibcs2_sys_msgsys(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_msgsys_args /* {
+ syscallarg(int) which;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(int) a4;
+ syscallarg(int) a5;
+ syscallarg(int) a6;
+ } */ *uap = v;
+
+ switch (SCARG(uap, which)) {
+#ifdef SYSVMSG
+ case 0: /* msgget */
+ SCARG(uap, which) = 1;
+ return compat_10_sys_msgsys(p, uap, retval);
+ case 1: { /* msgctl */
+ int error;
+ struct compat_10_sys_msgsys_args margs;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ SCARG(&margs, which) = 0;
+ SCARG(&margs, a2) = SCARG(uap, a2);
+ SCARG(&margs, a4) =
+ (int)stackgap_alloc(&sg, sizeof(struct msqid_ds));
+ SCARG(&margs, a3) = SCARG(uap, a3);
+ switch (SCARG(&margs, a3)) {
+ case IBCS2_IPC_STAT:
+ error = compat_10_sys_msgsys(p, &margs, retval);
+ if (!error)
+ cvt_msqid2imsqid(SCARG(&margs, a4),
+ (struct ibcs2_msqid_ds *)SCARG(uap, a4));
+ return error;
+ case IBCS2_IPC_SET:
+ cvt_imsqid2msqid((struct ibcs2_msqid_ds *)SCARG(uap,
+ a4),
+ SCARG(&margs, a4));
+ return compat_10_sys_msgsys(p, &margs, retval);
+ case IBCS2_IPC_RMID:
+ return compat_10_sys_msgsys(p, &margs, retval);
+ }
+ return EINVAL;
+ }
+ case 2: /* msgrcv */
+ SCARG(uap, which) = 3;
+ return compat_10_sys_msgsys(p, uap, retval);
+ case 3: /* msgsnd */
+ SCARG(uap, which) = 2;
+ return compat_10_sys_msgsys(p, uap, retval);
+#endif
+ default:
+ return EINVAL;
+ }
+}
+
+
+/*
+ * iBCS2 semsys call
+ */
+
+struct ibcs2_semid_ds {
+ struct ipc_perm sem_perm;
+ struct ibcs2_sem *sem_base;
+ u_short sem_nsems;
+ int pad1;
+ ibcs2_time_t sem_otime;
+ ibcs2_time_t sem_ctime;
+};
+
+struct ibcs2_sem {
+ u_short semval;
+ ibcs2_pid_t sempid;
+ u_short semncnt;
+ u_short semzcnt;
+};
+
+static void
+cvt_sem2isem(bp, ibp)
+struct sem *bp;
+struct ibcs2_sem *ibp;
+{
+ ibp->semval = bp->semval;
+ ibp->sempid = bp->sempid;
+ ibp->semncnt = bp->semncnt;
+ ibp->semzcnt = bp->semzcnt;
+ return;
+}
+
+static void
+cvt_isem2sem(ibp, bp)
+struct ibcs2_sem *ibp;
+struct sem *bp;
+{
+ bp->semval = ibp->semval;
+ bp->sempid = ibp->sempid;
+ bp->semncnt = ibp->semncnt;
+ bp->semzcnt = ibp->semzcnt;
+ return;
+}
+
+static void
+cvt_semid2isemid(bp, ibp)
+struct semid_ds *bp;
+struct ibcs2_semid_ds *ibp;
+{
+ ibp->sem_perm = bp->sem_perm;
+ ibp->sem_base = (struct ibcs2_sem *)bp->sem_base;
+ ibp->sem_nsems = bp->sem_nsems;
+ ibp->sem_otime = bp->sem_otime;
+ ibp->sem_ctime = bp->sem_ctime;
+ return;
+}
+
+static void
+cvt_isemid2semid(ibp, bp)
+struct ibcs2_semid_ds *ibp;
+struct semid_ds *bp;
+{
+ bp->sem_perm = ibp->sem_perm;
+ bp->sem_base = (struct sem *)ibp->sem_base;
+ bp->sem_nsems = ibp->sem_nsems;
+ bp->sem_otime = ibp->sem_otime;
+ bp->sem_ctime = ibp->sem_ctime;
+ return;
+}
+
+int
+ibcs2_sys_semsys(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_semsys_args /* {
+ syscallarg(int) which;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(int) a4;
+ syscallarg(int) a5;
+ } */ *uap = v;
+ int error;
+
+#ifdef SYSVSEM
+ switch (SCARG(uap, which)) {
+ case 0: /* semctl */
+ switch(SCARG(uap, a4)) {
+ case IBCS2_IPC_STAT:
+ {
+ struct ibcs2_semid_ds *isp;
+ struct semid_ds *sp;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ isp = (struct ibcs2_semid_ds *)SCARG(uap, a5);
+ sp = stackgap_alloc(&sg, sizeof(struct semid_ds));
+ SCARG(uap, a5) = (int)sp;
+ error = compat_10_sys_semsys(p, uap, retval);
+ if (!error) {
+ SCARG(uap, a5) = (int)isp;
+ isp = stackgap_alloc(&sg, sizeof(*isp));
+ cvt_semid2isemid(sp, isp);
+ error = copyout((caddr_t)isp,
+ (caddr_t)SCARG(uap, a5),
+ sizeof(*isp));
+ }
+ return error;
+ }
+ case IBCS2_IPC_SET:
+ {
+ struct ibcs2_semid_ds *isp;
+ struct semid_ds *sp;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ isp = stackgap_alloc(&sg, sizeof(*isp));
+ sp = stackgap_alloc(&sg, sizeof(*sp));
+ error = copyin((caddr_t)SCARG(uap, a5), (caddr_t)isp,
+ sizeof(*isp));
+ if (error)
+ return error;
+ cvt_isemid2semid(isp, sp);
+ SCARG(uap, a5) = (int)sp;
+ return compat_10_sys_semsys(p, uap, retval);
+ }
+ }
+ return compat_10_sys_semsys(p, uap, retval);
+
+ case 1: /* semget */
+ return compat_10_sys_semsys(p, uap, retval);
+
+ case 2: /* semop */
+ return compat_10_sys_semsys(p, uap, retval);
+ }
+#endif
+ return EINVAL;
+}
+
+
+/*
+ * iBCS2 shmsys call
+ */
+
+struct ibcs2_shmid_ds {
+ struct ipc_perm shm_perm;
+ int shm_segsz;
+ int pad1;
+ char pad2[4];
+ u_short shm_lpid;
+ u_short shm_cpid;
+ u_short shm_nattch;
+ u_short shm_cnattch;
+ ibcs2_time_t shm_atime;
+ ibcs2_time_t shm_dtime;
+ ibcs2_time_t shm_ctime;
+};
+
+static void
+cvt_shmid2ishmid(bp, ibp)
+struct shmid_ds *bp;
+struct ibcs2_shmid_ds *ibp;
+{
+ ibp->shm_perm = bp->shm_perm;
+ ibp->shm_segsz = bp->shm_segsz;
+ ibp->shm_lpid = bp->shm_lpid;
+ ibp->shm_cpid = bp->shm_cpid;
+ ibp->shm_nattch = bp->shm_nattch;
+ ibp->shm_cnattch = 0; /* ignored anyway */
+ ibp->shm_atime = bp->shm_atime;
+ ibp->shm_dtime = bp->shm_dtime;
+ ibp->shm_ctime = bp->shm_ctime;
+ return;
+}
+
+static void
+cvt_ishmid2shmid(ibp, bp)
+struct ibcs2_shmid_ds *ibp;
+struct shmid_ds *bp;
+{
+ bp->shm_perm = ibp->shm_perm;
+ bp->shm_segsz = ibp->shm_segsz;
+ bp->shm_lpid = ibp->shm_lpid;
+ bp->shm_cpid = ibp->shm_cpid;
+ bp->shm_nattch = ibp->shm_nattch;
+ bp->shm_atime = ibp->shm_atime;
+ bp->shm_dtime = ibp->shm_dtime;
+ bp->shm_ctime = ibp->shm_ctime;
+ bp->shm_internal = (void *)0; /* ignored anyway */
+ return;
+}
+
+int
+ibcs2_sys_shmsys(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_shmsys_args /* {
+ syscallarg(int) which;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(int) a4;
+ } */ *uap = v;
+ int error;
+
+#ifdef SYSVSHM
+ switch (SCARG(uap, which)) {
+ case 0: /* shmat */
+ return compat_10_sys_shmsys(p, uap, retval);
+
+ case 1: /* shmctl */
+ switch(SCARG(uap, a3)) {
+ case IBCS2_IPC_STAT:
+ {
+ struct ibcs2_shmid_ds *isp;
+ struct shmid_ds *sp;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ isp = (struct ibcs2_shmid_ds *)SCARG(uap, a4);
+ sp = stackgap_alloc(&sg, sizeof(*sp));
+ SCARG(uap, a4) = (int)sp;
+ error = compat_10_sys_shmsys(p, uap, retval);
+ if (!error) {
+ SCARG(uap, a4) = (int)isp;
+ isp = stackgap_alloc(&sg, sizeof(*isp));
+ cvt_shmid2ishmid(sp, isp);
+ error = copyout((caddr_t)isp,
+ (caddr_t)SCARG(uap, a4),
+ sizeof(*isp));
+ }
+ return error;
+ }
+ case IBCS2_IPC_SET:
+ {
+ struct ibcs2_shmid_ds *isp;
+ struct shmid_ds *sp;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ isp = stackgap_alloc(&sg, sizeof(*isp));
+ sp = stackgap_alloc(&sg, sizeof(*sp));
+ error = copyin((caddr_t)SCARG(uap, a4), (caddr_t)isp,
+ sizeof(*isp));
+ if (error)
+ return error;
+ cvt_ishmid2shmid(isp, sp);
+ SCARG(uap, a4) = (int)sp;
+ return compat_10_sys_shmsys(p, uap, retval);
+ }
+ }
+ return compat_10_sys_shmsys(p, uap, retval);
+
+ case 2: /* shmdt */
+ return compat_10_sys_shmsys(p, uap, retval);
+
+ case 3: /* shmget */
+ return compat_10_sys_shmsys(p, uap, retval);
+ }
+#endif
+ return EINVAL;
+}
diff --git a/sys/compat/ibcs2/ibcs2_misc.c b/sys/compat/ibcs2/ibcs2_misc.c
new file mode 100644
index 00000000000..b4be03db094
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_misc.c
@@ -0,0 +1,1398 @@
+/* $NetBSD: ibcs2_misc.c,v 1.11 1995/10/09 11:24:01 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Scott Bartram
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * 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, Lawrence Berkeley Laboratory.
+ *
+ * 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: Header: sun_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
+ *
+ * @(#)sun_misc.c 8.1 (Berkeley) 6/18/93
+ */
+
+/*
+ * IBCS2 compatibility module.
+ *
+ * IBCS2 system calls that are implemented differently in BSD are
+ * handled here.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/dir.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/reboot.h>
+#include <sys/resource.h>
+#include <sys/resourcevar.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/times.h>
+#include <sys/vnode.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <sys/utsname.h>
+#include <sys/unistd.h>
+
+#include <netinet/in.h>
+#include <sys/syscallargs.h>
+
+#include <miscfs/specfs/specdev.h>
+
+#include <vm/vm.h>
+#include <sys/sysctl.h> /* must be included after vm.h */
+
+#include <i386/include/reg.h>
+
+#include <compat/ibcs2/ibcs2_types.h>
+#include <compat/ibcs2/ibcs2_dirent.h>
+#include <compat/ibcs2/ibcs2_fcntl.h>
+#include <compat/ibcs2/ibcs2_time.h>
+#include <compat/ibcs2/ibcs2_signal.h>
+#include <compat/ibcs2/ibcs2_timeb.h>
+#include <compat/ibcs2/ibcs2_unistd.h>
+#include <compat/ibcs2/ibcs2_utsname.h>
+#include <compat/ibcs2/ibcs2_util.h>
+#include <compat/ibcs2/ibcs2_utime.h>
+#include <compat/ibcs2/ibcs2_syscallargs.h>
+
+
+int
+ibcs2_sys_ulimit(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_ulimit_args /* {
+ syscallarg(int) cmd;
+ syscallarg(int) newlimit;
+ } */ *uap = v;
+ int error;
+ struct rlimit rl;
+ struct sys_setrlimit_args sra;
+#define IBCS2_GETFSIZE 1
+#define IBCS2_SETFSIZE 2
+#define IBCS2_GETPSIZE 3
+#define IBCS2_GETDTABLESIZE 4
+
+ switch (SCARG(uap, cmd)) {
+ case IBCS2_GETFSIZE:
+ *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur;
+ return 0;
+ case IBCS2_SETFSIZE: /* XXX - fix this */
+#ifdef notyet
+ rl.rlim_cur = SCARG(uap, newlimit);
+ sra.which = RLIMIT_FSIZE;
+ sra.rlp = &rl;
+ error = setrlimit(p, &sra, retval);
+ if (!error)
+ *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur;
+ else
+ DPRINTF(("failed "));
+ return error;
+#else
+ *retval = SCARG(uap, newlimit);
+ return 0;
+#endif
+ case IBCS2_GETPSIZE:
+ *retval = p->p_rlimit[RLIMIT_RSS].rlim_cur; /* XXX */
+ return 0;
+ case IBCS2_GETDTABLESIZE:
+ uap->cmd = IBCS2_SC_OPEN_MAX;
+ return ibcs2_sys_sysconf(p, uap, retval);
+ default:
+ return ENOSYS;
+ }
+}
+
+int
+ibcs2_sys_waitsys(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_waitsys_args /* {
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ } */ *uap = v;
+ int error, status;
+ struct sys_wait4_args w4;
+#define WAITPID_EFLAGS 0x8c4 /* OF, SF, ZF, PF */
+
+ SCARG(&w4, rusage) = NULL;
+ if ((p->p_md.md_regs->tf_eflags & WAITPID_EFLAGS) == WAITPID_EFLAGS) {
+ /* waitpid */
+ SCARG(&w4, pid) = SCARG(uap, a1);
+ SCARG(&w4, status) = (int *)SCARG(uap, a2);
+ SCARG(&w4, options) = SCARG(uap, a3);
+ } else {
+ /* wait */
+ SCARG(&w4, pid) = WAIT_ANY;
+ SCARG(&w4, status) = (int *)SCARG(uap, a1);
+ SCARG(&w4, options) = 0;
+ }
+ if ((error = sys_wait4(p, &w4, retval)) != 0)
+ return error;
+ if (SCARG(&w4, status)) /* this is real iBCS brain-damage */
+ return copyin((caddr_t)SCARG(&w4, status), (caddr_t)&retval[1],
+ sizeof(SCARG(&w4, status)));
+ return 0;
+}
+
+int
+ibcs2_sys_execv(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_execv_args /* {
+ syscallarg(char *) path;
+ syscallarg(char **) argp;
+ } */ *uap = v;
+ struct sys_execve_args ea;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ SCARG(&ea, path) = SCARG(uap, path);
+ SCARG(&ea, argp) = SCARG(uap, argp);
+ SCARG(&ea, envp) = NULL;
+ return sys_execve(p, &ea, retval);
+}
+
+int
+ibcs2_sys_execve(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sys_execve_args /* {
+ syscallarg(char *) path;
+ syscallarg(char **) argp;
+ syscallarg(char **) envp;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_execve(p, uap, retval);
+}
+
+int
+ibcs2_sys_umount(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_umount_args /* {
+ syscallarg(char *) name;
+ } */ *uap = v;
+ struct sys_unmount_args um;
+
+ SCARG(&um, path) = SCARG(uap, name);
+ SCARG(&um, flags) = 0;
+ return sys_unmount(p, &um, retval);
+}
+
+int
+ibcs2_sys_mount(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_mount_args /* {
+ syscallarg(char *) special;
+ syscallarg(char *) dir;
+ syscallarg(int) flags;
+ syscallarg(int) fstype;
+ syscallarg(char *) data;
+ syscallarg(int) len;
+ } */ *uap = v;
+#ifdef notyet
+ int oflags = SCARG(uap, flags), nflags, error;
+ char fsname[MFSNAMELEN];
+
+ if (oflags & (IBCS2_MS_NOSUB | IBCS2_MS_SYS5))
+ return (EINVAL);
+ if ((oflags & IBCS2_MS_NEWTYPE) == 0)
+ return (EINVAL);
+ nflags = 0;
+ if (oflags & IBCS2_MS_RDONLY)
+ nflags |= MNT_RDONLY;
+ if (oflags & IBCS2_MS_NOSUID)
+ nflags |= MNT_NOSUID;
+ if (oflags & IBCS2_MS_REMOUNT)
+ nflags |= MNT_UPDATE;
+ SCARG(uap, flags) = nflags;
+
+ if (error = copyinstr((caddr_t)SCARG(uap, type), fsname, sizeof fsname,
+ (u_int *)0))
+ return (error);
+
+ if (strncmp(fsname, "4.2", sizeof fsname) == 0) {
+ SCARG(uap, type) = (caddr_t)STACK_ALLOC();
+ if (error = copyout("ufs", SCARG(uap, type), sizeof("ufs")))
+ return (error);
+ } else if (strncmp(fsname, "nfs", sizeof fsname) == 0) {
+ struct ibcs2_nfs_args sna;
+ struct sockaddr_in sain;
+ struct nfs_args na;
+ struct sockaddr sa;
+
+ if (error = copyin(SCARG(uap, data), &sna, sizeof sna))
+ return (error);
+ if (error = copyin(sna.addr, &sain, sizeof sain))
+ return (error);
+ bcopy(&sain, &sa, sizeof sa);
+ sa.sa_len = sizeof(sain);
+ SCARG(uap, data) = (caddr_t)STACK_ALLOC();
+ na.addr = (struct sockaddr *)((int)SCARG(uap, data) + sizeof na);
+ na.sotype = SOCK_DGRAM;
+ na.proto = IPPROTO_UDP;
+ na.fh = (nfsv2fh_t *)sna.fh;
+ na.flags = sna.flags;
+ na.wsize = sna.wsize;
+ na.rsize = sna.rsize;
+ na.timeo = sna.timeo;
+ na.retrans = sna.retrans;
+ na.hostname = sna.hostname;
+
+ if (error = copyout(&sa, na.addr, sizeof sa))
+ return (error);
+ if (error = copyout(&na, SCARG(uap, data), sizeof na))
+ return (error);
+ }
+ return (sys_mount(p, uap, retval));
+#else
+ return EINVAL;
+#endif
+}
+
+/*
+ * Read iBCS2-style directory entries. We suck them into kernel space so
+ * that they can be massaged before being copied out to user code. Like
+ * SunOS, we squish out `empty' entries.
+ *
+ * This is quite ugly, but what do you expect from compatibility code?
+ */
+
+int
+ibcs2_sys_getdents(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct ibcs2_sys_getdents_args /* {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(int) nbytes;
+ } */ *uap = v;
+ register struct dirent *bdp;
+ struct vnode *vp;
+ caddr_t inp, buf; /* BSD-format */
+ int len, reclen; /* BSD-format */
+ caddr_t outp; /* iBCS2-format */
+ int resid, ibcs2_reclen;/* iBCS2-format */
+ struct file *fp;
+ struct uio auio;
+ struct iovec aiov;
+ struct ibcs2_dirent idb;
+ off_t off; /* true file offset */
+ int buflen, error, eofflag;
+ u_long *cookiebuf, *cookie;
+ int ncookies;
+
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ return (error);
+
+ if ((fp->f_flag & FREAD) == 0)
+ return (EBADF);
+
+ vp = (struct vnode *)fp->f_data;
+
+ if (vp->v_type != VDIR) /* XXX vnode readdir op should do this */
+ return (EINVAL);
+
+ buflen = min(MAXBSIZE, SCARG(uap, nbytes));
+ buf = malloc(buflen, M_TEMP, M_WAITOK);
+ ncookies = buflen / 16;
+ cookiebuf = malloc(ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK);
+ VOP_LOCK(vp);
+ off = fp->f_offset;
+again:
+ aiov.iov_base = buf;
+ aiov.iov_len = buflen;
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_rw = UIO_READ;
+ auio.uio_segflg = UIO_SYSSPACE;
+ auio.uio_procp = p;
+ auio.uio_resid = buflen;
+ auio.uio_offset = off;
+ /*
+ * First we read into the malloc'ed buffer, then
+ * we massage it into user space, one record at a time.
+ */
+ error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, cookiebuf,
+ ncookies);
+ if (error)
+ goto out;
+
+ inp = buf;
+ outp = SCARG(uap, buf);
+ resid = SCARG(uap, nbytes);
+ if ((len = buflen - auio.uio_resid) == 0)
+ goto eof;
+
+ for (cookie = cookiebuf; len > 0; len -= reclen) {
+ bdp = (struct dirent *)inp;
+ reclen = bdp->d_reclen;
+ if (reclen & 3)
+ panic("ibcs2_getdents");
+ off = *cookie++; /* each entry points to the next */
+ if (bdp->d_fileno == 0) {
+ inp += reclen; /* it is a hole; squish it out */
+ continue;
+ }
+ ibcs2_reclen = IBCS2_RECLEN(&idb, bdp->d_namlen);
+ if (reclen > len || resid < ibcs2_reclen) {
+ /* entry too big for buffer, so just stop */
+ outp++;
+ break;
+ }
+ /*
+ * Massage in place to make a iBCS2-shaped dirent (otherwise
+ * we have to worry about touching user memory outside of
+ * the copyout() call).
+ */
+ idb.d_ino = (ibcs2_ino_t)bdp->d_fileno;
+ idb.d_off = (ibcs2_off_t)off;
+ idb.d_reclen = (u_short)ibcs2_reclen;
+ strcpy(idb.d_name, bdp->d_name);
+ if ((error = copyout((caddr_t)&idb, outp, ibcs2_reclen)))
+ goto out;
+ /* advance past this real entry */
+ inp += reclen;
+ /* advance output past iBCS2-shaped entry */
+ outp += ibcs2_reclen;
+ resid -= ibcs2_reclen;
+ }
+
+ /* if we squished out the whole block, try again */
+ if (outp == SCARG(uap, buf))
+ goto again;
+ fp->f_offset = off; /* update the vnode offset */
+
+eof:
+ *retval = SCARG(uap, nbytes) - resid;
+out:
+ VOP_UNLOCK(vp);
+ free(cookiebuf, M_TEMP);
+ free(buf, M_TEMP);
+ return (error);
+}
+
+int
+ibcs2_sys_read(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_read_args /* {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(u_int) nbytes;
+ } */ *uap = v;
+ register struct dirent *bdp;
+ register struct vnode *vp;
+ register caddr_t inp, buf; /* BSD-format */
+ register int len, reclen; /* BSD-format */
+ register caddr_t outp; /* iBCS2-format */
+ register int resid; /* iBCS2-format */
+ struct file *fp;
+ struct uio auio;
+ struct iovec aiov;
+ struct ibcs2_direct {
+ ibcs2_ino_t ino;
+ char name[14];
+ } idb;
+ off_t off; /* true file offset */
+ int buflen, error, eofflag, size;
+ u_long *cookiebuf, *cookie;
+ int ncookies;
+
+ if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) {
+ if (error == EINVAL)
+ return sys_read(p, uap, retval);
+ else
+ return error;
+ }
+ if ((fp->f_flag & FREAD) == 0)
+ return (EBADF);
+ vp = (struct vnode *)fp->f_data;
+ if (vp->v_type != VDIR)
+ return sys_read(p, uap, retval);
+ DPRINTF(("ibcs2_read: read directory\n"));
+ buflen = max(MAXBSIZE, SCARG(uap, nbytes));
+ buf = malloc(buflen, M_TEMP, M_WAITOK);
+ ncookies = buflen / 16;
+ cookiebuf = malloc(ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK);
+ VOP_LOCK(vp);
+ off = fp->f_offset;
+again:
+ aiov.iov_base = buf;
+ aiov.iov_len = buflen;
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_rw = UIO_READ;
+ auio.uio_segflg = UIO_SYSSPACE;
+ auio.uio_procp = p;
+ auio.uio_resid = buflen;
+ auio.uio_offset = off;
+ /*
+ * First we read into the malloc'ed buffer, then
+ * we massage it into user space, one record at a time.
+ */
+ if (error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, cookiebuf,
+ ncookies)) {
+ DPRINTF(("VOP_READDIR failed: %d\n", error));
+ goto out;
+ }
+ inp = buf + off;
+ buflen -= off;
+ outp = SCARG(uap, buf);
+ resid = SCARG(uap, nbytes);
+ if ((len = buflen - auio.uio_resid) == 0)
+ goto eof;
+ for (cookie = cookiebuf; len > 0 && resid > 0; len -= reclen) {
+ bdp = (struct dirent *)inp;
+ reclen = bdp->d_reclen;
+ if (reclen & 3)
+ panic("ibcs2_read");
+ if (bdp->d_fileno == 0) {
+ inp += reclen; /* it is a hole; squish it out */
+ off = *cookie++;
+ continue;
+ }
+ if (reclen > len || resid < sizeof(struct ibcs2_direct)) {
+ /* entry too big for buffer, so just stop */
+ outp++;
+ break;
+ }
+ /*
+ * Massage in place to make a iBCS2-shaped dirent (otherwise
+ * we have to worry about touching user memory outside of
+ * the copyout() call).
+ *
+ * TODO: if length(filename) > 14, then break filename into
+ * multiple entries and set inode = 0xffff except last
+ */
+ idb.ino = (bdp->d_fileno > 0xfffe) ? 0xfffe : bdp->d_fileno;
+ (void)copystr(bdp->d_name, idb.name, 14, &size);
+ bzero(idb.name + size, 14 - size);
+ if (error = copyout(&idb, outp, sizeof(struct ibcs2_direct)))
+ goto out;
+ /* advance past this real entry */
+ off = *cookie++; /* each entry points to the next */
+ inp += reclen;
+ /* advance output past iBCS2-shaped entry */
+ outp += sizeof(struct ibcs2_direct);
+ resid -= sizeof(struct ibcs2_direct);
+ }
+ /* if we squished out the whole block, try again */
+ if (outp == SCARG(uap, buf))
+ goto again;
+ fp->f_offset = off; /* update the vnode offset */
+eof:
+ *retval = SCARG(uap, nbytes) - resid;
+out:
+ VOP_UNLOCK(vp);
+ free(buf, M_TEMP);
+ return (error);
+}
+
+int
+ibcs2_sys_mknod(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_mknod_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ syscallarg(int) dev;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+ if (S_ISFIFO(SCARG(uap, mode))) {
+ struct sys_mkfifo_args ap;
+ SCARG(&ap, path) = SCARG(uap, path);
+ SCARG(&ap, mode) = SCARG(uap, mode);
+ return sys_mkfifo(p, uap, retval);
+ } else {
+ struct sys_mknod_args ap;
+ SCARG(&ap, path) = SCARG(uap, path);
+ SCARG(&ap, mode) = SCARG(uap, mode);
+ SCARG(&ap, dev) = SCARG(uap, dev);
+ return sys_mknod(p, &ap, retval);
+ }
+}
+
+int
+ibcs2_sys_getgroups(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_getgroups_args /* {
+ syscallarg(int) gidsetsize;
+ syscallarg(ibcs2_gid_t *) gidset;
+ } */ *uap = v;
+ int error, i;
+ ibcs2_gid_t igid, *iset;
+ struct sys_getgroups_args sa;
+ gid_t *gp;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ SCARG(&sa, gidsetsize) = SCARG(uap, gidsetsize);
+ if (SCARG(uap, gidsetsize)) {
+ SCARG(&sa, gidset) = stackgap_alloc(&sg, NGROUPS_MAX *
+ sizeof(gid_t *));
+ iset = stackgap_alloc(&sg, SCARG(uap, gidsetsize) *
+ sizeof(ibcs2_gid_t));
+ }
+ if (error = sys_getgroups(p, &sa, retval))
+ return error;
+ for (i = 0, gp = SCARG(&sa, gidset); i < retval[0]; i++)
+ iset[i] = (ibcs2_gid_t)*gp++;
+ if (retval[0] && (error = copyout((caddr_t)iset,
+ (caddr_t)SCARG(uap, gidset),
+ sizeof(ibcs2_gid_t) * retval[0])))
+ return error;
+ return 0;
+}
+
+int
+ibcs2_sys_setgroups(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_setgroups_args /* {
+ syscallarg(int) gidsetsize;
+ syscallarg(ibcs2_gid_t *) gidset;
+ } */ *uap = v;
+ int error, i;
+ ibcs2_gid_t igid, *iset;
+ struct sys_setgroups_args sa;
+ gid_t *gp;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ SCARG(&sa, gidsetsize) = SCARG(uap, gidsetsize);
+ SCARG(&sa, gidset) = stackgap_alloc(&sg, SCARG(&sa, gidsetsize) *
+ sizeof(gid_t *));
+ iset = stackgap_alloc(&sg, SCARG(&sa, gidsetsize) *
+ sizeof(ibcs2_gid_t *));
+ if (SCARG(&sa, gidsetsize)) {
+ if (error = copyin((caddr_t)SCARG(uap, gidset), (caddr_t)iset,
+ sizeof(ibcs2_gid_t *) *
+ SCARG(uap, gidsetsize)))
+ return error;
+ }
+ for (i = 0, gp = SCARG(&sa, gidset); i < SCARG(&sa, gidsetsize); i++)
+ *gp++ = (gid_t)iset[i];
+ return sys_setgroups(p, &sa, retval);
+}
+
+int
+ibcs2_sys_setuid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_setuid_args /* {
+ syscallarg(int) uid;
+ } */ *uap = v;
+ struct sys_setuid_args sa;
+
+ SCARG(&sa, uid) = (uid_t)SCARG(uap, uid);
+ return sys_setuid(p, &sa, retval);
+}
+
+int
+ibcs2_sys_setgid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_setgid_args /* {
+ syscallarg(int) gid;
+ } */ *uap = v;
+ struct sys_setgid_args sa;
+
+ SCARG(&sa, gid) = (gid_t)SCARG(uap, gid);
+ return sys_setgid(p, &sa, retval);
+}
+
+int
+xenix_sys_ftime(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct xenix_sys_ftime_args /* {
+ syscallarg(struct xenix_timeb *) tp;
+ } */ *uap = v;
+ struct timeval tv;
+ extern struct timezone tz;
+ struct xenix_timeb itb;
+
+ microtime(&tv);
+ itb.time = tv.tv_sec;
+ itb.millitm = (tv.tv_usec / 1000);
+ itb.timezone = tz.tz_minuteswest;
+ itb.dstflag = tz.tz_dsttime;
+ return copyout((caddr_t)&itb, (caddr_t)SCARG(uap, tp), xenix_timeb_len);
+}
+
+int
+ibcs2_sys_time(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_time_args /* {
+ syscallarg(ibcs2_time_t *) tp;
+ } */ *uap = v;
+ struct timeval tv;
+
+ microtime(&tv);
+ *retval = tv.tv_sec;
+ if (SCARG(uap, tp))
+ return copyout((caddr_t)&tv.tv_sec, (caddr_t)SCARG(uap, tp),
+ sizeof(ibcs2_time_t));
+ else
+ return 0;
+}
+
+int
+ibcs2_sys_pathconf(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_pathconf_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) name;
+ } */ *uap = v;
+ SCARG(uap, name)++; /* iBCS2 _PC_* defines are offset by one */
+ return sys_pathconf(p, uap, retval);
+}
+
+int
+ibcs2_sys_fpathconf(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_fpathconf_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) name;
+ } */ *uap = v;
+ SCARG(uap, name)++; /* iBCS2 _PC_* defines are offset by one */
+ return sys_fpathconf(p, uap, retval);
+}
+
+int
+ibcs2_sys_sysconf(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_sysconf_args /* {
+ syscallarg(int) name;
+ } */ *uap = v;
+ int mib[2], value, len, error;
+ struct sys___sysctl_args sa;
+ struct sys_getrlimit_args ga;
+
+ switch(SCARG(uap, name)) {
+ case IBCS2_SC_ARG_MAX:
+ mib[1] = KERN_ARGMAX;
+ break;
+
+ case IBCS2_SC_CHILD_MAX:
+ {
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ SCARG(&ga, which) = RLIMIT_NPROC;
+ SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit *));
+ if (error = sys_getrlimit(p, &ga, retval))
+ return error;
+ *retval = SCARG(&ga, rlp)->rlim_cur;
+ return 0;
+ }
+
+ case IBCS2_SC_CLK_TCK:
+ *retval = hz;
+ return 0;
+
+ case IBCS2_SC_NGROUPS_MAX:
+ mib[1] = KERN_NGROUPS;
+ break;
+
+ case IBCS2_SC_OPEN_MAX:
+ {
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ SCARG(&ga, which) = RLIMIT_NOFILE;
+ SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit *));
+ if (error = sys_getrlimit(p, &ga, retval))
+ return error;
+ *retval = SCARG(&ga, rlp)->rlim_cur;
+ return 0;
+ }
+
+ case IBCS2_SC_JOB_CONTROL:
+ mib[1] = KERN_JOB_CONTROL;
+ break;
+
+ case IBCS2_SC_SAVED_IDS:
+ mib[1] = KERN_SAVED_IDS;
+ break;
+
+ case IBCS2_SC_VERSION:
+ mib[1] = KERN_POSIX1;
+ break;
+
+ case IBCS2_SC_PASS_MAX:
+ *retval = 128; /* XXX - should we create PASS_MAX ? */
+ return 0;
+
+ case IBCS2_SC_XOPEN_VERSION:
+ *retval = 2; /* XXX: What should that be? */
+ return 0;
+
+ default:
+ return EINVAL;
+ }
+
+ mib[0] = CTL_KERN;
+ len = sizeof(value);
+ SCARG(&sa, name) = mib;
+ SCARG(&sa, namelen) = 2;
+ SCARG(&sa, old) = &value;
+ SCARG(&sa, oldlenp) = &len;
+ SCARG(&sa, new) = NULL;
+ SCARG(&sa, newlen) = 0;
+ if (error = sys___sysctl(p, &sa, retval))
+ return error;
+ *retval = value;
+ return 0;
+}
+
+int
+ibcs2_sys_alarm(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_alarm_args /* {
+ syscallarg(unsigned) sec;
+ } */ *uap = v;
+ int error;
+ struct itimerval *itp, *oitp;
+ struct sys_setitimer_args sa;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ itp = stackgap_alloc(&sg, sizeof(*itp));
+ oitp = stackgap_alloc(&sg, sizeof(*oitp));
+ timerclear(&itp->it_interval);
+ itp->it_value.tv_sec = SCARG(uap, sec);
+ itp->it_value.tv_usec = 0;
+
+ SCARG(&sa, which) = ITIMER_REAL;
+ SCARG(&sa, itv) = itp;
+ SCARG(&sa, oitv) = oitp;
+ error = sys_setitimer(p, &sa, retval);
+ if (error)
+ return error;
+ if (oitp->it_value.tv_usec)
+ oitp->it_value.tv_sec++;
+ *retval = oitp->it_value.tv_sec;
+ return 0;
+}
+
+int
+ibcs2_sys_getmsg(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_getmsg_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct ibcs2_stropts *) ctl;
+ syscallarg(struct ibcs2_stropts *) dat;
+ syscallarg(int *) flags;
+ } */ *uap = v;
+
+ return 0;
+}
+
+int
+ibcs2_sys_putmsg(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_putmsg_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct ibcs2_stropts *) ctl;
+ syscallarg(struct ibcs2_stropts *) dat;
+ syscallarg(int) flags;
+ } */ *uap = v;
+
+ return 0;
+}
+
+int
+ibcs2_sys_times(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_times_args /* {
+ syscallarg(struct tms *) tp;
+ } */ *uap = v;
+ int error;
+ struct sys_getrusage_args ga;
+ struct tms tms;
+ struct timeval t;
+ caddr_t sg = stackgap_init(p->p_emul);
+ struct rusage *ru = stackgap_alloc(&sg, sizeof(*ru));
+#define CONVTCK(r) (r.tv_sec * hz + r.tv_usec / (1000000 / hz))
+
+ SCARG(&ga, who) = RUSAGE_SELF;
+ SCARG(&ga, rusage) = ru;
+ error = sys_getrusage(p, &ga, retval);
+ if (error)
+ return error;
+ tms.tms_utime = CONVTCK(ru->ru_utime);
+ tms.tms_stime = CONVTCK(ru->ru_stime);
+
+ SCARG(&ga, who) = RUSAGE_CHILDREN;
+ error = sys_getrusage(p, &ga, retval);
+ if (error)
+ return error;
+ tms.tms_cutime = CONVTCK(ru->ru_utime);
+ tms.tms_cstime = CONVTCK(ru->ru_stime);
+
+ microtime(&t);
+ *retval = CONVTCK(t);
+
+ return copyout((caddr_t)&tms, (caddr_t)SCARG(uap, tp),
+ sizeof(struct tms));
+}
+
+int
+ibcs2_sys_stime(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_stime_args /* {
+ syscallarg(long *) timep;
+ } */ *uap = v;
+ int error;
+ struct sys_settimeofday_args sa;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ SCARG(&sa, tv) = stackgap_alloc(&sg, sizeof(*SCARG(&sa, tv)));
+ SCARG(&sa, tzp) = NULL;
+ if (error = copyin((caddr_t)SCARG(uap, timep),
+ &(SCARG(&sa, tv)->tv_sec), sizeof(long)))
+ return error;
+ SCARG(&sa, tv)->tv_usec = 0;
+ if (error = sys_settimeofday(p, &sa, retval))
+ return EPERM;
+ return 0;
+}
+
+int
+ibcs2_sys_utime(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_utime_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct ibcs2_utimbuf *) buf;
+ } */ *uap = v;
+ int error;
+ struct sys_utimes_args sa;
+ struct timeval *tp;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ SCARG(&sa, path) = SCARG(uap, path);
+ if (SCARG(uap, buf)) {
+ struct ibcs2_utimbuf ubuf;
+
+ if (error = copyin((caddr_t)SCARG(uap, buf), (caddr_t)&ubuf,
+ sizeof(ubuf)))
+ return error;
+ SCARG(&sa, tptr) = stackgap_alloc(&sg,
+ 2 * sizeof(struct timeval *));
+ tp = (struct timeval *)SCARG(&sa, tptr);
+ tp->tv_sec = ubuf.actime;
+ tp->tv_usec = 0;
+ tp++;
+ tp->tv_sec = ubuf.modtime;
+ tp->tv_usec = 0;
+ } else
+ SCARG(&sa, tptr) = NULL;
+ return sys_utimes(p, &sa, retval);
+}
+
+int
+ibcs2_sys_nice(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_nice_args /* {
+ syscallarg(int) incr;
+ } */ *uap = v;
+ int error, cur_nice = p->p_nice;
+ struct sys_setpriority_args sa;
+
+ SCARG(&sa, which) = PRIO_PROCESS;
+ SCARG(&sa, who) = 0;
+ SCARG(&sa, prio) = p->p_nice + SCARG(uap, incr);
+ if (error = sys_setpriority(p, &sa, retval))
+ return EPERM;
+ *retval = p->p_nice;
+ return 0;
+}
+
+/*
+ * iBCS2 getpgrp, setpgrp, setsid, and setpgid
+ */
+
+int
+ibcs2_sys_pgrpsys(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_pgrpsys_args /* {
+ syscallarg(int) type;
+ syscallarg(caddr_t) dummy;
+ syscallarg(int) pid;
+ syscallarg(int) pgid;
+ } */ *uap = v;
+ switch (SCARG(uap, type)) {
+ case 0: /* getpgrp */
+ *retval = p->p_pgrp->pg_id;
+ return 0;
+
+ case 1: /* setpgrp */
+ {
+ struct sys_setpgid_args sa;
+
+ SCARG(&sa, pid) = 0;
+ SCARG(&sa, pgid) = 0;
+ sys_setpgid(p, &sa, retval);
+ *retval = p->p_pgrp->pg_id;
+ return 0;
+ }
+
+ case 2: /* setpgid */
+ {
+ struct sys_setpgid_args sa;
+
+ SCARG(&sa, pid) = SCARG(uap, pid);
+ SCARG(&sa, pgid) = SCARG(uap, pgid);
+ return sys_setpgid(p, &sa, retval);
+ }
+
+ case 3: /* setsid */
+ return sys_setsid(p, NULL, retval);
+
+ default:
+ return EINVAL;
+ }
+}
+
+/*
+ * XXX - need to check for nested calls
+ */
+
+int
+ibcs2_sys_plock(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_plock_args /* {
+ syscallarg(int) cmd;
+ } */ *uap = v;
+ int error;
+#define IBCS2_UNLOCK 0
+#define IBCS2_PROCLOCK 1
+#define IBCS2_TEXTLOCK 2
+#define IBCS2_DATALOCK 4
+
+
+ if (error = suser(p->p_ucred, &p->p_acflag))
+ return EPERM;
+ switch(SCARG(uap, cmd)) {
+ case IBCS2_UNLOCK:
+ case IBCS2_PROCLOCK:
+ case IBCS2_TEXTLOCK:
+ case IBCS2_DATALOCK:
+ return 0; /* XXX - TODO */
+ }
+ return EINVAL;
+}
+
+int
+ibcs2_sys_uadmin(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_uadmin_args /* {
+ syscallarg(int) cmd;
+ syscallarg(int) func;
+ syscallarg(caddr_t) data;
+ } */ *uap = v;
+ int error;
+
+#define SCO_A_REBOOT 1
+#define SCO_A_SHUTDOWN 2
+#define SCO_A_REMOUNT 4
+#define SCO_A_CLOCK 8
+#define SCO_A_SETCONFIG 128
+#define SCO_A_GETDEV 130
+
+#define SCO_AD_HALT 0
+#define SCO_AD_BOOT 1
+#define SCO_AD_IBOOT 2
+#define SCO_AD_PWRDOWN 3
+#define SCO_AD_PWRNAP 4
+
+#define SCO_AD_PANICBOOT 1
+
+#define SCO_AD_GETBMAJ 0
+#define SCO_AD_GETCMAJ 1
+
+ /* XXX: is this the right place for this call? */
+ if (error = suser(p->p_ucred, &p->p_acflag))
+ return (error);
+
+ switch(SCARG(uap, cmd)) {
+ case SCO_A_REBOOT:
+ case SCO_A_SHUTDOWN:
+ switch(SCARG(uap, func)) {
+ case SCO_AD_HALT:
+ case SCO_AD_PWRDOWN:
+ case SCO_AD_PWRNAP:
+ boot(RB_HALT);
+ case SCO_AD_BOOT:
+ case SCO_AD_IBOOT:
+ boot(RB_AUTOBOOT);
+ }
+ return EINVAL;
+ case SCO_A_REMOUNT:
+ case SCO_A_CLOCK:
+ case SCO_A_SETCONFIG:
+ return 0;
+ case SCO_A_GETDEV:
+ return EINVAL; /* XXX - TODO */
+ }
+ return EINVAL;
+}
+
+int
+ibcs2_sys_sysfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_sysfs_args /* {
+ syscallarg(int) cmd;
+ syscallarg(caddr_t) d1;
+ syscallarg(char *) buf;
+ } */ *uap = v;
+
+#define IBCS2_GETFSIND 1
+#define IBCS2_GETFSTYP 2
+#define IBCS2_GETNFSTYP 3
+
+ switch(SCARG(uap, cmd)) {
+ case IBCS2_GETFSIND:
+ case IBCS2_GETFSTYP:
+ case IBCS2_GETNFSTYP:
+ }
+ return EINVAL; /* XXX - TODO */
+}
+
+int
+ibcs2_sys_poll(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_poll_args /* {
+ syscallarg(struct ibcs2_pollfd *) fds;
+ syscallarg(long) nfds;
+ syscallarg(int) timeout;
+ } */ *uap = v;
+
+ return EINVAL; /* XXX - TODO */
+}
+
+int
+xenix_sys_rdchk(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct xenix_sys_rdchk_args /* {
+ syscallarg(int) fd;
+ } */ *uap = v;
+ int error;
+ struct sys_ioctl_args sa;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ SCARG(&sa, fd) = SCARG(uap, fd);
+ SCARG(&sa, com) = FIONREAD;
+ SCARG(&sa, data) = stackgap_alloc(&sg, sizeof(int));
+ if (error = sys_ioctl(p, &sa, retval))
+ return error;
+ *retval = (*((int*)SCARG(&sa, data))) ? 1 : 0;
+ return 0;
+}
+
+int
+xenix_sys_chsize(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct xenix_sys_chsize_args /* {
+ syscallarg(int) fd;
+ syscallarg(long) size;
+ } */ *uap = v;
+ struct sys_ftruncate_args sa;
+
+ SCARG(&sa, fd) = SCARG(uap, fd);
+ SCARG(&sa, pad) = 0;
+ SCARG(&sa, length) = SCARG(uap, size);
+ return sys_ftruncate(p, &sa, retval);
+}
+
+int
+xenix_sys_nap(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct xenix_sys_nap_args /* {
+ syscallarg(int) millisec;
+ } */ *uap = v;
+
+ return ENOSYS;
+}
+
+int
+ibcs2_sys_unlink(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_unlink_args /* {
+ syscallarg(char *) path;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_unlink(p, uap, retval);
+}
+
+int
+ibcs2_sys_chdir(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_chdir_args /* {
+ syscallarg(char *) path;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_chdir(p, uap, retval);
+}
+
+int
+ibcs2_sys_chmod(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_chmod_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_chmod(p, uap, retval);
+}
+
+int
+ibcs2_sys_chown(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_chown_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) uid;
+ syscallarg(int) gid;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_chown(p, uap, retval);
+}
+
+int
+ibcs2_sys_rmdir(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_rmdir_args /* {
+ syscallarg(char *) path;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_rmdir(p, uap, retval);
+}
+
+int
+ibcs2_sys_mkdir(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_mkdir_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+ return sys_mkdir(p, uap, retval);
+}
+
+int
+ibcs2_sys_symlink(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_symlink_args /* {
+ syscallarg(char *) path;
+ syscallarg(char *) link;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ IBCS2_CHECK_ALT_CREAT(p, &sg, SCARG(uap, link));
+ return sys_symlink(p, uap, retval);
+}
+
+int
+ibcs2_sys_rename(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_rename_args /* {
+ syscallarg(char *) from;
+ syscallarg(char *) to;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, from));
+ IBCS2_CHECK_ALT_CREAT(p, &sg, SCARG(uap, to));
+ return sys_rename(p, uap, retval);
+}
+
+int
+ibcs2_sys_readlink(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_readlink_args /* {
+ syscallarg(char *) path;
+ syscallarg(char *) buf;
+ syscallarg(int) count;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ return sys_readlink(p, uap, retval);
+}
diff --git a/sys/compat/ibcs2/ibcs2_mount.h b/sys/compat/ibcs2/ibcs2_mount.h
new file mode 100644
index 00000000000..d1b9aaaedc2
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_mount.h
@@ -0,0 +1,41 @@
+/* $NetBSD: ibcs2_mount.h,v 1.2 1994/10/26 02:53:00 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_MOUNT_H
+#define _IBCS2_MOUNT_H
+
+#define IBCS2_MS_RDONLY 0x01
+#define IBCS2_MS_FSS 0x02
+#define IBCS2_MS_DATA 0x04
+#define IBCS2_MS_CACHE 0x08
+
+#endif /* _IBCS2_MOUNT_H */
diff --git a/sys/compat/ibcs2/ibcs2_pwd.h b/sys/compat/ibcs2/ibcs2_pwd.h
new file mode 100644
index 00000000000..5a845ef580e
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_pwd.h
@@ -0,0 +1,48 @@
+/* $NetBSD: ibcs2_pwd.h,v 1.2 1994/10/26 02:53:01 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_PWD_H
+#define _IBCS2_PWD_H
+
+struct ibcs2_passwd {
+ char *pw_name;
+ char *pw_passwd;
+ int pw_uid;
+ int pw_gid;
+ char *pw_age;
+ char *pw_comment;
+ char *pw_gecos;
+ char *pw_dir;
+ char *pw_shell;
+};
+
+#endif /* _IBCS2_PWD_H */
diff --git a/sys/compat/ibcs2/ibcs2_signal.c b/sys/compat/ibcs2/ibcs2_signal.c
new file mode 100644
index 00000000000..9a024767192
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_signal.c
@@ -0,0 +1,492 @@
+/* $NetBSD: ibcs2_signal.c,v 1.7 1995/10/07 06:26:52 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1995 Scott Bartram
+ * 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/namei.h>
+#include <sys/proc.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/kernel.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/malloc.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/ibcs2/ibcs2_types.h>
+#include <compat/ibcs2/ibcs2_signal.h>
+#include <compat/ibcs2/ibcs2_syscallargs.h>
+#include <compat/ibcs2/ibcs2_util.h>
+
+#define sigemptyset(s) bzero((s), sizeof(*(s)))
+#define sigismember(s, n) (*(s) & sigmask(n))
+#define sigaddset(s, n) (*(s) |= sigmask(n))
+
+#define ibcs2_sigmask(n) (1 << ((n) - 1))
+#define ibcs2_sigemptyset(s) bzero((s), sizeof(*(s)))
+#define ibcs2_sigismember(s, n) (*(s) & ibcs2_sigmask(n))
+#define ibcs2_sigaddset(s, n) (*(s) |= ibcs2_sigmask(n))
+
+int bsd_to_ibcs2_sig[] = {
+ 0, /* 0 */
+ IBCS2_SIGHUP, /* 1 */
+ IBCS2_SIGINT, /* 2 */
+ IBCS2_SIGQUIT, /* 3 */
+ IBCS2_SIGILL, /* 4 */
+ IBCS2_SIGTRAP, /* 5 */
+ IBCS2_SIGABRT, /* 6 */
+ IBCS2_SIGEMT, /* 7 */
+ IBCS2_SIGFPE, /* 8 */
+ IBCS2_SIGKILL, /* 9 */
+ IBCS2_SIGBUS, /* 10 */
+ IBCS2_SIGSEGV, /* 11 */
+ IBCS2_SIGSYS, /* 12 */
+ IBCS2_SIGPIPE, /* 13 */
+ IBCS2_SIGALRM, /* 14 */
+ IBCS2_SIGTERM, /* 15 */
+ 0, /* 16 - SIGURG */
+ IBCS2_SIGSTOP, /* 17 */
+ IBCS2_SIGTSTP, /* 18 */
+ IBCS2_SIGCONT, /* 19 */
+ IBCS2_SIGCLD, /* 20 */
+ IBCS2_SIGTTIN, /* 21 */
+ IBCS2_SIGTTOU, /* 22 */
+ IBCS2_SIGPOLL, /* 23 */
+ 0, /* 24 - SIGXCPU */
+ 0, /* 25 - SIGXFSZ */
+ IBCS2_SIGVTALRM, /* 26 */
+ IBCS2_SIGPROF, /* 27 */
+ IBCS2_SIGWINCH, /* 28 */
+ 0, /* 29 */
+ IBCS2_SIGUSR1, /* 30 */
+ IBCS2_SIGUSR2, /* 31 */
+};
+
+int ibcs2_to_bsd_sig[] = {
+ 0, /* 0 */
+ SIGHUP, /* 1 */
+ SIGINT, /* 2 */
+ SIGQUIT, /* 3 */
+ SIGILL, /* 4 */
+ SIGTRAP, /* 5 */
+ SIGABRT, /* 6 */
+ SIGEMT, /* 7 */
+ SIGFPE, /* 8 */
+ SIGKILL, /* 9 */
+ SIGBUS, /* 10 */
+ SIGSEGV, /* 11 */
+ SIGSYS, /* 12 */
+ SIGPIPE, /* 13 */
+ SIGALRM, /* 14 */
+ SIGTERM, /* 15 */
+ SIGUSR1, /* 16 */
+ SIGUSR2, /* 17 */
+ SIGCHLD, /* 18 */
+ 0, /* 19 - SIGPWR */
+ SIGWINCH, /* 20 */
+ 0, /* 21 */
+ SIGIO, /* 22 */
+ SIGSTOP, /* 23 */
+ SIGTSTP, /* 24 */
+ SIGCONT, /* 25 */
+ SIGTTIN, /* 26 */
+ SIGTTOU, /* 27 */
+ SIGVTALRM, /* 28 */
+ SIGPROF, /* 29 */
+ 0, /* 30 */
+ 0, /* 31 */
+};
+
+void
+ibcs2_to_bsd_sigset(iss, bss)
+ const ibcs2_sigset_t *iss;
+ sigset_t *bss;
+{
+ int i, newsig;
+
+ sigemptyset(bss);
+ for (i = 1; i < IBCS2_NSIG; i++) {
+ if (ibcs2_sigismember(iss, i)) {
+ newsig = ibcs2_to_bsd_sig[i];
+ if (newsig)
+ sigaddset(bss, newsig);
+ }
+ }
+}
+
+void
+bsd_to_ibcs2_sigset(bss, iss)
+ const sigset_t *bss;
+ ibcs2_sigset_t *iss;
+{
+ int i, newsig;
+
+ ibcs2_sigemptyset(iss);
+ for (i = 1; i < NSIG; i++) {
+ if (sigismember(bss, i)) {
+ newsig = bsd_to_ibcs2_sig[i];
+ if (newsig)
+ ibcs2_sigaddset(iss, newsig);
+ }
+ }
+}
+
+void
+ibcs2_to_bsd_sigaction(isa, bsa)
+ struct ibcs2_sigaction *isa;
+ struct sigaction *bsa;
+{
+
+ bsa->sa_handler = isa->sa_handler;
+ ibcs2_to_bsd_sigset(&isa->sa_mask, &bsa->sa_mask);
+ bsa->sa_flags = 0;
+ if ((isa->sa_flags & IBCS2_SA_NOCLDSTOP) != 0)
+ bsa->sa_flags |= SA_NOCLDSTOP;
+}
+
+void
+bsd_to_ibcs2_sigaction(bsa, isa)
+ struct sigaction *bsa;
+ struct ibcs2_sigaction *isa;
+{
+
+ isa->sa_handler = bsa->sa_handler;
+ bsd_to_ibcs2_sigset(&bsa->sa_mask, &isa->sa_mask);
+ isa->sa_flags = 0;
+ if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
+ isa->sa_flags |= SA_NOCLDSTOP;
+}
+
+int
+ibcs2_sys_sigaction(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_sigaction_args /* {
+ syscallarg(int) signum;
+ syscallarg(struct ibcs2_sigaction *) nsa;
+ syscallarg(struct ibcs2_sigaction *) osa;
+ } */ *uap = v;
+ struct ibcs2_sigaction *nisa, *oisa, tmpisa;
+ struct sigaction *nbsa, *obsa, tmpbsa;
+ struct sys_sigaction_args sa;
+ caddr_t sg;
+ int error;
+
+ sg = stackgap_init(p->p_emul);
+ nisa = SCARG(uap, nsa);
+ oisa = SCARG(uap, osa);
+
+ if (oisa != NULL)
+ obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ else
+ obsa = NULL;
+
+ if (nisa != NULL) {
+ nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ if ((error = copyin(nisa, &tmpisa, sizeof(tmpisa))) != 0)
+ return error;
+ ibcs2_to_bsd_sigaction(&tmpisa, &tmpbsa);
+ if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0)
+ return error;
+ } else
+ nbsa = NULL;
+
+ SCARG(&sa, signum) = ibcs2_to_bsd_sig[SCARG(uap, signum)];
+ SCARG(&sa, nsa) = nbsa;
+ SCARG(&sa, osa) = obsa;
+
+ if ((error = sys_sigaction(p, &sa, retval)) != 0)
+ return error;
+
+ if (oisa != NULL) {
+ if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0)
+ return error;
+ bsd_to_ibcs2_sigaction(&tmpbsa, &tmpisa);
+ if ((error = copyout(&tmpisa, oisa, sizeof(tmpisa))) != 0)
+ return error;
+ }
+
+ return 0;
+}
+
+int
+ibcs2_sys_sigsys(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_sigsys_args /* {
+ syscallarg(int) sig;
+ syscallarg(ibcs2_sig_t) fp;
+ } */ *uap = v;
+ int signum = ibcs2_to_bsd_sig[IBCS2_SIGNO(SCARG(uap, sig))];
+ int error;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ if (signum <= 0 || signum >= IBCS2_NSIG) {
+ if (IBCS2_SIGCALL(SCARG(uap, sig)) == IBCS2_SIGNAL_MASK ||
+ IBCS2_SIGCALL(SCARG(uap, sig)) == IBCS2_SIGSET_MASK)
+ *retval = (int)IBCS2_SIG_ERR;
+ return EINVAL;
+ }
+
+ switch (IBCS2_SIGCALL(SCARG(uap, sig))) {
+ /*
+ * sigset is identical to signal() except that SIG_HOLD is allowed as
+ * an action.
+ */
+ case IBCS2_SIGSET_MASK:
+ /*
+ * sigset is identical to signal() except
+ * that SIG_HOLD is allowed as
+ * an action.
+ */
+ if (SCARG(uap, fp) == IBCS2_SIG_HOLD) {
+ struct sys_sigprocmask_args sa;
+
+ SCARG(&sa, how) = SIG_BLOCK;
+ SCARG(&sa, mask) = sigmask(signum);
+ return sys_sigprocmask(p, &sa, retval);
+ }
+ /* FALLTHROUGH */
+
+ case IBCS2_SIGNAL_MASK:
+ {
+ struct sys_sigaction_args sa_args;
+ struct sigaction *nbsa, *obsa, sa;
+
+ nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ SCARG(&sa_args, signum) = signum;
+ SCARG(&sa_args, nsa) = nbsa;
+ SCARG(&sa_args, osa) = obsa;
+
+ sa.sa_handler = SCARG(uap, fp);
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+#if 0
+ if (signum != SIGALRM)
+ sa.sa_flags = SA_RESTART;
+#endif
+ if ((error = copyout(&sa, nbsa, sizeof(sa))) != 0)
+ return error;
+ if ((error = sys_sigaction(p, &sa_args, retval)) != 0) {
+ DPRINTF(("signal: sigaction failed: %d\n",
+ error));
+ *retval = (int)IBCS2_SIG_ERR;
+ return error;
+ }
+ if ((error = copyin(obsa, &sa, sizeof(sa))) != 0)
+ return error;
+ *retval = (int)sa.sa_handler;
+ return 0;
+ }
+
+ case IBCS2_SIGHOLD_MASK:
+ {
+ struct sys_sigprocmask_args sa;
+
+ SCARG(&sa, how) = SIG_BLOCK;
+ SCARG(&sa, mask) = sigmask(signum);
+ return sys_sigprocmask(p, &sa, retval);
+ }
+
+ case IBCS2_SIGRELSE_MASK:
+ {
+ struct sys_sigprocmask_args sa;
+
+ SCARG(&sa, how) = SIG_UNBLOCK;
+ SCARG(&sa, mask) = sigmask(signum);
+ return sys_sigprocmask(p, &sa, retval);
+ }
+
+ case IBCS2_SIGIGNORE_MASK:
+ {
+ struct sys_sigaction_args sa_args;
+ struct sigaction *bsa, sa;
+
+ bsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ SCARG(&sa_args, signum) = signum;
+ SCARG(&sa_args, nsa) = bsa;
+ SCARG(&sa_args, osa) = NULL;
+
+ sa.sa_handler = SIG_IGN;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ if ((error = copyout(&sa, bsa, sizeof(sa))) != 0)
+ return error;
+ if ((error = sys_sigaction(p, &sa_args, retval)) != 0) {
+ DPRINTF(("sigignore: sigaction failed\n"));
+ return error;
+ }
+ return 0;
+ }
+
+ case IBCS2_SIGPAUSE_MASK:
+ {
+ struct sys_sigsuspend_args sa;
+
+ SCARG(&sa, mask) = p->p_sigmask &~ sigmask(signum);
+ return sys_sigsuspend(p, &sa, retval);
+ }
+
+ default:
+ return ENOSYS;
+ }
+}
+
+int
+ibcs2_sys_sigprocmask(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_sigprocmask_args /* {
+ syscallarg(int) how;
+ syscallarg(ibcs2_sigset_t *) set;
+ syscallarg(ibcs2_sigset_t *) oset;
+ } */ *uap = v;
+ ibcs2_sigset_t iss;
+ sigset_t bss;
+ int error = 0;
+
+ if (SCARG(uap, oset) != NULL) {
+ /* Fix the return value first if needed */
+ bsd_to_ibcs2_sigset(&p->p_sigmask, &iss);
+ if ((error = copyout(&iss, SCARG(uap, oset), sizeof(iss))) != 0)
+ return error;
+ }
+
+ if (SCARG(uap, set) == NULL)
+ /* Just examine */
+ return 0;
+
+ if ((error = copyin(SCARG(uap, set), &iss, sizeof(iss))) != 0)
+ return error;
+
+ ibcs2_to_bsd_sigset(&iss, &bss);
+
+ (void) splhigh();
+
+ switch (SCARG(uap, how)) {
+ case IBCS2_SIG_BLOCK:
+ p->p_sigmask |= bss & ~sigcantmask;
+ break;
+
+ case IBCS2_SIG_UNBLOCK:
+ p->p_sigmask &= ~bss;
+ break;
+
+ case IBCS2_SIG_SETMASK:
+ p->p_sigmask = bss & ~sigcantmask;
+ break;
+
+ default:
+ error = EINVAL;
+ break;
+ }
+
+ (void) spl0();
+
+ return error;
+}
+
+int
+ibcs2_sys_sigpending(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_sigpending_args /* {
+ syscallarg(ibcs2_sigset_t *) mask;
+ } */ *uap = v;
+ sigset_t bss;
+ ibcs2_sigset_t iss;
+
+ bss = p->p_siglist & p->p_sigmask;
+ bsd_to_ibcs2_sigset(&bss, &iss);
+
+ return copyout(&iss, SCARG(uap, mask), sizeof(iss));
+}
+
+int
+ibcs2_sys_sigsuspend(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_sigsuspend_args /* {
+ syscallarg(ibcs2_sigset_t *) mask;
+ } */ *uap = v;
+ ibcs2_sigset_t sss;
+ sigset_t bss;
+ struct sys_sigsuspend_args sa;
+ int error;
+
+ if ((error = copyin(SCARG(uap, mask), &sss, sizeof(sss))) != 0)
+ return error;
+
+ ibcs2_to_bsd_sigset(&sss, &bss);
+
+ SCARG(&sa, mask) = bss;
+ return sys_sigsuspend(p, &sa, retval);
+}
+
+int
+ibcs2_sys_pause(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sys_sigsuspend_args bsa;
+
+ SCARG(&bsa, mask) = p->p_sigmask;
+ return sys_sigsuspend(p, &bsa, retval);
+}
+
+int
+ibcs2_sys_kill(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_kill_args /* {
+ syscallarg(int) pid;
+ syscallarg(int) signo;
+ } */ *uap = v;
+ struct sys_kill_args ka;
+
+ SCARG(&ka, pid) = SCARG(uap, pid);
+ SCARG(&ka, signum) = ibcs2_to_bsd_sig[SCARG(uap, signo)];
+ return sys_kill(p, &ka, retval);
+}
diff --git a/sys/compat/ibcs2/ibcs2_signal.h b/sys/compat/ibcs2/ibcs2_signal.h
new file mode 100644
index 00000000000..2858688d79d
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_signal.h
@@ -0,0 +1,105 @@
+/* $NetBSD: ibcs2_signal.h,v 1.7 1995/08/14 02:26:01 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_SIGNAL_H
+#define _IBCS2_SIGNAL_H
+
+#define IBCS2_SIGHUP 1
+#define IBCS2_SIGINT 2
+#define IBCS2_SIGQUIT 3
+#define IBCS2_SIGILL 4
+#define IBCS2_SIGTRAP 5
+#define IBCS2_SIGIOT 6
+#define IBCS2_SIGABRT 6
+#define IBCS2_SIGEMT 7
+#define IBCS2_SIGFPE 8
+#define IBCS2_SIGKILL 9
+#define IBCS2_SIGBUS 10
+#define IBCS2_SIGSEGV 11
+#define IBCS2_SIGSYS 12
+#define IBCS2_SIGPIPE 13
+#define IBCS2_SIGALRM 14
+#define IBCS2_SIGTERM 15
+#define IBCS2_SIGUSR1 16
+#define IBCS2_SIGUSR2 17
+#define IBCS2_SIGCLD 18
+#define IBCS2_SIGPWR 19
+#define IBCS2_SIGWINCH 20
+#define IBCS2_SIGPOLL 22
+#define IBCS2_NSIG 32
+
+/*
+ * SCO-specific
+ */
+#define IBCS2_SIGSTOP 23
+#define IBCS2_SIGTSTP 24
+#define IBCS2_SIGCONT 25
+#define IBCS2_SIGTTIN 26
+#define IBCS2_SIGTTOU 27
+#define IBCS2_SIGVTALRM 28
+#define IBCS2_SIGPROF 29
+
+#define IBCS2_SIGNO_MASK 0x00FF
+#define IBCS2_SIGNAL_MASK 0x0000
+#define IBCS2_SIGSET_MASK 0x0100
+#define IBCS2_SIGHOLD_MASK 0x0200
+#define IBCS2_SIGRELSE_MASK 0x0400
+#define IBCS2_SIGIGNORE_MASK 0x0800
+#define IBCS2_SIGPAUSE_MASK 0x1000
+
+#define IBCS2_SIGNO(x) ((x) & IBCS2_SIGNO_MASK)
+#define IBCS2_SIGCALL(x) ((x) & ~IBCS2_SIGNO_MASK)
+
+#define IBCS2_SIG_DFL (void(*)())0
+#define IBCS2_SIG_ERR (void(*)())-1
+#define IBCS2_SIG_IGN (void(*)())1
+#define IBCS2_SIG_HOLD (void(*)())2
+
+#define IBCS2_SIG_SETMASK 0
+#define IBCS2_SIG_BLOCK 1
+#define IBCS2_SIG_UNBLOCK 2
+
+typedef long ibcs2_sigset_t;
+typedef void (*ibcs2_sig_t) __P((int));
+
+struct ibcs2_sigaction {
+ ibcs2_sig_t sa_handler;
+ ibcs2_sigset_t sa_mask;
+ int sa_flags;
+};
+
+/* sa_flags */
+#define IBCS2_SA_NOCLDSTOP 1
+
+extern int bsd_to_ibcs2_sig[];
+
+#endif /* _IBCS2_SIGNAL_H */
diff --git a/sys/compat/ibcs2/ibcs2_socksys.c b/sys/compat/ibcs2/ibcs2_socksys.c
new file mode 100644
index 00000000000..1fb3b8193b0
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_socksys.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c) 1994, 1995 Scott Bartram
+ * Copyright (c) 1994 Arne H Juul
+ * 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. 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/proc.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/termios.h>
+#include <sys/tty.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <net/if.h>
+
+#include <compat/ibcs2/ibcs2_socksys.h>
+#include <compat/ibcs2/ibcs2_util.h>
+
+/*
+ * iBCS2 socksys calls.
+ */
+
+struct ibcs2_socksys_args {
+ int fd;
+ int magic;
+ caddr_t argsp;
+};
+
+int
+ibcs2_socksys(p, uap, retval)
+ register struct proc *p;
+ register struct ibcs2_socksys_args *uap;
+ register_t *retval;
+{
+ register struct filedesc *fdp = p->p_fd;
+ register struct file *fp;
+ int error;
+ int realargs[7]; /* 1 for command, 6 for recvfrom */
+
+ /*
+ * SOCKET should only be legal on /dev/socksys.
+ * GETIPDOMAINNAME should only be legal on /dev/socksys ?
+ * The others are (and should be) only legal on sockets.
+ */
+
+ if (error = copyin(uap->argsp, (caddr_t)realargs, sizeof(realargs)))
+ return error;
+ DPRINTF(("ibcs2_socksys: %08x %08x %08x %08x %08x %08x %08x\n",
+ realargs[0], realargs[1], realargs[2], realargs[3],
+ realargs[4], realargs[5], realargs[6]));
+ switch (realargs[0]) {
+ case SOCKSYS_ACCEPT:
+ return sys_accept(p, realargs + 1, retval);
+ case SOCKSYS_BIND:
+ return sys_bind(p, realargs + 1, retval);
+ case SOCKSYS_CONNECT:
+ return sys_connect(p, realargs + 1, retval);
+ case SOCKSYS_GETPEERNAME:
+ return sys_getpeername(p, realargs + 1, retval);
+ case SOCKSYS_GETSOCKNAME:
+ return sys_getsockname(p, realargs + 1, retval);
+ case SOCKSYS_GETSOCKOPT:
+ return sys_getsockopt(p, realargs + 1, retval);
+ case SOCKSYS_LISTEN:
+ return sys_listen(p, realargs + 1, retval);
+ case SOCKSYS_RECV:
+ realargs[5] = realargs[6] = 0;
+ /* FALLTHROUGH */
+ case SOCKSYS_RECVFROM:
+ return sys_recvfrom(p, realargs + 1, retval);
+ case SOCKSYS_SEND:
+ realargs[5] = realargs[6] = 0;
+ /* FALLTHROUGH */
+ case SOCKSYS_SENDTO:
+ return sys_sendto(p, realargs + 1, retval);
+ case SOCKSYS_SETSOCKOPT:
+ return sys_setsockopt(p, realargs + 1, retval);
+ case SOCKSYS_SHUTDOWN:
+ return sys_shutdown(p, realargs + 1, retval);
+ case SOCKSYS_SOCKET:
+ return sys_socket(p, realargs + 1, retval);
+ case SOCKSYS_SELECT:
+ return sys_select(p, realargs + 1, retval);
+ case SOCKSYS_GETIPDOMAIN:
+ return compat_09_sys_getdomainname(p, realargs + 1, retval);
+ case SOCKSYS_SETIPDOMAIN:
+ return compat_09_sys_setdomainname(p, realargs + 1, retval);
+ case SOCKSYS_ADJTIME:
+ return sys_adjtime(p, realargs + 1, retval);
+ case SOCKSYS_SETREUID:
+ return compat_43_sys_setreuid(p, realargs + 1, retval);
+ case SOCKSYS_SETREGID:
+ return compat_43_sys_setregid(p, realargs + 1, retval);
+ case SOCKSYS_GETTIME:
+ return sys_gettimeofday(p, realargs + 1, retval);
+ case SOCKSYS_SETTIME:
+ return sys_settimeofday(p, realargs + 1, retval);
+ case SOCKSYS_GETITIMER:
+ return sys_getitimer(p, realargs + 1, retval);
+ case SOCKSYS_SETITIMER:
+ return sys_setitimer(p, realargs + 1, retval);
+
+ default:
+ printf("socksys unknown %08x %08x %08x %08x %08x %08x %08x\n",
+ realargs[0], realargs[1], realargs[2], realargs[3],
+ realargs[4], realargs[5], realargs[6]);
+ return EINVAL;
+ }
+ /* NOTREACHED */
+}
diff --git a/sys/compat/ibcs2/ibcs2_socksys.h b/sys/compat/ibcs2/ibcs2_socksys.h
new file mode 100644
index 00000000000..bc89180b44b
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_socksys.h
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 1994, 1995 Scott Bartram
+ * Copyright (c) 1994 Arne H Juul
+ * 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. 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.
+ */
+
+
+#ifndef _IBCS2_SOCKSYS_H
+#define _IBCS2_SOCKSYS_H 1
+
+#include <sys/ioccom.h>
+#include <compat/ibcs2/ibcs2_types.h>
+
+#define SOCKSYS_ACCEPT 1
+#define SOCKSYS_BIND 2
+#define SOCKSYS_CONNECT 3
+#define SOCKSYS_GETPEERNAME 4
+#define SOCKSYS_GETSOCKNAME 5
+#define SOCKSYS_GETSOCKOPT 6
+#define SOCKSYS_LISTEN 7
+#define SOCKSYS_RECV 8
+#define SOCKSYS_RECVFROM 9
+#define SOCKSYS_SEND 10
+#define SOCKSYS_SENDTO 11
+#define SOCKSYS_SETSOCKOPT 12
+#define SOCKSYS_SHUTDOWN 13
+#define SOCKSYS_SOCKET 14
+#define SOCKSYS_SELECT 15
+#define SOCKSYS_GETIPDOMAIN 16
+#define SOCKSYS_SETIPDOMAIN 17
+#define SOCKSYS_ADJTIME 18
+#define SOCKSYS_SETREUID 19
+#define SOCKSYS_SETREGID 20
+#define SOCKSYS_GETTIME 21
+#define SOCKSYS_SETTIME 22
+#define SOCKSYS_GETITIMER 23
+#define SOCKSYS_SETITIMER 24
+
+#define IBCS2_SIOCSHIWAT _IOW('S', 1, int)
+#define IBCS2_SIOCGHIWAT _IOR('S', 2, int)
+#define IBCS2_SIOCSLOWAT _IOW('S', 3, int)
+#define IBCS2_SIOCGLOWAT _IOR('S', 4, int)
+#define IBCS2_SIOCATMARK _IOR('S', 5, int)
+#define IBCS2_SIOCSPGRP _IOW('S', 6, int)
+#define IBCS2_SIOCGPGRP _IOR('S', 7, int)
+#define IBCS2_FIONREAD _IOR('S', 8, int)
+#define IBCS2_FIONBIO _IOW('S', 9, int)
+#define IBCS2_FIOASYNC _IOW('S', 10, int)
+#define IBCS2_SIOCPROTO _IOW('S', 11, struct socknewproto)
+#define IBCS2_SIOCGETNAME _IOR('S', 12, struct sockaddr)
+#define IBCS2_SIOCGETPEER _IOR('S', 13, struct sockaddr)
+#define IBCS2_IF_UNITSEL _IOW('S', 14, int)
+#define IBCS2_SIOCXPROTO _IO('S', 15)
+
+#define IBCS2_SIOCADDRT _IOW('R', 9, struct rtentry)
+#define IBCS2_SIOCDELRT _IOW('R', 10, struct rtentry)
+
+#define IBCS2_SIOCSIFADDR _IOW('I', 11, struct ifreq)
+#define IBCS2_SIOCGIFADDR _IOWR('I', 12, struct ifreq)
+#define IBCS2_SIOCSIFDSTADDR _IOW('I', 13, struct ifreq)
+#define IBCS2_SIOCGIFDSTADDR _IOWR('I', 14, struct ifreq)
+#define IBCS2_SIOCSIFFLAGS _IOW('I', 15, struct ifreq)
+#define IBCS2_SIOCGIFFLAGS _IOWR('I', 16, struct ifreq)
+#define IBCS2_SIOCGIFCONF _IOWR('I', 17, struct ifconf)
+#define IBCS2_SIOCSIFMTU _IOW('I', 21, struct ifreq)
+#define IBCS2_SIOCGIFMTU _IOWR('I', 22, struct ifreq)
+#define IBCS2_SIOCIFDETACH _IOW('I', 26, struct ifreq)
+#define IBCS2_SIOCGENPSTATS _IOWR('I', 27, struct ifreq)
+#define IBCS2_SIOCX25XMT _IOWR('I', 29, struct ifreq)
+#define IBCS2_SIOCX25RCV _IOWR('I', 30, struct ifreq)
+#define IBCS2_SIOCX25TBL _IOWR('I', 31, struct ifreq)
+#define IBCS2_SIOCGIFBRDADDR _IOWR('I', 32, struct ifreq)
+#define IBCS2_SIOCSIFBRDADDR _IOW('I', 33, struct ifreq)
+#define IBCS2_SIOCGIFNETMASK _IOWR('I', 34, struct ifreq)
+#define IBCS2_SIOCSIFNETMASK _IOW('I', 35, struct ifreq)
+#define IBCS2_SIOCGIFMETRIC _IOWR('I', 36, struct ifreq)
+#define IBCS2_SIOCSIFMETRIC _IOW('I', 37, struct ifreq)
+#define IBCS2_SIOCSARP _IOW('I', 38, struct arpreq)
+#define IBCS2_SIOCGARP _IOWR('I', 39, struct arpreq)
+#define IBCS2_SIOCDARP _IOW('I', 40, struct arpreq)
+#define IBCS2_SIOCSIFNAME _IOW('I', 41, struct ifreq)
+#define IBCS2_SIOCGIFONEP _IOWR('I', 42, struct ifreq)
+#define IBCS2_SIOCSIFONEP _IOW('I', 43, struct ifreq)
+#define IBCS2_SIOCGENADDR _IOWR('I', 65, struct ifreq)
+#define IBCS2_SIOCSOCKSYS _IOW('I', 66, struct socksysreq)
+
+struct socksysreq {
+ int realargs[7];
+};
+
+struct socknewproto {
+ int family;
+ int type;
+ int proto;
+ ibcs2_dev_t dev;
+ int flags;
+};
+
+#endif /* _IBCS2_SOCKSYS_H */
diff --git a/sys/compat/ibcs2/ibcs2_stat.c b/sys/compat/ibcs2/ibcs2_stat.c
new file mode 100644
index 00000000000..4e4e21437a6
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_stat.c
@@ -0,0 +1,274 @@
+/*
+ * Copyright (c) 1995 Scott Bartram
+ * 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/namei.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/malloc.h>
+#include <sys/vnode.h>
+#include <sys/syscallargs.h>
+
+#include <vm/vm.h>
+
+#include <compat/ibcs2/ibcs2_types.h>
+#include <compat/ibcs2/ibcs2_fcntl.h>
+#include <compat/ibcs2/ibcs2_signal.h>
+#include <compat/ibcs2/ibcs2_stat.h>
+#include <compat/ibcs2/ibcs2_statfs.h>
+#include <compat/ibcs2/ibcs2_syscallargs.h>
+#include <compat/ibcs2/ibcs2_ustat.h>
+#include <compat/ibcs2/ibcs2_util.h>
+#include <compat/ibcs2/ibcs2_utsname.h>
+
+
+static void
+bsd_stat2ibcs_stat(st, st4)
+ struct ostat *st;
+ struct ibcs2_stat *st4;
+{
+ bzero(st4, sizeof(*st4));
+ st4->st_dev = (ibcs2_dev_t)st->st_dev;
+ st4->st_ino = (ibcs2_ino_t)st->st_ino;
+ st4->st_mode = (ibcs2_mode_t)st->st_mode;
+ st4->st_nlink = (ibcs2_nlink_t)st->st_nlink;
+ st4->st_uid = (ibcs2_uid_t)st->st_uid;
+ st4->st_gid = (ibcs2_gid_t)st->st_gid;
+ st4->st_rdev = (ibcs2_dev_t)st->st_rdev;
+ st4->st_size = (ibcs2_off_t)st->st_size;
+ st4->st_atim = (ibcs2_time_t)st->st_atime;
+ st4->st_mtim = (ibcs2_time_t)st->st_mtime;
+ st4->st_ctim = (ibcs2_time_t)st->st_ctime;
+}
+
+static int
+cvt_statfs(sp, buf, len)
+ struct statfs *sp;
+ caddr_t buf;
+ int len;
+{
+ struct ibcs2_statfs ssfs;
+
+ bzero(&ssfs, sizeof ssfs);
+ ssfs.f_fstyp = 0;
+ ssfs.f_bsize = sp->f_bsize;
+ ssfs.f_frsize = 0;
+ ssfs.f_blocks = sp->f_blocks;
+ ssfs.f_bfree = sp->f_bfree;
+ ssfs.f_files = sp->f_files;
+ ssfs.f_ffree = sp->f_ffree;
+ ssfs.f_fname[0] = 0;
+ ssfs.f_fpack[0] = 0;
+ return copyout((caddr_t)&ssfs, buf, len);
+}
+
+int
+ibcs2_sys_statfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_statfs_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct ibcs2_statfs *) buf;
+ syscallarg(int) len;
+ syscallarg(int) fstype;
+ } */ *uap = v;
+ register struct mount *mp;
+ register struct statfs *sp;
+ int error;
+ struct nameidata nd;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
+ if (error = namei(&nd))
+ return (error);
+ mp = nd.ni_vp->v_mount;
+ sp = &mp->mnt_stat;
+ vrele(nd.ni_vp);
+ if (error = VFS_STATFS(mp, sp, p))
+ return (error);
+ sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
+ return cvt_statfs(sp, (caddr_t)SCARG(uap, buf), SCARG(uap, len));
+}
+
+int
+ibcs2_sys_fstatfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_fstatfs_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct ibcs2_statfs *) buf;
+ syscallarg(int) len;
+ syscallarg(int) fstype;
+ } */ *uap = v;
+ struct file *fp;
+ struct mount *mp;
+ register struct statfs *sp;
+ int error;
+
+ if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
+ return (error);
+ mp = ((struct vnode *)fp->f_data)->v_mount;
+ sp = &mp->mnt_stat;
+ if (error = VFS_STATFS(mp, sp, p))
+ return (error);
+ sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
+ return cvt_statfs(sp, (caddr_t)SCARG(uap, buf), SCARG(uap, len));
+}
+
+int
+ibcs2_sys_stat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_stat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct ibcs2_stat *) st;
+ } */ *uap = v;
+ struct ostat st;
+ struct ibcs2_stat ibcs2_st;
+ struct compat_43_sys_stat_args cup;
+ int error;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(st));
+ if (error = compat_43_sys_stat(p, &cup, retval))
+ return error;
+ if (error = copyin(SCARG(&cup, ub), &st, sizeof(st)))
+ return error;
+ bsd_stat2ibcs_stat(&st, &ibcs2_st);
+ return copyout((caddr_t)&ibcs2_st, (caddr_t)SCARG(uap, st),
+ ibcs2_stat_len);
+}
+
+int
+ibcs2_sys_lstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_lstat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct ibcs2_stat *) st;
+ } */ *uap = v;
+ struct ostat st;
+ struct ibcs2_stat ibcs2_st;
+ struct compat_43_sys_lstat_args cup;
+ int error;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ IBCS2_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(st));
+ if (error = compat_43_sys_lstat(p, &cup, retval))
+ return error;
+ if (error = copyin(SCARG(&cup, ub), &st, sizeof(st)))
+ return error;
+ bsd_stat2ibcs_stat(&st, &ibcs2_st);
+ return copyout((caddr_t)&ibcs2_st, (caddr_t)SCARG(uap, st),
+ ibcs2_stat_len);
+}
+
+int
+ibcs2_sys_fstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_fstat_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct ibcs2_stat *) st;
+ } */ *uap = v;
+ struct ostat st;
+ struct ibcs2_stat ibcs2_st;
+ struct compat_43_sys_fstat_args cup;
+ int error;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ SCARG(&cup, fd) = SCARG(uap, fd);
+ SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(st));
+ if (error = compat_43_sys_fstat(p, &cup, retval))
+ return error;
+ if (error = copyin(SCARG(&cup, sb), &st, sizeof(st)))
+ return error;
+ bsd_stat2ibcs_stat(&st, &ibcs2_st);
+ return copyout((caddr_t)&ibcs2_st, (caddr_t)SCARG(uap, st),
+ ibcs2_stat_len);
+}
+
+int
+ibcs2_sys_utssys(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_sys_utssys_args /* {
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) flag;
+ } */ *uap = v;
+
+ switch (SCARG(uap, flag)) {
+ case 0: /* uname(2) */
+ {
+ struct ibcs2_utsname sut;
+ extern char ostype[], machine[], osrelease[];
+
+ bzero(&sut, ibcs2_utsname_len);
+ bcopy(ostype, sut.sysname, sizeof(sut.sysname) - 1);
+ bcopy(hostname, sut.nodename, sizeof(sut.nodename));
+ sut.nodename[sizeof(sut.nodename)-1] = '\0';
+ bcopy(osrelease, sut.release, sizeof(sut.release) - 1);
+ bcopy("1", sut.version, sizeof(sut.version) - 1);
+ bcopy(machine, sut.machine, sizeof(sut.machine) - 1);
+
+ return copyout((caddr_t)&sut, (caddr_t)SCARG(uap, a1),
+ ibcs2_utsname_len);
+ }
+
+ case 2: /* ustat(2) */
+ {
+ return ENOSYS; /* XXX - TODO */
+ }
+
+ default:
+ return ENOSYS;
+ }
+}
diff --git a/sys/compat/ibcs2/ibcs2_stat.h b/sys/compat/ibcs2/ibcs2_stat.h
new file mode 100644
index 00000000000..2eb01027e0c
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_stat.h
@@ -0,0 +1,89 @@
+/* $NetBSD: ibcs2_stat.h,v 1.2 1994/10/26 02:53:03 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_STAT_H
+#define _IBCS2_STAT_H
+
+#include <compat/ibcs2/ibcs2_types.h>
+
+struct ibcs2_stat {
+ ibcs2_dev_t st_dev;
+ ibcs2_ino_t st_ino;
+ ibcs2_mode_t st_mode;
+ ibcs2_nlink_t st_nlink;
+ ibcs2_uid_t st_uid;
+ ibcs2_gid_t st_gid;
+ ibcs2_dev_t st_rdev;
+ ibcs2_off_t st_size;
+ ibcs2_time_t st_atim;
+ ibcs2_time_t st_mtim;
+ ibcs2_time_t st_ctim;
+};
+
+#define ibcs2_stat_len (sizeof(struct ibcs2_stat))
+
+#define IBCS2_S_IFMT 0xf000
+#define IBCS2_S_IFIFO 0x1000
+#define IBCS2_S_IFCHR 0x2000
+#define IBCS2_S_IFDIR 0x4000
+#define IBCS2_S_IFBLK 0x6000
+#define IBCS2_S_IFREG 0x8000
+#define IBCS2_S_IFSOCK 0xc000
+
+#define IBCS2_S_IFNAM 0x5000
+#define IBCS2_S_IFLNK 0xa000
+
+#define IBCS2_S_ISUID 0x0800
+#define IBCS2_S_ISGID 0x0400
+#define IBCS2_S_ISVTX 0x0200
+
+#define IBCS2_S_IRWXU 0x01c0
+#define IBCS2_S_IRUSR 0x0100
+#define IBCS2_S_IWUSR 0x0080
+#define IBCS2_S_IXUSR 0x0040
+#define IBCS2_S_IRWXG 0x0038
+#define IBCS2_S_IRGRP 0x0020
+#define IBCS2_S_IWGRP 0x000f
+#define IBCS2_S_IXGRP 0x0008
+#define IBCS2_S_IRWXO 0x0007
+#define IBCS2_S_IROTH 0x0004
+#define IBCS2_S_IWOTH 0x0002
+#define IBCS2_S_IXOTH 0x0001
+
+#define IBCS2_S_ISFIFO(mode) (((mode) & IBCS2_S_IFMT) == IBCS2_S_IFIFO)
+#define IBCS2_S_ISCHR(mode) (((mode) & IBCS2_S_IFMT) == IBCS2_S_IFCHR)
+#define IBCS2_S_ISDIR(mode) (((mode) & IBCS2_S_IFMT) == IBCS2_S_IFDIR)
+#define IBCS2_S_ISBLK(mode) (((mode) & IBCS2_S_IFMT) == IBCS2_S_IFBLK)
+#define IBCS2_S_ISREG(mode) (((mode) & IBCS2_S_IFMT) == IBCS2_S_IFREG)
+#define IBCS2_S_ISSOCK(mode) (((mode) & IBCS2_S_IFMT) == IBCS2_S_IFSOCK)
+
+#endif /* _IBCS2_STAT_H */
diff --git a/sys/compat/ibcs2/ibcs2_statfs.h b/sys/compat/ibcs2/ibcs2_statfs.h
new file mode 100644
index 00000000000..d6e0100c1eb
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_statfs.h
@@ -0,0 +1,48 @@
+/* $NetBSD: ibcs2_statfs.h,v 1.2 1994/10/26 02:53:06 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_STATFS_H
+#define _IBCS2_STATFS_H
+
+struct ibcs2_statfs {
+ short f_fstyp;
+ long f_bsize;
+ long f_frsize;
+ long f_blocks;
+ long f_bfree;
+ long f_files;
+ long f_ffree;
+ char f_fname[6];
+ char f_fpack[6];
+};
+
+#endif /* _IBCS2_STATFS_H */
diff --git a/sys/compat/ibcs2/ibcs2_stropts.h b/sys/compat/ibcs2/ibcs2_stropts.h
new file mode 100644
index 00000000000..4d26e735826
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_stropts.h
@@ -0,0 +1,48 @@
+/*
+ * ibcs2_stropts.h
+ * Copyright (c) 1995 Scott Bartram
+ * 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. 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.
+ */
+
+#ifndef _IBCS2_STROPTS_H
+#define _IBCS2_STROPTS_H
+
+#define IBCS2_STR ('S'<<8)
+#define IBCS2_I_NREAD (IBCS2_STR|01)
+#define IBCS2_I_PUSH (IBCS2_STR|02)
+#define IBCS2_I_POP (IBCS2_STR|03)
+#define IBCS2_I_LOOK (IBCS2_STR|04)
+#define IBCS2_I_FLUSH (IBCS2_STR|05)
+#define IBCS2_I_SRDOPT (IBCS2_STR|06)
+#define IBCS2_I_GRDOPT (IBCS2_STR|07)
+#define IBCS2_I_STR (IBCS2_STR|010)
+#define IBCS2_I_SETSIG (IBCS2_STR|011)
+#define IBCS2_I_GETSIG (IBCS2_STR|012)
+#define IBCS2_I_FIND (IBCS2_STR|013)
+#define IBCS2_I_LINK (IBCS2_STR|014)
+#define IBCS2_I_UNLINK (IBCS2_STR|015)
+#define IBCS2_I_PEEK (IBCS2_STR|017)
+#define IBCS2_I_FDINSERT (IBCS2_STR|020)
+#define IBCS2_I_SENDFD (IBCS2_STR|021)
+#define IBCS2_I_RECVFD (IBCS2_STR|022)
+
+#endif /* _IBCS2_STROPTS_H */
diff --git a/sys/compat/ibcs2/ibcs2_syscall.h b/sys/compat/ibcs2/ibcs2_syscall.h
new file mode 100644
index 00000000000..ed8fef24186
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_syscall.h
@@ -0,0 +1,97 @@
+/*
+ * System call numbers.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.6 1995/10/07 06:26:56 mycroft Exp
+ */
+
+#define IBCS2_SYS_syscall 0
+#define IBCS2_SYS_exit 1
+#define IBCS2_SYS_fork 2
+#define IBCS2_SYS_read 3
+#define IBCS2_SYS_write 4
+#define IBCS2_SYS_open 5
+#define IBCS2_SYS_close 6
+#define IBCS2_SYS_waitsys 7
+#define IBCS2_SYS_creat 8
+#define IBCS2_SYS_link 9
+#define IBCS2_SYS_unlink 10
+#define IBCS2_SYS_execv 11
+#define IBCS2_SYS_chdir 12
+#define IBCS2_SYS_time 13
+#define IBCS2_SYS_mknod 14
+#define IBCS2_SYS_chmod 15
+#define IBCS2_SYS_chown 16
+#define IBCS2_SYS_obreak 17
+#define IBCS2_SYS_stat 18
+#define IBCS2_SYS_lseek 19
+#define IBCS2_SYS_getpid 20
+#define IBCS2_SYS_mount 21
+#define IBCS2_SYS_umount 22
+#define IBCS2_SYS_setuid 23
+#define IBCS2_SYS_getuid 24
+#define IBCS2_SYS_stime 25
+#define IBCS2_SYS_alarm 27
+#define IBCS2_SYS_fstat 28
+#define IBCS2_SYS_pause 29
+#define IBCS2_SYS_utime 30
+#define IBCS2_SYS_access 33
+#define IBCS2_SYS_nice 34
+#define IBCS2_SYS_statfs 35
+#define IBCS2_SYS_sync 36
+#define IBCS2_SYS_kill 37
+#define IBCS2_SYS_fstatfs 38
+#define IBCS2_SYS_pgrpsys 39
+#define IBCS2_SYS_dup 41
+#define IBCS2_SYS_pipe 42
+#define IBCS2_SYS_times 43
+#define IBCS2_SYS_plock 45
+#define IBCS2_SYS_setgid 46
+#define IBCS2_SYS_getgid 47
+#define IBCS2_SYS_sigsys 48
+#define IBCS2_SYS_msgsys 49
+#define IBCS2_SYS_shmsys 52
+#define IBCS2_SYS_semsys 53
+#define IBCS2_SYS_ioctl 54
+#define IBCS2_SYS_uadmin 55
+#define IBCS2_SYS_utssys 57
+#define IBCS2_SYS_execve 59
+#define IBCS2_SYS_umask 60
+#define IBCS2_SYS_chroot 61
+#define IBCS2_SYS_fcntl 62
+#define IBCS2_SYS_ulimit 63
+ /* 70 is obsolete rfs_advfs */
+ /* 71 is obsolete rfs_unadvfs */
+ /* 72 is obsolete rfs_rmount */
+ /* 73 is obsolete rfs_rumount */
+ /* 74 is obsolete rfs_rfstart */
+ /* 75 is obsolete rfs_sigret */
+ /* 76 is obsolete rfs_rdebug */
+ /* 77 is obsolete rfs_rfstop */
+#define IBCS2_SYS_rmdir 79
+#define IBCS2_SYS_mkdir 80
+#define IBCS2_SYS_getdents 81
+#define IBCS2_SYS_sysfs 84
+#define IBCS2_SYS_getmsg 85
+#define IBCS2_SYS_putmsg 86
+#define IBCS2_SYS_poll 87
+#define IBCS2_SYS_symlink 90
+#define IBCS2_SYS_lstat 91
+#define IBCS2_SYS_readlink 92
+#define IBCS2_SYS_sigreturn 103
+#define IBCS2_SYS_rdchk 135
+#define IBCS2_SYS_chsize 138
+#define IBCS2_SYS_ftime 139
+#define IBCS2_SYS_nap 140
+#define IBCS2_SYS_select 164
+#define IBCS2_SYS_sigaction 167
+#define IBCS2_SYS_sigprocmask 168
+#define IBCS2_SYS_sigpending 169
+#define IBCS2_SYS_sigsuspend 170
+#define IBCS2_SYS_getgroups 171
+#define IBCS2_SYS_setgroups 172
+#define IBCS2_SYS_sysconf 173
+#define IBCS2_SYS_pathconf 174
+#define IBCS2_SYS_fpathconf 175
+#define IBCS2_SYS_rename 176
+#define IBCS2_SYS_MAXSYSCALL 177
diff --git a/sys/compat/ibcs2/ibcs2_syscallargs.h b/sys/compat/ibcs2/ibcs2_syscallargs.h
new file mode 100644
index 00000000000..c9df53df8b4
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_syscallargs.h
@@ -0,0 +1,434 @@
+/*
+ * System call argument lists.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.6 1995/10/07 06:26:56 mycroft Exp
+ */
+
+#define syscallarg(x) union { x datum; register_t pad; }
+
+struct ibcs2_sys_read_args {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(u_int) nbytes;
+};
+
+struct ibcs2_sys_open_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+};
+
+struct ibcs2_sys_waitsys_args {
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+};
+
+struct ibcs2_sys_creat_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct ibcs2_sys_unlink_args {
+ syscallarg(char *) path;
+};
+
+struct ibcs2_sys_execv_args {
+ syscallarg(char *) path;
+ syscallarg(char **) argp;
+};
+
+struct ibcs2_sys_chdir_args {
+ syscallarg(char *) path;
+};
+
+struct ibcs2_sys_time_args {
+ syscallarg(ibcs2_time_t *) tp;
+};
+
+struct ibcs2_sys_mknod_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ syscallarg(int) dev;
+};
+
+struct ibcs2_sys_chmod_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct ibcs2_sys_chown_args {
+ syscallarg(char *) path;
+ syscallarg(int) uid;
+ syscallarg(int) gid;
+};
+
+struct ibcs2_sys_stat_args {
+ syscallarg(char *) path;
+ syscallarg(struct ibcs2_stat *) st;
+};
+
+struct ibcs2_sys_mount_args {
+ syscallarg(char *) special;
+ syscallarg(char *) dir;
+ syscallarg(int) flags;
+ syscallarg(int) fstype;
+ syscallarg(char *) data;
+ syscallarg(int) len;
+};
+
+struct ibcs2_sys_umount_args {
+ syscallarg(char *) name;
+};
+
+struct ibcs2_sys_setuid_args {
+ syscallarg(int) uid;
+};
+
+struct ibcs2_sys_stime_args {
+ syscallarg(long *) timep;
+};
+
+struct ibcs2_sys_alarm_args {
+ syscallarg(unsigned) sec;
+};
+
+struct ibcs2_sys_fstat_args {
+ syscallarg(int) fd;
+ syscallarg(struct ibcs2_stat *) st;
+};
+
+struct ibcs2_sys_utime_args {
+ syscallarg(char *) path;
+ syscallarg(struct ibcs2_utimbuf *) buf;
+};
+
+struct ibcs2_sys_access_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+};
+
+struct ibcs2_sys_nice_args {
+ syscallarg(int) incr;
+};
+
+struct ibcs2_sys_statfs_args {
+ syscallarg(char *) path;
+ syscallarg(struct ibcs2_statfs *) buf;
+ syscallarg(int) len;
+ syscallarg(int) fstype;
+};
+
+struct ibcs2_sys_kill_args {
+ syscallarg(int) pid;
+ syscallarg(int) signo;
+};
+
+struct ibcs2_sys_fstatfs_args {
+ syscallarg(int) fd;
+ syscallarg(struct ibcs2_statfs *) buf;
+ syscallarg(int) len;
+ syscallarg(int) fstype;
+};
+
+struct ibcs2_sys_pgrpsys_args {
+ syscallarg(int) type;
+ syscallarg(caddr_t) dummy;
+ syscallarg(int) pid;
+ syscallarg(int) pgid;
+};
+
+struct ibcs2_sys_times_args {
+ syscallarg(struct tms *) tp;
+};
+
+struct ibcs2_sys_plock_args {
+ syscallarg(int) cmd;
+};
+
+struct ibcs2_sys_setgid_args {
+ syscallarg(int) gid;
+};
+
+struct ibcs2_sys_sigsys_args {
+ syscallarg(int) sig;
+ syscallarg(ibcs2_sig_t) fp;
+};
+
+struct ibcs2_sys_msgsys_args {
+ syscallarg(int) which;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(int) a4;
+ syscallarg(int) a5;
+ syscallarg(int) a6;
+};
+
+struct ibcs2_sys_shmsys_args {
+ syscallarg(int) which;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(int) a4;
+};
+
+struct ibcs2_sys_semsys_args {
+ syscallarg(int) which;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(int) a4;
+ syscallarg(int) a5;
+};
+
+struct ibcs2_sys_ioctl_args {
+ syscallarg(int) fd;
+ syscallarg(int) cmd;
+ syscallarg(caddr_t) data;
+};
+
+struct ibcs2_sys_uadmin_args {
+ syscallarg(int) cmd;
+ syscallarg(int) func;
+ syscallarg(caddr_t) data;
+};
+
+struct ibcs2_sys_utssys_args {
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) flag;
+};
+
+struct ibcs2_sys_execve_args {
+ syscallarg(char *) path;
+ syscallarg(char **) argp;
+ syscallarg(char **) envp;
+};
+
+struct ibcs2_sys_fcntl_args {
+ syscallarg(int) fd;
+ syscallarg(int) cmd;
+ syscallarg(char *) arg;
+};
+
+struct ibcs2_sys_ulimit_args {
+ syscallarg(int) cmd;
+ syscallarg(int) newlimit;
+};
+
+struct ibcs2_sys_rmdir_args {
+ syscallarg(char *) path;
+};
+
+struct ibcs2_sys_mkdir_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct ibcs2_sys_getdents_args {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(int) nbytes;
+};
+
+struct ibcs2_sys_sysfs_args {
+ syscallarg(int) cmd;
+ syscallarg(caddr_t) d1;
+ syscallarg(char *) buf;
+};
+
+struct ibcs2_sys_getmsg_args {
+ syscallarg(int) fd;
+ syscallarg(struct ibcs2_stropts *) ctl;
+ syscallarg(struct ibcs2_stropts *) dat;
+ syscallarg(int *) flags;
+};
+
+struct ibcs2_sys_putmsg_args {
+ syscallarg(int) fd;
+ syscallarg(struct ibcs2_stropts *) ctl;
+ syscallarg(struct ibcs2_stropts *) dat;
+ syscallarg(int) flags;
+};
+
+struct ibcs2_sys_poll_args {
+ syscallarg(struct ibcs2_pollfd *) fds;
+ syscallarg(long) nfds;
+ syscallarg(int) timeout;
+};
+
+struct ibcs2_sys_symlink_args {
+ syscallarg(char *) path;
+ syscallarg(char *) link;
+};
+
+struct ibcs2_sys_lstat_args {
+ syscallarg(char *) path;
+ syscallarg(struct ibcs2_stat *) st;
+};
+
+struct ibcs2_sys_readlink_args {
+ syscallarg(char *) path;
+ syscallarg(char *) buf;
+ syscallarg(int) count;
+};
+
+struct xenix_sys_rdchk_args {
+ syscallarg(int) fd;
+};
+
+struct xenix_sys_chsize_args {
+ syscallarg(int) fd;
+ syscallarg(long) size;
+};
+
+struct xenix_sys_ftime_args {
+ syscallarg(struct xenix_timeb *) tp;
+};
+
+struct xenix_sys_nap_args {
+ syscallarg(int) millisec;
+};
+
+struct ibcs2_sys_sigaction_args {
+ syscallarg(int) signum;
+ syscallarg(struct ibcs2_sigaction *) nsa;
+ syscallarg(struct ibcs2_sigaction *) osa;
+};
+
+struct ibcs2_sys_sigprocmask_args {
+ syscallarg(int) how;
+ syscallarg(ibcs2_sigset_t *) set;
+ syscallarg(ibcs2_sigset_t *) oset;
+};
+
+struct ibcs2_sys_sigpending_args {
+ syscallarg(ibcs2_sigset_t *) mask;
+};
+
+struct ibcs2_sys_sigsuspend_args {
+ syscallarg(ibcs2_sigset_t *) mask;
+};
+
+struct ibcs2_sys_getgroups_args {
+ syscallarg(int) gidsetsize;
+ syscallarg(ibcs2_gid_t *) gidset;
+};
+
+struct ibcs2_sys_setgroups_args {
+ syscallarg(int) gidsetsize;
+ syscallarg(ibcs2_gid_t *) gidset;
+};
+
+struct ibcs2_sys_sysconf_args {
+ syscallarg(int) name;
+};
+
+struct ibcs2_sys_pathconf_args {
+ syscallarg(char *) path;
+ syscallarg(int) name;
+};
+
+struct ibcs2_sys_fpathconf_args {
+ syscallarg(int) fd;
+ syscallarg(int) name;
+};
+
+struct ibcs2_sys_rename_args {
+ syscallarg(char *) from;
+ syscallarg(char *) to;
+};
+
+/*
+ * System call prototypes.
+ */
+
+int sys_nosys __P((struct proc *, void *, register_t *));
+int sys_exit __P((struct proc *, void *, register_t *));
+int sys_fork __P((struct proc *, void *, register_t *));
+int ibcs2_sys_read __P((struct proc *, void *, register_t *));
+int sys_write __P((struct proc *, void *, register_t *));
+int ibcs2_sys_open __P((struct proc *, void *, register_t *));
+int sys_close __P((struct proc *, void *, register_t *));
+int ibcs2_sys_waitsys __P((struct proc *, void *, register_t *));
+int ibcs2_sys_creat __P((struct proc *, void *, register_t *));
+int sys_link __P((struct proc *, void *, register_t *));
+int ibcs2_sys_unlink __P((struct proc *, void *, register_t *));
+int ibcs2_sys_execv __P((struct proc *, void *, register_t *));
+int ibcs2_sys_chdir __P((struct proc *, void *, register_t *));
+int ibcs2_sys_time __P((struct proc *, void *, register_t *));
+int ibcs2_sys_mknod __P((struct proc *, void *, register_t *));
+int ibcs2_sys_chmod __P((struct proc *, void *, register_t *));
+int ibcs2_sys_chown __P((struct proc *, void *, register_t *));
+int sys_obreak __P((struct proc *, void *, register_t *));
+int ibcs2_sys_stat __P((struct proc *, void *, register_t *));
+int compat_43_sys_lseek __P((struct proc *, void *, register_t *));
+int sys_getpid __P((struct proc *, void *, register_t *));
+int ibcs2_sys_mount __P((struct proc *, void *, register_t *));
+int ibcs2_sys_umount __P((struct proc *, void *, register_t *));
+int ibcs2_sys_setuid __P((struct proc *, void *, register_t *));
+int sys_getuid __P((struct proc *, void *, register_t *));
+int ibcs2_sys_stime __P((struct proc *, void *, register_t *));
+int ibcs2_sys_alarm __P((struct proc *, void *, register_t *));
+int ibcs2_sys_fstat __P((struct proc *, void *, register_t *));
+int ibcs2_sys_pause __P((struct proc *, void *, register_t *));
+int ibcs2_sys_utime __P((struct proc *, void *, register_t *));
+int ibcs2_sys_access __P((struct proc *, void *, register_t *));
+int ibcs2_sys_nice __P((struct proc *, void *, register_t *));
+int ibcs2_sys_statfs __P((struct proc *, void *, register_t *));
+int sys_sync __P((struct proc *, void *, register_t *));
+int ibcs2_sys_kill __P((struct proc *, void *, register_t *));
+int ibcs2_sys_fstatfs __P((struct proc *, void *, register_t *));
+int ibcs2_sys_pgrpsys __P((struct proc *, void *, register_t *));
+int sys_dup __P((struct proc *, void *, register_t *));
+int sys_pipe __P((struct proc *, void *, register_t *));
+int ibcs2_sys_times __P((struct proc *, void *, register_t *));
+int ibcs2_sys_plock __P((struct proc *, void *, register_t *));
+int ibcs2_sys_setgid __P((struct proc *, void *, register_t *));
+int sys_getgid __P((struct proc *, void *, register_t *));
+int ibcs2_sys_sigsys __P((struct proc *, void *, register_t *));
+#ifdef SYSVMSG
+int ibcs2_sys_msgsys __P((struct proc *, void *, register_t *));
+#else
+#endif
+#ifdef SYSVSHM
+int ibcs2_sys_shmsys __P((struct proc *, void *, register_t *));
+#else
+#endif
+#ifdef SYSVSEM
+int ibcs2_sys_semsys __P((struct proc *, void *, register_t *));
+#else
+#endif
+int ibcs2_sys_ioctl __P((struct proc *, void *, register_t *));
+int ibcs2_sys_uadmin __P((struct proc *, void *, register_t *));
+int ibcs2_sys_utssys __P((struct proc *, void *, register_t *));
+int ibcs2_sys_execve __P((struct proc *, void *, register_t *));
+int sys_umask __P((struct proc *, void *, register_t *));
+int sys_chroot __P((struct proc *, void *, register_t *));
+int ibcs2_sys_fcntl __P((struct proc *, void *, register_t *));
+int ibcs2_sys_ulimit __P((struct proc *, void *, register_t *));
+int ibcs2_sys_rmdir __P((struct proc *, void *, register_t *));
+int ibcs2_sys_mkdir __P((struct proc *, void *, register_t *));
+int ibcs2_sys_getdents __P((struct proc *, void *, register_t *));
+int ibcs2_sys_sysfs __P((struct proc *, void *, register_t *));
+int ibcs2_sys_getmsg __P((struct proc *, void *, register_t *));
+int ibcs2_sys_putmsg __P((struct proc *, void *, register_t *));
+int ibcs2_sys_poll __P((struct proc *, void *, register_t *));
+int ibcs2_sys_symlink __P((struct proc *, void *, register_t *));
+int ibcs2_sys_lstat __P((struct proc *, void *, register_t *));
+int ibcs2_sys_readlink __P((struct proc *, void *, register_t *));
+int sys_sigreturn __P((struct proc *, void *, register_t *));
+int xenix_sys_rdchk __P((struct proc *, void *, register_t *));
+int xenix_sys_chsize __P((struct proc *, void *, register_t *));
+int xenix_sys_ftime __P((struct proc *, void *, register_t *));
+int xenix_sys_nap __P((struct proc *, void *, register_t *));
+int sys_select __P((struct proc *, void *, register_t *));
+int ibcs2_sys_sigaction __P((struct proc *, void *, register_t *));
+int ibcs2_sys_sigprocmask __P((struct proc *, void *, register_t *));
+int ibcs2_sys_sigpending __P((struct proc *, void *, register_t *));
+int ibcs2_sys_sigsuspend __P((struct proc *, void *, register_t *));
+int ibcs2_sys_getgroups __P((struct proc *, void *, register_t *));
+int ibcs2_sys_setgroups __P((struct proc *, void *, register_t *));
+int ibcs2_sys_sysconf __P((struct proc *, void *, register_t *));
+int ibcs2_sys_pathconf __P((struct proc *, void *, register_t *));
+int ibcs2_sys_fpathconf __P((struct proc *, void *, register_t *));
+int ibcs2_sys_rename __P((struct proc *, void *, register_t *));
diff --git a/sys/compat/ibcs2/ibcs2_syscalls.c b/sys/compat/ibcs2/ibcs2_syscalls.c
new file mode 100644
index 00000000000..256012fc268
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_syscalls.c
@@ -0,0 +1,198 @@
+/*
+ * System call names.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.6 1995/10/07 06:26:56 mycroft Exp
+ */
+
+char *ibcs2_syscallnames[] = {
+ "syscall", /* 0 = syscall */
+ "exit", /* 1 = exit */
+ "fork", /* 2 = fork */
+ "read", /* 3 = read */
+ "write", /* 4 = write */
+ "open", /* 5 = open */
+ "close", /* 6 = close */
+ "waitsys", /* 7 = waitsys */
+ "creat", /* 8 = creat */
+ "link", /* 9 = link */
+ "unlink", /* 10 = unlink */
+ "execv", /* 11 = execv */
+ "chdir", /* 12 = chdir */
+ "time", /* 13 = time */
+ "mknod", /* 14 = mknod */
+ "chmod", /* 15 = chmod */
+ "chown", /* 16 = chown */
+ "obreak", /* 17 = obreak */
+ "stat", /* 18 = stat */
+ "lseek", /* 19 = lseek */
+ "getpid", /* 20 = getpid */
+ "mount", /* 21 = mount */
+ "umount", /* 22 = umount */
+ "setuid", /* 23 = setuid */
+ "getuid", /* 24 = getuid */
+ "stime", /* 25 = stime */
+ "#26 (unimplemented ibcs2_ptrace)", /* 26 = unimplemented ibcs2_ptrace */
+ "alarm", /* 27 = alarm */
+ "fstat", /* 28 = fstat */
+ "pause", /* 29 = pause */
+ "utime", /* 30 = utime */
+ "#31 (unimplemented was stty)", /* 31 = unimplemented was stty */
+ "#32 (unimplemented was gtty)", /* 32 = unimplemented was gtty */
+ "access", /* 33 = access */
+ "nice", /* 34 = nice */
+ "statfs", /* 35 = statfs */
+ "sync", /* 36 = sync */
+ "kill", /* 37 = kill */
+ "fstatfs", /* 38 = fstatfs */
+ "pgrpsys", /* 39 = pgrpsys */
+ "#40 (unimplemented ibcs2_xenix)", /* 40 = unimplemented ibcs2_xenix */
+ "dup", /* 41 = dup */
+ "pipe", /* 42 = pipe */
+ "times", /* 43 = times */
+ "#44 (unimplemented profil)", /* 44 = unimplemented profil */
+ "plock", /* 45 = plock */
+ "setgid", /* 46 = setgid */
+ "getgid", /* 47 = getgid */
+ "sigsys", /* 48 = sigsys */
+#ifdef SYSVMSG
+ "msgsys", /* 49 = msgsys */
+#else
+ "#49 (unimplemented msgsys)", /* 49 = unimplemented msgsys */
+#endif
+ "#50 (unimplemented ibcs2_sys3b)", /* 50 = unimplemented ibcs2_sys3b */
+ "#51 (unimplemented ibcs2_acct)", /* 51 = unimplemented ibcs2_acct */
+#ifdef SYSVSHM
+ "shmsys", /* 52 = shmsys */
+#else
+ "#52 (unimplemented shmsys)", /* 52 = unimplemented shmsys */
+#endif
+#ifdef SYSVSEM
+ "semsys", /* 53 = semsys */
+#else
+ "#53 (unimplemented semsys)", /* 53 = unimplemented semsys */
+#endif
+ "ioctl", /* 54 = ioctl */
+ "uadmin", /* 55 = uadmin */
+ "#56 (unimplemented)", /* 56 = unimplemented */
+ "utssys", /* 57 = utssys */
+ "#58 (unimplemented)", /* 58 = unimplemented */
+ "execve", /* 59 = execve */
+ "umask", /* 60 = umask */
+ "chroot", /* 61 = chroot */
+ "fcntl", /* 62 = fcntl */
+ "ulimit", /* 63 = ulimit */
+ "#64 (unimplemented reserved for unix/pc)", /* 64 = unimplemented reserved for unix/pc */
+ "#65 (unimplemented reserved for unix/pc)", /* 65 = unimplemented reserved for unix/pc */
+ "#66 (unimplemented reserved for unix/pc)", /* 66 = unimplemented reserved for unix/pc */
+ "#67 (unimplemented reserved for unix/pc)", /* 67 = unimplemented reserved for unix/pc */
+ "#68 (unimplemented reserved for unix/pc)", /* 68 = unimplemented reserved for unix/pc */
+ "#69 (unimplemented reserved for unix/pc)", /* 69 = unimplemented reserved for unix/pc */
+ "#70 (obsolete rfs_advfs)", /* 70 = obsolete rfs_advfs */
+ "#71 (obsolete rfs_unadvfs)", /* 71 = obsolete rfs_unadvfs */
+ "#72 (obsolete rfs_rmount)", /* 72 = obsolete rfs_rmount */
+ "#73 (obsolete rfs_rumount)", /* 73 = obsolete rfs_rumount */
+ "#74 (obsolete rfs_rfstart)", /* 74 = obsolete rfs_rfstart */
+ "#75 (obsolete rfs_sigret)", /* 75 = obsolete rfs_sigret */
+ "#76 (obsolete rfs_rdebug)", /* 76 = obsolete rfs_rdebug */
+ "#77 (obsolete rfs_rfstop)", /* 77 = obsolete rfs_rfstop */
+ "#78 (unimplemented rfs_rfsys)", /* 78 = unimplemented rfs_rfsys */
+ "rmdir", /* 79 = rmdir */
+ "mkdir", /* 80 = mkdir */
+ "getdents", /* 81 = getdents */
+ "#82 (unimplemented)", /* 82 = unimplemented */
+ "#83 (unimplemented)", /* 83 = unimplemented */
+ "sysfs", /* 84 = sysfs */
+ "getmsg", /* 85 = getmsg */
+ "putmsg", /* 86 = putmsg */
+ "poll", /* 87 = poll */
+ "#88 (unimplemented)", /* 88 = unimplemented */
+ "#89 (unimplemented)", /* 89 = unimplemented */
+ "symlink", /* 90 = symlink */
+ "lstat", /* 91 = lstat */
+ "readlink", /* 92 = readlink */
+ "#93 (unimplemented)", /* 93 = unimplemented */
+ "#94 (unimplemented)", /* 94 = unimplemented */
+ "#95 (unimplemented)", /* 95 = unimplemented */
+ "#96 (unimplemented)", /* 96 = unimplemented */
+ "#97 (unimplemented)", /* 97 = unimplemented */
+ "#98 (unimplemented)", /* 98 = unimplemented */
+ "#99 (unimplemented)", /* 99 = unimplemented */
+ "#100 (unimplemented)", /* 100 = unimplemented */
+ "#101 (unimplemented)", /* 101 = unimplemented */
+ "#102 (unimplemented)", /* 102 = unimplemented */
+ "sigreturn", /* 103 = sigreturn */
+ "#104 (unimplemented)", /* 104 = unimplemented */
+ "#105 (unimplemented)", /* 105 = unimplemented */
+ "#106 (unimplemented)", /* 106 = unimplemented */
+ "#107 (unimplemented)", /* 107 = unimplemented */
+ "#108 (unimplemented)", /* 108 = unimplemented */
+ "#109 (unimplemented)", /* 109 = unimplemented */
+ "#110 (unimplemented)", /* 110 = unimplemented */
+ "#111 (unimplemented)", /* 111 = unimplemented */
+ "#112 (unimplemented)", /* 112 = unimplemented */
+ "#113 (unimplemented)", /* 113 = unimplemented */
+ "#114 (unimplemented)", /* 114 = unimplemented */
+ "#115 (unimplemented)", /* 115 = unimplemented */
+ "#116 (unimplemented)", /* 116 = unimplemented */
+ "#117 (unimplemented)", /* 117 = unimplemented */
+ "#118 (unimplemented)", /* 118 = unimplemented */
+ "#119 (unimplemented)", /* 119 = unimplemented */
+ "#120 (unimplemented)", /* 120 = unimplemented */
+ "#121 (unimplemented)", /* 121 = unimplemented */
+ "#122 (unimplemented)", /* 122 = unimplemented */
+ "#123 (unimplemented)", /* 123 = unimplemented */
+ "#124 (unimplemented)", /* 124 = unimplemented */
+ "#125 (unimplemented)", /* 125 = unimplemented */
+ "#126 (unimplemented)", /* 126 = unimplemented */
+ "#127 (unimplemented)", /* 127 = unimplemented */
+ "#128 (unimplemented)", /* 128 = unimplemented */
+ "#129 (unimplemented xenix_xlocking)", /* 129 = unimplemented xenix_xlocking */
+ "#130 (unimplemented xenix_creatsem)", /* 130 = unimplemented xenix_creatsem */
+ "#131 (unimplemented xenix_opensem)", /* 131 = unimplemented xenix_opensem */
+ "#132 (unimplemented xenix_sigsem)", /* 132 = unimplemented xenix_sigsem */
+ "#133 (unimplemented xenix_waitsem)", /* 133 = unimplemented xenix_waitsem */
+ "#134 (unimplemented xenix_nbwaitsem)", /* 134 = unimplemented xenix_nbwaitsem */
+ "rdchk", /* 135 = rdchk */
+ "#136 (unimplemented)", /* 136 = unimplemented */
+ "#137 (unimplemented)", /* 137 = unimplemented */
+ "chsize", /* 138 = chsize */
+ "ftime", /* 139 = ftime */
+ "nap", /* 140 = nap */
+ "#141 (unimplemented xenix_sdget)", /* 141 = unimplemented xenix_sdget */
+ "#142 (unimplemented xenix_sdfree)", /* 142 = unimplemented xenix_sdfree */
+ "#143 (unimplemented xenix_sdenter)", /* 143 = unimplemented xenix_sdenter */
+ "#144 (unimplemented xenix_sdleave)", /* 144 = unimplemented xenix_sdleave */
+ "#145 (unimplemented xenix_sdgetv)", /* 145 = unimplemented xenix_sdgetv */
+ "#146 (unimplemented xenix_sdwaitv)", /* 146 = unimplemented xenix_sdwaitv */
+ "#147 (unimplemented)", /* 147 = unimplemented */
+ "#148 (unimplemented)", /* 148 = unimplemented */
+ "#149 (unimplemented)", /* 149 = unimplemented */
+ "#150 (unimplemented)", /* 150 = unimplemented */
+ "#151 (unimplemented)", /* 151 = unimplemented */
+ "#152 (unimplemented)", /* 152 = unimplemented */
+ "#153 (unimplemented)", /* 153 = unimplemented */
+ "#154 (unimplemented)", /* 154 = unimplemented */
+ "#155 (unimplemented)", /* 155 = unimplemented */
+ "#156 (unimplemented)", /* 156 = unimplemented */
+ "#157 (unimplemented)", /* 157 = unimplemented */
+ "#158 (unimplemented)", /* 158 = unimplemented */
+ "#159 (unimplemented)", /* 159 = unimplemented */
+ "#160 (unimplemented xenix_proctl)", /* 160 = unimplemented xenix_proctl */
+ "#161 (unimplemented xenix_execseg)", /* 161 = unimplemented xenix_execseg */
+ "#162 (unimplemented xenix_unexecseg)", /* 162 = unimplemented xenix_unexecseg */
+ "#163 (unimplemented)", /* 163 = unimplemented */
+ "select", /* 164 = select */
+ "#165 (unimplemented xenix_eaccess)", /* 165 = unimplemented xenix_eaccess */
+ "#166 (unimplemented xenix_paccess)", /* 166 = unimplemented xenix_paccess */
+ "sigaction", /* 167 = sigaction */
+ "sigprocmask", /* 168 = sigprocmask */
+ "sigpending", /* 169 = sigpending */
+ "sigsuspend", /* 170 = sigsuspend */
+ "getgroups", /* 171 = getgroups */
+ "setgroups", /* 172 = setgroups */
+ "sysconf", /* 173 = sysconf */
+ "pathconf", /* 174 = pathconf */
+ "fpathconf", /* 175 = fpathconf */
+ "rename", /* 176 = rename */
+};
diff --git a/sys/compat/ibcs2/ibcs2_sysent.c b/sys/compat/ibcs2/ibcs2_sysent.c
new file mode 100644
index 00000000000..01ec246e72b
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_sysent.c
@@ -0,0 +1,409 @@
+/*
+ * System call switch table.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.6 1995/10/07 06:26:56 mycroft Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signal.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <compat/ibcs2/ibcs2_types.h>
+#include <compat/ibcs2/ibcs2_signal.h>
+#include <compat/ibcs2/ibcs2_syscallargs.h>
+#include <compat/ibcs2/ibcs2_statfs.h>
+
+#ifdef COMPAT_43
+#define compat_43(func) __CONCAT(compat_43_,func)
+#else
+#define compat_43(func) sys_nosys
+#endif
+
+#ifdef COMPAT_09
+#define compat_09(func) __CONCAT(compat_09_,func)
+#else
+#define compat_09(func) sys_nosys
+#endif
+
+#ifdef COMPAT_10
+#define compat_10(func) __CONCAT(compat_10_,func)
+#else
+#define compat_10(func) sys_nosys
+#endif
+
+#define s(type) sizeof(type)
+
+struct sysent ibcs2_sysent[] = {
+ { 0, 0,
+ sys_nosys }, /* 0 = syscall */
+ { 1, s(struct sys_exit_args),
+ sys_exit }, /* 1 = exit */
+ { 0, 0,
+ sys_fork }, /* 2 = fork */
+ { 3, s(struct ibcs2_sys_read_args),
+ ibcs2_sys_read }, /* 3 = read */
+ { 3, s(struct sys_write_args),
+ sys_write }, /* 4 = write */
+ { 3, s(struct ibcs2_sys_open_args),
+ ibcs2_sys_open }, /* 5 = open */
+ { 1, s(struct sys_close_args),
+ sys_close }, /* 6 = close */
+ { 3, s(struct ibcs2_sys_waitsys_args),
+ ibcs2_sys_waitsys }, /* 7 = waitsys */
+ { 2, s(struct ibcs2_sys_creat_args),
+ ibcs2_sys_creat }, /* 8 = creat */
+ { 2, s(struct sys_link_args),
+ sys_link }, /* 9 = link */
+ { 1, s(struct ibcs2_sys_unlink_args),
+ ibcs2_sys_unlink }, /* 10 = unlink */
+ { 2, s(struct ibcs2_sys_execv_args),
+ ibcs2_sys_execv }, /* 11 = execv */
+ { 1, s(struct ibcs2_sys_chdir_args),
+ ibcs2_sys_chdir }, /* 12 = chdir */
+ { 1, s(struct ibcs2_sys_time_args),
+ ibcs2_sys_time }, /* 13 = time */
+ { 3, s(struct ibcs2_sys_mknod_args),
+ ibcs2_sys_mknod }, /* 14 = mknod */
+ { 2, s(struct ibcs2_sys_chmod_args),
+ ibcs2_sys_chmod }, /* 15 = chmod */
+ { 3, s(struct ibcs2_sys_chown_args),
+ ibcs2_sys_chown }, /* 16 = chown */
+ { 1, s(struct sys_obreak_args),
+ sys_obreak }, /* 17 = obreak */
+ { 2, s(struct ibcs2_sys_stat_args),
+ ibcs2_sys_stat }, /* 18 = stat */
+ { 3, s(struct compat_43_sys_lseek_args),
+ compat_43_sys_lseek }, /* 19 = lseek */
+ { 0, 0,
+ sys_getpid }, /* 20 = getpid */
+ { 6, s(struct ibcs2_sys_mount_args),
+ ibcs2_sys_mount }, /* 21 = mount */
+ { 1, s(struct ibcs2_sys_umount_args),
+ ibcs2_sys_umount }, /* 22 = umount */
+ { 1, s(struct ibcs2_sys_setuid_args),
+ ibcs2_sys_setuid }, /* 23 = setuid */
+ { 0, 0,
+ sys_getuid }, /* 24 = getuid */
+ { 1, s(struct ibcs2_sys_stime_args),
+ ibcs2_sys_stime }, /* 25 = stime */
+ { 0, 0,
+ sys_nosys }, /* 26 = unimplemented ibcs2_ptrace */
+ { 1, s(struct ibcs2_sys_alarm_args),
+ ibcs2_sys_alarm }, /* 27 = alarm */
+ { 2, s(struct ibcs2_sys_fstat_args),
+ ibcs2_sys_fstat }, /* 28 = fstat */
+ { 0, 0,
+ ibcs2_sys_pause }, /* 29 = pause */
+ { 2, s(struct ibcs2_sys_utime_args),
+ ibcs2_sys_utime }, /* 30 = utime */
+ { 0, 0,
+ sys_nosys }, /* 31 = unimplemented was stty */
+ { 0, 0,
+ sys_nosys }, /* 32 = unimplemented was gtty */
+ { 2, s(struct ibcs2_sys_access_args),
+ ibcs2_sys_access }, /* 33 = access */
+ { 1, s(struct ibcs2_sys_nice_args),
+ ibcs2_sys_nice }, /* 34 = nice */
+ { 4, s(struct ibcs2_sys_statfs_args),
+ ibcs2_sys_statfs }, /* 35 = statfs */
+ { 0, 0,
+ sys_sync }, /* 36 = sync */
+ { 2, s(struct ibcs2_sys_kill_args),
+ ibcs2_sys_kill }, /* 37 = kill */
+ { 4, s(struct ibcs2_sys_fstatfs_args),
+ ibcs2_sys_fstatfs }, /* 38 = fstatfs */
+ { 4, s(struct ibcs2_sys_pgrpsys_args),
+ ibcs2_sys_pgrpsys }, /* 39 = pgrpsys */
+ { 0, 0,
+ sys_nosys }, /* 40 = unimplemented ibcs2_xenix */
+ { 1, s(struct sys_dup_args),
+ sys_dup }, /* 41 = dup */
+ { 0, 0,
+ sys_pipe }, /* 42 = pipe */
+ { 1, s(struct ibcs2_sys_times_args),
+ ibcs2_sys_times }, /* 43 = times */
+ { 0, 0,
+ sys_nosys }, /* 44 = unimplemented profil */
+ { 1, s(struct ibcs2_sys_plock_args),
+ ibcs2_sys_plock }, /* 45 = plock */
+ { 1, s(struct ibcs2_sys_setgid_args),
+ ibcs2_sys_setgid }, /* 46 = setgid */
+ { 0, 0,
+ sys_getgid }, /* 47 = getgid */
+ { 2, s(struct ibcs2_sys_sigsys_args),
+ ibcs2_sys_sigsys }, /* 48 = sigsys */
+#ifdef SYSVMSG
+ { 6, s(struct ibcs2_sys_msgsys_args),
+ ibcs2_sys_msgsys }, /* 49 = msgsys */
+#else
+ { 0, 0,
+ sys_nosys }, /* 49 = unimplemented msgsys */
+#endif
+ { 0, 0,
+ sys_nosys }, /* 50 = unimplemented ibcs2_sys3b */
+ { 0, 0,
+ sys_nosys }, /* 51 = unimplemented ibcs2_acct */
+#ifdef SYSVSHM
+ { 4, s(struct ibcs2_sys_shmsys_args),
+ ibcs2_sys_shmsys }, /* 52 = shmsys */
+#else
+ { 0, 0,
+ sys_nosys }, /* 52 = unimplemented shmsys */
+#endif
+#ifdef SYSVSEM
+ { 5, s(struct ibcs2_sys_semsys_args),
+ ibcs2_sys_semsys }, /* 53 = semsys */
+#else
+ { 0, 0,
+ sys_nosys }, /* 53 = unimplemented semsys */
+#endif
+ { 3, s(struct ibcs2_sys_ioctl_args),
+ ibcs2_sys_ioctl }, /* 54 = ioctl */
+ { 3, s(struct ibcs2_sys_uadmin_args),
+ ibcs2_sys_uadmin }, /* 55 = uadmin */
+ { 0, 0,
+ sys_nosys }, /* 56 = unimplemented */
+ { 3, s(struct ibcs2_sys_utssys_args),
+ ibcs2_sys_utssys }, /* 57 = utssys */
+ { 0, 0,
+ sys_nosys }, /* 58 = unimplemented */
+ { 3, s(struct ibcs2_sys_execve_args),
+ ibcs2_sys_execve }, /* 59 = execve */
+ { 1, s(struct sys_umask_args),
+ sys_umask }, /* 60 = umask */
+ { 1, s(struct sys_chroot_args),
+ sys_chroot }, /* 61 = chroot */
+ { 3, s(struct ibcs2_sys_fcntl_args),
+ ibcs2_sys_fcntl }, /* 62 = fcntl */
+ { 2, s(struct ibcs2_sys_ulimit_args),
+ ibcs2_sys_ulimit }, /* 63 = ulimit */
+ { 0, 0,
+ sys_nosys }, /* 64 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ sys_nosys }, /* 65 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ sys_nosys }, /* 66 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ sys_nosys }, /* 67 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ sys_nosys }, /* 68 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ sys_nosys }, /* 69 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ sys_nosys }, /* 70 = obsolete rfs_advfs */
+ { 0, 0,
+ sys_nosys }, /* 71 = obsolete rfs_unadvfs */
+ { 0, 0,
+ sys_nosys }, /* 72 = obsolete rfs_rmount */
+ { 0, 0,
+ sys_nosys }, /* 73 = obsolete rfs_rumount */
+ { 0, 0,
+ sys_nosys }, /* 74 = obsolete rfs_rfstart */
+ { 0, 0,
+ sys_nosys }, /* 75 = obsolete rfs_sigret */
+ { 0, 0,
+ sys_nosys }, /* 76 = obsolete rfs_rdebug */
+ { 0, 0,
+ sys_nosys }, /* 77 = obsolete rfs_rfstop */
+ { 0, 0,
+ sys_nosys }, /* 78 = unimplemented rfs_rfsys */
+ { 1, s(struct ibcs2_sys_rmdir_args),
+ ibcs2_sys_rmdir }, /* 79 = rmdir */
+ { 2, s(struct ibcs2_sys_mkdir_args),
+ ibcs2_sys_mkdir }, /* 80 = mkdir */
+ { 3, s(struct ibcs2_sys_getdents_args),
+ ibcs2_sys_getdents }, /* 81 = getdents */
+ { 0, 0,
+ sys_nosys }, /* 82 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 83 = unimplemented */
+ { 3, s(struct ibcs2_sys_sysfs_args),
+ ibcs2_sys_sysfs }, /* 84 = sysfs */
+ { 4, s(struct ibcs2_sys_getmsg_args),
+ ibcs2_sys_getmsg }, /* 85 = getmsg */
+ { 4, s(struct ibcs2_sys_putmsg_args),
+ ibcs2_sys_putmsg }, /* 86 = putmsg */
+ { 3, s(struct ibcs2_sys_poll_args),
+ ibcs2_sys_poll }, /* 87 = poll */
+ { 0, 0,
+ sys_nosys }, /* 88 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 89 = unimplemented */
+ { 2, s(struct ibcs2_sys_symlink_args),
+ ibcs2_sys_symlink }, /* 90 = symlink */
+ { 2, s(struct ibcs2_sys_lstat_args),
+ ibcs2_sys_lstat }, /* 91 = lstat */
+ { 3, s(struct ibcs2_sys_readlink_args),
+ ibcs2_sys_readlink }, /* 92 = readlink */
+ { 0, 0,
+ sys_nosys }, /* 93 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 94 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 95 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 96 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 97 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 98 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 99 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 100 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 101 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 102 = unimplemented */
+ { 1, s(struct sys_sigreturn_args),
+ sys_sigreturn }, /* 103 = sigreturn */
+ { 0, 0,
+ sys_nosys }, /* 104 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 105 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 106 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 107 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 108 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 109 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 110 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 111 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 112 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 113 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 114 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 115 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 116 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 117 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 118 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 119 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 120 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 121 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 122 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 123 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 124 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 125 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 126 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 127 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 128 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 129 = unimplemented xenix_xlocking */
+ { 0, 0,
+ sys_nosys }, /* 130 = unimplemented xenix_creatsem */
+ { 0, 0,
+ sys_nosys }, /* 131 = unimplemented xenix_opensem */
+ { 0, 0,
+ sys_nosys }, /* 132 = unimplemented xenix_sigsem */
+ { 0, 0,
+ sys_nosys }, /* 133 = unimplemented xenix_waitsem */
+ { 0, 0,
+ sys_nosys }, /* 134 = unimplemented xenix_nbwaitsem */
+ { 1, s(struct xenix_sys_rdchk_args),
+ xenix_sys_rdchk }, /* 135 = rdchk */
+ { 0, 0,
+ sys_nosys }, /* 136 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 137 = unimplemented */
+ { 2, s(struct xenix_sys_chsize_args),
+ xenix_sys_chsize }, /* 138 = chsize */
+ { 1, s(struct xenix_sys_ftime_args),
+ xenix_sys_ftime }, /* 139 = ftime */
+ { 1, s(struct xenix_sys_nap_args),
+ xenix_sys_nap }, /* 140 = nap */
+ { 0, 0,
+ sys_nosys }, /* 141 = unimplemented xenix_sdget */
+ { 0, 0,
+ sys_nosys }, /* 142 = unimplemented xenix_sdfree */
+ { 0, 0,
+ sys_nosys }, /* 143 = unimplemented xenix_sdenter */
+ { 0, 0,
+ sys_nosys }, /* 144 = unimplemented xenix_sdleave */
+ { 0, 0,
+ sys_nosys }, /* 145 = unimplemented xenix_sdgetv */
+ { 0, 0,
+ sys_nosys }, /* 146 = unimplemented xenix_sdwaitv */
+ { 0, 0,
+ sys_nosys }, /* 147 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 148 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 149 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 150 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 151 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 152 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 153 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 154 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 155 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 156 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 157 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 158 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 159 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 160 = unimplemented xenix_proctl */
+ { 0, 0,
+ sys_nosys }, /* 161 = unimplemented xenix_execseg */
+ { 0, 0,
+ sys_nosys }, /* 162 = unimplemented xenix_unexecseg */
+ { 0, 0,
+ sys_nosys }, /* 163 = unimplemented */
+ { 5, s(struct sys_select_args),
+ sys_select }, /* 164 = select */
+ { 0, 0,
+ sys_nosys }, /* 165 = unimplemented xenix_eaccess */
+ { 0, 0,
+ sys_nosys }, /* 166 = unimplemented xenix_paccess */
+ { 3, s(struct ibcs2_sys_sigaction_args),
+ ibcs2_sys_sigaction }, /* 167 = sigaction */
+ { 3, s(struct ibcs2_sys_sigprocmask_args),
+ ibcs2_sys_sigprocmask }, /* 168 = sigprocmask */
+ { 1, s(struct ibcs2_sys_sigpending_args),
+ ibcs2_sys_sigpending }, /* 169 = sigpending */
+ { 1, s(struct ibcs2_sys_sigsuspend_args),
+ ibcs2_sys_sigsuspend }, /* 170 = sigsuspend */
+ { 2, s(struct ibcs2_sys_getgroups_args),
+ ibcs2_sys_getgroups }, /* 171 = getgroups */
+ { 2, s(struct ibcs2_sys_setgroups_args),
+ ibcs2_sys_setgroups }, /* 172 = setgroups */
+ { 1, s(struct ibcs2_sys_sysconf_args),
+ ibcs2_sys_sysconf }, /* 173 = sysconf */
+ { 2, s(struct ibcs2_sys_pathconf_args),
+ ibcs2_sys_pathconf }, /* 174 = pathconf */
+ { 2, s(struct ibcs2_sys_fpathconf_args),
+ ibcs2_sys_fpathconf }, /* 175 = fpathconf */
+ { 2, s(struct ibcs2_sys_rename_args),
+ ibcs2_sys_rename }, /* 176 = rename */
+};
+
diff --git a/sys/compat/ibcs2/ibcs2_termios.h b/sys/compat/ibcs2/ibcs2_termios.h
new file mode 100644
index 00000000000..35602cf999d
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_termios.h
@@ -0,0 +1,235 @@
+/* $NetBSD: ibcs2_termios.h,v 1.3 1994/10/26 02:53:07 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_TERMIOS_H
+#define _IBCS2_TERMIOS_H 1
+
+#include <compat/ibcs2/ibcs2_types.h>
+
+#define IBCS2_NCC 8
+#define IBCS2_NCCS 13
+
+typedef u_short ibcs2_tcflag_t;
+typedef u_char ibcs2_cc_t;
+typedef u_long ibcs2_speed_t;
+
+struct ibcs2_termio {
+ u_short c_iflag;
+ u_short c_oflag;
+ u_short c_cflag;
+ u_short c_lflag;
+ char c_line;
+ u_char c_cc[IBCS2_NCC];
+};
+
+struct ibcs2_termios {
+ ibcs2_tcflag_t c_iflag;
+ ibcs2_tcflag_t c_oflag;
+ ibcs2_tcflag_t c_cflag;
+ ibcs2_tcflag_t c_lflag;
+ char c_line;
+ ibcs2_cc_t c_cc[IBCS2_NCCS];
+ char c_ispeed;
+ char c_ospeed;
+};
+
+#define IBCS2_VINTR 0
+#define IBCS2_VQUIT 1
+#define IBCS2_VERASE 2
+#define IBCS2_VKILL 3
+#define IBCS2_VEOF 4
+#define IBCS2_VEOL 5
+#define IBCS2_VEOL2 6
+#define IBCS2_VMIN 4
+#define IBCS2_VTIME 5
+#define IBCS2_VSWTCH 7
+#define IBCS2_VSUSP 10
+#define IBCS2_VSTART 11
+#define IBCS2_VSTOP 12
+
+#define IBCS2_CNUL 0
+#define IBCS2_CDEL 0377
+#define IBCS2_CESC '\\'
+#define IBCS2_CINTR 0177
+#define IBCS2_CQUIT 034
+#define IBCS2_CERASE '#'
+#define IBCS2_CKILL '@'
+#define IBCS2_CSTART 021
+#define IBCS2_CSTOP 023
+#define IBCS2_CSWTCH 032
+#define IBCS2_CNSWTCH 0
+#define IBCS2_CSUSP 032
+
+#define IBCS2_IGNBRK 0000001
+#define IBCS2_BRKINT 0000002
+#define IBCS2_IGNPAR 0000004
+#define IBCS2_PARMRK 0000010
+#define IBCS2_INPCK 0000020
+#define IBCS2_ISTRIP 0000040
+#define IBCS2_INLCR 0000100
+#define IBCS2_IGNCR 0000200
+#define IBCS2_ICRNL 0000400
+#define IBCS2_IUCLC 0001000
+#define IBCS2_IXON 0002000
+#define IBCS2_IXANY 0004000
+#define IBCS2_IXOFF 0010000
+#define IBCS2_IMAXBEL 0020000
+#define IBCS2_DOSMODE 0100000
+
+#define IBCS2_OPOST 0000001
+#define IBCS2_OLCUC 0000002
+#define IBCS2_ONLCR 0000004
+#define IBCS2_OCRNL 0000010
+#define IBCS2_ONOCR 0000020
+#define IBCS2_ONLRET 0000040
+#define IBCS2_OFILL 0000100
+#define IBCS2_OFDEL 0000200
+#define IBCS2_NLDLY 0000400
+#define IBCS2_NL0 0000000
+#define IBCS2_NL1 0000400
+#define IBCS2_CRDLY 0003000
+#define IBCS2_CR0 0000000
+#define IBCS2_CR1 0001000
+#define IBCS2_CR2 0002000
+#define IBCS2_CR3 0003000
+#define IBCS2_TABDLY 0014000
+#define IBCS2_TAB0 0000000
+#define IBCS2_TAB1 0004000
+#define IBCS2_TAB2 0010000
+#define IBCS2_TAB3 0014000
+#define IBCS2_BSDLY 0020000
+#define IBCS2_BS0 0000000
+#define IBCS2_BS1 0020000
+#define IBCS2_VTDLY 0040000
+#define IBCS2_VT0 0000000
+#define IBCS2_VT1 0040000
+#define IBCS2_FFDLY 0100000
+#define IBCS2_FF0 0000000
+#define IBCS2_FF1 0100000
+
+#define IBCS2_CBAUD 0000017
+#define IBCS2_CSIZE 0000060
+#define IBCS2_CS5 0000000
+#define IBCS2_CS6 0000020
+#define IBCS2_CS7 0000040
+#define IBCS2_CS8 0000060
+#define IBCS2_CSTOPB 0000100
+#define IBCS2_CREAD 0000200
+#define IBCS2_PARENB 0000400
+#define IBCS2_PARODD 0001000
+#define IBCS2_HUPCL 0002000
+#define IBCS2_CLOCAL 0004000
+#define IBCS2_RCV1EN 0010000
+#define IBCS2_XMT1EN 0020000
+#define IBCS2_LOBLK 0040000
+#define IBCS2_XCLUDE 0100000
+
+#define IBCS2_ISIG 0000001
+#define IBCS2_ICANON 0000002
+#define IBCS2_XCASE 0000004
+#define IBCS2_ECHO 0000010
+#define IBCS2_ECHOE 0000020
+#define IBCS2_ECHOK 0000040
+#define IBCS2_ECHONL 0000100
+#define IBCS2_NOFLSH 0000200
+#define IBCS2_IEXTEN 0000400
+#define IBCS2_TOSTOP 0001000
+
+#define IBCS2_XIOC (('i'<<24)|('X'<<16))
+#define IBCS2_XCGETA (IBCS2_XIOC|1)
+#define IBCS2_XCSETA (IBCS2_XIOC|2)
+#define IBCS2_XCSETAW (IBCS2_XIOC|3)
+#define IBCS2_XCSETAF (IBCS2_XIOC|4)
+
+#define IBCS2_OXIOC ('x'<<8)
+#define IBCS2_OXCGETA (IBCS2_OXIOC|1)
+#define IBCS2_OXCSETA (IBCS2_OXIOC|2)
+#define IBCS2_OXCSETAW (IBCS2_OXIOC|3)
+#define IBCS2_OXCSETAF (IBCS2_OXIOC|4)
+
+#define IBCS2_TIOC ('T'<<8)
+#define IBCS2_TCGETA (IBCS2_TIOC|1)
+#define IBCS2_TCSETA (IBCS2_TIOC|2)
+#define IBCS2_TCSETAW (IBCS2_TIOC|3)
+#define IBCS2_TCSETAF (IBCS2_TIOC|4)
+#define IBCS2_TCSBRK (IBCS2_TIOC|5)
+#define IBCS2_TCXONC (IBCS2_TIOC|6)
+#define IBCS2_TCFLSH (IBCS2_TIOC|7)
+
+#define IBCS2_TCGETSC (IBCS2_TIOC|34)
+#define IBCS2_TCSETSC (IBCS2_TIOC|35)
+
+#define IBCS2_TIOCSWINSZ (IBCS2_TIOC|103)
+#define IBCS2_TIOCGWINSZ (IBCS2_TIOC|104)
+#define IBCS2_TIOCSPGRP (IBCS2_TIOC|118)
+#define IBCS2_TIOCGPGRP (IBCS2_TIOC|119)
+
+#define IBCS2_TCSANOW IBCS2_XCSETA
+#define IBCS2_TCSADRAIN IBCS2_XCSETAW
+#define IBCS2_TCSAFLUSH IBCS2_XCSETAF
+#define IBCS2_TCSADFLUSH IBCS2_XCSETAF
+
+#define IBCS2_TCIFLUSH 0
+#define IBCS2_TCOFLUSH 1
+#define IBCS2_TCIOFLUSH 2
+
+#define IBCS2_TCOOFF 0
+#define IBCS2_TCOON 1
+#define IBCS2_TCIOFF 2
+#define IBCS2_TCION 3
+
+#define IBCS2_B0 0
+#define IBCS2_B50 1
+#define IBCS2_B75 2
+#define IBCS2_B110 3
+#define IBCS2_B134 4
+#define IBCS2_B150 5
+#define IBCS2_B200 6
+#define IBCS2_B300 7
+#define IBCS2_B600 8
+#define IBCS2_B1200 9
+#define IBCS2_B1800 10
+#define IBCS2_B2400 11
+#define IBCS2_B4800 12
+#define IBCS2_B9600 13
+#define IBCS2_B19200 14
+#define IBCS2_B38400 15
+
+struct ibcs2_winsize {
+ u_short ws_row;
+ u_short ws_col;
+ u_short ws_xpixel;
+ u_short ws_ypixel;
+};
+
+#endif /* _IBCS2_H_ */
+
diff --git a/sys/compat/ibcs2/ibcs2_time.h b/sys/compat/ibcs2/ibcs2_time.h
new file mode 100644
index 00000000000..a3b669b6ae3
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_time.h
@@ -0,0 +1,50 @@
+/* $NetBSD: ibcs2_time.h,v 1.2 1994/10/26 02:53:08 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_TIME_H
+#define _IBCS2_TIME_H
+
+#include <compat/ibcs2/ibcs2_types.h>
+
+struct ibcs2_tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+};
+
+#endif /* _IBCS2_TIME_H */
diff --git a/sys/compat/ibcs2/ibcs2_timeb.h b/sys/compat/ibcs2/ibcs2_timeb.h
new file mode 100644
index 00000000000..d85202d9172
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_timeb.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 1995 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_TIMEB_H
+#define _IBCS2_TIMEB_H
+
+#pragma pack(2)
+struct xenix_timeb {
+ ibcs2_time_t time;
+ unsigned short millitm;
+ short timezone;
+ short dstflag;
+};
+#pragma pack()
+
+#define xenix_timeb_len 10 /* packed struct */
+
+#endif /* _IBCS2_TIMEB_H */
diff --git a/sys/compat/ibcs2/ibcs2_types.h b/sys/compat/ibcs2/ibcs2_types.h
new file mode 100644
index 00000000000..305a1fc6f44
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_types.h
@@ -0,0 +1,54 @@
+/* $NetBSD: ibcs2_types.h,v 1.5 1995/08/14 01:11:54 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_TYPES_H
+#define _IBCS2_TYPES_H
+
+typedef unsigned char ibcs2_uchar_t;
+typedef unsigned long ibcs2_ulong_t;
+
+typedef char * ibcs2_caddr_t;
+typedef long ibcs2_daddr_t;
+typedef long ibcs2_off_t;
+typedef long ibcs2_key_t;
+typedef unsigned short ibcs2_uid_t;
+typedef unsigned short ibcs2_gid_t;
+typedef short ibcs2_nlink_t;
+typedef short ibcs2_dev_t;
+typedef unsigned short ibcs2_ino_t;
+typedef unsigned int ibcs2_size_t;
+typedef long ibcs2_time_t;
+typedef long ibcs2_clock_t;
+typedef unsigned short ibcs2_mode_t;
+typedef short ibcs2_pid_t;
+
+#endif /* _IBCS2_TYPES_H */
diff --git a/sys/compat/ibcs2/ibcs2_unistd.h b/sys/compat/ibcs2/ibcs2_unistd.h
new file mode 100644
index 00000000000..1a0dd669412
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_unistd.h
@@ -0,0 +1,75 @@
+/* $NetBSD: ibcs2_unistd.h,v 1.2 1994/10/26 02:53:11 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_UNISTD_H
+#define _IBCS2_UNISTD_H
+
+#define IBCS2_R_OK 4
+#define IBCS2_W_OK 2
+#define IBCS2_X_OK 1
+#define IBCS2_F_OK 0
+
+#define IBCS2_F_ULOCK 0
+#define IBCS2_F_LOCK 1
+#define IBCS2_F_TLOCK 2
+#define IBCS2_F_TEST 3
+
+#define IBCS2_SEEK_SET 0
+#define IBCS2_SEEK_CUR 1
+#define IBCS2_SEEK_END 2
+
+#define IBCS2_SC_ARG_MAX 0
+#define IBCS2_SC_CHILD_MAX 1
+#define IBCS2_SC_CLK_TCK 2
+#define IBCS2_SC_NGROUPS_MAX 3
+#define IBCS2_SC_OPEN_MAX 4
+#define IBCS2_SC_JOB_CONTROL 5
+#define IBCS2_SC_SAVED_IDS 6
+#define IBCS2_SC_VERSION 7
+#define IBCS2_SC_PASS_MAX 8
+#define IBCS2_SC_XOPEN_VERSION 9
+
+#define IBCS2_PC_LINK_MAX 0
+#define IBCS2_PC_MAX_CANON 1
+#define IBCS2_PC_MAX_INPUT 2
+#define IBCS2_PC_NAME_MAX 3
+#define IBCS2_PC_PATH_MAX 4
+#define IBCS2_PC_PIPE_BUF 5
+#define IBCS2_PC_CHOWN_RESTRICTED 6
+#define IBCS2_PC_NO_TRUNC 7
+#define IBCS2_PC_VDISABLE 8
+
+#define IBCS2_STDIN_FILENO 0
+#define IBCS2_STDOUT_FILENO 1
+#define IBCS2_STDERR_FILENO 2
+
+#endif /* _IBCS2_UNISTD_H */
diff --git a/sys/compat/ibcs2/ibcs2_ustat.h b/sys/compat/ibcs2/ibcs2_ustat.h
new file mode 100644
index 00000000000..03c71463591
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_ustat.h
@@ -0,0 +1,46 @@
+/* $NetBSD: ibcs2_ustat.h,v 1.2 1994/10/26 02:53:13 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_USTAT_H
+#define _IBCS2_USTAT_H 1
+
+#include <compat/ibcs2/ibcs2_types.h>
+
+struct ibcs2_ustat {
+ long f_tfree;
+ ibcs2_ino_t f_tinode;
+ char f_fname[6];
+ char f_fpack[6];
+};
+#define ibcs2_ustat_len (sizeof(struct ibcs2_ustat))
+
+#endif /* _IBCS2_USTAT_H */
diff --git a/sys/compat/ibcs2/ibcs2_util.h b/sys/compat/ibcs2/ibcs2_util.h
new file mode 100644
index 00000000000..167550d91ba
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_util.h
@@ -0,0 +1,52 @@
+/* $NetBSD: ibcs2_util.h,v 1.2 1995/06/24 20:19:06 christos Exp $ */
+
+/*
+ * Copyright (c) 1994 Christos Zoulas
+ * Copyright (c) 1995 Frank van der Linden
+ * Copyright (c) 1995 Scott Bartram
+ * 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.
+ *
+ */
+
+#ifndef _IBCS2_UTIL_H_
+#define _IBCS2_UTIL_H_
+
+#include <compat/common/compat_util.h>
+
+#ifdef DEBUG_IBCS2
+#define DPRINTF(a) printf a;
+#else
+#define DPRINTF(a)
+#endif
+
+extern const char ibcs2_emul_path[];
+
+#define IBCS2_CHECK_ALT_EXIST(p, sgp, path) \
+ CHECK_ALT_EXIST(p, sgp, ibcs2_emul_path, path)
+
+#define IBCS2_CHECK_ALT_CREAT(p, sgp, path) \
+ CHECK_ALT_CREAT(p, sgp, ibcs2_emul_path, path)
+
+#endif /* !_IBCS2_UTIL_H_ */
diff --git a/sys/compat/ibcs2/ibcs2_utime.h b/sys/compat/ibcs2/ibcs2_utime.h
new file mode 100644
index 00000000000..02d83150a27
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_utime.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 1995 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_UTIME_H
+#define _IBCS2_UTIME_H
+
+#include <compat/ibcs2/ibcs2_types.h>
+
+struct ibcs2_utimbuf {
+ ibcs2_time_t actime;
+ ibcs2_time_t modtime;
+};
+
+#endif /* _IBCS2_UTIME_H */
diff --git a/sys/compat/ibcs2/ibcs2_utsname.h b/sys/compat/ibcs2/ibcs2_utsname.h
new file mode 100644
index 00000000000..4f2ee68f7a9
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_utsname.h
@@ -0,0 +1,45 @@
+/* $NetBSD: ibcs2_utsname.h,v 1.2 1994/10/26 02:53:14 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_UTSNAME_H
+#define _IBCS2_UTSNAME_H
+
+struct ibcs2_utsname {
+ char sysname[9];
+ char nodename[9];
+ char release[9];
+ char version[9];
+ char machine[9];
+};
+#define ibcs2_utsname_len (sizeof(struct ibcs2_utsname))
+
+#endif /* _IBCS2_UTSNAME_H */
diff --git a/sys/compat/ibcs2/ibcs2_wait.h b/sys/compat/ibcs2/ibcs2_wait.h
new file mode 100644
index 00000000000..215d31eeef3
--- /dev/null
+++ b/sys/compat/ibcs2/ibcs2_wait.h
@@ -0,0 +1,47 @@
+/* $NetBSD: ibcs2_wait.h,v 1.2 1994/10/26 02:53:16 cgd Exp $ */
+
+/*
+ * Copyright (c) 1994 Scott Bartram
+ * 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 Scott Bartram.
+ * 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.
+ */
+
+#ifndef _IBCS2_WAIT_H
+#define _IBCS2_WAIT_H
+
+#define IBCS2_WUNTRACED 0x02
+#define IBCS2_WNOHANG 0x01
+
+#define IBCS2_WIFEXITED(stat) ((stat & 0xff) == 0)
+#define IBCS2_WIFSIGNALED(stat) ((stat) && (stat == (stat & 0xff)))
+#define IBCS2_WIFSTOPPED(stat) ((stat & 0xff) == 0x7f)
+
+#define IBCS2_WEXITSTATUS(stat) ((stat >> 8) & 0xff)
+#define IBCS2_WTERMSIG(stat) (stat & 0x7f)
+#define IBCS2_WSTOPSIG(stat) ((stat >> 8) & 0xff)
+
+#endif /* _IBCS2_WAIT_H */
diff --git a/sys/compat/ibcs2/syscalls.conf b/sys/compat/ibcs2/syscalls.conf
new file mode 100644
index 00000000000..7f46f443340
--- /dev/null
+++ b/sys/compat/ibcs2/syscalls.conf
@@ -0,0 +1,12 @@
+# syscalls.conf
+
+sysnames="ibcs2_syscalls.c"
+sysnumhdr="ibcs2_syscall.h"
+syssw="ibcs2_sysent.c"
+sysarghdr="ibcs2_syscallargs.h"
+compatopts="compat_43 compat_09 compat_10"
+libcompatopts=""
+
+switchname="ibcs2_sysent"
+namesname="ibcs2_syscallnames"
+constprefix="IBCS2_SYS_"
diff --git a/sys/compat/ibcs2/syscalls.master b/sys/compat/ibcs2/syscalls.master
new file mode 100644
index 00000000000..b661d89bfca
--- /dev/null
+++ b/sys/compat/ibcs2/syscalls.master
@@ -0,0 +1,258 @@
+ $NetBSD: syscalls.master,v 1.6 1995/10/07 06:26:56 mycroft Exp $
+
+; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
+
+; NetBSD COMPAT_IBCS2 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
+;
+; 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 <compat/ibcs2/ibcs2_types.h>
+#include <compat/ibcs2/ibcs2_signal.h>
+#include <compat/ibcs2/ibcs2_syscallargs.h>
+#include <compat/ibcs2/ibcs2_statfs.h>
+
+0 NOARGS { int sys_nosys(void); } syscall
+1 NOARGS { int sys_exit(int rval); }
+2 NOARGS { int sys_fork(void); }
+3 STD { int ibcs2_sys_read(int fd, char *buf, u_int nbytes); }
+4 NOARGS { int sys_write(int fd, char *buf, u_int nbytes); }
+5 STD { int ibcs2_sys_open(char *path, int flags, int mode); }
+6 NOARGS { int sys_close(int fd); }
+7 STD { int ibcs2_sys_waitsys(int a1, int a2, int a3); }
+8 STD { int ibcs2_sys_creat(char *path, int mode); }
+9 NOARGS { int sys_link(char *path, char *link); }
+10 STD { int ibcs2_sys_unlink(char *path); }
+11 STD { int ibcs2_sys_execv(char *path, char **argp); }
+12 STD { int ibcs2_sys_chdir(char *path); }
+13 STD { int ibcs2_sys_time(ibcs2_time_t *tp); }
+14 STD { int ibcs2_sys_mknod(char* path, int mode, int dev); }
+15 STD { int ibcs2_sys_chmod(char *path, int mode); }
+16 STD { int ibcs2_sys_chown(char *path, int uid, int gid); }
+17 NOARGS { int sys_obreak(caddr_t nsize); }
+18 STD { int ibcs2_sys_stat(char* path, \
+ struct ibcs2_stat *st); }
+19 NOARGS { long compat_43_sys_lseek(int fd, long offset, \
+ int whence); }
+20 NOARGS { pid_t sys_getpid(void); }
+21 STD { int ibcs2_sys_mount(char *special, char *dir, \
+ int flags, int fstype, char *data, int len); }
+22 STD { int ibcs2_sys_umount(char *name); }
+23 STD { int ibcs2_sys_setuid(int uid); }
+24 NOARGS { uid_t sys_getuid(void); }
+25 STD { int ibcs2_sys_stime(long *timep); }
+26 UNIMPL ibcs2_ptrace
+27 STD { int ibcs2_sys_alarm(unsigned sec); }
+28 STD { int ibcs2_sys_fstat(int fd, struct ibcs2_stat *st); }
+29 STD { int ibcs2_sys_pause(void); }
+30 STD { int ibcs2_sys_utime(char *path, \
+ struct ibcs2_utimbuf *buf); }
+31 UNIMPL was stty
+32 UNIMPL was gtty
+33 STD { int ibcs2_sys_access(char *path, int flags); }
+34 STD { int ibcs2_sys_nice(int incr); }
+35 STD { int ibcs2_sys_statfs(char *path, \
+ struct ibcs2_statfs *buf, int len, int fstype); }
+36 NOARGS { int sys_sync(void); }
+37 STD { int ibcs2_sys_kill(int pid, int signo); }
+38 STD { int ibcs2_sys_fstatfs(int fd, \
+ struct ibcs2_statfs *buf, int len, int fstype); }
+39 STD { int ibcs2_sys_pgrpsys(int type, caddr_t dummy, \
+ int pid, int pgid); }
+40 UNIMPL ibcs2_xenix
+41 NOARGS { int sys_dup(u_int fd); }
+42 NOARGS { int sys_pipe(void); }
+43 STD { int ibcs2_sys_times(struct tms *tp); }
+44 UNIMPL profil
+45 STD { int ibcs2_sys_plock(int cmd); }
+46 STD { int ibcs2_sys_setgid(int gid); }
+47 NOARGS { gid_t sys_getgid(void); }
+48 STD { int ibcs2_sys_sigsys(int sig, ibcs2_sig_t fp); }
+#ifdef SYSVMSG
+49 STD { int ibcs2_sys_msgsys(int which, int a2, int a3, \
+ int a4, int a5, int a6); }
+#else
+49 UNIMPL msgsys
+#endif
+50 UNIMPL ibcs2_sys3b
+51 UNIMPL ibcs2_acct
+#ifdef SYSVSHM
+52 STD { int ibcs2_sys_shmsys(int which, int a2, int a3, \
+ int a4); }
+#else
+52 UNIMPL shmsys
+#endif
+#ifdef SYSVSEM
+53 STD { int ibcs2_sys_semsys(int which, int a2, int a3, \
+ int a4, int a5); }
+#else
+53 UNIMPL semsys
+#endif
+54 STD { int ibcs2_sys_ioctl(int fd, int cmd, caddr_t data); }
+55 STD { int ibcs2_sys_uadmin(int cmd, int func, \
+ caddr_t data); }
+56 UNIMPL
+57 STD { int ibcs2_sys_utssys(int a1, int a2, int flag); }
+58 UNIMPL
+59 STD { int ibcs2_sys_execve(char *path, char **argp, \
+ char **envp); }
+60 NOARGS { int sys_umask(int newmask); }
+61 NOARGS { int sys_chroot(char *path); }
+62 STD { int ibcs2_sys_fcntl(int fd, int cmd, char *arg); }
+63 STD { long ibcs2_sys_ulimit(int cmd, int newlimit); }
+64 UNIMPL reserved for unix/pc
+65 UNIMPL reserved for unix/pc
+66 UNIMPL reserved for unix/pc
+67 UNIMPL reserved for unix/pc
+68 UNIMPL reserved for unix/pc
+69 UNIMPL reserved for unix/pc
+70 OBSOL rfs_advfs
+71 OBSOL rfs_unadvfs
+72 OBSOL rfs_rmount
+73 OBSOL rfs_rumount
+74 OBSOL rfs_rfstart
+75 OBSOL rfs_sigret
+76 OBSOL rfs_rdebug
+77 OBSOL rfs_rfstop
+78 UNIMPL rfs_rfsys
+79 STD { int ibcs2_sys_rmdir(char *path); }
+80 STD { int ibcs2_sys_mkdir(char *path, int mode); }
+81 STD { int ibcs2_sys_getdents(int fd, char *buf, \
+ int nbytes); }
+82 UNIMPL
+83 UNIMPL
+84 STD { int ibcs2_sys_sysfs(int cmd, caddr_t d1, char *buf); }
+85 STD { int ibcs2_sys_getmsg(int fd, \
+ struct ibcs2_stropts *ctl, \
+ struct ibcs2_stropts *dat, int *flags); }
+86 STD { int ibcs2_sys_putmsg(int fd, \
+ struct ibcs2_stropts *ctl, \
+ struct ibcs2_stropts *dat, int flags); }
+87 STD { int ibcs2_sys_poll(struct ibcs2_pollfd *fds, \
+ long nfds, int timeout); }
+88 UNIMPL
+89 UNIMPL
+90 STD { int ibcs2_sys_symlink(char *path, char *link); }
+91 STD { int ibcs2_sys_lstat(char *path, \
+ struct ibcs2_stat *st); }
+92 STD { int ibcs2_sys_readlink(char *path, char *buf, \
+ int count); }
+93 UNIMPL
+94 UNIMPL
+95 UNIMPL
+96 UNIMPL
+97 UNIMPL
+98 UNIMPL
+99 UNIMPL
+100 UNIMPL
+101 UNIMPL
+102 UNIMPL
+103 NOARGS { int sys_sigreturn(struct sigcontext *sigcntxp); }
+104 UNIMPL
+105 UNIMPL
+106 UNIMPL
+107 UNIMPL
+108 UNIMPL
+109 UNIMPL
+110 UNIMPL
+111 UNIMPL
+112 UNIMPL
+113 UNIMPL
+114 UNIMPL
+115 UNIMPL
+116 UNIMPL
+117 UNIMPL
+118 UNIMPL
+119 UNIMPL
+120 UNIMPL
+121 UNIMPL
+122 UNIMPL
+123 UNIMPL
+124 UNIMPL
+125 UNIMPL
+126 UNIMPL
+127 UNIMPL
+128 UNIMPL
+129 UNIMPL xenix_xlocking
+130 UNIMPL xenix_creatsem
+131 UNIMPL xenix_opensem
+132 UNIMPL xenix_sigsem
+133 UNIMPL xenix_waitsem
+134 UNIMPL xenix_nbwaitsem
+135 STD { int xenix_sys_rdchk(int fd); }
+136 UNIMPL
+137 UNIMPL
+138 STD { int xenix_sys_chsize(int fd, long size); }
+139 STD { int xenix_sys_ftime(struct xenix_timeb *tp); }
+140 STD { int xenix_sys_nap(int millisec); }
+141 UNIMPL xenix_sdget
+142 UNIMPL xenix_sdfree
+143 UNIMPL xenix_sdenter
+144 UNIMPL xenix_sdleave
+145 UNIMPL xenix_sdgetv
+146 UNIMPL xenix_sdwaitv
+147 UNIMPL
+148 UNIMPL
+149 UNIMPL
+150 UNIMPL
+151 UNIMPL
+152 UNIMPL
+153 UNIMPL
+154 UNIMPL
+155 UNIMPL
+156 UNIMPL
+157 UNIMPL
+158 UNIMPL
+159 UNIMPL
+160 UNIMPL xenix_proctl
+161 UNIMPL xenix_execseg
+162 UNIMPL xenix_unexecseg
+163 UNIMPL
+164 NOARGS { int sys_select(u_int nd, fd_set *in, fd_set *ou, \
+ fd_set *ex, struct timeval *tv); }
+165 UNIMPL xenix_eaccess
+166 UNIMPL xenix_paccess
+167 STD { int ibcs2_sys_sigaction(int signum, \
+ struct ibcs2_sigaction *nsa, \
+ struct ibcs2_sigaction *osa); }
+168 STD { int ibcs2_sys_sigprocmask(int how, \
+ ibcs2_sigset_t *set, ibcs2_sigset_t *oset); }
+169 STD { int ibcs2_sys_sigpending(ibcs2_sigset_t *mask); }
+170 STD { int ibcs2_sys_sigsuspend(ibcs2_sigset_t *mask); }
+171 STD { int ibcs2_sys_getgroups(int gidsetsize, \
+ ibcs2_gid_t *gidset); }
+172 STD { int ibcs2_sys_setgroups(int gidsetsize, \
+ ibcs2_gid_t *gidset); }
+173 STD { int ibcs2_sys_sysconf(int name); }
+174 STD { int ibcs2_sys_pathconf(char *path, int name); }
+175 STD { int ibcs2_sys_fpathconf(int fd, int name); }
+176 STD { int ibcs2_sys_rename(char *from, char *to); }
diff --git a/sys/compat/linux/Makefile b/sys/compat/linux/Makefile
new file mode 100644
index 00000000000..0627f6119a4
--- /dev/null
+++ b/sys/compat/linux/Makefile
@@ -0,0 +1,11 @@
+# $NetBSD: Makefile,v 1.1 1995/02/28 23:26:21 fvdl Exp $
+
+DEP= syscalls.conf syscalls.master ../../kern/makesyscalls.sh
+OBJS= linux_sysent.c linux_syscalls.c linux_syscall.h linux_syscallargs.h
+
+${OBJS}: ${DEP}
+ -mv -f linux_sysent.c linux_sysent.c.bak
+ -mv -f linux_syscalls.c linux_syscalls.c.bak
+ -mv -f linux_syscall.h linux_syscall.h.bak
+ -mv -f linux_syscallargs.h linux_syscallargs.h.bak
+ sh ../../kern/makesyscalls.sh syscalls.conf syscalls.master
diff --git a/sys/compat/linux/files.linux b/sys/compat/linux/files.linux
new file mode 100644
index 00000000000..c8aca4ae530
--- /dev/null
+++ b/sys/compat/linux/files.linux
@@ -0,0 +1,18 @@
+# $NetBSD: files.linux,v 1.3 1995/08/14 01:34:11 mycroft Exp $
+#
+# Config.new file description for machine-independent Linux compat code.
+# Included by ports that need it.
+
+# ports should define any machine-specific files they need in their
+# own file lists.
+
+file compat/linux/linux_error.c compat_linux
+file compat/linux/linux_exec.c compat_linux
+file compat/linux/linux_file.c compat_linux
+file compat/linux/linux_ioctl.c compat_linux
+file compat/linux/linux_ipc.c compat_linux
+file compat/linux/linux_misc.c compat_linux
+file compat/linux/linux_signal.c compat_linux
+file compat/linux/linux_socket.c compat_linux
+file compat/linux/linux_syscalls.c compat_linux
+file compat/linux/linux_sysent.c compat_linux
diff --git a/sys/compat/linux/linux_dirent.h b/sys/compat/linux/linux_dirent.h
new file mode 100644
index 00000000000..de63da00ca3
--- /dev/null
+++ b/sys/compat/linux/linux_dirent.h
@@ -0,0 +1,49 @@
+/* $NetBSD: linux_dirent.h,v 1.3 1995/10/07 06:26:59 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_DIRENT_H
+#define _LINUX_DIRENT_H
+
+#define LINUX_MAXNAMLEN 255
+
+struct linux_dirent {
+ linux_ino_t d_ino;
+ linux_off_t d_off;
+ u_short d_reclen;
+ char d_name[LINUX_MAXNAMLEN + 1];
+};
+
+#define LINUX_NAMEOFF(dp) ((char *)&(dp)->d_name - (char *)dp)
+#define LINUX_RECLEN(de,namlen) ALIGN((LINUX_NAMEOFF(de) + (namlen) + 1))
+
+#endif /* !_LINUX_DIRENT_H */
diff --git a/sys/compat/linux/linux_errno.h b/sys/compat/linux/linux_errno.h
new file mode 100644
index 00000000000..94530fd2eed
--- /dev/null
+++ b/sys/compat/linux/linux_errno.h
@@ -0,0 +1,158 @@
+/* $NetBSD: linux_errno.h,v 1.1 1995/02/28 23:25:34 fvdl Exp $ */
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_ERRNO_H
+#define _LINUX_ERRNO_H
+
+#define LINUX_EPERM 1
+#define LINUX_ENOENT 2
+#define LINUX_ESRCH 3
+#define LINUX_EINTR 4
+#define LINUX_EIO 5
+#define LINUX_ENXIO 6
+#define LINUX_E2BIG 7
+#define LINUX_ENOEXEC 8
+#define LINUX_EBADF 9
+#define LINUX_ECHILD 10
+#define LINUX_EAGAIN 11
+#define LINUX_ENOMEM 12
+#define LINUX_EACCES 13
+#define LINUX_EFAULT 14
+#define LINUX_ENOTBLK 15
+#define LINUX_EBUSY 16
+#define LINUX_EEXIST 17
+#define LINUX_EXDEV 18
+#define LINUX_ENODEV 19
+#define LINUX_ENOTDIR 20
+#define LINUX_EISDIR 21
+#define LINUX_EINVAL 22
+#define LINUX_ENFILE 23
+#define LINUX_EMFILE 24
+#define LINUX_ENOTTY 25
+#define LINUX_ETXTBSY 26
+#define LINUX_EFBIG 27
+#define LINUX_ENOSPC 28
+#define LINUX_ESPIPE 29
+#define LINUX_EROFS 30
+#define LINUX_EMLINK 31
+#define LINUX_EPIPE 32
+#define LINUX_EDOM 33
+#define LINUX_ERANGE 34
+#define LINUX_EDEADLK 35
+#define LINUX_ENAMETOOLONG 36
+#define LINUX_ENOLCK 37
+#define LINUX_ENOSYS 38
+#define LINUX_ENOTEMPTY 39
+#define LINUX_ELOOP 40
+#define LINUX_ENOMSG 42
+#define LINUX_EIDRM 43
+#define LINUX_ECHRNG 44
+#define LINUX_EL2NSYNC 45
+#define LINUX_EL3HLT 46
+#define LINUX_EL3RST 47
+#define LINUX_ELNRNG 48
+#define LINUX_EUNATCH 49
+#define LINUX_ENOCSI 50
+#define LINUX_EL2HLT 51
+#define LINUX_EBADE 52
+#define LINUX_EBADR 53
+#define LINUX_EXFULL 54
+#define LINUX_ENOANO 55
+#define LINUX_EBADRQC 56
+#define LINUX_EBADSLT 57
+#define LINUX_EDEADLOCK 58
+#define LINUX_EBFONT 59
+#define LINUX_ENOSTR 60
+#define LINUX_ENODATA 61
+#define LINUX_ETIME 62
+#define LINUX_ENOSR 63
+#define LINUX_ENONET 64
+#define LINUX_ENOPKG 65
+#define LINUX_EREMOTE 66
+#define LINUX_ENOLINK 67
+#define LINUX_EADV 68
+#define LINUX_ESRMNT 69
+#define LINUX_ECOMM 70
+#define LINUX_EPROTO 71
+#define LINUX_EMULTIHOP 72
+#define LINUX_EDOTDOT 73
+#define LINUX_EBADMSG 74
+#define LINUX_EOVERFLOW 75
+#define LINUX_ENOTUNIQ 76
+#define LINUX_EBADFD 77
+#define LINUX_EREMCHG 78
+#define LINUX_ELIBACC 79
+#define LINUX_ELIBBAD 80
+#define LINUX_ELIBSCN 81
+#define LINUX_ELIBMAX 82
+#define LINUX_ELIBEXEC 83
+#define LINUX_EILSEQ 84
+#define LINUX_ERESTART 85
+#define LINUX_ESTRPIPE 86
+#define LINUX_EUSERS 87
+#define LINUX_ENOTSOCK 88
+#define LINUX_EDESTADDRREQ 89
+#define LINUX_EMSGSIZE 90
+#define LINUX_EPROTOTYPE 91
+#define LINUX_ENOPROTOOPT 92
+#define LINUX_EPROTONOSUPPORT 93
+#define LINUX_ESOCKTNOSUPPORT 94
+#define LINUX_EOPNOTSUPP 95
+#define LINUX_EPFNOSUPPORT 96
+#define LINUX_EAFNOSUPPORT 97
+#define LINUX_EADDRINUSE 98
+#define LINUX_EADDRNOTAVAIL 99
+#define LINUX_ENETDOWN 100
+#define LINUX_ENETUNREACH 101
+#define LINUX_ENETRESET 102
+#define LINUX_ECONNABORTED 103
+#define LINUX_ECONNRESET 104
+#define LINUX_ENOBUFS 105
+#define LINUX_EISCONN 106
+#define LINUX_ENOTCONN 107
+#define LINUX_ESHUTDOWN 108
+#define LINUX_ETOOMANYREFS 109
+#define LINUX_ETIMEDOUT 110
+#define LINUX_ECONNREFUSED 111
+#define LINUX_EHOSTDOWN 112
+#define LINUX_EHOSTUNREACH 113
+#define LINUX_EALREADY 114
+#define LINUX_EINPROGRESS 115
+#define LINUX_ESTALE 116
+#define LINUX_EUCLEAN 117
+#define LINUX_ENOTNAM 118
+#define LINUX_ENAVAIL 119
+#define LINUX_EISNAM 120
+#define LINUX_EREMOTEIO 121
+#define LINUX_EDQUOT 122
+
+#endif /* !_LINUX_ERRNO_H */
diff --git a/sys/compat/linux/linux_error.c b/sys/compat/linux/linux_error.c
new file mode 100644
index 00000000000..1c42debe480
--- /dev/null
+++ b/sys/compat/linux/linux_error.c
@@ -0,0 +1,177 @@
+/* $NetBSD: linux_error.c,v 1.2 1995/04/22 19:48:32 christos Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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 <compat/linux/linux_errno.h>
+
+int linux_error[] = {
+ 0,
+ -LINUX_EPERM,
+ -LINUX_ENOENT,
+ -LINUX_ESRCH,
+ -LINUX_EINTR,
+ -LINUX_EIO,
+ -LINUX_ENXIO,
+ -LINUX_E2BIG,
+ -LINUX_ENOEXEC,
+ -LINUX_EBADF,
+ -LINUX_ECHILD,
+ -LINUX_EDEADLK,
+ -LINUX_ENOMEM,
+ -LINUX_EACCES,
+ -LINUX_EFAULT,
+ -LINUX_ENOTBLK,
+ -LINUX_EBUSY,
+ -LINUX_EEXIST,
+ -LINUX_EXDEV,
+ -LINUX_ENODEV,
+ -LINUX_ENOTDIR,
+ -LINUX_EISDIR,
+ -LINUX_EINVAL,
+ -LINUX_ENFILE,
+ -LINUX_EMFILE,
+ -LINUX_ENOTTY,
+ -LINUX_ETXTBSY,
+ -LINUX_EFBIG,
+ -LINUX_ENOSPC,
+ -LINUX_ESPIPE,
+ -LINUX_EROFS,
+ -LINUX_EMLINK,
+ -LINUX_EPIPE,
+ -LINUX_EDOM,
+ -LINUX_ERANGE,
+ -LINUX_EAGAIN,
+ -LINUX_EINPROGRESS,
+ -LINUX_EALREADY,
+ -LINUX_ENOTSOCK,
+ -LINUX_EDESTADDRREQ,
+ -LINUX_EMSGSIZE,
+ -LINUX_EPROTOTYPE,
+ -LINUX_ENOPROTOOPT,
+ -LINUX_EPROTONOSUPPORT,
+ -LINUX_ESOCKTNOSUPPORT,
+ -LINUX_EOPNOTSUPP,
+ -LINUX_EPFNOSUPPORT,
+ -LINUX_EAFNOSUPPORT,
+ -LINUX_EADDRINUSE,
+ -LINUX_EADDRNOTAVAIL,
+ -LINUX_ENETDOWN,
+ -LINUX_ENETUNREACH,
+ -LINUX_ENETRESET,
+ -LINUX_ECONNABORTED,
+ -LINUX_ECONNRESET,
+ -LINUX_ENOBUFS,
+ -LINUX_EISCONN,
+ -LINUX_ENOTCONN,
+ -LINUX_ESHUTDOWN,
+ -LINUX_ETOOMANYREFS,
+ -LINUX_ETIMEDOUT,
+ -LINUX_ECONNREFUSED,
+ -LINUX_ELOOP,
+ -LINUX_ENAMETOOLONG,
+ -LINUX_EHOSTDOWN,
+ -LINUX_EHOSTUNREACH,
+ -LINUX_ENOTEMPTY,
+ -LINUX_ENOSYS, /* not mapped (EPROCLIM) */
+ -LINUX_EUSERS,
+ -LINUX_EDQUOT,
+ -LINUX_ESTALE,
+ -LINUX_EREMOTE,
+ -LINUX_ENOSYS, /* not mapped (EBADRPC) */
+ -LINUX_ENOSYS, /* not mapped (ERPCMISMATCH) */
+ -LINUX_ENOSYS, /* not mapped (EPROGUNAVAIL) */
+ -LINUX_ENOSYS, /* not mapped (EPROGMISMATCH) */
+ -LINUX_ENOSYS, /* not mapped (EPROCUNAVAIL) */
+ -LINUX_ENOLCK,
+ -LINUX_ENOSYS,
+ -LINUX_ENOSYS, /* not mapped (EFTYPE) */
+ -LINUX_ENOSYS, /* not mapped (EAUTH) */
+ -LINUX_ENOSYS, /* not mapped (ENEEDAUTH) */
+ -LINUX_ENOSYS, /* not mapped (ELAST) */
+
+ /*
+ * The rest of the list consists of errors that only
+ * Linux has. They can be used to map them on to
+ * themselves, so Linux emulating syscalls can return
+ * these values.
+ */
+
+ -LINUX_ENOMSG,
+ -LINUX_EIDRM,
+ -LINUX_ECHRNG,
+ -LINUX_EL2NSYNC,
+ -LINUX_EL3HLT,
+ -LINUX_EL3RST,
+ -LINUX_ELNRNG,
+ -LINUX_EUNATCH,
+ -LINUX_ENOCSI,
+ -LINUX_EL2HLT,
+ -LINUX_EBADE,
+ -LINUX_EBADR,
+ -LINUX_EXFULL,
+ -LINUX_ENOANO,
+ -LINUX_EBADRQC,
+ -LINUX_EBADSLT,
+ -LINUX_EDEADLOCK,
+ -LINUX_EBFONT,
+ -LINUX_ENOSTR,
+ -LINUX_ENODATA,
+ -LINUX_ETIME,
+ -LINUX_ENOSR,
+ -LINUX_ENONET,
+ -LINUX_ENOPKG,
+ -LINUX_ENOLINK,
+ -LINUX_EADV,
+ -LINUX_ESRMNT,
+ -LINUX_ECOMM,
+ -LINUX_EPROTO,
+ -LINUX_EMULTIHOP,
+ -LINUX_EDOTDOT,
+ -LINUX_EBADMSG,
+ -LINUX_EOVERFLOW,
+ -LINUX_ENOTUNIQ,
+ -LINUX_EBADFD,
+ -LINUX_EREMCHG,
+ -LINUX_ELIBACC,
+ -LINUX_ELIBBAD,
+ -LINUX_ELIBSCN,
+ -LINUX_ELIBMAX,
+ -LINUX_ELIBEXEC,
+ -LINUX_EILSEQ,
+ -LINUX_ERESTART,
+ -LINUX_ESTRPIPE,
+ -LINUX_EUCLEAN,
+ -LINUX_ENOTNAM,
+ -LINUX_ENAVAIL,
+ -LINUX_EISNAM,
+ -LINUX_EREMOTEIO
+};
diff --git a/sys/compat/linux/linux_exec.c b/sys/compat/linux/linux_exec.c
new file mode 100644
index 00000000000..cc266db42bd
--- /dev/null
+++ b/sys/compat/linux/linux_exec.c
@@ -0,0 +1,502 @@
+/* $NetBSD: linux_exec.c,v 1.12 1995/10/07 06:27:00 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1995 Frank van der Linden
+ * 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.
+ *
+ * based on exec_aout.c, sunos_exec.c and svr4_exec.c
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/malloc.h>
+#include <sys/namei.h>
+#include <sys/vnode.h>
+#include <sys/exec_elf.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>
+#include <machine/exec.h>
+#include <machine/linux_machdep.h>
+
+#include <compat/linux/linux_types.h>
+#include <compat/linux/linux_syscall.h>
+#include <compat/linux/linux_signal.h>
+#include <compat/linux/linux_syscallargs.h>
+#include <compat/linux/linux_util.h>
+#include <compat/linux/linux_exec.h>
+
+static void *linux_aout_copyargs __P((struct exec_package *,
+ struct ps_strings *, void *, void *));
+
+#define LINUX_AOUT_AUX_ARGSIZ 2
+#define LINUX_ELF_AUX_ARGSIZ (sizeof(AuxInfo) * 8 / sizeof(char *))
+
+
+const char linux_emul_path[] = "/emul/linux";
+extern int linux_error[];
+extern char linux_sigcode[], linux_esigcode[];
+extern struct sysent linux_sysent[];
+extern char *linux_syscallnames[];
+
+struct emul emul_linux_aout = {
+ "linux",
+ linux_error,
+ linux_sendsig,
+ LINUX_SYS_syscall,
+ LINUX_SYS_MAXSYSCALL,
+ linux_sysent,
+ linux_syscallnames,
+ LINUX_AOUT_AUX_ARGSIZ,
+ linux_aout_copyargs,
+ setregs,
+ linux_sigcode,
+ linux_esigcode,
+};
+
+struct emul emul_linux_elf = {
+ "linux",
+ linux_error,
+ linux_sendsig,
+ LINUX_SYS_syscall,
+ LINUX_SYS_MAXSYSCALL,
+ linux_sysent,
+ linux_syscallnames,
+ LINUX_ELF_AUX_ARGSIZ,
+ elf_copyargs,
+ setregs,
+ linux_sigcode,
+ linux_esigcode,
+};
+
+
+static void *
+linux_aout_copyargs(pack, arginfo, stack, argp)
+ struct exec_package *pack;
+ struct ps_strings *arginfo;
+ void *stack;
+ void *argp;
+{
+ char **cpp = stack;
+ char **stk = stack;
+ char *dp, *sp;
+ size_t len;
+ void *nullp = NULL;
+ int argc = arginfo->ps_nargvstr;
+ int envc = arginfo->ps_nenvstr;
+
+ if (copyout(&argc, cpp++, sizeof(argc)))
+ return NULL;
+
+ /* leave room for envp and argv */
+ cpp += 2;
+ if (copyout(&cpp, &stk[1], sizeof (cpp)))
+ return NULL;
+
+ dp = (char *) (cpp + argc + envc + 2);
+ sp = argp;
+
+ /* XXX don't copy them out, remap them! */
+ arginfo->ps_argvstr = cpp; /* remember location of argv for later */
+
+ for (; --argc >= 0; sp += len, dp += len)
+ if (copyout(&dp, cpp++, sizeof(dp)) ||
+ copyoutstr(sp, dp, ARG_MAX, &len))
+ return NULL;
+
+ if (copyout(&nullp, cpp++, sizeof(nullp)))
+ return NULL;
+
+ if (copyout(&cpp, &stk[2], sizeof (cpp)))
+ return NULL;
+
+ arginfo->ps_envstr = cpp; /* remember location of envp for later */
+
+ for (; --envc >= 0; sp += len, dp += len)
+ if (copyout(&dp, cpp++, sizeof(dp)) ||
+ copyoutstr(sp, dp, ARG_MAX, &len))
+ return NULL;
+
+ if (copyout(&nullp, cpp++, sizeof(nullp)))
+ return NULL;
+
+ return cpp;
+}
+
+int
+exec_linux_aout_makecmds(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ struct exec *linux_ep = epp->ep_hdr;
+ int machtype, magic;
+ int error = ENOEXEC;
+
+ magic = LINUX_N_MAGIC(linux_ep);
+ machtype = LINUX_N_MACHTYPE(linux_ep);
+
+
+ if (machtype != LINUX_MID_MACHINE)
+ return (ENOEXEC);
+
+ switch (magic) {
+ case QMAGIC:
+ error = exec_linux_aout_prep_qmagic(p, epp);
+ break;
+ case ZMAGIC:
+ error = exec_linux_aout_prep_zmagic(p, epp);
+ break;
+ case NMAGIC:
+ error = exec_linux_aout_prep_nmagic(p, epp);
+ break;
+ case OMAGIC:
+ error = exec_linux_aout_prep_omagic(p, epp);
+ break;
+ }
+ if (error == 0)
+ epp->ep_emul = &emul_linux_aout;
+ return error;
+}
+
+/*
+ * Since text starts at 0x400 in Linux ZMAGIC executables, and 0x400
+ * is very likely not page aligned on most architectures, it is treated
+ * as an NMAGIC here. XXX
+ */
+
+int
+exec_linux_aout_prep_zmagic(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ struct exec *execp = epp->ep_hdr;
+
+ epp->ep_taddr = LINUX_N_TXTADDR(*execp, ZMAGIC);
+ epp->ep_tsize = execp->a_text;
+ epp->ep_daddr = LINUX_N_DATADDR(*execp, ZMAGIC);
+ epp->ep_dsize = execp->a_data + execp->a_bss;
+ epp->ep_entry = execp->a_entry;
+
+ /* set up command for text segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->a_text,
+ epp->ep_taddr, epp->ep_vp, LINUX_N_TXTOFF(*execp, ZMAGIC),
+ VM_PROT_READ|VM_PROT_EXECUTE);
+
+ /* set up command for data segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->a_data,
+ epp->ep_daddr, epp->ep_vp, LINUX_N_DATOFF(*execp, ZMAGIC),
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ /* set up command for bss segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss,
+ epp->ep_daddr + execp->a_data, NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ return exec_aout_setup_stack(p, epp);
+}
+
+/*
+ * exec_aout_prep_nmagic(): Prepare Linux NMAGIC package.
+ * Not different from the normal stuff.
+ */
+
+int
+exec_linux_aout_prep_nmagic(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ struct exec *execp = epp->ep_hdr;
+ long bsize, baddr;
+
+ epp->ep_taddr = LINUX_N_TXTADDR(*execp, NMAGIC);
+ epp->ep_tsize = execp->a_text;
+ epp->ep_daddr = LINUX_N_DATADDR(*execp, NMAGIC);
+ epp->ep_dsize = execp->a_data + execp->a_bss;
+ epp->ep_entry = execp->a_entry;
+
+ /* set up command for text segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->a_text,
+ epp->ep_taddr, epp->ep_vp, LINUX_N_TXTOFF(*execp, NMAGIC),
+ VM_PROT_READ|VM_PROT_EXECUTE);
+
+ /* set up command for data segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->a_data,
+ epp->ep_daddr, epp->ep_vp, LINUX_N_DATOFF(*execp, NMAGIC),
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ /* set up command for bss segment */
+ baddr = roundup(epp->ep_daddr + execp->a_data, NBPG);
+ bsize = epp->ep_daddr + epp->ep_dsize - baddr;
+ if (bsize > 0)
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr,
+ NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ return exec_aout_setup_stack(p, epp);
+}
+
+/*
+ * exec_aout_prep_omagic(): Prepare Linux OMAGIC package.
+ * Business as usual.
+ */
+
+int
+exec_linux_aout_prep_omagic(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ struct exec *execp = epp->ep_hdr;
+ long dsize, bsize, baddr;
+
+ epp->ep_taddr = LINUX_N_TXTADDR(*execp, OMAGIC);
+ epp->ep_tsize = execp->a_text;
+ epp->ep_daddr = LINUX_N_DATADDR(*execp, OMAGIC);
+ epp->ep_dsize = execp->a_data + execp->a_bss;
+ epp->ep_entry = execp->a_entry;
+
+ /* set up command for text and data segments */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
+ execp->a_text + execp->a_data, epp->ep_taddr, epp->ep_vp,
+ LINUX_N_TXTOFF(*execp, OMAGIC), VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ /* set up command for bss segment */
+ baddr = roundup(epp->ep_daddr + execp->a_data, NBPG);
+ bsize = epp->ep_daddr + epp->ep_dsize - baddr;
+ if (bsize > 0)
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr,
+ NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ /*
+ * Make sure (# of pages) mapped above equals (vm_tsize + vm_dsize);
+ * obreak(2) relies on this fact. Both `vm_tsize' and `vm_dsize' are
+ * computed (in execve(2)) by rounding *up* `ep_tsize' and `ep_dsize'
+ * respectively to page boundaries.
+ * Compensate `ep_dsize' for the amount of data covered by the last
+ * text page.
+ */
+ dsize = epp->ep_dsize + execp->a_text - roundup(execp->a_text, NBPG);
+ epp->ep_dsize = (dsize > 0) ? dsize : 0;
+ return exec_aout_setup_stack(p, epp);
+}
+
+int
+exec_linux_aout_prep_qmagic(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ struct exec *execp = epp->ep_hdr;
+
+ epp->ep_taddr = LINUX_N_TXTADDR(*execp, QMAGIC);
+ epp->ep_tsize = execp->a_text;
+ epp->ep_daddr = LINUX_N_DATADDR(*execp, QMAGIC);
+ epp->ep_dsize = execp->a_data + execp->a_bss;
+ epp->ep_entry = execp->a_entry;
+
+ /*
+ * check if vnode is in open for writing, because we want to
+ * demand-page out of it. if it is, don't do it, for various
+ * reasons
+ */
+ if ((execp->a_text != 0 || execp->a_data != 0) &&
+ epp->ep_vp->v_writecount != 0) {
+#ifdef DIAGNOSTIC
+ if (epp->ep_vp->v_flag & VTEXT)
+ panic("exec: a VTEXT vnode has writecount != 0\n");
+#endif
+ return ETXTBSY;
+ }
+ epp->ep_vp->v_flag |= VTEXT;
+
+ /* set up command for text segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_text,
+ epp->ep_taddr, epp->ep_vp, LINUX_N_TXTOFF(*execp, QMAGIC),
+ VM_PROT_READ|VM_PROT_EXECUTE);
+
+ /* set up command for data segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_data,
+ epp->ep_daddr, epp->ep_vp, LINUX_N_DATOFF(*execp, QMAGIC),
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ /* set up command for bss segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss,
+ epp->ep_daddr + execp->a_data, NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ return exec_aout_setup_stack(p, epp);
+}
+
+int
+linux_elf_probe(p, epp, itp, pos)
+ struct proc *p;
+ struct exec_package *epp;
+ char *itp;
+ u_long *pos;
+{
+ char *bp;
+ int error;
+ size_t len;
+
+ if (itp[0]) {
+ if ((error = emul_find(p, NULL, linux_emul_path, itp, &bp, 0)))
+ return error;
+ if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
+ return error;
+ free(bp, M_TEMP);
+ }
+ epp->ep_emul = &emul_linux_elf;
+ *pos = ELF32_NO_ADDR;
+ return 0;
+}
+
+/*
+ * The Linux system call to load shared libraries, a.out version. The
+ * a.out shared libs are just files that are mapped onto a fixed
+ * address in the process' address space. The address is given in
+ * a_entry. Read in the header, set up some VM commands and run them.
+ *
+ * Yes, both text and data are mapped at once, so we're left with
+ * writeable text for the shared libs. The Linux crt0 seemed to break
+ * sometimes when data was mapped seperately. It munmapped a uselib()
+ * of ld.so by hand, which failed with shared text and data for ld.so
+ * Yuck.
+ *
+ * Because of the problem with ZMAGIC executables (text starts
+ * at 0x400 in the file, but needs to be mapped at 0), ZMAGIC
+ * shared libs are not handled very efficiently :-(
+ */
+
+int
+linux_sys_uselib(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_uselib_args /* {
+ syscallarg(char *) path;
+ } */ *uap = v;
+ caddr_t sg;
+ long bsize, dsize, tsize, taddr, baddr, daddr;
+ struct nameidata ni;
+ struct vnode *vp;
+ struct exec hdr;
+ struct exec_vmcmd_set vcset;
+ int rem, i, magic, error;
+
+ sg = stackgap_init(p->p_emul);
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ NDINIT(&ni, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
+
+ if ((error = namei(&ni)))
+ return error;
+
+ vp = ni.ni_vp;
+
+ if ((error = vn_rdwr(UIO_READ, vp, (caddr_t) &hdr, LINUX_AOUT_HDR_SIZE,
+ 0, UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred,
+ &rem, p))) {
+ vrele(vp);
+ return error;
+ }
+
+ if (rem != 0) {
+ vrele(vp);
+ return ENOEXEC;
+ }
+
+ if (LINUX_N_MACHTYPE(&hdr) != LINUX_MID_MACHINE)
+ return ENOEXEC;
+
+ magic = LINUX_N_MAGIC(&hdr);
+ taddr = hdr.a_entry & (~(NBPG - 1));
+ tsize = hdr.a_text;
+ daddr = taddr + tsize;
+ dsize = hdr.a_data + hdr.a_bss;
+
+ if ((hdr.a_text != 0 || hdr.a_data != 0) && vp->v_writecount != 0) {
+ vrele(vp);
+ return ETXTBSY;
+ }
+ vp->v_flag |= VTEXT;
+
+ vcset.evs_cnt = 0;
+ vcset.evs_used = 0;
+
+ NEW_VMCMD(&vcset,
+ magic == ZMAGIC ? vmcmd_map_readvn : vmcmd_map_pagedvn,
+ hdr.a_text + hdr.a_data, taddr,
+ vp, LINUX_N_TXTOFF(hdr, magic),
+ VM_PROT_READ|VM_PROT_EXECUTE|VM_PROT_WRITE);
+
+ baddr = roundup(daddr + hdr.a_data, NBPG);
+ bsize = daddr + dsize - baddr;
+ if (bsize > 0) {
+ NEW_VMCMD(&vcset, vmcmd_map_zero, bsize, baddr,
+ NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+ }
+
+ for (i = 0; i < vcset.evs_used && !error; i++) {
+ struct exec_vmcmd *vcp;
+
+ vcp = &vcset.evs_cmds[i];
+ error = (*vcp->ev_proc)(p, vcp);
+ }
+
+ kill_vmcmds(&vcset);
+
+ vrele(vp);
+
+ return error;
+}
+
+/*
+ * Execve(2). Just check the alternate emulation path, and pass it on
+ * to the NetBSD execve().
+ */
+int
+linux_sys_execve(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_execve_args /* {
+ syscallarg(char *) path;
+ syscallarg(char **) argv;
+ syscallarg(char **) envp;
+ } */ *uap = v;
+ caddr_t sg;
+
+ sg = stackgap_init(p->p_emul);
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ return sys_execve(p, uap, retval);
+}
diff --git a/sys/compat/linux/linux_exec.h b/sys/compat/linux/linux_exec.h
new file mode 100644
index 00000000000..fe26bac4f31
--- /dev/null
+++ b/sys/compat/linux/linux_exec.h
@@ -0,0 +1,74 @@
+/* $NetBSD: linux_exec.h,v 1.5 1995/10/07 06:27:01 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ *
+ */
+
+#ifndef _LINUX_EXEC_H
+#define _LINUX_EXEC_H
+
+#define LINUX_M_I386 100
+/* Sparc? Alpha? */
+
+/* XXX linux_machdep.h ? */
+#ifdef i386
+#define LINUX_MID_MACHINE LINUX_M_I386
+#endif
+
+#define LINUX_AOUT_HDR_SIZE (sizeof (struct exec))
+
+#define LINUX_N_MAGIC(ep) ((ep)->a_midmag & 0xffff)
+#define LINUX_N_MACHTYPE(ep) (((ep)->a_midmag >> 16) & 0xff)
+
+#define LINUX_N_TXTOFF(x,m) \
+ ((m) == ZMAGIC ? 1024 : ((m) == QMAGIC ? 0 : sizeof (struct exec)))
+
+#define LINUX_N_DATOFF(x,m) (LINUX_N_TXTOFF(x,m) + (x).a_text)
+
+#define LINUX_N_TXTADDR(x,m) ((m) == QMAGIC ? PAGE_SIZE : 0)
+
+#define LINUX__N_SEGMENT_ROUND(x) (((x) + NBPG - 1) & ~(NBPG - 1))
+
+#define LINUX__N_TXTENDADDR(x,m) (LINUX_N_TXTADDR(x,m)+(x).a_text)
+
+#define LINUX_N_DATADDR(x,m) \
+ ((m)==OMAGIC? (LINUX__N_TXTENDADDR(x,m)) \
+ : (LINUX__N_SEGMENT_ROUND (LINUX__N_TXTENDADDR(x,m))))
+
+#define LINUX_N_BSSADDR(x,m) (LINUX_N_DATADDR(x,m) + (x).a_data)
+
+int exec_linux_aout_makecmds __P((struct proc *, struct exec_package *));
+int exec_linux_elf_makecmds __P((struct proc *, struct exec_package *));
+
+int linux_elf_probe __P((struct proc *p, struct exec_package *epp, char *itp,
+ u_long *pos));
+
+#endif /* !_LINUX_EXEC_H */
diff --git a/sys/compat/linux/linux_fcntl.h b/sys/compat/linux/linux_fcntl.h
new file mode 100644
index 00000000000..4c34e7d3f45
--- /dev/null
+++ b/sys/compat/linux/linux_fcntl.h
@@ -0,0 +1,90 @@
+/* $NetBSD: linux_fcntl.h,v 1.1 1995/02/28 23:25:40 fvdl Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+/*
+ * Various flag values used in Linux for open(2) and fcntl(2).
+ */
+
+#ifndef _LINUX_FCNTL_H
+#define _LINUX_FCNTL_H
+
+/* read/write mode for open(2) (as usual) */
+#define LINUX_O_RDONLY 0x0000
+#define LINUX_O_WRONLY 0x0001
+#define LINUX_O_RDWR 0x0002
+#define LINUX_O_ACCMODE 0x0003
+
+/* flags used in open(2) */
+#define LINUX_O_CREAT 0x0040
+#define LINUX_O_EXCL 0x0080
+#define LINUX_O_NOCTTY 0x0100
+#define LINUX_O_TRUNC 0x0200
+#define LINUX_O_APPEND 0x0400
+#define LINUX_O_NDELAY 0x0800
+#define LINUX_O_SYNC 0x1000
+
+#define LINUX_FASYNC 0x2000
+
+/* fcntl(2) operations */
+#define LINUX_F_DUPFD 0
+#define LINUX_F_GETFD 1
+#define LINUX_F_SETFD 2
+#define LINUX_F_GETFL 3
+#define LINUX_F_SETFL 4
+#define LINUX_F_GETLK 5
+#define LINUX_F_SETLK 6
+#define LINUX_F_SETLKW 7
+#define LINUX_F_SETOWN 8
+#define LINUX_F_GETOWN 9
+
+#define LINUX_F_RDLCK 0
+#define LINUX_F_WRLCK 1
+#define LINUX_F_UNLCK 2
+
+#define LINUX_LOCK_EX 4
+#define LINUX_LOCK_SH 8
+
+/*
+ * The arguments in the flock structure have a different order from the
+ * BSD structure.
+ */
+
+struct linux_flock {
+ short l_type;
+ short l_whence;
+ linux_off_t l_start;
+ linux_off_t l_len;
+ linux_pid_t l_pid;
+};
+
+#endif /* _LINUX_FCNTL_H */
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
new file mode 100644
index 00000000000..c05a89916f2
--- /dev/null
+++ b/sys/compat/linux/linux_file.c
@@ -0,0 +1,795 @@
+/* $NetBSD: linux_file.c,v 1.13 1995/10/08 22:53:43 fvdl Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/malloc.h>
+#include <sys/vnode.h>
+#include <sys/tty.h>
+#include <sys/conf.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/linux/linux_types.h>
+#include <compat/linux/linux_signal.h>
+#include <compat/linux/linux_syscallargs.h>
+#include <compat/linux/linux_fcntl.h>
+#include <compat/linux/linux_util.h>
+
+/*
+ * Some file-related calls are handled here. The usual flag conversion
+ * an structure conversion is done, and alternate emul path searching.
+ */
+
+/*
+ * The next two functions convert between the Linux and NetBSD values
+ * of the flags used in open(2) and fcntl(2).
+ */
+static int
+linux_to_bsd_ioflags(int lflags)
+{
+ int res = 0;
+
+ res |= cvtto_bsd_mask(lflags, LINUX_O_WRONLY, O_WRONLY);
+ res |= cvtto_bsd_mask(lflags, LINUX_O_RDONLY, O_RDONLY);
+ res |= cvtto_bsd_mask(lflags, LINUX_O_RDWR, O_RDWR);
+ res |= cvtto_bsd_mask(lflags, LINUX_O_CREAT, O_CREAT);
+ res |= cvtto_bsd_mask(lflags, LINUX_O_EXCL, O_EXCL);
+ res |= cvtto_bsd_mask(lflags, LINUX_O_NOCTTY, O_NOCTTY);
+ res |= cvtto_bsd_mask(lflags, LINUX_O_TRUNC, O_TRUNC);
+ res |= cvtto_bsd_mask(lflags, LINUX_O_NDELAY, O_NDELAY);
+ res |= cvtto_bsd_mask(lflags, LINUX_O_SYNC, O_FSYNC);
+ res |= cvtto_bsd_mask(lflags, LINUX_FASYNC, O_ASYNC);
+ res |= cvtto_bsd_mask(lflags, LINUX_O_APPEND, O_APPEND);
+
+ return res;
+}
+
+static int
+bsd_to_linux_ioflags(int bflags)
+{
+ int res = 0;
+
+ res |= cvtto_linux_mask(bflags, O_WRONLY, LINUX_O_WRONLY);
+ res |= cvtto_linux_mask(bflags, O_RDONLY, LINUX_O_RDONLY);
+ res |= cvtto_linux_mask(bflags, O_RDWR, LINUX_O_RDWR);
+ res |= cvtto_linux_mask(bflags, O_CREAT, LINUX_O_CREAT);
+ res |= cvtto_linux_mask(bflags, O_EXCL, LINUX_O_EXCL);
+ res |= cvtto_linux_mask(bflags, O_NOCTTY, LINUX_O_NOCTTY);
+ res |= cvtto_linux_mask(bflags, O_TRUNC, LINUX_O_TRUNC);
+ res |= cvtto_linux_mask(bflags, O_NDELAY, LINUX_O_NDELAY);
+ res |= cvtto_linux_mask(bflags, O_FSYNC, LINUX_O_SYNC);
+ res |= cvtto_linux_mask(bflags, O_ASYNC, LINUX_FASYNC);
+ res |= cvtto_linux_mask(bflags, O_APPEND, LINUX_O_APPEND);
+
+ return res;
+}
+
+/*
+ * creat(2) is an obsolete function, but it's present as a Linux
+ * system call, so let's deal with it.
+ *
+ * Just call open(2) with the TRUNC, CREAT and WRONLY flags.
+ */
+int
+linux_sys_creat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_creat_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ struct sys_open_args oa;
+ caddr_t sg;
+
+ sg = stackgap_init(p->p_emul);
+ LINUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+
+ SCARG(&oa, path) = SCARG(uap, path);
+ SCARG(&oa, flags) = O_CREAT | O_TRUNC | O_WRONLY;
+ SCARG(&oa, mode) = SCARG(uap, mode);
+
+ return sys_open(p, &oa, retval);
+}
+
+/*
+ * open(2). Take care of the different flag values, and let the
+ * NetBSD syscall do the real work. See if this operation
+ * gives the current process a controlling terminal.
+ * (XXX is this necessary?)
+ */
+int
+linux_sys_open(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_open_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ int error, fl;
+ struct sys_open_args boa;
+ caddr_t sg;
+
+ sg = stackgap_init(p->p_emul);
+
+ fl = linux_to_bsd_ioflags(SCARG(uap, flags));
+
+ if (fl & O_CREAT)
+ LINUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+ else
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&boa, path) = SCARG(uap, path);
+ SCARG(&boa, flags) = fl;
+ SCARG(&boa, mode) = SCARG(uap, mode);
+
+ if ((error = sys_open(p, &boa, retval)))
+ return error;
+
+ /*
+ * this bit from sunos_misc.c (and svr4_fcntl.c).
+ * If we are a session leader, and we don't have a controlling
+ * terminal yet, and the O_NOCTTY flag is not set, try to make
+ * this the controlling terminal.
+ */
+ if (!(fl & O_NOCTTY) && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
+ struct filedesc *fdp = p->p_fd;
+ struct file *fp = fdp->fd_ofiles[*retval];
+
+ /* ignore any error, just give it a try */
+ if (fp->f_type == DTYPE_VNODE)
+ (fp->f_ops->fo_ioctl) (fp, TIOCSCTTY, (caddr_t) 0, p);
+ }
+ return 0;
+}
+
+/*
+ * This appears to be part of a Linux attempt to switch to 64 bits file sizes.
+ */
+int
+linux_sys_llseek(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_llseek_args /* {
+ syscallarg(int) fd;
+ syscallarg(uint32_t) ohigh;
+ syscallarg(uint32_t) olow;
+ syscallarg(caddr_t) res;
+ syscallarg(int) whence;
+ } */ *uap = v;
+ struct sys_lseek_args bla;
+ int error;
+ off_t off;
+
+ off = SCARG(uap, olow) | (((off_t) SCARG(uap, ohigh)) << 32);
+
+ SCARG(&bla, fd) = SCARG(uap, fd);
+ SCARG(&bla, offset) = off;
+ SCARG(&bla, whence) = SCARG(uap, whence);
+
+ if ((error = sys_lseek(p, &bla, retval)))
+ return error;
+
+ if ((error = copyout(retval, SCARG(uap, res), sizeof (off_t))))
+ return error;
+
+ retval[0] = 0;
+ return 0;
+}
+
+/*
+ * The next two functions take care of converting the flock
+ * structure back and forth between Linux and NetBSD format.
+ * The only difference in the structures is the order of
+ * the fields, and the 'whence' value.
+ */
+static void
+bsd_to_linux_flock(bfp, lfp)
+ struct flock *bfp;
+ struct linux_flock *lfp;
+{
+
+ lfp->l_start = bfp->l_start;
+ lfp->l_len = bfp->l_len;
+ lfp->l_pid = bfp->l_pid;
+ lfp->l_whence = bfp->l_whence;
+ switch (bfp->l_type) {
+ case F_RDLCK:
+ lfp->l_type = LINUX_F_RDLCK;
+ break;
+ case F_UNLCK:
+ lfp->l_type = LINUX_F_UNLCK;
+ break;
+ case F_WRLCK:
+ lfp->l_type = LINUX_F_WRLCK;
+ break;
+ }
+}
+
+static void
+linux_to_bsd_flock(lfp, bfp)
+ struct linux_flock *lfp;
+ struct flock *bfp;
+{
+
+ bfp->l_start = lfp->l_start;
+ bfp->l_len = lfp->l_len;
+ bfp->l_pid = lfp->l_pid;
+ bfp->l_whence = lfp->l_whence;
+ switch (lfp->l_type) {
+ case LINUX_F_RDLCK:
+ bfp->l_type = F_RDLCK;
+ break;
+ case LINUX_F_UNLCK:
+ bfp->l_type = F_UNLCK;
+ break;
+ case LINUX_F_WRLCK:
+ bfp->l_type = F_WRLCK;
+ break;
+ }
+}
+
+/*
+ * Most actions in the fcntl() call are straightforward; simply
+ * pass control to the NetBSD system call. A few commands need
+ * conversions after the actual system call has done its work,
+ * because the flag values and lock structure are different.
+ */
+int
+linux_sys_fcntl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_fcntl_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) cmd;
+ syscallarg(void *) arg;
+ } */ *uap = v;
+ int fd, cmd, error, val;
+ caddr_t arg, sg;
+ struct linux_flock lfl;
+ struct flock *bfp, bfl;
+ struct sys_fcntl_args fca;
+ struct filedesc *fdp;
+ struct file *fp;
+ struct vnode *vp;
+ struct vattr va;
+ long pgid;
+ struct pgrp *pgrp;
+ struct tty *tp, *(*d_tty) __P((dev_t));
+
+ fd = SCARG(uap, fd);
+ cmd = SCARG(uap, cmd);
+ arg = (caddr_t) SCARG(uap, arg);
+
+ switch (cmd) {
+ case LINUX_F_DUPFD:
+ cmd = F_DUPFD;
+ break;
+ case LINUX_F_GETFD:
+ cmd = F_GETFD;
+ break;
+ case LINUX_F_SETFD:
+ cmd = F_SETFD;
+ break;
+ case LINUX_F_GETFL:
+ SCARG(&fca, fd) = fd;
+ SCARG(&fca, cmd) = F_GETFL;
+ SCARG(&fca, arg) = arg;
+ if ((error = sys_fcntl(p, &fca, retval)))
+ return error;
+ retval[0] = bsd_to_linux_ioflags(retval[0]);
+ return 0;
+ case LINUX_F_SETFL:
+ val = linux_to_bsd_ioflags((int)SCARG(uap, arg));
+ SCARG(&fca, fd) = fd;
+ SCARG(&fca, cmd) = F_SETFL;
+ SCARG(&fca, arg) = (caddr_t) val;
+ return sys_fcntl(p, &fca, retval);
+ case LINUX_F_GETLK:
+ sg = stackgap_init(p->p_emul);
+ bfp = (struct flock *) stackgap_alloc(&sg, sizeof *bfp);
+ SCARG(&fca, fd) = fd;
+ SCARG(&fca, cmd) = F_GETLK;
+ SCARG(&fca, arg) = bfp;
+ if ((error = sys_fcntl(p, &fca, retval)))
+ return error;
+ if ((error = copyin(bfp, &bfl, sizeof bfl)))
+ return error;
+ bsd_to_linux_flock(&bfl, &lfl);
+ return copyout(&lfl, arg, sizeof lfl);
+ break;
+ case LINUX_F_SETLK:
+ case LINUX_F_SETLKW:
+ cmd = (cmd == LINUX_F_SETLK ? F_SETLK : F_SETLKW);
+ if ((error = copyin(arg, &lfl, sizeof lfl)))
+ return error;
+ linux_to_bsd_flock(&lfl, &bfl);
+ sg = stackgap_init(p->p_emul);
+ bfp = (struct flock *) stackgap_alloc(&sg, sizeof *bfp);
+ if ((error = copyout(&bfl, bfp, sizeof bfl)))
+ return error;
+ SCARG(&fca, fd) = fd;
+ SCARG(&fca, cmd) = cmd;
+ SCARG(&fca, arg) = bfp;
+ return sys_fcntl(p, &fca, retval);
+ break;
+ case LINUX_F_SETOWN:
+ case LINUX_F_GETOWN:
+ /*
+ * We need to route around the normal fcntl() for these calls,
+ * since it uses TIOC{G,S}PGRP, which is too restrictive for
+ * Linux F_{G,S}ETOWN semantics. For sockets, this problem
+ * does not exist.
+ */
+ fdp = p->p_fd;
+ if ((u_int)fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fd]) == NULL)
+ return EBADF;
+ if (fp->f_type == DTYPE_SOCKET) {
+ cmd = cmd == LINUX_F_SETOWN ? F_SETOWN : F_GETOWN;
+ break;
+ }
+ vp = (struct vnode *)fp->f_data;
+ if (vp->v_type != VCHR)
+ return EINVAL;
+ if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)))
+ return error;
+ d_tty = cdevsw[major(va.va_rdev)].d_tty;
+ if (!d_tty || (!(tp = (*d_tty)(va.va_rdev))))
+ return EINVAL;
+ if (cmd == LINUX_F_GETOWN) {
+ retval[0] = tp->t_pgrp ? tp->t_pgrp->pg_id : NO_PID;
+ return 0;
+ }
+ if ((long)arg <= 0) {
+ pgid = -(long)arg;
+ } else {
+ struct proc *p1 = pfind((long)arg);
+ if (p1 == 0)
+ return (ESRCH);
+ pgid = (long)p1->p_pgrp->pg_id;
+ }
+ pgrp = pgfind(pgid);
+ if (pgrp == NULL || pgrp->pg_session != p->p_session)
+ return EPERM;
+ tp->t_pgrp = pgrp;
+ return 0;
+ default:
+ return EOPNOTSUPP;
+ }
+
+ SCARG(&fca, fd) = fd;
+ SCARG(&fca, cmd) = cmd;
+ SCARG(&fca, arg) = arg;
+
+ return sys_fcntl(p, &fca, retval);
+}
+
+/*
+ * Convert a NetBSD stat structure to a Linux stat structure.
+ * Only the order of the fields and the padding in the structure
+ * is different. linux_fakedev is a machine-dependent function
+ * which optionally converts device driver major/minor numbers
+ * (XXX horrible, but what can you do against code that compares
+ * things against constant major device numbers? sigh)
+ */
+static void
+bsd_to_linux_stat(bsp, lsp)
+ struct stat *bsp;
+ struct linux_stat *lsp;
+{
+
+ lsp->lst_dev = bsp->st_dev;
+ lsp->lst_ino = bsp->st_ino;
+ lsp->lst_mode = bsp->st_mode;
+ lsp->lst_nlink = bsp->st_nlink;
+ lsp->lst_uid = bsp->st_uid;
+ lsp->lst_gid = bsp->st_gid;
+ lsp->lst_rdev = linux_fakedev(bsp->st_rdev);
+ lsp->lst_size = bsp->st_size;
+ lsp->lst_blksize = bsp->st_blksize;
+ lsp->lst_blocks = bsp->st_blocks;
+ lsp->lst_atime = bsp->st_atime;
+ lsp->lst_mtime = bsp->st_mtime;
+ lsp->lst_ctime = bsp->st_ctime;
+}
+
+/*
+ * The stat functions below are plain sailing. stat and lstat are handled
+ * by one function to avoid code duplication.
+ */
+int
+linux_sys_fstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_fstat_args /* {
+ syscallarg(int) fd;
+ syscallarg(linux_stat *) sp;
+ } */ *uap = v;
+ struct sys_fstat_args fsa;
+ struct linux_stat tmplst;
+ struct stat *st,tmpst;
+ caddr_t sg;
+ int error;
+
+ sg = stackgap_init(p->p_emul);
+
+ st = stackgap_alloc(&sg, sizeof (struct stat));
+
+ SCARG(&fsa, fd) = SCARG(uap, fd);
+ SCARG(&fsa, sb) = st;
+
+ if ((error = sys_fstat(p, &fsa, retval)))
+ return error;
+
+ if ((error = copyin(st, &tmpst, sizeof tmpst)))
+ return error;
+
+ bsd_to_linux_stat(&tmpst, &tmplst);
+
+ if ((error = copyout(&tmplst, SCARG(uap, sp), sizeof tmplst)))
+ return error;
+
+ return 0;
+}
+
+static int
+linux_stat1(p, uap, retval, dolstat)
+ struct proc *p;
+ struct linux_sys_stat_args *uap;
+ register_t *retval;
+ int dolstat;
+{
+ struct sys_stat_args sa;
+ struct linux_stat tmplst;
+ struct stat *st, tmpst;
+ caddr_t sg;
+ int error;
+
+ sg = stackgap_init(p->p_emul);
+
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ st = stackgap_alloc(&sg, sizeof (struct stat));
+ SCARG(&sa, ub) = st;
+ SCARG(&sa, path) = SCARG(uap, path);
+
+ if ((error = (dolstat ? sys_lstat(p, &sa, retval) :
+ sys_stat(p, &sa, retval))))
+ return error;
+
+ if ((error = copyin(st, &tmpst, sizeof tmpst)))
+ return error;
+
+ bsd_to_linux_stat(&tmpst, &tmplst);
+
+ if ((error = copyout(&tmplst, SCARG(uap, sp), sizeof tmplst)))
+ return error;
+
+ return 0;
+}
+
+int
+linux_sys_stat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_stat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct linux_stat *) sp;
+ } */ *uap = v;
+
+ return linux_stat1(p, uap, retval, 0);
+}
+
+int
+linux_sys_lstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_lstat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct linux_stat *) sp;
+ } */ *uap = v;
+
+ return linux_stat1(p, uap, retval, 1);
+}
+
+/*
+ * The following syscalls are mostly here because of the alternate path check.
+ */
+int
+linux_sys_access(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_access_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ return sys_access(p, uap, retval);
+}
+
+int
+linux_sys_unlink(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+
+{
+ struct linux_sys_unlink_args /* {
+ syscallarg(char *) path;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ return sys_unlink(p, uap, retval);
+}
+
+int
+linux_sys_chdir(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_chdir_args /* {
+ syscallarg(char *) path;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ return sys_chdir(p, uap, retval);
+}
+
+int
+linux_sys_mknod(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_mknod_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ syscallarg(int) dev;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+ struct sys_mkfifo_args bma;
+
+ LINUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+
+ /*
+ * BSD handles FIFOs seperately
+ */
+ if (SCARG(uap, mode) & S_IFIFO) {
+ SCARG(&bma, path) = SCARG(uap, path);
+ SCARG(&bma, mode) = SCARG(uap, mode);
+ return sys_mkfifo(p, uap, retval);
+ } else
+ return sys_mknod(p, uap, retval);
+}
+
+int
+linux_sys_chmod(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_chmod_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ return sys_chmod(p, uap, retval);
+}
+
+int
+linux_sys_chown(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_chown_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) uid;
+ syscallarg(int) gid;
+ } */ *uap = v;
+ struct sys_chown_args bca;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&bca, path) = SCARG(uap, path);
+ SCARG(&bca, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
+ (uid_t)-1 : SCARG(uap, uid);
+ SCARG(&bca, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ?
+ (gid_t)-1 : SCARG(uap, gid);
+
+ return sys_chown(p, &bca, retval);
+}
+
+int
+linux_sys_fchown(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_fchown_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) uid;
+ syscallarg(int) gid;
+ } */ *uap = v;
+ struct sys_fchown_args bfa;
+
+ SCARG(&bfa, fd) = SCARG(uap, fd);
+ SCARG(&bfa, uid) = ((linux_uid_t)SCARG(uap, uid) == (linux_uid_t)-1) ?
+ (uid_t)-1 : SCARG(uap, uid);
+ SCARG(&bfa, gid) = ((linux_gid_t)SCARG(uap, gid) == (linux_gid_t)-1) ?
+ (gid_t)-1 : SCARG(uap, gid);
+
+ return sys_fchown(p, &bfa, retval);
+}
+
+int
+linux_sys_rename(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_rename_args /* {
+ syscallarg(char *) from;
+ syscallarg(char *) to;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, from));
+ LINUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, to));
+
+ return sys_rename(p, uap, retval);
+}
+
+int
+linux_sys_mkdir(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_mkdir_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ LINUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
+
+ return sys_mkdir(p, uap, retval);
+}
+
+int
+linux_sys_rmdir(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_rmdir_args /* {
+ syscallarg(char *) path;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ return sys_rmdir(p, uap, retval);
+}
+
+int
+linux_sys_symlink(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_symlink_args /* {
+ syscallarg(char *) path;
+ syscallarg(char *) to;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ LINUX_CHECK_ALT_CREAT(p, &sg, SCARG(uap, to));
+
+ return sys_symlink(p, uap, retval);
+}
+
+int
+linux_sys_readlink(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_readlink_args /* {
+ syscallarg(char *) name;
+ syscallarg(char *) buf;
+ syscallarg(int) count;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, name));
+
+ return sys_readlink(p, uap, retval);
+}
+
+int
+linux_sys_truncate(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_truncate_args /* {
+ syscallarg(char *) path;
+ syscallarg(long) length;
+ } */ *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ return compat_43_sys_truncate(p, uap, retval);
+}
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
new file mode 100644
index 00000000000..15967402545
--- /dev/null
+++ b/sys/compat/linux/linux_ioctl.c
@@ -0,0 +1,656 @@
+/* $NetBSD: linux_ioctl.c,v 1.8 1995/10/07 06:27:07 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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/param.h>
+#include <sys/proc.h>
+#include <sys/systm.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/termios.h>
+#include <sys/tty.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <net/if.h>
+#include <sys/sockio.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/linux/linux_types.h>
+#include <compat/linux/linux_ioctl.h>
+#include <compat/linux/linux_sockio.h>
+#include <compat/linux/linux_util.h>
+#include <compat/linux/linux_signal.h>
+#include <compat/linux/linux_syscallargs.h>
+
+static speed_t linux_speeds[] = {
+ 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
+ 9600, 19200, 38400, 57600, 115200
+};
+
+static int linux_spmasks[] = {
+ LINUX_B0, LINUX_B50, LINUX_B75, LINUX_B110, LINUX_B134, LINUX_B150,
+ LINUX_B200, LINUX_B300, LINUX_B600, LINUX_B1200, LINUX_B1800,
+ LINUX_B2400, LINUX_B4800, LINUX_B9600, LINUX_B19200, LINUX_B38400,
+ LINUX_B57600, LINUX_B115200, LINUX_B230400
+};
+
+/*
+ * Deal with termio ioctl cruft. This doesn't look very good..
+ * XXX too much code duplication, obviously..
+ *
+ * The conversion routines between Linux and BSD structures assume
+ * that the fields are already filled with the current values,
+ * so that fields present in BSD but not in Linux keep their current
+ * values.
+ */
+
+static int
+linux_termio_to_bsd_termios(lt, bts)
+ register struct linux_termio *lt;
+ register struct termios *bts;
+{
+ int index;
+
+ bts->c_iflag = 0;
+ bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IGNBRK, IGNBRK);
+ bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_BRKINT, BRKINT);
+ bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IGNPAR, IGNPAR);
+ bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_INPCK, INPCK);
+ bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_ISTRIP, ISTRIP);
+ bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_INLCR, INLCR);
+ bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IGNCR, IGNCR);
+ bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_ICRNL, ICRNL);
+ bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IXON, IXON);
+ bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IXANY, IXANY);
+ bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IXOFF, IXOFF);
+ bts->c_iflag |= cvtto_bsd_mask(lt->c_iflag, LINUX_IMAXBEL, IMAXBEL);
+
+ bts->c_oflag = 0;
+ bts->c_oflag |= cvtto_bsd_mask(lt->c_oflag, LINUX_OPOST, OPOST);
+ bts->c_oflag |= cvtto_bsd_mask(lt->c_oflag, LINUX_ONLCR, ONLCR);
+ bts->c_oflag |= cvtto_bsd_mask(lt->c_oflag, LINUX_XTABS, OXTABS);
+
+ /*
+ * This could have been:
+ * bts->c_cflag = (lt->c_flag & LINUX_CSIZE) << 4
+ * But who knows, those values might perhaps change one day.
+ */
+ switch (lt->c_cflag & LINUX_CSIZE) {
+ case LINUX_CS5:
+ bts->c_cflag = CS5;
+ break;
+ case LINUX_CS6:
+ bts->c_cflag = CS6;
+ break;
+ case LINUX_CS7:
+ bts->c_cflag = CS7;
+ break;
+ case LINUX_CS8:
+ bts->c_cflag = CS8;
+ break;
+ }
+ bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_CSTOPB, CSTOPB);
+ bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_CREAD, CREAD);
+ bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_PARENB, PARENB);
+ bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_PARODD, PARODD);
+ bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_HUPCL, HUPCL);
+ bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_CLOCAL, CLOCAL);
+ bts->c_cflag |= cvtto_bsd_mask(lt->c_cflag, LINUX_CRTSCTS, CRTSCTS);
+
+ bts->c_lflag = 0;
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ISIG, ISIG);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ICANON, ICANON);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHO, ECHO);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOE, ECHOE);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOK, ECHOK);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHONL, ECHONL);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_NOFLSH, NOFLSH);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_TOSTOP, TOSTOP);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOCTL, ECHOCTL);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOPRT, ECHOPRT);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_ECHOKE, ECHOKE);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_FLUSHO, FLUSHO);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_PENDIN, PENDIN);
+ bts->c_lflag |= cvtto_bsd_mask(lt->c_lflag, LINUX_IEXTEN, IEXTEN);
+
+ index = lt->c_cflag & LINUX_CBAUD;
+ if (index & LINUX_CBAUDEX)
+ index = (index & ~LINUX_CBAUDEX) + LINUX_NSPEEDS - 1;
+ bts->c_ispeed = bts->c_ospeed = linux_speeds[index];
+
+ bts->c_cc[VINTR] = lt->c_cc[LINUX_VINTR];
+ bts->c_cc[VQUIT] = lt->c_cc[LINUX_VQUIT];
+ bts->c_cc[VERASE] = lt->c_cc[LINUX_VERASE];
+ bts->c_cc[VKILL] = lt->c_cc[LINUX_VKILL];
+ bts->c_cc[VEOF] = lt->c_cc[LINUX_VEOF];
+ bts->c_cc[VTIME] = lt->c_cc[LINUX_VTIME];
+ bts->c_cc[VMIN] = lt->c_cc[LINUX_VMIN];
+}
+
+static int
+bsd_termios_to_linux_termio(bts, lt)
+ register struct termios *bts;
+ register struct linux_termio *lt;
+{
+ int i, mask;
+
+ lt->c_iflag = 0;
+ lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNBRK, LINUX_IGNBRK);
+ lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, BRKINT, LINUX_BRKINT);
+ lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNPAR, LINUX_IGNPAR);
+ lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, INPCK, LINUX_INPCK);
+ lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, ISTRIP, LINUX_ISTRIP);
+ lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, INLCR, LINUX_INLCR);
+ lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNCR, LINUX_IGNCR);
+ lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, ICRNL, LINUX_ICRNL);
+ lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXON, LINUX_IXON);
+ lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXANY, LINUX_IXANY);
+ lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXOFF, LINUX_IXOFF);
+ lt->c_iflag |= cvtto_linux_mask(bts->c_iflag, IMAXBEL, LINUX_IMAXBEL);
+
+ lt->c_oflag = 0;
+ lt->c_oflag |= cvtto_linux_mask(bts->c_oflag, OPOST, LINUX_OPOST);
+ lt->c_oflag |= cvtto_linux_mask(bts->c_oflag, ONLCR, LINUX_ONLCR);
+ lt->c_oflag |= cvtto_linux_mask(bts->c_oflag, OXTABS, LINUX_XTABS);
+
+ switch (bts->c_cflag & CSIZE) {
+ case CS5:
+ lt->c_cflag = LINUX_CS5;
+ break;
+ case CS6:
+ lt->c_cflag = LINUX_CS6;
+ break;
+ case CS7:
+ lt->c_cflag = LINUX_CS7;
+ break;
+ case CS8:
+ lt->c_cflag = LINUX_CS8;
+ break;
+ }
+ lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, CSTOPB, LINUX_CSTOPB);
+ lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, CREAD, LINUX_CREAD);
+ lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, PARENB, LINUX_PARENB);
+ lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, PARODD, LINUX_PARODD);
+ lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, HUPCL, LINUX_HUPCL);
+ lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, CLOCAL, LINUX_CLOCAL);
+ lt->c_cflag |= cvtto_linux_mask(bts->c_cflag, CRTSCTS, LINUX_CRTSCTS);
+
+ lt->c_lflag = 0;
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ISIG, LINUX_ISIG);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ICANON, LINUX_ICANON);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHO, LINUX_ECHO);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOE, LINUX_ECHOE);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOK, LINUX_ECHOK);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHONL, LINUX_ECHONL);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, NOFLSH, LINUX_NOFLSH);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, TOSTOP, LINUX_TOSTOP);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOCTL, LINUX_ECHOCTL);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOPRT, LINUX_ECHOPRT);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOKE, LINUX_ECHOKE);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, FLUSHO, LINUX_FLUSHO);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, PENDIN, LINUX_PENDIN);
+ lt->c_lflag |= cvtto_linux_mask(bts->c_lflag, IEXTEN, LINUX_IEXTEN);
+
+ mask = LINUX_B9600; /* XXX default value should this be 0? */
+ for (i = 0; i < sizeof (linux_speeds) / sizeof (speed_t); i++) {
+ if (bts->c_ospeed == linux_speeds[i]) {
+ mask = linux_spmasks[i];
+ break;
+ }
+ }
+ lt->c_cflag |= mask;
+
+ lt->c_cc[LINUX_VINTR] = bts->c_cc[VINTR];
+ lt->c_cc[LINUX_VQUIT] = bts->c_cc[VQUIT];
+ lt->c_cc[LINUX_VERASE] = bts->c_cc[VERASE];
+ lt->c_cc[LINUX_VKILL] = bts->c_cc[VKILL];
+ lt->c_cc[LINUX_VEOF] = bts->c_cc[VEOF];
+ lt->c_cc[LINUX_VTIME] = bts->c_cc[VTIME];
+ lt->c_cc[LINUX_VMIN] = bts->c_cc[VMIN];
+ lt->c_cc[LINUX_VSWTC] = 0;
+
+ /* XXX should be fixed someday */
+ lt->c_line = 0;
+}
+
+static int
+linux_termios_to_bsd_termios(lts, bts)
+ register struct linux_termios *lts;
+ register struct termios *bts;
+{
+ int index;
+
+ bts->c_iflag = 0;
+ bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IGNBRK, IGNBRK);
+ bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_BRKINT, BRKINT);
+ bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IGNPAR, IGNPAR);
+ bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_INPCK, INPCK);
+ bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_ISTRIP, ISTRIP);
+ bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_INLCR, INLCR);
+ bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IGNCR, IGNCR);
+ bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_ICRNL, ICRNL);
+ bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IXON, IXON);
+ bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IXANY, IXANY);
+ bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IXOFF, IXOFF);
+ bts->c_iflag |= cvtto_bsd_mask(lts->c_iflag, LINUX_IMAXBEL, IMAXBEL);
+
+ bts->c_oflag = 0;
+ bts->c_oflag |= cvtto_bsd_mask(lts->c_oflag, LINUX_OPOST, OPOST);
+ bts->c_oflag |= cvtto_bsd_mask(lts->c_oflag, LINUX_ONLCR, ONLCR);
+ bts->c_oflag |= cvtto_bsd_mask(lts->c_oflag, LINUX_XTABS, OXTABS);
+
+ bts->c_cflag = 0;
+ switch (lts->c_cflag & LINUX_CSIZE) {
+ case LINUX_CS5:
+ bts->c_cflag = CS5;
+ break;
+ case LINUX_CS6:
+ bts->c_cflag = CS6;
+ break;
+ case LINUX_CS7:
+ bts->c_cflag = CS7;
+ break;
+ case LINUX_CS8:
+ bts->c_cflag = CS8;
+ break;
+ }
+ bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_CSTOPB, CSTOPB);
+ bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_CREAD, CREAD);
+ bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_PARENB, PARENB);
+ bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_PARODD, PARODD);
+ bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_HUPCL, HUPCL);
+ bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_CLOCAL, CLOCAL);
+ bts->c_cflag |= cvtto_bsd_mask(lts->c_cflag, LINUX_CRTSCTS, CRTSCTS);
+
+ bts->c_lflag = 0;
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ISIG, ISIG);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ICANON, ICANON);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHO, ECHO);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOE, ECHOE);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOK, ECHOK);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHONL, ECHONL);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_NOFLSH, NOFLSH);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_TOSTOP, TOSTOP);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOCTL, ECHOCTL);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOPRT, ECHOPRT);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_ECHOKE, ECHOKE);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_FLUSHO, FLUSHO);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_PENDIN, PENDIN);
+ bts->c_lflag |= cvtto_bsd_mask(lts->c_lflag, LINUX_IEXTEN, IEXTEN);
+
+ index = lts->c_cflag & LINUX_CBAUD;
+ if (index & LINUX_CBAUDEX)
+ index = (index & ~LINUX_CBAUDEX) + LINUX_NSPEEDS - 1;
+ bts->c_ispeed = bts->c_ospeed = linux_speeds[index];
+
+ bts->c_cc[VINTR] = lts->c_cc[LINUX_VINTR];
+ bts->c_cc[VQUIT] = lts->c_cc[LINUX_VQUIT];
+ bts->c_cc[VERASE] = lts->c_cc[LINUX_VERASE];
+ bts->c_cc[VKILL] = lts->c_cc[LINUX_VKILL];
+ bts->c_cc[VEOF] = lts->c_cc[LINUX_VEOF];
+ bts->c_cc[VTIME] = lts->c_cc[LINUX_VTIME];
+ bts->c_cc[VMIN] = lts->c_cc[LINUX_VMIN];
+ bts->c_cc[VEOL] = lts->c_cc[LINUX_VEOL];
+ bts->c_cc[VEOL2] = lts->c_cc[LINUX_VEOL2];
+ bts->c_cc[VWERASE] = lts->c_cc[LINUX_VWERASE];
+ bts->c_cc[VSUSP] = lts->c_cc[LINUX_VSUSP];
+ bts->c_cc[VSTART] = lts->c_cc[LINUX_VSTART];
+ bts->c_cc[VSTOP] = lts->c_cc[LINUX_VSTOP];
+ bts->c_cc[VLNEXT] = lts->c_cc[LINUX_VLNEXT];
+ bts->c_cc[VDISCARD] = lts->c_cc[LINUX_VDISCARD];
+ bts->c_cc[VREPRINT] = lts->c_cc[LINUX_VREPRINT];
+}
+
+static int
+bsd_termios_to_linux_termios(bts, lts)
+ register struct termios *bts;
+ register struct linux_termios *lts;
+{
+ int i, mask;
+
+ lts->c_iflag = 0;
+ lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNBRK, LINUX_IGNBRK);
+ lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, BRKINT, LINUX_BRKINT);
+ lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNPAR, LINUX_IGNPAR);
+ lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, INPCK, LINUX_INPCK);
+ lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, ISTRIP, LINUX_ISTRIP);
+ lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, INLCR, LINUX_INLCR);
+ lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IGNCR, LINUX_IGNCR);
+ lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, ICRNL, LINUX_ICRNL);
+ lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXON, LINUX_IXON);
+ lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXANY, LINUX_IXANY);
+ lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IXOFF, LINUX_IXOFF);
+ lts->c_iflag |= cvtto_linux_mask(bts->c_iflag, IMAXBEL, LINUX_IMAXBEL);
+
+ lts->c_oflag = 0;
+ lts->c_oflag |= cvtto_linux_mask(bts->c_oflag, OPOST, LINUX_OPOST);
+ lts->c_oflag |= cvtto_linux_mask(bts->c_oflag, ONLCR, LINUX_ONLCR);
+ lts->c_oflag |= cvtto_linux_mask(bts->c_oflag, OXTABS, LINUX_XTABS);
+
+ switch (bts->c_cflag & CSIZE) {
+ case CS5:
+ lts->c_cflag = LINUX_CS5;
+ break;
+ case CS6:
+ lts->c_cflag = LINUX_CS6;
+ break;
+ case CS7:
+ lts->c_cflag = LINUX_CS7;
+ break;
+ case CS8:
+ lts->c_cflag = LINUX_CS8;
+ break;
+ }
+ lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CS5, LINUX_CS5);
+ lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CS6, LINUX_CS6);
+ lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CS7, LINUX_CS7);
+ lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CS8, LINUX_CS8);
+ lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CSTOPB, LINUX_CSTOPB);
+ lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CREAD, LINUX_CREAD);
+ lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, PARENB, LINUX_PARENB);
+ lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, PARODD, LINUX_PARODD);
+ lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, HUPCL, LINUX_HUPCL);
+ lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CLOCAL, LINUX_CLOCAL);
+ lts->c_cflag |= cvtto_linux_mask(bts->c_cflag, CRTSCTS, LINUX_CRTSCTS);
+
+ lts->c_lflag = 0;
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ISIG, LINUX_ISIG);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ICANON, LINUX_ICANON);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHO, LINUX_ECHO);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOE, LINUX_ECHOE);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOK, LINUX_ECHOK);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHONL, LINUX_ECHONL);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, NOFLSH, LINUX_NOFLSH);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, TOSTOP, LINUX_TOSTOP);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOCTL, LINUX_ECHOCTL);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOPRT, LINUX_ECHOPRT);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, ECHOKE, LINUX_ECHOKE);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, FLUSHO, LINUX_FLUSHO);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, PENDIN, LINUX_PENDIN);
+ lts->c_lflag |= cvtto_linux_mask(bts->c_lflag, IEXTEN, LINUX_IEXTEN);
+
+ mask = LINUX_B9600; /* XXX default value */
+ for (i = 0; i < sizeof (linux_speeds) / sizeof (speed_t); i++) {
+ if (bts->c_ospeed == linux_speeds[i]) {
+ mask = linux_spmasks[i];
+ break;
+ }
+ }
+ lts->c_cflag |= mask;
+
+ lts->c_cc[LINUX_VINTR] = bts->c_cc[VINTR];
+ lts->c_cc[LINUX_VQUIT] = bts->c_cc[VQUIT];
+ lts->c_cc[LINUX_VERASE] = bts->c_cc[VERASE];
+ lts->c_cc[LINUX_VKILL] = bts->c_cc[VKILL];
+ lts->c_cc[LINUX_VEOF] = bts->c_cc[VEOF];
+ lts->c_cc[LINUX_VTIME] = bts->c_cc[VTIME];
+ lts->c_cc[LINUX_VMIN] = bts->c_cc[VMIN];
+ lts->c_cc[LINUX_VEOL] = bts->c_cc[VEOL];
+ lts->c_cc[LINUX_VEOL2] = bts->c_cc[VEOL2];
+ lts->c_cc[LINUX_VWERASE] = bts->c_cc[VWERASE];
+ lts->c_cc[LINUX_VSUSP] = bts->c_cc[VSUSP];
+ lts->c_cc[LINUX_VSTART] = bts->c_cc[VSTART];
+ lts->c_cc[LINUX_VSTOP] = bts->c_cc[VSTOP];
+ lts->c_cc[LINUX_VLNEXT] = bts->c_cc[VLNEXT];
+ lts->c_cc[LINUX_VDISCARD] = bts->c_cc[VDISCARD];
+ lts->c_cc[LINUX_VREPRINT] = bts->c_cc[VREPRINT];
+ lts->c_cc[LINUX_VSWTC] = 0;
+
+ /* XXX should be fixed someday */
+ lts->c_line = 0;
+}
+
+/*
+ * Most ioctl command are just converted to their NetBSD values,
+ * and passed on. The ones that take structure pointers and (flag)
+ * values need some massaging. This is done the usual way by
+ * allocating stackgap memory, letting the actual ioctl call do its
+ * work their and converting back the data afterwards.
+ */
+int
+linux_sys_ioctl(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct linux_sys_ioctl_args /* {
+ syscallarg(int) fd;
+ syscallarg(u_long) com;
+ syscallarg(caddr_t) data;
+ } */ *uap = v;
+ int fd;
+ unsigned long com;
+ caddr_t data, sg;
+ struct file *fp;
+ struct filedesc *fdp;
+ struct linux_termio tmplt, *alt;
+ struct linux_termios tmplts, *alts;
+ struct termios tmpbts, *abts;
+ struct sys_ioctl_args ia;
+ int error, idat, *idatp;
+
+ fd = SCARG(&ia, fd) = SCARG(uap, fd);
+ com = SCARG(uap, com);
+ data = SCARG(&ia, data) = SCARG(uap, data);
+ retval[0] = 0;
+
+ fdp = p->p_fd;
+ if ((u_int)fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fd]) == NULL)
+ return (EBADF);
+
+ if ((fp->f_flag & (FREAD | FWRITE)) == 0)
+ return (EBADF);
+
+ sg = stackgap_init(p->p_emul);
+
+ switch (com) {
+ case LINUX_TCGETS:
+ SCARG(&ia, com) = TIOCGETA;
+ abts = stackgap_alloc(&sg, sizeof (*abts));
+ SCARG(&ia, data) = (caddr_t) abts;
+ if ((error = sys_ioctl(p, &ia, retval)) != 0)
+ return error;
+ if ((error = copyin(abts, &tmpbts, sizeof tmpbts)))
+ return error;
+ bsd_termios_to_linux_termios(&tmpbts, &tmplts);
+ return copyout(&tmplts, data, sizeof tmplts);
+ case LINUX_TCSETS:
+ case LINUX_TCSETSW:
+ case LINUX_TCSETSF:
+ switch (com) {
+ case LINUX_TCSETS:
+ SCARG(&ia, com) = TIOCSETA;
+ break;
+ case LINUX_TCSETSW:
+ SCARG(&ia, com) = TIOCSETAW;
+ break;
+ case LINUX_TCSETSF:
+ SCARG(&ia, com) = TIOCSETAF;
+ break;
+ }
+ if ((error = copyin(data, &tmplts, sizeof tmplts)))
+ return error;
+ abts = stackgap_alloc(&sg, sizeof tmpbts);
+ /*
+ * First fill in all fields, so that we keep the current
+ * values for fields that Linux doesn't know about.
+ */
+ if ((error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA,
+ (caddr_t) &tmpbts, p)))
+ return error;
+ linux_termios_to_bsd_termios(&tmplts, &tmpbts);
+ if ((error = copyout(&tmpbts, abts, sizeof tmpbts)))
+ return error;
+ SCARG(&ia, data) = (caddr_t) abts;
+ return sys_ioctl(p, &ia, retval);
+ case LINUX_TCGETA:
+ SCARG(&ia, com) = TIOCGETA;
+ abts = stackgap_alloc(&sg, sizeof (*abts));
+ SCARG(&ia, data) = (caddr_t) abts;
+ if ((error = sys_ioctl(p, &ia, retval)) != 0)
+ return error;
+ if ((error = copyin(abts, &tmpbts, sizeof tmpbts)))
+ return error;
+ bsd_termios_to_linux_termio(&tmpbts, &tmplt);
+ return copyout(&tmplt, data, sizeof tmplt);
+ case LINUX_TCSETA:
+ case LINUX_TCSETAW:
+ case LINUX_TCSETAF:
+ switch (com) {
+ case LINUX_TCSETA:
+ SCARG(&ia, com) = TIOCSETA;
+ break;
+ case LINUX_TCSETAW:
+ SCARG(&ia, com) = TIOCSETAW;
+ break;
+ case LINUX_TCSETAF:
+ SCARG(&ia, com) = TIOCSETAF;
+ break;
+ }
+ if ((error = copyin(&tmplt, data, sizeof tmplt)))
+ return error;
+ abts = stackgap_alloc(&sg, sizeof tmpbts);
+ /*
+ * First fill in all fields, so that we keep the current
+ * values for fields that Linux doesn't know about.
+ */
+ if ((error = (*fp->f_ops->fo_ioctl)(fp, TIOCGETA,
+ (caddr_t) &tmpbts, p)))
+ return error;
+ linux_termio_to_bsd_termios(&tmplt, &tmpbts);
+ if ((error = copyout(&tmpbts, abts, sizeof tmpbts)))
+ return error;
+ SCARG(&ia, data) = (caddr_t) abts;
+ return sys_ioctl(p, &ia, retval);
+ case LINUX_TIOCSETD:
+ if ((error = copyin(data, (caddr_t) &idat, sizeof idat)))
+ return error;
+ switch (idat) {
+ case LINUX_N_TTY:
+ idat = TTYDISC;
+ break;
+ case LINUX_N_SLIP:
+ idat = SLIPDISC;
+ break;
+ case LINUX_N_PPP:
+ idat = PPPDISC;
+ break;
+ /*
+ * We can't handle the mouse line discipline Linux has.
+ */
+ case LINUX_N_MOUSE:
+ default:
+ return EINVAL;
+ }
+
+ idatp = (int *) stackgap_alloc(&sg, sizeof (int));
+ if ((error = copyout(&idat, idatp, sizeof (int))))
+ return error;
+ SCARG(&ia, com) = TIOCSETD;
+ SCARG(&ia, data) = (caddr_t) idatp;
+ break;
+ case LINUX_TIOCGETD:
+ idatp = (int *) stackgap_alloc(&sg, sizeof (int));
+ SCARG(&ia, com) = TIOCGETD;
+ SCARG(&ia, data) = (caddr_t) idatp;
+ if ((error = sys_ioctl(p, &ia, retval)))
+ return error;
+ if ((error = copyin(idatp, (caddr_t) &idat, sizeof (int))))
+ return error;
+ switch (idat) {
+ case TTYDISC:
+ idat = LINUX_N_TTY;
+ break;
+ case SLIPDISC:
+ idat = LINUX_N_SLIP;
+ break;
+ case PPPDISC:
+ idat = LINUX_N_PPP;
+ break;
+ /*
+ * Linux does not have the tablet line discipline.
+ */
+ case TABLDISC:
+ default:
+ idat = -1; /* XXX What should this be? */
+ break;
+ }
+ return copyout(&idat, data, sizeof (int));
+ case LINUX_TIOCGWINSZ:
+ SCARG(&ia, com) = TIOCGWINSZ;
+ break;
+ case LINUX_TIOCSWINSZ:
+ SCARG(&ia, com) = TIOCSWINSZ;
+ break;
+ case LINUX_TIOCGPGRP:
+ SCARG(&ia, com) = TIOCGPGRP;
+ break;
+ case LINUX_TIOCSPGRP:
+ SCARG(&ia, com) = TIOCSPGRP;
+ break;
+ case LINUX_FIONREAD:
+ SCARG(&ia, com) = FIONREAD;
+ break;
+ case LINUX_FIONBIO:
+ SCARG(&ia, com) = FIONBIO;
+ break;
+ case LINUX_FIOASYNC:
+ SCARG(&ia, com) = FIOASYNC;
+ break;
+ case LINUX_TIOCEXCL:
+ SCARG(&ia, com) = TIOCEXCL;
+ break;
+ case LINUX_TIOCNXCL:
+ SCARG(&ia, com) = TIOCNXCL;
+ break;
+ case LINUX_TIOCCONS:
+ SCARG(&ia, com) = TIOCCONS;
+ break;
+ case LINUX_TIOCNOTTY:
+ SCARG(&ia, com) = TIOCNOTTY;
+ break;
+ case LINUX_SIOCADDMULTI:
+ SCARG(&ia, com) = SIOCADDMULTI;
+ break;
+ case LINUX_SIOCDELMULTI:
+ SCARG(&ia, com) = SIOCDELMULTI;
+ break;
+ default:
+ return linux_machdepioctl(p, uap, retval);
+ }
+
+ return sys_ioctl(p, &ia, retval);
+}
diff --git a/sys/compat/linux/linux_ioctl.h b/sys/compat/linux/linux_ioctl.h
new file mode 100644
index 00000000000..0acc5da9f02
--- /dev/null
+++ b/sys/compat/linux/linux_ioctl.h
@@ -0,0 +1,278 @@
+/* $NetBSD: linux_ioctl.h,v 1.2 1995/08/16 04:14:58 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_IOCTL_H
+#define _LINUX_IOCTL_H
+
+#define _LINUX_IO(c,n) (((c)<< 8) | (n))
+
+#define LINUX_TCGETS _LINUX_IO('T',1)
+#define LINUX_TCSETS _LINUX_IO('T',2)
+#define LINUX_TCSETSW _LINUX_IO('T',3)
+#define LINUX_TCSETSF _LINUX_IO('T',4)
+#define LINUX_TCGETA _LINUX_IO('T',5)
+#define LINUX_TCSETA _LINUX_IO('T',6)
+#define LINUX_TCSETAW _LINUX_IO('T',7)
+#define LINUX_TCSETAF _LINUX_IO('T',8)
+#define LINUX_TCSBRK _LINUX_IO('T',9)
+#define LINUX_TCXONC _LINUX_IO('T',10)
+#define LINUX_TCFLSH _LINUX_IO('T',11)
+#define LINUX_TIOCEXCL _LINUX_IO('T',12)
+#define LINUX_TIOCNXCL _LINUX_IO('T',13)
+#define LINUX_TIOCSCTTY _LINUX_IO('T',14)
+#define LINUX_TIOCGPGRP _LINUX_IO('T',15)
+#define LINUX_TIOCSPGRP _LINUX_IO('T',16)
+#define LINUX_TIOCOUTQ _LINUX_IO('T',17)
+#define LINUX_TIOCSTI _LINUX_IO('T',18)
+#define LINUX_TIOCGWINSZ _LINUX_IO('T',19)
+#define LINUX_TIOCSWINSZ _LINUX_IO('T',20)
+#define LINUX_TIOCMGET _LINUX_IO('T',21)
+#define LINUX_TIOCMBIS _LINUX_IO('T',22)
+#define LINUX_TIOCMBIC _LINUX_IO('T',23)
+#define LINUX_TIOCMSET _LINUX_IO('T',24)
+#define LINUX_TIOCGSOFTCAR _LINUX_IO('T',25)
+#define LINUX_TIOCSSOFTCAR _LINUX_IO('T',26)
+#define LINUX_FIONREAD _LINUX_IO('T',27)
+#define LINUX_TIOCINQ LINUX_FIONREAD
+#define LINUX_TIOCLINUX _LINUX_IO('T',28)
+#define LINUX_TIOCCONS _LINUX_IO('T',29)
+#define LINUX_TIOCGSERIAL _LINUX_IO('T',30)
+#define LINUX_TIOCSSERIAL _LINUX_IO('T',31)
+#define LINUX_TIOCPKT _LINUX_IO('T',32)
+#define LINUX_FIONBIO _LINUX_IO('T',33)
+#define LINUX_TIOCNOTTY _LINUX_IO('T',34)
+#define LINUX_TIOCSETD _LINUX_IO('T',35)
+#define LINUX_TIOCGETD _LINUX_IO('T',36)
+#define LINUX_TCSBRKP _LINUX_IO('T',37)
+#define LINUX_TIOCTTYGSTRUCT _LINUX_IO('T',38)
+
+#define LINUX_FIONCLEX _LINUX_IO('T',80)
+#define LINUX_FIOCLEX _LINUX_IO('T',81)
+#define LINUX_FIOASYNC _LINUX_IO('T',82)
+#define LINUX_TIOCSERCONFIG _LINUX_IO('T',83)
+#define LINUX_TIOCSERGWILD _LINUX_IO('T',84)
+#define LINUX_TIOCSERSWILD _LINUX_IO('T',85)
+#define LINUX_TIOCGLCKTRMIOS _LINUX_IO('T',86)
+#define LINUX_TIOCSLCKTRMIOS _LINUX_IO('T',87)
+#define LINUX_TIOCSERGSTRUCT _LINUX_IO('T',88)
+#define LINUX_TIOCSERGETLSR _LINUX_IO('T',89)
+
+
+#define LINUX_NCC 8
+struct linux_termio {
+ unsigned short c_iflag;
+ unsigned short c_oflag;
+ unsigned short c_cflag;
+ unsigned short c_lflag;
+ unsigned char c_line;
+ unsigned char c_cc[LINUX_NCC];
+};
+
+typedef unsigned char linux_cc_t;
+typedef unsigned long linux_tcflag_t;
+
+#define LINUX_NCCS 19
+struct linux_termios {
+ linux_tcflag_t c_iflag;
+ linux_tcflag_t c_oflag;
+ linux_tcflag_t c_cflag;
+ linux_tcflag_t c_lflag;
+ linux_cc_t c_line;
+ linux_cc_t c_cc[LINUX_NCCS];
+};
+
+/* Just in old style linux_termio struct */
+#define LINUX_VINTR 0
+#define LINUX_VQUIT 1
+#define LINUX_VERASE 2
+#define LINUX_VKILL 3
+#define LINUX_VEOF 4
+#define LINUX_VTIME 5
+#define LINUX_VMIN 6
+#define LINUX_VSWTC 7
+
+/* In the termios struct too */
+#define LINUX_VSTART 8
+#define LINUX_VSTOP 9
+#define LINUX_VSUSP 10
+#define LINUX_VEOL 11
+#define LINUX_VREPRINT 12
+#define LINUX_VDISCARD 13
+#define LINUX_VWERASE 14
+#define LINUX_VLNEXT 15
+#define LINUX_VEOL2 16
+
+/* Linux c_iflag masks */
+#define LINUX_IGNBRK 0x0000001
+#define LINUX_BRKINT 0x0000002
+#define LINUX_IGNPAR 0x0000004
+#define LINUX_PARMRK 0x0000008
+#define LINUX_INPCK 0x0000010
+#define LINUX_ISTRIP 0x0000020
+#define LINUX_INLCR 0x0000040
+#define LINUX_IGNCR 0x0000080
+#define LINUX_ICRNL 0x0000100
+#define LINUX_IUCLC 0x0000200
+#define LINUX_IXON 0x0000400
+#define LINUX_IXANY 0x0000800
+#define LINUX_IXOFF 0x0001000
+#define LINUX_IMAXBEL 0x0002000
+
+/* Linux c_oflag masks */
+#define LINUX_OPOST 0x0000001
+#define LINUX_OLCUC 0x0000002
+#define LINUX_ONLCR 0x0000004
+#define LINUX_OCRNL 0x0000008
+#define LINUX_ONOCR 0x0000010
+#define LINUX_ONLRET 0x0000020
+#define LINUX_OFILL 0x0000040
+#define LINUX_OFDEL 0x0000080
+#define LINUX_NLDLY 0x0000100
+
+#define LINUX_NL0 0x0000000
+#define LINUX_NL1 0x0000100
+#define LINUX_CRDLY 0x0000600
+#define LINUX_CR0 0x0000000
+#define LINUX_CR1 0x0000200
+#define LINUX_CR2 0x0000400
+#define LINUX_CR3 0x0000600
+#define LINUX_TABDLY 0x0001800
+#define LINUX_TAB0 0x0000000
+#define LINUX_TAB1 0x0000800
+#define LINUX_TAB2 0x0001000
+#define LINUX_TAB3 0x0001800
+#define LINUX_XTABS 0x0001800
+#define LINUX_BSDLY 0x0002000
+#define LINUX_BS0 0x0000000
+#define LINUX_BS1 0x0002000
+#define LINUX_VTDLY 0x0004000
+#define LINUX_VT0 0x0000000
+#define LINUX_VT1 0x0004000
+#define LINUX_FFDLY 0x0008000
+#define LINUX_FF0 0x0000000
+#define LINUX_FF1 0x0008000
+
+/* Linux c_cflag bit masks */
+
+#define LINUX_NSPEEDS 16
+#define LINUX_NXSPEEDS 2
+
+#define LINUX_CBAUD 0x0000100f
+
+#define LINUX_B0 0x00000000
+#define LINUX_B50 0x00000001
+#define LINUX_B75 0x00000002
+#define LINUX_B110 0x00000003
+#define LINUX_B134 0x00000004
+#define LINUX_B150 0x00000005
+#define LINUX_B200 0x00000006
+#define LINUX_B300 0x00000007
+#define LINUX_B600 0x00000008
+#define LINUX_B1200 0x00000009
+#define LINUX_B1800 0x0000000a
+#define LINUX_B2400 0x0000000b
+#define LINUX_B4800 0x0000000c
+#define LINUX_B9600 0x0000000d
+#define LINUX_B19200 0x0000000e
+#define LINUX_B38400 0x0000000f
+#define LINUX_EXTA LINUX_B19200
+#define LINUX_EXTB LINUX_B38400
+#define LINUX_CBAUDEX 0x00001000
+#define LINUX_B57600 0x00001001
+#define LINUX_B115200 0x00001002
+#define LINUX_B230400 0x00001003
+
+#define LINUX_CSIZE 0x00000030
+#define LINUX_CS5 0x00000000
+#define LINUX_CS6 0x00000010
+#define LINUX_CS7 0x00000020
+#define LINUX_CS8 0x00000030
+#define LINUX_CSTOPB 0x00000040
+#define LINUX_CREAD 0x00000080
+#define LINUX_PARENB 0x00000100
+#define LINUX_PARODD 0x00000200
+#define LINUX_HUPCL 0x00000400
+#define LINUX_CLOCAL 0x00000800
+
+#define LINUX_CRTSCTS 0x80000000
+
+/* Linux c_lflag masks */
+#define LINUX_ISIG 0x00000001
+#define LINUX_ICANON 0x00000002
+#define LINUX_XCASE 0x00000004
+#define LINUX_ECHO 0x00000008
+#define LINUX_ECHOE 0x00000010
+#define LINUX_ECHOK 0x00000020
+#define LINUX_ECHONL 0x00000040
+#define LINUX_NOFLSH 0x00000080
+#define LINUX_TOSTOP 0x00000100
+#define LINUX_ECHOCTL 0x00000200
+#define LINUX_ECHOPRT 0x00000400
+#define LINUX_ECHOKE 0x00000800
+#define LINUX_FLUSHO 0x00001000
+#define LINUX_PENDIN 0x00002000
+#define LINUX_IEXTEN 0x00008000
+
+/* Linux modem line defines.. not sure if they'll be used */
+#define LINUX_TIOCM_LE 0x0001
+#define LINUX_TIOCM_DTR 0x0002
+#define LINUX_TIOCM_RTS 0x0004
+#define LINUX_TIOCM_ST 0x0008
+#define LINUX_TIOCM_SR 0x0010
+#define LINUX_TIOCM_CTS 0x0020
+#define LINUX_TIOCM_CAR 0x0040
+#define LINUX_TIOCM_RNG 0x0080
+#define LINUX_TIOCM_DSR 0x0100
+#define LINUX_TIOCM_CD LINUX_TIOCM_CAR
+#define LINUX_TIOCM_RI LINUX_TIOCM_RNG
+
+#define LINUX_TCIFLUSH 0
+#define LINUX_TCOFLUSH 1
+#define LINUX_TCIOFLUSH 2
+
+#define LINUX_TCOOFF 0
+#define LINUX_TCOON 1
+#define LINUX_TCIOFF 2
+#define LINUX_TCION 3
+
+#define LINUX_TCSANOW 0
+#define LINUX_TCSADRAIN 1
+#define LINUX_TCSAFLUSH 2
+
+/* Linux line disciplines */
+#define LINUX_N_TTY 0
+#define LINUX_N_SLIP 1
+#define LINUX_N_MOUSE 2
+#define LINUX_N_PPP 3
+
+#endif /* !_LINUX_IOCTL_H */
diff --git a/sys/compat/linux/linux_ipc.c b/sys/compat/linux/linux_ipc.c
new file mode 100644
index 00000000000..407a075eb7e
--- /dev/null
+++ b/sys/compat/linux/linux_ipc.c
@@ -0,0 +1,707 @@
+/* $NetBSD: linux_ipc.c,v 1.9 1995/10/08 22:49:29 fvdl Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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/types.h>
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/shm.h>
+#include <sys/sem.h>
+#include <sys/msg.h>
+#include <sys/proc.h>
+#include <sys/uio.h>
+#include <sys/time.h>
+#include <sys/malloc.h>
+#include <sys/mman.h>
+#include <sys/systm.h>
+#include <sys/stat.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+
+#include <compat/linux/linux_types.h>
+#include <compat/linux/linux_signal.h>
+#include <compat/linux/linux_syscallargs.h>
+#include <compat/linux/linux_util.h>
+#include <compat/linux/linux_ipc.h>
+#include <compat/linux/linux_msg.h>
+#include <compat/linux/linux_shm.h>
+#include <compat/linux/linux_sem.h>
+#include <compat/linux/linux_ipccall.h>
+
+/*
+ * Stuff to deal with the SysV ipc/shm/semaphore interface in Linux.
+ * The main difference is, that Linux handles it all via one
+ * system call, which has the usual maximum amount of 5 arguments.
+ * This results in a kludge for calls that take 6 of them.
+ *
+ * The SYSVXXXX options have to be enabled to get the appropriate
+ * functions to work.
+ */
+
+#ifdef SYSVSEM
+static int linux_semop __P((struct proc *, struct linux_sys_ipc_args *,
+ register_t *));
+static int linux_semget __P((struct proc *, struct linux_sys_ipc_args *,
+ register_t *));
+static int linux_semctl __P((struct proc *, struct linux_sys_ipc_args *,
+ register_t *));
+#endif
+
+#ifdef SYSVMSG
+static int linux_msgsnd __P((struct proc *, struct linux_sys_ipc_args *,
+ register_t *));
+static int linux_msgrcv __P((struct proc *, struct linux_sys_ipc_args *,
+ register_t *));
+static int linux_msgop __P((struct proc *, struct linux_sys_ipc_args *,
+ register_t *));
+static int linux_msgctl __P((struct proc *, struct linux_sys_ipc_args *,
+ register_t *));
+#endif
+
+#ifdef SYSVSHM
+static int linux_shmat __P((struct proc *, struct linux_sys_ipc_args *,
+ register_t *));
+static int linux_shmdt __P((struct proc *, struct linux_sys_ipc_args *,
+ register_t *));
+static int linux_shmget __P((struct proc *, struct linux_sys_ipc_args *,
+ register_t *));
+static int linux_shmctl __P((struct proc *, struct linux_sys_ipc_args *,
+ register_t *));
+#endif
+
+
+int
+linux_sys_ipc(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_ipc_args /* {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+ } */ *uap = v;
+ int what, error;
+
+ switch (SCARG(uap, what)) {
+#ifdef SYSVSEM
+ case LINUX_SYS_semop:
+ return linux_semop(p, uap, retval);
+ case LINUX_SYS_semget:
+ return linux_semget(p, uap, retval);
+ case LINUX_SYS_semctl:
+ return linux_semctl(p, uap, retval);
+#endif
+#ifdef SYSVMSG
+ case LINUX_SYS_msgsnd:
+ return linux_msgsnd(p, uap, retval);
+ case LINUX_SYS_msgrcv:
+ return linux_msgrcv(p, uap, retval);
+ case LINUX_SYS_msgget:
+ return linux_msgget(p, uap, retval);
+ case LINUX_SYS_msgctl:
+ return linux_msgctl(p, uap, retval);
+#endif
+#ifdef SYSVSHM
+ case LINUX_SYS_shmat:
+ return linux_shmat(p, uap, retval);
+ case LINUX_SYS_shmdt:
+ return linux_shmdt(p, uap, retval);
+ case LINUX_SYS_shmget:
+ return linux_shmget(p, uap, retval);
+ case LINUX_SYS_shmctl:
+ return linux_shmctl(p, uap, retval);
+#endif
+ default:
+ return ENOSYS;
+ }
+}
+
+/*
+ * Convert between Linux and NetBSD ipc_perm structures. Only the
+ * order of the fields is different.
+ */
+static void
+linux_to_bsd_ipc_perm(lpp, bpp)
+ struct linux_ipc_perm *lpp;
+ struct ipc_perm *bpp;
+{
+
+ bpp->key = lpp->l_key;
+ bpp->uid = lpp->l_uid;
+ bpp->gid = lpp->l_gid;
+ bpp->cuid = lpp->l_cuid;
+ bpp->cgid = lpp->l_cgid;
+ bpp->mode = lpp->l_mode;
+ bpp->seq = lpp->l_seq;
+}
+
+static void
+bsd_to_linux_ipc_perm(bpp, lpp)
+ struct ipc_perm *bpp;
+ struct linux_ipc_perm *lpp;
+{
+
+ lpp->l_key = bpp->key;
+ lpp->l_uid = bpp->uid;
+ lpp->l_gid = bpp->gid;
+ lpp->l_cuid = bpp->cuid;
+ lpp->l_cgid = bpp->cgid;
+ lpp->l_mode = bpp->mode;
+ lpp->l_seq = bpp->seq;
+}
+
+#ifdef SYSVSEM
+/*
+ * Semaphore operations. Most constants and structures are the same on
+ * both systems. Only semctl() needs some extra work.
+ */
+
+/*
+ * Convert between Linux and NetBSD semid_ds structures.
+ */
+static void
+bsd_to_linux_semid_ds(bs, ls)
+ struct semid_ds *bs;
+ struct linux_semid_ds *ls;
+{
+
+ bsd_to_linux_ipc_perm(&bs->sem_perm, &ls->l_sem_perm);
+ ls->l_sem_otime = bs->sem_otime;
+ ls->l_sem_ctime = bs->sem_ctime;
+ ls->l_sem_nsems = bs->sem_nsems;
+ ls->l_sem_base = bs->sem_base;
+}
+
+static void
+linux_to_bsd_semid_ds(ls, bs)
+ struct linux_semid_ds *ls;
+ struct semid_ds *bs;
+{
+
+ linux_to_bsd_ipc_perm(&ls->l_sem_perm, &bs->sem_perm);
+ bs->sem_otime = ls->l_sem_otime;
+ bs->sem_ctime = ls->l_sem_ctime;
+ bs->sem_nsems = ls->l_sem_nsems;
+ bs->sem_base = ls->l_sem_base;
+}
+
+int
+linux_semop(p, uap, retval)
+ struct proc *p;
+ struct linux_sys_ipc_args /* {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+ } */ *uap;
+ register_t *retval;
+{
+ struct sys_semop_args bsa;
+
+ SCARG(&bsa, semid) = SCARG(uap, a1);
+ SCARG(&bsa, sops) = (struct sembuf *)SCARG(uap, ptr);
+ SCARG(&bsa, nsops) = SCARG(uap, a2);
+
+ return sys_semop(p, &bsa, retval);
+}
+
+int
+linux_semget(p, uap, retval)
+ struct proc *p;
+ struct linux_sys_ipc_args /* {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+ } */ *uap;
+ register_t *retval;
+{
+ struct sys_semget_args bsa;
+
+ SCARG(&bsa, key) = (key_t)SCARG(uap, a1);
+ SCARG(&bsa, nsems) = SCARG(uap, a2);
+ SCARG(&bsa, semflg) = SCARG(uap, a3);
+
+ return sys_semget(p, &bsa, retval);
+}
+
+/*
+ * Most of this can be handled by directly passing the arguments on,
+ * buf IPC_* require a lot of copy{in,out} because of the extra indirection
+ * (we are passed a pointer to a union cointaining a pointer to a semid_ds
+ * structure.
+ */
+int
+linux_semctl(p, uap, retval)
+ struct proc *p;
+ struct linux_sys_ipc_args /* {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+ } */ *uap;
+ register_t *retval;
+{
+ caddr_t sg, unptr, dsp, ldsp;
+ int error, cmd;
+ struct sys___semctl_args bsa;
+ struct linux_semid_ds lm;
+ struct semid_ds bm;
+
+ SCARG(&bsa, semid) = SCARG(uap, a1);
+ SCARG(&bsa, semnum) = SCARG(uap, a2);
+ SCARG(&bsa, cmd) = SCARG(uap, a3);
+ SCARG(&bsa, arg) = (union semun *)SCARG(uap, ptr);
+ switch(SCARG(uap, a3)) {
+ case LINUX_GETVAL:
+ cmd = GETVAL;
+ break;
+ case LINUX_GETPID:
+ cmd = GETPID;
+ break;
+ case LINUX_GETNCNT:
+ cmd = GETNCNT;
+ break;
+ case LINUX_GETZCNT:
+ cmd = GETZCNT;
+ break;
+ case LINUX_SETVAL:
+ cmd = SETVAL;
+ break;
+ case LINUX_IPC_RMID:
+ cmd = IPC_RMID;
+ break;
+ case LINUX_IPC_SET:
+ if ((error = copyin(SCARG(uap, ptr), &ldsp, sizeof ldsp)))
+ return error;
+ if ((error = copyin(ldsp, (caddr_t)&lm, sizeof lm)))
+ return error;
+ linux_to_bsd_semid_ds(&lm, &bm);
+ sg = stackgap_init(p->p_emul);
+ unptr = stackgap_alloc(&sg, sizeof (union semun));
+ dsp = stackgap_alloc(&sg, sizeof (struct semid_ds));
+ if ((error = copyout((caddr_t)&bm, dsp, sizeof bm)))
+ return error;
+ if ((error = copyout((caddr_t)&dsp, unptr, sizeof dsp)))
+ return error;
+ SCARG(&bsa, arg) = (union semun *)unptr;
+ return sys___semctl(p, &bsa, retval);
+ case LINUX_IPC_STAT:
+ sg = stackgap_init(p->p_emul);
+ unptr = stackgap_alloc(&sg, sizeof (union semun *));
+ dsp = stackgap_alloc(&sg, sizeof (struct semid_ds));
+ if ((error = copyout((caddr_t)&dsp, unptr, sizeof dsp)))
+ return error;
+ SCARG(&bsa, arg) = (union semun *)unptr;
+ if ((error = sys___semctl(p, &bsa, retval)))
+ return error;
+ if ((error = copyin(dsp, (caddr_t)&bm, sizeof bm)))
+ return error;
+ bsd_to_linux_semid_ds(&bm, &lm);
+ if ((error = copyin(SCARG(uap, ptr), &ldsp, sizeof ldsp)))
+ return error;
+ return copyout((caddr_t)&lm, ldsp, sizeof lm);
+ default:
+ return EINVAL;
+ }
+ SCARG(&bsa, cmd) = cmd;
+
+ return sys___semctl(p, &bsa, retval);
+}
+#endif /* SYSVSEM */
+
+#ifdef SYSVMSG
+
+static void
+linux_to_bsd_msqid_ds(lmp, bmp)
+ struct linux_msqid_ds *lmp;
+ struct msqid_ds *bmp;
+{
+
+ linux_to_bsd_ipc_perm(&lmp->l_msg_perm, &bmp->msg_perm);
+ bmp->msg_first = lmp->l_msg_first;
+ bmp->msg_last = lmp->l_msg_last;
+ bmp->msg_cbytes = lmp->l_msg_cbytes;
+ bmp->msg_qnum = lmp->l_msg_qnum;
+ bmp->msg_qbytes = lmp->l_msg_qbytes;
+ bmp->msg_lspid = lmp->l_msg_lspid;
+ bmp->msg_lrpid = lmp->l_msg_lrpid;
+ bmp->msg_stime = lmp->l_msg_stime;
+ bmp->msg_rtime = lmp->l_msg_rtime;
+ bmp->msg_ctime = lmp->l_msg_ctime;
+}
+
+static void
+bsd_to_linux_msqid_ds(bmp, lmp)
+ struct msqid_ds *bmp;
+ struct linux_msqid_ds *lmp;
+{
+
+ bsd_to_linux_ipc_perm(&bmp->msg_perm, &lmp->l_msg_perm);
+ lmp->l_msg_first = bmp->msg_first;
+ lmp->l_msg_last = bmp->msg_last;
+ lmp->l_msg_cbytes = bmp->msg_cbytes;
+ lmp->l_msg_qnum = bmp->msg_qnum;
+ lmp->l_msg_qbytes = bmp->msg_qbytes;
+ lmp->l_msg_lspid = bmp->msg_lspid;
+ lmp->l_msg_lrpid = bmp->msg_lrpid;
+ lmp->l_msg_stime = bmp->msg_stime;
+ lmp->l_msg_rtime = bmp->msg_rtime;
+ lmp->l_msg_ctime = bmp->msg_ctime;
+}
+
+int
+linux_msgsnd(p, uap, retval)
+ struct proc *p;
+ struct linux_sys_ipc_args /* {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+ } */ *uap;
+ register_t *retval;
+{
+ struct sys_msgsnd_args bma;
+
+ SCARG(&bma, msqid) = SCARG(uap, a1);
+ SCARG(&bma, msgp) = SCARG(uap, ptr);
+ SCARG(&bma, msgsz) = SCARG(uap, a2);
+ SCARG(&bma, msgflg) = SCARG(uap, a3);
+
+ return sys_msgsnd(p, &bma, retval);
+}
+
+int
+linux_msgrcv(p, uap, retval)
+ struct proc *p;
+ struct linux_sys_ipc_args /* {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+ } */ *uap;
+ register_t *retval;
+{
+ struct sys_msgrcv_args bma;
+ struct linux_msgrcv_msgarg kluge;
+ int error;
+
+ if ((error = copyin(SCARG(uap, ptr), &kluge, sizeof kluge)))
+ return error;
+
+ SCARG(&bma, msqid) = SCARG(uap, a1);
+ SCARG(&bma, msgp) = kluge.msg;
+ SCARG(&bma, msgsz) = SCARG(uap, a2);
+ SCARG(&bma, msgtyp) = kluge.type;
+ SCARG(&bma, msgflg) = SCARG(uap, a3);
+
+ return sys_msgrcv(p, &bma, retval);
+}
+
+int
+linux_msgget(p, uap, retval)
+ struct proc *p;
+ struct linux_sys_ipc_args /* {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+ } */ *uap;
+ register_t *retval;
+{
+ struct sys_msgget_args bma;
+
+ SCARG(&bma, key) = (key_t)SCARG(uap, a1);
+ SCARG(&bma, msgflg) = SCARG(uap, a2);
+
+ return sys_msgget(p, &bma, retval);
+}
+
+int
+linux_msgctl(p, uap, retval)
+ struct proc *p;
+ struct linux_sys_ipc_args /* {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+ } */ *uap;
+ register_t *retval;
+{
+ struct sys_msgctl_args bma;
+ caddr_t umsgptr, sg;
+ struct linux_msqid_ds lm;
+ struct msqid_ds bm;
+ int error;
+
+ SCARG(&bma, msqid) = SCARG(uap, a1);
+ SCARG(&bma, cmd) = SCARG(uap, a2);
+ switch (SCARG(uap, a2)) {
+ case LINUX_IPC_RMID:
+ return sys_msgctl(p, &bma, retval);
+ case LINUX_IPC_SET:
+ if ((error = copyin(SCARG(uap, ptr), (caddr_t)&lm, sizeof lm)))
+ return error;
+ linux_to_bsd_msqid_ds(&lm, &bm);
+ sg = stackgap_init(p->p_emul);
+ umsgptr = stackgap_alloc(&sg, sizeof bm);
+ if ((error = copyout((caddr_t)&bm, umsgptr, sizeof bm)))
+ return error;
+ SCARG(&bma, buf) = (struct msqid_ds *)umsgptr;
+ return sys_msgctl(p, &bma, retval);
+ case LINUX_IPC_STAT:
+ sg = stackgap_init(p->p_emul);
+ umsgptr = stackgap_alloc(&sg, sizeof (struct msqid_ds));
+ SCARG(&bma, buf) = (struct msqid_ds *)umsgptr;
+ if ((error = sys_msgctl(p, &bma, retval)))
+ return error;
+ if ((error = copyin(umsgptr, (caddr_t)&bm, sizeof bm)))
+ return error;
+ bsd_to_linux_msqid_ds(&bm, &lm);
+ return copyout((caddr_t)&lm, SCARG(uap, ptr), sizeof lm);
+ }
+ return EINVAL;
+}
+#endif /* SYSVMSG */
+
+#ifdef SYSVSHM
+/*
+ * shmat(2). Very straightforward, except that Linux passes a pointer
+ * in which the return value is to be passed. This is subsequently
+ * handled by libc, apparently.
+ */
+int
+linux_shmat(p, uap, retval)
+ struct proc *p;
+ struct linux_sys_ipc_args /* {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+ } */ *uap;
+ register_t *retval;
+{
+ struct sys_shmat_args bsa;
+ int error;
+
+ SCARG(&bsa, shmid) = SCARG(uap, a1);
+ SCARG(&bsa, shmaddr) = SCARG(uap, ptr);
+ SCARG(&bsa, shmflg) = SCARG(uap, a2);
+
+ if ((error = sys_shmat(p, &bsa, retval)))
+ return error;
+
+ if ((error = copyout(&retval[0], (caddr_t) SCARG(uap, a3),
+ sizeof retval[0])))
+ return error;
+
+ retval[0] = 0;
+ return 0;
+}
+
+/*
+ * shmdt(): this could have been mapped directly, if it wasn't for
+ * the extra indirection by the linux_ipc system call.
+ */
+int
+linux_shmdt(p, uap, retval)
+ struct proc *p;
+ struct linux_sys_ipc_args /* {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+ } */ *uap;
+ register_t *retval;
+{
+ struct sys_shmdt_args bsa;
+
+ SCARG(&bsa, shmaddr) = SCARG(uap, ptr);
+
+ return sys_shmdt(p, &bsa, retval);
+}
+
+/*
+ * Same story as shmdt.
+ */
+int
+linux_shmget(p, uap, retval)
+ struct proc *p;
+ struct linux_sys_ipc_args /* {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+ } */ *uap;
+ register_t *retval;
+{
+ struct sys_shmget_args bsa;
+
+ SCARG(&bsa, key) = SCARG(uap, a1);
+ SCARG(&bsa, size) = SCARG(uap, a2);
+ SCARG(&bsa, shmflg) = SCARG(uap, a3);
+
+ return sys_shmget(p, &bsa, retval);
+}
+
+/*
+ * Convert between Linux and NetBSD shmid_ds structures.
+ * The order of the fields is once again the difference, and
+ * we also need a place to store the internal data pointer
+ * in, which is unfortunately stored in this structure.
+ *
+ * We abuse a Linux internal field for that.
+ */
+static void
+linux_to_bsd_shmid_ds(lsp, bsp)
+ struct linux_shmid_ds *lsp;
+ struct shmid_ds *bsp;
+{
+
+ linux_to_bsd_ipc_perm(&lsp->l_shm_perm, &bsp->shm_perm);
+ bsp->shm_segsz = lsp->l_shm_segsz;
+ bsp->shm_lpid = lsp->l_shm_lpid;
+ bsp->shm_cpid = lsp->l_shm_cpid;
+ bsp->shm_nattch = lsp->l_shm_nattch;
+ bsp->shm_atime = lsp->l_shm_atime;
+ bsp->shm_dtime = lsp->l_shm_dtime;
+ bsp->shm_ctime = lsp->l_shm_ctime;
+ bsp->shm_internal = lsp->l_private2; /* XXX Oh well. */
+}
+
+static void
+bsd_to_linux_shmid_ds(bsp, lsp)
+ struct shmid_ds *bsp;
+ struct linux_shmid_ds *lsp;
+{
+
+ bsd_to_linux_ipc_perm(&bsp->shm_perm, &lsp->l_shm_perm);
+ lsp->l_shm_segsz = bsp->shm_segsz;
+ lsp->l_shm_lpid = bsp->shm_lpid;
+ lsp->l_shm_cpid = bsp->shm_cpid;
+ lsp->l_shm_nattch = bsp->shm_nattch;
+ lsp->l_shm_atime = bsp->shm_atime;
+ lsp->l_shm_dtime = bsp->shm_dtime;
+ lsp->l_shm_ctime = bsp->shm_ctime;
+ lsp->l_private2 = bsp->shm_internal; /* XXX */
+}
+
+/*
+ * shmctl. Not implemented (for now): IPC_INFO, SHM_INFO, SHM_STAT
+ * SHM_LOCK and SHM_UNLOCK are passed on, but currently not implemented
+ * by NetBSD itself.
+ *
+ * The usual structure conversion and massaging is done.
+ */
+int
+linux_shmctl(p, uap, retval)
+ struct proc *p;
+ struct linux_sys_ipc_args /* {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+ } */ *uap;
+ register_t *retval;
+{
+ int error;
+ caddr_t sg;
+ struct sys_shmctl_args bsa;
+ struct shmid_ds *bsp, bs;
+ struct linux_shmid_ds lseg;
+
+ switch (SCARG(uap, a2)) {
+ case LINUX_IPC_STAT:
+ sg = stackgap_init(p->p_emul);
+ bsp = stackgap_alloc(&sg, sizeof (struct shmid_ds));
+ SCARG(&bsa, shmid) = SCARG(uap, a1);
+ SCARG(&bsa, cmd) = IPC_STAT;
+ SCARG(&bsa, buf) = bsp;
+ if ((error = sys_shmctl(p, &bsa, retval)))
+ return error;
+ if ((error = copyin((caddr_t) &bs, (caddr_t) bsp, sizeof bs)))
+ return error;
+ bsd_to_linux_shmid_ds(&bs, &lseg);
+ return copyout((caddr_t) &lseg, SCARG(uap, ptr), sizeof lseg);
+ case LINUX_IPC_SET:
+ if ((error = copyin(SCARG(uap, ptr), (caddr_t) &lseg,
+ sizeof lseg)))
+ return error;
+ linux_to_bsd_shmid_ds(&lseg, &bs);
+ sg = stackgap_init(p->p_emul);
+ bsp = stackgap_alloc(&sg, sizeof (struct shmid_ds));
+ if ((error = copyout((caddr_t) &bs, (caddr_t) bsp, sizeof bs)))
+ return error;
+ SCARG(&bsa, shmid) = SCARG(uap, a1);
+ SCARG(&bsa, cmd) = IPC_SET;
+ SCARG(&bsa, buf) = bsp;
+ return sys_shmctl(p, &bsa, retval);
+ case LINUX_IPC_RMID:
+ case LINUX_SHM_LOCK:
+ case LINUX_SHM_UNLOCK:
+ SCARG(&bsa, shmid) = SCARG(uap, a1);
+ switch (SCARG(uap, a2)) {
+ case LINUX_IPC_RMID:
+ SCARG(&bsa, cmd) = IPC_RMID;
+ break;
+ case LINUX_SHM_LOCK:
+ SCARG(&bsa, cmd) = SHM_LOCK;
+ break;
+ case LINUX_SHM_UNLOCK:
+ SCARG(&bsa, cmd) = SHM_UNLOCK;
+ break;
+ }
+ SCARG(&bsa, buf) = NULL;
+ return sys_shmctl(p, &bsa, retval);
+ case LINUX_IPC_INFO:
+ case LINUX_SHM_STAT:
+ case LINUX_SHM_INFO:
+ default:
+ return EINVAL;
+ }
+}
+#endif /* SYSVSHM */
diff --git a/sys/compat/linux/linux_ipc.h b/sys/compat/linux/linux_ipc.h
new file mode 100644
index 00000000000..1f9245f6ed8
--- /dev/null
+++ b/sys/compat/linux/linux_ipc.h
@@ -0,0 +1,64 @@
+/* $NetBSD: linux_ipc.h,v 1.1 1995/02/28 23:25:47 fvdl Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_IPC_H
+#define _LINUX_IPC_H
+
+/*
+ * Structs and values to handle the SYSV ipc/shm/msg calls implemented
+ * in Linux. Most values match the NetBSD values (as they are both derived
+ * from SysV values). Values that are the same may not be defined here.
+ */
+
+typedef int linux_key_t;
+
+/*
+ * The only thing different about the Linux ipc_perm structure is the
+ * order of the fields.
+ */
+struct linux_ipc_perm {
+ linux_key_t l_key;
+ ushort l_uid;
+ ushort l_gid;
+ ushort l_cuid;
+ ushort l_cgid;
+ ushort l_mode;
+ ushort l_seq;
+};
+
+#define LINUX_IPC_RMID 0
+#define LINUX_IPC_SET 1
+#define LINUX_IPC_STAT 2
+#define LINUX_IPC_INFO 3
+
+#endif /* _LINUX_IPC_H */
diff --git a/sys/compat/linux/linux_ipccall.h b/sys/compat/linux/linux_ipccall.h
new file mode 100644
index 00000000000..854b641dac2
--- /dev/null
+++ b/sys/compat/linux/linux_ipccall.h
@@ -0,0 +1,54 @@
+/* $NetBSD: linux_ipccall.h,v 1.2 1995/08/15 21:14:33 fvdl Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_IPC_CALL_H
+#define _LINUX_IPC_CALL_H
+
+/*
+ * Defines for the numbers passes as the first argument to the
+ * linux_ipc() call, and based on which the actual system calls
+ * are made.
+ */
+#define LINUX_SYS_semop 1
+#define LINUX_SYS_semget 2
+#define LINUX_SYS_semctl 3
+#define LINUX_SYS_msgsnd 11
+#define LINUX_SYS_msgrcv 12
+#define LINUX_SYS_msgget 13
+#define LINUX_SYS_msgctl 14
+#define LINUX_SYS_shmat 21
+#define LINUX_SYS_shmdt 22
+#define LINUX_SYS_shmget 23
+#define LINUX_SYS_shmctl 24
+
+#endif /* _LINUX_IPC_CALL_H */
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
new file mode 100644
index 00000000000..a244225896a
--- /dev/null
+++ b/sys/compat/linux/linux_misc.c
@@ -0,0 +1,1105 @@
+/* $NetBSD: linux_misc.c,v 1.22 1995/10/09 11:24:05 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+/*
+ * Linux compatibility module. Try to deal with various Linux system calls.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/dir.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/ptrace.h>
+#include <sys/resource.h>
+#include <sys/resourcevar.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <sys/times.h>
+#include <sys/vnode.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <sys/utsname.h>
+#include <sys/unistd.h>
+
+#include <sys/syscallargs.h>
+
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+
+#include <compat/linux/linux_types.h>
+#include <compat/linux/linux_fcntl.h>
+#include <compat/linux/linux_mmap.h>
+#include <compat/linux/linux_signal.h>
+#include <compat/linux/linux_syscallargs.h>
+#include <compat/linux/linux_util.h>
+#include <compat/linux/linux_dirent.h>
+
+/*
+ * The information on a terminated (or stopped) process needs
+ * to be converted in order for Linux binaries to get a valid signal
+ * number out of it.
+ */
+static int
+bsd_to_linux_wstat(status)
+ int *status;
+{
+
+ if (WIFSIGNALED(*status))
+ *status = (*status & ~0177) |
+ bsd_to_linux_sig[WTERMSIG(*status)];
+ else if (WIFSTOPPED(*status))
+ *status = (*status & ~0xff00) |
+ (bsd_to_linux_sig[WSTOPSIG(*status)] << 8);
+}
+
+/*
+ * waitpid(2). Passed on to the NetBSD call, surrounded by code to
+ * reserve some space for a NetBSD-style wait status, and converting
+ * it to what Linux wants.
+ */
+int
+linux_sys_waitpid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_waitpid_args /* {
+ syscallarg(int) pid;
+ syscallarg(int *) status;
+ syscallarg(int) options;
+ } */ *uap = v;
+ struct sys_wait4_args w4a;
+ int error, *status, tstat;
+ caddr_t sg;
+
+ if (SCARG(uap, status) != NULL) {
+ sg = stackgap_init(p->p_emul);
+ status = (int *) stackgap_alloc(&sg, sizeof status);
+ } else
+ status = NULL;
+
+ SCARG(&w4a, pid) = SCARG(uap, pid);
+ SCARG(&w4a, status) = status;
+ SCARG(&w4a, options) = SCARG(uap, options);
+ SCARG(&w4a, rusage) = NULL;
+
+ if ((error = sys_wait4(p, &w4a, retval)))
+ return error;
+
+ p->p_siglist &= ~sigmask(SIGCHLD);
+
+ if (status != NULL) {
+ if ((error = copyin(status, &tstat, sizeof tstat)))
+ return error;
+
+ bsd_to_linux_wstat(&tstat);
+ return copyout(&tstat, SCARG(uap, status), sizeof tstat);
+ }
+
+ return 0;
+}
+
+/*
+ * This is very much the same as waitpid()
+ */
+int
+linux_sys_wait4(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_wait4_args /* {
+ syscallarg(int) pid;
+ syscallarg(int *) status;
+ syscallarg(int) options;
+ syscallarg(struct rusage *) rusage;
+ } */ *uap = v;
+ struct sys_wait4_args w4a;
+ int error, *status, tstat;
+ caddr_t sg;
+
+ if (SCARG(uap, status) != NULL) {
+ sg = stackgap_init(p->p_emul);
+ status = (int *) stackgap_alloc(&sg, sizeof status);
+ } else
+ status = NULL;
+
+ SCARG(&w4a, pid) = SCARG(uap, pid);
+ SCARG(&w4a, status) = status;
+ SCARG(&w4a, options) = SCARG(uap, options);
+ SCARG(&w4a, rusage) = SCARG(uap, rusage);
+
+ if ((error = sys_wait4(p, &w4a, retval)))
+ return error;
+
+ p->p_siglist &= ~sigmask(SIGCHLD);
+
+ if (status != NULL) {
+ if ((error = copyin(status, &tstat, sizeof tstat)))
+ return error;
+
+ bsd_to_linux_wstat(&tstat);
+
+ return copyout(&tstat, SCARG(uap, status), sizeof tstat);
+ }
+
+ return 0;
+}
+
+/*
+ * This is the old brk(2) call. I don't think anything in the Linux
+ * world uses this anymore
+ */
+int
+linux_sys_break(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_brk_args /* {
+ syscallarg(char *) nsize;
+ } */ *uap = v;
+
+ return ENOSYS;
+}
+
+/*
+ * Linux brk(2). The check if the new address is >= the old one is
+ * done in the kernel in Linux. NetBSD does it in the library.
+ */
+int
+linux_sys_brk(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_brk_args /* {
+ syscallarg(char *) nsize;
+ } */ *uap = v;
+ char *nbrk = SCARG(uap, nsize);
+ struct sys_obreak_args oba;
+ struct vmspace *vm = p->p_vmspace;
+ int error = 0;
+ caddr_t oldbrk, newbrk;
+
+ oldbrk = vm->vm_daddr + ctob(vm->vm_dsize);
+ /*
+ * XXX inconsistent.. Linux always returns at least the old
+ * brk value, but it will be page-aligned if this fails,
+ * and possibly not page aligned if it succeeds (the user
+ * supplied pointer is returned).
+ */
+ SCARG(&oba, nsize) = nbrk;
+
+ if ((caddr_t) nbrk > vm->vm_daddr && sys_obreak(p, &oba, retval) == 0)
+ retval[0] = (register_t)nbrk;
+ else
+ retval[0] = (register_t)oldbrk;
+
+ return 0;
+}
+
+/*
+ * I wonder why Linux has gettimeofday() _and_ time().. Still, we
+ * need to deal with it.
+ */
+int
+linux_sys_time(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_time_args /* {
+ linux_time_t *t;
+ } */ *uap = v;
+ struct timeval atv;
+ linux_time_t tt;
+ int error;
+
+ microtime(&atv);
+
+ tt = atv.tv_sec;
+ if (SCARG(uap, t) && (error = copyout(&tt, SCARG(uap, t), sizeof tt)))
+ return error;
+
+ retval[0] = tt;
+ return 0;
+}
+
+/*
+ * Convert BSD statfs structure to Linux statfs structure.
+ * The Linux structure has less fields, and it also wants
+ * the length of a name in a dir entry in a field, which
+ * we fake (probably the wrong way).
+ */
+static void
+bsd_to_linux_statfs(bsp, lsp)
+ struct statfs *bsp;
+ struct linux_statfs *lsp;
+{
+
+ lsp->l_ftype = bsp->f_type;
+ lsp->l_fbsize = bsp->f_bsize;
+ lsp->l_fblocks = bsp->f_blocks;
+ lsp->l_fbfree = bsp->f_bfree;
+ lsp->l_fbavail = bsp->f_bavail;
+ lsp->l_ffiles = bsp->f_files;
+ lsp->l_fffree = bsp->f_ffree;
+ lsp->l_ffsid.val[0] = bsp->f_fsid.val[0];
+ lsp->l_ffsid.val[1] = bsp->f_fsid.val[1];
+ lsp->l_fnamelen = MAXNAMLEN; /* XXX */
+}
+
+/*
+ * Implement the fs stat functions. Straightforward.
+ */
+int
+linux_sys_statfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_statfs_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct linux_statfs *) sp;
+ } */ *uap = v;
+ struct statfs btmp, *bsp;
+ struct linux_statfs ltmp;
+ struct sys_statfs_args bsa;
+ caddr_t sg;
+ int error;
+
+ sg = stackgap_init(p->p_emul);
+ bsp = (struct statfs *) stackgap_alloc(&sg, sizeof (struct statfs));
+
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&bsa, path) = SCARG(uap, path);
+ SCARG(&bsa, buf) = bsp;
+
+ if ((error = sys_statfs(p, &bsa, retval)))
+ return error;
+
+ if ((error = copyin((caddr_t) bsp, (caddr_t) &btmp, sizeof btmp)))
+ return error;
+
+ bsd_to_linux_statfs(&btmp, &ltmp);
+
+ return copyout((caddr_t) &ltmp, (caddr_t) SCARG(uap, sp), sizeof ltmp);
+}
+
+int
+linux_sys_fstatfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_fstatfs_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct linux_statfs *) sp;
+ } */ *uap = v;
+ struct statfs btmp, *bsp;
+ struct linux_statfs ltmp;
+ struct sys_fstatfs_args bsa;
+ caddr_t sg;
+ int error;
+
+ sg = stackgap_init(p->p_emul);
+ bsp = (struct statfs *) stackgap_alloc(&sg, sizeof (struct statfs));
+
+ SCARG(&bsa, fd) = SCARG(uap, fd);
+ SCARG(&bsa, buf) = bsp;
+
+ if ((error = sys_fstatfs(p, &bsa, retval)))
+ return error;
+
+ if ((error = copyin((caddr_t) bsp, (caddr_t) &btmp, sizeof btmp)))
+ return error;
+
+ bsd_to_linux_statfs(&btmp, &ltmp);
+
+ return copyout((caddr_t) &ltmp, (caddr_t) SCARG(uap, sp), sizeof ltmp);
+}
+
+/*
+ * uname(). Just copy the info from the various strings stored in the
+ * kernel, and put it in the Linux utsname structure. That structure
+ * is almost the same as the NetBSD one, only it has fields 65 characters
+ * long, and an extra domainname field.
+ */
+int
+linux_sys_uname(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_uname_args /* {
+ syscallarg(struct linux_utsname *) up;
+ } */ *uap = v;
+ extern char ostype[], hostname[], osrelease[], version[], machine[],
+ domainname[];
+ struct linux_utsname luts;
+ int len;
+ char *cp;
+
+ strncpy(luts.l_sysname, ostype, sizeof(luts.l_sysname));
+ strncpy(luts.l_nodename, hostname, sizeof(luts.l_nodename));
+ strncpy(luts.l_release, osrelease, sizeof(luts.l_release));
+ strncpy(luts.l_version, version, sizeof(luts.l_version));
+ strncpy(luts.l_machine, machine, sizeof(luts.l_machine));
+ strncpy(luts.l_domainname, domainname, sizeof(luts.l_domainname));
+
+ /* This part taken from the the uname() in libc */
+ len = sizeof(luts.l_version);
+ for (cp = luts.l_version; len--; ++cp)
+ if (*cp == '\n' || *cp == '\t')
+ if (len > 1)
+ *cp = ' ';
+ else
+ *cp = '\0';
+
+ return copyout(&luts, SCARG(uap, up), sizeof(luts));
+}
+
+int
+linux_sys_olduname(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_uname_args /* {
+ syscallarg(struct linux_oldutsname *) up;
+ } */ *uap = v;
+ extern char ostype[], hostname[], osrelease[], version[], machine[];
+ struct linux_oldutsname luts;
+ int len;
+ char *cp;
+
+ strncpy(luts.l_sysname, ostype, sizeof(luts.l_sysname));
+ strncpy(luts.l_nodename, hostname, sizeof(luts.l_nodename));
+ strncpy(luts.l_release, osrelease, sizeof(luts.l_release));
+ strncpy(luts.l_version, version, sizeof(luts.l_version));
+ strncpy(luts.l_machine, machine, sizeof(luts.l_machine));
+
+ /* This part taken from the the uname() in libc */
+ len = sizeof(luts.l_version);
+ for (cp = luts.l_version; len--; ++cp)
+ if (*cp == '\n' || *cp == '\t')
+ if (len > 1)
+ *cp = ' ';
+ else
+ *cp = '\0';
+
+ return copyout(&luts, SCARG(uap, up), sizeof(luts));
+}
+
+int
+linux_sys_oldolduname(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_uname_args /* {
+ syscallarg(struct linux_oldoldutsname *) up;
+ } */ *uap = v;
+ extern char ostype[], hostname[], osrelease[], version[], machine[];
+ struct linux_oldoldutsname luts;
+ int len;
+ char *cp;
+
+ strncpy(luts.l_sysname, ostype, sizeof(luts.l_sysname));
+ strncpy(luts.l_nodename, hostname, sizeof(luts.l_nodename));
+ strncpy(luts.l_release, osrelease, sizeof(luts.l_release));
+ strncpy(luts.l_version, version, sizeof(luts.l_version));
+ strncpy(luts.l_machine, machine, sizeof(luts.l_machine));
+
+ /* This part taken from the the uname() in libc */
+ len = sizeof(luts.l_version);
+ for (cp = luts.l_version; len--; ++cp)
+ if (*cp == '\n' || *cp == '\t')
+ if (len > 1)
+ *cp = ' ';
+ else
+ *cp = '\0';
+
+ return copyout(&luts, SCARG(uap, up), sizeof(luts));
+}
+
+/*
+ * Linux wants to pass everything to a syscall in registers. However,
+ * mmap() has 6 of them. Oops: out of register error. They just pass
+ * everything in a structure.
+ */
+int
+linux_sys_mmap(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_mmap_args /* {
+ syscallarg(struct linux_mmap *) lmp;
+ } */ *uap = v;
+ struct linux_mmap lmap;
+ struct sys_mmap_args cma;
+ int error, flags;
+
+ if ((error = copyin(SCARG(uap, lmp), &lmap, sizeof lmap)))
+ return error;
+
+ flags = 0;
+ flags |= cvtto_bsd_mask(lmap.lm_flags, LINUX_MAP_SHARED, MAP_SHARED);
+ flags |= cvtto_bsd_mask(lmap.lm_flags, LINUX_MAP_PRIVATE, MAP_PRIVATE);
+ flags |= cvtto_bsd_mask(lmap.lm_flags, LINUX_MAP_FIXED, MAP_FIXED);
+ flags |= cvtto_bsd_mask(lmap.lm_flags, LINUX_MAP_ANON, MAP_ANON);
+
+ SCARG(&cma,addr) = lmap.lm_addr;
+ SCARG(&cma,len) = lmap.lm_len;
+ SCARG(&cma,prot) = lmap.lm_prot;
+ SCARG(&cma,flags) = flags;
+ SCARG(&cma,fd) = lmap.lm_fd;
+ SCARG(&cma,pad) = 0;
+ SCARG(&cma,pos) = lmap.lm_pos;
+
+ return sys_mmap(p, &cma, retval);
+}
+
+/*
+ * Linux doesn't use the retval[1] value to determine whether
+ * we are the child or parent.
+ */
+int
+linux_sys_fork(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ int error;
+
+ if ((error = sys_fork(p, v, retval)))
+ return error;
+
+ if (retval[1] == 1)
+ retval[0] = 0;
+
+ return 0;
+}
+
+/*
+ * This code is partly stolen from src/lib/libc/compat-43/times.c
+ * XXX - CLK_TCK isn't declared in /sys, just in <time.h>, done here
+ */
+
+#define CLK_TCK 100
+#define CONVTCK(r) (r.tv_sec * CLK_TCK + r.tv_usec / (1000000 / CLK_TCK))
+
+int
+linux_sys_times(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_times_args /* {
+ syscallarg(struct times *) tms;
+ } */ *uap = v;
+ struct timeval t;
+ struct linux_tms ltms;
+ struct rusage ru;
+ int error, s;
+
+ calcru(p, &ru.ru_utime, &ru.ru_stime, NULL);
+ ltms.ltms_utime = CONVTCK(ru.ru_utime);
+ ltms.ltms_stime = CONVTCK(ru.ru_stime);
+
+ ltms.ltms_cutime = CONVTCK(p->p_stats->p_cru.ru_utime);
+ ltms.ltms_cstime = CONVTCK(p->p_stats->p_cru.ru_stime);
+
+ if ((error = copyout(&ltms, SCARG(uap, tms), sizeof ltms)))
+ return error;
+
+ s = splclock();
+ timersub(&time, &boottime, &t);
+ splx(s);
+
+ retval[0] = ((linux_clock_t)(CONVTCK(t)));
+ return 0;
+}
+
+/*
+ * NetBSD passes fd[0] in retval[0], and fd[1] in retval[1].
+ * Linux directly passes the pointer.
+ */
+int
+linux_sys_pipe(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_pipe_args /* {
+ syscallarg(int *) pfds;
+ } */ *uap = v;
+ int error;
+
+ if ((error = sys_pipe(p, 0, retval)))
+ return error;
+
+ /* Assumes register_t is an int */
+
+ if ((error = copyout(retval, SCARG(uap, pfds), 2 * sizeof (int))))
+ return error;
+
+ retval[0] = 0;
+ return 0;
+}
+
+/*
+ * Alarm. This is a libc call which uses setitimer(2) in NetBSD.
+ * Fiddle with the timers to make it work.
+ */
+int
+linux_sys_alarm(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_alarm_args /* {
+ syscallarg(unsigned int) secs;
+ } */ *uap = v;
+ int error, s;
+ struct itimerval *itp, it;
+
+ itp = &p->p_realtimer;
+ s = splclock();
+ /*
+ * Clear any pending timer alarms.
+ */
+ untimeout(realitexpire, p);
+ timerclear(&itp->it_interval);
+ if (timerisset(&itp->it_value) &&
+ timercmp(&itp->it_value, &time, >))
+ timersub(&itp->it_value, &time, &itp->it_value);
+ /*
+ * Return how many seconds were left (rounded up)
+ */
+ retval[0] = itp->it_value.tv_sec;
+ if (itp->it_value.tv_usec)
+ retval[0]++;
+
+ /*
+ * alarm(0) just resets the timer.
+ */
+ if (SCARG(uap, secs) == 0) {
+ timerclear(&itp->it_value);
+ splx(s);
+ return 0;
+ }
+
+ /*
+ * Check the new alarm time for sanity, and set it.
+ */
+ timerclear(&it.it_interval);
+ it.it_value.tv_sec = SCARG(uap, secs);
+ it.it_value.tv_usec = 0;
+ if (itimerfix(&it.it_value) || itimerfix(&it.it_interval)) {
+ splx(s);
+ return (EINVAL);
+ }
+
+ if (timerisset(&it.it_value)) {
+ timeradd(&it.it_value, &time, &it.it_value);
+ timeout(realitexpire, p, hzto(&it.it_value));
+ }
+ p->p_realtimer = it;
+ splx(s);
+
+ return 0;
+}
+
+/*
+ * utime(). Do conversion to things that utimes() understands,
+ * and pass it on.
+ */
+int
+linux_sys_utime(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_utime_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct linux_utimbuf *)times;
+ } */ *uap = v;
+ caddr_t sg;
+ int error;
+ struct sys_utimes_args ua;
+ struct timeval tv[2], *tvp;
+ struct linux_utimbuf lut;
+
+ sg = stackgap_init(p->p_emul);
+ LINUX_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&ua, path) = SCARG(uap, path);
+
+ if (SCARG(uap, times) != NULL) {
+ if ((error = copyin(SCARG(uap, times), &lut, sizeof lut)))
+ return error;
+ tv[0].tv_usec = tv[1].tv_usec = 0;
+ tv[0].tv_sec = lut.l_actime;
+ tv[1].tv_sec = lut.l_modtime;
+ tvp = (struct timeval *) stackgap_alloc(&sg, sizeof(tv));
+ if ((error = copyout(tv, tvp, sizeof tv)))
+ return error;
+ SCARG(&ua, tptr) = tvp;
+ }
+ else
+ SCARG(&ua, tptr) = NULL;
+
+ return sys_utimes(p, uap, retval);
+}
+
+/*
+ * The old Linux readdir was only able to read one entry at a time,
+ * even though it had a 'count' argument. In fact, the emulation
+ * of the old call was better than the original, because it did handle
+ * the count arg properly. Don't bother with it anymore now, and use
+ * it to distinguish between old and new. The difference is that the
+ * newer one actually does multiple entries, and the reclen field
+ * really is the reclen, not the namelength.
+ */
+int
+linux_sys_readdir(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_readdir_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct linux_dirent *) dent;
+ syscallarg(unsigned int) count;
+ } */ *uap = v;
+
+ SCARG(uap, count) = 1;
+ return linux_sys_getdents(p, uap, retval);
+}
+
+/*
+ * Linux 'readdir' call. This code is mostly taken from the
+ * SunOS getdents call (see compat/sunos/sunos_misc.c), though
+ * an attempt has been made to keep it a little cleaner (failing
+ * miserably, because of the cruft needed if count 1 is passed).
+ *
+ * The d_off field should contain the offset of the next valid entry,
+ * but in Linux it has the offset of the entry itself. We emulate
+ * that bug here.
+ *
+ * Read in BSD-style entries, convert them, and copy them out.
+ *
+ * Note that this doesn't handle union-mounted filesystems.
+ */
+int
+linux_sys_getdents(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_readdir_args /* {
+ syscallarg(int) fd;
+ syscallarg(caddr_t) dent;
+ syscallarg(unsigned int) count;
+ } */ *uap = v;
+ register struct dirent *bdp;
+ struct vnode *vp;
+ caddr_t inp, buf; /* BSD-format */
+ int len, reclen; /* BSD-format */
+ caddr_t outp; /* Linux-format */
+ int resid, linux_reclen;/* Linux-format */
+ struct file *fp;
+ struct uio auio;
+ struct iovec aiov;
+ struct linux_dirent idb;
+ off_t off; /* true file offset */
+ int buflen, error, eofflag, nbytes, oldcall;
+ struct vattr va;
+ u_long *cookiebuf, *cookie;
+ int ncookies;
+
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ return (error);
+
+ if ((fp->f_flag & FREAD) == 0)
+ return (EBADF);
+
+ vp = (struct vnode *)fp->f_data;
+
+ if (vp->v_type != VDIR) /* XXX vnode readdir op should do this */
+ return (EINVAL);
+
+ if ((error = VOP_GETATTR(vp, &va, p->p_ucred, p)))
+ return error;
+
+ nbytes = SCARG(uap, count);
+ if (nbytes == 1) { /* emulating old, broken behaviour */
+ nbytes = sizeof (struct linux_dirent);
+ buflen = max(va.va_blocksize, nbytes);
+ oldcall = 1;
+ } else {
+ buflen = min(MAXBSIZE, nbytes);
+ oldcall = 0;
+ }
+ buf = malloc(buflen, M_TEMP, M_WAITOK);
+ ncookies = buflen / 16;
+ cookiebuf = malloc(ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK);
+ VOP_LOCK(vp);
+ off = fp->f_offset;
+again:
+ aiov.iov_base = buf;
+ aiov.iov_len = buflen;
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_rw = UIO_READ;
+ auio.uio_segflg = UIO_SYSSPACE;
+ auio.uio_procp = p;
+ auio.uio_resid = buflen;
+ auio.uio_offset = off;
+ /*
+ * First we read into the malloc'ed buffer, then
+ * we massage it into user space, one record at a time.
+ */
+ error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, cookiebuf,
+ ncookies);
+ if (error)
+ goto out;
+
+ inp = buf;
+ outp = SCARG(uap, dent);
+ resid = nbytes;
+ if ((len = buflen - auio.uio_resid) == 0)
+ goto eof;
+
+ for (cookie = cookiebuf; len > 0; len -= reclen) {
+ bdp = (struct dirent *)inp;
+ reclen = bdp->d_reclen;
+ if (reclen & 3)
+ panic("linux_readdir");
+ if (bdp->d_fileno == 0) {
+ inp += reclen; /* it is a hole; squish it out */
+ off = *cookie++;
+ continue;
+ }
+ linux_reclen = LINUX_RECLEN(&idb, bdp->d_namlen);
+ if (reclen > len || resid < linux_reclen) {
+ /* entry too big for buffer, so just stop */
+ outp++;
+ off = *cookie++;
+ break;
+ }
+ /*
+ * Massage in place to make a Linux-shaped dirent (otherwise
+ * we have to worry about touching user memory outside of
+ * the copyout() call).
+ */
+ idb.d_ino = (linux_ino_t)bdp->d_fileno;
+ /*
+ * The old readdir() call misuses the offset and reclen fields.
+ */
+ if (oldcall) {
+ idb.d_off = (linux_off_t)linux_reclen;
+ idb.d_reclen = (u_short)bdp->d_namlen;
+ } else {
+ idb.d_off = (linux_off_t)off;
+ idb.d_reclen = (u_short)linux_reclen;
+ }
+ strcpy(idb.d_name, bdp->d_name);
+ if ((error = copyout((caddr_t)&idb, outp, linux_reclen)))
+ goto out;
+ /* advance past this real entry */
+ inp += reclen;
+ off = *cookie++; /* each entry points to itself */
+ /* advance output past Linux-shaped entry */
+ outp += linux_reclen;
+ resid -= linux_reclen;
+ if (oldcall)
+ break;
+ }
+
+ /* if we squished out the whole block, try again */
+ if (outp == SCARG(uap, dent))
+ goto again;
+ fp->f_offset = off; /* update the vnode offset */
+
+ if (oldcall)
+ nbytes = resid + linux_reclen;
+
+eof:
+ *retval = nbytes - resid;
+out:
+ VOP_UNLOCK(vp);
+ free(cookiebuf, M_TEMP);
+ free(buf, M_TEMP);
+ return error;
+}
+
+/*
+ * Not sure why the arguments to this older version of select() were put
+ * into a structure, because there are 5, and that can all be handled
+ * in registers on the i386 like Linux wants to.
+ */
+int
+linux_sys_oldselect(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_oldselect_args /* {
+ syscallarg(struct linux_select *) lsp;
+ } */ *uap = v;
+ struct linux_select ls;
+ int error;
+
+ if ((error = copyin(SCARG(uap, lsp), &ls, sizeof(ls))))
+ return error;
+
+ return linux_select1(p, retval, ls.nfds, ls.readfds, ls.writefds,
+ ls.exceptfds, ls.timeout);
+}
+
+/*
+ * Even when just using registers to pass arguments to syscalls you can
+ * have 5 of them on the i386. So this newer version of select() does
+ * this.
+ */
+int
+linux_sys_select(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_select_args /* {
+ syscallarg(int) nfds;
+ syscallarg(fd_set *) readfds;
+ syscallarg(fd_set *) writefds;
+ syscallarg(fd_set *) exceptfds;
+ syscallarg(struct timeval *) timeout;
+ } */ *uap = v;
+
+ return linux_select1(p, retval, SCARG(uap, nfds), SCARG(uap, readfds),
+ SCARG(uap, writefds), SCARG(uap, exceptfds), SCARG(uap, timeout));
+}
+
+/*
+ * Common code for the old and new versions of select(). A couple of
+ * things are important:
+ * 1) return the amount of time left in the 'timeout' parameter
+ * 2) select never returns ERESTART on Linux, always return EINTR
+ */
+int
+linux_select1(p, retval, nfds, readfds, writefds, exceptfds, timeout)
+ struct proc *p;
+ register_t *retval;
+ int nfds;
+ fd_set *readfds, *writefds, *exceptfds;
+ struct timeval *timeout;
+{
+ struct sys_select_args bsa;
+ struct timeval tv0, tv1, utv, *tvp;
+ caddr_t sg;
+ int error;
+
+ SCARG(&bsa, nd) = nfds;
+ SCARG(&bsa, in) = readfds;
+ SCARG(&bsa, ou) = writefds;
+ SCARG(&bsa, ex) = exceptfds;
+ SCARG(&bsa, tv) = timeout;
+
+ /*
+ * Store current time for computation of the amount of
+ * time left.
+ */
+ if (timeout) {
+ if ((error = copyin(timeout, &utv, sizeof(utv))))
+ return error;
+ if (itimerfix(&utv)) {
+ /*
+ * The timeval was invalid. Convert it to something
+ * valid that will act as it does under Linux.
+ */
+ sg = stackgap_init(p->p_emul);
+ tvp = stackgap_alloc(&sg, sizeof(utv));
+ utv.tv_sec += utv.tv_usec / 1000000;
+ utv.tv_usec %= 1000000;
+ if (utv.tv_usec < 0) {
+ utv.tv_sec -= 1;
+ utv.tv_usec += 1000000;
+ }
+ if (utv.tv_sec < 0)
+ timerclear(&utv);
+ if ((error = copyout(&utv, tvp, sizeof(utv))))
+ return error;
+ SCARG(&bsa, tv) = tvp;
+ }
+ microtime(&tv0);
+ }
+
+ error = sys_select(p, &bsa, retval);
+ if (error) {
+ /*
+ * See fs/select.c in the Linux kernel. Without this,
+ * Maelstrom doesn't work.
+ */
+ if (error == ERESTART)
+ error = EINTR;
+ return error;
+ }
+
+ if (timeout) {
+ if (*retval) {
+ /*
+ * Compute how much time was left of the timeout,
+ * by subtracting the current time and the time
+ * before we started the call, and subtracting
+ * that result from the user-supplied value.
+ */
+ microtime(&tv1);
+ timersub(&tv1, &tv0, &tv1);
+ timersub(&utv, &tv1, &utv);
+ if (utv.tv_sec < 0)
+ timerclear(&utv);
+ } else
+ timerclear(&utv);
+ if ((error = copyout(&utv, timeout, sizeof(utv))))
+ return error;
+ }
+
+ return 0;
+}
+
+/*
+ * Get the process group of a certain process. Look it up
+ * and return the value.
+ */
+int
+linux_sys_getpgid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_getpgid_args /* {
+ syscallarg(int) pid;
+ } */ *uap = v;
+ struct proc *targp;
+
+ if (SCARG(uap, pid) != 0 && SCARG(uap, pid) != p->p_pid)
+ if ((targp = pfind(SCARG(uap, pid))) == 0)
+ return ESRCH;
+ else
+ targp = p;
+
+ retval[0] = targp->p_pgid;
+ return 0;
+}
+
+/*
+ * Set the 'personality' (emulation mode) for the current process. Only
+ * accept the Linux personality here (0). This call is needed because
+ * the Linux ELF crt0 issues it in an ugly kludge to make sure that
+ * ELF binaries run in Linux mode, not SVR4 mode.
+ */
+int
+linux_sys_personality(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_personality_args /* {
+ syscallarg(int) per;
+ } */ *uap = v;
+
+ if (SCARG(uap, per) != 0)
+ return EINVAL;
+ retval[0] = 0;
+ return 0;
+}
+
+/*
+ * The calls are here because of type conversions.
+ */
+int
+linux_sys_setreuid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_setreuid_args /* {
+ syscallarg(int) ruid;
+ syscallarg(int) euid;
+ } */ *uap = v;
+ struct compat_43_sys_setreuid_args bsa;
+
+ SCARG(&bsa, ruid) = ((linux_uid_t)SCARG(uap, ruid) == (linux_uid_t)-1) ?
+ (uid_t)-1 : SCARG(uap, ruid);
+ SCARG(&bsa, euid) = ((linux_uid_t)SCARG(uap, euid) == (linux_uid_t)-1) ?
+ (uid_t)-1 : SCARG(uap, euid);
+
+ return compat_43_sys_setreuid(p, &bsa, retval);
+}
+
+int
+linux_sys_setregid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_setregid_args /* {
+ syscallarg(int) rgid;
+ syscallarg(int) egid;
+ } */ *uap = v;
+ struct compat_43_sys_setregid_args bsa;
+
+ SCARG(&bsa, rgid) = ((linux_gid_t)SCARG(uap, rgid) == (linux_gid_t)-1) ?
+ (uid_t)-1 : SCARG(uap, rgid);
+ SCARG(&bsa, egid) = ((linux_gid_t)SCARG(uap, egid) == (linux_gid_t)-1) ?
+ (uid_t)-1 : SCARG(uap, egid);
+
+ return compat_43_sys_setregid(p, &bsa, retval);
+}
diff --git a/sys/compat/linux/linux_mmap.h b/sys/compat/linux/linux_mmap.h
new file mode 100644
index 00000000000..3b13dcc0c46
--- /dev/null
+++ b/sys/compat/linux/linux_mmap.h
@@ -0,0 +1,53 @@
+/* $NetBSD: linux_mmap.h,v 1.1 1995/02/28 23:25:52 fvdl Exp $ */
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_MMAP_H
+#define _LINUX_MMAP_H
+
+#define LINUX_PROT_NONE 0x00
+#define LINUX_PROT_READ 0x01
+#define LINUX_PROT_WRITE 0x02
+#define LINUX_PROT_EXEC 0x04
+
+#define LINUX_MAP_SHARED 0x0001
+#define LINUX_MAP_PRIVATE 0x0002
+
+#define LINUX_MAP_FIXED 0x0010
+#define LINUX_MAP_ANON 0x0020
+
+/* the following flags are silently ignored */
+
+#define LINUX_MAP_GROWSDOWN 0x0400
+#define LINUX_MAP_DENYWRITE 0x0800
+#define LINUX_MAP_EXECUTABLE 0x1000
+
+#endif /* !_LINUX_MMAP_H */
diff --git a/sys/compat/linux/linux_msg.h b/sys/compat/linux/linux_msg.h
new file mode 100644
index 00000000000..b7858236dbb
--- /dev/null
+++ b/sys/compat/linux/linux_msg.h
@@ -0,0 +1,93 @@
+/* $NetBSD: linux_msg.h,v 1.2 1995/08/15 21:14:34 fvdl Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_MSG_H
+#define _LINUX_MSG_H
+
+/*
+ * msq_id_ds structure. Mostly the same fields, except for some internal
+ * ones.
+ */
+struct linux_msqid_ds {
+ struct linux_ipc_perm l_msg_perm;
+ void *l_msg_first;
+ void *l_msg_last;
+ linux_time_t l_msg_stime;
+ linux_time_t l_msg_rtime;
+ linux_time_t l_msg_ctime;
+ void *l_wwait; /* Linux internal */
+ void *l_rwait; /* Linux internal */
+ ushort l_msg_cbytes;
+ ushort l_msg_qnum;
+ ushort l_msg_qbytes;
+ ushort l_msg_lspid;
+ ushort l_msg_lrpid;
+};
+
+#define LINUX_MSG_NOERROR 0x1000
+#define LINUX_MSG_EXCEPT 0x2000
+
+/*
+ * The notorious anonymous message structure.
+ */
+struct linux_mymsg {
+ long l_mtype;
+ char l_mtext[1];
+};
+
+/*
+ * This kludge is used for the 6th argument to the msgrcv system
+ * call, to get around the maximum of 5 arguments to a syscall in Linux.
+ */
+struct linux_msgrcv_msgarg {
+ struct linux_mymsg *msg;
+ int type;
+};
+/*
+ * For msgctl calls.
+ */
+struct linux_msginfo {
+ int l_msgpool;
+ int l_msgmap;
+ int l_msgmax;
+ int l_msgmnb;
+ int l_msgmni;
+ int l_msgssz;
+ int l_msgtql;
+ ushort l_msgseg;
+};
+
+#define LINUX_MSG_STAT 11
+#define LINUX_MSG_INFO 12
+
+#endif /* _LINUX_MSG_H */
diff --git a/sys/compat/linux/linux_sem.h b/sys/compat/linux/linux_sem.h
new file mode 100644
index 00000000000..8cfbdab7f9a
--- /dev/null
+++ b/sys/compat/linux/linux_sem.h
@@ -0,0 +1,72 @@
+/* $NetBSD: linux_sem.h,v 1.1 1995/08/15 21:14:35 fvdl Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_SEM_H
+#define _LINUX_SEM_H
+
+/*
+ * Operations for semctl(2), in addition to IPC_STAT and IPC_SET
+ */
+#define LINUX_GETPID 11
+#define LINUX_GETVAL 12
+#define LINUX_GETALL 13
+#define LINUX_GETNCNT 14
+#define LINUX_GETZCNT 15
+#define LINUX_SETVAL 16
+#define LINUX_SETALL 17
+
+/*
+ * Linux semid_ds structure. Internally used pointer fields are not
+ * important to us and have been changed to void *
+ */
+
+struct linux_semid_ds {
+ struct linux_ipc_perm l_sem_perm;
+ linux_time_t l_sem_otime;
+ linux_time_t l_sem_ctime;
+ void *l_sem_base;
+ void *l_eventn;
+ void *l_eventz;
+ void *l_undo;
+ ushort l_sem_nsems;
+};
+
+union linux_semun {
+ int l_val;
+ struct linux_semid_ds *l_buf;
+ ushort *l_array;
+ void *l___buf; /* For unsupported IPC_INFO */
+ void *l___pad;
+};
+
+#endif /* _LINUX_SEM_H */
diff --git a/sys/compat/linux/linux_shm.h b/sys/compat/linux/linux_shm.h
new file mode 100644
index 00000000000..098595062d1
--- /dev/null
+++ b/sys/compat/linux/linux_shm.h
@@ -0,0 +1,63 @@
+/* $NetBSD: linux_shm.h,v 1.1 1995/02/28 23:25:57 fvdl Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_SHM_H
+#define _LINUX_SHM_H
+
+/*
+ * shm segment control structure
+ */
+struct linux_shmid_ds {
+ struct linux_ipc_perm l_shm_perm;
+ int l_shm_segsz;
+ linux_time_t l_shm_atime;
+ linux_time_t l_shm_dtime;
+ linux_time_t l_shm_ctime;
+ ushort l_shm_cpid;
+ ushort l_shm_lpid;
+ short l_shm_nattch;
+ ushort l_private1;
+ void *l_private2;
+ void *l_private3;
+};
+
+#define LINUX_SHM_RDONLY 0x1000
+#define LINUX_SHM_RND 0x2000
+#define LINUX_SHM_REMAP 0x4000
+
+#define LINUX_SHM_LOCK 11
+#define LINUX_SHM_UNLOCK 12
+#define LINUX_SHM_STAT 13
+#define LINUX_SHM_INFO 14
+
+#endif /* _LINUX_SHM_H */
diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c
new file mode 100644
index 00000000000..212a0f254ee
--- /dev/null
+++ b/sys/compat/linux/linux_signal.c
@@ -0,0 +1,501 @@
+/* $NetBSD: linux_signal.c,v 1.9 1995/10/07 06:27:12 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ *
+ * heavily from: svr4_signal.c,v 1.7 1995/01/09 01:04:21 christos Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/kernel.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/malloc.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/linux/linux_types.h>
+#include <compat/linux/linux_signal.h>
+#include <compat/linux/linux_syscallargs.h>
+#include <compat/linux/linux_util.h>
+
+#define sigemptyset(s) bzero((s), sizeof(*(s)))
+#define sigismember(s, n) (*(s) & sigmask(n))
+#define sigaddset(s, n) (*(s) |= sigmask(n))
+
+#define linux_sigmask(n) (1 << ((n) - 1))
+#define linux_sigemptyset(s) bzero((s), sizeof(*(s)))
+#define linux_sigismember(s, n) (*(s) & linux_sigmask(n))
+#define linux_sigaddset(s, n) (*(s) |= linux_sigmask(n))
+
+int bsd_to_linux_sig[] = {
+ 0,
+ LINUX_SIGHUP,
+ LINUX_SIGINT,
+ LINUX_SIGQUIT,
+ LINUX_SIGILL,
+ LINUX_SIGTRAP,
+ LINUX_SIGABRT,
+ 0,
+ LINUX_SIGFPE,
+ LINUX_SIGKILL,
+ LINUX_SIGBUS,
+ LINUX_SIGSEGV,
+ 0,
+ LINUX_SIGPIPE,
+ LINUX_SIGALRM,
+ LINUX_SIGTERM,
+ LINUX_SIGURG,
+ LINUX_SIGSTOP,
+ LINUX_SIGTSTP,
+ LINUX_SIGCONT,
+ LINUX_SIGCHLD,
+ LINUX_SIGTTIN,
+ LINUX_SIGTTOU,
+ LINUX_SIGIO,
+ LINUX_SIGXCPU,
+ LINUX_SIGXFSZ,
+ LINUX_SIGVTALRM,
+ LINUX_SIGPROF,
+ LINUX_SIGWINCH,
+ 0,
+ LINUX_SIGUSR1,
+ LINUX_SIGUSR2,
+};
+
+int linux_to_bsd_sig[] = {
+ 0,
+ SIGHUP,
+ SIGINT,
+ SIGQUIT,
+ SIGILL,
+ SIGTRAP,
+ SIGABRT,
+ SIGBUS,
+ SIGFPE,
+ SIGKILL,
+ SIGUSR1,
+ SIGSEGV,
+ SIGUSR2,
+ SIGPIPE,
+ SIGALRM,
+ SIGTERM,
+ 0,
+ SIGCHLD,
+ SIGCONT,
+ SIGSTOP,
+ SIGTSTP,
+ SIGTTIN,
+ SIGTTOU,
+ SIGURG,
+ SIGXCPU,
+ SIGXFSZ,
+ SIGVTALRM,
+ SIGPROF,
+ SIGWINCH,
+ SIGIO,
+ 0,
+ 0,
+};
+
+/*
+ * Ok, we know that Linux and BSD signals both are just an unsigned int.
+ * Don't bother to use the sigismember() stuff for now.
+ */
+void
+linux_to_bsd_sigset(lss, bss)
+ const linux_sigset_t *lss;
+ sigset_t *bss;
+{
+ int i, newsig;
+
+ sigemptyset(bss);
+ for (i = 1; i < LINUX_NSIG; i++) {
+ if (linux_sigismember(lss, i)) {
+ newsig = linux_to_bsd_sig[i];
+ if (newsig)
+ sigaddset(bss, newsig);
+ }
+ }
+}
+
+void
+bsd_to_linux_sigset(bss, lss)
+ const sigset_t *bss;
+ linux_sigset_t *lss;
+{
+ int i, newsig;
+
+ linux_sigemptyset(lss);
+ for (i = 1; i < NSIG; i++) {
+ if (sigismember(bss, i)) {
+ newsig = bsd_to_linux_sig[i];
+ if (newsig)
+ linux_sigaddset(lss, newsig);
+ }
+ }
+}
+
+/*
+ * Convert between Linux and BSD sigaction structures. Linux has
+ * one extra field (sa_restorer) which we don't support.
+ */
+void
+linux_to_bsd_sigaction(lsa, bsa)
+ struct linux_sigaction *lsa;
+ struct sigaction *bsa;
+{
+
+ bsa->sa_handler = lsa->sa_handler;
+ linux_to_bsd_sigset(&bsa->sa_mask, &lsa->sa_mask);
+ bsa->sa_flags = 0;
+ if ((lsa->sa_flags & LINUX_SA_ONSTACK) != 0)
+ bsa->sa_flags |= SA_ONSTACK;
+ if ((lsa->sa_flags & LINUX_SA_RESTART) != 0)
+ bsa->sa_flags |= SA_RESTART;
+ if ((lsa->sa_flags & LINUX_SA_ONESHOT) != 0)
+ bsa->sa_flags |= SA_RESETHAND;
+ if ((lsa->sa_flags & LINUX_SA_NOCLDSTOP) != 0)
+ bsa->sa_flags |= SA_NOCLDSTOP;
+ if ((lsa->sa_flags & LINUX_SA_NOMASK) != 0)
+ bsa->sa_flags |= SA_NODEFER;
+}
+
+void
+bsd_to_linux_sigaction(bsa, lsa)
+ struct sigaction *bsa;
+ struct linux_sigaction *lsa;
+{
+
+ lsa->sa_handler = bsa->sa_handler;
+ bsd_to_linux_sigset(&lsa->sa_mask, &bsa->sa_mask);
+ lsa->sa_flags = 0;
+ if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
+ lsa->sa_flags |= LINUX_SA_NOCLDSTOP;
+ if ((bsa->sa_flags & SA_ONSTACK) != 0)
+ lsa->sa_flags |= LINUX_SA_ONSTACK;
+ if ((bsa->sa_flags & SA_RESTART) != 0)
+ lsa->sa_flags |= LINUX_SA_RESTART;
+ if ((bsa->sa_flags & SA_NODEFER) != 0)
+ lsa->sa_flags |= LINUX_SA_NOMASK;
+ if ((bsa->sa_flags & SA_RESETHAND) != 0)
+ lsa->sa_flags |= LINUX_SA_ONESHOT;
+ lsa->sa_restorer = NULL;
+}
+
+
+/*
+ * The Linux sigaction() system call. Do the usual conversions,
+ * and just call sigaction(). Some flags and values are silently
+ * ignored (see above).
+ */
+int
+linux_sys_sigaction(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_sigaction_args /* {
+ syscallarg(int) signum;
+ syscallarg(struct linux_sigaction *) nsa;
+ syscallarg(struct linux_sigaction *) osa;
+ } */ *uap = v;
+ struct linux_sigaction *nlsa, *olsa, tmplsa;
+ struct sigaction *nbsa, *obsa, tmpbsa;
+ struct sys_sigaction_args sa;
+ caddr_t sg;
+ int error;
+
+ sg = stackgap_init(p->p_emul);
+ nlsa = SCARG(uap, nsa);
+ olsa = SCARG(uap, osa);
+
+ if (olsa != NULL)
+ obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ else
+ obsa = NULL;
+
+ if (nlsa != NULL) {
+ nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ if ((error = copyin(nlsa, &tmplsa, sizeof(tmplsa))) != 0)
+ return error;
+ linux_to_bsd_sigaction(&tmplsa, &tmpbsa);
+ if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0)
+ return error;
+ } else
+ nbsa = NULL;
+
+ SCARG(&sa, signum) = linux_to_bsd_sig[SCARG(uap, signum)];
+ SCARG(&sa, nsa) = nbsa;
+ SCARG(&sa, osa) = obsa;
+
+ if ((error = sys_sigaction(p, &sa, retval)) != 0)
+ return error;
+
+ if (olsa != NULL) {
+ if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0)
+ return error;
+ bsd_to_linux_sigaction(&tmpbsa, &tmplsa);
+ if ((error = copyout(&tmplsa, olsa, sizeof(tmplsa))) != 0)
+ return error;
+ }
+
+ return 0;
+}
+
+/*
+ * The Linux signal() system call. I think that the signal() in the C
+ * library actually calls sigaction, so I doubt this one is ever used.
+ * But hey, it can't hurt having it here. The same restrictions as for
+ * sigaction() apply.
+ */
+int
+linux_sys_signal(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_signal_args /* {
+ syscallarg(int) sig;
+ syscallarg(linux_handler_t) handler;
+ } */ *uap = v;
+ caddr_t sg;
+ struct sys_sigaction_args sa_args;
+ struct sigaction *osa, *nsa, tmpsa;
+ int error;
+
+ sg = stackgap_init(p->p_emul);
+ nsa = stackgap_alloc(&sg, sizeof *nsa);
+ osa = stackgap_alloc(&sg, sizeof *osa);
+
+ tmpsa.sa_handler = SCARG(uap, handler);
+ tmpsa.sa_mask = (sigset_t) 0;
+ tmpsa.sa_flags = SA_RESETHAND | SA_NODEFER;
+ if ((error = copyout(&tmpsa, nsa, sizeof tmpsa)))
+ return error;
+
+ SCARG(&sa_args, signum) = linux_to_bsd_sig[SCARG(uap, sig)];
+ SCARG(&sa_args, osa) = osa;
+ SCARG(&sa_args, nsa) = nsa;
+ if ((error = sys_sigaction(p, &sa_args, retval)))
+ return error;
+
+ if ((error = copyin(osa, &tmpsa, sizeof *osa)))
+ return error;
+ retval[0] = (register_t) tmpsa.sa_handler;
+
+ return 0;
+}
+
+/*
+ * This is just a copy of the svr4 compat one. I feel so creative now.
+ */
+int
+linux_sys_sigprocmask(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_sigprocmask_args /* {
+ syscallarg(int) how;
+ syscallarg(linux_sigset_t *) set;
+ syscallarg(linux_sigset_t *) oset;
+ } */ *uap = v;
+ linux_sigset_t ss;
+ sigset_t bs;
+ int error = 0;
+
+ *retval = 0;
+
+ if (SCARG(uap, oset) != NULL) {
+ /* Fix the return value first if needed */
+ bsd_to_linux_sigset(&p->p_sigmask, &ss);
+ if ((error = copyout(&ss, SCARG(uap, oset), sizeof(ss))) != 0)
+ return error;
+ }
+
+ if (SCARG(uap, set) == NULL)
+ /* Just examine */
+ return 0;
+
+ if ((error = copyin(SCARG(uap, set), &ss, sizeof(ss))) != 0)
+ return error;
+
+ linux_to_bsd_sigset(&ss, &bs);
+
+ (void) splhigh();
+
+ switch (SCARG(uap, how)) {
+ case LINUX_SIG_BLOCK:
+ p->p_sigmask |= bs & ~sigcantmask;
+ break;
+
+ case LINUX_SIG_UNBLOCK:
+ p->p_sigmask &= ~bs;
+ break;
+
+ case LINUX_SIG_SETMASK:
+ p->p_sigmask = bs & ~sigcantmask;
+ break;
+
+ default:
+ error = EINVAL;
+ break;
+ }
+
+ (void) spl0();
+
+ return error;
+}
+
+/*
+ * The functions below really make no distinction between an int
+ * and [linux_]sigset_t. This is ok for now, but it might break
+ * sometime. Then again, sigset_t is trusted to be an int everywhere
+ * else in the kernel too.
+ */
+/* ARGSUSED */
+int
+linux_sys_siggetmask(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+
+ bsd_to_linux_sigset(&p->p_sigmask, (linux_sigset_t *)retval);
+ return 0;
+}
+
+/*
+ * The following three functions fiddle with a process' signal mask.
+ * Convert the signal masks because of the different signal
+ * values for Linux. The need for this is the reason why
+ * they are here, and have not been mapped directly.
+ */
+int
+linux_sys_sigsetmask(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_sigsetmask_args /* {
+ syscallarg(linux_sigset_t) mask;
+ } */ *uap = v;
+ linux_sigset_t mask;
+ sigset_t bsdsig;
+
+ bsd_to_linux_sigset(&p->p_sigmask, (linux_sigset_t *)retval);
+
+ mask = SCARG(uap, mask);
+ bsd_to_linux_sigset(&mask, &bsdsig);
+
+ splhigh();
+ p->p_sigmask = bsdsig & ~sigcantmask;
+ spl0();
+
+ return 0;
+}
+
+int
+linux_sys_sigpending(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_sigpending_args /* {
+ syscallarg(linux_sigset_t *) mask;
+ } */ *uap = v;
+ sigset_t bs;
+ linux_sigset_t ls;
+
+ bs = p->p_siglist & p->p_sigmask;
+ bsd_to_linux_sigset(&bs, &ls);
+
+ return copyout(&ls, SCARG(uap, mask), sizeof(ls));
+}
+
+int
+linux_sys_sigsuspend(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_sigsuspend_args /* {
+ syscallarg(caddr_t) restart;
+ syscallarg(int) oldmask;
+ syscallarg(int) mask;
+ } */ *uap = v;
+ struct sys_sigsuspend_args sa;
+
+ linux_to_bsd_sigset(&SCARG(uap, mask), &SCARG(&sa, mask));
+ return sys_sigsuspend(p, &sa, retval);
+}
+
+/*
+ * The deprecated pause(2), which is really just an instance
+ * of sigsuspend(2).
+ */
+int
+linux_sys_pause(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sys_sigsuspend_args bsa;
+
+ SCARG(&bsa, mask) = p->p_sigmask;
+ return sys_sigsuspend(p, &bsa, retval);
+}
+
+/*
+ * Once more: only a signal conversion is needed.
+ */
+int
+linux_sys_kill(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_kill_args /* {
+ syscallarg(int) pid;
+ syscallarg(int) signum;
+ } */ *uap = v;
+ struct sys_kill_args ka;
+
+ SCARG(&ka, pid) = SCARG(uap, pid);
+ SCARG(&ka, signum) = linux_to_bsd_sig[SCARG(uap, signum)];
+ return sys_kill(p, &ka, retval);
+}
diff --git a/sys/compat/linux/linux_signal.h b/sys/compat/linux/linux_signal.h
new file mode 100644
index 00000000000..e002dbf7c3d
--- /dev/null
+++ b/sys/compat/linux/linux_signal.h
@@ -0,0 +1,95 @@
+/* $NetBSD: linux_signal.h,v 1.4 1995/08/27 20:51:51 fvdl Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_SIGNAL_H
+#define _LINUX_SIGNAL_H
+
+#define LINUX_SIGHUP 1
+#define LINUX_SIGINT 2
+#define LINUX_SIGQUIT 3
+#define LINUX_SIGILL 4
+#define LINUX_SIGTRAP 5
+#define LINUX_SIGABRT 6
+#define LINUX_SIGIOT 6
+#define LINUX_SIGBUS 7
+#define LINUX_SIGFPE 8
+#define LINUX_SIGKILL 9
+#define LINUX_SIGUSR1 10
+#define LINUX_SIGSEGV 11
+#define LINUX_SIGUSR2 12
+#define LINUX_SIGPIPE 13
+#define LINUX_SIGALRM 14
+#define LINUX_SIGTERM 15
+#define LINUX_SIGSTKFLT 16
+#define LINUX_SIGCHLD 17
+#define LINUX_SIGCONT 18
+#define LINUX_SIGSTOP 19
+#define LINUX_SIGTSTP 20
+#define LINUX_SIGTTIN 21
+#define LINUX_SIGTTOU 22
+#define LINUX_SIGURG 23
+#define LINUX_SIGXCPU 24
+#define LINUX_SIGXFSZ 25
+#define LINUX_SIGVTALRM 26
+#define LINUX_SIGPROF 27
+#define LINUX_SIGWINCH 28
+#define LINUX_SIGIO 29
+#define LINUX_SIGPWR 30
+#define LINUX_NSIG 32
+
+#define LINUX_SIG_BLOCK 0
+#define LINUX_SIG_UNBLOCK 1
+#define LINUX_SIG_SETMASK 2
+
+typedef u_long linux_sigset_t;
+typedef void (*linux_handler_t) __P((int));
+
+struct linux_sigaction {
+ linux_handler_t sa_handler;
+ linux_sigset_t sa_mask;
+ u_long sa_flags;
+ void (*sa_restorer) __P((void));
+};
+
+/* sa_flags */
+#define LINUX_SA_NOCLDSTOP 0x00000001
+#define LINUX_SA_ONSTACK 0x08000000
+#define LINUX_SA_RESTART 0x10000000
+#define LINUX_SA_INTERRUPT 0x20000000
+#define LINUX_SA_NOMASK 0x40000000
+#define LINUX_SA_ONESHOT 0x80000000
+
+extern int bsd_to_linux_sig[];
+extern int linux_to_bsd_sig[];
+
+#endif /* !_LINUX_SIGNAL_H */
diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c
new file mode 100644
index 00000000000..664a246f99e
--- /dev/null
+++ b/sys/compat/linux/linux_socket.c
@@ -0,0 +1,704 @@
+/* $NetBSD: linux_socket.c,v 1.12 1995/10/07 06:27:13 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/buf.h>
+#include <sys/malloc.h>
+#include <sys/ioctl.h>
+#include <sys/tty.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/mount.h>
+#include <sys/proc.h>
+#include <sys/vnode.h>
+#include <sys/device.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/linux/linux_types.h>
+#include <compat/linux/linux_util.h>
+#include <compat/linux/linux_signal.h>
+#include <compat/linux/linux_syscallargs.h>
+#include <compat/linux/linux_ioctl.h>
+#include <compat/linux/linux_socket.h>
+#include <compat/linux/linux_socketcall.h>
+#include <compat/linux/linux_sockio.h>
+
+/*
+ * All the calls in this file are entered via one common system
+ * call in Linux, represented here by linux_socketcall()
+ * Arguments for the various calls are on the user stack. A pointer
+ * to them is the only thing that is passed. It is up to the various
+ * calls to copy them in themselves. To make it look better, they
+ * are copied to structures.
+ */
+
+/*
+ * Convert between Linux and BSD socket domain values
+ */
+int
+linux_to_bsd_domain(ldom)
+ int ldom;
+{
+
+ switch (ldom) {
+ case LINUX_AF_UNSPEC:
+ return AF_UNSPEC;
+ case LINUX_AF_UNIX:
+ return AF_LOCAL;
+ case LINUX_AF_INET:
+ return AF_INET;
+ case LINUX_AF_AX25:
+ return AF_CCITT;
+ case LINUX_AF_IPX:
+ return AF_IPX;
+ case LINUX_AF_APPLETALK:
+ return AF_APPLETALK;
+ default:
+ return -1;
+ }
+}
+
+int
+linux_socket(p, uap, retval)
+ struct proc *p;
+ struct linux_socket_args /* {
+ syscallarg(int) domain;
+ syscallarg(int) type;
+ syscallarg(int) protocol;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_socket_args lsa;
+ struct sys_socket_args bsa;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lsa, sizeof lsa)))
+ return error;
+
+ SCARG(&bsa, protocol) = lsa.protocol;
+ SCARG(&bsa, type) = lsa.type;
+ SCARG(&bsa, domain) = linux_to_bsd_domain(lsa.domain);
+ if (SCARG(&bsa, domain) == -1)
+ return EINVAL;
+ return sys_socket(p, &bsa, retval);
+}
+
+int
+linux_bind(p, uap, retval)
+ struct proc *p;
+ struct linux_bind_args /* {
+ syscallarg(int) s;
+ syscallarg(struct sockaddr *) name;
+ syscallarg(int) namelen;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_bind_args lba;
+ struct sys_bind_args bba;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lba, sizeof lba)))
+ return error;
+
+ SCARG(&bba, s) = lba.s;
+ SCARG(&bba, name) = (caddr_t) lba.name;
+ SCARG(&bba, namelen) = lba.namelen;
+
+ return sys_bind(p, &bba, retval);
+}
+
+int
+linux_connect(p, uap, retval)
+ struct proc *p;
+ struct linux_connect_args /* {
+ syscallarg(int) s;
+ syscallarg(struct sockaddr *) name;
+ syscallarg(int) namelen;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_connect_args lca;
+ struct sys_connect_args bca;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lca, sizeof lca)))
+ return error;
+
+ SCARG(&bca, s) = lca.s;
+ SCARG(&bca, name) = (caddr_t) lca.name;
+ SCARG(&bca, namelen) = lca.namelen;
+
+ return sys_connect(p, &bca, retval);
+}
+
+int
+linux_listen(p, uap, retval)
+ struct proc *p;
+ struct linux_listen_args /* {
+ syscallarg(int) s;
+ syscallarg(int) backlog;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_listen_args lla;
+ struct sys_listen_args bla;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lla, sizeof lla)))
+ return error;
+
+ SCARG(&bla, s) = lla.s;
+ SCARG(&bla, backlog) = lla.backlog;
+
+ return sys_listen(p, &bla, retval);
+}
+
+int
+linux_accept(p, uap, retval)
+ struct proc *p;
+ struct linux_accept_args /* {
+ syscallarg(int) s;
+ syscallarg(struct sockaddr *) addr;
+ syscallarg(int *) namelen;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_accept_args laa;
+ struct compat_43_sys_accept_args baa;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &laa, sizeof laa)))
+ return error;
+
+ SCARG(&baa, s) = laa.s;
+ SCARG(&baa, name) = (caddr_t) laa.addr;
+ SCARG(&baa, anamelen) = laa.namelen;
+
+ return compat_43_sys_accept(p, &baa, retval);
+}
+
+int
+linux_getsockname(p, uap, retval)
+ struct proc *p;
+ struct linux_getsockname_args /* {
+ syscallarg(int) s;
+ syscallarg(struct sockaddr *) addr;
+ syscallarg(int *) namelen;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_getsockname_args lga;
+ struct compat_43_sys_getsockname_args bga;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lga, sizeof lga)))
+ return error;
+
+ SCARG(&bga, fdec) = lga.s;
+ SCARG(&bga, asa) = (caddr_t) lga.addr;
+ SCARG(&bga, alen) = lga.namelen;
+
+ return compat_43_sys_getsockname(p, &bga, retval);
+}
+
+int
+linux_getpeername(p, uap, retval)
+ struct proc *p;
+ struct linux_getpeername_args /* {
+ syscallarg(int) s;
+ syscallarg(struct sockaddr *) addr;
+ syscallarg(int *) namelen;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_getpeername_args lga;
+ struct compat_43_sys_getpeername_args bga;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lga, sizeof lga)))
+ return error;
+
+ SCARG(&bga, fdes) = lga.s;
+ SCARG(&bga, asa) = (caddr_t) lga.addr;
+ SCARG(&bga, alen) = lga.namelen;
+
+ return compat_43_sys_getpeername(p, &bga, retval);
+}
+
+int
+linux_socketpair(p, uap, retval)
+ struct proc *p;
+ struct linux_socketpair_args /* {
+ syscallarg(int) domain;
+ syscallarg(int) type;
+ syscallarg(int) protocol;
+ syscallarg(int *) rsv;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_socketpair_args lsa;
+ struct sys_socketpair_args bsa;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, &lsa, sizeof lsa)))
+ return error;
+
+ SCARG(&bsa, domain) = linux_to_bsd_domain(lsa.domain);
+ if (SCARG(&bsa, domain) == -1)
+ return EINVAL;
+ SCARG(&bsa, type) = lsa.type;
+ SCARG(&bsa, protocol) = lsa.protocol;
+ SCARG(&bsa, rsv) = lsa.rsv;
+
+ return sys_socketpair(p, &bsa, retval);
+}
+
+int
+linux_send(p, uap, retval)
+ struct proc *p;
+ struct linux_send_args /* {
+ syscallarg(int) s;
+ syscallarg(void *) msg;
+ syscallarg(int) len;
+ syscallarg(int) flags;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_send_args lsa;
+ struct compat_43_sys_send_args bsa;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lsa, sizeof lsa)))
+ return error;
+
+ SCARG(&bsa, s) = lsa.s;
+ SCARG(&bsa, buf) = lsa.msg;
+ SCARG(&bsa, len) = lsa.len;
+ SCARG(&bsa, flags) = lsa.flags;
+
+ return compat_43_sys_send(p, &bsa, retval);
+}
+
+int
+linux_recv(p, uap, retval)
+ struct proc *p;
+ struct linux_recv_args /* {
+ syscallarg(int) s;
+ syscallarg(void *) msg;
+ syscallarg(int) len;
+ syscallarg(int) flags;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_recv_args lra;
+ struct compat_43_sys_recv_args bra;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lra, sizeof lra)))
+ return error;
+
+ SCARG(&bra, s) = lra.s;
+ SCARG(&bra, buf) = lra.msg;
+ SCARG(&bra, len) = lra.len;
+ SCARG(&bra, flags) = lra.flags;
+
+ return compat_43_sys_recv(p, &bra, retval);
+}
+
+int
+linux_sendto(p, uap, retval)
+ struct proc *p;
+ struct linux_sendto_args /* {
+ syscallarg(int) s;
+ syscallarg(void *) msg;
+ syscallarg(int) len;
+ syscallarg(int) flags;
+ syscallarg(sockaddr *) to;
+ syscallarg(int) tolen;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_sendto_args lsa;
+ struct sys_sendto_args bsa;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lsa, sizeof lsa)))
+ return error;
+
+ SCARG(&bsa, s) = lsa.s;
+ SCARG(&bsa, buf) = lsa.msg;
+ SCARG(&bsa, len) = lsa.len;
+ SCARG(&bsa, flags) = lsa.flags;
+ SCARG(&bsa, to) = (caddr_t) lsa.to;
+ SCARG(&bsa, tolen) = lsa.tolen;
+
+ return sys_sendto(p, &bsa, retval);
+}
+
+int
+linux_recvfrom(p, uap, retval)
+ struct proc *p;
+ struct linux_recvfrom_args /* {
+ syscallarg(int) s;
+ syscallarg(void *) buf;
+ syscallarg(int) len;
+ syscallarg(int) flags;
+ syscallarg(struct sockaddr *) from;
+ syscallarg(int *) fromlen;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_recvfrom_args lra;
+ struct compat_43_sys_recvfrom_args bra;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lra, sizeof lra)))
+ return error;
+
+ SCARG(&bra, s) = lra.s;
+ SCARG(&bra, buf) = lra.buf;
+ SCARG(&bra, len) = lra.len;
+ SCARG(&bra, flags) = lra.flags;
+ SCARG(&bra, from) = (caddr_t) lra.from;
+ SCARG(&bra, fromlenaddr) = lra.fromlen;
+
+ return compat_43_sys_recvfrom(p, &bra, retval);
+}
+
+int
+linux_shutdown(p, uap, retval)
+ struct proc *p;
+ struct linux_shutdown_args /* {
+ syscallarg(int) s;
+ syscallarg(int) how;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_shutdown_args lsa;
+ struct sys_shutdown_args bsa;
+ int error;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lsa, sizeof lsa)))
+ return error;
+
+ SCARG(&bsa, s) = lsa.s;
+ SCARG(&bsa, how) = lsa.how;
+
+ return sys_shutdown(p, &bsa, retval);
+}
+
+/*
+ * Convert socket option level from Linux to NetBSD value. Only SOL_SOCKET
+ * is different, the rest matches IPPROTO_* on both systems.
+ */
+int
+linux_to_bsd_sopt_level(llevel)
+ int llevel;
+{
+
+ switch (llevel) {
+ case LINUX_SOL_SOCKET:
+ return SOL_SOCKET;
+ case LINUX_SOL_IP:
+ return IPPROTO_IP;
+ case LINUX_SOL_TCP:
+ return IPPROTO_TCP;
+ case LINUX_SOL_UDP:
+ return IPPROTO_UDP;
+ default:
+ return -1;
+ }
+}
+
+/*
+ * Convert Linux socket level socket option numbers to NetBSD values.
+ */
+int
+linux_to_bsd_so_sockopt(lopt)
+ int lopt;
+{
+
+ switch (lopt) {
+ case LINUX_SO_DEBUG:
+ return SO_DEBUG;
+ case LINUX_SO_REUSEADDR:
+ return SO_REUSEADDR;
+ case LINUX_SO_TYPE:
+ return SO_TYPE;
+ case LINUX_SO_ERROR:
+ return SO_ERROR;
+ case LINUX_SO_DONTROUTE:
+ return SO_DONTROUTE;
+ case LINUX_SO_BROADCAST:
+ return SO_BROADCAST;
+ case LINUX_SO_SNDBUF:
+ return SO_SNDBUF;
+ case LINUX_SO_RCVBUF:
+ return SO_RCVBUF;
+ case LINUX_SO_KEEPALIVE:
+ return SO_KEEPALIVE;
+ case LINUX_SO_OOBINLINE:
+ return SO_OOBINLINE;
+ case LINUX_SO_LINGER:
+ return SO_LINGER;
+ case LINUX_SO_PRIORITY:
+ case LINUX_SO_NO_CHECK:
+ default:
+ return -1;
+ }
+}
+
+/*
+ * Convert Linux IP level socket option number to NetBSD values.
+ */
+int
+linux_to_bsd_ip_sockopt(lopt)
+ int lopt;
+{
+
+ switch (lopt) {
+ case LINUX_IP_TOS:
+ return IP_TOS;
+ case LINUX_IP_TTL:
+ return IP_TTL;
+ case LINUX_IP_MULTICAST_TTL:
+ return IP_MULTICAST_TTL;
+ case LINUX_IP_MULTICAST_LOOP:
+ return IP_MULTICAST_LOOP;
+ case LINUX_IP_MULTICAST_IF:
+ return IP_MULTICAST_IF;
+ case LINUX_IP_ADD_MEMBERSHIP:
+ return IP_ADD_MEMBERSHIP;
+ case LINUX_IP_DROP_MEMBERSHIP:
+ return IP_DROP_MEMBERSHIP;
+ default:
+ return -1;
+ }
+}
+
+/*
+ * Convert Linux TCP level socket option number to NetBSD values.
+ */
+int
+linux_to_bsd_tcp_sockopt(lopt)
+ int lopt;
+{
+
+ switch (lopt) {
+ case LINUX_TCP_NODELAY:
+ return TCP_NODELAY;
+ case LINUX_TCP_MAXSEG:
+ return TCP_MAXSEG;
+ default:
+ return -1;
+ }
+}
+
+/*
+ * Convert Linux UDP level socket option number to NetBSD values.
+ */
+int
+linux_to_bsd_udp_sockopt(lopt)
+ int lopt;
+{
+
+ switch (lopt) {
+ default:
+ return -1;
+ }
+}
+
+/*
+ * Another reasonably straightforward function: setsockopt(2).
+ * The level and option numbers are converted; the values passed
+ * are not (yet) converted, the ones currently implemented don't
+ * need conversion, as they are the same on both systems.
+ */
+int
+linux_setsockopt(p, uap, retval)
+ struct proc *p;
+ struct linux_setsockopt_args /* {
+ syscallarg(int) s;
+ syscallarg(int) level;
+ syscallarg(int) optname;
+ syscallarg(void *) optval;
+ syscallarg(int) optlen;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_setsockopt_args lsa;
+ struct sys_setsockopt_args bsa;
+ int error, name;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lsa, sizeof lsa)))
+ return error;
+
+ SCARG(&bsa, s) = lsa.s;
+ SCARG(&bsa, level) = linux_to_bsd_sopt_level(lsa.level);
+ SCARG(&bsa, val) = lsa.optval;
+ SCARG(&bsa, valsize) = lsa.optlen;
+
+ switch (SCARG(&bsa, level)) {
+ case SOL_SOCKET:
+ name = linux_to_bsd_so_sockopt(lsa.optname);
+ break;
+ case IPPROTO_IP:
+ name = linux_to_bsd_ip_sockopt(lsa.optname);
+ break;
+ case IPPROTO_TCP:
+ name = linux_to_bsd_tcp_sockopt(lsa.optname);
+ break;
+ case IPPROTO_UDP:
+ name = linux_to_bsd_udp_sockopt(lsa.optname);
+ break;
+ default:
+ return EINVAL;
+ }
+
+ if (name == -1)
+ return EINVAL;
+ SCARG(&bsa, name) = name;
+
+ return sys_setsockopt(p, &bsa, retval);
+}
+
+/*
+ * getsockopt(2) is very much the same as setsockopt(2) (see above)
+ */
+int
+linux_getsockopt(p, uap, retval)
+ struct proc *p;
+ struct linux_getsockopt_args /* {
+ syscallarg(int) s;
+ syscallarg(int) level;
+ syscallarg(int) optname;
+ syscallarg(void *) optval;
+ syscallarg(int) *optlen;
+ } */ *uap;
+ register_t *retval;
+{
+ struct linux_getsockopt_args lga;
+ struct sys_getsockopt_args bga;
+ int error, name;
+
+ if ((error = copyin((caddr_t) uap, (caddr_t) &lga, sizeof lga)))
+ return error;
+
+ SCARG(&bga, s) = lga.s;
+ SCARG(&bga, level) = linux_to_bsd_sopt_level(lga.level);
+ SCARG(&bga, val) = lga.optval;
+ SCARG(&bga, avalsize) = lga.optlen;
+
+ switch (SCARG(&bga, level)) {
+ case SOL_SOCKET:
+ name = linux_to_bsd_so_sockopt(lga.optname);
+ break;
+ case IPPROTO_IP:
+ name = linux_to_bsd_ip_sockopt(lga.optname);
+ break;
+ case IPPROTO_TCP:
+ name = linux_to_bsd_tcp_sockopt(lga.optname);
+ break;
+ case IPPROTO_UDP:
+ name = linux_to_bsd_udp_sockopt(lga.optname);
+ break;
+ default:
+ return EINVAL;
+ }
+
+ if (name == -1)
+ return EINVAL;
+ SCARG(&bga, name) = name;
+
+ return sys_getsockopt(p, &bga, retval);
+}
+
+/*
+ * Entry point to all Linux socket calls. Just check which call to
+ * make and take appropriate action.
+ */
+int
+linux_sys_socketcall(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct linux_sys_socketcall_args /* {
+ syscallarg(int) what;
+ syscallarg(void *) args;
+ } */ *uap = v;
+
+ switch (SCARG(uap, what)) {
+ case LINUX_SYS_socket:
+ return linux_socket(p, SCARG(uap, args), retval);
+ case LINUX_SYS_bind:
+ return linux_bind(p, SCARG(uap, args), retval);
+ case LINUX_SYS_connect:
+ return linux_connect(p, SCARG(uap, args), retval);
+ case LINUX_SYS_listen:
+ return linux_listen(p, SCARG(uap, args), retval);
+ case LINUX_SYS_accept:
+ return linux_accept(p, SCARG(uap, args), retval);
+ case LINUX_SYS_getsockname:
+ return linux_getsockname(p, SCARG(uap, args), retval);
+ case LINUX_SYS_getpeername:
+ return linux_getpeername(p, SCARG(uap, args), retval);
+ case LINUX_SYS_socketpair:
+ return linux_socketpair(p, SCARG(uap, args), retval);
+ case LINUX_SYS_send:
+ return linux_send(p, SCARG(uap, args), retval);
+ case LINUX_SYS_recv:
+ return linux_recv(p, SCARG(uap, args), retval);
+ case LINUX_SYS_sendto:
+ return linux_sendto(p, SCARG(uap, args), retval);
+ case LINUX_SYS_recvfrom:
+ return linux_recvfrom(p, SCARG(uap, args), retval);
+ case LINUX_SYS_shutdown:
+ return linux_shutdown(p, SCARG(uap, args), retval);
+ case LINUX_SYS_setsockopt:
+ return linux_setsockopt(p, SCARG(uap, args), retval);
+ case LINUX_SYS_getsockopt:
+ return linux_getsockopt(p, SCARG(uap, args), retval);
+ default:
+ return ENOSYS;
+ }
+}
diff --git a/sys/compat/linux/linux_socket.h b/sys/compat/linux/linux_socket.h
new file mode 100644
index 00000000000..a0da285cfa2
--- /dev/null
+++ b/sys/compat/linux/linux_socket.h
@@ -0,0 +1,107 @@
+/* $NetBSD: linux_socket.h,v 1.3 1995/05/28 10:16:34 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_SOCKET_H
+#define _LINUX_SOCKET_H
+
+/*
+ * Various Linux socket defines. Everything that is not re-defined here
+ * is the same as in NetBSD.
+ *
+ * COMPAT_43 is assumed, and the osockaddr struct is used (it is what
+ * Linux uses)
+ */
+
+/*
+ * Address families. There are fewer of them, and they're numbered
+ * a bit different
+ */
+
+#define LINUX_AF_UNSPEC 0
+#define LINUX_AF_UNIX 1
+#define LINUX_AF_INET 2
+#define LINUX_AF_AX25 3
+#define LINUX_AF_IPX 4
+#define LINUX_AF_APPLETALK 5
+
+/*
+ * Option levels for [gs]etsockopt(2). Only SOL_SOCKET is different,
+ * the rest matches IPPROTO_XXX
+ */
+
+#define LINUX_SOL_SOCKET 1
+#define LINUX_SOL_IP 0
+#define LINUX_SOL_IPX 256
+#define LINUX_SOL_AX25 257
+#define LINUX_SOL_TCP 6
+#define LINUX_SOL_UDP 17
+
+/*
+ * Options for [gs]etsockopt(2), socket level. For Linux, they
+ * are not masks, but just increasing numbers.
+ */
+
+#define LINUX_SO_DEBUG 1
+#define LINUX_SO_REUSEADDR 2
+#define LINUX_SO_TYPE 3
+#define LINUX_SO_ERROR 4
+#define LINUX_SO_DONTROUTE 5
+#define LINUX_SO_BROADCAST 6
+#define LINUX_SO_SNDBUF 7
+#define LINUX_SO_RCVBUF 8
+#define LINUX_SO_KEEPALIVE 9
+#define LINUX_SO_OOBINLINE 10
+#define LINUX_SO_NO_CHECK 11
+#define LINUX_SO_PRIORITY 12
+#define LINUX_SO_LINGER 13
+
+/*
+ * Options vor [gs]etsockopt(2), IP level.
+ */
+
+#define LINUX_IP_TOS 1
+#define LINUX_IP_TTL 2
+#define LINUX_IP_MULTICAST_IF 32
+#define LINUX_IP_MULTICAST_TTL 33
+#define LINUX_IP_MULTICAST_LOOP 34
+#define LINUX_IP_ADD_MEMBERSHIP 35
+#define LINUX_IP_DROP_MEMBERSHIP 36
+
+/*
+ * Options vor [gs]etsockopt(2), TCP level.
+ */
+
+#define LINUX_TCP_NODELAY 1
+#define LINUX_TCP_MAXSEG 2
+
+#endif /* _LINUX_SOCKET_H */
diff --git a/sys/compat/linux/linux_socketcall.h b/sys/compat/linux/linux_socketcall.h
new file mode 100644
index 00000000000..60b1156f2bc
--- /dev/null
+++ b/sys/compat/linux/linux_socketcall.h
@@ -0,0 +1,162 @@
+/* $NetBSD: linux_socketcall.h,v 1.1 1995/02/28 23:26:05 fvdl Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_SOCKETCALL_H
+#define _LINUX_SOCKETCALL_H
+
+/*
+ * Values passed to the Linux socketcall() syscall, determining the actual
+ * action to take.
+ */
+#define LINUX_SYS_socket 1
+#define LINUX_SYS_bind 2
+#define LINUX_SYS_connect 3
+#define LINUX_SYS_listen 4
+#define LINUX_SYS_accept 5
+#define LINUX_SYS_getsockname 6
+#define LINUX_SYS_getpeername 7
+#define LINUX_SYS_socketpair 8
+#define LINUX_SYS_send 9
+#define LINUX_SYS_recv 10
+#define LINUX_SYS_sendto 11
+#define LINUX_SYS_recvfrom 12
+#define LINUX_SYS_shutdown 13
+#define LINUX_SYS_setsockopt 14
+#define LINUX_SYS_getsockopt 15
+
+/*
+ * Structures for the arguments of the different system calls. This looks
+ * a little better than copyin() of all values one by one.
+ */
+struct linux_socket_args {
+ int domain;
+ int type;
+ int protocol;
+};
+
+struct linux_bind_args {
+ int s;
+ struct sockaddr *name;
+ int namelen;
+};
+
+struct linux_connect_args {
+ int s;
+ struct sockaddr *name;
+ int namelen;
+};
+
+struct linux_listen_args {
+ int s;
+ int backlog;
+};
+
+struct linux_accept_args {
+ int s;
+ struct sockaddr *addr;
+ int *namelen;
+};
+
+struct linux_getsockname_args {
+ int s;
+ struct sockaddr *addr;
+ int *namelen;
+};
+
+struct linux_getpeername_args {
+ int s;
+ struct sockaddr *addr;
+ int *namelen;
+};
+
+struct linux_socketpair_args {
+ int domain;
+ int type;
+ int protocol;
+ int *rsv;
+};
+
+struct linux_send_args {
+ int s;
+ void *msg;
+ int len;
+ int flags;
+};
+
+struct linux_recv_args {
+ int s;
+ void *msg;
+ int len;
+ int flags;
+};
+
+struct linux_sendto_args {
+ int s;
+ void *msg;
+ int len;
+ int flags;
+ struct sockaddr *to;
+ int tolen;
+};
+
+struct linux_recvfrom_args {
+ int s;
+ void *buf;
+ int len;
+ int flags;
+ struct sockaddr *from;
+ int *fromlen;
+};
+
+struct linux_shutdown_args {
+ int s;
+ int how;
+};
+
+struct linux_getsockopt_args {
+ int s;
+ int level;
+ int optname;
+ void *optval;
+ int *optlen;
+};
+
+struct linux_setsockopt_args {
+ int s;
+ int level;
+ int optname;
+ void *optval;
+ int optlen;
+};
+
+#endif /* _LINUX_SOCKETCALL_H */
diff --git a/sys/compat/linux/linux_sockio.h b/sys/compat/linux/linux_sockio.h
new file mode 100644
index 00000000000..62ae2bc26a4
--- /dev/null
+++ b/sys/compat/linux/linux_sockio.h
@@ -0,0 +1,40 @@
+/* $NetBSD: linux_sockio.h,v 1.2 1995/06/22 21:34:42 fvdl Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_SOCKIO_H
+#define _LINUX_SOCKIO_H
+
+#define LINUX_SIOCADDMULTI 0x8931
+#define LINUX_SIOCDELMULTI 0x8932
+
+#endif /* _LINUX_SOCKIO_H */
diff --git a/sys/compat/linux/linux_syscall.h b/sys/compat/linux/linux_syscall.h
new file mode 100644
index 00000000000..4bc8e99b8e6
--- /dev/null
+++ b/sys/compat/linux/linux_syscall.h
@@ -0,0 +1,120 @@
+/*
+ * System call numbers.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:15 mycroft Exp
+ */
+
+#define LINUX_SYS_syscall 0
+#define LINUX_SYS_exit 1
+#define LINUX_SYS_fork 2
+#define LINUX_SYS_read 3
+#define LINUX_SYS_write 4
+#define LINUX_SYS_open 5
+#define LINUX_SYS_close 6
+#define LINUX_SYS_waitpid 7
+#define LINUX_SYS_creat 8
+#define LINUX_SYS_link 9
+#define LINUX_SYS_unlink 10
+#define LINUX_SYS_execve 11
+#define LINUX_SYS_chdir 12
+#define LINUX_SYS_time 13
+#define LINUX_SYS_mknod 14
+#define LINUX_SYS_chmod 15
+#define LINUX_SYS_chown 16
+#define LINUX_SYS_break 17
+ /* 18 is obsolete ostat */
+#define LINUX_SYS_lseek 19
+#define LINUX_SYS_getpid 20
+#define LINUX_SYS_setuid 23
+#define LINUX_SYS_getuid 24
+#define LINUX_SYS_alarm 27
+ /* 28 is obsolete ofstat */
+#define LINUX_SYS_pause 29
+#define LINUX_SYS_utime 30
+#define LINUX_SYS_access 33
+#define LINUX_SYS_sync 36
+#define LINUX_SYS_kill 37
+#define LINUX_SYS_rename 38
+#define LINUX_SYS_mkdir 39
+#define LINUX_SYS_rmdir 40
+#define LINUX_SYS_dup 41
+#define LINUX_SYS_pipe 42
+#define LINUX_SYS_times 43
+#define LINUX_SYS_brk 45
+#define LINUX_SYS_setgid 46
+#define LINUX_SYS_getgid 47
+#define LINUX_SYS_signal 48
+#define LINUX_SYS_geteuid 49
+#define LINUX_SYS_getegid 50
+#define LINUX_SYS_acct 51
+#define LINUX_SYS_ioctl 54
+#define LINUX_SYS_fcntl 55
+#define LINUX_SYS_setpgid 57
+#define LINUX_SYS_oldolduname 59
+#define LINUX_SYS_umask 60
+#define LINUX_SYS_chroot 61
+#define LINUX_SYS_dup2 63
+#define LINUX_SYS_getppid 64
+#define LINUX_SYS_getpgrp 65
+#define LINUX_SYS_setsid 66
+#define LINUX_SYS_sigaction 67
+#define LINUX_SYS_siggetmask 68
+#define LINUX_SYS_sigsetmask 69
+#define LINUX_SYS_setreuid 70
+#define LINUX_SYS_setregid 71
+#define LINUX_SYS_sigsuspend 72
+#define LINUX_SYS_sigpending 73
+#define LINUX_SYS_sethostname 74
+#define LINUX_SYS_setrlimit 75
+#define LINUX_SYS_getrlimit 76
+#define LINUX_SYS_getrusage 77
+#define LINUX_SYS_gettimeofday 78
+#define LINUX_SYS_settimeofday 79
+#define LINUX_SYS_getgroups 80
+#define LINUX_SYS_setgroups 81
+#define LINUX_SYS_oldselect 82
+#define LINUX_SYS_symlink 83
+#define LINUX_SYS_olstat 84
+#define LINUX_SYS_readlink 85
+#define LINUX_SYS_uselib 86
+#define LINUX_SYS_swapon 87
+#define LINUX_SYS_reboot 88
+#define LINUX_SYS_readdir 89
+#define LINUX_SYS_mmap 90
+#define LINUX_SYS_munmap 91
+#define LINUX_SYS_truncate 92
+#define LINUX_SYS_ftruncate 93
+#define LINUX_SYS_fchmod 94
+#define LINUX_SYS_fchown 95
+#define LINUX_SYS_getpriority 96
+#define LINUX_SYS_setpriority 97
+#define LINUX_SYS_profil 98
+#define LINUX_SYS_statfs 99
+#define LINUX_SYS_fstatfs 100
+#define LINUX_SYS_ioperm 101
+#define LINUX_SYS_socketcall 102
+#define LINUX_SYS_setitimer 104
+#define LINUX_SYS_getitimer 105
+#define LINUX_SYS_stat 106
+#define LINUX_SYS_lstat 107
+#define LINUX_SYS_fstat 108
+#define LINUX_SYS_olduname 109
+#define LINUX_SYS_iopl 110
+#define LINUX_SYS_wait4 114
+#define LINUX_SYS_ipc 117
+#define LINUX_SYS_fsync 118
+#define LINUX_SYS_sigreturn 119
+#define LINUX_SYS_setdomainname 121
+#define LINUX_SYS_uname 122
+#define LINUX_SYS_modify_ldt 123
+#define LINUX_SYS_mprotect 125
+#define LINUX_SYS_sigprocmask 126
+#define LINUX_SYS_getpgid 132
+#define LINUX_SYS_fchdir 133
+#define LINUX_SYS_personality 136
+#define LINUX_SYS_llseek 140
+#define LINUX_SYS_getdents 141
+#define LINUX_SYS_select 142
+#define LINUX_SYS_flock 143
+#define LINUX_SYS_MAXSYSCALL 144
diff --git a/sys/compat/linux/linux_syscallargs.h b/sys/compat/linux/linux_syscallargs.h
new file mode 100644
index 00000000000..a4d393b1a83
--- /dev/null
+++ b/sys/compat/linux/linux_syscallargs.h
@@ -0,0 +1,433 @@
+/*
+ * System call argument lists.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:15 mycroft Exp
+ */
+
+#define syscallarg(x) union { x datum; register_t pad; }
+
+struct linux_sys_open_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+};
+
+struct linux_sys_waitpid_args {
+ syscallarg(int) pid;
+ syscallarg(int *) status;
+ syscallarg(int) options;
+};
+
+struct linux_sys_creat_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct linux_sys_unlink_args {
+ syscallarg(char *) path;
+};
+
+struct linux_sys_execve_args {
+ syscallarg(char *) path;
+ syscallarg(char **) argp;
+ syscallarg(char **) envp;
+};
+
+struct linux_sys_chdir_args {
+ syscallarg(char *) path;
+};
+
+struct linux_sys_time_args {
+ syscallarg(linux_time_t *) t;
+};
+
+struct linux_sys_mknod_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ syscallarg(int) dev;
+};
+
+struct linux_sys_chmod_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct linux_sys_chown_args {
+ syscallarg(char *) path;
+ syscallarg(int) uid;
+ syscallarg(int) gid;
+};
+
+struct linux_sys_break_args {
+ syscallarg(char *) nsize;
+};
+
+struct linux_sys_alarm_args {
+ syscallarg(unsigned int) secs;
+};
+
+struct linux_sys_utime_args {
+ syscallarg(char *) path;
+ syscallarg(struct linux_utimbuf *) times;
+};
+
+struct linux_sys_access_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+};
+
+struct linux_sys_kill_args {
+ syscallarg(int) pid;
+ syscallarg(int) signum;
+};
+
+struct linux_sys_rename_args {
+ syscallarg(char *) from;
+ syscallarg(char *) to;
+};
+
+struct linux_sys_mkdir_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct linux_sys_rmdir_args {
+ syscallarg(char *) path;
+};
+
+struct linux_sys_pipe_args {
+ syscallarg(int *) pfds;
+};
+
+struct linux_sys_times_args {
+ syscallarg(struct times *) tms;
+};
+
+struct linux_sys_brk_args {
+ syscallarg(char *) nsize;
+};
+
+struct linux_sys_signal_args {
+ syscallarg(int) sig;
+ syscallarg(linux_handler_t) handler;
+};
+
+struct linux_sys_ioctl_args {
+ syscallarg(int) fd;
+ syscallarg(u_long) com;
+ syscallarg(caddr_t) data;
+};
+
+struct linux_sys_fcntl_args {
+ syscallarg(int) fd;
+ syscallarg(int) cmd;
+ syscallarg(void *) arg;
+};
+
+struct linux_sys_oldolduname_args {
+ syscallarg(struct linux_oldold_utsname *) up;
+};
+
+struct linux_sys_sigaction_args {
+ syscallarg(int) signum;
+ syscallarg(struct linux_sigaction *) nsa;
+ syscallarg(struct linux_sigaction *) osa;
+};
+
+struct linux_sys_sigsetmask_args {
+ syscallarg(linux_sigset_t) mask;
+};
+
+struct linux_sys_setreuid_args {
+ syscallarg(int) ruid;
+ syscallarg(int) euid;
+};
+
+struct linux_sys_setregid_args {
+ syscallarg(int) rgid;
+ syscallarg(int) egid;
+};
+
+struct linux_sys_sigsuspend_args {
+ syscallarg(caddr_t) restart;
+ syscallarg(int) oldmask;
+ syscallarg(int) mask;
+};
+
+struct linux_sys_sigpending_args {
+ syscallarg(linux_sigset_t *) mask;
+};
+
+struct linux_sys_oldselect_args {
+ syscallarg(struct linux_select *) lsp;
+};
+
+struct linux_sys_symlink_args {
+ syscallarg(char *) path;
+ syscallarg(char *) to;
+};
+
+struct linux_sys_readlink_args {
+ syscallarg(char *) name;
+ syscallarg(char *) buf;
+ syscallarg(int) count;
+};
+
+struct linux_sys_uselib_args {
+ syscallarg(char *) path;
+};
+
+struct linux_sys_readdir_args {
+ syscallarg(int) fd;
+ syscallarg(caddr_t) dent;
+ syscallarg(unsigned int) count;
+};
+
+struct linux_sys_mmap_args {
+ syscallarg(struct linux_mmap *) lmp;
+};
+
+struct linux_sys_truncate_args {
+ syscallarg(char *) path;
+ syscallarg(long) length;
+};
+
+struct linux_sys_fchown_args {
+ syscallarg(int) fd;
+ syscallarg(int) uid;
+ syscallarg(int) gid;
+};
+
+struct linux_sys_statfs_args {
+ syscallarg(char *) path;
+ syscallarg(struct linux_statfs *) sp;
+};
+
+struct linux_sys_fstatfs_args {
+ syscallarg(int) fd;
+ syscallarg(struct linux_statfs *) sp;
+};
+
+struct linux_sys_ioperm_args {
+ syscallarg(unsigned int) lo;
+ syscallarg(unsigned int) hi;
+ syscallarg(int) val;
+};
+
+struct linux_sys_socketcall_args {
+ syscallarg(int) what;
+ syscallarg(void *) args;
+};
+
+struct linux_sys_stat_args {
+ syscallarg(char *) path;
+ syscallarg(struct linux_stat *) sp;
+};
+
+struct linux_sys_lstat_args {
+ syscallarg(char *) path;
+ syscallarg(struct linux_stat *) sp;
+};
+
+struct linux_sys_fstat_args {
+ syscallarg(int) fd;
+ syscallarg(struct linux_stat *) sp;
+};
+
+struct linux_sys_olduname_args {
+ syscallarg(struct linux_old_utsname *) up;
+};
+
+struct linux_sys_iopl_args {
+ syscallarg(int) level;
+};
+
+struct linux_sys_wait4_args {
+ syscallarg(int) pid;
+ syscallarg(int *) status;
+ syscallarg(int) options;
+ syscallarg(struct rusage *) rusage;
+};
+
+struct linux_sys_ipc_args {
+ syscallarg(int) what;
+ syscallarg(int) a1;
+ syscallarg(int) a2;
+ syscallarg(int) a3;
+ syscallarg(caddr_t) ptr;
+};
+
+struct linux_sys_sigreturn_args {
+ syscallarg(struct linux_sigcontext *) scp;
+};
+
+struct linux_sys_uname_args {
+ syscallarg(struct linux_utsname *) up;
+};
+
+struct linux_sys_modify_ldt_args {
+ syscallarg(int) func;
+ syscallarg(void *) ptr;
+ syscallarg(size_t) bytecount;
+};
+
+struct linux_sys_sigprocmask_args {
+ syscallarg(int) how;
+ syscallarg(linux_sigset_t *) set;
+ syscallarg(linux_sigset_t *) oset;
+};
+
+struct linux_sys_getpgid_args {
+ syscallarg(int) pid;
+};
+
+struct linux_sys_personality_args {
+ syscallarg(int) per;
+};
+
+struct linux_sys_llseek_args {
+ syscallarg(int) fd;
+ syscallarg(u_int32_t) ohigh;
+ syscallarg(u_int32_t) olow;
+ syscallarg(caddr_t) res;
+ syscallarg(int) whence;
+};
+
+struct linux_sys_getdents_args {
+ syscallarg(int) fd;
+ syscallarg(void *) dirent;
+ syscallarg(unsigned) count;
+};
+
+struct linux_sys_select_args {
+ syscallarg(int) nfds;
+ syscallarg(fd_set *) readfds;
+ syscallarg(fd_set *) writefds;
+ syscallarg(fd_set *) exceptfds;
+ syscallarg(struct timeval *) timeout;
+};
+
+/*
+ * System call prototypes.
+ */
+
+int sys_nosys __P((struct proc *, void *, register_t *));
+int sys_exit __P((struct proc *, void *, register_t *));
+int linux_sys_fork __P((struct proc *, void *, register_t *));
+int sys_read __P((struct proc *, void *, register_t *));
+int sys_write __P((struct proc *, void *, register_t *));
+int linux_sys_open __P((struct proc *, void *, register_t *));
+int sys_close __P((struct proc *, void *, register_t *));
+int linux_sys_waitpid __P((struct proc *, void *, register_t *));
+int linux_sys_creat __P((struct proc *, void *, register_t *));
+int sys_link __P((struct proc *, void *, register_t *));
+int linux_sys_unlink __P((struct proc *, void *, register_t *));
+int linux_sys_execve __P((struct proc *, void *, register_t *));
+int linux_sys_chdir __P((struct proc *, void *, register_t *));
+int linux_sys_time __P((struct proc *, void *, register_t *));
+int linux_sys_mknod __P((struct proc *, void *, register_t *));
+int linux_sys_chmod __P((struct proc *, void *, register_t *));
+int linux_sys_chown __P((struct proc *, void *, register_t *));
+int linux_sys_break __P((struct proc *, void *, register_t *));
+int compat_43_sys_lseek __P((struct proc *, void *, register_t *));
+int sys_getpid __P((struct proc *, void *, register_t *));
+int sys_setuid __P((struct proc *, void *, register_t *));
+int sys_getuid __P((struct proc *, void *, register_t *));
+int linux_sys_alarm __P((struct proc *, void *, register_t *));
+int linux_sys_pause __P((struct proc *, void *, register_t *));
+int linux_sys_utime __P((struct proc *, void *, register_t *));
+int linux_sys_access __P((struct proc *, void *, register_t *));
+int sys_sync __P((struct proc *, void *, register_t *));
+int linux_sys_kill __P((struct proc *, void *, register_t *));
+int linux_sys_rename __P((struct proc *, void *, register_t *));
+int linux_sys_mkdir __P((struct proc *, void *, register_t *));
+int linux_sys_rmdir __P((struct proc *, void *, register_t *));
+int sys_dup __P((struct proc *, void *, register_t *));
+int linux_sys_pipe __P((struct proc *, void *, register_t *));
+int linux_sys_times __P((struct proc *, void *, register_t *));
+int linux_sys_brk __P((struct proc *, void *, register_t *));
+int sys_setgid __P((struct proc *, void *, register_t *));
+int sys_getgid __P((struct proc *, void *, register_t *));
+int linux_sys_signal __P((struct proc *, void *, register_t *));
+int sys_geteuid __P((struct proc *, void *, register_t *));
+int sys_getegid __P((struct proc *, void *, register_t *));
+int sys_acct __P((struct proc *, void *, register_t *));
+int linux_sys_ioctl __P((struct proc *, void *, register_t *));
+int linux_sys_fcntl __P((struct proc *, void *, register_t *));
+int sys_setpgid __P((struct proc *, void *, register_t *));
+int linux_sys_oldolduname __P((struct proc *, void *, register_t *));
+int sys_umask __P((struct proc *, void *, register_t *));
+int sys_chroot __P((struct proc *, void *, register_t *));
+int sys_dup2 __P((struct proc *, void *, register_t *));
+int sys_getppid __P((struct proc *, void *, register_t *));
+int sys_getpgrp __P((struct proc *, void *, register_t *));
+int sys_setsid __P((struct proc *, void *, register_t *));
+int linux_sys_sigaction __P((struct proc *, void *, register_t *));
+int linux_sys_siggetmask __P((struct proc *, void *, register_t *));
+int linux_sys_sigsetmask __P((struct proc *, void *, register_t *));
+int linux_sys_setreuid __P((struct proc *, void *, register_t *));
+int linux_sys_setregid __P((struct proc *, void *, register_t *));
+int linux_sys_sigsuspend __P((struct proc *, void *, register_t *));
+int linux_sys_sigpending __P((struct proc *, void *, register_t *));
+int compat_43_sys_sethostname __P((struct proc *, void *, register_t *));
+int compat_43_sys_setrlimit __P((struct proc *, void *, register_t *));
+int compat_43_sys_getrlimit __P((struct proc *, void *, register_t *));
+int sys_getrusage __P((struct proc *, void *, register_t *));
+int sys_gettimeofday __P((struct proc *, void *, register_t *));
+int sys_settimeofday __P((struct proc *, void *, register_t *));
+int sys_getgroups __P((struct proc *, void *, register_t *));
+int sys_setgroups __P((struct proc *, void *, register_t *));
+int linux_sys_oldselect __P((struct proc *, void *, register_t *));
+int linux_sys_symlink __P((struct proc *, void *, register_t *));
+int compat_43_sys_lstat __P((struct proc *, void *, register_t *));
+int linux_sys_readlink __P((struct proc *, void *, register_t *));
+int linux_sys_uselib __P((struct proc *, void *, register_t *));
+int sys_swapon __P((struct proc *, void *, register_t *));
+int sys_reboot __P((struct proc *, void *, register_t *));
+int linux_sys_readdir __P((struct proc *, void *, register_t *));
+int linux_sys_mmap __P((struct proc *, void *, register_t *));
+int sys_munmap __P((struct proc *, void *, register_t *));
+int linux_sys_truncate __P((struct proc *, void *, register_t *));
+int compat_43_sys_ftruncate __P((struct proc *, void *, register_t *));
+int sys_fchmod __P((struct proc *, void *, register_t *));
+int linux_sys_fchown __P((struct proc *, void *, register_t *));
+int sys_getpriority __P((struct proc *, void *, register_t *));
+int sys_setpriority __P((struct proc *, void *, register_t *));
+int sys_profil __P((struct proc *, void *, register_t *));
+int linux_sys_statfs __P((struct proc *, void *, register_t *));
+int linux_sys_fstatfs __P((struct proc *, void *, register_t *));
+#ifdef __i386__
+int linux_sys_ioperm __P((struct proc *, void *, register_t *));
+#else
+#endif
+int linux_sys_socketcall __P((struct proc *, void *, register_t *));
+int sys_setitimer __P((struct proc *, void *, register_t *));
+int sys_getitimer __P((struct proc *, void *, register_t *));
+int linux_sys_stat __P((struct proc *, void *, register_t *));
+int linux_sys_lstat __P((struct proc *, void *, register_t *));
+int linux_sys_fstat __P((struct proc *, void *, register_t *));
+int linux_sys_olduname __P((struct proc *, void *, register_t *));
+#ifdef __i386__
+int linux_sys_iopl __P((struct proc *, void *, register_t *));
+#else
+#endif
+int linux_sys_wait4 __P((struct proc *, void *, register_t *));
+int linux_sys_ipc __P((struct proc *, void *, register_t *));
+int sys_fsync __P((struct proc *, void *, register_t *));
+int linux_sys_sigreturn __P((struct proc *, void *, register_t *));
+int compat_09_sys_setdomainname __P((struct proc *, void *, register_t *));
+int linux_sys_uname __P((struct proc *, void *, register_t *));
+#ifdef __i386__
+int linux_sys_modify_ldt __P((struct proc *, void *, register_t *));
+#else
+#endif
+int sys_mprotect __P((struct proc *, void *, register_t *));
+int linux_sys_sigprocmask __P((struct proc *, void *, register_t *));
+int linux_sys_getpgid __P((struct proc *, void *, register_t *));
+int sys_fchdir __P((struct proc *, void *, register_t *));
+int linux_sys_personality __P((struct proc *, void *, register_t *));
+int linux_sys_llseek __P((struct proc *, void *, register_t *));
+int linux_sys_getdents __P((struct proc *, void *, register_t *));
+int linux_sys_select __P((struct proc *, void *, register_t *));
+int sys_flock __P((struct proc *, void *, register_t *));
diff --git a/sys/compat/linux/linux_syscalls.c b/sys/compat/linux/linux_syscalls.c
new file mode 100644
index 00000000000..237014c11bf
--- /dev/null
+++ b/sys/compat/linux/linux_syscalls.c
@@ -0,0 +1,165 @@
+/*
+ * System call names.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:15 mycroft Exp
+ */
+
+char *linux_syscallnames[] = {
+ "syscall", /* 0 = syscall */
+ "exit", /* 1 = exit */
+ "fork", /* 2 = fork */
+ "read", /* 3 = read */
+ "write", /* 4 = write */
+ "open", /* 5 = open */
+ "close", /* 6 = close */
+ "waitpid", /* 7 = waitpid */
+ "creat", /* 8 = creat */
+ "link", /* 9 = link */
+ "unlink", /* 10 = unlink */
+ "execve", /* 11 = execve */
+ "chdir", /* 12 = chdir */
+ "time", /* 13 = time */
+ "mknod", /* 14 = mknod */
+ "chmod", /* 15 = chmod */
+ "chown", /* 16 = chown */
+ "break", /* 17 = break */
+ "#18 (obsolete ostat)", /* 18 = obsolete ostat */
+ "lseek", /* 19 = lseek */
+ "getpid", /* 20 = getpid */
+ "#21 (unimplemented mount)", /* 21 = unimplemented mount */
+ "#22 (unimplemented umount)", /* 22 = unimplemented umount */
+ "setuid", /* 23 = setuid */
+ "getuid", /* 24 = getuid */
+ "#25 (unimplemented stime)", /* 25 = unimplemented stime */
+ "#26 (unimplemented ptrace)", /* 26 = unimplemented ptrace */
+ "alarm", /* 27 = alarm */
+ "#28 (obsolete ofstat)", /* 28 = obsolete ofstat */
+ "pause", /* 29 = pause */
+ "utime", /* 30 = utime */
+ "#31 (unimplemented stty)", /* 31 = unimplemented stty */
+ "#32 (unimplemented gtty)", /* 32 = unimplemented gtty */
+ "access", /* 33 = access */
+ "#34 (unimplemented nice)", /* 34 = unimplemented nice */
+ "#35 (unimplemented ftime)", /* 35 = unimplemented ftime */
+ "sync", /* 36 = sync */
+ "kill", /* 37 = kill */
+ "rename", /* 38 = rename */
+ "mkdir", /* 39 = mkdir */
+ "rmdir", /* 40 = rmdir */
+ "dup", /* 41 = dup */
+ "pipe", /* 42 = pipe */
+ "times", /* 43 = times */
+ "#44 (unimplemented prof)", /* 44 = unimplemented prof */
+ "brk", /* 45 = brk */
+ "setgid", /* 46 = setgid */
+ "getgid", /* 47 = getgid */
+ "signal", /* 48 = signal */
+ "geteuid", /* 49 = geteuid */
+ "getegid", /* 50 = getegid */
+ "acct", /* 51 = acct */
+ "#52 (unimplemented phys)", /* 52 = unimplemented phys */
+ "#53 (unimplemented lock)", /* 53 = unimplemented lock */
+ "ioctl", /* 54 = ioctl */
+ "fcntl", /* 55 = fcntl */
+ "#56 (unimplemented mpx)", /* 56 = unimplemented mpx */
+ "setpgid", /* 57 = setpgid */
+ "#58 (unimplemented ulimit)", /* 58 = unimplemented ulimit */
+ "oldolduname", /* 59 = oldolduname */
+ "umask", /* 60 = umask */
+ "chroot", /* 61 = chroot */
+ "#62 (unimplemented ustat)", /* 62 = unimplemented ustat */
+ "dup2", /* 63 = dup2 */
+ "getppid", /* 64 = getppid */
+ "getpgrp", /* 65 = getpgrp */
+ "setsid", /* 66 = setsid */
+ "sigaction", /* 67 = sigaction */
+ "siggetmask", /* 68 = siggetmask */
+ "sigsetmask", /* 69 = sigsetmask */
+ "setreuid", /* 70 = setreuid */
+ "setregid", /* 71 = setregid */
+ "sigsuspend", /* 72 = sigsuspend */
+ "sigpending", /* 73 = sigpending */
+ "sethostname", /* 74 = sethostname */
+ "setrlimit", /* 75 = setrlimit */
+ "getrlimit", /* 76 = getrlimit */
+ "getrusage", /* 77 = getrusage */
+ "gettimeofday", /* 78 = gettimeofday */
+ "settimeofday", /* 79 = settimeofday */
+ "getgroups", /* 80 = getgroups */
+ "setgroups", /* 81 = setgroups */
+ "oldselect", /* 82 = oldselect */
+ "symlink", /* 83 = symlink */
+ "olstat", /* 84 = olstat */
+ "readlink", /* 85 = readlink */
+ "uselib", /* 86 = uselib */
+ "swapon", /* 87 = swapon */
+ "reboot", /* 88 = reboot */
+ "readdir", /* 89 = readdir */
+ "mmap", /* 90 = mmap */
+ "munmap", /* 91 = munmap */
+ "truncate", /* 92 = truncate */
+ "ftruncate", /* 93 = ftruncate */
+ "fchmod", /* 94 = fchmod */
+ "fchown", /* 95 = fchown */
+ "getpriority", /* 96 = getpriority */
+ "setpriority", /* 97 = setpriority */
+ "profil", /* 98 = profil */
+ "statfs", /* 99 = statfs */
+ "fstatfs", /* 100 = fstatfs */
+#ifdef __i386__
+ "ioperm", /* 101 = ioperm */
+#else
+ "#101 (unimplemented ioperm)", /* 101 = unimplemented ioperm */
+#endif
+ "socketcall", /* 102 = socketcall */
+ "#103 (unimplemented klog)", /* 103 = unimplemented klog */
+ "setitimer", /* 104 = setitimer */
+ "getitimer", /* 105 = getitimer */
+ "stat", /* 106 = stat */
+ "lstat", /* 107 = lstat */
+ "fstat", /* 108 = fstat */
+ "olduname", /* 109 = olduname */
+#ifdef __i386__
+ "iopl", /* 110 = iopl */
+#else
+ "#110 (unimplemented iopl)", /* 110 = unimplemented iopl */
+#endif
+ "#111 (unimplemented vhangup)", /* 111 = unimplemented vhangup */
+ "#112 (unimplemented idle)", /* 112 = unimplemented idle */
+ "#113 (unimplemented vm86)", /* 113 = unimplemented vm86 */
+ "wait4", /* 114 = wait4 */
+ "#115 (unimplemented swapoff)", /* 115 = unimplemented swapoff */
+ "#116 (unimplemented sysinfo)", /* 116 = unimplemented sysinfo */
+ "ipc", /* 117 = ipc */
+ "fsync", /* 118 = fsync */
+ "sigreturn", /* 119 = sigreturn */
+ "#120 (unimplemented clone)", /* 120 = unimplemented clone */
+ "setdomainname", /* 121 = setdomainname */
+ "uname", /* 122 = uname */
+#ifdef __i386__
+ "modify_ldt", /* 123 = modify_ldt */
+#else
+ "#123 (unimplemented modify_ldt)", /* 123 = unimplemented modify_ldt */
+#endif
+ "#124 (unimplemented adjtimex)", /* 124 = unimplemented adjtimex */
+ "mprotect", /* 125 = mprotect */
+ "sigprocmask", /* 126 = sigprocmask */
+ "#127 (unimplemented create_module)", /* 127 = unimplemented create_module */
+ "#128 (unimplemented init_module)", /* 128 = unimplemented init_module */
+ "#129 (unimplemented delete_module)", /* 129 = unimplemented delete_module */
+ "#130 (unimplemented get_kernel_syms)", /* 130 = unimplemented get_kernel_syms */
+ "#131 (unimplemented quotactl)", /* 131 = unimplemented quotactl */
+ "getpgid", /* 132 = getpgid */
+ "fchdir", /* 133 = fchdir */
+ "#134 (unimplemented bdflush)", /* 134 = unimplemented bdflush */
+ "#135 (unimplemented sysfs)", /* 135 = unimplemented sysfs */
+ "personality", /* 136 = personality */
+ "#137 (unimplemented afs_syscall)", /* 137 = unimplemented afs_syscall */
+ "#138 (unimplemented setfsuid)", /* 138 = unimplemented setfsuid */
+ "#139 (unimplemented getfsuid)", /* 139 = unimplemented getfsuid */
+ "llseek", /* 140 = llseek */
+ "getdents", /* 141 = getdents */
+ "select", /* 142 = select */
+ "flock", /* 143 = flock */
+};
diff --git a/sys/compat/linux/linux_sysent.c b/sys/compat/linux/linux_sysent.c
new file mode 100644
index 00000000000..0469f99ecd1
--- /dev/null
+++ b/sys/compat/linux/linux_sysent.c
@@ -0,0 +1,325 @@
+/*
+ * System call switch table.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:15 mycroft Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signal.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <compat/linux/linux_types.h>
+#include <compat/linux/linux_signal.h>
+#include <compat/linux/linux_syscallargs.h>
+#include <machine/linux_machdep.h>
+
+#define s(type) sizeof(type)
+
+struct sysent linux_sysent[] = {
+ { 0, 0,
+ sys_nosys }, /* 0 = syscall */
+ { 1, s(struct sys_exit_args),
+ sys_exit }, /* 1 = exit */
+ { 0, 0,
+ linux_sys_fork }, /* 2 = fork */
+ { 3, s(struct sys_read_args),
+ sys_read }, /* 3 = read */
+ { 3, s(struct sys_write_args),
+ sys_write }, /* 4 = write */
+ { 3, s(struct linux_sys_open_args),
+ linux_sys_open }, /* 5 = open */
+ { 1, s(struct sys_close_args),
+ sys_close }, /* 6 = close */
+ { 3, s(struct linux_sys_waitpid_args),
+ linux_sys_waitpid }, /* 7 = waitpid */
+ { 2, s(struct linux_sys_creat_args),
+ linux_sys_creat }, /* 8 = creat */
+ { 2, s(struct sys_link_args),
+ sys_link }, /* 9 = link */
+ { 1, s(struct linux_sys_unlink_args),
+ linux_sys_unlink }, /* 10 = unlink */
+ { 3, s(struct linux_sys_execve_args),
+ linux_sys_execve }, /* 11 = execve */
+ { 1, s(struct linux_sys_chdir_args),
+ linux_sys_chdir }, /* 12 = chdir */
+ { 1, s(struct linux_sys_time_args),
+ linux_sys_time }, /* 13 = time */
+ { 3, s(struct linux_sys_mknod_args),
+ linux_sys_mknod }, /* 14 = mknod */
+ { 2, s(struct linux_sys_chmod_args),
+ linux_sys_chmod }, /* 15 = chmod */
+ { 3, s(struct linux_sys_chown_args),
+ linux_sys_chown }, /* 16 = chown */
+ { 1, s(struct linux_sys_break_args),
+ linux_sys_break }, /* 17 = break */
+ { 0, 0,
+ sys_nosys }, /* 18 = obsolete ostat */
+ { 3, s(struct compat_43_sys_lseek_args),
+ compat_43_sys_lseek }, /* 19 = lseek */
+ { 0, 0,
+ sys_getpid }, /* 20 = getpid */
+ { 0, 0,
+ sys_nosys }, /* 21 = unimplemented mount */
+ { 0, 0,
+ sys_nosys }, /* 22 = unimplemented umount */
+ { 1, s(struct sys_setuid_args),
+ sys_setuid }, /* 23 = setuid */
+ { 0, 0,
+ sys_getuid }, /* 24 = getuid */
+ { 0, 0,
+ sys_nosys }, /* 25 = unimplemented stime */
+ { 0, 0,
+ sys_nosys }, /* 26 = unimplemented ptrace */
+ { 1, s(struct linux_sys_alarm_args),
+ linux_sys_alarm }, /* 27 = alarm */
+ { 0, 0,
+ sys_nosys }, /* 28 = obsolete ofstat */
+ { 0, 0,
+ linux_sys_pause }, /* 29 = pause */
+ { 2, s(struct linux_sys_utime_args),
+ linux_sys_utime }, /* 30 = utime */
+ { 0, 0,
+ sys_nosys }, /* 31 = unimplemented stty */
+ { 0, 0,
+ sys_nosys }, /* 32 = unimplemented gtty */
+ { 2, s(struct linux_sys_access_args),
+ linux_sys_access }, /* 33 = access */
+ { 0, 0,
+ sys_nosys }, /* 34 = unimplemented nice */
+ { 0, 0,
+ sys_nosys }, /* 35 = unimplemented ftime */
+ { 0, 0,
+ sys_sync }, /* 36 = sync */
+ { 2, s(struct linux_sys_kill_args),
+ linux_sys_kill }, /* 37 = kill */
+ { 2, s(struct linux_sys_rename_args),
+ linux_sys_rename }, /* 38 = rename */
+ { 2, s(struct linux_sys_mkdir_args),
+ linux_sys_mkdir }, /* 39 = mkdir */
+ { 1, s(struct linux_sys_rmdir_args),
+ linux_sys_rmdir }, /* 40 = rmdir */
+ { 1, s(struct sys_dup_args),
+ sys_dup }, /* 41 = dup */
+ { 1, s(struct linux_sys_pipe_args),
+ linux_sys_pipe }, /* 42 = pipe */
+ { 1, s(struct linux_sys_times_args),
+ linux_sys_times }, /* 43 = times */
+ { 0, 0,
+ sys_nosys }, /* 44 = unimplemented prof */
+ { 1, s(struct linux_sys_brk_args),
+ linux_sys_brk }, /* 45 = brk */
+ { 1, s(struct sys_setgid_args),
+ sys_setgid }, /* 46 = setgid */
+ { 0, 0,
+ sys_getgid }, /* 47 = getgid */
+ { 2, s(struct linux_sys_signal_args),
+ linux_sys_signal }, /* 48 = signal */
+ { 0, 0,
+ sys_geteuid }, /* 49 = geteuid */
+ { 0, 0,
+ sys_getegid }, /* 50 = getegid */
+ { 1, s(struct sys_acct_args),
+ sys_acct }, /* 51 = acct */
+ { 0, 0,
+ sys_nosys }, /* 52 = unimplemented phys */
+ { 0, 0,
+ sys_nosys }, /* 53 = unimplemented lock */
+ { 3, s(struct linux_sys_ioctl_args),
+ linux_sys_ioctl }, /* 54 = ioctl */
+ { 3, s(struct linux_sys_fcntl_args),
+ linux_sys_fcntl }, /* 55 = fcntl */
+ { 0, 0,
+ sys_nosys }, /* 56 = unimplemented mpx */
+ { 2, s(struct sys_setpgid_args),
+ sys_setpgid }, /* 57 = setpgid */
+ { 0, 0,
+ sys_nosys }, /* 58 = unimplemented ulimit */
+ { 1, s(struct linux_sys_oldolduname_args),
+ linux_sys_oldolduname }, /* 59 = oldolduname */
+ { 1, s(struct sys_umask_args),
+ sys_umask }, /* 60 = umask */
+ { 1, s(struct sys_chroot_args),
+ sys_chroot }, /* 61 = chroot */
+ { 0, 0,
+ sys_nosys }, /* 62 = unimplemented ustat */
+ { 2, s(struct sys_dup2_args),
+ sys_dup2 }, /* 63 = dup2 */
+ { 0, 0,
+ sys_getppid }, /* 64 = getppid */
+ { 0, 0,
+ sys_getpgrp }, /* 65 = getpgrp */
+ { 0, 0,
+ sys_setsid }, /* 66 = setsid */
+ { 3, s(struct linux_sys_sigaction_args),
+ linux_sys_sigaction }, /* 67 = sigaction */
+ { 0, 0,
+ linux_sys_siggetmask }, /* 68 = siggetmask */
+ { 1, s(struct linux_sys_sigsetmask_args),
+ linux_sys_sigsetmask }, /* 69 = sigsetmask */
+ { 2, s(struct linux_sys_setreuid_args),
+ linux_sys_setreuid }, /* 70 = setreuid */
+ { 2, s(struct linux_sys_setregid_args),
+ linux_sys_setregid }, /* 71 = setregid */
+ { 3, s(struct linux_sys_sigsuspend_args),
+ linux_sys_sigsuspend }, /* 72 = sigsuspend */
+ { 1, s(struct linux_sys_sigpending_args),
+ linux_sys_sigpending }, /* 73 = sigpending */
+ { 2, s(struct compat_43_sys_sethostname_args),
+ compat_43_sys_sethostname }, /* 74 = sethostname */
+ { 2, s(struct compat_43_sys_setrlimit_args),
+ compat_43_sys_setrlimit }, /* 75 = setrlimit */
+ { 2, s(struct compat_43_sys_getrlimit_args),
+ compat_43_sys_getrlimit }, /* 76 = getrlimit */
+ { 2, s(struct sys_getrusage_args),
+ sys_getrusage }, /* 77 = getrusage */
+ { 2, s(struct sys_gettimeofday_args),
+ sys_gettimeofday }, /* 78 = gettimeofday */
+ { 2, s(struct sys_settimeofday_args),
+ sys_settimeofday }, /* 79 = settimeofday */
+ { 2, s(struct sys_getgroups_args),
+ sys_getgroups }, /* 80 = getgroups */
+ { 2, s(struct sys_setgroups_args),
+ sys_setgroups }, /* 81 = setgroups */
+ { 1, s(struct linux_sys_oldselect_args),
+ linux_sys_oldselect }, /* 82 = oldselect */
+ { 2, s(struct linux_sys_symlink_args),
+ linux_sys_symlink }, /* 83 = symlink */
+ { 2, s(struct compat_43_sys_lstat_args),
+ compat_43_sys_lstat }, /* 84 = olstat */
+ { 3, s(struct linux_sys_readlink_args),
+ linux_sys_readlink }, /* 85 = readlink */
+ { 1, s(struct linux_sys_uselib_args),
+ linux_sys_uselib }, /* 86 = uselib */
+ { 1, s(struct sys_swapon_args),
+ sys_swapon }, /* 87 = swapon */
+ { 1, s(struct sys_reboot_args),
+ sys_reboot }, /* 88 = reboot */
+ { 3, s(struct linux_sys_readdir_args),
+ linux_sys_readdir }, /* 89 = readdir */
+ { 1, s(struct linux_sys_mmap_args),
+ linux_sys_mmap }, /* 90 = mmap */
+ { 2, s(struct sys_munmap_args),
+ sys_munmap }, /* 91 = munmap */
+ { 2, s(struct linux_sys_truncate_args),
+ linux_sys_truncate }, /* 92 = truncate */
+ { 2, s(struct compat_43_sys_ftruncate_args),
+ compat_43_sys_ftruncate }, /* 93 = ftruncate */
+ { 2, s(struct sys_fchmod_args),
+ sys_fchmod }, /* 94 = fchmod */
+ { 3, s(struct linux_sys_fchown_args),
+ linux_sys_fchown }, /* 95 = fchown */
+ { 2, s(struct sys_getpriority_args),
+ sys_getpriority }, /* 96 = getpriority */
+ { 3, s(struct sys_setpriority_args),
+ sys_setpriority }, /* 97 = setpriority */
+ { 4, s(struct sys_profil_args),
+ sys_profil }, /* 98 = profil */
+ { 2, s(struct linux_sys_statfs_args),
+ linux_sys_statfs }, /* 99 = statfs */
+ { 2, s(struct linux_sys_fstatfs_args),
+ linux_sys_fstatfs }, /* 100 = fstatfs */
+#ifdef __i386__
+ { 3, s(struct linux_sys_ioperm_args),
+ linux_sys_ioperm }, /* 101 = ioperm */
+#else
+ { 0, 0,
+ sys_nosys }, /* 101 = unimplemented ioperm */
+#endif
+ { 2, s(struct linux_sys_socketcall_args),
+ linux_sys_socketcall }, /* 102 = socketcall */
+ { 0, 0,
+ sys_nosys }, /* 103 = unimplemented klog */
+ { 3, s(struct sys_setitimer_args),
+ sys_setitimer }, /* 104 = setitimer */
+ { 2, s(struct sys_getitimer_args),
+ sys_getitimer }, /* 105 = getitimer */
+ { 2, s(struct linux_sys_stat_args),
+ linux_sys_stat }, /* 106 = stat */
+ { 2, s(struct linux_sys_lstat_args),
+ linux_sys_lstat }, /* 107 = lstat */
+ { 2, s(struct linux_sys_fstat_args),
+ linux_sys_fstat }, /* 108 = fstat */
+ { 1, s(struct linux_sys_olduname_args),
+ linux_sys_olduname }, /* 109 = olduname */
+#ifdef __i386__
+ { 1, s(struct linux_sys_iopl_args),
+ linux_sys_iopl }, /* 110 = iopl */
+#else
+ { 0, 0,
+ sys_nosys }, /* 110 = unimplemented iopl */
+#endif
+ { 0, 0,
+ sys_nosys }, /* 111 = unimplemented vhangup */
+ { 0, 0,
+ sys_nosys }, /* 112 = unimplemented idle */
+ { 0, 0,
+ sys_nosys }, /* 113 = unimplemented vm86 */
+ { 4, s(struct linux_sys_wait4_args),
+ linux_sys_wait4 }, /* 114 = wait4 */
+ { 0, 0,
+ sys_nosys }, /* 115 = unimplemented swapoff */
+ { 0, 0,
+ sys_nosys }, /* 116 = unimplemented sysinfo */
+ { 5, s(struct linux_sys_ipc_args),
+ linux_sys_ipc }, /* 117 = ipc */
+ { 1, s(struct sys_fsync_args),
+ sys_fsync }, /* 118 = fsync */
+ { 1, s(struct linux_sys_sigreturn_args),
+ linux_sys_sigreturn }, /* 119 = sigreturn */
+ { 0, 0,
+ sys_nosys }, /* 120 = unimplemented clone */
+ { 2, s(struct compat_09_sys_setdomainname_args),
+ compat_09_sys_setdomainname }, /* 121 = setdomainname */
+ { 1, s(struct linux_sys_uname_args),
+ linux_sys_uname }, /* 122 = uname */
+#ifdef __i386__
+ { 3, s(struct linux_sys_modify_ldt_args),
+ linux_sys_modify_ldt }, /* 123 = modify_ldt */
+#else
+ { 0, 0,
+ sys_nosys }, /* 123 = unimplemented modify_ldt */
+#endif
+ { 0, 0,
+ sys_nosys }, /* 124 = unimplemented adjtimex */
+ { 3, s(struct sys_mprotect_args),
+ sys_mprotect }, /* 125 = mprotect */
+ { 3, s(struct linux_sys_sigprocmask_args),
+ linux_sys_sigprocmask }, /* 126 = sigprocmask */
+ { 0, 0,
+ sys_nosys }, /* 127 = unimplemented create_module */
+ { 0, 0,
+ sys_nosys }, /* 128 = unimplemented init_module */
+ { 0, 0,
+ sys_nosys }, /* 129 = unimplemented delete_module */
+ { 0, 0,
+ sys_nosys }, /* 130 = unimplemented get_kernel_syms */
+ { 0, 0,
+ sys_nosys }, /* 131 = unimplemented quotactl */
+ { 1, s(struct linux_sys_getpgid_args),
+ linux_sys_getpgid }, /* 132 = getpgid */
+ { 1, s(struct sys_fchdir_args),
+ sys_fchdir }, /* 133 = fchdir */
+ { 0, 0,
+ sys_nosys }, /* 134 = unimplemented bdflush */
+ { 0, 0,
+ sys_nosys }, /* 135 = unimplemented sysfs */
+ { 1, s(struct linux_sys_personality_args),
+ linux_sys_personality }, /* 136 = personality */
+ { 0, 0,
+ sys_nosys }, /* 137 = unimplemented afs_syscall */
+ { 0, 0,
+ sys_nosys }, /* 138 = unimplemented setfsuid */
+ { 0, 0,
+ sys_nosys }, /* 139 = unimplemented getfsuid */
+ { 5, s(struct linux_sys_llseek_args),
+ linux_sys_llseek }, /* 140 = llseek */
+ { 3, s(struct linux_sys_getdents_args),
+ linux_sys_getdents }, /* 141 = getdents */
+ { 5, s(struct linux_sys_select_args),
+ linux_sys_select }, /* 142 = select */
+ { 2, s(struct sys_flock_args),
+ sys_flock }, /* 143 = flock */
+};
+
diff --git a/sys/compat/linux/linux_types.h b/sys/compat/linux/linux_types.h
new file mode 100644
index 00000000000..c931a2ab560
--- /dev/null
+++ b/sys/compat/linux/linux_types.h
@@ -0,0 +1,151 @@
+/* $NetBSD: linux_types.h,v 1.4 1995/08/21 03:42:11 mycroft Exp $ */
+
+/*
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed for the NetBSD Project
+ * by Frank van der Linden
+ * 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.
+ */
+
+#ifndef _LINUX_TYPES_H
+#define _LINUX_TYPES_H
+
+typedef struct {
+ long val[2];
+} linux_fsid_t;
+
+typedef unsigned short linux_uid_t;
+typedef unsigned short linux_gid_t;
+typedef unsigned short linux_dev_t;
+typedef unsigned long linux_ino_t;
+typedef unsigned short linux_mode_t;
+typedef unsigned short linux_nlink_t;
+typedef long linux_time_t;
+typedef long linux_clock_t;
+typedef long linux_off_t;
+typedef int linux_pid_t;
+
+struct linux_statfs {
+ long l_ftype;
+ long l_fbsize;
+ long l_fblocks;
+ long l_fbfree;
+ long l_fbavail;
+ long l_ffiles;
+ long l_fffree;
+ linux_fsid_t l_ffsid;
+ long l_fnamelen;
+ long l_fspare[6];
+};
+
+/*
+ * Structure for uname(2)
+ */
+struct linux_utsname {
+ char l_sysname[65];
+ char l_nodename[65];
+ char l_release[65];
+ char l_version[65];
+ char l_machine[65];
+ char l_domainname[65];
+};
+
+struct linux_oldutsname {
+ char l_sysname[65];
+ char l_nodename[65];
+ char l_release[65];
+ char l_version[65];
+ char l_machine[65];
+};
+
+struct linux_oldoldutsname {
+ char l_sysname[9];
+ char l_nodename[9];
+ char l_release[9];
+ char l_version[9];
+ char l_machine[9];
+};
+
+/*
+ * Passed to the mmap() system call
+ */
+struct linux_mmap {
+ caddr_t lm_addr;
+ int lm_len;
+ int lm_prot;
+ int lm_flags;
+ int lm_fd;
+ int lm_pos;
+};
+
+/*
+ * Passed to the select() system call
+ */
+struct linux_select {
+ int nfds;
+ fd_set *readfds;
+ fd_set *writefds;
+ fd_set *exceptfds;
+ struct timeval *timeout;
+};
+
+struct linux_stat {
+ linux_dev_t lst_dev;
+ unsigned short pad1;
+ linux_ino_t lst_ino;
+ linux_mode_t lst_mode;
+ linux_nlink_t lst_nlink;
+ linux_uid_t lst_uid;
+ linux_gid_t lst_gid;
+ linux_dev_t lst_rdev;
+ unsigned short pad2;
+ linux_off_t lst_size;
+ unsigned long lst_blksize;
+ unsigned long lst_blocks;
+ linux_time_t lst_atime;
+ unsigned long unused1;
+ linux_time_t lst_mtime;
+ unsigned long unused2;
+ linux_time_t lst_ctime;
+ unsigned long unused3;
+ unsigned long unused4;
+ unsigned long unused5;
+};
+
+struct linux_tms {
+ linux_clock_t ltms_utime;
+ linux_clock_t ltms_stime;
+ linux_clock_t ltms_cutime;
+ linux_clock_t ltms_cstime;
+};
+
+struct linux_utimbuf {
+ linux_time_t l_actime;
+ linux_time_t l_modtime;
+};
+
+#endif /* !_LINUX_TYPES_H */
diff --git a/sys/compat/linux/linux_util.h b/sys/compat/linux/linux_util.h
new file mode 100644
index 00000000000..72fcdbd62c1
--- /dev/null
+++ b/sys/compat/linux/linux_util.h
@@ -0,0 +1,48 @@
+/* $NetBSD: linux_util.h,v 1.5 1995/06/24 20:20:42 christos 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.
+ *
+ */
+
+#ifndef _LINUX_UTIL_H_
+#define _LINUX_UTIL_H_
+
+#include <compat/common/compat_util.h>
+
+#define cvtto_linux_mask(flags,bmask,lmask) (((flags) & bmask) ? lmask : 0)
+#define cvtto_bsd_mask(flags,lmask,bmask) (((flags) & lmask) ? bmask : 0)
+
+extern const char linux_emul_path[];
+
+#define LINUX_CHECK_ALT_EXIST(p, sgp, path) \
+ CHECK_ALT_EXIST(p, sgp, linux_emul_path, path)
+
+#define LINUX_CHECK_ALT_CREAT(p, sgp, path) \
+ CHECK_ALT_CREAT(p, sgp, linux_emul_path, path)
+
+#endif /* !_LINUX_UTIL_H_ */
diff --git a/sys/compat/linux/syscalls.conf b/sys/compat/linux/syscalls.conf
new file mode 100644
index 00000000000..3b8796db129
--- /dev/null
+++ b/sys/compat/linux/syscalls.conf
@@ -0,0 +1,12 @@
+# $NetBSD: syscalls.conf,v 1.1 1995/02/28 23:26:24 fvdl Exp $
+
+sysnames="linux_syscalls.c"
+sysnumhdr="linux_syscall.h"
+syssw="linux_sysent.c"
+sysarghdr="linux_syscallargs.h"
+compatopts=""
+libcompatopts=""
+
+switchname="linux_sysent"
+namesname="linux_syscallnames"
+constprefix="LINUX_SYS_"
diff --git a/sys/compat/linux/syscalls.master b/sys/compat/linux/syscalls.master
new file mode 100644
index 00000000000..20241fba899
--- /dev/null
+++ b/sys/compat/linux/syscalls.master
@@ -0,0 +1,235 @@
+ $NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:15 mycroft Exp $
+
+; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
+
+; NetBSD COMPAT_LINUX 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
+;
+; 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 <compat/linux/linux_types.h>
+#include <compat/linux/linux_signal.h>
+#include <compat/linux/linux_syscallargs.h>
+
+#include <machine/linux_machdep.h>
+
+0 NOARGS { int sys_nosys(void); } syscall
+1 NOARGS { int sys_exit(int rval); }
+2 STD { int linux_sys_fork(void); }
+3 NOARGS { int sys_read(int fd, char *buf, u_int nbyte); }
+4 NOARGS { int sys_write(int fd, char *buf, u_int nbyte); }
+5 STD { int linux_sys_open(char *path, int flags, int mode); }
+6 NOARGS { int sys_close(int fd); }
+7 STD { int linux_sys_waitpid(int pid, int *status, \
+ int options);}
+8 STD { int linux_sys_creat(char *path, int mode); }
+9 NOARGS { int sys_link(char *path, char *link); }
+10 STD { int linux_sys_unlink(char *path); }
+11 STD { int linux_sys_execve(char *path, char **argp, \
+ char **envp); }
+12 STD { int linux_sys_chdir(char *path); }
+13 STD { int linux_sys_time(linux_time_t *t); }
+14 STD { int linux_sys_mknod(char *path, int mode, int dev); }
+15 STD { int linux_sys_chmod(char *path, int mode); }
+16 STD { int linux_sys_chown(char *path, int uid, int gid); }
+17 STD { int linux_sys_break(char *nsize); }
+18 OBSOL ostat
+19 NOARGS { long compat_43_sys_lseek(int fd, long offset, \
+ int whence); }
+20 NOARGS { pid_t sys_getpid(void); }
+21 UNIMPL mount
+22 UNIMPL umount
+23 NOARGS { int sys_setuid(uid_t uid); }
+24 NOARGS { uid_t sys_getuid(void); }
+25 UNIMPL stime
+26 UNIMPL ptrace
+27 STD { int linux_sys_alarm(unsigned int secs); }
+28 OBSOL ofstat
+29 STD { int linux_sys_pause(void); }
+30 STD { int linux_sys_utime(char *path, \
+ struct linux_utimbuf *times); }
+31 UNIMPL stty
+32 UNIMPL gtty
+33 STD { int linux_sys_access(char *path, int flags); }
+34 UNIMPL nice
+35 UNIMPL ftime
+36 NOARGS { int sys_sync(void); }
+37 STD { int linux_sys_kill(int pid, int signum); }
+38 STD { int linux_sys_rename(char *from, char *to); }
+39 STD { int linux_sys_mkdir(char *path, int mode); }
+40 STD { int linux_sys_rmdir(char *path); }
+41 NOARGS { int sys_dup(u_int fd); }
+42 STD { int linux_sys_pipe(int *pfds); }
+43 STD { int linux_sys_times(struct times *tms); }
+44 UNIMPL prof
+45 STD { int linux_sys_brk(char *nsize); }
+46 NOARGS { int sys_setgid(gid_t gid); }
+47 NOARGS { gid_t sys_getgid(void); }
+48 STD { int linux_sys_signal(int sig, \
+ linux_handler_t handler); }
+49 NOARGS { uid_t sys_geteuid(void); }
+50 NOARGS { gid_t sys_getegid(void); }
+51 NOARGS { int sys_acct(char *path); }
+52 UNIMPL phys
+53 UNIMPL lock
+54 STD { int linux_sys_ioctl(int fd, u_long com, \
+ caddr_t data); }
+55 STD { int linux_sys_fcntl(int fd, int cmd, void *arg); }
+56 UNIMPL mpx
+57 NOARGS { int sys_setpgid(int pid, int pgid); }
+58 UNIMPL ulimit
+59 STD { int linux_sys_oldolduname(struct linux_oldold_utsname *up); }
+60 NOARGS { int sys_umask(int newmask); }
+61 NOARGS { int sys_chroot(char *path); }
+62 UNIMPL ustat
+63 NOARGS { int sys_dup2(u_int from, u_int to); }
+64 NOARGS { pid_t sys_getppid(void); }
+65 NOARGS { int sys_getpgrp(void); }
+66 NOARGS { int sys_setsid(void); }
+67 STD { int linux_sys_sigaction(int signum, \
+ struct linux_sigaction *nsa, \
+ struct linux_sigaction *osa); }
+68 STD { int linux_sys_siggetmask(void); }
+69 STD { int linux_sys_sigsetmask(linux_sigset_t mask); }
+70 STD { int linux_sys_setreuid(int ruid, int euid); }
+71 STD { int linux_sys_setregid(int rgid, int egid); }
+72 STD { int linux_sys_sigsuspend(caddr_t restart, \
+ int oldmask, int mask); }
+73 STD { int linux_sys_sigpending(linux_sigset_t *mask); }
+74 NOARGS { int compat_43_sys_sethostname(char *hostname, \
+ u_int len);}
+75 NOARGS { int compat_43_sys_setrlimit(u_int which, \
+ struct ogetrlimit *rlp); }
+76 NOARGS { int compat_43_sys_getrlimit(u_int which, \
+ struct ogetrlimit *rlp); }
+77 NOARGS { int sys_getrusage(int who, struct rusage *rusage); }
+78 NOARGS { int sys_gettimeofday(struct timeval *tp, \
+ struct timezone *tzp); }
+79 NOARGS { int sys_settimeofday(struct timeval *tp, \
+ struct timezone *tzp); }
+80 NOARGS { int sys_getgroups(u_int gidsetsize, gid_t *gidset); }
+81 NOARGS { int sys_setgroups(u_int gidsetsize, gid_t *gidset); }
+82 STD { int linux_sys_oldselect(struct linux_select *lsp); }
+83 STD { int linux_sys_symlink(char *path, char *to); }
+84 NOARGS { int compat_43_sys_lstat(char *path, \
+ struct ostat *up); } olstat
+85 STD { int linux_sys_readlink(char *name, char *buf, \
+ int count); }
+86 STD { int linux_sys_uselib(char *path); }
+87 NOARGS { int sys_swapon(char *name); }
+88 NOARGS { int sys_reboot(int opt); }
+89 STD { int linux_sys_readdir(int fd, caddr_t dent, \
+ unsigned int count); }
+90 STD { int linux_sys_mmap(struct linux_mmap *lmp); }
+91 NOARGS { int sys_munmap(caddr_t addr, int len); }
+92 STD { int linux_sys_truncate(char *path, long length); }
+93 NOARGS { int compat_43_sys_ftruncate(int fd, long length); }
+94 NOARGS { int sys_fchmod(int fd, int mode); }
+95 STD { int linux_sys_fchown(int fd, int uid, int gid); }
+96 NOARGS { int sys_getpriority(int which, int who); }
+97 NOARGS { int sys_setpriority(int which, int who, int prio); }
+98 NOARGS { int sys_profil(caddr_t samples, u_int size, \
+ u_int offset, u_int scale); }
+99 STD { int linux_sys_statfs(char *path, \
+ struct linux_statfs *sp); }
+100 STD { int linux_sys_fstatfs(int fd, \
+ struct linux_statfs *sp); }
+#ifdef __i386__
+101 STD { int linux_sys_ioperm(unsigned int lo, \
+ unsigned int hi, int val); }
+#else
+101 UNIMPL ioperm
+#endif
+102 STD { int linux_sys_socketcall(int what, void *args); }
+103 UNIMPL klog
+104 NOARGS { int sys_setitimer(u_int which, \
+ struct itimerval *itv, struct itimerval *oitv); }
+105 NOARGS { int sys_getitimer(u_int which, \
+ struct itimerval *itv); }
+106 STD { int linux_sys_stat(char *path, \
+ struct linux_stat *sp); }
+107 STD { int linux_sys_lstat(char *path, \
+ struct linux_stat *sp); }
+108 STD { int linux_sys_fstat(int fd, struct linux_stat *sp); }
+109 STD { int linux_sys_olduname(struct linux_old_utsname *up); }
+#ifdef __i386__
+110 STD { int linux_sys_iopl(int level); }
+#else
+110 UNIMPL iopl
+#endif
+111 UNIMPL vhangup
+112 UNIMPL idle
+113 UNIMPL vm86
+114 STD { int linux_sys_wait4(int pid, int *status, \
+ int options, struct rusage *rusage); }
+115 UNIMPL swapoff
+116 UNIMPL sysinfo
+117 STD { int linux_sys_ipc(int what, int a1, int a2, int a3, \
+ caddr_t ptr); }
+118 NOARGS { int sys_fsync(int fd); }
+119 STD { int linux_sys_sigreturn(struct linux_sigcontext *scp); }
+120 UNIMPL clone
+121 NOARGS { int compat_09_sys_setdomainname(char *name, \
+ int len); }
+122 STD { int linux_sys_uname(struct linux_utsname *up); }
+#ifdef __i386__
+123 STD { int linux_sys_modify_ldt(int func, void *ptr, \
+ size_t bytecount); }
+#else
+123 UNIMPL modify_ldt
+#endif
+124 UNIMPL adjtimex
+125 NOARGS { int sys_mprotect(caddr_t addr, int len, int prot); }
+126 STD { int linux_sys_sigprocmask(int how, \
+ linux_sigset_t *set, linux_sigset_t *oset); }
+127 UNIMPL create_module
+128 UNIMPL init_module
+129 UNIMPL delete_module
+130 UNIMPL get_kernel_syms
+131 UNIMPL quotactl
+132 STD { int linux_sys_getpgid(int pid); }
+133 NOARGS { int sys_fchdir(int fd); }
+134 UNIMPL bdflush
+135 UNIMPL sysfs
+136 STD { int linux_sys_personality(int per); }
+137 UNIMPL afs_syscall
+138 UNIMPL setfsuid
+139 UNIMPL getfsuid
+140 STD { int linux_sys_llseek(int fd, u_int32_t ohigh, \
+ u_int32_t olow, caddr_t res, int whence); }
+141 STD { int linux_sys_getdents(int fd, void *dirent, \
+ unsigned count); }
+142 STD { int linux_sys_select(int nfds, fd_set *readfds, \
+ fd_set *writefds, fd_set *exceptfds, \
+ struct timeval *timeout); }
+143 NOARGS { int sys_flock(int fd, int how); }
diff --git a/sys/compat/osf1/Makefile b/sys/compat/osf1/Makefile
new file mode 100644
index 00000000000..da4a1176a78
--- /dev/null
+++ b/sys/compat/osf1/Makefile
@@ -0,0 +1,11 @@
+# $NetBSD: Makefile,v 1.1 1995/02/13 21:39:00 cgd Exp $
+
+DEP= syscalls.conf syscalls.master ../../kern/makesyscalls.sh
+OBJS= osf1_sysent.c osf1_syscalls.c osf1_syscall.h osf1_syscallargs.h
+
+${OBJS}: ${DEP}
+ -mv -f osf1_sysent.c osf1_sysent.c.bak
+ -mv -f osf1_syscalls.c osf1_syscalls.c.bak
+ -mv -f osf1_syscall.h osf1_syscall.h.bak
+ -mv -f osf1_syscallargs.h osf1_syscallargs.h.bak
+ sh ../../kern/makesyscalls.sh syscalls.conf syscalls.master
diff --git a/sys/compat/osf1/README.dynamic b/sys/compat/osf1/README.dynamic
new file mode 100644
index 00000000000..ce90731daeb
--- /dev/null
+++ b/sys/compat/osf1/README.dynamic
@@ -0,0 +1,77 @@
+$NetBSD: README.dynamic,v 1.1 1995/02/13 21:39:01 cgd Exp $
+
+Currently, the NetBSD OSF/1 emulation code only supports statically
+linked OSF/1 binaries. This document is meant to be a quick
+description of what would need to happen to support dynamically linked
+OSF/1 binaries, and to provide an indication of the amount of work
+that would be required to add such support.
+
+To support dynamically linked OSF/1 binaries, three steps would have
+to be taken:
+ (1) The osf1_exec_with_loader() syscall emulation code would
+ have to be written.
+ (2) Execve() would have to be changed to support invocation of
+ a loader for dynamically linked binaries.
+ (3) The pmap code would have to be extended to allow process
+ virtual spaces that are much larger than are currently
+ allowed.
+
+1. Implementing osf1_exec_with_loader().
+
+The description of osf1_exec_with_loader is as follows:
+
+ int exec_with_loader(int flags, const char *loader,
+ const char *file, char * const argv[],
+ char * const envp[]);
+
+It invokes the program named by file, with the given argv and envp,
+by starting the specified loader (or /sbin/loader) and somehow passing
+the flags, file name, argv, and envp in such a way that the
+appropriate things will happen with them. This interface is
+completely undocumented (in the documentation that we have available),
+and so the only way to figure it out is to disassemble the OSF/1
+kernel and/or /sbin/loader.
+
+2. Changing execve() to support OSF/1 dynamically linked executables.
+
+Normally, dynamically linked executables are invoked using execve(),
+in the normal fashion. The kernel transforms that request into one
+that uses the loader, and causes the loader to be invoked with the
+appropriate information to run the target executable.
+
+The mechanism by which this is done is unknown; it may be possible to
+completely replace the OSF/1 loader with one designed for NetBSD, but
+that is rather prohibitive. (Additionally, it wouldn't solve the
+problem of needing to implement the osf1_exec_with_loader()
+functionality.)
+
+In any case, this would not be insignificant; it and/or the
+implementation of osf1_exec_with_loader() would probably require a
+complete rewrite or duplication of the current execve() code.
+
+3. Extending the pmap code to handle larger virtual spaces.
+
+OSF/1's /sbin/loader wants to be loaded at 0x3ff80000000. Currently,
+because of a simplifying assumption (specifically, to only use the
+first level-one pte for user-space mappings, effectively turning the
+pmap into one that looks much like one for a mc68030), only 8Gb
+(0x200000000 bytes) of user virtual space are supported.
+
+It is unclear that the extra virtual space is necessary for any
+applications that NetBSD/Alpha would be used for, and support for it
+would add a significant amount of complexity to the pmap module.
+Adding that support would probably require a from-scratch rewrite of
+the pmap module.
+
+
+Because of the difficulties in emulating the system call interface
+used to run dynamic executables, and the difficulties in allowing
+support for the address space the OSF/1 loader needs, I do not think
+that it is feasible to support dynamically linked OSF/1 executables
+with the OSF/1 loading mechanism. It may be possible to do so with a
+new loading mechanism which could be written for NetBSD, but it is
+unclear that the necessary interfaces to do even that could be
+discovered, and the effort required to implement a new loading
+mechanism would be prohibitive.
+
+-- cgd
diff --git a/sys/compat/osf1/README.mach-traps b/sys/compat/osf1/README.mach-traps
new file mode 100644
index 00000000000..1748ac28bd3
--- /dev/null
+++ b/sys/compat/osf1/README.mach-traps
@@ -0,0 +1,58 @@
+$NetBSD: README.mach-traps,v 1.1 1995/02/13 21:39:02 cgd Exp $
+
+Some Alpha AXP OSF/1 binaries directly use the facilities provided by
+the Mach kernel that is the basis for OSF/1. These include (but are
+surely not limited to) 'dd', 'ps', and 'w'.
+
+Invariably, the symptom that these binaries display is that they crash
+with an "unimplemented system call" trap (SIGSYS signal) for a syscall
+that has a negative number. In general, binaries that use the Mach
+syscalls appear to invoke task_self() as their first syscall.
+
+The name, number, and number of arguments for each Mach syscall is
+given below; this information was gleaned by looking through the OSF/1
+libmach.a's object files with dbx, then double-checked against the
+contents of OSF/1's <mach/syscall_sw.h>.
+
+These calls would be very difficult to implement properly in the
+OSF/1 emulation code; by its very nature, NetBSD is not Mach, and we
+don't and can't provide the underlying facilities that it does.
+
+-- cgd
+
+trap name number nargs notes
+---- ---- ------ ----- -----
+task_self -10 0
+thread_reply -11 0
+task_notify -12 0
+thread_self -13 0
+msg_send_old -14 3
+msg_receive_old -15 3
+msg_rpc_old -16 5
+msg_send_trap -20 4
+msg_receive_trap -21 5
+msg_rpc_trap -22 6
+lw_wire -30 3
+lw_unwire -31 1
+inode_swap_preference -40 3
+init_process -41 0
+map_fd -43 5
+htg_unix_syscall -52 3
+host_self -55 1
+host_priv_self -56 1
+swtch_pri -59 1
+swtch -60 0
+thread_switch -61 3
+mach_sctimes_0 -70 0 only if MACH_SCTIMES defined
+mach_sctimes_1 -71 1 only if MACH_SCTIMES defined
+mach_sctimes_2 -72 2 only if MACH_SCTIMES defined
+mach_sctimes_3 -73 3 only if MACH_SCTIMES defined
+mach_sctimes_4 -74 4 only if MACH_SCTIMES defined
+mach_sctimes_5 -75 5 only if MACH_SCTIMES defined
+mach_sctimes_6 -76 6 only if MACH_SCTIMES defined
+mach_sctimes_7 -77 0 only if MACH_SCTIMES defined
+mach_sctimes_8 -78 6 only if MACH_SCTIMES defined
+mach_sctimes_9 -79 1 only if MACH_SCTIMES defined
+mach_sctimes_10 -80 2 only if MACH_SCTIMES defined
+mach_sctimes_11 -81 2 only if MACH_SCTIMES defined
+mach_sctimes_port_alloc_dealloc -82 1 only if MACH_SCTIMES defined
diff --git a/sys/compat/osf1/README.syscalls b/sys/compat/osf1/README.syscalls
new file mode 100644
index 00000000000..50e08e810f8
--- /dev/null
+++ b/sys/compat/osf1/README.syscalls
@@ -0,0 +1,160 @@
+$NetBSD: README.syscalls,v 1.1 1995/02/13 21:39:03 cgd Exp $
+
+Once the new syscall argument-handling method was implemented, most
+OSF/1 syscalls boiled down to their NetBSD equivalents. The
+differences are detailed in this file.
+
+Note that some OSF/1 syscalls, including some of those that map
+directly to equivalent NetBSD syscalls, are not implemented; they
+were not needed, so the effort to implement and check them was not
+expended.
+
+Finally, there are some OSF/1 syscalls which were left unimplemented,
+but which seem strange enough to merit a bit more explanation.
+
+OSF/1 compatibility is helped by the fact that the sigcontext
+structure was created for NetBSD/Alpha to be the same as the OSF/1
+sigcontext structure. Because of this, only one sendsig() function is
+needed, and the the NetBSD sigreturn() function can be used for OSF/1
+sigreturn(), as well.
+
+The system calls are split out among the three files:
+ osf1_ioctl.c
+ osf1_misc.c
+ osf1_mount.c
+as follows:
+ osf1_ioctl.c contains all osf1_ioctl() handling code.
+ osf1_mount.c contains all code dealing with mounting and
+ unmounting file systems, and with mount points in
+ general (e.g. osf1_getfsstat()).
+ osf1_misc.c contains the rest of the emulation functions.
+
+The emulation functions as follows:
+
+osf1_mknod()
+ dev_t's are different between OSF/1 and NetBSD. In OSF/1 a
+ dev_t has 12 bits of major number and 20 bits of minor number.
+ Under NetBSD, it's 24 bits of major, 8 bits of minor (but the
+ top 16 bits of the major number are unused, and may be
+ rearranged later). In any case, it was decided that the
+ primary use for OSF/1 binaries would be to complement native
+ NetBSD binaries, so file system dev_t's are assumed to be in
+ the NetBSD format, and osf1_mknod() translates from the OSF/1
+ format to the NetBSD format.
+
+osf1_getfsstat()
+ The statfs structure is different between NetBSD and OSF/1,
+ and the way file system types are denoted is different, as
+ well. This routine is the same as getfsstat(), except it
+ converts the statfs structures before returning them to the
+ OSF/1 process.
+
+osf1_lseek()
+ To compensate for quad alignment on 32-bit machines, the
+ NetBSD lseek() needs an extra argument of padding, before the
+ off_t 'offset' argument. This wrapper inserts the padding,
+ and calls the NetBSD routine.
+
+osf1_mount()
+ The file system type specification and the way you specify
+ mount options differs substantially between NetBSD and OSF/1.
+ This routine (and its callees) fakes up NetBSD arguments, and
+ calls the NetBSD routine.
+
+osf1_unmount()
+ Probably not necessary, but safe; translates flags, in case
+ the NetBSD unmount flags ever change.
+
+osf1_exec_with_loader() [UNIMPLEMENTED]
+ From the description in the OSF/1 manual page, this executes a
+ file with a named loader, or "/sbin/loader" if none is named.
+ It appears to be used in some way, when executing dynamically
+ linked binaries, but is _not_ called directly from user space
+ in the normal case. The interface by which it passes the name
+ of the file to be executed, its arguments, etc., to the loader
+ is unspecified, and, from experimental evidence, doesn't seem
+ to be the normal UN*X argument-passing convention (i.e.
+ argc/argv). For proper dynamically linked binary support,
+ this function will probably have to be implemented, but it's
+ unclear how that can be done (short of disassembling a lot of
+ code).
+
+osf1_open()
+ Translates OSF/1 flags to NetBSD flags.
+
+osf1_ioctl()
+ Screens out ioctl requests that aren't known to work, and
+ translates those that differ between NetBSD and OSF/1.
+
+osf1_reboot()
+ Translates OSF/1 flags to NetBSD flags.
+
+osf1_stat()
+ The stat structure differs between NetBSD and OSF/1, both in
+ terms of field sizes, and in the dev_t representation.
+ This does a NetBSD stat(), translates the results, and returns
+ them to the OSF/1 process.
+
+osf1_lstat()
+ Same as osf1_stat(), but for lstat().
+
+osf1_mmap()
+ The NetBSD version needs 4 bytes of padding before the off_t
+ 'pos' argument, and also uses different flags than the OSF/1
+ version. This wrapper translates the flags and deals with the
+ argument struct padding differences, then calls the NetBSD
+ routine.
+
+osf1_fstat()
+ Same as osf1_stat(), but for fstat().
+
+osf1_fcntl()
+ Translates OSF/1 fcntl() requests into their NetBSD
+ counterparts, then calls the NetBSD fcntl() to do the
+ operations.
+
+osf1_socket()
+ Makes sure that the socket type is valid for NetBSD, and if
+ so, calls NetBSD's socket().
+
+osf1_sendto()
+ Makes sure that the 'flags' argument doesn't use flags that
+ NetBSD can't handle, and calls NetBSD's sendto().
+
+osf1_getrlimit()
+ Makes sure that the 'which' selector is one that NetBSD can
+ deal with, and calls NetBSD's getrlimit().
+
+osf1_setrlimit()
+ Same as osf1_getrlimit(), but for setrlimit().
+
+osf1_sigaction()
+ Deals with the differences in the NetBSD and OSF/1 sigaction
+ structures, and calls NetBSD's sigaction with the appropriate
+ arguments. If the call requests that the old sigaction be
+ passed back, osf1_sigaction() translates it back to the OSF/1
+ form, and returns it appropriately.
+
+osf1_statfs()
+ Does that statfs() on the given pathname, then translates the
+ NetBSD statfs structure into the one that OSF/1 uses and
+ returns it. Makes a best effort on the mount type, because
+ there's not a one-to-one mapping between NetBSD and OSF/1
+ mount types.
+
+osf1_fstatfs()
+ Same as osf1_statfs(), but for fstatfs().
+
+osf1_usleep_thread()
+ This function is how sleep() and usleep() (and possibly other
+ functions) are implemented in OSF/1. Its usage was discovered
+ by disassembling the library routines that use it. It takes
+ two pointers to timeval structures as arguments. The first
+ contains the amount of time (in seconds and microseconds) to
+ sleep. If the second pointer is non-null, if the process
+ wakes up early, the amount of time "unslept" is returned. If
+ the process doesn't wake up early, zero is returned.
+
+osf1_setsysinfo()
+ A null-op; used early on, but nothing cares that it actually
+ does anything.
diff --git a/sys/compat/osf1/files.osf1 b/sys/compat/osf1/files.osf1
new file mode 100644
index 00000000000..97585145d11
--- /dev/null
+++ b/sys/compat/osf1/files.osf1
@@ -0,0 +1,14 @@
+# $NetBSD: files.osf1,v 1.2 1995/10/07 06:27:17 mycroft Exp $
+#
+# Config file description for machine-independent OSF/1 compat code.
+# Included by ports that need it.
+
+# ports should define any machine-specific files they need in their
+# own file lists.
+
+file compat/osf1/osf1_ioctl.c compat_osf1
+file compat/osf1/osf1_misc.c compat_osf1
+file compat/osf1/osf1_mount.c compat_osf1
+file compat/osf1/osf1_signal.c compat_osf1
+file compat/osf1/osf1_syscalls.c compat_osf1
+file compat/osf1/osf1_sysent.c compat_osf1
diff --git a/sys/compat/osf1/osf1_ioctl.c b/sys/compat/osf1/osf1_ioctl.c
new file mode 100644
index 00000000000..cdc95f10a76
--- /dev/null
+++ b/sys/compat/osf1/osf1_ioctl.c
@@ -0,0 +1,211 @@
+/* $NetBSD: osf1_ioctl.c,v 1.3 1995/10/07 06:27:19 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/ioctl.h>
+#include <sys/termios.h>
+
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <compat/osf1/osf1_syscallargs.h>
+
+#ifdef SYSCALL_DEBUG
+extern int scdebug;
+#endif
+
+#define OSF1_IOCPARM_MASK 0x1fff /* parameter length, at most 13 bits */
+#define OSF1_IOCPARM_LEN(x) (((x) >> 16) & OSF1_IOCPARM_MASK)
+#define OSF1_IOCGROUP(x) (((x) >> 8) & 0xff)
+
+#define OSF1_IOCPARM_MAX NBPG /* max size of ioctl */
+#define OSF1_IOC_VOID 0x20000000 /* no parameters */
+#define OSF1_IOC_OUT 0x40000000 /* copy out parameters */
+#define OSF1_IOC_IN 0x80000000 /* copy in parameters */
+#define OSF1_IOC_INOUT (OSF1_IOC_IN|OSF1_IOC_OUT)
+#define OSF1_IOC_DIRMASK 0xe0000000 /* mask for IN/OUT/VOID */
+
+#define OSF1_IOCCMD(x) ((x) & 0xff)
+
+int osf1_ioctl_i __P((struct proc *p, struct sys_ioctl_args *nuap,
+ register_t *retval, int cmd, int dir, int len));
+int osf1_ioctl_t __P((struct proc *p, struct sys_ioctl_args *nuap,
+ register_t *retval, int cmd, int dir, int len));
+
+int
+osf1_sys_ioctl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_ioctl_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) com;
+ syscallarg(caddr_t) data;
+ } */ *uap = v;
+ struct sys_ioctl_args /* {
+ syscallarg(int) fd;
+ syscallarg(u_long) com;
+ syscallarg(caddr_t) data;
+ } */ a;
+ int op, dir, group, cmd, len;
+#ifdef SYSCALL_DEBUG
+ char *dirstr;
+#endif
+
+ op = SCARG(uap, com);
+ dir = op & OSF1_IOC_DIRMASK;
+ group = OSF1_IOCGROUP(op);
+ cmd = OSF1_IOCCMD(op);
+ len = OSF1_IOCPARM_LEN(op);
+
+ switch (dir) {
+ case OSF1_IOC_VOID:
+ dir = IOC_VOID;
+#ifdef SYSCALL_DEBUG
+ dirstr = "none";
+#endif
+ break;
+ case OSF1_IOC_OUT:
+ dir = IOC_OUT;
+#ifdef SYSCALL_DEBUG
+ dirstr = "out";
+#endif
+ break;
+ case OSF1_IOC_IN:
+ dir = IOC_IN;
+#ifdef SYSCALL_DEBUG
+ dirstr = "in";
+#endif
+ break;
+ case OSF1_IOC_INOUT:
+ dir = IOC_INOUT;
+#ifdef SYSCALL_DEBUG
+ dirstr = "in-out";
+#endif
+ break;
+ default:
+ return (EINVAL);
+ break;
+ }
+#ifdef SYSCALL_DEBUG
+ if (scdebug)
+ printf(
+ "OSF/1 IOCTL: group = %c, cmd = %d, len = %d, dir = %s\n",
+ group, cmd, len, dirstr);
+#endif
+
+ SCARG(&a, fd) = SCARG(uap, fd);
+ SCARG(&a, com) = SCARG(uap, com);
+ SCARG(&a, data) = SCARG(uap, data);
+ switch (group) {
+ case 'i':
+ return osf1_ioctl_i(p, &a, retval, cmd, dir, len);
+ case 't':
+ return osf1_ioctl_t(p, &a, retval, cmd, dir, len);
+ default:
+ return (ENOTTY);
+ }
+}
+
+int
+osf1_ioctl_i(p, uap, retval, cmd, dir, len)
+ struct proc *p;
+ struct sys_ioctl_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) com;
+ syscallarg(caddr_t) data;
+ } */ *uap;
+ register_t *retval;
+ int cmd;
+ int dir;
+ int len;
+{
+
+ switch (cmd) {
+ case 12: /* OSF/1 SIOCSIFADDR */
+ case 14: /* OSF/1 SIOCSIFDSTADDR */
+ case 16: /* OSF/1 SIOCSIFFLAGS (XXX) */
+ case 17: /* OSF/1 SIOCGIFFLAGS (XXX) */
+ case 19: /* OSF/1 SIOCSIFBRDADDR */
+ case 22: /* OSF/1 SIOCSIFNETMASK */
+ case 23: /* OSF/1 SIOCGIFMETRIC */
+ case 24: /* OSF/1 SIOCSIFMETRIC */
+ case 25: /* OSF/1 SIOCDIFADDR */
+ case 33: /* OSF/1 SIOCGIFADDR */
+ case 34: /* OSF/1 SIOCGIFDSTADDR */
+ case 35: /* OSF/1 SIOCGIFBRDADDR */
+ case 37: /* OSF/1 SIOCGIFNETMASK */
+ /* same as in NetBSD */
+ break;
+
+ default:
+ return (ENOTTY);
+ }
+
+ return sys_ioctl(p, uap, retval);
+}
+
+int
+osf1_ioctl_t(p, uap, retval, cmd, dir, len)
+ struct proc *p;
+ struct sys_ioctl_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) com;
+ syscallarg(caddr_t) data;
+ } */ *uap;
+ register_t *retval;
+ int cmd;
+ int dir;
+ int len;
+{
+
+ switch (cmd) {
+#ifdef COMPAT_43
+ case 8: /* OSF/1 COMPAT_43 TIOCGETP (XXX) */
+ case 9: /* OSF/1 COMPAT_43 TIOCSETP (XXX) */
+#endif
+ case 19: /* OSF/1 TIOCGETA (XXX) */
+ case 20: /* OSF/1 TIOCSETA (XXX) */
+ case 21: /* OSF/1 TIOCSETAW (XXX) */
+ case 22: /* OSF/1 TIOCSETAF (XXX) */
+ case 26: /* OSF/1 TIOCGETD (XXX) */
+ case 27: /* OSF/1 TIOCSETD (XXX) */
+ case 97: /* OSF/1 TIOCSCTTY */
+ case 103: /* OSF/1 TIOCSWINSZ */
+ case 104: /* OSF/1 TIOCGWINSZ */
+ /* same as in NetBSD */
+ break;
+
+ default:
+ return (ENOTTY);
+ }
+
+ return sys_ioctl(p, uap, retval);
+}
diff --git a/sys/compat/osf1/osf1_misc.c b/sys/compat/osf1/osf1_misc.c
new file mode 100644
index 00000000000..19df0d2d95c
--- /dev/null
+++ b/sys/compat/osf1/osf1_misc.c
@@ -0,0 +1,937 @@
+/* $NetBSD: osf1_misc.c,v 1.7 1995/10/07 06:53:04 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/reboot.h>
+#include <sys/syscallargs.h>
+
+#include <compat/osf1/osf1_syscall.h>
+#include <compat/osf1/osf1_syscallargs.h>
+#include <compat/osf1/osf1_util.h>
+
+#include <vm/vm.h>
+
+#ifdef SYSCALL_DEBUG
+extern int scdebug;
+#endif
+
+extern struct sysent osf1_sysent[];
+extern char *osf1_syscallnames[];
+extern void cpu_exec_ecoff_setregs __P((struct proc *, struct exec_package *,
+ u_long, register_t *));
+
+extern char sigcode[], esigcode[];
+
+struct emul emul_osf1 = {
+ "osf1",
+ NULL,
+ sendsig,
+ OSF1_SYS_syscall,
+ OSF1_SYS_MAXSYSCALL,
+ osf1_sysent,
+ osf1_syscallnames,
+ 0,
+ copyargs,
+ cpu_exec_ecoff_setregs,
+ sigcode,
+ esigcode,
+};
+
+int
+osf1_sys_open(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_open_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+ } */ *uap = v;
+ struct sys_open_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+ } */ a;
+#ifdef SYSCALL_DEBUG
+ char pnbuf[1024];
+
+ if (scdebug &&
+ copyinstr(SCARG(uap, path), pnbuf, sizeof pnbuf, NULL) == 0)
+ printf("osf1_open: open: %s\n", pnbuf);
+#endif
+
+ SCARG(&a, path) = SCARG(uap, path);
+ SCARG(&a, flags) = SCARG(uap, flags); /* XXX translate */
+ SCARG(&a, mode) = SCARG(uap, mode);
+
+ return sys_open(p, &a, retval);
+}
+
+int
+osf1_sys_setsysinfo(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_setsysinfo_args /* {
+ syscallarg(u_long) op;
+ syscallarg(caddr_t) buffer;
+ syscallarg(u_long) nbytes;
+ syscallarg(caddr_t) arg;
+ syscallarg(u_long) flag;
+ } */ *uap = v;
+
+ return (0);
+}
+
+#define OSF1_RLIMIT_LASTCOMMON 5 /* last one that's common */
+#define OSF1_RLIMIT_NOFILE 6 /* OSF1's RLIMIT_NOFILE */
+#define OSF1_RLIMIT_NLIMITS 8 /* Number of OSF1 rlimits */
+
+osf1_sys_getrlimit(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_getrlimit_args /* {
+ syscallarg(u_int) which;
+ syscallarg(struct rlimit *) rlp;
+ } */ *uap = v;
+ struct sys_getrlimit_args /* {
+ syscallarg(u_int) which;
+ syscallarg(struct rlimit *) rlp;
+ } */ a;
+
+ if (SCARG(uap, which) >= OSF1_RLIMIT_NLIMITS)
+ return (EINVAL);
+
+ if (SCARG(uap, which) <= OSF1_RLIMIT_LASTCOMMON)
+ SCARG(&a, which) = SCARG(uap, which);
+ else if (SCARG(uap, which) == OSF1_RLIMIT_NOFILE)
+ SCARG(&a, which) = RLIMIT_NOFILE;
+ else
+ return (0);
+ SCARG(&a, rlp) = SCARG(uap, rlp);
+
+ return sys_getrlimit(p, &a, retval);
+}
+
+osf1_sys_setrlimit(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_setrlimit_args /* {
+ syscallarg(u_int) which;
+ syscallarg(struct rlimit *) rlp;
+ } */ *uap = v;
+ struct sys_setrlimit_args /* {
+ syscallarg(u_int) which;
+ syscallarg(struct rlimit *) rlp;
+ } */ a;
+
+ if (SCARG(uap, which) >= OSF1_RLIMIT_NLIMITS)
+ return (EINVAL);
+
+ if (SCARG(uap, which) <= OSF1_RLIMIT_LASTCOMMON)
+ SCARG(&a, which) = SCARG(uap, which);
+ else if (SCARG(uap, which) == OSF1_RLIMIT_NOFILE)
+ SCARG(&a, which) = RLIMIT_NOFILE;
+ else
+ return (0);
+ SCARG(&a, rlp) = SCARG(uap, rlp);
+
+ return sys_setrlimit(p, &a, retval);
+}
+
+#define OSF1_MAP_SHARED 0x001
+#define OSF1_MAP_PRIVATE 0x002
+#define OSF1_MAP_ANONYMOUS 0x010
+#define OSF1_MAP_FILE 0x000
+#define OSF1_MAP_TYPE 0x0f0
+#define OSF1_MAP_FIXED 0x100
+#define OSF1_MAP_HASSEMAPHORE 0x200
+#define OSF1_MAP_INHERIT 0x400
+#define OSF1_MAP_UNALIGNED 0x800
+
+int
+osf1_sys_mmap(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_mmap_args /* {
+ syscallarg(caddr_t) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) prot;
+ syscallarg(int) flags;
+ syscallarg(int) fd;
+ syscallarg(off_t) pos;
+ } */ *uap = v;
+ struct sys_mmap_args /* {
+ syscallarg(caddr_t) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) prot;
+ syscallarg(int) flags;
+ syscallarg(int) fd;
+ syscallarg(long) pad;
+ syscallarg(off_t) pos;
+ } */ a;
+
+ SCARG(&a, addr) = SCARG(uap, addr);
+ SCARG(&a, len) = SCARG(uap, len);
+ SCARG(&a, prot) = SCARG(uap, prot);
+ SCARG(&a, fd) = SCARG(uap, fd);
+ SCARG(&a, pad) = 0;
+ SCARG(&a, pos) = SCARG(uap, pos);
+
+ SCARG(&a, flags) = 0;
+ if (SCARG(uap, flags) & OSF1_MAP_SHARED)
+ SCARG(&a, flags) |= MAP_SHARED;
+ if (SCARG(uap, flags) & OSF1_MAP_PRIVATE)
+ SCARG(&a, flags) |= MAP_PRIVATE;
+ switch (SCARG(uap, flags) & OSF1_MAP_TYPE) {
+ case OSF1_MAP_ANONYMOUS:
+ SCARG(&a, flags) |= MAP_ANON;
+ break;
+ case OSF1_MAP_FILE:
+ SCARG(&a, flags) |= MAP_FILE;
+ break;
+ default:
+ return (EINVAL);
+ }
+ if (SCARG(uap, flags) & OSF1_MAP_FIXED)
+ SCARG(&a, flags) |= MAP_FIXED;
+ if (SCARG(uap, flags) & OSF1_MAP_HASSEMAPHORE)
+ SCARG(&a, flags) |= MAP_HASSEMAPHORE;
+ if (SCARG(uap, flags) & OSF1_MAP_INHERIT)
+ SCARG(&a, flags) |= MAP_INHERIT;
+ if (SCARG(uap, flags) & OSF1_MAP_UNALIGNED)
+ return (EINVAL);
+
+ return sys_mmap(p, &a, retval);
+}
+
+int
+osf1_sys_usleep_thread(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_usleep_thread_args /* {
+ syscallarg(struct timeval *) sleep;
+ syscallarg(struct timeval *) slept;
+ } */ *uap = v;
+ struct timeval tv, endtv;
+ u_long ticks;
+ int error, s;
+
+ if (error = copyin(SCARG(uap, sleep), &tv, sizeof tv))
+ return (error);
+
+ ticks = ((u_long)tv.tv_sec * 1000000 + tv.tv_usec) / tick;
+ s = splclock();
+ tv = time;
+ splx(s);
+
+ tsleep(p, PUSER|PCATCH, "OSF/1", ticks); /* XXX */
+
+ if (SCARG(uap, slept) != NULL) {
+ s = splclock();
+ timersub(&time, &tv, &endtv);
+ splx(s);
+ if (tv.tv_sec < 0 || tv.tv_usec < 0)
+ tv.tv_sec = tv.tv_usec = 0;
+
+ error = copyout(&endtv, SCARG(uap, slept), sizeof endtv);
+ }
+ return (error);
+}
+
+struct osf1_stat {
+ int32_t st_dev;
+ u_int32_t st_ino;
+ u_int32_t st_mode;
+ u_int16_t st_nlink;
+ u_int32_t st_uid;
+ u_int32_t st_gid;
+ int32_t st_rdev;
+ u_int64_t st_size;
+ int32_t st_atime_sec;
+ int32_t st_spare1;
+ int32_t st_mtime_sec;
+ int32_t st_spare2;
+ int32_t st_ctime_sec;
+ int32_t st_spare3;
+ u_int32_t st_blksize;
+ int32_t st_blocks;
+ u_int32_t st_flags;
+ u_int32_t st_gen;
+};
+
+/*
+ * Get file status; this version follows links.
+ */
+/* ARGSUSED */
+osf1_sys_stat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct osf1_sys_stat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct osf1_stat *) ub;
+ } */ *uap = v;
+ struct stat sb;
+ struct osf1_stat osb;
+ int error;
+ struct nameidata nd;
+
+ NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
+ SCARG(uap, path), p);
+ if (error = namei(&nd))
+ return (error);
+ error = vn_stat(nd.ni_vp, &sb, p);
+ vput(nd.ni_vp);
+ if (error)
+ return (error);
+ cvtstat2osf1(&sb, &osb);
+ error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb));
+ return (error);
+}
+
+/*
+ * Get file status; this version does not follow links.
+ */
+/* ARGSUSED */
+osf1_sys_lstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct osf1_sys_lstat_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct osf1_stat *) ub;
+ } */ *uap = v;
+ struct stat sb;
+ struct osf1_stat osb;
+ int error;
+ struct nameidata nd;
+
+ NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF, UIO_USERSPACE,
+ SCARG(uap, path), p);
+ if (error = namei(&nd))
+ return (error);
+ error = vn_stat(nd.ni_vp, &sb, p);
+ vput(nd.ni_vp);
+ if (error)
+ return (error);
+ cvtstat2osf1(&sb, &osb);
+ error = copyout((caddr_t)&osb, (caddr_t)SCARG(uap, ub), sizeof (osb));
+ return (error);
+}
+
+/*
+ * Return status information about a file descriptor.
+ */
+osf1_sys_fstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct osf1_sys_fstat_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct osf1_stat *) sb;
+ } */ *uap = v;
+ register struct filedesc *fdp = p->p_fd;
+ register struct file *fp;
+ struct stat ub;
+ struct osf1_stat oub;
+ int error;
+
+ if ((unsigned)SCARG(uap, fd) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
+ return (EBADF);
+ switch (fp->f_type) {
+
+ case DTYPE_VNODE:
+ error = vn_stat((struct vnode *)fp->f_data, &ub, p);
+ break;
+
+ case DTYPE_SOCKET:
+ error = soo_stat((struct socket *)fp->f_data, &ub);
+ break;
+
+ default:
+ panic("ofstat");
+ /*NOTREACHED*/
+ }
+ cvtstat2osf1(&ub, &oub);
+ if (error == 0)
+ error = copyout((caddr_t)&oub, (caddr_t)SCARG(uap, sb),
+ sizeof (oub));
+ return (error);
+}
+
+#define bsd2osf_dev(dev) (major(dev) << 20 | minor(dev))
+#define osf2bsd_dev(dev) makedev((dev >> 20) & 0xfff, dev & 0xfffff)
+
+/*
+ * Convert from a stat structure to an osf1 stat structure.
+ */
+cvtstat2osf1(st, ost)
+ struct stat *st;
+ struct osf1_stat *ost;
+{
+
+ ost->st_dev = bsd2osf_dev(st->st_dev);
+ ost->st_ino = st->st_ino;
+ ost->st_mode = st->st_mode;
+ ost->st_nlink = st->st_nlink;
+ ost->st_uid = st->st_uid == -2 ? (u_int16_t) -2 : st->st_uid;
+ ost->st_gid = st->st_gid == -2 ? (u_int16_t) -2 : st->st_gid;
+ ost->st_rdev = bsd2osf_dev(st->st_rdev);
+ ost->st_size = st->st_size;
+ ost->st_atime_sec = st->st_atime;
+ ost->st_spare1 = 0;
+ ost->st_mtime_sec = st->st_mtime;
+ ost->st_spare2 = 0;
+ ost->st_ctime_sec = st->st_ctime;
+ ost->st_spare3 = 0;
+ ost->st_blksize = st->st_blksize;
+ ost->st_blocks = st->st_blocks;
+ ost->st_flags = st->st_flags;
+ ost->st_gen = st->st_gen;
+}
+
+int
+osf1_sys_mknod(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_mknod_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ syscallarg(int) dev;
+ } */ *uap = v;
+ struct sys_mknod_args a;
+
+ SCARG(&a, path) = SCARG(uap, path);
+ SCARG(&a, mode) = SCARG(uap, mode);
+ SCARG(&a, dev) = osf2bsd_dev(SCARG(uap, dev));
+
+ return sys_mknod(p, &a, retval);
+}
+
+#define OSF1_F_DUPFD 0
+#define OSF1_F_GETFD 1
+#define OSF1_F_SETFD 2
+#define OSF1_F_GETFL 3
+#define OSF1_F_SETFL 4
+
+#define OSF1_FAPPEND 0x00008 /* XXX OSF1_O_APPEND */
+#define OSF1_FNONBLOCK 0x00004 /* XXX OSF1_O_NONBLOCK */
+#define OSF1_FASYNC 0x00040
+#define OSF1_FSYNC 0x04000 /* XXX OSF1_O_SYNC */
+
+int
+osf1_sys_fcntl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_fcntl_args /* {
+ syscallarg(int) fd;
+ syscallarg(int) cmd;
+ syscallarg(void *) arg;
+ } */ *uap = v;
+ struct sys_fcntl_args a;
+ long tmp;
+ int error;
+
+ SCARG(&a, fd) = SCARG(uap, fd);
+
+ switch (SCARG(uap, cmd)) {
+ case OSF1_F_DUPFD:
+ SCARG(&a, cmd) = F_DUPFD;
+ SCARG(&a, arg) = SCARG(uap, arg);
+ break;
+
+ case OSF1_F_GETFD:
+ SCARG(&a, cmd) = F_GETFD;
+ SCARG(&a, arg) = SCARG(uap, arg);
+ break;
+
+ case OSF1_F_SETFD:
+ SCARG(&a, cmd) = F_SETFD;
+ SCARG(&a, arg) = SCARG(uap, arg);
+ break;
+
+ case OSF1_F_GETFL:
+ SCARG(&a, cmd) = F_GETFL;
+ SCARG(&a, arg) = SCARG(uap, arg); /* ignored */
+ break;
+
+ case OSF1_F_SETFL:
+ SCARG(&a, cmd) = F_SETFL;
+ tmp = 0;
+ if ((long)SCARG(uap, arg) & OSF1_FAPPEND)
+ tmp |= FAPPEND;
+ if ((long)SCARG(uap, arg) & OSF1_FNONBLOCK)
+ tmp |= FNONBLOCK;
+ if ((long)SCARG(uap, arg) & OSF1_FASYNC)
+ tmp |= FASYNC;
+ if ((long)SCARG(uap, arg) & OSF1_FSYNC)
+ tmp |= FFSYNC;
+ SCARG(&a, arg) = (void *)tmp;
+ break;
+
+ default: /* XXX other cases */
+ return (EINVAL);
+ }
+
+ error = sys_fcntl(p, &a, retval);
+
+ if (error)
+ return error;
+
+ switch (SCARG(uap, cmd)) {
+ case OSF1_F_GETFL:
+ /* XXX */
+ break;
+ }
+
+ return error;
+}
+
+int
+osf1_sys_socket(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct osf1_sys_socket_args /* {
+ syscallarg(int) domain;
+ syscallarg(int) type;
+ syscallarg(int) protocol;
+ } */ *uap = v;
+ struct sys_socket_args a;
+
+ if (SCARG(uap, type) > AF_LINK)
+ return (EINVAL); /* XXX After AF_LINK, divergence. */
+
+ SCARG(&a, domain) = SCARG(uap, domain);
+ SCARG(&a, type) = SCARG(uap, type);
+ SCARG(&a, protocol) = SCARG(uap, protocol);
+
+ return sys_socket(p, &a, retval);
+}
+
+int
+osf1_sys_sendto(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct osf1_sys_sendto_args /* {
+ syscallarg(int) s;
+ syscallarg(caddr_t) buf;
+ syscallarg(size_t) len;
+ syscallarg(int) flags;
+ syscallarg(caddr_t) to;
+ syscallarg(int) tolen;
+ } */ *uap = v;
+ struct sys_sendto_args a;
+
+ if (SCARG(uap, flags) & ~0x7f) /* unsupported flags */
+ return (EINVAL);
+
+ SCARG(&a, s) = SCARG(uap, s);
+ SCARG(&a, buf) = SCARG(uap, buf);
+ SCARG(&a, len) = SCARG(uap, len);
+ SCARG(&a, flags) = SCARG(uap, flags);
+ SCARG(&a, to) = SCARG(uap, to);
+ SCARG(&a, tolen) = SCARG(uap, tolen);
+
+ return sys_sendto(p, &a, retval);
+}
+
+#define OSF1_RB_ASKNAME 0x001
+#define OSF1_RB_SINGLE 0x002
+#define OSF1_RB_NOSYNC 0x004
+#define OSF1_RB_HALT 0x008
+#define OSF1_RB_INITNAME 0x010
+#define OSF1_RB_DFLTROOT 0x020
+#define OSF1_RB_ALTBOOT 0x040
+#define OSF1_RB_UNIPROC 0x080
+#define OSF1_RB_ALLFLAGS 0x0ff /* all of the above */
+
+int
+osf1_sys_reboot(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_reboot_args /* {
+ syscallarg(int) opt;
+ } */ *uap = v;
+ struct sys_reboot_args a;
+
+ if (SCARG(uap, opt) & ~OSF1_RB_ALLFLAGS &&
+ SCARG(uap, opt) & (OSF1_RB_ALTBOOT|OSF1_RB_UNIPROC))
+ return (EINVAL);
+
+ SCARG(&a, opt) = 0;
+ if (SCARG(uap, opt) & OSF1_RB_ASKNAME)
+ SCARG(&a, opt) |= RB_ASKNAME;
+ if (SCARG(uap, opt) & OSF1_RB_SINGLE)
+ SCARG(&a, opt) |= RB_SINGLE;
+ if (SCARG(uap, opt) & OSF1_RB_NOSYNC)
+ SCARG(&a, opt) |= RB_NOSYNC;
+ if (SCARG(uap, opt) & OSF1_RB_HALT)
+ SCARG(&a, opt) |= RB_HALT;
+ if (SCARG(uap, opt) & OSF1_RB_INITNAME)
+ SCARG(&a, opt) |= RB_INITNAME;
+ if (SCARG(uap, opt) & OSF1_RB_DFLTROOT)
+ SCARG(&a, opt) |= RB_DFLTROOT;
+
+ return sys_reboot(p, &a, retval);
+}
+
+int
+osf1_sys_lseek(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_lseek_args /* {
+ syscallarg(int) fd;
+ syscallarg(off_t) offset;
+ syscallarg(int) whence;
+ } */ *uap = v;
+ struct sys_lseek_args a;
+
+ SCARG(&a, fd) = SCARG(uap, fd);
+ SCARG(&a, pad) = 0;
+ SCARG(&a, offset) = SCARG(uap, offset);
+ SCARG(&a, whence) = SCARG(uap, whence);
+
+ return sys_lseek(p, &a, retval);
+}
+
+/*
+ * OSF/1 defines _POSIX_SAVED_IDS, which means that our normal
+ * setuid() won't work.
+ *
+ * Instead, by P1003.1b-1993, setuid() is supposed to work like:
+ * If the process has appropriate [super-user] priviledges, the
+ * setuid() function sets the real user ID, effective user
+ * ID, and the saved set-user-ID to uid.
+ * If the process does not have appropriate priviledges, but uid
+ * is equal to the real user ID or the saved set-user-ID, the
+ * setuid() function sets the effective user ID to uid; the
+ * real user ID and saved set-user-ID remain unchanged by
+ * this function call.
+ */
+int
+osf1_sys_setuid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_setuid_args /* {
+ syscallargs(uid_t) uid;
+ } */ *uap = v;
+ register struct pcred *pc = p->p_cred;
+ uid_t uid = SCARG(uap, uid);
+ int error;
+
+ if ((error = suser(pc->pc_ucred, &p->p_acflag)) != 0 &&
+ uid != pc->p_ruid && uid != pc->p_svuid)
+ return (error);
+
+ pc->pc_ucred = crcopy(pc->pc_ucred);
+ pc->pc_ucred->cr_uid = uid;
+ if (error == 0) {
+ (void)chgproccnt(pc->p_ruid, -1);
+ (void)chgproccnt(uid, 1);
+ pc->p_ruid = uid;
+ pc->p_svuid = uid;
+ }
+ p->p_flag |= P_SUGID;
+ return (0);
+}
+
+/*
+ * OSF/1 defines _POSIX_SAVED_IDS, which means that our normal
+ * setgid() won't work.
+ *
+ * If you change "uid" to "gid" in the discussion, above, about
+ * setuid(), you'll get a correct description of setgid().
+ */
+int
+osf1_sys_setgid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_setgid_args /* {
+ syscallargs(gid_t) gid;
+ } */ *uap = v;
+ register struct pcred *pc = p->p_cred;
+ gid_t gid = SCARG(uap, gid);
+ int error;
+
+ if ((error = suser(pc->pc_ucred, &p->p_acflag)) != 0 &&
+ gid != pc->p_rgid && gid != pc->p_svgid)
+ return (error);
+
+ pc->pc_ucred = crcopy(pc->pc_ucred);
+ pc->pc_ucred->cr_gid = gid;
+ if (error == 0) {
+ pc->p_rgid = gid;
+ pc->p_svgid = gid;
+ }
+ p->p_flag |= P_SUGID;
+ return (0);
+}
+
+/*
+ * The structures end up being the same... but we can't be sure that
+ * the other word of our iov_len is zero!
+ */
+struct osf1_iovec {
+ char *iov_base;
+ int iov_len;
+};
+
+int
+osf1_sys_readv(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_readv_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct osf1_iovec *) iovp;
+ syscallarg(u_int) iovcnt;
+ } */ *uap = v;
+ struct sys_readv_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct iovec *) iovp;
+ syscallarg(u_int) iovcnt;
+ } */ a;
+ struct emul *e = p->p_emul;
+ struct osf1_iovec *oio;
+ struct iovec *nio;
+ int error, i;
+ extern char sigcode[], esigcode[];
+
+ if (SCARG(uap, iovcnt) > (STACKGAPLEN / sizeof (struct iovec)))
+ return (EINVAL);
+
+ oio = (struct osf1_iovec *)
+ malloc(SCARG(uap, iovcnt)*sizeof (struct osf1_iovec),
+ M_TEMP, M_WAITOK);
+ nio = (struct iovec *)malloc(SCARG(uap, iovcnt)*sizeof (struct iovec),
+ M_TEMP, M_WAITOK);
+
+ error = 0;
+ if (error = copyin(SCARG(uap, iovp), oio,
+ SCARG(uap, iovcnt) * sizeof (struct osf1_iovec)))
+ goto punt;
+ for (i = 0; i < SCARG(uap, iovcnt); i++) {
+ nio[i].iov_base = oio[i].iov_base;
+ nio[i].iov_len = oio[i].iov_len;
+ }
+
+ SCARG(&a, fd) = SCARG(uap, fd);
+ SCARG(&a, iovp) = (struct iovec *)STACKGAPBASE;
+ SCARG(&a, iovcnt) = SCARG(uap, iovcnt);
+
+ if (error = copyout(nio, (caddr_t)SCARG(&a, iovp),
+ SCARG(uap, iovcnt) * sizeof (struct iovec)))
+ goto punt;
+ error = sys_readv(p, &a, retval);
+
+punt:
+ free(oio, M_TEMP);
+ free(nio, M_TEMP);
+ return (error);
+}
+
+int
+osf1_sys_writev(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_writev_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct osf1_iovec *) iovp;
+ syscallarg(u_int) iovcnt;
+ } */ *uap = v;
+ struct sys_writev_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct iovec *) iovp;
+ syscallarg(u_int) iovcnt;
+ } */ a;
+ struct emul *e = p->p_emul;
+ struct osf1_iovec *oio;
+ struct iovec *nio;
+ int error, i;
+ extern char sigcode[], esigcode[];
+
+ if (SCARG(uap, iovcnt) > (STACKGAPLEN / sizeof (struct iovec)))
+ return (EINVAL);
+
+ oio = (struct osf1_iovec *)
+ malloc(SCARG(uap, iovcnt)*sizeof (struct osf1_iovec),
+ M_TEMP, M_WAITOK);
+ nio = (struct iovec *)malloc(SCARG(uap, iovcnt)*sizeof (struct iovec),
+ M_TEMP, M_WAITOK);
+
+ error = 0;
+ if (error = copyin(SCARG(uap, iovp), oio,
+ SCARG(uap, iovcnt) * sizeof (struct osf1_iovec)))
+ goto punt;
+ for (i = 0; i < SCARG(uap, iovcnt); i++) {
+ nio[i].iov_base = oio[i].iov_base;
+ nio[i].iov_len = oio[i].iov_len;
+ }
+
+ SCARG(&a, fd) = SCARG(uap, fd);
+ SCARG(&a, iovp) = (struct iovec *)STACKGAPBASE;
+ SCARG(&a, iovcnt) = SCARG(uap, iovcnt);
+
+ if (error = copyout(nio, (caddr_t)SCARG(&a, iovp),
+ SCARG(uap, iovcnt) * sizeof (struct iovec)))
+ goto punt;
+ error = sys_writev(p, &a, retval);
+
+punt:
+ free(oio, M_TEMP);
+ free(nio, M_TEMP);
+ return (error);
+}
+
+/* More of the stupid off_t padding! */
+int
+osf1_sys_truncate(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_truncate_args /* {
+ syscallarg(char *) path;
+ syscallarg(off_t) length;
+ } */ *uap = v;
+ struct sys_truncate_args a;
+
+ SCARG(&a, path) = SCARG(uap, path);
+ SCARG(&a, pad) = 0;
+ SCARG(&a, length) = SCARG(uap, length);
+
+ return sys_truncate(p, &a, retval);
+}
+
+int
+osf1_sys_ftruncate(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_ftruncate_args /* {
+ syscallarg(int) fd;
+ syscallarg(off_t) length;
+ } */ *uap = v;
+ struct sys_ftruncate_args a;
+
+ SCARG(&a, fd) = SCARG(uap, fd);
+ SCARG(&a, pad) = 0;
+ SCARG(&a, length) = SCARG(uap, length);
+
+ return sys_ftruncate(p, &a, retval);
+}
+
+int
+osf1_sys_getsid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_getsid_args /* {
+ syscallarg(pid_t) pid;
+ } */ *uap = v;
+ struct proc *t;
+
+ if (SCARG(uap, pid) == 0)
+ t = p;
+ else if ((t = pfind(SCARG(uap, pid))) == NULL)
+ return (ESRCH);
+
+ *retval = t->p_session->s_leader->p_pid;
+ return (0);
+}
+
+int
+osf1_sys_getrusage(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+
+ /* XXX */
+ return EINVAL;
+}
+
+int
+osf1_sys_madvise(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+
+ /* XXX */
+ return EINVAL;
+}
diff --git a/sys/compat/osf1/osf1_mount.c b/sys/compat/osf1/osf1_mount.c
new file mode 100644
index 00000000000..b02a42bf700
--- /dev/null
+++ b/sys/compat/osf1/osf1_mount.c
@@ -0,0 +1,479 @@
+/* $NetBSD: osf1_mount.c,v 1.5 1995/10/07 06:27:24 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1994, 1995 Carnegie-Mellon University.
+ * All rights reserved.
+ *
+ * Author: Chris G. Demetriou
+ *
+ * Permission to use, copy, modify and distribute this software and
+ * its documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
+ * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
+ *
+ * Carnegie Mellon requests users of this software to return to
+ *
+ * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
+ * School of Computer Science
+ * Carnegie Mellon University
+ * Pittsburgh PA 15213-3890
+ *
+ * any improvements or extensions that they make and grant Carnegie the
+ * rights to redistribute these changes.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/vnode.h>
+#include <sys/syscallargs.h>
+
+#include <compat/osf1/osf1_syscallargs.h>
+#include <compat/osf1/osf1_util.h>
+
+#include <net/if.h>
+#include <netinet/in.h>
+
+#include <machine/vmparam.h>
+
+/* File system type numbers. */
+#define OSF1_MOUNT_NONE 0
+#define OSF1_MOUNT_UFS 1
+#define OSF1_MOUNT_NFS 2
+#define OSF1_MOUNT_MFS 3
+#define OSF1_MOUNT_PC 4
+#define OSF1_MOUNT_S5FS 5
+#define OSF1_MOUNT_CDFS 6
+#define OSF1_MOUNT_DFS 7
+#define OSF1_MOUNT_EFS 8
+#define OSF1_MOUNT_PROCFS 9
+#define OSF1_MOUNT_MSFS 10
+#define OSF1_MOUNT_FFM 11
+#define OSF1_MOUNT_FDFS 12
+#define OSF1_MOUNT_ADDON 13
+#define OSF1_MOUNT_MAXTYPE OSF1_MOUNT_ADDON
+
+#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)
+
+struct osf1_statfs {
+ int16_t f_type; /* 0 */
+ int16_t f_flags; /* 2 */
+ int32_t f_fsize; /* 4 */
+ int32_t f_bsize; /* 8 */
+ int32_t f_blocks; /* 12 */
+ int32_t f_bfree; /* 16 */
+ int32_t f_bavail; /* 20 */
+ int32_t f_files; /* 24 */
+ int32_t f_ffree; /* 28 */
+ int64_t f_fsid; /* 32 */
+ int32_t f_spare[9]; /* 40 (36 bytes) */
+ char f_mntonname[90]; /* 76 (90 bytes) */
+ char f_mntfromname[90]; /* 166 (90 bytes) */
+ char f_xxx[80]; /* 256 (80 bytes) XXX */
+};
+
+/* Arguments to mount() for various FS types. */
+#ifdef notyet /* XXX */
+struct osf1_ufs_args {
+ char *fspec;
+ int32_t exflags;
+ u_int32_t exroot;
+};
+
+struct osf1_cdfs_args {
+ char *fspec;
+ int32_t exflags;
+ u_int32_t exroot;
+ int32_t flags;
+};
+#endif
+
+struct osf1_mfs_args {
+ char *name;
+ caddr_t base;
+ u_int size;
+};
+
+struct osf1_nfs_args {
+ struct sockaddr_in *addr;
+ nfsv2fh_t *fh;
+ int32_t flags;
+ int32_t wsize;
+ int32_t rsize;
+ int32_t timeo;
+ int32_t retrans;
+ char *hostname;
+ int32_t acregmin;
+ int32_t acregmax;
+ int32_t acdirmin;
+ int32_t acdirmax;
+ char *netname;
+ void *pathconf;
+};
+
+#define OSF1_NFSMNT_SOFT 0x00001
+#define OSF1_NFSMNT_WSIZE 0x00002
+#define OSF1_NFSMNT_RSIZE 0x00004
+#define OSF1_NFSMNT_TIMEO 0x00008
+#define OSF1_NFSMNT_RETRANS 0x00010
+#define OSF1_NFSMNT_HOSTNAME 0x00020
+#define OSF1_NFSMNT_INT 0x00040
+#define OSF1_NFSMNT_NOCONN 0x00080
+#define OSF1_NFSMNT_NOAC 0x00100 /* ??? */
+#define OSF1_NFSMNT_ACREGMIN 0x00200 /* ??? */
+#define OSF1_NFSMNT_ACREGMAX 0x00400 /* ??? */
+#define OSF1_NFSMNT_ACDIRMIN 0x00800 /* ??? */
+#define OSF1_NFSMNT_ACDIRMAX 0x01000 /* ??? */
+#define OSF1_NFSMNT_NOCTO 0x02000 /* ??? */
+#define OSF1_NFSMNT_POSIX 0x04000 /* ??? */
+#define OSF1_NFSMNT_AUTO 0x08000 /* ??? */
+
+#define OSF1_NFSMNT_FLAGS \
+ (OSF1_NFSMNT_SOFT|OSF1_NFSMNT_WSIZE|OSF1_NFSMNT_RSIZE| \
+ OSF1_NFSMNT_TIMEO|OSF1_NFSMNT_RETRANS|OSF1_NFSMNT_HOSTNAME| \
+ OSF1_NFSMNT_INT|OSF1_NFSMNT_NOCONN)
+
+void
+bsd2osf_statfs(bsfs, osfs)
+ struct statfs *bsfs;
+ struct osf1_statfs *osfs;
+{
+
+ bzero(osfs, sizeof (struct osf1_statfs));
+ if (!strncmp(MOUNT_UFS, bsfs->f_fstypename, MFSNAMELEN))
+ osfs->f_type = OSF1_MOUNT_UFS;
+ else if (!strncmp(MOUNT_NFS, bsfs->f_fstypename, MFSNAMELEN))
+ osfs->f_type = OSF1_MOUNT_NFS;
+ else if (!strncmp(MOUNT_MFS, bsfs->f_fstypename, MFSNAMELEN))
+ 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_flags; /* XXX translate */
+ osfs->f_fsize = bsfs->f_bsize;
+ osfs->f_bsize = bsfs->f_iosize;
+ 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;
+ bcopy(&bsfs->f_fsid, &osfs->f_fsid,
+ max(sizeof bsfs->f_fsid, sizeof osfs->f_fsid));
+ /* osfs->f_spare zeroed above */
+ bcopy(bsfs->f_mntonname, osfs->f_mntonname,
+ max(sizeof bsfs->f_mntonname, sizeof osfs->f_mntonname));
+ bcopy(bsfs->f_mntfromname, osfs->f_mntfromname,
+ max(sizeof bsfs->f_mntfromname, sizeof osfs->f_mntfromname));
+ /* XXX osfs->f_xxx should be filled in... */
+}
+
+int
+osf1_sys_statfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_statfs_args /* {
+ syscallarg(char *) path;
+ syscallarg(struct osf1_statfs *) buf;
+ syscallarg(int) len;
+ } */ *uap = v;
+ struct mount *mp;
+ struct statfs *sp;
+ struct osf1_statfs osfs;
+ int error;
+ struct nameidata nd;
+
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
+ if (error = namei(&nd))
+ return (error);
+ mp = nd.ni_vp->v_mount;
+ sp = &mp->mnt_stat;
+ vrele(nd.ni_vp);
+ if (error = VFS_STATFS(mp, sp, p))
+ return (error);
+ sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
+ bsd2osf_statfs(sp, &osfs);
+ return copyout(&osfs, SCARG(uap, buf), min(sizeof osfs,
+ SCARG(uap, len)));
+}
+
+int
+osf1_sys_fstatfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_fstatfs_args /* {
+ syscallarg(int) fd;
+ syscallarg(struct osf1_statfs *) buf;
+ syscallarg(int) len;
+ } */ *uap = v;
+ struct file *fp;
+ struct mount *mp;
+ struct statfs *sp;
+ struct osf1_statfs osfs;
+ int error;
+
+ if (error = getvnode(p->p_fd, uap->fd, &fp))
+ return (error);
+ mp = ((struct vnode *)fp->f_data)->v_mount;
+ sp = &mp->mnt_stat;
+ if (error = VFS_STATFS(mp, sp, p))
+ return (error);
+ sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
+ bsd2osf_statfs(sp, &osfs);
+ return copyout(&osfs, SCARG(uap, buf), min(sizeof osfs,
+ SCARG(uap, len)));
+}
+
+int
+osf1_sys_getfsstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct osf1_sys_getfsstat_args /* {
+ syscallarg(struct osf1_statfs *) buf;
+ syscallarg(long) bufsize;
+ syscallarg(int) flags;
+ } */ *uap = v;
+ struct mount *mp, *nmp;
+ struct statfs *sp;
+ struct osf1_statfs osfs;
+ caddr_t osf_sfsp;
+ long count, maxcount, error;
+
+ if (SCARG(uap, flags) & ~OSF1_GETFSSTAT_FLAGS)
+ return (EINVAL);
+
+ maxcount = SCARG(uap, bufsize) / sizeof(struct osf1_statfs);
+ osf_sfsp = (caddr_t)SCARG(uap, buf);
+ for (count = 0, mp = mountlist.cqh_first; mp != (void *)&mountlist;
+ mp = nmp) {
+ nmp = mp->mnt_list.cqe_next;
+ if (osf_sfsp && count < maxcount &&
+ ((mp->mnt_flag & MNT_MLOCK) == 0)) {
+ sp = &mp->mnt_stat;
+ /*
+ * If OSF1_MNT_NOWAIT is specified, do not refresh the
+ * fsstat cache. OSF1_MNT_WAIT overrides
+ * OSF1_MNT_NOWAIT.
+ */
+ if (((SCARG(uap, flags) & OSF1_MNT_NOWAIT) == 0 ||
+ (SCARG(uap, flags) & OSF1_MNT_WAIT)) &&
+ (error = VFS_STATFS(mp, sp, p)))
+ continue;
+ sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
+ bsd2osf_statfs(sp, &osfs);
+ if (error = copyout(&osfs, osf_sfsp,
+ sizeof (struct osf1_statfs)))
+ return (error);
+ osf_sfsp += sizeof (struct osf1_statfs);
+ }
+ count++;
+ }
+ if (osf_sfsp && count > maxcount)
+ *retval = maxcount;
+ else
+ *retval = count;
+ return (0);
+}
+
+int
+osf1_sys_unmount(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_unmount_args /* {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ } */ *uap = v;
+ struct sys_unmount_args a;
+
+ SCARG(&a, path) = SCARG(uap, path);
+
+ if (SCARG(uap, flags) & ~OSF1_UNMOUNT_FLAGS)
+ return (EINVAL);
+ SCARG(&a, flags) = 0;
+ if ((SCARG(uap, flags) & OSF1_MNT_FORCE) &&
+ (SCARG(uap, flags) & OSF1_MNT_NOFORCE) == 0)
+ SCARG(&a, flags) |= MNT_FORCE;
+
+ return sys_unmount(p, &a, retval);
+}
+
+int
+osf1_sys_mount(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_mount_args /* {
+ syscallarg(int) type;
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(caddr_t) data;
+ } */ *uap = v;
+ struct sys_mount_args a;
+ int error;
+
+ SCARG(&a, path) = SCARG(uap, path);
+
+ if (SCARG(uap, flags) & ~OSF1_MOUNT_FLAGS)
+ return (EINVAL);
+ SCARG(&a, flags) = SCARG(uap, flags); /* XXX - xlate */
+
+ switch (SCARG(uap, type)) {
+ case OSF1_MOUNT_UFS: /* XXX */
+ return (EINVAL);
+ break;
+
+ case OSF1_MOUNT_NFS: /* XXX */
+ if (error = osf1_mount_nfs(p, uap, &a))
+ return error;
+ break;
+
+ case OSF1_MOUNT_MFS: /* XXX */
+ if (error = osf1_mount_mfs(p, uap, &a))
+ return error;
+ break;
+
+ case OSF1_MOUNT_CDFS: /* XXX */
+ return (EINVAL);
+ break;
+
+ case OSF1_MOUNT_PROCFS: /* XXX */
+ return (EINVAL);
+ break;
+
+ case OSF1_MOUNT_NONE:
+ case OSF1_MOUNT_PC:
+ case OSF1_MOUNT_S5FS:
+ case OSF1_MOUNT_DFS:
+ case OSF1_MOUNT_EFS:
+ case OSF1_MOUNT_MSFS:
+ case OSF1_MOUNT_FFM:
+ case OSF1_MOUNT_FDFS:
+ case OSF1_MOUNT_ADDON:
+ default:
+ return (EINVAL);
+ }
+
+ return sys_mount(p, &a, retval);
+}
+
+int
+osf1_mount_mfs(p, osf_argp, bsd_argp)
+ struct proc *p;
+ struct osf1_sys_mount_args *osf_argp;
+ struct sys_mount_args *bsd_argp;
+{
+ struct emul *e = p->p_emul;
+ struct osf1_mfs_args osf_ma;
+ struct mfs_args bsd_ma;
+ caddr_t cp;
+ int error;
+
+ if (error = copyin(SCARG(osf_argp, data), &osf_ma, sizeof osf_ma))
+ return error;
+
+ bzero(&bsd_ma, sizeof bsd_ma);
+ bsd_ma.fspec = osf_ma.name;
+ /* XXX export args */
+ bsd_ma.base = osf_ma.base;
+ bsd_ma.size = osf_ma.size;
+
+ cp = STACKGAPBASE;
+ SCARG(bsd_argp, data) = cp;
+ if (error = copyout(&bsd_ma, cp, sizeof bsd_ma))
+ return error;
+ cp += ALIGN(sizeof bsd_ma);
+
+ SCARG(bsd_argp, type) = cp;
+ if (error = copyout(MOUNT_MFS, cp, strlen(MOUNT_MFS) + 1))
+ return error;
+
+ return 0;
+}
+
+int
+osf1_mount_nfs(p, osf_argp, bsd_argp)
+ struct proc *p;
+ struct osf1_sys_mount_args *osf_argp;
+ struct sys_mount_args *bsd_argp;
+{
+ struct emul *e = p->p_emul;
+ struct osf1_nfs_args osf_na;
+ struct nfs_args bsd_na;
+ caddr_t cp;
+ int error;
+
+ if (error = copyin(SCARG(osf_argp, data), &osf_na, sizeof osf_na))
+ return error;
+
+ bzero(&bsd_na, sizeof bsd_na);
+ bsd_na.addr = (struct sockaddr *)osf_na.addr;
+ bsd_na.addrlen = sizeof (struct sockaddr_in);
+ bsd_na.sotype = SOCK_DGRAM;
+ bsd_na.proto = 0;
+ bsd_na.fh = osf_na.fh;
+
+ if (osf_na.flags & ~OSF1_NFSMNT_FLAGS)
+ return EINVAL;
+ if (osf_na.flags & OSF1_NFSMNT_SOFT)
+ bsd_na.flags |= NFSMNT_SOFT;
+ if (osf_na.flags & OSF1_NFSMNT_WSIZE) {
+ bsd_na.wsize = osf_na.wsize;
+ bsd_na.flags |= NFSMNT_WSIZE;
+ }
+ if (osf_na.flags & OSF1_NFSMNT_RSIZE) {
+ bsd_na.rsize = osf_na.rsize;
+ bsd_na.flags |= NFSMNT_RSIZE;
+ }
+ if (osf_na.flags & OSF1_NFSMNT_TIMEO) {
+ bsd_na.timeo = osf_na.timeo;
+ bsd_na.flags |= NFSMNT_TIMEO;
+ }
+ if (osf_na.flags & OSF1_NFSMNT_RETRANS) {
+ bsd_na.retrans = osf_na.retrans;
+ bsd_na.flags |= NFSMNT_RETRANS;
+ }
+ if (osf_na.flags & OSF1_NFSMNT_HOSTNAME)
+ bsd_na.hostname = osf_na.hostname;
+ if (osf_na.flags & OSF1_NFSMNT_INT)
+ bsd_na.flags |= NFSMNT_INT;
+ if (osf_na.flags & OSF1_NFSMNT_NOCONN)
+ bsd_na.flags |= NFSMNT_NOCONN;
+
+ cp = STACKGAPBASE;
+ SCARG(bsd_argp, data) = cp;
+ if (error = copyout(&bsd_na, cp, sizeof bsd_na))
+ return error;
+ cp += ALIGN(sizeof bsd_na);
+
+ SCARG(bsd_argp, type) = cp;
+ if (error = copyout(MOUNT_NFS, cp, strlen(MOUNT_NFS) + 1))
+ return error;
+
+ return 0;
+}
diff --git a/sys/compat/osf1/osf1_signal.c b/sys/compat/osf1/osf1_signal.c
new file mode 100644
index 00000000000..027d919c28f
--- /dev/null
+++ b/sys/compat/osf1/osf1_signal.c
@@ -0,0 +1,557 @@
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/kernel.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/malloc.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/osf1/osf1_signal.h>
+#include <compat/osf1/osf1_syscallargs.h>
+#include <compat/osf1/osf1_util.h>
+
+static void bsd_to_osf1_sigaction __P((const struct sigaction *bsa,
+ struct osf1_sigaction *osa));
+static void osf1_to_bsd_sigaction __P((const struct osf1_sigaction *osa,
+ struct sigaction *bsa));
+
+#define sigemptyset(s) bzero((s), sizeof(*(s)))
+#define sigismember(s, n) (*(s) & sigmask(n))
+#define sigaddset(s, n) (*(s) |= sigmask(n))
+
+#define osf1_sigmask(n) (1 << ((n) - 1))
+#define osf1_sigemptyset(s) bzero((s), sizeof(*(s)))
+#define osf1_sigismember(s, n) (*(s) & sigmask(n))
+#define osf1_sigaddset(s, n) (*(s) |= sigmask(n))
+
+int bsd_to_osf1_sig[] = {
+ 0,
+ OSF1_SIGHUP,
+ OSF1_SIGINT,
+ OSF1_SIGQUIT,
+ OSF1_SIGILL,
+ OSF1_SIGTRAP,
+ OSF1_SIGABRT,
+ OSF1_SIGEMT,
+ OSF1_SIGFPE,
+ OSF1_SIGKILL,
+ OSF1_SIGBUS,
+ OSF1_SIGSEGV,
+ OSF1_SIGSYS,
+ OSF1_SIGPIPE,
+ OSF1_SIGALRM,
+ OSF1_SIGTERM,
+ OSF1_SIGURG,
+ OSF1_SIGSTOP,
+ OSF1_SIGTSTP,
+ OSF1_SIGCONT,
+ OSF1_SIGCHLD,
+ OSF1_SIGTTIN,
+ OSF1_SIGTTOU,
+ OSF1_SIGIO,
+ OSF1_SIGXCPU,
+ OSF1_SIGXFSZ,
+ OSF1_SIGVTALRM,
+ OSF1_SIGPROF,
+ OSF1_SIGWINCH,
+ OSF1_SIGINFO,
+ OSF1_SIGUSR1,
+ OSF1_SIGUSR2,
+};
+
+int osf1_to_bsd_sig[] = {
+ 0,
+ SIGHUP,
+ SIGINT,
+ SIGQUIT,
+ SIGILL,
+ SIGTRAP,
+ SIGABRT,
+ SIGEMT,
+ SIGFPE,
+ SIGKILL,
+ SIGBUS,
+ SIGSEGV,
+ SIGSYS,
+ SIGPIPE,
+ SIGALRM,
+ SIGTERM,
+ SIGURG,
+ SIGSTOP,
+ SIGTSTP,
+ SIGCONT,
+ SIGCHLD,
+ SIGTTIN,
+ SIGTTOU,
+ SIGIO,
+ SIGXCPU,
+ SIGXFSZ,
+ SIGVTALRM,
+ SIGPROF,
+ SIGWINCH,
+ SIGINFO,
+ SIGUSR1,
+ SIGUSR2,
+};
+
+void
+osf1_to_bsd_sigset(oss, bss)
+ const osf1_sigset_t *oss;
+ sigset_t *bss;
+{
+ int i, newsig;
+
+ sigemptyset(bss);
+ for (i = 1; i < OSF1_NSIG; i++) {
+ if (osf1_sigismember(oss, i)) {
+ newsig = osf1_to_bsd_sig[i];
+ if (newsig)
+ sigaddset(bss, newsig);
+ }
+ }
+}
+
+
+void
+bsd_to_osf1_sigset(bss, oss)
+ const sigset_t *bss;
+ osf1_sigset_t *oss;
+{
+ int i, newsig;
+
+ osf1_sigemptyset(oss);
+ for (i = 1; i < NSIG; i++) {
+ if (sigismember(bss, i)) {
+ newsig = bsd_to_osf1_sig[i];
+ if (newsig)
+ osf1_sigaddset(oss, newsig);
+ }
+ }
+}
+
+/*
+ * XXX: Only a subset of the flags is currently implemented.
+ */
+void
+osf1_to_bsd_sigaction(osa, bsa)
+ const struct osf1_sigaction *osa;
+ struct sigaction *bsa;
+{
+
+ bsa->sa_handler = osa->sa_handler;
+ osf1_to_bsd_sigset(&osa->sa_mask, &bsa->sa_mask);
+ bsa->sa_flags = 0;
+ if ((osa->sa_flags & OSF1_SA_ONSTACK) != 0)
+ bsa->sa_flags |= SA_ONSTACK;
+ if ((osa->sa_flags & OSF1_SA_RESTART) != 0)
+ bsa->sa_flags |= SA_RESTART;
+ if ((osa->sa_flags & OSF1_SA_RESETHAND) != 0)
+ bsa->sa_flags |= SA_RESETHAND;
+ if ((osa->sa_flags & OSF1_SA_NOCLDSTOP) != 0)
+ bsa->sa_flags |= SA_NOCLDSTOP;
+ if ((osa->sa_flags & OSF1_SA_NODEFER) != 0)
+ bsa->sa_flags |= SA_NODEFER;
+}
+
+void
+bsd_to_osf1_sigaction(bsa, osa)
+ const struct sigaction *bsa;
+ struct osf1_sigaction *osa;
+{
+
+ osa->sa_handler = bsa->sa_handler;
+ bsd_to_osf1_sigset(&bsa->sa_mask, &osa->sa_mask);
+ osa->sa_flags = 0;
+ if ((bsa->sa_flags & SA_ONSTACK) != 0)
+ osa->sa_flags |= SA_ONSTACK;
+ if ((bsa->sa_flags & SA_RESTART) != 0)
+ osa->sa_flags |= SA_RESTART;
+ if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
+ osa->sa_flags |= SA_NOCLDSTOP;
+ if ((bsa->sa_flags & SA_NODEFER) != 0)
+ osa->sa_flags |= SA_NODEFER;
+ if ((bsa->sa_flags & SA_RESETHAND) != 0)
+ osa->sa_flags |= SA_RESETHAND;
+}
+
+void
+osf1_to_bsd_sigaltstack(oss, bss)
+ const struct osf1_sigaltstack *oss;
+ struct sigaltstack *bss;
+{
+
+ bss->ss_base = oss->ss_sp;
+ bss->ss_size = oss->ss_size;
+ bss->ss_flags = 0;
+
+ if ((oss->ss_flags & OSF1_SS_DISABLE) != 0)
+ bss->ss_flags |= SS_DISABLE;
+ if ((oss->ss_flags & OSF1_SS_ONSTACK) != 0)
+ bss->ss_flags |= SS_ONSTACK;
+}
+
+void
+bsd_to_osf1_sigaltstack(bss, oss)
+ const struct sigaltstack *bss;
+ struct osf1_sigaltstack *oss;
+{
+
+ oss->ss_sp = bss->ss_base;
+ oss->ss_size = bss->ss_size;
+ oss->ss_flags = 0;
+
+ if ((bss->ss_flags & SS_DISABLE) != 0)
+ oss->ss_flags |= OSF1_SS_DISABLE;
+ if ((bss->ss_flags & SS_ONSTACK) != 0)
+ oss->ss_flags |= OSF1_SS_ONSTACK;
+}
+
+int
+osf1_sys_sigaction(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_sigaction_args /* {
+ syscallarg(int) signum;
+ syscallarg(struct osf1_sigaction *) nsa;
+ syscallarg(struct osf1_sigaction *) osa;
+ } */ *uap = v;
+ struct osf1_sigaction *nosa, *oosa, tmposa;
+ struct sigaction *nbsa, *obsa, tmpbsa;
+ struct sys_sigaction_args sa;
+ caddr_t sg;
+ int error;
+
+ sg = stackgap_init(p->p_emul);
+ nosa = SCARG(uap, nsa);
+ oosa = SCARG(uap, osa);
+
+ if (oosa != NULL)
+ obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ else
+ obsa = NULL;
+
+ if (nosa != NULL) {
+ nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ if ((error = copyin(nosa, &tmposa, sizeof(tmposa))) != 0)
+ return error;
+ osf1_to_bsd_sigaction(&tmposa, &tmpbsa);
+ if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0)
+ return error;
+ } else
+ nbsa = NULL;
+
+ SCARG(&sa, signum) = osf1_to_bsd_sig[SCARG(uap, signum)];
+ SCARG(&sa, nsa) = nbsa;
+ SCARG(&sa, osa) = obsa;
+
+ if ((error = sys_sigaction(p, &sa, retval)) != 0)
+ return error;
+
+ if (oosa != NULL) {
+ if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0)
+ return error;
+ bsd_to_osf1_sigaction(&tmpbsa, &tmposa);
+ if ((error = copyout(&tmposa, oosa, sizeof(tmposa))) != 0)
+ return error;
+ }
+
+ return 0;
+}
+
+int
+osf1_sys_sigaltstack(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_sigaltstack_args /* {
+ syscallarg(struct osf1_sigaltstack *) nss;
+ syscallarg(struct osf1_sigaltstack *) oss;
+ } */ *uap = v;
+ struct osf1_sigaltstack *noss, *ooss, tmposs;
+ struct sigaltstack *nbss, *obss, tmpbss;
+ struct sys_sigaltstack_args sa;
+ caddr_t sg;
+ int error;
+
+ sg = stackgap_init(p->p_emul);
+ noss = SCARG(uap, nss);
+ ooss = SCARG(uap, oss);
+
+ if (ooss != NULL)
+ obss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
+ else
+ obss = NULL;
+
+ if (noss != NULL) {
+ nbss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
+ if ((error = copyin(noss, &tmposs, sizeof(tmposs))) != 0)
+ return error;
+ osf1_to_bsd_sigaltstack(&tmposs, &tmpbss);
+ if ((error = copyout(&tmpbss, nbss, sizeof(tmpbss))) != 0)
+ return error;
+ } else
+ nbss = NULL;
+
+ SCARG(&sa, nss) = nbss;
+ SCARG(&sa, oss) = obss;
+
+ if ((error = sys_sigaltstack(p, &sa, retval)) != 0)
+ return error;
+
+ if (obss != NULL) {
+ if ((error = copyin(obss, &tmpbss, sizeof(tmpbss))) != 0)
+ return error;
+ bsd_to_osf1_sigaltstack(&tmpbss, &tmposs);
+ if ((error = copyout(&tmposs, ooss, sizeof(tmposs))) != 0)
+ return error;
+ }
+
+ return 0;
+}
+
+#if 0
+int
+osf1_sys_signal(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_signal_args /* {
+ syscallarg(int) signum;
+ syscallarg(osf1_sig_t) handler;
+ } */ *uap = v;
+ int signum = osf1_to_bsd_sig[OSF1_SIGNO(SCARG(uap, signum))];
+ int error;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ if (signum <= 0 || signum >= OSF1_NSIG) {
+ if (OSF1_SIGCALL(SCARG(uap, signum)) == OSF1_SIGNAL_MASK ||
+ OSF1_SIGCALL(SCARG(uap, signum)) == OSF1_SIGDEFER_MASK)
+ *retval = (int)OSF1_SIG_ERR;
+ return EINVAL;
+ }
+
+ switch (OSF1_SIGCALL(SCARG(uap, signum))) {
+ case OSF1_SIGDEFER_MASK:
+ /*
+ * sigset is identical to signal() except
+ * that SIG_HOLD is allowed as
+ * an action.
+ */
+ if (SCARG(uap, handler) == OSF1_SIG_HOLD) {
+ struct sys_sigprocmask_args sa;
+
+ SCARG(&sa, how) = SIG_BLOCK;
+ SCARG(&sa, mask) = sigmask(signum);
+ return sys_sigprocmask(p, &sa, retval);
+ }
+ /* FALLTHROUGH */
+
+ case OSF1_SIGNAL_MASK:
+ {
+ struct sys_sigaction_args sa_args;
+ struct sigaction *nbsa, *obsa, sa;
+
+ nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ SCARG(&sa_args, signum) = signum;
+ SCARG(&sa_args, nsa) = nbsa;
+ SCARG(&sa_args, osa) = obsa;
+
+ sa.sa_handler = SCARG(uap, handler);
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+#if 0
+ if (signum != SIGALRM)
+ sa.sa_flags = SA_RESTART;
+#endif
+ if ((error = copyout(&sa, nbsa, sizeof(sa))) != 0)
+ return error;
+ if ((error = sys_sigaction(p, &sa_args, retval)) != 0) {
+ DPRINTF(("signal: sigaction failed: %d\n",
+ error));
+ *retval = (int)OSF1_SIG_ERR;
+ return error;
+ }
+ if ((error = copyin(obsa, &sa, sizeof(sa))) != 0)
+ return error;
+ *retval = (int)sa.sa_handler;
+ return 0;
+ }
+
+ case OSF1_SIGHOLD_MASK:
+ {
+ struct sys_sigprocmask_args sa;
+
+ SCARG(&sa, how) = SIG_BLOCK;
+ SCARG(&sa, mask) = sigmask(signum);
+ return sys_sigprocmask(p, &sa, retval);
+ }
+
+ case OSF1_SIGRELSE_MASK:
+ {
+ struct sys_sigprocmask_args sa;
+
+ SCARG(&sa, how) = SIG_UNBLOCK;
+ SCARG(&sa, mask) = sigmask(signum);
+ return sys_sigprocmask(p, &sa, retval);
+ }
+
+ case OSF1_SIGIGNORE_MASK:
+ {
+ struct sys_sigaction_args sa_args;
+ struct sigaction *bsa, sa;
+
+ bsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ SCARG(&sa_args, signum) = signum;
+ SCARG(&sa_args, nsa) = bsa;
+ SCARG(&sa_args, osa) = NULL;
+
+ sa.sa_handler = SIG_IGN;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ if ((error = copyout(&sa, bsa, sizeof(sa))) != 0)
+ return error;
+ if ((error = sys_sigaction(p, &sa_args, retval)) != 0) {
+ DPRINTF(("sigignore: sigaction failed\n"));
+ return error;
+ }
+ return 0;
+ }
+
+ case OSF1_SIGPAUSE_MASK:
+ {
+ struct sys_sigsuspend_args sa;
+
+ SCARG(&sa, mask) = p->p_sigmask & ~sigmask(signum);
+ return sys_sigsuspend(p, &sa, retval);
+ }
+
+ default:
+ return ENOSYS;
+ }
+}
+
+int
+osf1_sys_sigprocmask(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_sigprocmask_args /* {
+ syscallarg(int) how;
+ syscallarg(osf1_sigset_t *) set;
+ syscallarg(osf1_sigset_t *) oset;
+ } */ *uap = v;
+ osf1_sigset_t oss;
+ sigset_t bss;
+ int error = 0;
+
+ if (SCARG(uap, oset) != NULL) {
+ /* Fix the return value first if needed */
+ bsd_to_osf1_sigset(&p->p_sigmask, &oss);
+ if ((error = copyout(&oss, SCARG(uap, oset), sizeof(oss))) != 0)
+ return error;
+ }
+
+ if (SCARG(uap, set) == NULL)
+ /* Just examine */
+ return 0;
+
+ if ((error = copyin(SCARG(uap, set), &oss, sizeof(oss))) != 0)
+ return error;
+
+ osf1_to_bsd_sigset(&oss, &bss);
+
+ (void) splhigh();
+
+ switch (SCARG(uap, how)) {
+ case OSF1_SIG_BLOCK:
+ p->p_sigmask |= bss & ~sigcantmask;
+ break;
+
+ case OSF1_SIG_UNBLOCK:
+ p->p_sigmask &= ~bss;
+ break;
+
+ case OSF1_SIG_SETMASK:
+ p->p_sigmask = bss & ~sigcantmask;
+ break;
+
+ default:
+ error = EINVAL;
+ break;
+ }
+
+ (void) spl0();
+
+ return error;
+}
+
+int
+osf1_sys_sigpending(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_sigpending_args /* {
+ syscallarg(osf1_sigset_t *) mask;
+ } */ *uap = v;
+ sigset_t bss;
+ osf1_sigset_t oss;
+
+ bss = p->p_siglist & p->p_sigmask;
+ bsd_to_osf1_sigset(&bss, &oss);
+
+ return copyout(&oss, SCARG(uap, mask), sizeof(oss));
+}
+
+int
+osf1_sys_sigsuspend(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_sigsuspend_args /* {
+ syscallarg(osf1_sigset_t *) ss;
+ } */ *uap = v;
+ osf1_sigset_t oss;
+ sigset_t bss;
+ struct sys_sigsuspend_args sa;
+ int error;
+
+ if ((error = copyin(SCARG(uap, ss), &oss, sizeof(oss))) != 0)
+ return error;
+
+ osf1_to_bsd_sigset(&oss, &bss);
+
+ SCARG(&sa, mask) = bss;
+ return sys_sigsuspend(p, &sa, retval);
+}
+
+int
+osf1_sys_kill(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct osf1_sys_kill_args /* {
+ syscallarg(int) pid;
+ syscallarg(int) signum;
+ } */ *uap = v;
+ struct sys_kill_args ka;
+
+ SCARG(&ka, pid) = SCARG(uap, pid);
+ SCARG(&ka, signum) = osf1_to_bsd_sig[SCARG(uap, signum)];
+ return sys_kill(p, &ka, retval);
+}
+#endif
diff --git a/sys/compat/osf1/osf1_signal.h b/sys/compat/osf1/osf1_signal.h
new file mode 100644
index 00000000000..b5baf97c230
--- /dev/null
+++ b/sys/compat/osf1/osf1_signal.h
@@ -0,0 +1,80 @@
+#ifndef _OSF1_SIGNAL_H
+#define _OSF1_SIGNAL_H
+
+#define OSF1_SIGHUP 1
+#define OSF1_SIGINT 2
+#define OSF1_SIGQUIT 3
+#define OSF1_SIGILL 4
+#define OSF1_SIGTRAP 5
+#define OSF1_SIGABRT 6
+#define OSF1_SIGEMT 7
+#define OSF1_SIGFPE 8
+#define OSF1_SIGKILL 9
+#define OSF1_SIGBUS 10
+#define OSF1_SIGSEGV 11
+#define OSF1_SIGSYS 12
+#define OSF1_SIGPIPE 13
+#define OSF1_SIGALRM 14
+#define OSF1_SIGTERM 15
+#define OSF1_SIGURG 16
+#define OSF1_SIGSTOP 17
+#define OSF1_SIGTSTP 18
+#define OSF1_SIGCONT 19
+#define OSF1_SIGCHLD 20
+#define OSF1_SIGTTIN 21
+#define OSF1_SIGTTOU 22
+#define OSF1_SIGIO 23
+#define OSF1_SIGXCPU 24
+#define OSF1_SIGXFSZ 25
+#define OSF1_SIGVTALRM 26
+#define OSF1_SIGPROF 27
+#define OSF1_SIGWINCH 28
+#define OSF1_SIGINFO 29
+#define OSF1_SIGUSR1 30
+#define OSF1_SIGUSR2 31
+#define OSF1_NSIG 32
+
+#define OSF1_SIG_DFL (void(*)())0
+#define OSF1_SIG_ERR (void(*)())-1
+#define OSF1_SIG_IGN (void(*)())1
+#define OSF1_SIG_HOLD (void(*)())2
+
+#define OSF1_SIG_BLOCK 1
+#define OSF1_SIG_UNBLOCK 2
+#define OSF1_SIG_SETMASK 3
+
+typedef u_long osf1_sigset_t;
+typedef void (*osf1_handler_t) __P((int));
+
+struct osf1_sigaction {
+ osf1_handler_t sa_handler;
+ osf1_sigset_t sa_mask;
+ int sa_flags;
+};
+
+struct osf1_sigaltstack {
+ caddr_t ss_sp;
+ int ss_flags;
+ size_t ss_size;
+};
+
+/* sa_flags */
+#define OSF1_SA_ONSTACK 0x00000001
+#define OSF1_SA_RESTART 0x00000002
+#define OSF1_SA_NOCLDSTOP 0x00000004
+#define OSF1_SA_NODEFER 0x00000008
+#define OSF1_SA_RESETHAND 0x00000010
+#define OSF1_SA_NOCLDWAIT 0x00000020
+#define OSF1_SA_SIGINFO 0x00000040
+
+/* ss_flags */
+#define OSF1_SS_ONSTACK 0x00000001
+#define OSF1_SS_DISABLE 0x00000002
+
+extern int osf1_to_linux_sig[];
+void bsd_to_osf1_sigaltstack __P((const struct sigaltstack *, struct osf1_sigaltstack *));
+void bsd_to_osf1_sigset __P((const sigset_t *, osf1_sigset_t *));
+void osf1_to_bsd_sigaltstack __P((const struct osf1_sigaltstack *, struct sigaltstack *));
+void osf1_to_bsd_sigset __P((const osf1_sigset_t *, sigset_t *));
+
+#endif /* !_OSF1_SIGNAL_H */
diff --git a/sys/compat/osf1/osf1_syscall.h b/sys/compat/osf1/osf1_syscall.h
new file mode 100644
index 00000000000..a8caad77ab1
--- /dev/null
+++ b/sys/compat/osf1/osf1_syscall.h
@@ -0,0 +1,115 @@
+/*
+ * System call numbers.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.2 1995/10/07 06:27:28 mycroft Exp
+ */
+
+#define OSF1_SYS_syscall 0
+#define OSF1_SYS_exit 1
+#define OSF1_SYS_fork 2
+#define OSF1_SYS_read 3
+#define OSF1_SYS_write 4
+#define OSF1_SYS_close 6
+#define OSF1_SYS_wait4 7
+#define OSF1_SYS_link 9
+#define OSF1_SYS_unlink 10
+#define OSF1_SYS_chdir 12
+#define OSF1_SYS_fchdir 13
+#define OSF1_SYS_mknod 14
+#define OSF1_SYS_chmod 15
+#define OSF1_SYS_chown 16
+#define OSF1_SYS_obreak 17
+#define OSF1_SYS_getfsstat 18
+#define OSF1_SYS_lseek 19
+#define OSF1_SYS_getpid 20
+#define OSF1_SYS_mount 21
+#define OSF1_SYS_unmount 22
+#define OSF1_SYS_setuid 23
+#define OSF1_SYS_getuid 24
+#define OSF1_SYS_access 33
+#define OSF1_SYS_sync 36
+#define OSF1_SYS_kill 37
+#define OSF1_SYS_setpgid 39
+#define OSF1_SYS_dup 41
+#define OSF1_SYS_pipe 42
+#define OSF1_SYS_open 45
+ /* 46 is obsolete sigaction */
+#define OSF1_SYS_getgid 47
+#define OSF1_SYS_sigprocmask 48
+#define OSF1_SYS_getlogin 49
+#define OSF1_SYS_setlogin 50
+#define OSF1_SYS_acct 51
+#define OSF1_SYS_ioctl 54
+#define OSF1_SYS_reboot 55
+#define OSF1_SYS_revoke 56
+#define OSF1_SYS_symlink 57
+#define OSF1_SYS_readlink 58
+#define OSF1_SYS_execve 59
+#define OSF1_SYS_umask 60
+#define OSF1_SYS_chroot 61
+#define OSF1_SYS_getpgrp 63
+#define OSF1_SYS_getpagesize 64
+#define OSF1_SYS_vfork 66
+#define OSF1_SYS_stat 67
+#define OSF1_SYS_lstat 68
+#define OSF1_SYS_mmap 71
+#define OSF1_SYS_munmap 73
+#define OSF1_SYS_madvise 75
+#define OSF1_SYS_getgroups 79
+#define OSF1_SYS_setgroups 80
+#define OSF1_SYS_setpgrp 82
+#define OSF1_SYS_setitimer 83
+#define OSF1_SYS_gethostname 87
+#define OSF1_SYS_sethostname 88
+#define OSF1_SYS_getdtablesize 89
+#define OSF1_SYS_dup2 90
+#define OSF1_SYS_fstat 91
+#define OSF1_SYS_fcntl 92
+#define OSF1_SYS_select 93
+#define OSF1_SYS_fsync 95
+#define OSF1_SYS_setpriority 96
+#define OSF1_SYS_socket 97
+#define OSF1_SYS_connect 98
+#define OSF1_SYS_getpriority 100
+#define OSF1_SYS_send 101
+#define OSF1_SYS_recv 102
+#define OSF1_SYS_sigreturn 103
+#define OSF1_SYS_bind 104
+#define OSF1_SYS_setsockopt 105
+#define OSF1_SYS_sigsuspend 111
+#define OSF1_SYS_sigstack 112
+#define OSF1_SYS_gettimeofday 116
+#define OSF1_SYS_getrusage 117
+#define OSF1_SYS_getsockopt 118
+#define OSF1_SYS_readv 120
+#define OSF1_SYS_writev 121
+#define OSF1_SYS_settimeofday 122
+#define OSF1_SYS_fchown 123
+#define OSF1_SYS_fchmod 124
+#define OSF1_SYS_recvfrom 125
+#define OSF1_SYS_rename 128
+#define OSF1_SYS_truncate 129
+#define OSF1_SYS_ftruncate 130
+#define OSF1_SYS_setgid 132
+#define OSF1_SYS_sendto 133
+#define OSF1_SYS_shutdown 134
+#define OSF1_SYS_mkdir 136
+#define OSF1_SYS_rmdir 137
+#define OSF1_SYS_utimes 138
+ /* 139 is obsolete 4.2 sigreturn */
+#define OSF1_SYS_gethostid 142
+#define OSF1_SYS_sethostid 143
+#define OSF1_SYS_getrlimit 144
+#define OSF1_SYS_setrlimit 145
+#define OSF1_SYS_setsid 147
+#define OSF1_SYS_quota 149
+#define OSF1_SYS_sigaction 156
+#define OSF1_SYS_getdirentries 159
+#define OSF1_SYS_statfs 160
+#define OSF1_SYS_fstatfs 161
+#define OSF1_SYS_getsid 234
+#define OSF1_SYS_sigaltstack 235
+#define OSF1_SYS_usleep_thread 251
+#define OSF1_SYS_setsysinfo 257
+#define OSF1_SYS_MAXSYSCALL 261
diff --git a/sys/compat/osf1/osf1_syscallargs.h b/sys/compat/osf1/osf1_syscallargs.h
new file mode 100644
index 00000000000..eb0da037b12
--- /dev/null
+++ b/sys/compat/osf1/osf1_syscallargs.h
@@ -0,0 +1,289 @@
+/*
+ * System call argument lists.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.2 1995/10/07 06:27:28 mycroft Exp
+ */
+
+#define syscallarg(x) union { x datum; register_t pad; }
+
+struct osf1_sys_mknod_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ syscallarg(int) dev;
+};
+
+struct osf1_sys_getfsstat_args {
+ syscallarg(struct osf1_statfs *) buf;
+ syscallarg(long) bufsize;
+ syscallarg(int) flags;
+};
+
+struct osf1_sys_lseek_args {
+ syscallarg(int) fd;
+ syscallarg(off_t) offset;
+ syscallarg(int) whence;
+};
+
+struct osf1_sys_mount_args {
+ syscallarg(int) type;
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(caddr_t) data;
+};
+
+struct osf1_sys_unmount_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+};
+
+struct osf1_sys_setuid_args {
+ syscallarg(uid_t) uid;
+};
+
+struct osf1_sys_open_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+};
+
+struct osf1_sys_ioctl_args {
+ syscallarg(int) fd;
+ syscallarg(int) com;
+ syscallarg(caddr_t) data;
+};
+
+struct osf1_sys_reboot_args {
+ syscallarg(int) opt;
+};
+
+struct osf1_sys_stat_args {
+ syscallarg(char *) path;
+ syscallarg(struct osf1_stat *) ub;
+};
+
+struct osf1_sys_lstat_args {
+ syscallarg(char *) path;
+ syscallarg(struct osf1_stat *) ub;
+};
+
+struct osf1_sys_mmap_args {
+ syscallarg(caddr_t) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) prot;
+ syscallarg(int) flags;
+ syscallarg(int) fd;
+ syscallarg(off_t) pos;
+};
+
+struct osf1_sys_fstat_args {
+ syscallarg(int) fd;
+ syscallarg(void *) sb;
+};
+
+struct osf1_sys_fcntl_args {
+ syscallarg(int) fd;
+ syscallarg(int) cmd;
+ syscallarg(void *) arg;
+};
+
+struct osf1_sys_socket_args {
+ syscallarg(int) domain;
+ syscallarg(int) type;
+ syscallarg(int) protocol;
+};
+
+struct osf1_sys_readv_args {
+ syscallarg(int) fd;
+ syscallarg(struct osf1_iovec *) iovp;
+ syscallarg(u_int) iovcnt;
+};
+
+struct osf1_sys_writev_args {
+ syscallarg(int) fd;
+ syscallarg(struct osf1_iovec *) iovp;
+ syscallarg(u_int) iovcnt;
+};
+
+struct osf1_sys_truncate_args {
+ syscallarg(char *) path;
+ syscallarg(off_t) length;
+};
+
+struct osf1_sys_ftruncate_args {
+ syscallarg(int) fd;
+ syscallarg(off_t) length;
+};
+
+struct osf1_sys_setgid_args {
+ syscallarg(gid_t) gid;
+};
+
+struct osf1_sys_sendto_args {
+ syscallarg(int) s;
+ syscallarg(caddr_t) buf;
+ syscallarg(size_t) len;
+ syscallarg(int) flags;
+ syscallarg(caddr_t) to;
+ syscallarg(int) tolen;
+};
+
+struct osf1_sys_getrlimit_args {
+ syscallarg(u_int) which;
+ syscallarg(struct rlimit *) rlp;
+};
+
+struct osf1_sys_setrlimit_args {
+ syscallarg(u_int) which;
+ syscallarg(struct rlimit *) rlp;
+};
+
+struct osf1_sys_sigaction_args {
+ syscallarg(int) signum;
+ syscallarg(struct osf1_sigaction *) nsa;
+ syscallarg(struct osf1_sigaction *) osa;
+};
+
+struct osf1_sys_statfs_args {
+ syscallarg(char *) path;
+ syscallarg(struct osf1_statfs *) buf;
+ syscallarg(int) len;
+};
+
+struct osf1_sys_fstatfs_args {
+ syscallarg(int) fd;
+ syscallarg(struct osf1_statfs *) buf;
+ syscallarg(int) len;
+};
+
+struct osf1_sys_getsid_args {
+ syscallarg(pid_t) pid;
+};
+
+struct osf1_sys_sigaltstack_args {
+ syscallarg(struct osf1_sigaltstack *) nss;
+ syscallarg(struct osf1_sigaltstack *) oss;
+};
+
+struct osf1_sys_usleep_thread_args {
+ syscallarg(struct timeval *) sleep;
+ syscallarg(struct timeval *) slept;
+};
+
+struct osf1_sys_setsysinfo_args {
+ syscallarg(u_long) op;
+ syscallarg(caddr_t) buffer;
+ syscallarg(u_long) nbytes;
+ syscallarg(caddr_t) arg;
+ syscallarg(u_long) flag;
+};
+
+/*
+ * System call prototypes.
+ */
+
+int sys_nosys __P((struct proc *, void *, register_t *));
+int sys_exit __P((struct proc *, void *, register_t *));
+int sys_fork __P((struct proc *, void *, register_t *));
+int sys_read __P((struct proc *, void *, register_t *));
+int sys_write __P((struct proc *, void *, register_t *));
+int sys_close __P((struct proc *, void *, register_t *));
+int sys_wait4 __P((struct proc *, void *, register_t *));
+int sys_link __P((struct proc *, void *, register_t *));
+int sys_unlink __P((struct proc *, void *, register_t *));
+int sys_chdir __P((struct proc *, void *, register_t *));
+int sys_fchdir __P((struct proc *, void *, register_t *));
+int osf1_sys_mknod __P((struct proc *, void *, register_t *));
+int sys_chmod __P((struct proc *, void *, register_t *));
+int sys_chown __P((struct proc *, void *, register_t *));
+int sys_obreak __P((struct proc *, void *, register_t *));
+int osf1_sys_getfsstat __P((struct proc *, void *, register_t *));
+int osf1_sys_lseek __P((struct proc *, void *, register_t *));
+int sys_getpid __P((struct proc *, void *, register_t *));
+int osf1_sys_mount __P((struct proc *, void *, register_t *));
+int osf1_sys_unmount __P((struct proc *, void *, register_t *));
+int osf1_sys_setuid __P((struct proc *, void *, register_t *));
+int sys_getuid __P((struct proc *, void *, register_t *));
+int sys_access __P((struct proc *, void *, register_t *));
+int sys_sync __P((struct proc *, void *, register_t *));
+int sys_kill __P((struct proc *, void *, register_t *));
+int sys_setpgid __P((struct proc *, void *, register_t *));
+int sys_dup __P((struct proc *, void *, register_t *));
+int sys_pipe __P((struct proc *, void *, register_t *));
+int osf1_sys_open __P((struct proc *, void *, register_t *));
+int sys_getgid __P((struct proc *, void *, register_t *));
+int sys_sigprocmask __P((struct proc *, void *, register_t *));
+int sys_getlogin __P((struct proc *, void *, register_t *));
+int sys_setlogin __P((struct proc *, void *, register_t *));
+int sys_acct __P((struct proc *, void *, register_t *));
+int osf1_sys_ioctl __P((struct proc *, void *, register_t *));
+int osf1_sys_reboot __P((struct proc *, void *, register_t *));
+int sys_revoke __P((struct proc *, void *, register_t *));
+int sys_symlink __P((struct proc *, void *, register_t *));
+int sys_readlink __P((struct proc *, void *, register_t *));
+int sys_execve __P((struct proc *, void *, register_t *));
+int sys_umask __P((struct proc *, void *, register_t *));
+int sys_chroot __P((struct proc *, void *, register_t *));
+int sys_getpgrp __P((struct proc *, void *, register_t *));
+int compat_43_sys_getpagesize __P((struct proc *, void *, register_t *));
+int sys_vfork __P((struct proc *, void *, register_t *));
+int osf1_sys_stat __P((struct proc *, void *, register_t *));
+int osf1_sys_lstat __P((struct proc *, void *, register_t *));
+int osf1_sys_mmap __P((struct proc *, void *, register_t *));
+int sys_munmap __P((struct proc *, void *, register_t *));
+int osf1_sys_madvise __P((struct proc *, void *, register_t *));
+int sys_getgroups __P((struct proc *, void *, register_t *));
+int sys_setgroups __P((struct proc *, void *, register_t *));
+int sys_setpgid __P((struct proc *, void *, register_t *));
+int sys_setitimer __P((struct proc *, void *, register_t *));
+int compat_43_sys_gethostname __P((struct proc *, void *, register_t *));
+int compat_43_sys_sethostname __P((struct proc *, void *, register_t *));
+int compat_43_sys_getdtablesize __P((struct proc *, void *, register_t *));
+int sys_dup2 __P((struct proc *, void *, register_t *));
+int osf1_sys_fstat __P((struct proc *, void *, register_t *));
+int osf1_sys_fcntl __P((struct proc *, void *, register_t *));
+int sys_select __P((struct proc *, void *, register_t *));
+int sys_fsync __P((struct proc *, void *, register_t *));
+int sys_setpriority __P((struct proc *, void *, register_t *));
+int osf1_sys_socket __P((struct proc *, void *, register_t *));
+int sys_connect __P((struct proc *, void *, register_t *));
+int sys_getpriority __P((struct proc *, void *, register_t *));
+int compat_43_sys_send __P((struct proc *, void *, register_t *));
+int compat_43_sys_recv __P((struct proc *, void *, register_t *));
+int sys_sigreturn __P((struct proc *, void *, register_t *));
+int sys_bind __P((struct proc *, void *, register_t *));
+int sys_setsockopt __P((struct proc *, void *, register_t *));
+int sys_sigsuspend __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigstack __P((struct proc *, void *, register_t *));
+int sys_gettimeofday __P((struct proc *, void *, register_t *));
+int osf1_sys_getrusage __P((struct proc *, void *, register_t *));
+int sys_getsockopt __P((struct proc *, void *, register_t *));
+int osf1_sys_readv __P((struct proc *, void *, register_t *));
+int osf1_sys_writev __P((struct proc *, void *, register_t *));
+int sys_settimeofday __P((struct proc *, void *, register_t *));
+int sys_fchown __P((struct proc *, void *, register_t *));
+int sys_fchmod __P((struct proc *, void *, register_t *));
+int compat_43_sys_recvfrom __P((struct proc *, void *, register_t *));
+int sys_rename __P((struct proc *, void *, register_t *));
+int osf1_sys_truncate __P((struct proc *, void *, register_t *));
+int osf1_sys_ftruncate __P((struct proc *, void *, register_t *));
+int osf1_sys_setgid __P((struct proc *, void *, register_t *));
+int osf1_sys_sendto __P((struct proc *, void *, register_t *));
+int sys_shutdown __P((struct proc *, void *, register_t *));
+int sys_mkdir __P((struct proc *, void *, register_t *));
+int sys_rmdir __P((struct proc *, void *, register_t *));
+int sys_utimes __P((struct proc *, void *, register_t *));
+int compat_43_sys_gethostid __P((struct proc *, void *, register_t *));
+int compat_43_sys_sethostid __P((struct proc *, void *, register_t *));
+int osf1_sys_getrlimit __P((struct proc *, void *, register_t *));
+int osf1_sys_setrlimit __P((struct proc *, void *, register_t *));
+int sys_setsid __P((struct proc *, void *, register_t *));
+int compat_43_sys_quota __P((struct proc *, void *, register_t *));
+int osf1_sys_sigaction __P((struct proc *, void *, register_t *));
+int compat_43_sys_getdirentries __P((struct proc *, void *, register_t *));
+int osf1_sys_statfs __P((struct proc *, void *, register_t *));
+int osf1_sys_fstatfs __P((struct proc *, void *, register_t *));
+int osf1_sys_getsid __P((struct proc *, void *, register_t *));
+int osf1_sys_sigaltstack __P((struct proc *, void *, register_t *));
+int osf1_sys_usleep_thread __P((struct proc *, void *, register_t *));
+int osf1_sys_setsysinfo __P((struct proc *, void *, register_t *));
diff --git a/sys/compat/osf1/osf1_syscalls.c b/sys/compat/osf1/osf1_syscalls.c
new file mode 100644
index 00000000000..b0b39e7a1ac
--- /dev/null
+++ b/sys/compat/osf1/osf1_syscalls.c
@@ -0,0 +1,270 @@
+/*
+ * System call names.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.2 1995/10/07 06:27:28 mycroft Exp
+ */
+
+char *osf1_syscallnames[] = {
+ "syscall", /* 0 = syscall */
+ "exit", /* 1 = exit */
+ "fork", /* 2 = fork */
+ "read", /* 3 = read */
+ "write", /* 4 = write */
+ "#5 (unimplemented old open)", /* 5 = unimplemented old open */
+ "close", /* 6 = close */
+ "wait4", /* 7 = wait4 */
+ "#8 (unimplemented old creat)", /* 8 = unimplemented old creat */
+ "link", /* 9 = link */
+ "unlink", /* 10 = unlink */
+ "#11 (unimplemented execv)", /* 11 = unimplemented execv */
+ "chdir", /* 12 = chdir */
+ "fchdir", /* 13 = fchdir */
+ "mknod", /* 14 = mknod */
+ "chmod", /* 15 = chmod */
+ "chown", /* 16 = chown */
+ "obreak", /* 17 = obreak */
+ "getfsstat", /* 18 = getfsstat */
+ "lseek", /* 19 = lseek */
+ "getpid", /* 20 = getpid */
+ "mount", /* 21 = mount */
+ "unmount", /* 22 = unmount */
+ "setuid", /* 23 = setuid */
+ "getuid", /* 24 = getuid */
+ "#25 (unimplemented exec_with_loader)", /* 25 = unimplemented exec_with_loader */
+ "#26 (unimplemented ptrace)", /* 26 = unimplemented ptrace */
+ "#27 (unimplemented recvmsg)", /* 27 = unimplemented recvmsg */
+ "#28 (unimplemented sendmsg)", /* 28 = unimplemented sendmsg */
+ "#29 (unimplemented recvfrom)", /* 29 = unimplemented recvfrom */
+ "#30 (unimplemented accept)", /* 30 = unimplemented accept */
+ "#31 (unimplemented getpeername)", /* 31 = unimplemented getpeername */
+ "#32 (unimplemented getsockname)", /* 32 = unimplemented getsockname */
+ "access", /* 33 = access */
+ "#34 (unimplemented chflags)", /* 34 = unimplemented chflags */
+ "#35 (unimplemented fchflags)", /* 35 = unimplemented fchflags */
+ "sync", /* 36 = sync */
+ "kill", /* 37 = kill */
+ "#38 (unimplemented old stat)", /* 38 = unimplemented old stat */
+ "setpgid", /* 39 = setpgid */
+ "#40 (unimplemented old lstat)", /* 40 = unimplemented old lstat */
+ "dup", /* 41 = dup */
+ "pipe", /* 42 = pipe */
+ "#43 (unimplemented set_program_attributes)", /* 43 = unimplemented set_program_attributes */
+ "#44 (unimplemented profil)", /* 44 = unimplemented profil */
+ "open", /* 45 = open */
+ "#46 (obsolete sigaction)", /* 46 = obsolete sigaction */
+ "getgid", /* 47 = getgid */
+ "sigprocmask", /* 48 = sigprocmask */
+ "getlogin", /* 49 = getlogin */
+ "setlogin", /* 50 = setlogin */
+ "acct", /* 51 = acct */
+ "#52 (unimplemented sigpending)", /* 52 = unimplemented sigpending */
+ "#53 (unimplemented)", /* 53 = unimplemented */
+ "ioctl", /* 54 = ioctl */
+ "reboot", /* 55 = reboot */
+ "revoke", /* 56 = revoke */
+ "symlink", /* 57 = symlink */
+ "readlink", /* 58 = readlink */
+ "execve", /* 59 = execve */
+ "umask", /* 60 = umask */
+ "chroot", /* 61 = chroot */
+ "#62 (unimplemented old fstat)", /* 62 = unimplemented old fstat */
+ "getpgrp", /* 63 = getpgrp */
+ "getpagesize", /* 64 = getpagesize */
+ "#65 (unimplemented mremap)", /* 65 = unimplemented mremap */
+ "vfork", /* 66 = vfork */
+ "stat", /* 67 = stat */
+ "lstat", /* 68 = lstat */
+ "#69 (unimplemented sbrk)", /* 69 = unimplemented sbrk */
+ "#70 (unimplemented sstk)", /* 70 = unimplemented sstk */
+ "mmap", /* 71 = mmap */
+ "#72 (unimplemented ovadvise)", /* 72 = unimplemented ovadvise */
+ "munmap", /* 73 = munmap */
+ "#74 (unimplemented mprotect)", /* 74 = unimplemented mprotect */
+ "madvise", /* 75 = madvise */
+ "#76 (unimplemented old vhangup)", /* 76 = unimplemented old vhangup */
+ "#77 (unimplemented kmodcall)", /* 77 = unimplemented kmodcall */
+ "#78 (unimplemented mincore)", /* 78 = unimplemented mincore */
+ "getgroups", /* 79 = getgroups */
+ "setgroups", /* 80 = setgroups */
+ "#81 (unimplemented old getpgrp)", /* 81 = unimplemented old getpgrp */
+ "setpgrp", /* 82 = setpgrp */
+ "setitimer", /* 83 = setitimer */
+ "#84 (unimplemented old wait)", /* 84 = unimplemented old wait */
+ "#85 (unimplemented table)", /* 85 = unimplemented table */
+ "#86 (unimplemented getitimer)", /* 86 = unimplemented getitimer */
+ "gethostname", /* 87 = gethostname */
+ "sethostname", /* 88 = sethostname */
+ "getdtablesize", /* 89 = getdtablesize */
+ "dup2", /* 90 = dup2 */
+ "fstat", /* 91 = fstat */
+ "fcntl", /* 92 = fcntl */
+ "select", /* 93 = select */
+ "#94 (unimplemented poll)", /* 94 = unimplemented poll */
+ "fsync", /* 95 = fsync */
+ "setpriority", /* 96 = setpriority */
+ "socket", /* 97 = socket */
+ "connect", /* 98 = connect */
+ "#99 (unimplemented old accept)", /* 99 = unimplemented old accept */
+ "getpriority", /* 100 = getpriority */
+ "send", /* 101 = send */
+ "recv", /* 102 = recv */
+ "sigreturn", /* 103 = sigreturn */
+ "bind", /* 104 = bind */
+ "setsockopt", /* 105 = setsockopt */
+ "#106 (unimplemented listen)", /* 106 = unimplemented listen */
+ "#107 (unimplemented plock)", /* 107 = unimplemented plock */
+ "#108 (unimplemented old sigvec)", /* 108 = unimplemented old sigvec */
+ "#109 (unimplemented old sigblock)", /* 109 = unimplemented old sigblock */
+ "#110 (unimplemented old sigsetmask)", /* 110 = unimplemented old sigsetmask */
+ "sigsuspend", /* 111 = sigsuspend */
+ "sigstack", /* 112 = sigstack */
+ "#113 (unimplemented old recvmsg)", /* 113 = unimplemented old recvmsg */
+ "#114 (unimplemented old sendmsg)", /* 114 = unimplemented old sendmsg */
+ "#115 (unimplemented vtrace)", /* 115 = unimplemented vtrace */
+ "gettimeofday", /* 116 = gettimeofday */
+ "getrusage", /* 117 = getrusage */
+ "getsockopt", /* 118 = getsockopt */
+ "#119 (unimplemented)", /* 119 = unimplemented */
+ "readv", /* 120 = readv */
+ "writev", /* 121 = writev */
+ "settimeofday", /* 122 = settimeofday */
+ "fchown", /* 123 = fchown */
+ "fchmod", /* 124 = fchmod */
+ "recvfrom", /* 125 = recvfrom */
+ "#126 (unimplemented setreuid)", /* 126 = unimplemented setreuid */
+ "#127 (unimplemented setregid)", /* 127 = unimplemented setregid */
+ "rename", /* 128 = rename */
+ "truncate", /* 129 = truncate */
+ "ftruncate", /* 130 = ftruncate */
+ "#131 (unimplemented flock)", /* 131 = unimplemented flock */
+ "setgid", /* 132 = setgid */
+ "sendto", /* 133 = sendto */
+ "shutdown", /* 134 = shutdown */
+ "#135 (unimplemented socketpair)", /* 135 = unimplemented socketpair */
+ "mkdir", /* 136 = mkdir */
+ "rmdir", /* 137 = rmdir */
+ "utimes", /* 138 = utimes */
+ "#139 (obsolete 4.2 sigreturn)", /* 139 = obsolete 4.2 sigreturn */
+ "#140 (unimplemented adjtime)", /* 140 = unimplemented adjtime */
+ "#141 (unimplemented old getpeername)", /* 141 = unimplemented old getpeername */
+ "gethostid", /* 142 = gethostid */
+ "sethostid", /* 143 = sethostid */
+ "getrlimit", /* 144 = getrlimit */
+ "setrlimit", /* 145 = setrlimit */
+ "#146 (unimplemented old killpg)", /* 146 = unimplemented old killpg */
+ "setsid", /* 147 = setsid */
+ "#148 (unimplemented quotactl)", /* 148 = unimplemented quotactl */
+ "quota", /* 149 = quota */
+ "#150 (unimplemented old getsockname)", /* 150 = unimplemented old getsockname */
+ "#151 (unimplemented)", /* 151 = unimplemented */
+ "#152 (unimplemented)", /* 152 = unimplemented */
+ "#153 (unimplemented)", /* 153 = unimplemented */
+ "#154 (unimplemented)", /* 154 = unimplemented */
+ "#155 (unimplemented)", /* 155 = unimplemented */
+ "sigaction", /* 156 = sigaction */
+ "#157 (unimplemented)", /* 157 = unimplemented */
+ "#158 (unimplemented nfssvc)", /* 158 = unimplemented nfssvc */
+ "getdirentries", /* 159 = getdirentries */
+ "statfs", /* 160 = statfs */
+ "fstatfs", /* 161 = fstatfs */
+ "#162 (unimplemented)", /* 162 = unimplemented */
+ "#163 (unimplemented async_daemon)", /* 163 = unimplemented async_daemon */
+ "#164 (unimplemented getfh)", /* 164 = unimplemented getfh */
+ "#165 (unimplemented getdomainname)", /* 165 = unimplemented getdomainname */
+ "#166 (unimplemented setdomainname)", /* 166 = unimplemented setdomainname */
+ "#167 (unimplemented)", /* 167 = unimplemented */
+ "#168 (unimplemented)", /* 168 = unimplemented */
+ "#169 (unimplemented exportfs)", /* 169 = unimplemented exportfs */
+ "#170 (unimplemented)", /* 170 = unimplemented */
+ "#171 (unimplemented)", /* 171 = unimplemented */
+ "#172 (unimplemented alt msgctl)", /* 172 = unimplemented alt msgctl */
+ "#173 (unimplemented alt msgget)", /* 173 = unimplemented alt msgget */
+ "#174 (unimplemented alt msgrcv)", /* 174 = unimplemented alt msgrcv */
+ "#175 (unimplemented alt msgsnd)", /* 175 = unimplemented alt msgsnd */
+ "#176 (unimplemented alt semctl)", /* 176 = unimplemented alt semctl */
+ "#177 (unimplemented alt semget)", /* 177 = unimplemented alt semget */
+ "#178 (unimplemented alt semop)", /* 178 = unimplemented alt semop */
+ "#179 (unimplemented alt uname)", /* 179 = unimplemented alt uname */
+ "#180 (unimplemented)", /* 180 = unimplemented */
+ "#181 (unimplemented alt plock)", /* 181 = unimplemented alt plock */
+ "#182 (unimplemented lockf)", /* 182 = unimplemented lockf */
+ "#183 (unimplemented)", /* 183 = unimplemented */
+ "#184 (unimplemented getmnt)", /* 184 = unimplemented getmnt */
+ "#185 (unimplemented)", /* 185 = unimplemented */
+ "#186 (unimplemented unmount)", /* 186 = unimplemented unmount */
+ "#187 (unimplemented alt sigpending)", /* 187 = unimplemented alt sigpending */
+ "#188 (unimplemented alt setsid)", /* 188 = unimplemented alt setsid */
+ "#189 (unimplemented)", /* 189 = unimplemented */
+ "#190 (unimplemented)", /* 190 = unimplemented */
+ "#191 (unimplemented)", /* 191 = unimplemented */
+ "#192 (unimplemented)", /* 192 = unimplemented */
+ "#193 (unimplemented)", /* 193 = unimplemented */
+ "#194 (unimplemented)", /* 194 = unimplemented */
+ "#195 (unimplemented)", /* 195 = unimplemented */
+ "#196 (unimplemented)", /* 196 = unimplemented */
+ "#197 (unimplemented)", /* 197 = unimplemented */
+ "#198 (unimplemented)", /* 198 = unimplemented */
+ "#199 (unimplemented swapon)", /* 199 = unimplemented swapon */
+ "#200 (unimplemented msgctl)", /* 200 = unimplemented msgctl */
+ "#201 (unimplemented msgget)", /* 201 = unimplemented msgget */
+ "#202 (unimplemented msgrcv)", /* 202 = unimplemented msgrcv */
+ "#203 (unimplemented msgsnd)", /* 203 = unimplemented msgsnd */
+ "#204 (unimplemented semctl)", /* 204 = unimplemented semctl */
+ "#205 (unimplemented semget)", /* 205 = unimplemented semget */
+ "#206 (unimplemented semop)", /* 206 = unimplemented semop */
+ "#207 (unimplemented uname)", /* 207 = unimplemented uname */
+ "#208 (unimplemented lchown)", /* 208 = unimplemented lchown */
+ "#209 (unimplemented shmat)", /* 209 = unimplemented shmat */
+ "#210 (unimplemented shmctl)", /* 210 = unimplemented shmctl */
+ "#211 (unimplemented shmdt)", /* 211 = unimplemented shmdt */
+ "#212 (unimplemented shmget)", /* 212 = unimplemented shmget */
+ "#213 (unimplemented mvalid)", /* 213 = unimplemented mvalid */
+ "#214 (unimplemented getaddressconf)", /* 214 = unimplemented getaddressconf */
+ "#215 (unimplemented msleep)", /* 215 = unimplemented msleep */
+ "#216 (unimplemented mwakeup)", /* 216 = unimplemented mwakeup */
+ "#217 (unimplemented msync)", /* 217 = unimplemented msync */
+ "#218 (unimplemented signal)", /* 218 = unimplemented signal */
+ "#219 (unimplemented utc gettime)", /* 219 = unimplemented utc gettime */
+ "#220 (unimplemented utc adjtime)", /* 220 = unimplemented utc adjtime */
+ "#221 (unimplemented)", /* 221 = unimplemented */
+ "#222 (unimplemented security)", /* 222 = unimplemented security */
+ "#223 (unimplemented kloadcall)", /* 223 = unimplemented kloadcall */
+ "#224 (unimplemented)", /* 224 = unimplemented */
+ "#225 (unimplemented)", /* 225 = unimplemented */
+ "#226 (unimplemented)", /* 226 = unimplemented */
+ "#227 (unimplemented)", /* 227 = unimplemented */
+ "#228 (unimplemented)", /* 228 = unimplemented */
+ "#229 (unimplemented)", /* 229 = unimplemented */
+ "#230 (unimplemented)", /* 230 = unimplemented */
+ "#231 (unimplemented)", /* 231 = unimplemented */
+ "#232 (unimplemented)", /* 232 = unimplemented */
+ "#233 (unimplemented getpgid)", /* 233 = unimplemented getpgid */
+ "getsid", /* 234 = getsid */
+ "sigaltstack", /* 235 = sigaltstack */
+ "#236 (unimplemented waitid)", /* 236 = unimplemented waitid */
+ "#237 (unimplemented priocntlset)", /* 237 = unimplemented priocntlset */
+ "#238 (unimplemented sigsendset)", /* 238 = unimplemented sigsendset */
+ "#239 (unimplemented)", /* 239 = unimplemented */
+ "#240 (unimplemented msfs_syscall)", /* 240 = unimplemented msfs_syscall */
+ "#241 (unimplemented sysinfo)", /* 241 = unimplemented sysinfo */
+ "#242 (unimplemented uadmin)", /* 242 = unimplemented uadmin */
+ "#243 (unimplemented fuser)", /* 243 = unimplemented fuser */
+ "#244 (unimplemented)", /* 244 = unimplemented */
+ "#245 (unimplemented)", /* 245 = unimplemented */
+ "#246 (unimplemented)", /* 246 = unimplemented */
+ "#247 (unimplemented)", /* 247 = unimplemented */
+ "#248 (unimplemented)", /* 248 = unimplemented */
+ "#249 (unimplemented)", /* 249 = unimplemented */
+ "#250 (unimplemented uswitch)", /* 250 = unimplemented uswitch */
+ "usleep_thread", /* 251 = usleep_thread */
+ "#252 (unimplemented audcntl)", /* 252 = unimplemented audcntl */
+ "#253 (unimplemented audgen)", /* 253 = unimplemented audgen */
+ "#254 (unimplemented sysfs)", /* 254 = unimplemented sysfs */
+ "#255 (unimplemented)", /* 255 = unimplemented */
+ "#256 (unimplemented getsysinfo)", /* 256 = unimplemented getsysinfo */
+ "setsysinfo", /* 257 = setsysinfo */
+ "#258 (unimplemented afs_syscall)", /* 258 = unimplemented afs_syscall */
+ "#259 (unimplemented swapctl)", /* 259 = unimplemented swapctl */
+ "#260 (unimplemented memcntl)", /* 260 = unimplemented memcntl */
+};
diff --git a/sys/compat/osf1/osf1_sysent.c b/sys/compat/osf1/osf1_sysent.c
new file mode 100644
index 00000000000..20e7fb00486
--- /dev/null
+++ b/sys/compat/osf1/osf1_sysent.c
@@ -0,0 +1,541 @@
+/*
+ * System call switch table.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.2 1995/10/07 06:27:28 mycroft Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signal.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <compat/osf1/osf1_syscallargs.h>
+
+#define s(type) sizeof(type)
+
+struct sysent osf1_sysent[] = {
+ { 0, 0,
+ sys_nosys }, /* 0 = syscall */
+ { 1, s(struct sys_exit_args),
+ sys_exit }, /* 1 = exit */
+ { 0, 0,
+ sys_fork }, /* 2 = fork */
+ { 3, s(struct sys_read_args),
+ sys_read }, /* 3 = read */
+ { 3, s(struct sys_write_args),
+ sys_write }, /* 4 = write */
+ { 0, 0,
+ sys_nosys }, /* 5 = unimplemented old open */
+ { 1, s(struct sys_close_args),
+ sys_close }, /* 6 = close */
+ { 4, s(struct sys_wait4_args),
+ sys_wait4 }, /* 7 = wait4 */
+ { 0, 0,
+ sys_nosys }, /* 8 = unimplemented old creat */
+ { 2, s(struct sys_link_args),
+ sys_link }, /* 9 = link */
+ { 1, s(struct sys_unlink_args),
+ sys_unlink }, /* 10 = unlink */
+ { 0, 0,
+ sys_nosys }, /* 11 = unimplemented execv */
+ { 1, s(struct sys_chdir_args),
+ sys_chdir }, /* 12 = chdir */
+ { 1, s(struct sys_fchdir_args),
+ sys_fchdir }, /* 13 = fchdir */
+ { 3, s(struct osf1_sys_mknod_args),
+ osf1_sys_mknod }, /* 14 = mknod */
+ { 2, s(struct sys_chmod_args),
+ sys_chmod }, /* 15 = chmod */
+ { 3, s(struct sys_chown_args),
+ sys_chown }, /* 16 = chown */
+ { 1, s(struct sys_obreak_args),
+ sys_obreak }, /* 17 = obreak */
+ { 3, s(struct osf1_sys_getfsstat_args),
+ osf1_sys_getfsstat }, /* 18 = getfsstat */
+ { 3, s(struct osf1_sys_lseek_args),
+ osf1_sys_lseek }, /* 19 = lseek */
+ { 0, 0,
+ sys_getpid }, /* 20 = getpid */
+ { 4, s(struct osf1_sys_mount_args),
+ osf1_sys_mount }, /* 21 = mount */
+ { 2, s(struct osf1_sys_unmount_args),
+ osf1_sys_unmount }, /* 22 = unmount */
+ { 1, s(struct osf1_sys_setuid_args),
+ osf1_sys_setuid }, /* 23 = setuid */
+ { 0, 0,
+ sys_getuid }, /* 24 = getuid */
+ { 0, 0,
+ sys_nosys }, /* 25 = unimplemented exec_with_loader */
+ { 0, 0,
+ sys_nosys }, /* 26 = unimplemented ptrace */
+ { 0, 0,
+ sys_nosys }, /* 27 = unimplemented recvmsg */
+ { 0, 0,
+ sys_nosys }, /* 28 = unimplemented sendmsg */
+ { 0, 0,
+ sys_nosys }, /* 29 = unimplemented recvfrom */
+ { 0, 0,
+ sys_nosys }, /* 30 = unimplemented accept */
+ { 0, 0,
+ sys_nosys }, /* 31 = unimplemented getpeername */
+ { 0, 0,
+ sys_nosys }, /* 32 = unimplemented getsockname */
+ { 2, s(struct sys_access_args),
+ sys_access }, /* 33 = access */
+ { 0, 0,
+ sys_nosys }, /* 34 = unimplemented chflags */
+ { 0, 0,
+ sys_nosys }, /* 35 = unimplemented fchflags */
+ { 0, 0,
+ sys_sync }, /* 36 = sync */
+ { 2, s(struct sys_kill_args),
+ sys_kill }, /* 37 = kill */
+ { 0, 0,
+ sys_nosys }, /* 38 = unimplemented old stat */
+ { 2, s(struct sys_setpgid_args),
+ sys_setpgid }, /* 39 = setpgid */
+ { 0, 0,
+ sys_nosys }, /* 40 = unimplemented old lstat */
+ { 1, s(struct sys_dup_args),
+ sys_dup }, /* 41 = dup */
+ { 0, 0,
+ sys_pipe }, /* 42 = pipe */
+ { 0, 0,
+ sys_nosys }, /* 43 = unimplemented set_program_attributes */
+ { 0, 0,
+ sys_nosys }, /* 44 = unimplemented profil */
+ { 3, s(struct osf1_sys_open_args),
+ osf1_sys_open }, /* 45 = open */
+ { 0, 0,
+ sys_nosys }, /* 46 = obsolete sigaction */
+ { 0, 0,
+ sys_getgid }, /* 47 = getgid */
+ { 2, s(struct sys_sigprocmask_args),
+ sys_sigprocmask }, /* 48 = sigprocmask */
+ { 2, s(struct sys_getlogin_args),
+ sys_getlogin }, /* 49 = getlogin */
+ { 1, s(struct sys_setlogin_args),
+ sys_setlogin }, /* 50 = setlogin */
+ { 1, s(struct sys_acct_args),
+ sys_acct }, /* 51 = acct */
+ { 0, 0,
+ sys_nosys }, /* 52 = unimplemented sigpending */
+ { 0, 0,
+ sys_nosys }, /* 53 = unimplemented */
+ { 3, s(struct osf1_sys_ioctl_args),
+ osf1_sys_ioctl }, /* 54 = ioctl */
+ { 1, s(struct osf1_sys_reboot_args),
+ osf1_sys_reboot }, /* 55 = reboot */
+ { 1, s(struct sys_revoke_args),
+ sys_revoke }, /* 56 = revoke */
+ { 2, s(struct sys_symlink_args),
+ sys_symlink }, /* 57 = symlink */
+ { 3, s(struct sys_readlink_args),
+ sys_readlink }, /* 58 = readlink */
+ { 3, s(struct sys_execve_args),
+ sys_execve }, /* 59 = execve */
+ { 1, s(struct sys_umask_args),
+ sys_umask }, /* 60 = umask */
+ { 1, s(struct sys_chroot_args),
+ sys_chroot }, /* 61 = chroot */
+ { 0, 0,
+ sys_nosys }, /* 62 = unimplemented old fstat */
+ { 0, 0,
+ sys_getpgrp }, /* 63 = getpgrp */
+ { 0, 0,
+ compat_43_sys_getpagesize }, /* 64 = getpagesize */
+ { 0, 0,
+ sys_nosys }, /* 65 = unimplemented mremap */
+ { 0, 0,
+ sys_vfork }, /* 66 = vfork */
+ { 2, s(struct osf1_sys_stat_args),
+ osf1_sys_stat }, /* 67 = stat */
+ { 2, s(struct osf1_sys_lstat_args),
+ osf1_sys_lstat }, /* 68 = lstat */
+ { 0, 0,
+ sys_nosys }, /* 69 = unimplemented sbrk */
+ { 0, 0,
+ sys_nosys }, /* 70 = unimplemented sstk */
+ { 6, s(struct osf1_sys_mmap_args),
+ osf1_sys_mmap }, /* 71 = mmap */
+ { 0, 0,
+ sys_nosys }, /* 72 = unimplemented ovadvise */
+ { 2, s(struct sys_munmap_args),
+ sys_munmap }, /* 73 = munmap */
+ { 0, 0,
+ sys_nosys }, /* 74 = unimplemented mprotect */
+ { 0, 0,
+ osf1_sys_madvise }, /* 75 = madvise */
+ { 0, 0,
+ sys_nosys }, /* 76 = unimplemented old vhangup */
+ { 0, 0,
+ sys_nosys }, /* 77 = unimplemented kmodcall */
+ { 0, 0,
+ sys_nosys }, /* 78 = unimplemented mincore */
+ { 2, s(struct sys_getgroups_args),
+ sys_getgroups }, /* 79 = getgroups */
+ { 2, s(struct sys_setgroups_args),
+ sys_setgroups }, /* 80 = setgroups */
+ { 0, 0,
+ sys_nosys }, /* 81 = unimplemented old getpgrp */
+ { 2, s(struct sys_setpgid_args),
+ sys_setpgid }, /* 82 = setpgrp */
+ { 3, s(struct sys_setitimer_args),
+ sys_setitimer }, /* 83 = setitimer */
+ { 0, 0,
+ sys_nosys }, /* 84 = unimplemented old wait */
+ { 0, 0,
+ sys_nosys }, /* 85 = unimplemented table */
+ { 0, 0,
+ sys_nosys }, /* 86 = unimplemented getitimer */
+ { 2, s(struct compat_43_sys_gethostname_args),
+ compat_43_sys_gethostname }, /* 87 = gethostname */
+ { 2, s(struct compat_43_sys_sethostname_args),
+ compat_43_sys_sethostname }, /* 88 = sethostname */
+ { 0, 0,
+ compat_43_sys_getdtablesize }, /* 89 = getdtablesize */
+ { 2, s(struct sys_dup2_args),
+ sys_dup2 }, /* 90 = dup2 */
+ { 2, s(struct osf1_sys_fstat_args),
+ osf1_sys_fstat }, /* 91 = fstat */
+ { 3, s(struct osf1_sys_fcntl_args),
+ osf1_sys_fcntl }, /* 92 = fcntl */
+ { 5, s(struct sys_select_args),
+ sys_select }, /* 93 = select */
+ { 0, 0,
+ sys_nosys }, /* 94 = unimplemented poll */
+ { 1, s(struct sys_fsync_args),
+ sys_fsync }, /* 95 = fsync */
+ { 3, s(struct sys_setpriority_args),
+ sys_setpriority }, /* 96 = setpriority */
+ { 3, s(struct osf1_sys_socket_args),
+ osf1_sys_socket }, /* 97 = socket */
+ { 3, s(struct sys_connect_args),
+ sys_connect }, /* 98 = connect */
+ { 0, 0,
+ sys_nosys }, /* 99 = unimplemented old accept */
+ { 2, s(struct sys_getpriority_args),
+ sys_getpriority }, /* 100 = getpriority */
+ { 4, s(struct compat_43_sys_send_args),
+ compat_43_sys_send }, /* 101 = send */
+ { 4, s(struct compat_43_sys_recv_args),
+ compat_43_sys_recv }, /* 102 = recv */
+ { 1, s(struct sys_sigreturn_args),
+ sys_sigreturn }, /* 103 = sigreturn */
+ { 3, s(struct sys_bind_args),
+ sys_bind }, /* 104 = bind */
+ { 5, s(struct sys_setsockopt_args),
+ sys_setsockopt }, /* 105 = setsockopt */
+ { 0, 0,
+ sys_nosys }, /* 106 = unimplemented listen */
+ { 0, 0,
+ sys_nosys }, /* 107 = unimplemented plock */
+ { 0, 0,
+ sys_nosys }, /* 108 = unimplemented old sigvec */
+ { 0, 0,
+ sys_nosys }, /* 109 = unimplemented old sigblock */
+ { 0, 0,
+ sys_nosys }, /* 110 = unimplemented old sigsetmask */
+ { 1, s(struct sys_sigsuspend_args),
+ sys_sigsuspend }, /* 111 = sigsuspend */
+ { 2, s(struct compat_43_sys_sigstack_args),
+ compat_43_sys_sigstack }, /* 112 = sigstack */
+ { 0, 0,
+ sys_nosys }, /* 113 = unimplemented old recvmsg */
+ { 0, 0,
+ sys_nosys }, /* 114 = unimplemented old sendmsg */
+ { 0, 0,
+ sys_nosys }, /* 115 = unimplemented vtrace */
+ { 2, s(struct sys_gettimeofday_args),
+ sys_gettimeofday }, /* 116 = gettimeofday */
+ { 0, 0,
+ osf1_sys_getrusage }, /* 117 = getrusage */
+ { 5, s(struct sys_getsockopt_args),
+ sys_getsockopt }, /* 118 = getsockopt */
+ { 0, 0,
+ sys_nosys }, /* 119 = unimplemented */
+ { 3, s(struct osf1_sys_readv_args),
+ osf1_sys_readv }, /* 120 = readv */
+ { 3, s(struct osf1_sys_writev_args),
+ osf1_sys_writev }, /* 121 = writev */
+ { 2, s(struct sys_settimeofday_args),
+ sys_settimeofday }, /* 122 = settimeofday */
+ { 3, s(struct sys_fchown_args),
+ sys_fchown }, /* 123 = fchown */
+ { 2, s(struct sys_fchmod_args),
+ sys_fchmod }, /* 124 = fchmod */
+ { 6, s(struct compat_43_sys_recvfrom_args),
+ compat_43_sys_recvfrom }, /* 125 = recvfrom */
+ { 0, 0,
+ sys_nosys }, /* 126 = unimplemented setreuid */
+ { 0, 0,
+ sys_nosys }, /* 127 = unimplemented setregid */
+ { 2, s(struct sys_rename_args),
+ sys_rename }, /* 128 = rename */
+ { 2, s(struct osf1_sys_truncate_args),
+ osf1_sys_truncate }, /* 129 = truncate */
+ { 2, s(struct osf1_sys_ftruncate_args),
+ osf1_sys_ftruncate }, /* 130 = ftruncate */
+ { 0, 0,
+ sys_nosys }, /* 131 = unimplemented flock */
+ { 1, s(struct osf1_sys_setgid_args),
+ osf1_sys_setgid }, /* 132 = setgid */
+ { 6, s(struct osf1_sys_sendto_args),
+ osf1_sys_sendto }, /* 133 = sendto */
+ { 2, s(struct sys_shutdown_args),
+ sys_shutdown }, /* 134 = shutdown */
+ { 0, 0,
+ sys_nosys }, /* 135 = unimplemented socketpair */
+ { 2, s(struct sys_mkdir_args),
+ sys_mkdir }, /* 136 = mkdir */
+ { 1, s(struct sys_rmdir_args),
+ sys_rmdir }, /* 137 = rmdir */
+ { 2, s(struct sys_utimes_args),
+ sys_utimes }, /* 138 = utimes */
+ { 0, 0,
+ sys_nosys }, /* 139 = obsolete 4.2 sigreturn */
+ { 0, 0,
+ sys_nosys }, /* 140 = unimplemented adjtime */
+ { 0, 0,
+ sys_nosys }, /* 141 = unimplemented old getpeername */
+ { 0, 0,
+ compat_43_sys_gethostid }, /* 142 = gethostid */
+ { 1, s(struct compat_43_sys_sethostid_args),
+ compat_43_sys_sethostid }, /* 143 = sethostid */
+ { 2, s(struct osf1_sys_getrlimit_args),
+ osf1_sys_getrlimit }, /* 144 = getrlimit */
+ { 2, s(struct osf1_sys_setrlimit_args),
+ osf1_sys_setrlimit }, /* 145 = setrlimit */
+ { 0, 0,
+ sys_nosys }, /* 146 = unimplemented old killpg */
+ { 0, 0,
+ sys_setsid }, /* 147 = setsid */
+ { 0, 0,
+ sys_nosys }, /* 148 = unimplemented quotactl */
+ { 0, 0,
+ compat_43_sys_quota }, /* 149 = quota */
+ { 0, 0,
+ sys_nosys }, /* 150 = unimplemented old getsockname */
+ { 0, 0,
+ sys_nosys }, /* 151 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 152 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 153 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 154 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 155 = unimplemented */
+ { 3, s(struct osf1_sys_sigaction_args),
+ osf1_sys_sigaction }, /* 156 = sigaction */
+ { 0, 0,
+ sys_nosys }, /* 157 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 158 = unimplemented nfssvc */
+ { 4, s(struct compat_43_sys_getdirentries_args),
+ compat_43_sys_getdirentries }, /* 159 = getdirentries */
+ { 3, s(struct osf1_sys_statfs_args),
+ osf1_sys_statfs }, /* 160 = statfs */
+ { 3, s(struct osf1_sys_fstatfs_args),
+ osf1_sys_fstatfs }, /* 161 = fstatfs */
+ { 0, 0,
+ sys_nosys }, /* 162 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 163 = unimplemented async_daemon */
+ { 0, 0,
+ sys_nosys }, /* 164 = unimplemented getfh */
+ { 0, 0,
+ sys_nosys }, /* 165 = unimplemented getdomainname */
+ { 0, 0,
+ sys_nosys }, /* 166 = unimplemented setdomainname */
+ { 0, 0,
+ sys_nosys }, /* 167 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 168 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 169 = unimplemented exportfs */
+ { 0, 0,
+ sys_nosys }, /* 170 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 171 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 172 = unimplemented alt msgctl */
+ { 0, 0,
+ sys_nosys }, /* 173 = unimplemented alt msgget */
+ { 0, 0,
+ sys_nosys }, /* 174 = unimplemented alt msgrcv */
+ { 0, 0,
+ sys_nosys }, /* 175 = unimplemented alt msgsnd */
+ { 0, 0,
+ sys_nosys }, /* 176 = unimplemented alt semctl */
+ { 0, 0,
+ sys_nosys }, /* 177 = unimplemented alt semget */
+ { 0, 0,
+ sys_nosys }, /* 178 = unimplemented alt semop */
+ { 0, 0,
+ sys_nosys }, /* 179 = unimplemented alt uname */
+ { 0, 0,
+ sys_nosys }, /* 180 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 181 = unimplemented alt plock */
+ { 0, 0,
+ sys_nosys }, /* 182 = unimplemented lockf */
+ { 0, 0,
+ sys_nosys }, /* 183 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 184 = unimplemented getmnt */
+ { 0, 0,
+ sys_nosys }, /* 185 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 186 = unimplemented unmount */
+ { 0, 0,
+ sys_nosys }, /* 187 = unimplemented alt sigpending */
+ { 0, 0,
+ sys_nosys }, /* 188 = unimplemented alt setsid */
+ { 0, 0,
+ sys_nosys }, /* 189 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 190 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 191 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 192 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 193 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 194 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 195 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 196 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 197 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 198 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 199 = unimplemented swapon */
+ { 0, 0,
+ sys_nosys }, /* 200 = unimplemented msgctl */
+ { 0, 0,
+ sys_nosys }, /* 201 = unimplemented msgget */
+ { 0, 0,
+ sys_nosys }, /* 202 = unimplemented msgrcv */
+ { 0, 0,
+ sys_nosys }, /* 203 = unimplemented msgsnd */
+ { 0, 0,
+ sys_nosys }, /* 204 = unimplemented semctl */
+ { 0, 0,
+ sys_nosys }, /* 205 = unimplemented semget */
+ { 0, 0,
+ sys_nosys }, /* 206 = unimplemented semop */
+ { 0, 0,
+ sys_nosys }, /* 207 = unimplemented uname */
+ { 0, 0,
+ sys_nosys }, /* 208 = unimplemented lchown */
+ { 0, 0,
+ sys_nosys }, /* 209 = unimplemented shmat */
+ { 0, 0,
+ sys_nosys }, /* 210 = unimplemented shmctl */
+ { 0, 0,
+ sys_nosys }, /* 211 = unimplemented shmdt */
+ { 0, 0,
+ sys_nosys }, /* 212 = unimplemented shmget */
+ { 0, 0,
+ sys_nosys }, /* 213 = unimplemented mvalid */
+ { 0, 0,
+ sys_nosys }, /* 214 = unimplemented getaddressconf */
+ { 0, 0,
+ sys_nosys }, /* 215 = unimplemented msleep */
+ { 0, 0,
+ sys_nosys }, /* 216 = unimplemented mwakeup */
+ { 0, 0,
+ sys_nosys }, /* 217 = unimplemented msync */
+ { 0, 0,
+ sys_nosys }, /* 218 = unimplemented signal */
+ { 0, 0,
+ sys_nosys }, /* 219 = unimplemented utc gettime */
+ { 0, 0,
+ sys_nosys }, /* 220 = unimplemented utc adjtime */
+ { 0, 0,
+ sys_nosys }, /* 221 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 222 = unimplemented security */
+ { 0, 0,
+ sys_nosys }, /* 223 = unimplemented kloadcall */
+ { 0, 0,
+ sys_nosys }, /* 224 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 225 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 226 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 227 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 228 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 229 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 230 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 231 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 232 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 233 = unimplemented getpgid */
+ { 1, s(struct osf1_sys_getsid_args),
+ osf1_sys_getsid }, /* 234 = getsid */
+ { 2, s(struct osf1_sys_sigaltstack_args),
+ osf1_sys_sigaltstack }, /* 235 = sigaltstack */
+ { 0, 0,
+ sys_nosys }, /* 236 = unimplemented waitid */
+ { 0, 0,
+ sys_nosys }, /* 237 = unimplemented priocntlset */
+ { 0, 0,
+ sys_nosys }, /* 238 = unimplemented sigsendset */
+ { 0, 0,
+ sys_nosys }, /* 239 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 240 = unimplemented msfs_syscall */
+ { 0, 0,
+ sys_nosys }, /* 241 = unimplemented sysinfo */
+ { 0, 0,
+ sys_nosys }, /* 242 = unimplemented uadmin */
+ { 0, 0,
+ sys_nosys }, /* 243 = unimplemented fuser */
+ { 0, 0,
+ sys_nosys }, /* 244 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 245 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 246 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 247 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 248 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 249 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 250 = unimplemented uswitch */
+ { 2, s(struct osf1_sys_usleep_thread_args),
+ osf1_sys_usleep_thread }, /* 251 = usleep_thread */
+ { 0, 0,
+ sys_nosys }, /* 252 = unimplemented audcntl */
+ { 0, 0,
+ sys_nosys }, /* 253 = unimplemented audgen */
+ { 0, 0,
+ sys_nosys }, /* 254 = unimplemented sysfs */
+ { 0, 0,
+ sys_nosys }, /* 255 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 256 = unimplemented getsysinfo */
+ { 5, s(struct osf1_sys_setsysinfo_args),
+ osf1_sys_setsysinfo }, /* 257 = setsysinfo */
+ { 0, 0,
+ sys_nosys }, /* 258 = unimplemented afs_syscall */
+ { 0, 0,
+ sys_nosys }, /* 259 = unimplemented swapctl */
+ { 0, 0,
+ sys_nosys }, /* 260 = unimplemented memcntl */
+};
+
diff --git a/sys/compat/osf1/osf1_util.h b/sys/compat/osf1/osf1_util.h
new file mode 100644
index 00000000000..99f0bac8647
--- /dev/null
+++ b/sys/compat/osf1/osf1_util.h
@@ -0,0 +1 @@
+#include <compat/common/compat_util.h>
diff --git a/sys/compat/osf1/syscalls.conf b/sys/compat/osf1/syscalls.conf
new file mode 100644
index 00000000000..ffa7904533e
--- /dev/null
+++ b/sys/compat/osf1/syscalls.conf
@@ -0,0 +1,12 @@
+# $NetBSD: syscalls.conf,v 1.1 1995/02/13 21:39:08 cgd Exp $
+
+sysnames="osf1_syscalls.c"
+sysnumhdr="osf1_syscall.h"
+syssw="osf1_sysent.c"
+sysarghdr="osf1_syscallargs.h"
+compatopts=""
+libcompatopts=""
+
+switchname="osf1_sysent"
+namesname="osf1_syscallnames"
+constprefix="OSF1_SYS_"
diff --git a/sys/compat/osf1/syscalls.master b/sys/compat/osf1/syscalls.master
new file mode 100644
index 00000000000..b2598938356
--- /dev/null
+++ b/sys/compat/osf1/syscalls.master
@@ -0,0 +1,338 @@
+ $NetBSD: syscalls.master,v 1.2 1995/10/07 06:27:28 mycroft Exp $
+
+; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
+
+; NetBSD COMPAT_OSF1 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
+;
+; 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 <compat/osf1/osf1_syscallargs.h>
+
+0 NOARGS { int sys_nosys(void); } syscall
+1 NOARGS { int sys_exit(int rval); }
+2 NOARGS { int sys_fork(void); }
+3 NOARGS { int sys_read(int fd, char *buf, u_int nbyte); }
+4 NOARGS { int sys_write(int fd, char *buf, u_int nbyte); }
+5 UNIMPL old open
+6 NOARGS { int sys_close(int fd); }
+7 NOARGS { int sys_wait4(int pid, int *status, int options, \
+ struct rusage *rusage); }
+8 UNIMPL old creat
+9 NOARGS { int sys_link(char *path, char *link); }
+10 NOARGS { int sys_unlink(char *path); }
+11 UNIMPL execv
+12 NOARGS { int sys_chdir(char *path); }
+13 NOARGS { int sys_fchdir(int fd); }
+14 STD { int osf1_sys_mknod(char *path, int mode, int dev); }
+15 NOARGS { int sys_chmod(char *path, int mode); }
+16 NOARGS { int sys_chown(char *path, int uid, int gid); }
+17 NOARGS { int sys_obreak(char *nsize); }
+18 STD { int osf1_sys_getfsstat(struct osf1_statfs *buf, \
+ long bufsize, int flags); }
+19 STD { off_t osf1_sys_lseek(int fd, off_t offset, \
+ int whence); }
+20 NOARGS { pid_t sys_getpid(void); }
+21 STD { int osf1_sys_mount(int type, char *path, int flags, \
+ caddr_t data); }
+22 STD { int osf1_sys_unmount(char *path, int flags); }
+23 STD { int osf1_sys_setuid(uid_t uid); }
+24 NOARGS { uid_t sys_getuid(void); }
+25 UNIMPL exec_with_loader
+26 UNIMPL ptrace
+27 UNIMPL recvmsg
+28 UNIMPL sendmsg
+29 UNIMPL recvfrom
+30 UNIMPL accept
+31 UNIMPL getpeername
+32 UNIMPL getsockname
+33 NOARGS { int sys_access(char *path, int flags); }
+34 UNIMPL chflags
+35 UNIMPL fchflags
+36 NOARGS { int sys_sync(void); }
+37 NOARGS { int sys_kill(int pid, int signum); }
+38 UNIMPL old stat
+39 NOARGS { int sys_setpgid(int pid, int pgid); }
+40 UNIMPL old lstat
+41 NOARGS { int sys_dup(u_int fd); }
+42 NOARGS { int sys_pipe(void); }
+43 UNIMPL set_program_attributes
+44 UNIMPL profil
+45 STD { int osf1_sys_open(char *path, int flags, int mode); }
+46 OBSOL sigaction
+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(char *namebuf); }
+51 NOARGS { int sys_acct(char *path); }
+52 UNIMPL sigpending
+53 UNIMPL
+54 STD { int osf1_sys_ioctl(int fd, int com, caddr_t data); }
+55 STD { int osf1_sys_reboot(int opt); }
+56 NOARGS { int sys_revoke(char *path); }
+57 NOARGS { int sys_symlink(char *path, char *link); }
+58 NOARGS { int sys_readlink(char *path, char *buf, int count); }
+59 NOARGS { int sys_execve(char *path, char **argp, \
+ char **envp); }
+60 NOARGS { int sys_umask(int newmask); }
+61 NOARGS { int sys_chroot(char *path); }
+62 UNIMPL old fstat
+63 NOARGS { int sys_getpgrp(void); }
+64 NOARGS { int compat_43_sys_getpagesize(void); }
+65 UNIMPL mremap
+66 NOARGS { int sys_vfork(void); }
+67 STD { int osf1_sys_stat(char *path, struct osf1_stat *ub); }
+68 STD { int osf1_sys_lstat(char *path, \
+ struct osf1_stat *ub); }
+69 UNIMPL sbrk
+70 UNIMPL sstk
+71 STD { caddr_t osf1_sys_mmap(caddr_t addr, size_t len, \
+ int prot, int flags, int fd, off_t pos); }
+72 UNIMPL ovadvise
+73 NOARGS { int sys_munmap(caddr_t addr, size_t len); }
+74 UNIMPL mprotect
+; XXX
+75 STD { int osf1_sys_madvise(void); }
+76 UNIMPL old vhangup
+77 UNIMPL kmodcall
+78 UNIMPL mincore
+79 NOARGS { int sys_getgroups(u_int gidsetsize, gid_t *gidset); }
+80 NOARGS { int sys_setgroups(u_int gidsetsize, gid_t *gidset); }
+81 UNIMPL old getpgrp
+; OSF/1 setpgrp(); identical in function to setpgid(). XXX
+82 NOARGS { int sys_setpgid(int pid, int pgid); } setpgrp
+83 NOARGS { int sys_setitimer(u_int which, \
+ struct itimerval *itv, struct itimerval *oitv); }
+84 UNIMPL old wait
+85 UNIMPL table
+86 UNIMPL getitimer
+87 NOARGS { int compat_43_sys_gethostname(char *hostname, \
+ u_int len); }
+88 NOARGS { int compat_43_sys_sethostname(char *hostname, \
+ u_int len); }
+89 NOARGS { int compat_43_sys_getdtablesize(void); }
+90 NOARGS { int sys_dup2(u_int from, u_int to); }
+91 STD { int osf1_sys_fstat(int fd, void *sb); }
+92 STD { int osf1_sys_fcntl(int fd, int cmd, void *arg); }
+93 NOARGS { int sys_select(u_int nd, fd_set *in, fd_set *ou, \
+ fd_set *ex, struct timeval *tv); }
+94 UNIMPL poll
+95 NOARGS { int sys_fsync(int fd); }
+96 NOARGS { int sys_setpriority(int which, int who, int prio); }
+97 STD { int osf1_sys_socket(int domain, int type, \
+ int protocol); }
+98 NOARGS { int sys_connect(int s, caddr_t name, int namelen); }
+99 UNIMPL old accept
+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); }
+102 NOARGS { int compat_43_sys_recv(int s, caddr_t buf, int len, \
+ int flags); }
+103 NOARGS { int sys_sigreturn(struct sigcontext *sigcntxp); }
+104 NOARGS { int sys_bind(int s, caddr_t name, int namelen); }
+105 NOARGS { int sys_setsockopt(int s, int level, int name, \
+ caddr_t val, int valsize); }
+106 UNIMPL listen
+107 UNIMPL plock
+108 UNIMPL old sigvec
+109 UNIMPL old sigblock
+110 UNIMPL old sigsetmask
+111 NOARGS { int sys_sigsuspend(int mask); }
+112 NOARGS { int compat_43_sys_sigstack(struct sigstack *nss, \
+ struct sigstack *oss); }
+113 UNIMPL old recvmsg
+114 UNIMPL old sendmsg
+115 UNIMPL vtrace
+116 NOARGS { int sys_gettimeofday(struct timeval *tp, \
+ struct timezone *tzp); }
+; XXX
+117 STD { int osf1_sys_getrusage(void); }
+118 NOARGS { int sys_getsockopt(int s, int level, int name, \
+ caddr_t val, int *avalsize); }
+119 UNIMPL
+120 STD { int osf1_sys_readv(int fd, struct osf1_iovec *iovp, \
+ u_int iovcnt); }
+121 STD { int osf1_sys_writev(int fd, struct osf1_iovec *iovp, \
+ u_int iovcnt); }
+122 NOARGS { int sys_settimeofday(struct timeval *tv, \
+ struct timezone *tzp); }
+123 NOARGS { int sys_fchown(int fd, int uid, int 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); }
+126 UNIMPL setreuid
+127 UNIMPL setregid
+128 NOARGS { int sys_rename(char *from, char *to); }
+129 STD { int osf1_sys_truncate(char *path, off_t length); }
+130 STD { int osf1_sys_ftruncate(int fd, off_t length); }
+131 UNIMPL flock
+132 STD { int osf1_sys_setgid(gid_t gid); }
+133 STD { int osf1_sys_sendto(int s, caddr_t buf, size_t len, \
+ int flags, caddr_t to, int tolen); }
+134 NOARGS { int sys_shutdown(int s, int how); }
+135 UNIMPL socketpair
+136 NOARGS { int sys_mkdir(char *path, int mode); }
+137 NOARGS { int sys_rmdir(char *path); }
+138 NOARGS { int sys_utimes(char *path, struct timeval *tptr); }
+139 OBSOL 4.2 sigreturn
+140 UNIMPL adjtime
+141 UNIMPL old getpeername
+142 NOARGS { int32_t compat_43_sys_gethostid(void); }
+143 NOARGS { int compat_43_sys_sethostid(int32_t hostid); }
+144 STD { int osf1_sys_getrlimit(u_int which, \
+ struct rlimit *rlp); }
+145 STD { int osf1_sys_setrlimit(u_int which, \
+ struct rlimit *rlp); }
+146 UNIMPL old killpg
+147 NOARGS { int sys_setsid(void); }
+148 UNIMPL quotactl
+149 NOARGS { int compat_43_sys_quota(void); }
+150 UNIMPL old getsockname
+151 UNIMPL
+152 UNIMPL
+153 UNIMPL
+154 UNIMPL
+155 UNIMPL
+156 STD { int osf1_sys_sigaction(int signum, \
+ struct osf1_sigaction *nsa, \
+ struct osf1_sigaction *osa); }
+157 UNIMPL
+158 UNIMPL nfssvc
+159 NOARGS { int compat_43_sys_getdirentries(int fd, char *buf, \
+ u_int count, long *basep); }
+160 STD { int osf1_sys_statfs(char *path, \
+ struct osf1_statfs *buf, int len); }
+161 STD { int osf1_sys_fstatfs(int fd, \
+ struct osf1_statfs *buf, int len); }
+162 UNIMPL
+163 UNIMPL async_daemon
+164 UNIMPL getfh
+165 UNIMPL getdomainname
+166 UNIMPL setdomainname
+167 UNIMPL
+168 UNIMPL
+169 UNIMPL exportfs
+170 UNIMPL
+171 UNIMPL
+172 UNIMPL alt msgctl
+173 UNIMPL alt msgget
+174 UNIMPL alt msgrcv
+175 UNIMPL alt msgsnd
+176 UNIMPL alt semctl
+177 UNIMPL alt semget
+178 UNIMPL alt semop
+179 UNIMPL alt uname
+180 UNIMPL
+181 UNIMPL alt plock
+182 UNIMPL lockf
+183 UNIMPL
+184 UNIMPL getmnt
+185 UNIMPL
+186 UNIMPL unmount
+187 UNIMPL alt sigpending
+188 UNIMPL alt setsid
+189 UNIMPL
+190 UNIMPL
+191 UNIMPL
+192 UNIMPL
+193 UNIMPL
+194 UNIMPL
+195 UNIMPL
+196 UNIMPL
+197 UNIMPL
+198 UNIMPL
+199 UNIMPL swapon
+200 UNIMPL msgctl
+201 UNIMPL msgget
+202 UNIMPL msgrcv
+203 UNIMPL msgsnd
+204 UNIMPL semctl
+205 UNIMPL semget
+206 UNIMPL semop
+207 UNIMPL uname
+208 UNIMPL lchown
+209 UNIMPL shmat
+210 UNIMPL shmctl
+211 UNIMPL shmdt
+212 UNIMPL shmget
+213 UNIMPL mvalid
+214 UNIMPL getaddressconf
+215 UNIMPL msleep
+216 UNIMPL mwakeup
+217 UNIMPL msync
+218 UNIMPL signal
+219 UNIMPL utc gettime
+220 UNIMPL utc adjtime
+221 UNIMPL
+222 UNIMPL security
+223 UNIMPL kloadcall
+224 UNIMPL
+225 UNIMPL
+226 UNIMPL
+227 UNIMPL
+228 UNIMPL
+229 UNIMPL
+230 UNIMPL
+231 UNIMPL
+232 UNIMPL
+233 UNIMPL getpgid
+234 STD { pid_t osf1_sys_getsid(pid_t pid); }
+235 STD { int osf1_sys_sigaltstack(struct osf1_sigaltstack *nss, \
+ struct osf1_sigaltstack *oss); }
+236 UNIMPL waitid
+237 UNIMPL priocntlset
+238 UNIMPL sigsendset
+239 UNIMPL
+240 UNIMPL msfs_syscall
+241 UNIMPL sysinfo
+242 UNIMPL uadmin
+243 UNIMPL fuser
+244 UNIMPL
+245 UNIMPL
+246 UNIMPL
+247 UNIMPL
+248 UNIMPL
+249 UNIMPL
+250 UNIMPL uswitch
+251 STD { int osf1_sys_usleep_thread(struct timeval *sleep, \
+ struct timeval *slept); }
+252 UNIMPL audcntl
+253 UNIMPL audgen
+254 UNIMPL sysfs
+255 UNIMPL
+256 UNIMPL getsysinfo
+257 STD { int osf1_sys_setsysinfo(u_long op, caddr_t buffer, \
+ u_long nbytes, caddr_t arg, u_long flag); }
+258 UNIMPL afs_syscall
+259 UNIMPL swapctl
+260 UNIMPL memcntl
diff --git a/sys/compat/sunos/exec.h b/sys/compat/sunos/exec.h
new file mode 100644
index 00000000000..c7e0693f740
--- /dev/null
+++ b/sys/compat/sunos/exec.h
@@ -0,0 +1,48 @@
+/* $NetBSD: exec.h,v 1.4 1994/10/25 23:03:22 deraadt Exp $ */
+
+/*
+ * Copyright (c) 1993 Theo de Raadt
+ * 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.
+ */
+
+#ifndef _SUNOS_EXEC_H_
+#define _SUNOS_EXEC_H_
+
+struct sunos_exec {
+ u_char a_dynamic:1; /* has a __DYNAMIC */
+ u_char a_toolversion:7;/* version of toolset used to create this file */
+ u_char a_machtype; /* machine type */
+ u_short a_magic; /* magic number */
+};
+#define SUNOS_M_68020 2 /* runs only on 68020 */
+#define SUNOS_M_SPARC 3 /* runs only on SPARC */
+
+#ifdef sparc
+#define SUNOS_M_NATIVE SUNOS_M_SPARC
+#else
+#define SUNOS_M_NATIVE SUNOS_M_68020
+#endif
+
+#endif /* !_SUNOS_EXEC_H_ */
diff --git a/sys/compat/sunos/files.sunos b/sys/compat/sunos/files.sunos
new file mode 100644
index 00000000000..e28f1c0a91b
--- /dev/null
+++ b/sys/compat/sunos/files.sunos
@@ -0,0 +1,13 @@
+# $NetBSD: files.sunos,v 1.3 1995/06/24 20:22:33 christos Exp $
+#
+# Config.new file description for machine-independent SunOS compat code.
+# Included by ports that need it.
+
+# ports should define any machine-specific files they need in their
+# own file lists.
+
+file compat/sunos/sunos_exec.c compat_sunos
+file compat/sunos/sunos_sysent.c compat_sunos
+file compat/sunos/sunos_ioctl.c compat_sunos
+file compat/sunos/sunos_misc.c compat_sunos
+#file compat/sunos/sunos_syscalls.c compat_sunos
diff --git a/sys/compat/sunos/sunos.h b/sys/compat/sunos/sunos.h
new file mode 100644
index 00000000000..db93710d457
--- /dev/null
+++ b/sys/compat/sunos/sunos.h
@@ -0,0 +1,143 @@
+/* $NetBSD: sunos.h,v 1.5 1995/10/09 16:54:48 mycroft Exp $ */
+
+#define SUNM_RDONLY 0x01 /* mount fs read-only */
+#define SUNM_NOSUID 0x02 /* mount fs with setuid disallowed */
+#define SUNM_NEWTYPE 0x04 /* type is string (char *), not int */
+#define SUNM_GRPID 0x08 /* (bsd semantics; ignored) */
+#define SUNM_REMOUNT 0x10 /* update existing mount */
+#define SUNM_NOSUB 0x20 /* prevent submounts (rejected) */
+#define SUNM_MULTI 0x40 /* (ignored) */
+#define SUNM_SYS5 0x80 /* Sys 5-specific semantics (rejected) */
+
+struct sunos_nfs_args {
+ struct sockaddr_in *addr; /* file server address */
+ caddr_t fh; /* file handle to be mounted */
+ int flags; /* flags */
+ int wsize; /* write size in bytes */
+ int rsize; /* read size in bytes */
+ int timeo; /* initial timeout in .1 secs */
+ int retrans; /* times to retry send */
+ char *hostname; /* server's hostname */
+ int acregmin; /* attr cache file min secs */
+ int acregmax; /* attr cache file max secs */
+ int acdirmin; /* attr cache dir min secs */
+ int acdirmax; /* attr cache dir max secs */
+ char *netname; /* server's netname */
+ struct pathcnf *pathconf; /* static pathconf kludge */
+};
+
+
+struct sunos_ustat {
+ daddr_t f_tfree; /* total free */
+ ino_t f_tinode; /* total inodes free */
+ char f_path[6]; /* filsys name */
+ char f_fpack[6]; /* filsys pack name */
+};
+
+struct sunos_statfs {
+ long f_type; /* type of info, zero for now */
+ long f_bsize; /* fundamental file system block size */
+ long f_blocks; /* total blocks in file system */
+ long f_bfree; /* free blocks */
+ long f_bavail; /* free blocks available to non-super-user */
+ long f_files; /* total file nodes in file system */
+ long f_ffree; /* free file nodes in fs */
+ fsid_t f_fsid; /* file system id */
+ long f_spare[7]; /* spare for later */
+};
+
+
+struct sunos_utsname {
+ char sysname[9];
+ char nodename[9];
+ char nodeext[65-9];
+ char release[9];
+ char version[9];
+ char machine[9];
+};
+
+
+struct sunos_ttysize {
+ int ts_row;
+ int ts_col;
+};
+
+struct sunos_termio {
+ u_short c_iflag;
+ u_short c_oflag;
+ u_short c_cflag;
+ u_short c_lflag;
+ char c_line;
+ unsigned char c_cc[8];
+};
+#define SUNOS_TCGETA _IOR('T', 1, struct sunos_termio)
+#define SUNOS_TCSETA _IOW('T', 2, struct sunos_termio)
+#define SUNOS_TCSETAW _IOW('T', 3, struct sunos_termio)
+#define SUNOS_TCSETAF _IOW('T', 4, struct sunos_termio)
+#define SUNOS_TCSBRK _IO('T', 5)
+
+struct sunos_termios {
+ u_long c_iflag;
+ u_long c_oflag;
+ u_long c_cflag;
+ u_long c_lflag;
+ char c_line;
+ u_char c_cc[17];
+};
+#define SUNOS_TCXONC _IO('T', 6)
+#define SUNOS_TCFLSH _IO('T', 7)
+#define SUNOS_TCGETS _IOR('T', 8, struct sunos_termios)
+#define SUNOS_TCSETS _IOW('T', 9, struct sunos_termios)
+#define SUNOS_TCSETSW _IOW('T', 10, struct sunos_termios)
+#define SUNOS_TCSETSF _IOW('T', 11, struct sunos_termios)
+#define SUNOS_TCSNDBRK _IO('T', 12)
+#define SUNOS_TCDRAIN _IO('T', 13)
+
+struct sunos_pollfd {
+ int fd;
+ short events;
+ short revents;
+};
+#define SUNOS_POLLIN 0x0001
+#define SUNOS_POLLPRI 0x0002
+#define SUNOS_POLLOUT 0x0004
+#define SUNOS_POLLERR 0x0008
+#define SUNOS_POLLHUP 0x0010
+#define SUNOS_POLLNVAL 0x0020
+#define SUNOS_POLLRDNORM 0x0040
+#define SUNOS_POLLRDBAND 0x0080
+#define SUNOS_POLLWRBAND 0x0100
+
+/* Sun audio compatibility */
+struct sunos_audio_prinfo {
+ u_int sample_rate;
+ u_int channels;
+ u_int precision;
+ u_int encoding;
+ u_int gain;
+ u_int port;
+ u_int avail_ports;
+ u_int reserved0[3];
+ u_int samples;
+ u_int eof;
+ u_char pause;
+ u_char error;
+ u_char waiting;
+ u_char balance;
+ u_short minordev;
+ u_char open;
+ u_char active;
+};
+struct sunos_audio_info {
+ struct sunos_audio_prinfo play;
+ struct sunos_audio_prinfo record;
+ u_int monitor_gain;
+ u_int reserved[4];
+};
+
+/* Values for AUDIO_GETDEV ioctl: */
+#define SUNOS_AUDIO_DEV_UNKNOWN 0
+#define SUNOS_AUDIO_DEV_AMD 1
+#define SUNOS_AUDIO_DEV_SPEAKERBOX 2
+#define SUNOS_AUDIO_DEV_CODEC 3
+
diff --git a/sys/compat/sunos/sunos_dirent.h b/sys/compat/sunos/sunos_dirent.h
new file mode 100644
index 00000000000..bfba3af4f57
--- /dev/null
+++ b/sys/compat/sunos/sunos_dirent.h
@@ -0,0 +1,46 @@
+/* $NetBSD: sunos_dirent.h,v 1.1 1995/10/09 11:24:10 mycroft 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.
+ */
+
+#ifndef _SUNOS_DIRENT_H_
+#define _SUNOS_DIRENT_H_
+
+#define SUNOS_MAXNAMLEN 255
+
+struct sunos_dirent {
+ long d_off;
+ u_long d_fileno;
+ u_short d_reclen;
+ u_short d_namlen;
+ char d_name[SUNOS_MAXNAMLEN + 1];
+};
+
+#define SUNOS_NAMEOFF(dp) ((char *)&(dp)->d_name - (char *)dp)
+#define SUNOS_RECLEN(de,namlen) ALIGN((SUNOS_NAMEOFF(de) + (namlen) + 1))
+
+#endif /* !_SVR4_DIRENT_H_ */
diff --git a/sys/compat/sunos/sunos_exec.c b/sys/compat/sunos/sunos_exec.c
new file mode 100644
index 00000000000..3ed414feb97
--- /dev/null
+++ b/sys/compat/sunos/sunos_exec.c
@@ -0,0 +1,266 @@
+/* $NetBSD: sunos_exec.c,v 1.9 1995/06/25 14:15:08 briggs Exp $ */
+
+/*
+ * Copyright (c) 1993 Theo de Raadt
+ * 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/filedesc.h>
+#include <sys/kernel.h>
+#include <sys/proc.h>
+#include <sys/mount.h>
+#include <sys/malloc.h>
+#include <sys/namei.h>
+#include <sys/signalvar.h>
+#include <sys/vnode.h>
+#include <sys/file.h>
+#include <sys/exec.h>
+#include <sys/resourcevar.h>
+#include <sys/wait.h>
+
+#include <sys/mman.h>
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/vm_map.h>
+#include <vm/vm_kern.h>
+#include <vm/vm_pager.h>
+
+#include <machine/cpu.h>
+#include <machine/reg.h>
+#include <machine/exec.h>
+
+#include <compat/sunos/exec.h>
+#include <compat/sunos/sunos_syscall.h>
+
+#ifdef sparc
+#define sunos_exec_aout_prep_zmagic exec_aout_prep_zmagic
+#define sunos_exec_aout_prep_nmagic exec_aout_prep_nmagic
+#define sunos_exec_aout_prep_omagic exec_aout_prep_omagic
+#endif
+
+extern int nsunos_sysent;
+extern struct sysent sunos_sysent[];
+#ifdef SYSCALL_DEBUG
+extern char *sunos_syscallnames[];
+#endif
+extern void sunos_sendsig __P((sig_t, int, int, u_long));
+extern char sigcode[], esigcode[];
+const char sunos_emul_path[] = "/emul/sunos";
+
+struct emul emul_sunos = {
+ "sunos",
+ NULL,
+#ifdef sparc
+ sendsig,
+#else
+ sunos_sendsig,
+#endif
+ SUNOS_SYS_syscall,
+ SUNOS_SYS_MAXSYSCALL,
+ sunos_sysent,
+#ifdef SYSCALL_DEBUG
+ sunos_syscallnames,
+#else
+ NULL,
+#endif
+ 0,
+ copyargs,
+ setregs,
+ sigcode,
+ esigcode,
+};
+
+int
+sunos_exec_aout_makecmds(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ struct sunos_exec *sunmag = epp->ep_hdr;
+ int error = ENOEXEC;
+
+ if(sunmag->a_machtype != SUNOS_M_NATIVE)
+ return (ENOEXEC);
+
+ switch (sunmag->a_magic) {
+ case ZMAGIC:
+ error = sunos_exec_aout_prep_zmagic(p, epp);
+ break;
+ case NMAGIC:
+ error = sunos_exec_aout_prep_nmagic(p, epp);
+ break;
+ case OMAGIC:
+ error = sunos_exec_aout_prep_omagic(p, epp);
+ break;
+ }
+ if (error==0)
+ epp->ep_emul = &emul_sunos;
+ return error;
+}
+
+/*
+ * the code below is only needed for sun3 emulation.
+ */
+#ifndef sparc
+
+/* suns keep data seg aligned to SEGSIZ because of sun custom mmu */
+#define SEGSIZ 0x20000
+#define SUNOS_N_TXTADDR(x,m) __LDPGSZ
+#define SUNOS_N_DATADDR(x,m) (((m)==OMAGIC) ? \
+ (SUNOS_N_TXTADDR(x,m) + (x).a_text) : \
+ (SEGSIZ + ((SUNOS_N_TXTADDR(x,m) + (x).a_text - 1) & ~(SEGSIZ-1))))
+#define SUNOS_N_BSSADDR(x,m) (SUNOS_N_DATADDR(x,m)+(x).a_data)
+
+#define SUNOS_N_TXTOFF(x,m) ((m)==ZMAGIC ? 0 : sizeof (struct exec))
+#define SUNOS_N_DATOFF(x,m) (SUNOS_N_TXTOFF(x,m) + (x).a_text)
+
+/*
+ * sunos_exec_aout_prep_zmagic(): Prepare a SunOS ZMAGIC binary's exec package
+ *
+ * First, set of the various offsets/lengths in the exec package.
+ *
+ * Then, mark the text image busy (so it can be demand paged) or error
+ * out if this is not possible. Finally, set up vmcmds for the
+ * text, data, bss, and stack segments.
+ */
+int
+sunos_exec_aout_prep_zmagic(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ struct exec *execp = epp->ep_hdr;
+ struct exec_vmcmd *ccmdp;
+
+ epp->ep_taddr = SUNOS_N_TXTADDR(*execp, ZMAGIC);
+ epp->ep_tsize = execp->a_text;
+ epp->ep_daddr = SUNOS_N_DATADDR(*execp, ZMAGIC);
+ epp->ep_dsize = execp->a_data + execp->a_bss;
+ epp->ep_entry = execp->a_entry;
+
+ /*
+ * check if vnode is in open for writing, because we want to
+ * demand-page out of it. if it is, don't do it, for various
+ * reasons
+ */
+ if ((execp->a_text != 0 || execp->a_data != 0) &&
+ epp->ep_vp->v_writecount != 0) {
+#ifdef DIAGNOSTIC
+ if (epp->ep_vp->v_flag & VTEXT)
+ panic("exec: a VTEXT vnode has writecount != 0\n");
+#endif
+ return ETXTBSY;
+ }
+ epp->ep_vp->v_flag |= VTEXT;
+
+ /* set up command for text segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_text,
+ epp->ep_taddr, epp->ep_vp, SUNOS_N_TXTOFF(*execp, ZMAGIC),
+ VM_PROT_READ|VM_PROT_EXECUTE);
+
+ /* set up command for data segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_data,
+ epp->ep_daddr, epp->ep_vp, SUNOS_N_DATOFF(*execp, ZMAGIC),
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ /* set up command for bss segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, execp->a_bss,
+ epp->ep_daddr + execp->a_data, NULLVP, 0,
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ return exec_aout_setup_stack(p, epp);
+}
+
+/*
+ * sunos_exec_aout_prep_nmagic(): Prepare a SunOS NMAGIC binary's exec package
+ */
+int
+sunos_exec_aout_prep_nmagic(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ struct exec *execp = epp->ep_hdr;
+ struct exec_vmcmd *ccmdp;
+ long bsize, baddr;
+
+ epp->ep_taddr = SUNOS_N_TXTADDR(*execp, NMAGIC);
+ epp->ep_tsize = execp->a_text;
+ epp->ep_daddr = SUNOS_N_DATADDR(*execp, NMAGIC);
+ epp->ep_dsize = execp->a_data + execp->a_bss;
+ epp->ep_entry = execp->a_entry;
+
+ /* set up command for text segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->a_text,
+ epp->ep_taddr, epp->ep_vp, SUNOS_N_TXTOFF(*execp, NMAGIC),
+ VM_PROT_READ|VM_PROT_EXECUTE);
+
+ /* set up command for data segment */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn, execp->a_data,
+ epp->ep_daddr, epp->ep_vp, SUNOS_N_DATOFF(*execp, NMAGIC),
+ VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ /* set up command for bss segment */
+ baddr = roundup(epp->ep_daddr + execp->a_data, NBPG);
+ bsize = epp->ep_daddr + epp->ep_dsize - baddr;
+ if (bsize > 0)
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr,
+ NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ return exec_aout_setup_stack(p, epp);
+}
+
+/*
+ * sunos_exec_aout_prep_omagic(): Prepare a SunOS OMAGIC binary's exec package
+ */
+int
+sunos_exec_aout_prep_omagic(p, epp)
+ struct proc *p;
+ struct exec_package *epp;
+{
+ struct exec *execp = epp->ep_hdr;
+ struct exec_vmcmd *ccmdp;
+ long bsize, baddr;
+
+ epp->ep_taddr = SUNOS_N_TXTADDR(*execp, OMAGIC);
+ epp->ep_tsize = execp->a_text;
+ epp->ep_daddr = SUNOS_N_DATADDR(*execp, OMAGIC);
+ epp->ep_dsize = execp->a_data + execp->a_bss;
+ epp->ep_entry = execp->a_entry;
+
+ /* set up command for text and data segments */
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_readvn,
+ execp->a_text + execp->a_data, epp->ep_taddr, epp->ep_vp,
+ SUNOS_N_TXTOFF(*execp, OMAGIC), VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ /* set up command for bss segment */
+ baddr = roundup(epp->ep_daddr + execp->a_data, NBPG);
+ bsize = epp->ep_daddr + epp->ep_dsize - baddr;
+ if (bsize > 0)
+ NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_zero, bsize, baddr,
+ NULLVP, 0, VM_PROT_READ|VM_PROT_WRITE|VM_PROT_EXECUTE);
+
+ return exec_aout_setup_stack(p, epp);
+}
+#endif /* !sparc */
diff --git a/sys/compat/sunos/sunos_ioctl.c b/sys/compat/sunos/sunos_ioctl.c
new file mode 100644
index 00000000000..d4796c502d2
--- /dev/null
+++ b/sys/compat/sunos/sunos_ioctl.c
@@ -0,0 +1,785 @@
+/* $NetBSD: sunos_ioctl.c,v 1.21 1995/10/07 06:27:31 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1993 Markus Wild.
+ * 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. 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.
+ *
+ * loosely from: Header: sunos_ioctl.c,v 1.7 93/05/28 04:40:43 torek Exp
+ */
+
+#include <sys/param.h>
+#include <sys/proc.h>
+#include <sys/systm.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/termios.h>
+#include <sys/tty.h>
+#include <sys/socket.h>
+#include <sys/audioio.h>
+#include <net/if.h>
+
+#include <sys/mount.h>
+
+#include <sys/syscallargs.h>
+#include <compat/sunos/sunos.h>
+#include <compat/sunos/sunos_syscallargs.h>
+
+/*
+ * SunOS ioctl calls.
+ * This file is something of a hodge-podge.
+ * Support gets added as things turn up....
+ */
+
+static struct speedtab sptab[] = {
+ { 0, 0 },
+ { 50, 1 },
+ { 75, 2 },
+ { 110, 3 },
+ { 134, 4 },
+ { 135, 4 },
+ { 150, 5 },
+ { 200, 6 },
+ { 300, 7 },
+ { 600, 8 },
+ { 1200, 9 },
+ { 1800, 10 },
+ { 2400, 11 },
+ { 4800, 12 },
+ { 9600, 13 },
+ { 19200, 14 },
+ { 38400, 15 },
+ { -1, -1 }
+};
+
+static u_long s2btab[] = {
+ 0,
+ 50,
+ 75,
+ 110,
+ 134,
+ 150,
+ 200,
+ 300,
+ 600,
+ 1200,
+ 1800,
+ 2400,
+ 4800,
+ 9600,
+ 19200,
+ 38400,
+};
+
+/*
+ * these two conversion functions have mostly been done
+ * with some perl cut&paste, then handedited to comment
+ * out what doesn't exist under NetBSD.
+ * A note from Markus's code:
+ * (l & BITMASK1) / BITMASK1 * BITMASK2 is translated
+ * optimally by gcc m68k, much better than any ?: stuff.
+ * Code may vary with different architectures of course.
+ *
+ * I don't know what optimizer you used, but seeing divu's and
+ * bfextu's in the m68k assembly output did not encourage me...
+ * as well, gcc on the sparc definately generates much better
+ * code with ?:.
+ */
+
+static void
+stios2btios(st, bt)
+ struct sunos_termios *st;
+ struct termios *bt;
+{
+ register u_long l, r;
+
+ l = st->c_iflag;
+ r = ((l & 0x00000001) ? IGNBRK : 0);
+ r |= ((l & 0x00000002) ? BRKINT : 0);
+ r |= ((l & 0x00000004) ? IGNPAR : 0);
+ r |= ((l & 0x00000008) ? PARMRK : 0);
+ r |= ((l & 0x00000010) ? INPCK : 0);
+ r |= ((l & 0x00000020) ? ISTRIP : 0);
+ r |= ((l & 0x00000040) ? INLCR : 0);
+ r |= ((l & 0x00000080) ? IGNCR : 0);
+ r |= ((l & 0x00000100) ? ICRNL : 0);
+ /* ((l & 0x00000200) ? IUCLC : 0) */
+ r |= ((l & 0x00000400) ? IXON : 0);
+ r |= ((l & 0x00000800) ? IXANY : 0);
+ r |= ((l & 0x00001000) ? IXOFF : 0);
+ r |= ((l & 0x00002000) ? IMAXBEL : 0);
+ bt->c_iflag = r;
+
+ l = st->c_oflag;
+ r = ((l & 0x00000001) ? OPOST : 0);
+ /* ((l & 0x00000002) ? OLCUC : 0) */
+ r |= ((l & 0x00000004) ? ONLCR : 0);
+ /* ((l & 0x00000008) ? OCRNL : 0) */
+ /* ((l & 0x00000010) ? ONOCR : 0) */
+ /* ((l & 0x00000020) ? ONLRET : 0) */
+ /* ((l & 0x00000040) ? OFILL : 0) */
+ /* ((l & 0x00000080) ? OFDEL : 0) */
+ /* ((l & 0x00000100) ? NLDLY : 0) */
+ /* ((l & 0x00000100) ? NL1 : 0) */
+ /* ((l & 0x00000600) ? CRDLY : 0) */
+ /* ((l & 0x00000200) ? CR1 : 0) */
+ /* ((l & 0x00000400) ? CR2 : 0) */
+ /* ((l & 0x00000600) ? CR3 : 0) */
+ /* ((l & 0x00001800) ? TABDLY : 0) */
+ /* ((l & 0x00000800) ? TAB1 : 0) */
+ /* ((l & 0x00001000) ? TAB2 : 0) */
+ r |= ((l & 0x00001800) ? OXTABS : 0);
+ /* ((l & 0x00002000) ? BSDLY : 0) */
+ /* ((l & 0x00002000) ? BS1 : 0) */
+ /* ((l & 0x00004000) ? VTDLY : 0) */
+ /* ((l & 0x00004000) ? VT1 : 0) */
+ /* ((l & 0x00008000) ? FFDLY : 0) */
+ /* ((l & 0x00008000) ? FF1 : 0) */
+ /* ((l & 0x00010000) ? PAGEOUT : 0) */
+ /* ((l & 0x00020000) ? WRAP : 0) */
+ bt->c_oflag = r;
+
+ l = st->c_cflag;
+ switch (l & 0x00000030) {
+ case 0:
+ r = CS5;
+ break;
+ case 0x00000010:
+ r = CS6;
+ break;
+ case 0x00000020:
+ r = CS7;
+ break;
+ case 0x00000030:
+ r = CS8;
+ break;
+ }
+ r |= ((l & 0x00000040) ? CSTOPB : 0);
+ r |= ((l & 0x00000080) ? CREAD : 0);
+ r |= ((l & 0x00000100) ? PARENB : 0);
+ r |= ((l & 0x00000200) ? PARODD : 0);
+ r |= ((l & 0x00000400) ? HUPCL : 0);
+ r |= ((l & 0x00000800) ? CLOCAL : 0);
+ /* ((l & 0x00001000) ? LOBLK : 0) */
+ r |= ((l & 0x80000000) ? (CRTS_IFLOW|CCTS_OFLOW) : 0);
+ bt->c_cflag = r;
+
+ bt->c_ispeed = bt->c_ospeed = s2btab[l & 0x0000000f];
+
+ l = st->c_lflag;
+ r = ((l & 0x00000001) ? ISIG : 0);
+ r |= ((l & 0x00000002) ? ICANON : 0);
+ /* ((l & 0x00000004) ? XCASE : 0) */
+ r |= ((l & 0x00000008) ? ECHO : 0);
+ r |= ((l & 0x00000010) ? ECHOE : 0);
+ r |= ((l & 0x00000020) ? ECHOK : 0);
+ r |= ((l & 0x00000040) ? ECHONL : 0);
+ r |= ((l & 0x00000080) ? NOFLSH : 0);
+ r |= ((l & 0x00000100) ? TOSTOP : 0);
+ r |= ((l & 0x00000200) ? ECHOCTL : 0);
+ r |= ((l & 0x00000400) ? ECHOPRT : 0);
+ r |= ((l & 0x00000800) ? ECHOKE : 0);
+ /* ((l & 0x00001000) ? DEFECHO : 0) */
+ r |= ((l & 0x00002000) ? FLUSHO : 0);
+ r |= ((l & 0x00004000) ? PENDIN : 0);
+ bt->c_lflag = r;
+
+ bt->c_cc[VINTR] = st->c_cc[0] ? st->c_cc[0] : _POSIX_VDISABLE;
+ bt->c_cc[VQUIT] = st->c_cc[1] ? st->c_cc[1] : _POSIX_VDISABLE;
+ bt->c_cc[VERASE] = st->c_cc[2] ? st->c_cc[2] : _POSIX_VDISABLE;
+ bt->c_cc[VKILL] = st->c_cc[3] ? st->c_cc[3] : _POSIX_VDISABLE;
+ bt->c_cc[VEOF] = st->c_cc[4] ? st->c_cc[4] : _POSIX_VDISABLE;
+ bt->c_cc[VEOL] = st->c_cc[5] ? st->c_cc[5] : _POSIX_VDISABLE;
+ bt->c_cc[VEOL2] = st->c_cc[6] ? st->c_cc[6] : _POSIX_VDISABLE;
+ /* bt->c_cc[VSWTCH] = st->c_cc[7] ? st->c_cc[7] : _POSIX_VDISABLE; */
+ bt->c_cc[VSTART] = st->c_cc[8] ? st->c_cc[8] : _POSIX_VDISABLE;
+ bt->c_cc[VSTOP] = st->c_cc[9] ? st->c_cc[9] : _POSIX_VDISABLE;
+ bt->c_cc[VSUSP] = st->c_cc[10] ? st->c_cc[10] : _POSIX_VDISABLE;
+ bt->c_cc[VDSUSP] = st->c_cc[11] ? st->c_cc[11] : _POSIX_VDISABLE;
+ bt->c_cc[VREPRINT] = st->c_cc[12] ? st->c_cc[12] : _POSIX_VDISABLE;
+ bt->c_cc[VDISCARD] = st->c_cc[13] ? st->c_cc[13] : _POSIX_VDISABLE;
+ bt->c_cc[VWERASE] = st->c_cc[14] ? st->c_cc[14] : _POSIX_VDISABLE;
+ bt->c_cc[VLNEXT] = st->c_cc[15] ? st->c_cc[15] : _POSIX_VDISABLE;
+ bt->c_cc[VSTATUS] = st->c_cc[16] ? st->c_cc[16] : _POSIX_VDISABLE;
+
+ /* if `raw mode', create native VMIN/VTIME from SunOS VEOF/VEOL */
+ bt->c_cc[VMIN] = (bt->c_lflag & ICANON) ? 1 : bt->c_cc[VEOF];
+ bt->c_cc[VTIME] = (bt->c_lflag & ICANON) ? 1 : bt->c_cc[VEOL];
+}
+
+
+static void
+btios2stios(bt, st)
+ struct termios *bt;
+ struct sunos_termios *st;
+{
+ register u_long l, r;
+
+ l = bt->c_iflag;
+ r = ((l & IGNBRK) ? 0x00000001 : 0);
+ r |= ((l & BRKINT) ? 0x00000002 : 0);
+ r |= ((l & IGNPAR) ? 0x00000004 : 0);
+ r |= ((l & PARMRK) ? 0x00000008 : 0);
+ r |= ((l & INPCK) ? 0x00000010 : 0);
+ r |= ((l & ISTRIP) ? 0x00000020 : 0);
+ r |= ((l & INLCR) ? 0x00000040 : 0);
+ r |= ((l & IGNCR) ? 0x00000080 : 0);
+ r |= ((l & ICRNL) ? 0x00000100 : 0);
+ /* ((l & IUCLC) ? 0x00000200 : 0) */
+ r |= ((l & IXON) ? 0x00000400 : 0);
+ r |= ((l & IXANY) ? 0x00000800 : 0);
+ r |= ((l & IXOFF) ? 0x00001000 : 0);
+ r |= ((l & IMAXBEL) ? 0x00002000 : 0);
+ st->c_iflag = r;
+
+ l = bt->c_oflag;
+ r = ((l & OPOST) ? 0x00000001 : 0);
+ /* ((l & OLCUC) ? 0x00000002 : 0) */
+ r |= ((l & ONLCR) ? 0x00000004 : 0);
+ /* ((l & OCRNL) ? 0x00000008 : 0) */
+ /* ((l & ONOCR) ? 0x00000010 : 0) */
+ /* ((l & ONLRET) ? 0x00000020 : 0) */
+ /* ((l & OFILL) ? 0x00000040 : 0) */
+ /* ((l & OFDEL) ? 0x00000080 : 0) */
+ /* ((l & NLDLY) ? 0x00000100 : 0) */
+ /* ((l & NL1) ? 0x00000100 : 0) */
+ /* ((l & CRDLY) ? 0x00000600 : 0) */
+ /* ((l & CR1) ? 0x00000200 : 0) */
+ /* ((l & CR2) ? 0x00000400 : 0) */
+ /* ((l & CR3) ? 0x00000600 : 0) */
+ /* ((l & TABDLY) ? 0x00001800 : 0) */
+ /* ((l & TAB1) ? 0x00000800 : 0) */
+ /* ((l & TAB2) ? 0x00001000 : 0) */
+ r |= ((l & OXTABS) ? 0x00001800 : 0);
+ /* ((l & BSDLY) ? 0x00002000 : 0) */
+ /* ((l & BS1) ? 0x00002000 : 0) */
+ /* ((l & VTDLY) ? 0x00004000 : 0) */
+ /* ((l & VT1) ? 0x00004000 : 0) */
+ /* ((l & FFDLY) ? 0x00008000 : 0) */
+ /* ((l & FF1) ? 0x00008000 : 0) */
+ /* ((l & PAGEOUT) ? 0x00010000 : 0) */
+ /* ((l & WRAP) ? 0x00020000 : 0) */
+ st->c_oflag = r;
+
+ l = bt->c_cflag;
+ switch (l & CSIZE) {
+ case CS5:
+ r = 0;
+ break;
+ case CS6:
+ r = 0x00000010;
+ break;
+ case CS7:
+ r = 0x00000020;
+ break;
+ case CS8:
+ r = 0x00000030;
+ break;
+ }
+ r |= ((l & CSTOPB) ? 0x00000040 : 0);
+ r |= ((l & CREAD) ? 0x00000080 : 0);
+ r |= ((l & PARENB) ? 0x00000100 : 0);
+ r |= ((l & PARODD) ? 0x00000200 : 0);
+ r |= ((l & HUPCL) ? 0x00000400 : 0);
+ r |= ((l & CLOCAL) ? 0x00000800 : 0);
+ /* ((l & LOBLK) ? 0x00001000 : 0) */
+ r |= ((l & (CRTS_IFLOW|CCTS_OFLOW)) ? 0x80000000 : 0);
+ st->c_cflag = r;
+
+ l = bt->c_lflag;
+ r = ((l & ISIG) ? 0x00000001 : 0);
+ r |= ((l & ICANON) ? 0x00000002 : 0);
+ /* ((l & XCASE) ? 0x00000004 : 0) */
+ r |= ((l & ECHO) ? 0x00000008 : 0);
+ r |= ((l & ECHOE) ? 0x00000010 : 0);
+ r |= ((l & ECHOK) ? 0x00000020 : 0);
+ r |= ((l & ECHONL) ? 0x00000040 : 0);
+ r |= ((l & NOFLSH) ? 0x00000080 : 0);
+ r |= ((l & TOSTOP) ? 0x00000100 : 0);
+ r |= ((l & ECHOCTL) ? 0x00000200 : 0);
+ r |= ((l & ECHOPRT) ? 0x00000400 : 0);
+ r |= ((l & ECHOKE) ? 0x00000800 : 0);
+ /* ((l & DEFECHO) ? 0x00001000 : 0) */
+ r |= ((l & FLUSHO) ? 0x00002000 : 0);
+ r |= ((l & PENDIN) ? 0x00004000 : 0);
+ st->c_lflag = r;
+
+ l = ttspeedtab(bt->c_ospeed, sptab);
+ if (l >= 0)
+ st->c_cflag |= l;
+
+ st->c_cc[0] = bt->c_cc[VINTR] != _POSIX_VDISABLE? bt->c_cc[VINTR]:0;
+ st->c_cc[1] = bt->c_cc[VQUIT] != _POSIX_VDISABLE? bt->c_cc[VQUIT]:0;
+ st->c_cc[2] = bt->c_cc[VERASE] != _POSIX_VDISABLE? bt->c_cc[VERASE]:0;
+ st->c_cc[3] = bt->c_cc[VKILL] != _POSIX_VDISABLE? bt->c_cc[VKILL]:0;
+ st->c_cc[4] = bt->c_cc[VEOF] != _POSIX_VDISABLE? bt->c_cc[VEOF]:0;
+ st->c_cc[5] = bt->c_cc[VEOL] != _POSIX_VDISABLE? bt->c_cc[VEOL]:0;
+ st->c_cc[6] = bt->c_cc[VEOL2] != _POSIX_VDISABLE? bt->c_cc[VEOL2]:0;
+ st->c_cc[7] = 0;
+ /* bt->c_cc[VSWTCH] != _POSIX_VDISABLE? bt->c_cc[VSWTCH]: */
+ st->c_cc[8] = bt->c_cc[VSTART] != _POSIX_VDISABLE? bt->c_cc[VSTART]:0;
+ st->c_cc[9] = bt->c_cc[VSTOP] != _POSIX_VDISABLE? bt->c_cc[VSTOP]:0;
+ st->c_cc[10]= bt->c_cc[VSUSP] != _POSIX_VDISABLE? bt->c_cc[VSUSP]:0;
+ st->c_cc[11]= bt->c_cc[VDSUSP] != _POSIX_VDISABLE? bt->c_cc[VDSUSP]:0;
+ st->c_cc[12]= bt->c_cc[VREPRINT]!= _POSIX_VDISABLE? bt->c_cc[VREPRINT]:0;
+ st->c_cc[13]= bt->c_cc[VDISCARD]!= _POSIX_VDISABLE? bt->c_cc[VDISCARD]:0;
+ st->c_cc[14]= bt->c_cc[VWERASE] != _POSIX_VDISABLE? bt->c_cc[VWERASE]:0;
+ st->c_cc[15]= bt->c_cc[VLNEXT] != _POSIX_VDISABLE? bt->c_cc[VLNEXT]:0;
+ st->c_cc[16]= bt->c_cc[VSTATUS] != _POSIX_VDISABLE? bt->c_cc[VSTATUS]:0;
+
+ if (!(bt->c_lflag & ICANON)) {
+ /* SunOS stores VMIN/VTIME in VEOF/VEOL (if ICANON is off) */
+ st->c_cc[4] = bt->c_cc[VMIN];
+ st->c_cc[5] = bt->c_cc[VTIME];
+ }
+
+ st->c_line = 0;
+}
+
+static void
+stios2stio(ts, t)
+ struct sunos_termios *ts;
+ struct sunos_termio *t;
+{
+ t->c_iflag = ts->c_iflag;
+ t->c_oflag = ts->c_oflag;
+ t->c_cflag = ts->c_cflag;
+ t->c_lflag = ts->c_lflag;
+ t->c_line = ts->c_line;
+ bcopy(ts->c_cc, t->c_cc, 8);
+}
+
+static void
+stio2stios(t, ts)
+ struct sunos_termio *t;
+ struct sunos_termios *ts;
+{
+ ts->c_iflag = t->c_iflag;
+ ts->c_oflag = t->c_oflag;
+ ts->c_cflag = t->c_cflag;
+ ts->c_lflag = t->c_lflag;
+ ts->c_line = t->c_line;
+ bcopy(t->c_cc, ts->c_cc, 8); /* don't touch the upper fields! */
+}
+
+int
+sunos_sys_ioctl(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_ioctl_args *uap = v;
+ register struct filedesc *fdp = p->p_fd;
+ register struct file *fp;
+ register int (*ctl)();
+ int error;
+
+ if ( (unsigned)SCARG(uap, fd) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
+ return EBADF;
+
+ if ((fp->f_flag & (FREAD|FWRITE)) == 0)
+ return EBADF;
+
+ ctl = fp->f_ops->fo_ioctl;
+
+ switch (SCARG(uap, com)) {
+ case _IOR('t', 0, int):
+ SCARG(uap, com) = TIOCGETD;
+ break;
+ case _IOW('t', 1, int):
+ {
+ int disc;
+
+ if ((error = copyin(SCARG(uap, data), (caddr_t)&disc,
+ sizeof disc)) != 0)
+ return error;
+
+ /* map SunOS NTTYDISC into our termios discipline */
+ if (disc == 2)
+ disc = 0;
+ /* all other disciplines are not supported by NetBSD */
+ if (disc)
+ return ENXIO;
+
+ return (*ctl)(fp, TIOCSETD, (caddr_t)&disc, p);
+ }
+ case _IOW('t', 101, int): /* sun SUNOS_TIOCSSOFTCAR */
+ {
+ int x; /* unused */
+
+ return copyin((caddr_t)&x, SCARG(uap, data), sizeof x);
+ }
+ case _IOR('t', 100, int): /* sun SUNOS_TIOCSSOFTCAR */
+ {
+ int x = 0;
+
+ return copyout((caddr_t)&x, SCARG(uap, data), sizeof x);
+ }
+ case _IO('t', 36): /* sun TIOCCONS, no parameters */
+ {
+ int on = 1;
+ return (*ctl)(fp, TIOCCONS, (caddr_t)&on, p);
+ }
+ case _IOW('t', 37, struct sunos_ttysize):
+ {
+ struct winsize ws;
+ struct sunos_ttysize ss;
+
+ if ((error = (*ctl)(fp, TIOCGWINSZ, (caddr_t)&ws, p)) != 0)
+ return (error);
+
+ if ((error = copyin (SCARG(uap, data), &ss, sizeof (ss))) != 0)
+ return error;
+
+ ws.ws_row = ss.ts_row;
+ ws.ws_col = ss.ts_col;
+
+ return ((*ctl)(fp, TIOCSWINSZ, (caddr_t)&ws, p));
+ }
+ case _IOW('t', 38, struct sunos_ttysize):
+ {
+ struct winsize ws;
+ struct sunos_ttysize ss;
+
+ if ((error = (*ctl)(fp, TIOCGWINSZ, (caddr_t)&ws, p)) != 0)
+ return (error);
+
+ ss.ts_row = ws.ws_row;
+ ss.ts_col = ws.ws_col;
+
+ return copyout ((caddr_t)&ss, SCARG(uap, data), sizeof (ss));
+ }
+ case _IOW('t', 130, int):
+ SCARG(uap, com) = TIOCSPGRP;
+ break;
+ case _IOR('t', 131, int):
+ SCARG(uap, com) = TIOCGPGRP;
+ break;
+ case _IO('t', 132):
+ SCARG(uap, com) = TIOCSCTTY;
+ break;
+ case SUNOS_TCGETA:
+ case SUNOS_TCGETS:
+ {
+ struct termios bts;
+ struct sunos_termios sts;
+ struct sunos_termio st;
+
+ if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0)
+ return error;
+
+ btios2stios (&bts, &sts);
+ if (SCARG(uap, com) == SUNOS_TCGETA) {
+ stios2stio (&sts, &st);
+ return copyout((caddr_t)&st, SCARG(uap, data),
+ sizeof (st));
+ } else
+ return copyout((caddr_t)&sts, SCARG(uap, data),
+ sizeof (sts));
+ /*NOTREACHED*/
+ }
+ case SUNOS_TCSETA:
+ case SUNOS_TCSETAW:
+ case SUNOS_TCSETAF:
+ {
+ struct termios bts;
+ struct sunos_termios sts;
+ struct sunos_termio st;
+
+ if ((error = copyin(SCARG(uap, data), (caddr_t)&st,
+ sizeof (st))) != 0)
+ return error;
+
+ /* get full BSD termios so we don't lose information */
+ if ((error = (*ctl)(fp, TIOCGETA, (caddr_t)&bts, p)) != 0)
+ return error;
+
+ /*
+ * convert to sun termios, copy in information from
+ * termio, and convert back, then set new values.
+ */
+ btios2stios(&bts, &sts);
+ stio2stios(&st, &sts);
+ stios2btios(&sts, &bts);
+
+ return (*ctl)(fp, SCARG(uap, com) - SUNOS_TCSETA + TIOCSETA,
+ (caddr_t)&bts, p);
+ }
+ case SUNOS_TCSETS:
+ case SUNOS_TCSETSW:
+ case SUNOS_TCSETSF:
+ {
+ struct termios bts;
+ struct sunos_termios sts;
+
+ if ((error = copyin (SCARG(uap, data), (caddr_t)&sts,
+ sizeof (sts))) != 0)
+ return error;
+ stios2btios (&sts, &bts);
+ return (*ctl)(fp, SCARG(uap, com) - SUNOS_TCSETS + TIOCSETA,
+ (caddr_t)&bts, p);
+ }
+/*
+ * Pseudo-tty ioctl translations.
+ */
+ case _IOW('t', 32, int): { /* TIOCTCNTL */
+ int error, on;
+
+ if (error = copyin (SCARG(uap, data), (caddr_t)&on, sizeof (on)))
+ return error;
+ return (*ctl)(fp, TIOCUCNTL, (caddr_t)&on, p);
+ }
+ case _IOW('t', 33, int): { /* TIOCSIGNAL */
+ int error, sig;
+
+ if (error = copyin (SCARG(uap, data), (caddr_t)&sig, sizeof (sig)))
+ return error;
+ return (*ctl)(fp, TIOCSIG, (caddr_t)&sig, p);
+ }
+
+/*
+ * Socket ioctl translations.
+ */
+#define IFREQ_IN(a) { \
+ struct ifreq ifreq; \
+ if (error = copyin (SCARG(uap, data), (caddr_t)&ifreq, sizeof (ifreq))) \
+ return error; \
+ return (*ctl)(fp, a, (caddr_t)&ifreq, p); \
+}
+#define IFREQ_INOUT(a) { \
+ struct ifreq ifreq; \
+ if (error = copyin (SCARG(uap, data), (caddr_t)&ifreq, sizeof (ifreq))) \
+ return error; \
+ if (error = (*ctl)(fp, a, (caddr_t)&ifreq, p)) \
+ return error; \
+ return copyout ((caddr_t)&ifreq, SCARG(uap, data), sizeof (ifreq)); \
+}
+
+ case _IOW('i', 12, struct ifreq):
+ /* SIOCSIFADDR */
+ break;
+
+ case _IOWR('i', 13, struct ifreq):
+ IFREQ_INOUT(OSIOCGIFADDR);
+
+ case _IOW('i', 14, struct ifreq):
+ /* SIOCSIFDSTADDR */
+ break;
+
+ case _IOWR('i', 15, struct ifreq):
+ IFREQ_INOUT(OSIOCGIFDSTADDR);
+
+ case _IOW('i', 16, struct ifreq):
+ /* SIOCSIFFLAGS */
+ break;
+
+ case _IOWR('i', 17, struct ifreq):
+ /* SIOCGIFFLAGS */
+ break;
+
+ case _IOW('i', 21, struct ifreq):
+ IFREQ_IN(SIOCSIFMTU);
+
+ case _IOWR('i', 22, struct ifreq):
+ IFREQ_INOUT(SIOCGIFMTU);
+
+ case _IOWR('i', 23, struct ifreq):
+ IFREQ_INOUT(SIOCGIFBRDADDR);
+
+ case _IOW('i', 24, struct ifreq):
+ IFREQ_IN(SIOCSIFBRDADDR);
+
+ case _IOWR('i', 25, struct ifreq):
+ IFREQ_INOUT(OSIOCGIFNETMASK);
+
+ case _IOW('i', 26, struct ifreq):
+ IFREQ_IN(SIOCSIFNETMASK);
+
+ case _IOWR('i', 27, struct ifreq):
+ IFREQ_INOUT(SIOCGIFMETRIC);
+
+ case _IOWR('i', 28, struct ifreq):
+ IFREQ_IN(SIOCSIFMETRIC);
+
+ case _IOW('i', 30, struct arpreq):
+ /* SIOCSARP */
+ break;
+
+ case _IOWR('i', 31, struct arpreq):
+ /* SIOCGARP */
+ break;
+
+ case _IOW('i', 32, struct arpreq):
+ /* SIOCDARP */
+ break;
+
+ case _IOW('i', 18, struct ifreq): /* SIOCSIFMEM */
+ case _IOWR('i', 19, struct ifreq): /* SIOCGIFMEM */
+ case _IOW('i', 40, struct ifreq): /* SIOCUPPER */
+ case _IOW('i', 41, struct ifreq): /* SIOCLOWER */
+ case _IOW('i', 44, struct ifreq): /* SIOCSETSYNC */
+ case _IOWR('i', 45, struct ifreq): /* SIOCGETSYNC */
+ case _IOWR('i', 46, struct ifreq): /* SIOCSDSTATS */
+ case _IOWR('i', 47, struct ifreq): /* SIOCSESTATS */
+ case _IOW('i', 48, int): /* SIOCSPROMISC */
+ case _IOW('i', 49, struct ifreq): /* SIOCADDMULTI */
+ case _IOW('i', 50, struct ifreq): /* SIOCDELMULTI */
+ return EOPNOTSUPP;
+
+ case _IOWR('i', 20, struct ifconf): /* SIOCGIFCONF */
+ {
+ struct ifconf ifconf;
+
+ /*
+ * XXX: two more problems
+ * 1. our sockaddr's are variable length, not always sizeof(sockaddr)
+ * 2. this returns a name per protocol, ie. it returns two "lo0"'s
+ */
+ if (error = copyin (SCARG(uap, data), (caddr_t)&ifconf,
+ sizeof (ifconf)))
+ return error;
+ if (error = (*ctl)(fp, OSIOCGIFCONF, (caddr_t)&ifconf, p))
+ return error;
+ return copyout ((caddr_t)&ifconf, SCARG(uap, data),
+ sizeof (ifconf));
+ }
+
+/*
+ * Audio ioctl translations.
+ */
+ case _IOR('A', 1, struct sunos_audio_info): /* AUDIO_GETINFO */
+ sunos_au_getinfo:
+ {
+ struct audio_info aui;
+ struct sunos_audio_info sunos_aui;
+
+ if (error = (*ctl)(fp, AUDIO_GETINFO, (caddr_t)&aui, p))
+ return error;
+
+ sunos_aui.play = *(struct sunos_audio_prinfo *)&aui.play;
+ sunos_aui.record = *(struct sunos_audio_prinfo *)&aui.record;
+
+ /* `avail_ports' is `seek' in BSD */
+#define AUDIO_SPEAKER 1
+#define AUDIO_HEADPHONE 2
+ sunos_aui.play.avail_ports = AUDIO_SPEAKER | AUDIO_HEADPHONE;
+ sunos_aui.record.avail_ports = AUDIO_SPEAKER | AUDIO_HEADPHONE;
+
+ sunos_aui.play.waiting = 0;
+ sunos_aui.record.waiting = 0;
+ sunos_aui.play.eof = 0;
+ sunos_aui.record.eof = 0;
+ sunos_aui.monitor_gain = aui.__spare; /* XXX */
+ /*XXXsunos_aui.output_muted = 0;*/
+ /*XXX*/sunos_aui.reserved[0] = 0;
+ /*XXX*/sunos_aui.reserved[1] = 0;
+ /*XXX*/sunos_aui.reserved[2] = 0;
+ /*XXX*/sunos_aui.reserved[3] = 0;
+
+ return copyout ((caddr_t)&sunos_aui, SCARG(uap, data),
+ sizeof (sunos_aui));
+ }
+
+ case _IOWR('A', 2, struct sunos_audio_info): /* AUDIO_SETINFO */
+ {
+ struct audio_info aui;
+ struct sunos_audio_info sunos_aui;
+
+ if (error = copyin (SCARG(uap, data), (caddr_t)&sunos_aui,
+ sizeof (sunos_aui)))
+ return error;
+
+ aui.play = *(struct audio_prinfo *)&sunos_aui.play;
+ aui.record = *(struct audio_prinfo *)&sunos_aui.record;
+ aui.__spare = sunos_aui.monitor_gain;
+ aui.blocksize = ~0;
+ aui.hiwat = ~0;
+ aui.lowat = ~0;
+ aui.backlog = ~0;
+ aui.mode = ~0;
+ /*
+ * The bsd driver does not distinguish between paused and
+ * active. (In the sun driver, not active means samples are
+ * not ouput at all, but paused means the last streams buffer
+ * is drained and then output stops.) If either are 0, then
+ * when stop output. Otherwise, if either are non-zero,
+ * we resume.
+ */
+ if (sunos_aui.play.pause == 0 || sunos_aui.play.active == 0)
+ aui.play.pause = 0;
+ else if (sunos_aui.play.pause != (u_char)~0 ||
+ sunos_aui.play.active != (u_char)~0)
+ aui.play.pause = 1;
+ if (sunos_aui.record.pause == 0 || sunos_aui.record.active == 0)
+ aui.record.pause = 0;
+ else if (sunos_aui.record.pause != (u_char)~0 ||
+ sunos_aui.record.active != (u_char)~0)
+ aui.record.pause = 1;
+
+ if (error = (*ctl)(fp, AUDIO_SETINFO, (caddr_t)&aui, p))
+ return error;
+ /* Return new state */
+ goto sunos_au_getinfo;
+ }
+ case _IO('A', 3): /* AUDIO_DRAIN */
+ return (*ctl)(fp, AUDIO_DRAIN, (void *)0, p);
+ case _IOR('A', 4, int): /* AUDIO_GETDEV */
+ {
+ int devtype = SUNOS_AUDIO_DEV_AMD;
+ return copyout ((caddr_t)&devtype, SCARG(uap, data),
+ sizeof (devtype));
+ }
+
+/*
+ * Selected streams ioctls.
+ */
+#define SUNOS_S_FLUSHR 1
+#define SUNOS_S_FLUSHW 2
+#define SUNOS_S_FLUSHRW 3
+
+#define SUNOS_S_INPUT 1
+#define SUNOS_S_HIPRI 2
+#define SUNOS_S_OUTPUT 4
+#define SUNOS_S_MSG 8
+
+ case _IO('S', 5): /* I_FLUSH */
+ {
+ int tmp = 0;
+ switch ((int)SCARG(uap, data)) {
+ case SUNOS_S_FLUSHR: tmp = FREAD;
+ case SUNOS_S_FLUSHW: tmp = FWRITE;
+ case SUNOS_S_FLUSHRW: tmp = FREAD|FWRITE;
+ }
+ return (*ctl)(fp, TIOCFLUSH, (caddr_t)&tmp, p);
+ }
+ case _IO('S', 9): /* I_SIGSET */
+ {
+ int on = 1;
+ if (((int)SCARG(uap, data) & (SUNOS_S_HIPRI|SUNOS_S_INPUT)) ==
+ SUNOS_S_HIPRI)
+ return EOPNOTSUPP;
+ return (*ctl)(fp, FIOASYNC, (caddr_t)&on, p);
+ }
+ }
+ return (sys_ioctl(p, uap, retval));
+}
diff --git a/sys/compat/sunos/sunos_misc.c b/sys/compat/sunos/sunos_misc.c
new file mode 100644
index 00000000000..caf3b6275ec
--- /dev/null
+++ b/sys/compat/sunos/sunos_misc.c
@@ -0,0 +1,1279 @@
+/* $NetBSD: sunos_misc.c,v 1.56.2.1 1995/10/13 19:57:44 pk Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * 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, Lawrence Berkeley Laboratory.
+ *
+ * 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.
+ *
+ * @(#)sunos_misc.c 8.1 (Berkeley) 6/18/93
+ *
+ * Header: sunos_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
+ */
+
+/*
+ * SunOS compatibility module.
+ *
+ * SunOS system calls that are implemented differently in BSD are
+ * handled here.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/proc.h>
+#include <sys/dir.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/reboot.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/ptrace.h>
+#include <sys/resource.h>
+#include <sys/resourcevar.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/socket.h>
+#include <sys/vnode.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <sys/utsname.h>
+#include <sys/unistd.h>
+#include <sys/syscallargs.h>
+
+#include <compat/sunos/sunos.h>
+#include <compat/sunos/sunos_syscallargs.h>
+#include <compat/sunos/sunos_util.h>
+#include <compat/sunos/sunos_dirent.h>
+
+#include <netinet/in.h>
+
+#include <miscfs/specfs/specdev.h>
+
+#include <nfs/rpcv2.h>
+#include <nfs/nfsv2.h>
+#include <nfs/nfs.h>
+
+#include <vm/vm.h>
+
+int
+sunos_sys_wait4(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_wait4_args *uap = v;
+ if (SCARG(uap, pid) == 0)
+ SCARG(uap, pid) = WAIT_ANY;
+ return (sys_wait4(p, uap, retval));
+}
+
+int
+sunos_sys_creat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_creat_args *uap = v;
+ struct sys_open_args ouap;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&ouap, path) = SCARG(uap, path);
+ SCARG(&ouap, flags) = O_WRONLY | O_CREAT | O_TRUNC;
+ SCARG(&ouap, mode) = SCARG(uap, mode);
+
+ return (sys_open(p, &ouap, retval));
+}
+
+int
+sunos_sys_access(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_access_args *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+ SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ return (sys_access(p, uap, retval));
+}
+
+int
+sunos_sys_stat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_stat_args *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+ SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ return (compat_43_sys_stat(p, uap, retval));
+}
+
+int
+sunos_sys_lstat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_lstat_args *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+ SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ return (compat_43_sys_lstat(p, uap, retval));
+}
+
+int
+sunos_sys_execv(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_execv_args *uap = v;
+ struct sys_execve_args ouap;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&ouap, path) = SCARG(uap, path);
+ SCARG(&ouap, argp) = SCARG(uap, argp);
+ SCARG(&ouap, envp) = NULL;
+
+ return (sys_execve(p, &ouap, retval));
+}
+
+int
+sunos_sys_omsync(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_omsync_args *uap = v;
+ struct sys_msync_args ouap;
+
+ if (SCARG(uap, flags))
+ return (EINVAL);
+ SCARG(&ouap, addr) = SCARG(uap, addr);
+ SCARG(&ouap, len) = SCARG(uap, len);
+
+ return (sys_msync(p, &ouap, retval));
+}
+
+int
+sunos_sys_unmount(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_unmount_args *uap = v;
+ struct sys_unmount_args ouap;
+
+ SCARG(&ouap, path) = SCARG(uap, path);
+ SCARG(&ouap, flags) = 0;
+
+ return (sys_unmount(p, &ouap, retval));
+}
+
+int
+sunos_sys_mount(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_mount_args *uap = v;
+ struct emul *e = p->p_emul;
+ int oflags = SCARG(uap, flags), nflags, error;
+ char fsname[MFSNAMELEN];
+
+ if (oflags & (SUNM_NOSUB | SUNM_SYS5))
+ return (EINVAL);
+ if ((oflags & SUNM_NEWTYPE) == 0)
+ return (EINVAL);
+ nflags = 0;
+ if (oflags & SUNM_RDONLY)
+ nflags |= MNT_RDONLY;
+ if (oflags & SUNM_NOSUID)
+ nflags |= MNT_NOSUID;
+ if (oflags & SUNM_REMOUNT)
+ nflags |= MNT_UPDATE;
+ SCARG(uap, flags) = nflags;
+
+ if (error = copyinstr((caddr_t)SCARG(uap, type), fsname,
+ sizeof fsname, (size_t *)0))
+ return (error);
+
+ if (strncmp(fsname, "4.2", sizeof fsname) == 0) {
+ SCARG(uap, type) = STACKGAPBASE;
+ if (error = copyout("ufs", SCARG(uap, type), sizeof("ufs")))
+ return (error);
+ } else if (strncmp(fsname, "nfs", sizeof fsname) == 0) {
+ struct sunos_nfs_args sna;
+ struct sockaddr_in sain;
+ struct nfs_args na;
+ struct sockaddr sa;
+
+ if (error = copyin(SCARG(uap, data), &sna, sizeof sna))
+ return (error);
+ if (error = copyin(sna.addr, &sain, sizeof sain))
+ return (error);
+ bcopy(&sain, &sa, sizeof sa);
+ sa.sa_len = sizeof(sain);
+ SCARG(uap, data) = STACKGAPBASE;
+ na.addr = (struct sockaddr *)((int)SCARG(uap, data) + sizeof na);
+ na.addrlen = sizeof(struct sockaddr);
+ na.sotype = SOCK_DGRAM;
+ na.proto = IPPROTO_UDP;
+ na.fh = (nfsv2fh_t *)sna.fh;
+ na.flags = sna.flags;
+ na.wsize = sna.wsize;
+ na.rsize = sna.rsize;
+ na.timeo = sna.timeo;
+ na.retrans = sna.retrans;
+ na.hostname = sna.hostname;
+
+ if (error = copyout(&sa, na.addr, sizeof sa))
+ return (error);
+ if (error = copyout(&na, SCARG(uap, data), sizeof na))
+ return (error);
+ }
+ return (sys_mount(p, (struct sys_mount_args *)uap, retval));
+}
+
+#if defined(NFSCLIENT)
+int
+async_daemon(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sys_nfssvc_args ouap;
+
+ SCARG(&ouap, flag) = NFSSVC_BIOD;
+ SCARG(&ouap, argp) = NULL;
+
+ return (sys_nfssvc(p, &ouap, retval));
+}
+#endif /* NFSCLIENT */
+
+int
+sunos_sys_sigpending(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_sigpending_args *uap = v;
+ int mask = p->p_siglist & p->p_sigmask;
+
+ return (copyout((caddr_t)&mask, (caddr_t)SCARG(uap, mask), sizeof(int)));
+}
+
+/*
+ * Read Sun-style directory entries. We suck them into kernel space so
+ * that they can be massaged before being copied out to user code. Like
+ * SunOS, we squish out `empty' entries.
+ *
+ * This is quite ugly, but what do you expect from compatibility code?
+ */
+int
+sunos_sys_getdents(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_getdents_args *uap = v;
+ struct dirent *bdp;
+ struct vnode *vp;
+ caddr_t inp, buf; /* BSD-format */
+ int len, reclen; /* BSD-format */
+ caddr_t outp; /* Sun-format */
+ int resid, sunos_reclen;/* Sun-format */
+ struct file *fp;
+ struct uio auio;
+ struct iovec aiov;
+ struct sunos_dirent idb;
+ off_t off; /* true file offset */
+ int buflen, error, eofflag;
+ u_long *cookiebuf, *cookie;
+ int ncookies;
+
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ return (error);
+
+ if ((fp->f_flag & FREAD) == 0)
+ return (EBADF);
+
+ vp = (struct vnode *)fp->f_data;
+
+ if (vp->v_type != VDIR) /* XXX vnode readdir op should do this */
+ return (EINVAL);
+
+ buflen = min(MAXBSIZE, SCARG(uap, nbytes));
+ buf = malloc(buflen, M_TEMP, M_WAITOK);
+ ncookies = buflen / 16;
+ cookiebuf = malloc(ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK);
+ VOP_LOCK(vp);
+ off = fp->f_offset;
+again:
+ aiov.iov_base = buf;
+ aiov.iov_len = buflen;
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_rw = UIO_READ;
+ auio.uio_segflg = UIO_SYSSPACE;
+ auio.uio_procp = p;
+ auio.uio_resid = buflen;
+ auio.uio_offset = off;
+ /*
+ * First we read into the malloc'ed buffer, then
+ * we massage it into user space, one record at a time.
+ */
+ error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, cookiebuf,
+ ncookies);
+ if (error) {
+ off_t coff;
+
+ if (error != EINVAL)
+ goto out;
+ error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, 0, 0);
+ if (error)
+ goto out;
+
+ /* Fake the cookies */
+ error = 0;
+ inp = buf;
+ len = buflen - auio.uio_resid;
+ coff = off;
+ cookie = cookiebuf;
+ for (; len > 0; len -= reclen) {
+ reclen = ((struct dirent *)inp)->d_reclen;
+ if (reclen & 3)
+ panic("sunos_getdents");
+ coff += reclen; /* each entry points to next */
+ *cookie++ = coff;
+ inp += reclen;
+ }
+ }
+
+ inp = buf;
+ outp = SCARG(uap, buf);
+ resid = SCARG(uap, nbytes);
+ if ((len = buflen - auio.uio_resid) == 0)
+ goto eof;
+
+ for (cookie = cookiebuf; len > 0; len -= reclen) {
+ bdp = (struct dirent *)inp;
+ reclen = bdp->d_reclen;
+ if (reclen & 3)
+ panic("sunos_getdents");
+ off = *cookie++; /* each entry points to next */
+ if (bdp->d_fileno == 0) {
+ inp += reclen; /* it is a hole; squish it out */
+ continue;
+ }
+ sunos_reclen = SUNOS_RECLEN(&idb, bdp->d_namlen);
+ if (reclen > len || resid < sunos_reclen) {
+ /* entry too big for buffer, so just stop */
+ outp++;
+ break;
+ }
+ /*
+ * Massage in place to make a Sun-shaped dirent (otherwise
+ * we have to worry about touching user memory outside of
+ * the copyout() call).
+ */
+ idb.d_fileno = bdp->d_fileno;
+ idb.d_off = off;
+ idb.d_reclen = sunos_reclen;
+ idb.d_namlen = bdp->d_namlen;
+ strcpy(idb.d_name, bdp->d_name);
+ if ((error = copyout((caddr_t)&idb, outp, sunos_reclen)) != 0)
+ goto out;
+ /* advance past this real entry */
+ inp += reclen;
+ /* advance output past Sun-shaped entry */
+ outp += sunos_reclen;
+ resid -= sunos_reclen;
+ }
+
+ /* if we squished out the whole block, try again */
+ if (outp == SCARG(uap, buf))
+ goto again;
+ fp->f_offset = off; /* update the vnode offset */
+
+eof:
+ *retval = SCARG(uap, nbytes) - resid;
+out:
+ VOP_UNLOCK(vp);
+ free(cookiebuf, M_TEMP);
+ free(buf, M_TEMP);
+ return (error);
+}
+
+#define SUNOS__MAP_NEW 0x80000000 /* if not, old mmap & cannot handle */
+
+int
+sunos_sys_mmap(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct sunos_sys_mmap_args *uap = v;
+ struct sys_mmap_args ouap;
+ register struct filedesc *fdp;
+ register struct file *fp;
+ register struct vnode *vp;
+
+ /*
+ * Verify the arguments.
+ */
+ if (SCARG(uap, prot) & ~(PROT_READ|PROT_WRITE|PROT_EXEC))
+ return (EINVAL); /* XXX still needed? */
+
+ if ((SCARG(uap, flags) & SUNOS__MAP_NEW) == 0)
+ return (EINVAL);
+
+ SCARG(&ouap, flags) = SCARG(uap, flags) & ~SUNOS__MAP_NEW;
+ SCARG(&ouap, addr) = SCARG(uap, addr);
+
+ if ((SCARG(&ouap, flags) & MAP_FIXED) == 0 &&
+ SCARG(&ouap, addr) != 0 &&
+ SCARG(&ouap, addr) < (caddr_t)round_page(p->p_vmspace->vm_daddr+MAXDSIZ))
+ SCARG(&ouap, addr) = (caddr_t)round_page(p->p_vmspace->vm_daddr+MAXDSIZ);
+
+ SCARG(&ouap, len) = SCARG(uap, len);
+ SCARG(&ouap, prot) = SCARG(uap, prot);
+ SCARG(&ouap, fd) = SCARG(uap, fd);
+ SCARG(&ouap, pos) = SCARG(uap, pos);
+
+ /*
+ * Special case: if fd refers to /dev/zero, map as MAP_ANON. (XXX)
+ */
+ fdp = p->p_fd;
+ if ((unsigned)SCARG(&ouap, fd) < fdp->fd_nfiles && /*XXX*/
+ (fp = fdp->fd_ofiles[SCARG(&ouap, fd)]) != NULL && /*XXX*/
+ fp->f_type == DTYPE_VNODE && /*XXX*/
+ (vp = (struct vnode *)fp->f_data)->v_type == VCHR && /*XXX*/
+ iszerodev(vp->v_rdev)) { /*XXX*/
+ SCARG(&ouap, flags) |= MAP_ANON;
+ SCARG(&ouap, fd) = -1;
+ }
+
+ return (sys_mmap(p, &ouap, retval));
+}
+
+#define MC_SYNC 1
+#define MC_LOCK 2
+#define MC_UNLOCK 3
+#define MC_ADVISE 4
+#define MC_LOCKAS 5
+#define MC_UNLOCKAS 6
+
+int
+sunos_sys_mctl(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct sunos_sys_mctl_args *uap = v;
+
+ switch (SCARG(uap, func)) {
+ case MC_ADVISE: /* ignore for now */
+ return (0);
+ case MC_SYNC: /* translate to msync */
+ return (sys_msync(p, uap, retval));
+ default:
+ return (EINVAL);
+ }
+}
+
+int
+sunos_sys_setsockopt(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct sunos_sys_setsockopt_args *uap = v;
+ struct file *fp;
+ struct mbuf *m = NULL;
+ int error;
+
+ if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ return (error);
+#define SO_DONTLINGER (~SO_LINGER)
+ if (SCARG(uap, name) == SO_DONTLINGER) {
+ m = m_get(M_WAIT, MT_SOOPTS);
+ if (m == NULL)
+ return (ENOBUFS);
+ mtod(m, struct linger *)->l_onoff = 0;
+ m->m_len = sizeof(struct linger);
+ return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
+ SO_LINGER, m));
+ }
+ if (SCARG(uap, level) == IPPROTO_IP) {
+#define SUNOS_IP_MULTICAST_IF 2
+#define SUNOS_IP_MULTICAST_TTL 3
+#define SUNOS_IP_MULTICAST_LOOP 4
+#define SUNOS_IP_ADD_MEMBERSHIP 5
+#define SUNOS_IP_DROP_MEMBERSHIP 6
+ static int ipoptxlat[] = {
+ IP_MULTICAST_IF,
+ IP_MULTICAST_TTL,
+ IP_MULTICAST_LOOP,
+ IP_ADD_MEMBERSHIP,
+ IP_DROP_MEMBERSHIP
+ };
+ if (SCARG(uap, name) >= SUNOS_IP_MULTICAST_IF &&
+ SCARG(uap, name) <= SUNOS_IP_DROP_MEMBERSHIP) {
+ SCARG(uap, name) =
+ ipoptxlat[SCARG(uap, name) - SUNOS_IP_MULTICAST_IF];
+ }
+ }
+ if (SCARG(uap, valsize) > MLEN)
+ return (EINVAL);
+ if (SCARG(uap, val)) {
+ m = m_get(M_WAIT, MT_SOOPTS);
+ if (m == NULL)
+ return (ENOBUFS);
+ if (error = copyin(SCARG(uap, val), mtod(m, caddr_t),
+ (u_int)SCARG(uap, valsize))) {
+ (void) m_free(m);
+ return (error);
+ }
+ m->m_len = SCARG(uap, valsize);
+ }
+ return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
+ SCARG(uap, name), m));
+}
+
+int
+sunos_sys_fchroot(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct sunos_sys_fchroot_args *uap = v;
+ register struct filedesc *fdp = p->p_fd;
+ register struct vnode *vp;
+ struct file *fp;
+ int error;
+
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
+ return (error);
+ if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
+ return (error);
+ vp = (struct vnode *)fp->f_data;
+ VOP_LOCK(vp);
+ if (vp->v_type != VDIR)
+ error = ENOTDIR;
+ else
+ error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
+ VOP_UNLOCK(vp);
+ if (error)
+ return (error);
+ VREF(vp);
+ if (fdp->fd_rdir != NULL)
+ vrele(fdp->fd_rdir);
+ fdp->fd_rdir = vp;
+ return (0);
+}
+
+/*
+ * XXX: This needs cleaning up.
+ */
+int
+sunos_sys_auditsys(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ return 0;
+}
+
+int
+sunos_sys_uname(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_uname_args *uap = v;
+ struct sunos_utsname sut;
+ extern char ostype[], machine[], osrelease[];
+
+ bzero(&sut, sizeof(sut));
+
+ bcopy(ostype, sut.sysname, sizeof(sut.sysname) - 1);
+ bcopy(hostname, sut.nodename, sizeof(sut.nodename));
+ sut.nodename[sizeof(sut.nodename)-1] = '\0';
+ bcopy(osrelease, sut.release, sizeof(sut.release) - 1);
+ bcopy("1", sut.version, sizeof(sut.version) - 1);
+ bcopy(machine, sut.machine, sizeof(sut.machine) - 1);
+
+ return copyout((caddr_t)&sut, (caddr_t)SCARG(uap, name),
+ sizeof(struct sunos_utsname));
+}
+
+int
+sunos_sys_setpgrp(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_setpgrp_args *uap = v;
+
+ /*
+ * difference to our setpgid call is to include backwards
+ * compatibility to pre-setsid() binaries. Do setsid()
+ * instead of setpgid() in those cases where the process
+ * tries to create a new session the old way.
+ */
+ if (!SCARG(uap, pgid) &&
+ (!SCARG(uap, pid) || SCARG(uap, pid) == p->p_pid))
+ return sys_setsid(p, uap, retval);
+ else
+ return sys_setpgid(p, uap, retval);
+}
+
+int
+sunos_sys_open(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_open_args *uap = v;
+ int l, r;
+ int noctty;
+ int ret;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ /* convert mode into NetBSD mode */
+ l = SCARG(uap, flags);
+ noctty = l & 0x8000;
+ r = (l & (0x0001 | 0x0002 | 0x0008 | 0x0040 | 0x0200 | 0x0400 | 0x0800));
+ r |= ((l & (0x0004 | 0x1000 | 0x4000)) ? O_NONBLOCK : 0);
+ r |= ((l & 0x0080) ? O_SHLOCK : 0);
+ r |= ((l & 0x0100) ? O_EXLOCK : 0);
+ r |= ((l & 0x2000) ? O_FSYNC : 0);
+
+ SCARG(uap, flags) = r;
+ ret = sys_open(p, (struct sys_open_args *)uap, retval);
+
+ if (!ret && !noctty && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
+ struct filedesc *fdp = p->p_fd;
+ struct file *fp = fdp->fd_ofiles[*retval];
+
+ /* ignore any error, just give it a try */
+ if (fp->f_type == DTYPE_VNODE)
+ (fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, (caddr_t)0, p);
+ }
+ return ret;
+}
+
+#if defined (NFSSERVER)
+int
+sunos_sys_nfssvc(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_nfssvc_args *uap = v;
+ struct emul *e = p->p_emul;
+ struct sys_nfssvc_args outuap;
+ struct sockaddr sa;
+ int error;
+
+#if 0
+ bzero(&outuap, sizeof outuap);
+ SCARG(&outuap, fd) = SCARG(uap, fd);
+ SCARG(&outuap, mskval) = STACKGAPBASE;
+ SCARG(&outuap, msklen) = sizeof sa;
+ SCARG(&outuap, mtchval) = SCARG(&outuap, mskval) + sizeof sa;
+ SCARG(&outuap, mtchlen) = sizeof sa;
+
+ bzero(&sa, sizeof sa);
+ if (error = copyout(&sa, SCARG(&outuap, mskval), SCARG(&outuap, msklen)))
+ return (error);
+ if (error = copyout(&sa, SCARG(&outuap, mtchval), SCARG(&outuap, mtchlen)))
+ return (error);
+
+ return nfssvc(p, &outuap, retval);
+#else
+ return (ENOSYS);
+#endif
+}
+#endif /* NFSSERVER */
+
+int
+sunos_sys_ustat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_ustat_args *uap = v;
+ struct sunos_ustat us;
+ int error;
+
+ bzero(&us, sizeof us);
+
+ /*
+ * XXX: should set f_tfree and f_tinode at least
+ * How do we translate dev -> fstat? (and then to sunos_ustat)
+ */
+
+ if (error = copyout(&us, SCARG(uap, buf), sizeof us))
+ return (error);
+ return 0;
+}
+
+int
+sunos_sys_quotactl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_quotactl_args *uap = v;
+
+ return EINVAL;
+}
+
+int
+sunos_sys_vhangup(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+
+ return 0;
+}
+
+static
+sunstatfs(sp, buf)
+ struct statfs *sp;
+ caddr_t buf;
+{
+ struct sunos_statfs ssfs;
+
+ bzero(&ssfs, sizeof ssfs);
+ ssfs.f_type = 0;
+ ssfs.f_bsize = sp->f_bsize;
+ ssfs.f_blocks = sp->f_blocks;
+ ssfs.f_bfree = sp->f_bfree;
+ ssfs.f_bavail = sp->f_bavail;
+ ssfs.f_files = sp->f_files;
+ ssfs.f_ffree = sp->f_ffree;
+ ssfs.f_fsid = sp->f_fsid;
+ return copyout((caddr_t)&ssfs, buf, sizeof ssfs);
+}
+
+int
+sunos_sys_statfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_statfs_args *uap = v;
+ register struct mount *mp;
+ register struct statfs *sp;
+ int error;
+ struct nameidata nd;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
+ if (error = namei(&nd))
+ return (error);
+ mp = nd.ni_vp->v_mount;
+ sp = &mp->mnt_stat;
+ vrele(nd.ni_vp);
+ if (error = VFS_STATFS(mp, sp, p))
+ return (error);
+ sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
+ return sunstatfs(sp, (caddr_t)SCARG(uap, buf));
+}
+
+int
+sunos_sys_fstatfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_fstatfs_args *uap = v;
+ struct file *fp;
+ struct mount *mp;
+ register struct statfs *sp;
+ int error;
+
+ if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
+ return (error);
+ mp = ((struct vnode *)fp->f_data)->v_mount;
+ sp = &mp->mnt_stat;
+ if (error = VFS_STATFS(mp, sp, p))
+ return (error);
+ sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
+ return sunstatfs(sp, (caddr_t)SCARG(uap, buf));
+}
+
+int
+sunos_sys_exportfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_exportfs_args *uap = v;
+
+ /*
+ * XXX: should perhaps translate into a mount(2)
+ * with MOUNT_EXPORT?
+ */
+ return 0;
+}
+
+int
+sunos_sys_mknod(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_mknod_args *uap = v;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SUNOS_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ if (S_ISFIFO(SCARG(uap, mode)))
+ return sys_mkfifo(p, uap, retval);
+
+ return sys_mknod(p, (struct sys_mknod_args *)uap, retval);
+}
+
+#define SUNOS_SC_ARG_MAX 1
+#define SUNOS_SC_CHILD_MAX 2
+#define SUNOS_SC_CLK_TCK 3
+#define SUNOS_SC_NGROUPS_MAX 4
+#define SUNOS_SC_OPEN_MAX 5
+#define SUNOS_SC_JOB_CONTROL 6
+#define SUNOS_SC_SAVED_IDS 7
+#define SUNOS_SC_VERSION 8
+
+int
+sunos_sys_sysconf(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_sysconf_args *uap = v;
+ extern int maxfiles;
+
+ switch(SCARG(uap, name)) {
+ case SUNOS_SC_ARG_MAX:
+ *retval = ARG_MAX;
+ break;
+ case SUNOS_SC_CHILD_MAX:
+ *retval = maxproc;
+ break;
+ case SUNOS_SC_CLK_TCK:
+ *retval = 60; /* should this be `hz', ie. 100? */
+ break;
+ case SUNOS_SC_NGROUPS_MAX:
+ *retval = NGROUPS_MAX;
+ break;
+ case SUNOS_SC_OPEN_MAX:
+ *retval = maxfiles;
+ break;
+ case SUNOS_SC_JOB_CONTROL:
+ *retval = 1;
+ break;
+ case SUNOS_SC_SAVED_IDS:
+#ifdef _POSIX_SAVED_IDS
+ *retval = 1;
+#else
+ *retval = 0;
+#endif
+ break;
+ case SUNOS_SC_VERSION:
+ *retval = 198808;
+ break;
+ default:
+ return EINVAL;
+ }
+ return 0;
+}
+
+#define SUNOS_RLIMIT_NOFILE 6 /* Other RLIMIT_* are the same */
+#define SUNOS_RLIM_NLIMITS 7
+
+int
+sunos_sys_getrlimit(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_getrlimit_args *uap = v;
+
+ if (SCARG(uap, which) >= SUNOS_RLIM_NLIMITS)
+ return EINVAL;
+
+ if (SCARG(uap, which) == SUNOS_RLIMIT_NOFILE)
+ SCARG(uap, which) = RLIMIT_NOFILE;
+
+ return compat_43_sys_getrlimit(p, uap, retval);
+}
+
+int
+sunos_sys_setrlimit(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_getrlimit_args *uap = v;
+
+ if (SCARG(uap, which) >= SUNOS_RLIM_NLIMITS)
+ return EINVAL;
+
+ if (SCARG(uap, which) == SUNOS_RLIMIT_NOFILE)
+ SCARG(uap, which) = RLIMIT_NOFILE;
+
+ return compat_43_sys_setrlimit(p, uap, retval);
+}
+
+/* for the m68k machines */
+#ifndef PT_GETFPREGS
+#define PT_GETFPREGS -1
+#endif
+#ifndef PT_SETFPREGS
+#define PT_SETFPREGS -1
+#endif
+
+static int sreq2breq[] = {
+ PT_TRACE_ME, PT_READ_I, PT_READ_D, -1,
+ PT_WRITE_I, PT_WRITE_D, -1, PT_CONTINUE,
+ PT_KILL, -1, PT_ATTACH, PT_DETACH,
+ PT_GETREGS, PT_SETREGS, PT_GETFPREGS, PT_SETFPREGS
+};
+static int nreqs = sizeof(sreq2breq) / sizeof(sreq2breq[0]);
+
+sunos_sys_ptrace(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_ptrace_args *uap = v;
+ struct sys_ptrace_args pa;
+ int req;
+
+ req = SCARG(uap, req);
+
+ if (req < 0 || req >= nreqs)
+ return (EINVAL);
+
+ req = sreq2breq[req];
+ if (req == -1)
+ return (EINVAL);
+
+ SCARG(&pa, req) = req;
+ SCARG(&pa, pid) = (pid_t)SCARG(uap, pid);
+ SCARG(&pa, addr) = (caddr_t)SCARG(uap, addr);
+ SCARG(&pa, data) = SCARG(uap, data);
+
+ return sys_ptrace(p, &pa, retval);
+}
+
+static void
+sunos_pollscan(p, pl, nfd, retval)
+ struct proc *p;
+ struct sunos_pollfd *pl;
+ int nfd;
+ register_t *retval;
+{
+ register struct filedesc *fdp = p->p_fd;
+ register int msk, i;
+ struct file *fp;
+ int n = 0;
+ static int flag[3] = { FREAD, FWRITE, 0 };
+ static int pflag[3] = { SUNOS_POLLIN|SUNOS_POLLRDNORM,
+ SUNOS_POLLOUT, SUNOS_POLLERR };
+
+ /*
+ * XXX: We need to implement the rest of the flags.
+ */
+ for (i = 0; i < nfd; i++) {
+ fp = fdp->fd_ofiles[pl[i].fd];
+ if (fp == NULL) {
+ if (pl[i].events & SUNOS_POLLNVAL) {
+ pl[i].revents |= SUNOS_POLLNVAL;
+ n++;
+ }
+ continue;
+ }
+ for (msk = 0; msk < 3; msk++) {
+ if (pl[i].events & pflag[msk]) {
+ if ((*fp->f_ops->fo_select)(fp, flag[msk], p)) {
+ pl[i].revents |=
+ pflag[msk] & pl[i].events;
+ n++;
+ }
+ }
+ }
+ }
+ *retval = n;
+}
+
+
+/*
+ * We are using the same mechanism as select only we encode/decode args
+ * differently.
+ */
+int
+sunos_sys_poll(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_poll_args *uap = v;
+ int i, s;
+ int error, error2;
+ size_t sz = sizeof(struct sunos_pollfd) * SCARG(uap, nfds);
+ struct sunos_pollfd *pl;
+ int msec = SCARG(uap, timeout);
+ struct timeval atv;
+ int timo;
+ u_int ni;
+ int ncoll;
+ extern int nselcoll, selwait;
+
+ pl = (struct sunos_pollfd *) malloc(sz, M_TEMP, M_WAITOK);
+
+ if (error = copyin(SCARG(uap, fds), pl, sz))
+ goto bad;
+
+ for (i = 0; i < SCARG(uap, nfds); i++)
+ pl[i].revents = 0;
+
+ if (msec != -1) {
+ atv.tv_sec = msec / 1000;
+ atv.tv_usec = (msec - (atv.tv_sec * 1000)) * 1000;
+
+ if (itimerfix(&atv)) {
+ error = EINVAL;
+ goto done;
+ }
+ s = splclock();
+ timeradd(&atv, &time, &atv);
+ timo = hzto(&atv);
+ /*
+ * Avoid inadvertently sleeping forever.
+ */
+ if (timo == 0)
+ timo = 1;
+ splx(s);
+ } else
+ timo = 0;
+
+retry:
+ ncoll = nselcoll;
+ p->p_flag |= P_SELECT;
+ sunos_pollscan(p, pl, SCARG(uap, nfds), retval);
+ if (*retval)
+ goto done;
+ s = splhigh();
+ if (timo && timercmp(&time, &atv, >=)) {
+ splx(s);
+ goto done;
+ }
+ if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) {
+ splx(s);
+ goto retry;
+ }
+ p->p_flag &= ~P_SELECT;
+ error = tsleep((caddr_t)&selwait, PSOCK | PCATCH, "sunos_poll", timo);
+ splx(s);
+ if (error == 0)
+ goto retry;
+
+done:
+ p->p_flag &= ~P_SELECT;
+ /* poll is not restarted after signals... */
+ if (error == ERESTART)
+ error = EINTR;
+ if (error == EWOULDBLOCK)
+ error = 0;
+
+ if (error2 = copyout(pl, SCARG(uap, fds), sz))
+ error = error2;
+
+bad:
+ free((char *) pl, M_TEMP);
+
+ return (error);
+}
+
+/*
+ * SunOS reboot system call (for compatibility).
+ * Sun lets you pass in a boot string which the PROM
+ * saves and provides to the next boot program.
+ */
+static struct sunos_howto_conv {
+ int sun_howto;
+ int bsd_howto;
+} sunos_howto_conv[] = {
+ { 0x001, RB_ASKNAME },
+ { 0x002, RB_SINGLE },
+ { 0x004, RB_NOSYNC },
+ { 0x008, RB_HALT },
+ { 0x080, RB_DUMP },
+ { 0x000, 0 },
+};
+#define SUNOS_RB_STRING 0x200
+
+int
+sunos_sys_reboot(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sunos_sys_reboot_args *uap = v;
+ struct sunos_howto_conv *convp;
+ int error, bsd_howto, sun_howto;
+
+ if (error = suser(p->p_ucred, &p->p_acflag))
+ return (error);
+
+ /*
+ * Convert howto bits to BSD format.
+ */
+ sun_howto = SCARG(uap, howto);
+ bsd_howto = 0;
+ convp = sunos_howto_conv;
+ while (convp->sun_howto) {
+ if (sun_howto & convp->sun_howto)
+ bsd_howto |= convp->bsd_howto;
+ convp++;
+ }
+
+#ifdef sun3
+ /*
+ * Sun RB_STRING (Get user supplied bootstring.)
+ * If the machine supports passing a string to the
+ * next booted kernel, add the machine name above
+ * and provide a reboot2() function (see sun3).
+ */
+ if (sun_howto & SUNOS_RB_STRING) {
+ char bs[128];
+
+ error = copyinstr(SCARG(uap, bootstr), bs, sizeof(bs), 0);
+ if (error)
+ return error;
+
+ return (reboot2(bsd_howto, bs));
+ }
+#endif /* sun3 */
+
+ return (boot(bsd_howto));
+}
+
+/*
+ * Generalized interface signal handler, 4.3-compatible.
+ */
+/* ARGSUSED */
+int
+sunos_sys_sigvec(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct sunos_sys_sigvec_args /* {
+ syscallarg(int) signum;
+ syscallarg(struct sigvec *) nsv;
+ syscallarg(struct sigvec *) osv;
+ } */ *uap = v;
+ struct sigvec vec;
+ register struct sigacts *ps = p->p_sigacts;
+ register struct sigvec *sv;
+ register int signum;
+ int bit, error;
+
+ signum = SCARG(uap, signum);
+ if (signum <= 0 || signum >= NSIG ||
+ signum == SIGKILL || signum == SIGSTOP)
+ return (EINVAL);
+ sv = &vec;
+ if (SCARG(uap, osv)) {
+ *(sig_t *)&sv->sv_handler = ps->ps_sigact[signum];
+ sv->sv_mask = ps->ps_catchmask[signum];
+ bit = sigmask(signum);
+ sv->sv_flags = 0;
+ if ((ps->ps_sigonstack & bit) != 0)
+ sv->sv_flags |= SV_ONSTACK;
+ if ((ps->ps_sigintr & bit) != 0)
+ sv->sv_flags |= SV_INTERRUPT;
+ if ((ps->ps_sigreset & bit) != 0)
+ sv->sv_flags |= SA_RESETHAND;
+ sv->sv_mask &= ~bit;
+ if (error = copyout((caddr_t)sv, (caddr_t)SCARG(uap, osv),
+ sizeof (vec)))
+ return (error);
+ }
+ if (SCARG(uap, nsv)) {
+ if (error = copyin((caddr_t)SCARG(uap, nsv), (caddr_t)sv,
+ sizeof (vec)))
+ return (error);
+ /*
+ * SunOS uses the mask 0x0004 as SV_RESETHAND
+ * meaning: `reset to SIG_DFL on delivery'.
+ * We support only the bits in: 0xF
+ * (those bits are the same as ours)
+ */
+ if (sv->sv_flags & ~0xF)
+ return (EINVAL);
+ /* SunOS binaries have a user-mode trampoline. */
+ sv->sv_flags |= SA_USERTRAMP;
+ /* Convert sigvec:SV_INTERRUPT to sigaction:SA_RESTART */
+ sv->sv_flags ^= SA_RESTART; /* same bit, inverted */
+ setsigvec(p, signum, (struct sigaction *)sv);
+ }
+ return (0);
+}
diff --git a/sys/compat/sunos/sunos_syscall.h b/sys/compat/sunos/sunos_syscall.h
new file mode 100644
index 00000000000..5f3cfc53a37
--- /dev/null
+++ b/sys/compat/sunos/sunos_syscall.h
@@ -0,0 +1,157 @@
+/*
+ * System call numbers.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.32 1995/10/07 06:27:35 mycroft Exp
+ */
+
+#define SUNOS_SYS_syscall 0
+#define SUNOS_SYS_exit 1
+#define SUNOS_SYS_fork 2
+#define SUNOS_SYS_read 3
+#define SUNOS_SYS_write 4
+#define SUNOS_SYS_open 5
+#define SUNOS_SYS_close 6
+#define SUNOS_SYS_wait4 7
+#define SUNOS_SYS_creat 8
+#define SUNOS_SYS_link 9
+#define SUNOS_SYS_unlink 10
+#define SUNOS_SYS_execv 11
+#define SUNOS_SYS_chdir 12
+ /* 13 is obsolete time */
+#define SUNOS_SYS_mknod 14
+#define SUNOS_SYS_chmod 15
+#define SUNOS_SYS_chown 16
+#define SUNOS_SYS_break 17
+ /* 18 is obsolete stat */
+#define SUNOS_SYS_lseek 19
+#define SUNOS_SYS_getpid 20
+ /* 21 is obsolete sunos_old_mount */
+#define SUNOS_SYS_setuid 23
+#define SUNOS_SYS_getuid 24
+#define SUNOS_SYS_ptrace 26
+#define SUNOS_SYS_access 33
+#define SUNOS_SYS_sync 36
+#define SUNOS_SYS_kill 37
+#define SUNOS_SYS_stat 38
+#define SUNOS_SYS_lstat 40
+#define SUNOS_SYS_dup 41
+#define SUNOS_SYS_pipe 42
+#define SUNOS_SYS_profil 44
+#define SUNOS_SYS_setgid 46
+#define SUNOS_SYS_getgid 47
+#define SUNOS_SYS_acct 51
+#define SUNOS_SYS_mctl 53
+#define SUNOS_SYS_ioctl 54
+#define SUNOS_SYS_reboot 55
+ /* 56 is obsolete sunos_owait3 */
+#define SUNOS_SYS_symlink 57
+#define SUNOS_SYS_readlink 58
+#define SUNOS_SYS_execve 59
+#define SUNOS_SYS_umask 60
+#define SUNOS_SYS_chroot 61
+#define SUNOS_SYS_fstat 62
+#define SUNOS_SYS_getpagesize 64
+#define SUNOS_SYS_omsync 65
+#define SUNOS_SYS_vfork 66
+ /* 67 is obsolete vread */
+ /* 68 is obsolete vwrite */
+#define SUNOS_SYS_sbrk 69
+#define SUNOS_SYS_sstk 70
+#define SUNOS_SYS_mmap 71
+#define SUNOS_SYS_vadvise 72
+#define SUNOS_SYS_munmap 73
+#define SUNOS_SYS_mprotect 74
+#define SUNOS_SYS_madvise 75
+#define SUNOS_SYS_vhangup 76
+#define SUNOS_SYS_mincore 78
+#define SUNOS_SYS_getgroups 79
+#define SUNOS_SYS_setgroups 80
+#define SUNOS_SYS_getpgrp 81
+#define SUNOS_SYS_setpgrp 82
+#define SUNOS_SYS_setitimer 83
+#define SUNOS_SYS_swapon 85
+#define SUNOS_SYS_getitimer 86
+#define SUNOS_SYS_gethostname 87
+#define SUNOS_SYS_sethostname 88
+#define SUNOS_SYS_getdtablesize 89
+#define SUNOS_SYS_dup2 90
+#define SUNOS_SYS_fcntl 92
+#define SUNOS_SYS_select 93
+#define SUNOS_SYS_fsync 95
+#define SUNOS_SYS_setpriority 96
+#define SUNOS_SYS_socket 97
+#define SUNOS_SYS_connect 98
+#define SUNOS_SYS_accept 99
+#define SUNOS_SYS_getpriority 100
+#define SUNOS_SYS_send 101
+#define SUNOS_SYS_recv 102
+#define SUNOS_SYS_bind 104
+#define SUNOS_SYS_setsockopt 105
+#define SUNOS_SYS_listen 106
+#define SUNOS_SYS_sigvec 108
+#define SUNOS_SYS_sigblock 109
+#define SUNOS_SYS_sigsetmask 110
+#define SUNOS_SYS_sigsuspend 111
+#define SUNOS_SYS_sigstack 112
+#define SUNOS_SYS_recvmsg 113
+#define SUNOS_SYS_sendmsg 114
+ /* 115 is obsolete vtrace */
+#define SUNOS_SYS_gettimeofday 116
+#define SUNOS_SYS_getrusage 117
+#define SUNOS_SYS_getsockopt 118
+#define SUNOS_SYS_readv 120
+#define SUNOS_SYS_writev 121
+#define SUNOS_SYS_settimeofday 122
+#define SUNOS_SYS_fchown 123
+#define SUNOS_SYS_fchmod 124
+#define SUNOS_SYS_recvfrom 125
+#define SUNOS_SYS_setreuid 126
+#define SUNOS_SYS_setregid 127
+#define SUNOS_SYS_rename 128
+#define SUNOS_SYS_truncate 129
+#define SUNOS_SYS_ftruncate 130
+#define SUNOS_SYS_flock 131
+#define SUNOS_SYS_sendto 133
+#define SUNOS_SYS_shutdown 134
+#define SUNOS_SYS_socketpair 135
+#define SUNOS_SYS_mkdir 136
+#define SUNOS_SYS_rmdir 137
+#define SUNOS_SYS_utimes 138
+#define SUNOS_SYS_sigreturn 139
+#define SUNOS_SYS_adjtime 140
+#define SUNOS_SYS_getpeername 141
+#define SUNOS_SYS_gethostid 142
+#define SUNOS_SYS_getrlimit 144
+#define SUNOS_SYS_setrlimit 145
+#define SUNOS_SYS_killpg 146
+#define SUNOS_SYS_getsockname 150
+#define SUNOS_SYS_poll 153
+#define SUNOS_SYS_nfssvc 155
+#define SUNOS_SYS_getdirentries 156
+#define SUNOS_SYS_statfs 157
+#define SUNOS_SYS_fstatfs 158
+#define SUNOS_SYS_unmount 159
+#define SUNOS_SYS_async_daemon 160
+#define SUNOS_SYS_getfh 161
+#define SUNOS_SYS_getdomainname 162
+#define SUNOS_SYS_setdomainname 163
+#define SUNOS_SYS_quotactl 165
+#define SUNOS_SYS_exportfs 166
+#define SUNOS_SYS_mount 167
+#define SUNOS_SYS_ustat 168
+#define SUNOS_SYS_semsys 169
+#define SUNOS_SYS_msgsys 170
+#define SUNOS_SYS_shmsys 171
+#define SUNOS_SYS_auditsys 172
+#define SUNOS_SYS_getdents 174
+#define SUNOS_SYS_setsid 175
+#define SUNOS_SYS_fchdir 176
+#define SUNOS_SYS_fchroot 177
+#define SUNOS_SYS_sigpending 183
+#define SUNOS_SYS_setpgid 185
+#define SUNOS_SYS_pathconf 186
+#define SUNOS_SYS_fpathconf 187
+#define SUNOS_SYS_sysconf 188
+#define SUNOS_SYS_uname 189
+#define SUNOS_SYS_MAXSYSCALL 190
diff --git a/sys/compat/sunos/sunos_syscallargs.h b/sys/compat/sunos/sunos_syscallargs.h
new file mode 100644
index 00000000000..cf9f3da584b
--- /dev/null
+++ b/sys/compat/sunos/sunos_syscallargs.h
@@ -0,0 +1,362 @@
+/*
+ * System call argument lists.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.32 1995/10/07 06:27:35 mycroft Exp
+ */
+
+#define syscallarg(x) union { x datum; register_t pad; }
+
+struct sunos_sys_open_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+};
+
+struct sunos_sys_wait4_args {
+ syscallarg(int) pid;
+ syscallarg(int *) status;
+ syscallarg(int) options;
+ syscallarg(struct rusage *) rusage;
+};
+
+struct sunos_sys_creat_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct sunos_sys_execv_args {
+ syscallarg(char *) path;
+ syscallarg(char **) argp;
+};
+
+struct sunos_sys_mknod_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ syscallarg(int) dev;
+};
+
+struct sunos_sys_ptrace_args {
+ syscallarg(int) req;
+ syscallarg(pid_t) pid;
+ syscallarg(caddr_t) addr;
+ syscallarg(int) data;
+ syscallarg(char *) addr2;
+};
+
+struct sunos_sys_access_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+};
+
+struct sunos_sys_stat_args {
+ syscallarg(char *) path;
+ syscallarg(struct ostat *) ub;
+};
+
+struct sunos_sys_lstat_args {
+ syscallarg(char *) path;
+ syscallarg(struct ostat *) ub;
+};
+
+struct sunos_sys_mctl_args {
+ syscallarg(caddr_t) addr;
+ syscallarg(int) len;
+ syscallarg(int) func;
+ syscallarg(void *) arg;
+};
+
+struct sunos_sys_ioctl_args {
+ syscallarg(int) fd;
+ syscallarg(u_long) com;
+ syscallarg(caddr_t) data;
+};
+
+struct sunos_sys_reboot_args {
+ syscallarg(int) howto;
+ syscallarg(char *) bootstr;
+};
+
+struct sunos_sys_omsync_args {
+ syscallarg(caddr_t) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) flags;
+};
+
+struct sunos_sys_mmap_args {
+ syscallarg(caddr_t) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) prot;
+ syscallarg(int) flags;
+ syscallarg(int) fd;
+ syscallarg(long) pos;
+};
+
+struct sunos_sys_setpgrp_args {
+ syscallarg(int) pid;
+ syscallarg(int) pgid;
+};
+
+struct sunos_sys_setsockopt_args {
+ syscallarg(int) s;
+ syscallarg(int) level;
+ syscallarg(int) name;
+ syscallarg(caddr_t) val;
+ syscallarg(int) valsize;
+};
+
+struct sunos_sys_sigvec_args {
+ syscallarg(int) signum;
+ syscallarg(struct sigvec *) nsv;
+ syscallarg(struct sigvec *) osv;
+};
+
+struct sunos_sys_sigreturn_args {
+ syscallarg(struct sigcontext *) sigcntxp;
+};
+
+struct sunos_sys_getrlimit_args {
+ syscallarg(u_int) which;
+ syscallarg(struct orlimit *) rlp;
+};
+
+struct sunos_sys_setrlimit_args {
+ syscallarg(u_int) which;
+ syscallarg(struct orlimit *) rlp;
+};
+
+struct sunos_sys_poll_args {
+ syscallarg(struct sunos_pollfd *) fds;
+ syscallarg(long) nfds;
+ syscallarg(int) timeout;
+};
+
+struct sunos_sys_nfssvc_args {
+ syscallarg(int) fd;
+};
+
+struct sunos_sys_statfs_args {
+ syscallarg(char *) path;
+ syscallarg(struct sunos_statfs *) buf;
+};
+
+struct sunos_sys_fstatfs_args {
+ syscallarg(int) fd;
+ syscallarg(struct sunos_statfs *) buf;
+};
+
+struct sunos_sys_unmount_args {
+ syscallarg(char *) path;
+};
+
+struct sunos_sys_quotactl_args {
+ syscallarg(int) cmd;
+ syscallarg(char *) special;
+ syscallarg(int) uid;
+ syscallarg(caddr_t) addr;
+};
+
+struct sunos_sys_exportfs_args {
+ syscallarg(char *) path;
+ syscallarg(char *) ex;
+};
+
+struct sunos_sys_mount_args {
+ syscallarg(char *) type;
+ syscallarg(char *) dir;
+ syscallarg(int) flags;
+ syscallarg(caddr_t) data;
+};
+
+struct sunos_sys_ustat_args {
+ syscallarg(int) dev;
+ syscallarg(struct sunos_ustat *) buf;
+};
+
+struct sunos_sys_auditsys_args {
+ syscallarg(char *) record;
+};
+
+struct sunos_sys_getdents_args {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(int) nbytes;
+};
+
+struct sunos_sys_fchroot_args {
+ syscallarg(int) fd;
+};
+
+struct sunos_sys_sigpending_args {
+ syscallarg(int *) mask;
+};
+
+struct sunos_sys_sysconf_args {
+ syscallarg(int) name;
+};
+
+struct sunos_sys_uname_args {
+ syscallarg(struct sunos_utsname *) name;
+};
+
+/*
+ * System call prototypes.
+ */
+
+int sys_nosys __P((struct proc *, void *, register_t *));
+int sys_exit __P((struct proc *, void *, register_t *));
+int sys_fork __P((struct proc *, void *, register_t *));
+int sys_read __P((struct proc *, void *, register_t *));
+int sys_write __P((struct proc *, void *, register_t *));
+int sunos_sys_open __P((struct proc *, void *, register_t *));
+int sys_close __P((struct proc *, void *, register_t *));
+int sunos_sys_wait4 __P((struct proc *, void *, register_t *));
+int sunos_sys_creat __P((struct proc *, void *, register_t *));
+int sys_link __P((struct proc *, void *, register_t *));
+int sys_unlink __P((struct proc *, void *, register_t *));
+int sunos_sys_execv __P((struct proc *, void *, register_t *));
+int sys_chdir __P((struct proc *, void *, register_t *));
+int sunos_sys_mknod __P((struct proc *, void *, register_t *));
+int sys_chmod __P((struct proc *, void *, register_t *));
+int sys_chown __P((struct proc *, void *, register_t *));
+int sys_obreak __P((struct proc *, void *, register_t *));
+int compat_43_sys_lseek __P((struct proc *, void *, register_t *));
+int sys_getpid __P((struct proc *, void *, register_t *));
+int sys_setuid __P((struct proc *, void *, register_t *));
+int sys_getuid __P((struct proc *, void *, register_t *));
+int sunos_sys_ptrace __P((struct proc *, void *, register_t *));
+int sunos_sys_access __P((struct proc *, void *, register_t *));
+int sys_sync __P((struct proc *, void *, register_t *));
+int sys_kill __P((struct proc *, void *, register_t *));
+int sunos_sys_stat __P((struct proc *, void *, register_t *));
+int sunos_sys_lstat __P((struct proc *, void *, register_t *));
+int sys_dup __P((struct proc *, void *, register_t *));
+int sys_pipe __P((struct proc *, void *, register_t *));
+int sys_profil __P((struct proc *, void *, register_t *));
+int sys_setgid __P((struct proc *, void *, register_t *));
+int sys_getgid __P((struct proc *, void *, register_t *));
+int sys_acct __P((struct proc *, void *, register_t *));
+int sunos_sys_mctl __P((struct proc *, void *, register_t *));
+int sunos_sys_ioctl __P((struct proc *, void *, register_t *));
+int sunos_sys_reboot __P((struct proc *, void *, register_t *));
+int sys_symlink __P((struct proc *, void *, register_t *));
+int sys_readlink __P((struct proc *, void *, register_t *));
+int sys_execve __P((struct proc *, void *, register_t *));
+int sys_umask __P((struct proc *, void *, register_t *));
+int sys_chroot __P((struct proc *, void *, register_t *));
+int compat_43_sys_fstat __P((struct proc *, void *, register_t *));
+int compat_43_sys_getpagesize __P((struct proc *, void *, register_t *));
+int sunos_sys_omsync __P((struct proc *, void *, register_t *));
+int sys_vfork __P((struct proc *, void *, register_t *));
+int sys_sbrk __P((struct proc *, void *, register_t *));
+int sys_sstk __P((struct proc *, void *, register_t *));
+int sunos_sys_mmap __P((struct proc *, void *, register_t *));
+int sys_ovadvise __P((struct proc *, void *, register_t *));
+int sys_munmap __P((struct proc *, void *, register_t *));
+int sys_mprotect __P((struct proc *, void *, register_t *));
+int sys_madvise __P((struct proc *, void *, register_t *));
+int sunos_sys_vhangup __P((struct proc *, void *, register_t *));
+int sys_mincore __P((struct proc *, void *, register_t *));
+int sys_getgroups __P((struct proc *, void *, register_t *));
+int sys_setgroups __P((struct proc *, void *, register_t *));
+int sys_getpgrp __P((struct proc *, void *, register_t *));
+int sunos_sys_setpgrp __P((struct proc *, void *, register_t *));
+int sys_setitimer __P((struct proc *, void *, register_t *));
+int sys_swapon __P((struct proc *, void *, register_t *));
+int sys_getitimer __P((struct proc *, void *, register_t *));
+int compat_43_sys_gethostname __P((struct proc *, void *, register_t *));
+int compat_43_sys_sethostname __P((struct proc *, void *, register_t *));
+int compat_43_sys_getdtablesize __P((struct proc *, void *, register_t *));
+int sys_dup2 __P((struct proc *, void *, register_t *));
+int sys_fcntl __P((struct proc *, void *, register_t *));
+int sys_select __P((struct proc *, void *, register_t *));
+int sys_fsync __P((struct proc *, void *, register_t *));
+int sys_setpriority __P((struct proc *, void *, register_t *));
+int sys_socket __P((struct proc *, void *, register_t *));
+int sys_connect __P((struct proc *, void *, register_t *));
+int compat_43_sys_accept __P((struct proc *, void *, register_t *));
+int sys_getpriority __P((struct proc *, void *, register_t *));
+int compat_43_sys_send __P((struct proc *, void *, register_t *));
+int compat_43_sys_recv __P((struct proc *, void *, register_t *));
+int sys_bind __P((struct proc *, void *, register_t *));
+int sunos_sys_setsockopt __P((struct proc *, void *, register_t *));
+int sys_listen __P((struct proc *, void *, register_t *));
+int sunos_sys_sigvec __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigblock __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigsetmask __P((struct proc *, void *, register_t *));
+int sys_sigsuspend __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigstack __P((struct proc *, void *, register_t *));
+int compat_43_sys_recvmsg __P((struct proc *, void *, register_t *));
+int compat_43_sys_sendmsg __P((struct proc *, void *, register_t *));
+int sys_gettimeofday __P((struct proc *, void *, register_t *));
+int sys_getrusage __P((struct proc *, void *, register_t *));
+int sys_getsockopt __P((struct proc *, void *, register_t *));
+int sys_readv __P((struct proc *, void *, register_t *));
+int sys_writev __P((struct proc *, void *, register_t *));
+int sys_settimeofday __P((struct proc *, void *, register_t *));
+int sys_fchown __P((struct proc *, void *, register_t *));
+int sys_fchmod __P((struct proc *, void *, register_t *));
+int compat_43_sys_recvfrom __P((struct proc *, void *, register_t *));
+int compat_43_sys_setreuid __P((struct proc *, void *, register_t *));
+int compat_43_sys_setregid __P((struct proc *, void *, register_t *));
+int sys_rename __P((struct proc *, void *, register_t *));
+int compat_43_sys_truncate __P((struct proc *, void *, register_t *));
+int compat_43_sys_ftruncate __P((struct proc *, void *, register_t *));
+int sys_flock __P((struct proc *, void *, register_t *));
+int sys_sendto __P((struct proc *, void *, register_t *));
+int sys_shutdown __P((struct proc *, void *, register_t *));
+int sys_socketpair __P((struct proc *, void *, register_t *));
+int sys_mkdir __P((struct proc *, void *, register_t *));
+int sys_rmdir __P((struct proc *, void *, register_t *));
+int sys_utimes __P((struct proc *, void *, register_t *));
+int sunos_sys_sigreturn __P((struct proc *, void *, register_t *));
+int sys_adjtime __P((struct proc *, void *, register_t *));
+int compat_43_sys_getpeername __P((struct proc *, void *, register_t *));
+int compat_43_sys_gethostid __P((struct proc *, void *, register_t *));
+int sunos_sys_getrlimit __P((struct proc *, void *, register_t *));
+int sunos_sys_setrlimit __P((struct proc *, void *, register_t *));
+int compat_43_sys_killpg __P((struct proc *, void *, register_t *));
+int compat_43_sys_getsockname __P((struct proc *, void *, register_t *));
+int sunos_sys_poll __P((struct proc *, void *, register_t *));
+#ifdef NFSSERVER
+int sunos_sys_nfssvc __P((struct proc *, void *, register_t *));
+#else
+#endif
+int sys_getdirentries __P((struct proc *, void *, register_t *));
+int sunos_sys_statfs __P((struct proc *, void *, register_t *));
+int sunos_sys_fstatfs __P((struct proc *, void *, register_t *));
+int sunos_sys_unmount __P((struct proc *, void *, register_t *));
+#ifdef NFSCLIENT
+int async_daemon __P((struct proc *, void *, register_t *));
+int sys_getfh __P((struct proc *, void *, register_t *));
+#else
+#endif
+int compat_09_sys_getdomainname __P((struct proc *, void *, register_t *));
+int compat_09_sys_setdomainname __P((struct proc *, void *, register_t *));
+int sunos_sys_quotactl __P((struct proc *, void *, register_t *));
+int sunos_sys_exportfs __P((struct proc *, void *, register_t *));
+int sunos_sys_mount __P((struct proc *, void *, register_t *));
+int sunos_sys_ustat __P((struct proc *, void *, register_t *));
+#ifdef SYSVSEM
+int compat_10_sys_semsys __P((struct proc *, void *, register_t *));
+#else
+#endif
+#ifdef SYSVMSG
+int compat_10_sys_msgsys __P((struct proc *, void *, register_t *));
+#else
+#endif
+#ifdef SYSVSHM
+int compat_10_sys_shmsys __P((struct proc *, void *, register_t *));
+#else
+#endif
+int sunos_sys_auditsys __P((struct proc *, void *, register_t *));
+int sunos_sys_getdents __P((struct proc *, void *, register_t *));
+int sys_setsid __P((struct proc *, void *, register_t *));
+int sys_fchdir __P((struct proc *, void *, register_t *));
+int sunos_sys_fchroot __P((struct proc *, void *, register_t *));
+int sunos_sys_sigpending __P((struct proc *, void *, register_t *));
+int sys_setpgid __P((struct proc *, void *, register_t *));
+int sys_pathconf __P((struct proc *, void *, register_t *));
+int sys_fpathconf __P((struct proc *, void *, register_t *));
+int sunos_sys_sysconf __P((struct proc *, void *, register_t *));
+int sunos_sys_uname __P((struct proc *, void *, register_t *));
diff --git a/sys/compat/sunos/sunos_syscalls.c b/sys/compat/sunos/sunos_syscalls.c
new file mode 100644
index 00000000000..c53d6460f9f
--- /dev/null
+++ b/sys/compat/sunos/sunos_syscalls.c
@@ -0,0 +1,220 @@
+/*
+ * System call names.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.32 1995/10/07 06:27:35 mycroft Exp
+ */
+
+char *sunos_syscallnames[] = {
+ "syscall", /* 0 = syscall */
+ "exit", /* 1 = exit */
+ "fork", /* 2 = fork */
+ "read", /* 3 = read */
+ "write", /* 4 = write */
+ "open", /* 5 = open */
+ "close", /* 6 = close */
+ "wait4", /* 7 = wait4 */
+ "creat", /* 8 = creat */
+ "link", /* 9 = link */
+ "unlink", /* 10 = unlink */
+ "execv", /* 11 = execv */
+ "chdir", /* 12 = chdir */
+ "#13 (obsolete time)", /* 13 = obsolete time */
+ "mknod", /* 14 = mknod */
+ "chmod", /* 15 = chmod */
+ "chown", /* 16 = chown */
+ "break", /* 17 = break */
+ "#18 (obsolete stat)", /* 18 = obsolete stat */
+ "lseek", /* 19 = lseek */
+ "getpid", /* 20 = getpid */
+ "#21 (obsolete sunos_old_mount)", /* 21 = obsolete sunos_old_mount */
+ "#22 (unimplemented System V umount)", /* 22 = unimplemented System V umount */
+ "setuid", /* 23 = setuid */
+ "getuid", /* 24 = getuid */
+ "#25 (unimplemented sunos_stime)", /* 25 = unimplemented sunos_stime */
+ "ptrace", /* 26 = ptrace */
+ "#27 (unimplemented sunos_alarm)", /* 27 = unimplemented sunos_alarm */
+ "#28 (unimplemented sunos_fstat)", /* 28 = unimplemented sunos_fstat */
+ "#29 (unimplemented sunos_pause)", /* 29 = unimplemented sunos_pause */
+ "#30 (unimplemented sunos_utime)", /* 30 = unimplemented sunos_utime */
+ "#31 (unimplemented sunos_stty)", /* 31 = unimplemented sunos_stty */
+ "#32 (unimplemented sunos_gtty)", /* 32 = unimplemented sunos_gtty */
+ "access", /* 33 = access */
+ "#34 (unimplemented sunos_nice)", /* 34 = unimplemented sunos_nice */
+ "#35 (unimplemented sunos_ftime)", /* 35 = unimplemented sunos_ftime */
+ "sync", /* 36 = sync */
+ "kill", /* 37 = kill */
+ "stat", /* 38 = stat */
+ "#39 (unimplemented sunos_setpgrp)", /* 39 = unimplemented sunos_setpgrp */
+ "lstat", /* 40 = lstat */
+ "dup", /* 41 = dup */
+ "pipe", /* 42 = pipe */
+ "#43 (unimplemented sunos_times)", /* 43 = unimplemented sunos_times */
+ "profil", /* 44 = profil */
+ "#45 (unimplemented)", /* 45 = unimplemented */
+ "setgid", /* 46 = setgid */
+ "getgid", /* 47 = getgid */
+ "#48 (unimplemented sunos_ssig)", /* 48 = unimplemented sunos_ssig */
+ "#49 (unimplemented reserved for USG)", /* 49 = unimplemented reserved for USG */
+ "#50 (unimplemented reserved for USG)", /* 50 = unimplemented reserved for USG */
+ "acct", /* 51 = acct */
+ "#52 (unimplemented)", /* 52 = unimplemented */
+ "mctl", /* 53 = mctl */
+ "ioctl", /* 54 = ioctl */
+ "reboot", /* 55 = reboot */
+ "#56 (obsolete sunos_owait3)", /* 56 = obsolete sunos_owait3 */
+ "symlink", /* 57 = symlink */
+ "readlink", /* 58 = readlink */
+ "execve", /* 59 = execve */
+ "umask", /* 60 = umask */
+ "chroot", /* 61 = chroot */
+ "fstat", /* 62 = fstat */
+ "#63 (unimplemented)", /* 63 = unimplemented */
+ "getpagesize", /* 64 = getpagesize */
+ "omsync", /* 65 = omsync */
+ "vfork", /* 66 = vfork */
+ "#67 (obsolete vread)", /* 67 = obsolete vread */
+ "#68 (obsolete vwrite)", /* 68 = obsolete vwrite */
+ "sbrk", /* 69 = sbrk */
+ "sstk", /* 70 = sstk */
+ "mmap", /* 71 = mmap */
+ "vadvise", /* 72 = vadvise */
+ "munmap", /* 73 = munmap */
+ "mprotect", /* 74 = mprotect */
+ "madvise", /* 75 = madvise */
+ "vhangup", /* 76 = vhangup */
+ "#77 (unimplemented vlimit)", /* 77 = unimplemented vlimit */
+ "mincore", /* 78 = mincore */
+ "getgroups", /* 79 = getgroups */
+ "setgroups", /* 80 = setgroups */
+ "getpgrp", /* 81 = getpgrp */
+ "setpgrp", /* 82 = setpgrp */
+ "setitimer", /* 83 = setitimer */
+ "#84 (unimplemented { int sunos_sys_wait ( void ) ; })", /* 84 = unimplemented { int sunos_sys_wait ( void ) ; } */
+ "swapon", /* 85 = swapon */
+ "getitimer", /* 86 = getitimer */
+ "gethostname", /* 87 = gethostname */
+ "sethostname", /* 88 = sethostname */
+ "getdtablesize", /* 89 = getdtablesize */
+ "dup2", /* 90 = dup2 */
+ "#91 (unimplemented getdopt)", /* 91 = unimplemented getdopt */
+ "fcntl", /* 92 = fcntl */
+ "select", /* 93 = select */
+ "#94 (unimplemented setdopt)", /* 94 = unimplemented setdopt */
+ "fsync", /* 95 = fsync */
+ "setpriority", /* 96 = setpriority */
+ "socket", /* 97 = socket */
+ "connect", /* 98 = connect */
+ "accept", /* 99 = accept */
+ "getpriority", /* 100 = getpriority */
+ "send", /* 101 = send */
+ "recv", /* 102 = recv */
+ "#103 (unimplemented old socketaddr)", /* 103 = unimplemented old socketaddr */
+ "bind", /* 104 = bind */
+ "setsockopt", /* 105 = setsockopt */
+ "listen", /* 106 = listen */
+ "#107 (unimplemented vtimes)", /* 107 = unimplemented vtimes */
+ "sigvec", /* 108 = sigvec */
+ "sigblock", /* 109 = sigblock */
+ "sigsetmask", /* 110 = sigsetmask */
+ "sigsuspend", /* 111 = sigsuspend */
+ "sigstack", /* 112 = sigstack */
+ "recvmsg", /* 113 = recvmsg */
+ "sendmsg", /* 114 = sendmsg */
+ "#115 (obsolete vtrace)", /* 115 = obsolete vtrace */
+ "gettimeofday", /* 116 = gettimeofday */
+ "getrusage", /* 117 = getrusage */
+ "getsockopt", /* 118 = getsockopt */
+ "#119 (unimplemented)", /* 119 = unimplemented */
+ "readv", /* 120 = readv */
+ "writev", /* 121 = writev */
+ "settimeofday", /* 122 = settimeofday */
+ "fchown", /* 123 = fchown */
+ "fchmod", /* 124 = fchmod */
+ "recvfrom", /* 125 = recvfrom */
+ "setreuid", /* 126 = setreuid */
+ "setregid", /* 127 = setregid */
+ "rename", /* 128 = rename */
+ "truncate", /* 129 = truncate */
+ "ftruncate", /* 130 = ftruncate */
+ "flock", /* 131 = flock */
+ "#132 (unimplemented)", /* 132 = unimplemented */
+ "sendto", /* 133 = sendto */
+ "shutdown", /* 134 = shutdown */
+ "socketpair", /* 135 = socketpair */
+ "mkdir", /* 136 = mkdir */
+ "rmdir", /* 137 = rmdir */
+ "utimes", /* 138 = utimes */
+ "sigreturn", /* 139 = sigreturn */
+ "adjtime", /* 140 = adjtime */
+ "getpeername", /* 141 = getpeername */
+ "gethostid", /* 142 = gethostid */
+ "#143 (unimplemented old sethostid)", /* 143 = unimplemented old sethostid */
+ "getrlimit", /* 144 = getrlimit */
+ "setrlimit", /* 145 = setrlimit */
+ "killpg", /* 146 = killpg */
+ "#147 (unimplemented)", /* 147 = unimplemented */
+ "#148 (unimplemented)", /* 148 = unimplemented */
+ "#149 (unimplemented)", /* 149 = unimplemented */
+ "getsockname", /* 150 = getsockname */
+ "#151 (unimplemented getmsg)", /* 151 = unimplemented getmsg */
+ "#152 (unimplemented putmsg)", /* 152 = unimplemented putmsg */
+ "poll", /* 153 = poll */
+ "#154 (unimplemented)", /* 154 = unimplemented */
+#ifdef NFSSERVER
+ "nfssvc", /* 155 = nfssvc */
+#else
+ "#155 (unimplemented)", /* 155 = unimplemented */
+#endif
+ "getdirentries", /* 156 = getdirentries */
+ "statfs", /* 157 = statfs */
+ "fstatfs", /* 158 = fstatfs */
+ "unmount", /* 159 = unmount */
+#ifdef NFSCLIENT
+ "async_daemon", /* 160 = async_daemon */
+ "getfh", /* 161 = getfh */
+#else
+ "#160 (unimplemented)", /* 160 = unimplemented */
+ "#161 (unimplemented)", /* 161 = unimplemented */
+#endif
+ "getdomainname", /* 162 = getdomainname */
+ "setdomainname", /* 163 = setdomainname */
+ "#164 (unimplemented rtschedule)", /* 164 = unimplemented rtschedule */
+ "quotactl", /* 165 = quotactl */
+ "exportfs", /* 166 = exportfs */
+ "mount", /* 167 = mount */
+ "ustat", /* 168 = ustat */
+#ifdef SYSVSEM
+ "semsys", /* 169 = semsys */
+#else
+ "#169 (unimplemented semsys)", /* 169 = unimplemented semsys */
+#endif
+#ifdef SYSVMSG
+ "msgsys", /* 170 = msgsys */
+#else
+ "#170 (unimplemented msgsys)", /* 170 = unimplemented msgsys */
+#endif
+#ifdef SYSVSHM
+ "shmsys", /* 171 = shmsys */
+#else
+ "#171 (unimplemented shmsys)", /* 171 = unimplemented shmsys */
+#endif
+ "auditsys", /* 172 = auditsys */
+ "#173 (unimplemented rfssys)", /* 173 = unimplemented rfssys */
+ "getdents", /* 174 = getdents */
+ "setsid", /* 175 = setsid */
+ "fchdir", /* 176 = fchdir */
+ "fchroot", /* 177 = fchroot */
+ "#178 (unimplemented vpixsys)", /* 178 = unimplemented vpixsys */
+ "#179 (unimplemented aioread)", /* 179 = unimplemented aioread */
+ "#180 (unimplemented aiowrite)", /* 180 = unimplemented aiowrite */
+ "#181 (unimplemented aiowait)", /* 181 = unimplemented aiowait */
+ "#182 (unimplemented aiocancel)", /* 182 = unimplemented aiocancel */
+ "sigpending", /* 183 = sigpending */
+ "#184 (unimplemented)", /* 184 = unimplemented */
+ "setpgid", /* 185 = setpgid */
+ "pathconf", /* 186 = pathconf */
+ "fpathconf", /* 187 = fpathconf */
+ "sysconf", /* 188 = sysconf */
+ "uname", /* 189 = uname */
+};
diff --git a/sys/compat/sunos/sunos_sysent.c b/sys/compat/sunos/sunos_sysent.c
new file mode 100644
index 00000000000..dbd17ba4f5e
--- /dev/null
+++ b/sys/compat/sunos/sunos_sysent.c
@@ -0,0 +1,445 @@
+/*
+ * System call switch table.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.32 1995/10/07 06:27:35 mycroft Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signal.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <compat/sunos/sunos.h>
+#include <compat/sunos/sunos_syscallargs.h>
+
+#ifdef COMPAT_43
+#define compat_43(func) __CONCAT(compat_43_,func)
+#else
+#define compat_43(func) sys_nosys
+#endif
+
+#ifdef COMPAT_09
+#define compat_09(func) __CONCAT(compat_09_,func)
+#else
+#define compat_09(func) sys_nosys
+#endif
+
+#ifdef COMPAT_10
+#define compat_10(func) __CONCAT(compat_10_,func)
+#else
+#define compat_10(func) sys_nosys
+#endif
+
+#define s(type) sizeof(type)
+
+struct sysent sunos_sysent[] = {
+ { 0, 0,
+ sys_nosys }, /* 0 = syscall */
+ { 1, s(struct sys_exit_args),
+ sys_exit }, /* 1 = exit */
+ { 0, 0,
+ sys_fork }, /* 2 = fork */
+ { 3, s(struct sys_read_args),
+ sys_read }, /* 3 = read */
+ { 3, s(struct sys_write_args),
+ sys_write }, /* 4 = write */
+ { 3, s(struct sunos_sys_open_args),
+ sunos_sys_open }, /* 5 = open */
+ { 1, s(struct sys_close_args),
+ sys_close }, /* 6 = close */
+ { 4, s(struct sunos_sys_wait4_args),
+ sunos_sys_wait4 }, /* 7 = wait4 */
+ { 2, s(struct sunos_sys_creat_args),
+ sunos_sys_creat }, /* 8 = creat */
+ { 2, s(struct sys_link_args),
+ sys_link }, /* 9 = link */
+ { 1, s(struct sys_unlink_args),
+ sys_unlink }, /* 10 = unlink */
+ { 2, s(struct sunos_sys_execv_args),
+ sunos_sys_execv }, /* 11 = execv */
+ { 1, s(struct sys_chdir_args),
+ sys_chdir }, /* 12 = chdir */
+ { 0, 0,
+ sys_nosys }, /* 13 = obsolete time */
+ { 3, s(struct sunos_sys_mknod_args),
+ sunos_sys_mknod }, /* 14 = mknod */
+ { 2, s(struct sys_chmod_args),
+ sys_chmod }, /* 15 = chmod */
+ { 3, s(struct sys_chown_args),
+ sys_chown }, /* 16 = chown */
+ { 1, s(struct sys_obreak_args),
+ sys_obreak }, /* 17 = break */
+ { 0, 0,
+ sys_nosys }, /* 18 = obsolete stat */
+ { 3, s(struct compat_43_sys_lseek_args),
+ compat_43_sys_lseek }, /* 19 = lseek */
+ { 0, 0,
+ sys_getpid }, /* 20 = getpid */
+ { 0, 0,
+ sys_nosys }, /* 21 = obsolete sunos_old_mount */
+ { 0, 0,
+ sys_nosys }, /* 22 = unimplemented System V umount */
+ { 1, s(struct sys_setuid_args),
+ sys_setuid }, /* 23 = setuid */
+ { 0, 0,
+ sys_getuid }, /* 24 = getuid */
+ { 0, 0,
+ sys_nosys }, /* 25 = unimplemented sunos_stime */
+ { 5, s(struct sunos_sys_ptrace_args),
+ sunos_sys_ptrace }, /* 26 = ptrace */
+ { 0, 0,
+ sys_nosys }, /* 27 = unimplemented sunos_alarm */
+ { 0, 0,
+ sys_nosys }, /* 28 = unimplemented sunos_fstat */
+ { 0, 0,
+ sys_nosys }, /* 29 = unimplemented sunos_pause */
+ { 0, 0,
+ sys_nosys }, /* 30 = unimplemented sunos_utime */
+ { 0, 0,
+ sys_nosys }, /* 31 = unimplemented sunos_stty */
+ { 0, 0,
+ sys_nosys }, /* 32 = unimplemented sunos_gtty */
+ { 2, s(struct sunos_sys_access_args),
+ sunos_sys_access }, /* 33 = access */
+ { 0, 0,
+ sys_nosys }, /* 34 = unimplemented sunos_nice */
+ { 0, 0,
+ sys_nosys }, /* 35 = unimplemented sunos_ftime */
+ { 0, 0,
+ sys_sync }, /* 36 = sync */
+ { 2, s(struct sys_kill_args),
+ sys_kill }, /* 37 = kill */
+ { 2, s(struct sunos_sys_stat_args),
+ sunos_sys_stat }, /* 38 = stat */
+ { 0, 0,
+ sys_nosys }, /* 39 = unimplemented sunos_setpgrp */
+ { 2, s(struct sunos_sys_lstat_args),
+ sunos_sys_lstat }, /* 40 = lstat */
+ { 1, s(struct sys_dup_args),
+ sys_dup }, /* 41 = dup */
+ { 0, 0,
+ sys_pipe }, /* 42 = pipe */
+ { 0, 0,
+ sys_nosys }, /* 43 = unimplemented sunos_times */
+ { 4, s(struct sys_profil_args),
+ sys_profil }, /* 44 = profil */
+ { 0, 0,
+ sys_nosys }, /* 45 = unimplemented */
+ { 1, s(struct sys_setgid_args),
+ sys_setgid }, /* 46 = setgid */
+ { 0, 0,
+ sys_getgid }, /* 47 = getgid */
+ { 0, 0,
+ sys_nosys }, /* 48 = unimplemented sunos_ssig */
+ { 0, 0,
+ sys_nosys }, /* 49 = unimplemented reserved for USG */
+ { 0, 0,
+ sys_nosys }, /* 50 = unimplemented reserved for USG */
+ { 1, s(struct sys_acct_args),
+ sys_acct }, /* 51 = acct */
+ { 0, 0,
+ sys_nosys }, /* 52 = unimplemented */
+ { 4, s(struct sunos_sys_mctl_args),
+ sunos_sys_mctl }, /* 53 = mctl */
+ { 3, s(struct sunos_sys_ioctl_args),
+ sunos_sys_ioctl }, /* 54 = ioctl */
+ { 2, s(struct sunos_sys_reboot_args),
+ sunos_sys_reboot }, /* 55 = reboot */
+ { 0, 0,
+ sys_nosys }, /* 56 = obsolete sunos_owait3 */
+ { 2, s(struct sys_symlink_args),
+ sys_symlink }, /* 57 = symlink */
+ { 3, s(struct sys_readlink_args),
+ sys_readlink }, /* 58 = readlink */
+ { 3, s(struct sys_execve_args),
+ sys_execve }, /* 59 = execve */
+ { 1, s(struct sys_umask_args),
+ sys_umask }, /* 60 = umask */
+ { 1, s(struct sys_chroot_args),
+ sys_chroot }, /* 61 = chroot */
+ { 2, s(struct compat_43_sys_fstat_args),
+ compat_43_sys_fstat }, /* 62 = fstat */
+ { 0, 0,
+ sys_nosys }, /* 63 = unimplemented */
+ { 0, 0,
+ compat_43_sys_getpagesize }, /* 64 = getpagesize */
+ { 3, s(struct sunos_sys_omsync_args),
+ sunos_sys_omsync }, /* 65 = omsync */
+ { 0, 0,
+ sys_vfork }, /* 66 = vfork */
+ { 0, 0,
+ sys_nosys }, /* 67 = obsolete vread */
+ { 0, 0,
+ sys_nosys }, /* 68 = obsolete vwrite */
+ { 1, s(struct sys_sbrk_args),
+ sys_sbrk }, /* 69 = sbrk */
+ { 1, s(struct sys_sstk_args),
+ sys_sstk }, /* 70 = sstk */
+ { 6, s(struct sunos_sys_mmap_args),
+ sunos_sys_mmap }, /* 71 = mmap */
+ { 1, s(struct sys_ovadvise_args),
+ sys_ovadvise }, /* 72 = vadvise */
+ { 2, s(struct sys_munmap_args),
+ sys_munmap }, /* 73 = munmap */
+ { 3, s(struct sys_mprotect_args),
+ sys_mprotect }, /* 74 = mprotect */
+ { 3, s(struct sys_madvise_args),
+ sys_madvise }, /* 75 = madvise */
+ { 0, 0,
+ sunos_sys_vhangup }, /* 76 = vhangup */
+ { 0, 0,
+ sys_nosys }, /* 77 = unimplemented vlimit */
+ { 3, s(struct sys_mincore_args),
+ sys_mincore }, /* 78 = mincore */
+ { 2, s(struct sys_getgroups_args),
+ sys_getgroups }, /* 79 = getgroups */
+ { 2, s(struct sys_setgroups_args),
+ sys_setgroups }, /* 80 = setgroups */
+ { 0, 0,
+ sys_getpgrp }, /* 81 = getpgrp */
+ { 2, s(struct sunos_sys_setpgrp_args),
+ sunos_sys_setpgrp }, /* 82 = setpgrp */
+ { 3, s(struct sys_setitimer_args),
+ sys_setitimer }, /* 83 = setitimer */
+ { 0, 0,
+ sys_nosys }, /* 84 = unimplemented { int sunos_sys_wait ( void ) ; } */
+ { 1, s(struct sys_swapon_args),
+ sys_swapon }, /* 85 = swapon */
+ { 2, s(struct sys_getitimer_args),
+ sys_getitimer }, /* 86 = getitimer */
+ { 2, s(struct compat_43_sys_gethostname_args),
+ compat_43_sys_gethostname }, /* 87 = gethostname */
+ { 2, s(struct compat_43_sys_sethostname_args),
+ compat_43_sys_sethostname }, /* 88 = sethostname */
+ { 0, 0,
+ compat_43_sys_getdtablesize }, /* 89 = getdtablesize */
+ { 2, s(struct sys_dup2_args),
+ sys_dup2 }, /* 90 = dup2 */
+ { 0, 0,
+ sys_nosys }, /* 91 = unimplemented getdopt */
+ { 3, s(struct sys_fcntl_args),
+ sys_fcntl }, /* 92 = fcntl */
+ { 5, s(struct sys_select_args),
+ sys_select }, /* 93 = select */
+ { 0, 0,
+ sys_nosys }, /* 94 = unimplemented setdopt */
+ { 1, s(struct sys_fsync_args),
+ sys_fsync }, /* 95 = fsync */
+ { 3, s(struct sys_setpriority_args),
+ sys_setpriority }, /* 96 = setpriority */
+ { 3, s(struct sys_socket_args),
+ sys_socket }, /* 97 = socket */
+ { 3, s(struct sys_connect_args),
+ sys_connect }, /* 98 = connect */
+ { 3, s(struct compat_43_sys_accept_args),
+ compat_43_sys_accept }, /* 99 = accept */
+ { 2, s(struct sys_getpriority_args),
+ sys_getpriority }, /* 100 = getpriority */
+ { 4, s(struct compat_43_sys_send_args),
+ compat_43_sys_send }, /* 101 = send */
+ { 4, s(struct compat_43_sys_recv_args),
+ compat_43_sys_recv }, /* 102 = recv */
+ { 0, 0,
+ sys_nosys }, /* 103 = unimplemented old socketaddr */
+ { 3, s(struct sys_bind_args),
+ sys_bind }, /* 104 = bind */
+ { 5, s(struct sunos_sys_setsockopt_args),
+ sunos_sys_setsockopt }, /* 105 = setsockopt */
+ { 2, s(struct sys_listen_args),
+ sys_listen }, /* 106 = listen */
+ { 0, 0,
+ sys_nosys }, /* 107 = unimplemented vtimes */
+ { 3, s(struct sunos_sys_sigvec_args),
+ sunos_sys_sigvec }, /* 108 = sigvec */
+ { 1, s(struct compat_43_sys_sigblock_args),
+ compat_43_sys_sigblock }, /* 109 = sigblock */
+ { 1, s(struct compat_43_sys_sigsetmask_args),
+ compat_43_sys_sigsetmask }, /* 110 = sigsetmask */
+ { 1, s(struct sys_sigsuspend_args),
+ sys_sigsuspend }, /* 111 = sigsuspend */
+ { 2, s(struct compat_43_sys_sigstack_args),
+ compat_43_sys_sigstack }, /* 112 = sigstack */
+ { 3, s(struct compat_43_sys_recvmsg_args),
+ compat_43_sys_recvmsg }, /* 113 = recvmsg */
+ { 3, s(struct compat_43_sys_sendmsg_args),
+ compat_43_sys_sendmsg }, /* 114 = sendmsg */
+ { 0, 0,
+ sys_nosys }, /* 115 = obsolete vtrace */
+ { 2, s(struct sys_gettimeofday_args),
+ sys_gettimeofday }, /* 116 = gettimeofday */
+ { 2, s(struct sys_getrusage_args),
+ sys_getrusage }, /* 117 = getrusage */
+ { 5, s(struct sys_getsockopt_args),
+ sys_getsockopt }, /* 118 = getsockopt */
+ { 0, 0,
+ sys_nosys }, /* 119 = unimplemented */
+ { 3, s(struct sys_readv_args),
+ sys_readv }, /* 120 = readv */
+ { 3, s(struct sys_writev_args),
+ sys_writev }, /* 121 = writev */
+ { 2, s(struct sys_settimeofday_args),
+ sys_settimeofday }, /* 122 = settimeofday */
+ { 3, s(struct sys_fchown_args),
+ sys_fchown }, /* 123 = fchown */
+ { 2, s(struct sys_fchmod_args),
+ sys_fchmod }, /* 124 = fchmod */
+ { 6, s(struct compat_43_sys_recvfrom_args),
+ compat_43_sys_recvfrom }, /* 125 = recvfrom */
+ { 2, s(struct compat_43_sys_setreuid_args),
+ compat_43_sys_setreuid }, /* 126 = setreuid */
+ { 2, s(struct compat_43_sys_setregid_args),
+ compat_43_sys_setregid }, /* 127 = setregid */
+ { 2, s(struct sys_rename_args),
+ sys_rename }, /* 128 = rename */
+ { 2, s(struct compat_43_sys_truncate_args),
+ compat_43_sys_truncate }, /* 129 = truncate */
+ { 2, s(struct compat_43_sys_ftruncate_args),
+ compat_43_sys_ftruncate }, /* 130 = ftruncate */
+ { 2, s(struct sys_flock_args),
+ sys_flock }, /* 131 = flock */
+ { 0, 0,
+ sys_nosys }, /* 132 = unimplemented */
+ { 6, s(struct sys_sendto_args),
+ sys_sendto }, /* 133 = sendto */
+ { 2, s(struct sys_shutdown_args),
+ sys_shutdown }, /* 134 = shutdown */
+ { 4, s(struct sys_socketpair_args),
+ sys_socketpair }, /* 135 = socketpair */
+ { 2, s(struct sys_mkdir_args),
+ sys_mkdir }, /* 136 = mkdir */
+ { 1, s(struct sys_rmdir_args),
+ sys_rmdir }, /* 137 = rmdir */
+ { 2, s(struct sys_utimes_args),
+ sys_utimes }, /* 138 = utimes */
+ { 1, s(struct sunos_sys_sigreturn_args),
+ sunos_sys_sigreturn }, /* 139 = sigreturn */
+ { 2, s(struct sys_adjtime_args),
+ sys_adjtime }, /* 140 = adjtime */
+ { 3, s(struct compat_43_sys_getpeername_args),
+ compat_43_sys_getpeername }, /* 141 = getpeername */
+ { 0, 0,
+ compat_43_sys_gethostid }, /* 142 = gethostid */
+ { 0, 0,
+ sys_nosys }, /* 143 = unimplemented old sethostid */
+ { 2, s(struct sunos_sys_getrlimit_args),
+ sunos_sys_getrlimit }, /* 144 = getrlimit */
+ { 2, s(struct sunos_sys_setrlimit_args),
+ sunos_sys_setrlimit }, /* 145 = setrlimit */
+ { 2, s(struct compat_43_sys_killpg_args),
+ compat_43_sys_killpg }, /* 146 = killpg */
+ { 0, 0,
+ sys_nosys }, /* 147 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 148 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 149 = unimplemented */
+ { 3, s(struct compat_43_sys_getsockname_args),
+ compat_43_sys_getsockname }, /* 150 = getsockname */
+ { 0, 0,
+ sys_nosys }, /* 151 = unimplemented getmsg */
+ { 0, 0,
+ sys_nosys }, /* 152 = unimplemented putmsg */
+ { 3, s(struct sunos_sys_poll_args),
+ sunos_sys_poll }, /* 153 = poll */
+ { 0, 0,
+ sys_nosys }, /* 154 = unimplemented */
+#ifdef NFSSERVER
+ { 1, s(struct sunos_sys_nfssvc_args),
+ sunos_sys_nfssvc }, /* 155 = nfssvc */
+#else
+ { 0, 0,
+ sys_nosys }, /* 155 = unimplemented */
+#endif
+ { 4, s(struct sys_getdirentries_args),
+ sys_getdirentries }, /* 156 = getdirentries */
+ { 2, s(struct sunos_sys_statfs_args),
+ sunos_sys_statfs }, /* 157 = statfs */
+ { 2, s(struct sunos_sys_fstatfs_args),
+ sunos_sys_fstatfs }, /* 158 = fstatfs */
+ { 1, s(struct sunos_sys_unmount_args),
+ sunos_sys_unmount }, /* 159 = unmount */
+#ifdef NFSCLIENT
+ { 0, 0,
+ async_daemon }, /* 160 = async_daemon */
+ { 2, s(struct sys_getfh_args),
+ sys_getfh }, /* 161 = getfh */
+#else
+ { 0, 0,
+ sys_nosys }, /* 160 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 161 = unimplemented */
+#endif
+ { 2, s(struct compat_09_sys_getdomainname_args),
+ compat_09_sys_getdomainname }, /* 162 = getdomainname */
+ { 2, s(struct compat_09_sys_setdomainname_args),
+ compat_09_sys_setdomainname }, /* 163 = setdomainname */
+ { 0, 0,
+ sys_nosys }, /* 164 = unimplemented rtschedule */
+ { 4, s(struct sunos_sys_quotactl_args),
+ sunos_sys_quotactl }, /* 165 = quotactl */
+ { 2, s(struct sunos_sys_exportfs_args),
+ sunos_sys_exportfs }, /* 166 = exportfs */
+ { 4, s(struct sunos_sys_mount_args),
+ sunos_sys_mount }, /* 167 = mount */
+ { 2, s(struct sunos_sys_ustat_args),
+ sunos_sys_ustat }, /* 168 = ustat */
+#ifdef SYSVSEM
+ { 5, s(struct compat_10_sys_semsys_args),
+ compat_10_sys_semsys }, /* 169 = semsys */
+#else
+ { 0, 0,
+ sys_nosys }, /* 169 = unimplemented semsys */
+#endif
+#ifdef SYSVMSG
+ { 6, s(struct compat_10_sys_msgsys_args),
+ compat_10_sys_msgsys }, /* 170 = msgsys */
+#else
+ { 0, 0,
+ sys_nosys }, /* 170 = unimplemented msgsys */
+#endif
+#ifdef SYSVSHM
+ { 4, s(struct compat_10_sys_shmsys_args),
+ compat_10_sys_shmsys }, /* 171 = shmsys */
+#else
+ { 0, 0,
+ sys_nosys }, /* 171 = unimplemented shmsys */
+#endif
+ { 1, s(struct sunos_sys_auditsys_args),
+ sunos_sys_auditsys }, /* 172 = auditsys */
+ { 0, 0,
+ sys_nosys }, /* 173 = unimplemented rfssys */
+ { 3, s(struct sunos_sys_getdents_args),
+ sunos_sys_getdents }, /* 174 = getdents */
+ { 0, 0,
+ sys_setsid }, /* 175 = setsid */
+ { 1, s(struct sys_fchdir_args),
+ sys_fchdir }, /* 176 = fchdir */
+ { 1, s(struct sunos_sys_fchroot_args),
+ sunos_sys_fchroot }, /* 177 = fchroot */
+ { 0, 0,
+ sys_nosys }, /* 178 = unimplemented vpixsys */
+ { 0, 0,
+ sys_nosys }, /* 179 = unimplemented aioread */
+ { 0, 0,
+ sys_nosys }, /* 180 = unimplemented aiowrite */
+ { 0, 0,
+ sys_nosys }, /* 181 = unimplemented aiowait */
+ { 0, 0,
+ sys_nosys }, /* 182 = unimplemented aiocancel */
+ { 1, s(struct sunos_sys_sigpending_args),
+ sunos_sys_sigpending }, /* 183 = sigpending */
+ { 0, 0,
+ sys_nosys }, /* 184 = unimplemented */
+ { 2, s(struct sys_setpgid_args),
+ sys_setpgid }, /* 185 = setpgid */
+ { 2, s(struct sys_pathconf_args),
+ sys_pathconf }, /* 186 = pathconf */
+ { 2, s(struct sys_fpathconf_args),
+ sys_fpathconf }, /* 187 = fpathconf */
+ { 1, s(struct sunos_sys_sysconf_args),
+ sunos_sys_sysconf }, /* 188 = sysconf */
+ { 1, s(struct sunos_sys_uname_args),
+ sunos_sys_uname }, /* 189 = uname */
+};
+
diff --git a/sys/compat/sunos/sunos_util.h b/sys/compat/sunos/sunos_util.h
new file mode 100644
index 00000000000..3443059a325
--- /dev/null
+++ b/sys/compat/sunos/sunos_util.h
@@ -0,0 +1,41 @@
+/* $NetBSD: sunos_util.h,v 1.2 1995/06/24 20:22:58 christos Exp $ */
+
+/*
+ * Copyright (c) 1994 Christos Zoulas
+ * Copyright (c) 1995 Matthew 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.
+ * 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.
+ */
+
+#ifndef _SUNOS_UTIL_H_
+#define _SUNOS_UTIL_H_
+
+#include <compat/common/compat_util.h>
+
+extern const char sunos_emul_path[];
+
+#define SUNOS_CHECK_ALT_EXIST(p, sgp, path) \
+ CHECK_ALT_EXIST(p, sgp, sunos_emul_path, path)
+
+#endif /* !_SUNOS_UTIL_H_ */
diff --git a/sys/compat/sunos/syscalls.conf b/sys/compat/sunos/syscalls.conf
new file mode 100644
index 00000000000..c55e7cdecf5
--- /dev/null
+++ b/sys/compat/sunos/syscalls.conf
@@ -0,0 +1,12 @@
+# $NetBSD: syscalls.conf,v 1.3 1995/04/27 12:05:43 christos Exp $
+
+sysnames="sunos_syscalls.c"
+sysnumhdr="sunos_syscall.h"
+syssw="sunos_sysent.c"
+sysarghdr="sunos_syscallargs.h"
+compatopts="compat_43 compat_09 compat_10"
+libcompatopts=""
+
+switchname="sunos_sysent"
+namesname="sunos_syscallnames"
+constprefix="SUNOS_SYS_"
diff --git a/sys/compat/sunos/syscalls.master b/sys/compat/sunos/syscalls.master
new file mode 100644
index 00000000000..6a6f00f3dbd
--- /dev/null
+++ b/sys/compat/sunos/syscalls.master
@@ -0,0 +1,303 @@
+ $NetBSD: syscalls.master,v 1.32 1995/10/07 06:27:35 mycroft Exp $
+
+; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
+
+; NetBSD COMPAT_SUNOS 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
+;
+; 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 <compat/sunos/sunos.h>
+#include <compat/sunos/sunos_syscallargs.h>
+
+0 NOARGS { int sys_nosys(void); } syscall
+1 NOARGS { int sys_exit(int rval); }
+2 NOARGS { int sys_fork(void); }
+3 NOARGS { int sys_read(int fd, char *buf, u_int nbyte); }
+4 NOARGS { int sys_write(int fd, char *buf, u_int nbyte); }
+5 STD { int sunos_sys_open(char *path, int flags, int mode); }
+6 NOARGS { int sys_close(int fd); }
+7 STD { int sunos_sys_wait4(int pid, int *status, \
+ int options, struct rusage *rusage); }
+8 STD { int sunos_sys_creat(char *path, int mode); }
+9 NOARGS { int sys_link(char *path, char *link); }
+10 NOARGS { int sys_unlink(char *path); }
+11 STD { int sunos_sys_execv(char *path, char **argp); }
+12 NOARGS { int sys_chdir(char *path); }
+13 OBSOL time
+14 STD { int sunos_sys_mknod(char *path, int mode, int dev); }
+15 NOARGS { int sys_chmod(char *path, int mode); }
+16 NOARGS { int sys_chown(char *path, int uid, int gid); }
+17 NOARGS { int sys_obreak(char *nsize); } break
+18 OBSOL stat
+19 NOARGS { long compat_43_sys_lseek(int fd, long offset, int whence); }
+20 NOARGS { pid_t sys_getpid(void); }
+21 OBSOL sunos_old_mount
+22 UNIMPL System V umount
+23 NOARGS { int sys_setuid(uid_t uid); }
+24 NOARGS { uid_t sys_getuid(void); }
+25 UNIMPL sunos_stime
+26 STD { long sunos_sys_ptrace(int req, pid_t pid, \
+ caddr_t addr, int data, char *addr2); }
+27 UNIMPL sunos_alarm
+28 UNIMPL sunos_fstat
+29 UNIMPL sunos_pause
+30 UNIMPL sunos_utime
+31 UNIMPL sunos_stty
+32 UNIMPL sunos_gtty
+33 STD { int sunos_sys_access(char *path, int flags); }
+34 UNIMPL sunos_nice
+35 UNIMPL sunos_ftime
+36 NOARGS { int sys_sync(void); }
+37 NOARGS { int sys_kill(int pid, int signum); }
+38 STD { int sunos_sys_stat(char *path, struct ostat *ub); }
+39 UNIMPL sunos_setpgrp
+40 STD { int sunos_sys_lstat(char *path, struct ostat *ub); }
+41 NOARGS { int sys_dup(u_int fd); }
+42 NOARGS { int sys_pipe(void); }
+43 UNIMPL sunos_times
+44 NOARGS { int sys_profil(caddr_t samples, u_int size, \
+ u_int offset, u_int scale); }
+45 UNIMPL
+46 NOARGS { int sys_setgid(uid_t gid); }
+47 NOARGS { gid_t sys_getgid(void); }
+48 UNIMPL sunos_ssig
+49 UNIMPL reserved for USG
+50 UNIMPL reserved for USG
+51 NOARGS { int sys_acct(char *path); }
+52 UNIMPL
+53 STD { int sunos_sys_mctl(caddr_t addr, int len, int func, \
+ void *arg); }
+54 STD { int sunos_sys_ioctl(int fd, u_long com, \
+ caddr_t data); }
+55 STD { int sunos_sys_reboot(int howto, char *bootstr); }
+56 OBSOL sunos_owait3
+57 NOARGS { int sys_symlink(char *path, char *link); }
+58 NOARGS { int sys_readlink(char *path, char *buf, int count); }
+59 NOARGS { int sys_execve(char *path, char **argp, \
+ char **envp); }
+60 NOARGS { int sys_umask(int newmask); }
+61 NOARGS { int sys_chroot(char *path); }
+62 NOARGS { int compat_43_sys_fstat(int fd, struct ostat *sb); }
+63 UNIMPL
+64 NOARGS { int compat_43_sys_getpagesize(void); }
+65 STD { int sunos_sys_omsync(caddr_t addr, size_t len, \
+ int flags); }
+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 STD { int sunos_sys_mmap(caddr_t addr, size_t len, \
+ int prot, int flags, int fd, long pos); }
+72 NOARGS { int sys_ovadvise(int anom); } vadvise
+73 NOARGS { int sys_munmap(caddr_t addr, size_t len); }
+74 NOARGS { int sys_mprotect(caddr_t addr, size_t len, \
+ int prot); }
+75 NOARGS { int sys_madvise(caddr_t addr, size_t len, \
+ int behav); }
+76 STD { int sunos_sys_vhangup(void); }
+77 UNIMPL vlimit
+78 NOARGS { int sys_mincore(caddr_t addr, size_t len, \
+ char *vec); }
+79 NOARGS { int sys_getgroups(u_int gidsetsize, gid_t *gidset); }
+80 NOARGS { int sys_setgroups(u_int gidsetsize, gid_t *gidset); }
+81 NOARGS { int sys_getpgrp(void); }
+82 STD { int sunos_sys_setpgrp(int pid, int pgid); }
+83 NOARGS { int sys_setitimer(u_int which, \
+ struct itimerval *itv, struct itimerval *oitv); }
+84 UNIMPL { int sunos_sys_wait(void); }
+85 NOARGS { int sys_swapon(char *name); }
+86 NOARGS { int sys_getitimer(u_int which, \
+ struct itimerval *itv); }
+87 NOARGS { int compat_43_sys_gethostname(char *hostname, \
+ u_int len); }
+88 NOARGS { int compat_43_sys_sethostname(char *hostname, \
+ u_int len); }
+89 NOARGS { int compat_43_sys_getdtablesize(void); }
+90 NOARGS { int sys_dup2(u_int from, u_int to); }
+91 UNIMPL getdopt
+92 NOARGS { int sys_fcntl(int fd, int cmd, void *arg); }
+93 NOARGS { int sys_select(u_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, caddr_t name, int namelen); }
+99 NOARGS { int compat_43_sys_accept(int s, caddr_t name, \
+ int *anamelen); }
+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); }
+102 NOARGS { int compat_43_sys_recv(int s, caddr_t buf, int len, \
+ int flags); }
+103 UNIMPL old socketaddr
+104 NOARGS { int sys_bind(int s, caddr_t name, int namelen); }
+105 STD { int sunos_sys_setsockopt(int s, int level, int name, \
+ caddr_t val, int valsize); }
+106 NOARGS { int sys_listen(int s, int backlog); }
+107 UNIMPL vtimes
+108 STD { int sunos_sys_sigvec(int signum, struct sigvec *nsv, \
+ struct sigvec *osv); }
+109 NOARGS { int compat_43_sys_sigblock(int mask); }
+110 NOARGS { int compat_43_sys_sigsetmask(int mask); }
+111 NOARGS { int sys_sigsuspend(int mask); }
+112 NOARGS { int compat_43_sys_sigstack(struct sigstack *nss, \
+ struct sigstack *oss); }
+113 NOARGS { int compat_43_sys_recvmsg(int s, \
+ struct omsghdr *msg, int flags); }
+114 NOARGS { int compat_43_sys_sendmsg(int s, caddr_t msg, \
+ int flags); }
+115 OBSOL vtrace
+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, \
+ caddr_t val, int *avalsize); }
+119 UNIMPL
+120 NOARGS { int sys_readv(int fd, struct iovec *iovp, \
+ u_int iovcnt); }
+121 NOARGS { int sys_writev(int fd, struct iovec *iovp, \
+ u_int iovcnt); }
+122 NOARGS { int sys_settimeofday(struct timeval *tv, \
+ struct timezone *tzp); }
+123 NOARGS { int sys_fchown(int fd, int uid, int 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); }
+126 NOARGS { int compat_43_sys_setreuid(int ruid, int euid); }
+127 NOARGS { int compat_43_sys_setregid(int rgid, int egid); }
+128 NOARGS { int sys_rename(char *from, char *to); }
+129 NOARGS { int compat_43_sys_truncate(char *path, long length); }
+130 NOARGS { int compat_43_sys_ftruncate(int fd, long length); }
+131 NOARGS { int sys_flock(int fd, int how); }
+132 UNIMPL
+133 NOARGS { int sys_sendto(int s, caddr_t buf, size_t len, \
+ int flags, caddr_t to, int 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(char *path, int mode); }
+137 NOARGS { int sys_rmdir(char *path); }
+138 NOARGS { int sys_utimes(char *path, struct timeval *tptr); }
+139 STD { int sunos_sys_sigreturn(struct sigcontext *sigcntxp); }
+140 NOARGS { int sys_adjtime(struct timeval *delta, \
+ struct timeval *olddelta); }
+141 NOARGS { int compat_43_sys_getpeername(int fdes, caddr_t asa, \
+ int *alen); }
+142 NOARGS { int compat_43_sys_gethostid(void); }
+143 UNIMPL old sethostid
+144 STD { int sunos_sys_getrlimit(u_int which, \
+ struct orlimit *rlp); }
+145 STD { int sunos_sys_setrlimit(u_int which, \
+ struct orlimit *rlp); }
+146 NOARGS { int compat_43_sys_killpg(int pgid, int signum); }
+147 UNIMPL
+148 UNIMPL
+149 UNIMPL
+150 NOARGS { int compat_43_sys_getsockname(int fdes, caddr_t asa, \
+ int *alen); }
+151 UNIMPL getmsg
+152 UNIMPL putmsg
+153 STD { int sunos_sys_poll(struct sunos_pollfd *fds, \
+ long nfds, int timeout); }
+154 UNIMPL
+#ifdef NFSSERVER
+155 STD { int sunos_sys_nfssvc(int fd); }
+#else
+155 UNIMPL
+#endif
+156 NOARGS { int sys_getdirentries(int fd, char *buf, \
+ u_int count, long *basep); }
+157 STD { int sunos_sys_statfs(char *path, \
+ struct sunos_statfs *buf); }
+158 STD { int sunos_sys_fstatfs(int fd, \
+ struct sunos_statfs *buf); }
+159 STD { int sunos_sys_unmount(char *path); }
+#ifdef NFSCLIENT
+160 NOARGS { int async_daemon(void); }
+161 NOARGS { int sys_getfh(char *fname, fhandle_t *fhp); }
+#else
+160 UNIMPL
+161 UNIMPL
+#endif
+162 NOARGS { int compat_09_sys_getdomainname(char *domainname, \
+ int len); }
+163 NOARGS { int compat_09_sys_setdomainname(char *domainname, \
+ int len); }
+164 UNIMPL rtschedule
+165 STD { int sunos_sys_quotactl(int cmd, char *special, \
+ int uid, caddr_t addr); }
+166 STD { int sunos_sys_exportfs(char *path, char *ex); }
+167 STD { int sunos_sys_mount(char *type, char *dir, \
+ int flags, caddr_t data); }
+168 STD { int sunos_sys_ustat(int dev, \
+ struct sunos_ustat *buf); }
+#ifdef SYSVSEM
+169 NOARGS { int compat_10_sys_semsys(int which, int a2, int a3, \
+ int a4, int a5); }
+#else
+169 UNIMPL semsys
+#endif
+#ifdef SYSVMSG
+170 NOARGS { int compat_10_sys_msgsys(int which, int a2, int a3, \
+ int a4, int a5, int a6); }
+#else
+170 UNIMPL msgsys
+#endif
+#ifdef SYSVSHM
+171 NOARGS { int compat_10_sys_shmsys(int which, int a2, int a3, \
+ int a4); }
+#else
+171 UNIMPL shmsys
+#endif
+172 STD { int sunos_sys_auditsys(char *record); }
+173 UNIMPL rfssys
+174 STD { int sunos_sys_getdents(int fd, char *buf, \
+ int nbytes); }
+175 NOARGS { int sys_setsid(void); }
+176 NOARGS { int sys_fchdir(int fd); }
+177 STD { int sunos_sys_fchroot(int fd); }
+178 UNIMPL vpixsys
+179 UNIMPL aioread
+180 UNIMPL aiowrite
+181 UNIMPL aiowait
+182 UNIMPL aiocancel
+183 STD { int sunos_sys_sigpending(int *mask); }
+184 UNIMPL
+185 NOARGS { int sys_setpgid(int pid, int pgid); }
+186 NOARGS { long sys_pathconf(char *path, int name); }
+187 NOARGS { long sys_fpathconf(int fd, int name); }
+188 STD { int sunos_sys_sysconf(int name); }
+189 STD { int sunos_sys_uname(struct sunos_utsname *name); }
diff --git a/sys/compat/svr4/files.svr4 b/sys/compat/svr4/files.svr4
new file mode 100644
index 00000000000..fd59078d07e
--- /dev/null
+++ b/sys/compat/svr4/files.svr4
@@ -0,0 +1,23 @@
+# $NetBSD: files.svr4,v 1.4 1995/08/14 01:34:12 mycroft Exp $
+#
+# Config.new file description for machine-independent SVR4 compat code.
+# Included by ports that need it.
+
+# ports should define any machine-specific files they need in their
+# own file lists.
+
+file compat/svr4/svr4_error.c compat_svr4
+file compat/svr4/svr4_exec.c compat_svr4
+file compat/svr4/svr4_fcntl.c compat_svr4
+file compat/svr4/svr4_filio.c compat_svr4
+file compat/svr4/svr4_ioctl.c compat_svr4
+file compat/svr4/svr4_misc.c compat_svr4
+file compat/svr4/svr4_net.c compat_svr4
+file compat/svr4/svr4_signal.c compat_svr4
+file compat/svr4/svr4_sockio.c compat_svr4
+file compat/svr4/svr4_stat.c compat_svr4
+file compat/svr4/svr4_stream.c compat_svr4
+file compat/svr4/svr4_syscalls.c compat_svr4
+file compat/svr4/svr4_sysent.c compat_svr4
+file compat/svr4/svr4_termios.c compat_svr4
+file compat/svr4/svr4_ttold.c compat_svr4
diff --git a/sys/compat/svr4/svr4_dirent.h b/sys/compat/svr4/svr4_dirent.h
new file mode 100644
index 00000000000..4197afafc5f
--- /dev/null
+++ b/sys/compat/svr4/svr4_dirent.h
@@ -0,0 +1,45 @@
+/* $NetBSD: svr4_dirent.h,v 1.4 1995/10/07 06:27:37 mycroft 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.
+ */
+
+#ifndef _SVR4_DIRENT_H_
+#define _SVR4_DIRENT_H_
+
+#define SVR4_MAXNAMLEN 512
+
+struct svr4_dirent {
+ svr4_ino_t d_ino;
+ svr4_off_t d_off;
+ u_short d_reclen;
+ char d_name[SVR4_MAXNAMLEN + 1];
+};
+
+#define SVR4_NAMEOFF(dp) ((char *)&(dp)->d_name - (char *)dp)
+#define SVR4_RECLEN(de,namlen) ALIGN((SVR4_NAMEOFF(de) + (namlen) + 1))
+
+#endif /* !_SVR4_DIRENT_H_ */
diff --git a/sys/compat/svr4/svr4_errno.h b/sys/compat/svr4/svr4_errno.h
new file mode 100644
index 00000000000..63fa48872d7
--- /dev/null
+++ b/sys/compat/svr4/svr4_errno.h
@@ -0,0 +1,171 @@
+/* $NetBSD: svr4_errno.h,v 1.2 1994/11/18 02:53:37 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.
+ */
+
+#ifndef _SVR4_ERRNO_H_
+#define _SVR4_ERRNO_H_
+
+#define SVR4_EPERM 1
+#define SVR4_ENOENT 2
+#define SVR4_ESRCH 3
+#define SVR4_EINTR 4
+#define SVR4_EIO 5
+#define SVR4_ENXIO 6
+#define SVR4_E2BIG 7
+#define SVR4_ENOEXEC 8
+#define SVR4_EBADF 9
+#define SVR4_ECHILD 10
+#define SVR4_EAGAIN 11
+#define SVR4_ENOMEM 12
+#define SVR4_EACCES 13
+#define SVR4_EFAULT 14
+#define SVR4_ENOTBLK 15
+#define SVR4_EBUSY 16
+#define SVR4_EEXIST 17
+#define SVR4_EXDEV 18
+#define SVR4_ENODEV 19
+#define SVR4_ENOTDIR 20
+#define SVR4_EISDIR 21
+#define SVR4_EINVAL 22
+#define SVR4_ENFILE 23
+#define SVR4_EMFILE 24
+#define SVR4_ENOTTY 25
+#define SVR4_ETXTBSY 26
+#define SVR4_EFBIG 27
+#define SVR4_ENOSPC 28
+#define SVR4_ESPIPE 29
+#define SVR4_EROFS 30
+#define SVR4_EMLINK 31
+#define SVR4_EPIPE 32
+#define SVR4_EDOM 33
+#define SVR4_ERANGE 34
+#define SVR4_ENOMSG 35
+#define SVR4_EIDRM 36
+#define SVR4_ECHRNG 37
+#define SVR4_EL2NSYNC 38
+#define SVR4_EL3HLT 39
+#define SVR4_EL3RST 40
+#define SVR4_ELNRNG 41
+#define SVR4_EUNATCH 42
+#define SVR4_ENOCSI 43
+#define SVR4_EL2HLT 44
+#define SVR4_EDEADLK 45
+#define SVR4_ENOLCK 46
+#define SVR4_EBADE 50
+#define SVR4_EBADR 51
+#define SVR4_EXFULL 52
+#define SVR4_ENOANO 53
+#define SVR4_EBADRQC 54
+#define SVR4_EBADSLT 55
+#define SVR4_EDEADLOCK 56
+#define SVR4_EBFONT 57
+#define SVR4_ENOSTR 60
+#define SVR4_ENODATA 61
+#define SVR4_ETIME 62
+#define SVR4_ENOSR 63
+#define SVR4_ENONET 64
+#define SVR4_ENOPKG 65
+#define SVR4_EREMOTE 66
+#define SVR4_ENOLINK 67
+#define SVR4_EADV 68
+#define SVR4_ESRMNT 69
+#define SVR4_ECOMM 70
+#define SVR4_EPROTO 71
+#define SVR4_EMULTIHOP 74
+#define SVR4_EBADMSG 77
+#define SVR4_ENAMETOOLONG 78
+#define SVR4_EOVERFLOW 79
+#define SVR4_ENOTUNIQ 80
+#define SVR4_EBADFD 81
+#define SVR4_EREMCHG 82
+#define SVR4_ELIBACC 83
+#define SVR4_ELIBBAD 84
+#define SVR4_ELIBSCN 85
+#define SVR4_ELIBMAX 86
+#define SVR4_ELIBEXEC 87
+#define SVR4_EILSEQ 88
+#define SVR4_ENOSYS 89
+#define SVR4_ELOOP 90
+#define SVR4_ERESTART 91
+#define SVR4_ESTRPIPE 92
+#define SVR4_ENOTEMPTY 93
+#define SVR4_EUSERS 94
+#define SVR4_ENOTSOCK 95
+#define SVR4_EDESTADDRREQ 96
+#define SVR4_EMSGSIZE 97
+#define SVR4_EPROTOTYPE 98
+#define SVR4_ENOPROTOOPT 99
+#define SVR4_EPROTONOSUPPORT 120
+#define SVR4_ESOCKTNOSUPPORT 121
+#define SVR4_EOPNOTSUPP 122
+#define SVR4_EPFNOSUPPORT 123
+#define SVR4_EAFNOSUPPORT 124
+#define SVR4_EADDRINUSE 125
+#define SVR4_EADDRNOTAVAIL 126
+#define SVR4_ENETDOWN 127
+#define SVR4_ENETUNREACH 128
+#define SVR4_ENETRESET 129
+#define SVR4_ECONNABORTED 130
+#define SVR4_ECONNRESET 131
+#define SVR4_ENOBUFS 132
+#define SVR4_EISCONN 133
+#define SVR4_ENOTCONN 134
+#define SVR4_EUCLEAN 135
+#define SVR4_ENOTNAM 137
+#define SVR4_ENAVAIL 138
+#define SVR4_EISNAM 139
+#define SVR4_EREMOTEIO 140
+#define SVR4_EINIT 141
+#define SVR4_EREMDEV 142
+#define SVR4_ESHUTDOWN 143
+#define SVR4_ETOOMANYREFS 144
+#define SVR4_ETIMEDOUT 145
+#define SVR4_ECONNREFUSED 146
+#define SVR4_EHOSTDOWN 147
+#define SVR4_EHOSTUNREACH 148
+#define SVR4_EWOULDBLOCK SVR4_EAGAIN
+#define SVR4_EALREADY 149
+#define SVR4_EINPROGRESS 150
+#define SVR4_ESTALE 151
+#define SVR4_EIORESID 500
+
+/*
+ * These ones are not translated...
+ */
+#define SVR4_EPROCLIM SVR4_ENOSYS
+#define SVR4_EDQUOT SVR4_ENOSYS
+#define SVR4_EBADRPC SVR4_ENOSYS
+#define SVR4_ERPCMISMATCH SVR4_ENOSYS
+#define SVR4_EPROGUNAVAIL SVR4_ENOSYS
+#define SVR4_EPROGMISMATCH SVR4_ENOSYS
+#define SVR4_EPROCUNAVAIL SVR4_ENOSYS
+#define SVR4_EFTYPE SVR4_ENOSYS
+#define SVR4_EAUTH SVR4_ENOSYS
+#define SVR4_ENEEDAUTH SVR4_ENOSYS
+
+#endif /* !_SVR4_ERRNO_H_ */
diff --git a/sys/compat/svr4/svr4_error.c b/sys/compat/svr4/svr4_error.c
new file mode 100644
index 00000000000..7f674e28284
--- /dev/null
+++ b/sys/compat/svr4/svr4_error.c
@@ -0,0 +1,120 @@
+/* $NetBSD: svr4_error.c,v 1.2 1994/11/18 02:53:41 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.
+ */
+
+/*
+ * Translate error codes.
+ */
+
+#include <compat/svr4/svr4_errno.h>
+
+
+int svr4_error[] = {
+ 0,
+ SVR4_EPERM,
+ SVR4_ENOENT,
+ SVR4_ESRCH,
+ SVR4_EINTR,
+ SVR4_EIO,
+ SVR4_ENXIO,
+ SVR4_E2BIG,
+ SVR4_ENOEXEC,
+ SVR4_EBADF,
+ SVR4_ECHILD,
+ SVR4_EDEADLK,
+ SVR4_ENOMEM,
+ SVR4_EACCES,
+ SVR4_EFAULT,
+ SVR4_ENOTBLK,
+ SVR4_EBUSY,
+ SVR4_EEXIST,
+ SVR4_EXDEV,
+ SVR4_ENODEV,
+ SVR4_ENOTDIR,
+ SVR4_EISDIR,
+ SVR4_EINVAL,
+ SVR4_ENFILE,
+ SVR4_EMFILE,
+ SVR4_ENOTTY,
+ SVR4_ETXTBSY,
+ SVR4_EFBIG,
+ SVR4_ENOSPC,
+ SVR4_ESPIPE,
+ SVR4_EROFS,
+ SVR4_EMLINK,
+ SVR4_EPIPE,
+ SVR4_EDOM,
+ SVR4_ERANGE,
+ SVR4_EAGAIN,
+ SVR4_EINPROGRESS,
+ SVR4_EALREADY,
+ SVR4_ENOTSOCK,
+ SVR4_EDESTADDRREQ,
+ SVR4_EMSGSIZE,
+ SVR4_EPROTOTYPE,
+ SVR4_ENOPROTOOPT,
+ SVR4_EPROTONOSUPPORT,
+ SVR4_ESOCKTNOSUPPORT,
+ SVR4_EOPNOTSUPP,
+ SVR4_EPFNOSUPPORT,
+ SVR4_EAFNOSUPPORT,
+ SVR4_EADDRINUSE,
+ SVR4_EADDRNOTAVAIL,
+ SVR4_ENETDOWN,
+ SVR4_ENETUNREACH,
+ SVR4_ENETRESET,
+ SVR4_ECONNABORTED,
+ SVR4_ECONNRESET,
+ SVR4_ENOBUFS,
+ SVR4_EISCONN,
+ SVR4_ENOTCONN,
+ SVR4_ESHUTDOWN,
+ SVR4_ETOOMANYREFS,
+ SVR4_ETIMEDOUT,
+ SVR4_ECONNREFUSED,
+ SVR4_ELOOP,
+ SVR4_ENAMETOOLONG,
+ SVR4_EHOSTDOWN,
+ SVR4_EHOSTUNREACH,
+ SVR4_ENOTEMPTY,
+ SVR4_EPROCLIM,
+ SVR4_EUSERS,
+ SVR4_EDQUOT,
+ SVR4_ESTALE,
+ SVR4_EREMOTE,
+ SVR4_EBADRPC,
+ SVR4_ERPCMISMATCH,
+ SVR4_EPROGUNAVAIL,
+ SVR4_EPROGMISMATCH,
+ SVR4_EPROCUNAVAIL,
+ SVR4_ENOLCK,
+ SVR4_ENOSYS,
+ SVR4_EFTYPE,
+ SVR4_EAUTH,
+ SVR4_ENEEDAUTH,
+};
diff --git a/sys/compat/svr4/svr4_exec.c b/sys/compat/svr4/svr4_exec.c
new file mode 100644
index 00000000000..9393f63736a
--- /dev/null
+++ b/sys/compat/svr4/svr4_exec.c
@@ -0,0 +1,132 @@
+/* $NetBSD: svr4_exec.c,v 1.15 1995/06/24 20:29:19 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/kernel.h>
+#include <sys/proc.h>
+#include <sys/malloc.h>
+#include <sys/namei.h>
+#include <sys/vnode.h>
+#include <sys/exec_elf.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>
+#include <machine/exec.h>
+#include <machine/svr4_machdep.h>
+
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_syscall.h>
+#include <compat/svr4/svr4_exec.h>
+
+static void *svr4_copyargs __P((struct exec_package *, struct ps_strings *,
+ void *, void *));
+
+const char svr4_emul_path[] = "/emul/svr4";
+extern int svr4_error[];
+extern char svr4_sigcode[], svr4_esigcode[];
+extern struct sysent svr4_sysent[];
+extern char *svr4_syscallnames[];
+
+struct emul emul_svr4 = {
+ "svr4",
+ svr4_error,
+ svr4_sendsig,
+ SVR4_SYS_syscall,
+ SVR4_SYS_MAXSYSCALL,
+ svr4_sysent,
+ svr4_syscallnames,
+ SVR4_AUX_ARGSIZ,
+ svr4_copyargs,
+ setregs,
+ svr4_sigcode,
+ svr4_esigcode,
+};
+
+static void *
+svr4_copyargs(pack, arginfo, stack, argp)
+ struct exec_package *pack;
+ struct ps_strings *arginfo;
+ void *stack;
+ void *argp;
+{
+ AuxInfo *a;
+ struct elf_args *ap;
+
+ if (!(a = (AuxInfo *) elf_copyargs(pack, arginfo, stack, argp)))
+ return NULL;
+#ifdef SVR4_COMPAT_SOLARIS2
+ if (pack->ep_emul_arg) {
+ a->au_id = AUX_sun_uid;
+ a->au_v = p->p_ucred->cr_uid;
+ a++;
+
+ a->au_id = AUX_sun_ruid;
+ a->au_v = p->p_cred->ruid;
+ a++;
+
+ a->au_id = AUX_sun_gid;
+ a->au_v = p->p_ucred->cr_gid;
+ a++;
+
+ a->au_id = AUX_sun_rgid;
+ a->au_v = p->p_cred->rgid;
+ a++;
+ }
+#endif
+ return a;
+}
+
+int
+svr4_elf_probe(p, epp, itp, pos)
+ struct proc *p;
+ struct exec_package *epp;
+ char *itp;
+ u_long *pos;
+{
+ char *bp;
+ int error;
+ size_t len;
+
+ if (itp[0]) {
+ if ((error = emul_find(p, NULL, svr4_emul_path, itp, &bp, 0)))
+ return error;
+ if ((error = copystr(bp, itp, MAXPATHLEN, &len)))
+ return error;
+ free(bp, M_TEMP);
+ }
+ epp->ep_emul = &emul_svr4;
+ *pos = SVR4_INTERP_ADDR;
+ return 0;
+}
diff --git a/sys/compat/svr4/svr4_exec.h b/sys/compat/svr4/svr4_exec.h
new file mode 100644
index 00000000000..747e7866b35
--- /dev/null
+++ b/sys/compat/svr4/svr4_exec.h
@@ -0,0 +1,67 @@
+/* $NetBSD: svr4_exec.h,v 1.7 1995/07/02 06:16:06 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.
+ */
+
+#ifndef _SVR4_EXEC_H_
+#define _SVR4_EXEC_H_
+
+#ifdef SVR4_COMPAT_SOLARIS2
+# define SVR4_AUX_ARGSIZ (sizeof(AuxInfo) * 12 / sizeof(char *))
+#else
+# define SVR4_AUX_ARGSIZ (sizeof(AuxInfo) * 8 / sizeof(char *))
+#endif
+
+/*
+ * The following is horrible; there must be a better way. I need to
+ * play with brk(2) a bit more.
+ */
+#ifdef i386
+/*
+ * I cannot load the interpreter after the data segment because brk(2)
+ * breaks. I have to load it somewhere before. Programs start at
+ * 0x08000000 so I load the interpreter far before.
+ */
+#define SVR4_INTERP_ADDR 0x01000000
+#endif
+
+#ifdef sparc
+/*
+ * Here programs load at 0x00010000, so I load the interpreter far after
+ * the end of the data segment.
+ */
+#define SVR4_INTERP_ADDR 0x10000000
+#endif
+
+#ifndef SVR4_INTERP_ADDR
+# define SVR4_INTERP_ADDR 0
+#endif
+
+int svr4_elf_probe __P((struct proc *p, struct exec_package *, char *,
+ u_long *pos));
+
+#endif /* !_SVR4_EXEC_H_ */
diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c
new file mode 100644
index 00000000000..a2421d32fc7
--- /dev/null
+++ b/sys/compat/svr4/svr4_fcntl.c
@@ -0,0 +1,450 @@
+/* $NetBSD: svr4_fcntl.c,v 1.13 1995/10/09 23:56:17 thorpej 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/namei.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/malloc.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_fcntl.h>
+#include <compat/svr4/svr4_poll.h>
+
+static u_long
+svr4_to_bsd_cmd(cmd)
+ u_long cmd;
+{
+
+ switch (cmd) {
+ case SVR4_F_DUPFD:
+ return F_DUPFD;
+ case SVR4_F_GETFD:
+ return F_GETFD;
+ case SVR4_F_SETFD:
+ return F_SETFD;
+ case SVR4_F_GETFL:
+ return F_GETFL;
+ case SVR4_F_SETFL:
+ return F_SETFL;
+ case SVR4_F_GETLK:
+ return F_GETLK;
+ case SVR4_F_SETLK:
+ return F_SETLK;
+ case SVR4_F_SETLKW:
+ return F_SETLKW;
+ default:
+ return -1;
+ }
+}
+
+
+static int
+svr4_to_bsd_flags(l)
+ int l;
+{
+ int r = 0;
+ r |= (l & SVR4_O_RDONLY) ? O_RDONLY : 0;
+ r |= (l & SVR4_O_WRONLY) ? O_WRONLY : 0;
+ r |= (l & SVR4_O_RDWR) ? O_RDWR : 0;
+ r |= (l & SVR4_O_NDELAY) ? O_NONBLOCK : 0;
+ r |= (l & SVR4_O_APPEND) ? O_APPEND : 0;
+ r |= (l & SVR4_O_SYNC) ? O_FSYNC : 0;
+ r |= (l & SVR4_O_RAIOSIG) ? O_ASYNC : 0;
+ r |= (l & SVR4_O_NONBLOCK) ? O_NONBLOCK : 0;
+ r |= (l & SVR4_O_PRIV) ? O_EXLOCK : 0;
+ r |= (l & SVR4_O_CREAT) ? O_CREAT : 0;
+ r |= (l & SVR4_O_TRUNC) ? O_TRUNC : 0;
+ r |= (l & SVR4_O_EXCL) ? O_EXCL : 0;
+ r |= (l & SVR4_O_NOCTTY) ? O_NOCTTY : 0;
+ return r;
+}
+
+
+static int
+bsd_to_svr4_flags(l)
+ int l;
+{
+ int r = 0;
+ r |= (l & O_RDONLY) ? SVR4_O_RDONLY : 0;
+ r |= (l & O_WRONLY) ? SVR4_O_WRONLY : 0;
+ r |= (l & O_RDWR) ? SVR4_O_RDWR : 0;
+ r |= (l & O_NDELAY) ? SVR4_O_NONBLOCK : 0;
+ r |= (l & O_APPEND) ? SVR4_O_APPEND : 0;
+ r |= (l & O_FSYNC) ? SVR4_O_SYNC : 0;
+ r |= (l & O_ASYNC) ? SVR4_O_RAIOSIG : 0;
+ r |= (l & O_NONBLOCK) ? SVR4_O_NONBLOCK : 0;
+ r |= (l & O_EXLOCK) ? SVR4_O_PRIV : 0;
+ r |= (l & O_CREAT) ? SVR4_O_CREAT : 0;
+ r |= (l & O_TRUNC) ? SVR4_O_TRUNC : 0;
+ r |= (l & O_EXCL) ? SVR4_O_EXCL : 0;
+ r |= (l & O_NOCTTY) ? SVR4_O_NOCTTY : 0;
+ return r;
+}
+
+static void
+bsd_to_svr4_flock(iflp, oflp)
+ struct flock *iflp;
+ struct svr4_flock *oflp;
+{
+ switch (iflp->l_type) {
+ case F_RDLCK:
+ oflp->l_type = SVR4_F_RDLCK;
+ break;
+ case F_WRLCK:
+ oflp->l_type = SVR4_F_WRLCK;
+ break;
+ case F_UNLCK:
+ oflp->l_type = SVR4_F_UNLCK;
+ break;
+ default:
+ oflp->l_type = -1;
+ break;
+ }
+
+ oflp->l_whence = (short) iflp->l_whence;
+ oflp->l_start = (svr4_off_t) iflp->l_start;
+ oflp->l_len = (svr4_off_t) iflp->l_len;
+ oflp->l_sysid = 0;
+ oflp->l_pid = (svr4_pid_t) iflp->l_pid;
+}
+
+
+static void
+svr4_to_bsd_flock(iflp, oflp)
+ struct svr4_flock *iflp;
+ struct flock *oflp;
+{
+ switch (iflp->l_type) {
+ case SVR4_F_RDLCK:
+ oflp->l_type = F_RDLCK;
+ break;
+ case SVR4_F_WRLCK:
+ oflp->l_type = F_WRLCK;
+ break;
+ case SVR4_F_UNLCK:
+ oflp->l_type = F_UNLCK;
+ break;
+ default:
+ oflp->l_type = -1;
+ break;
+ }
+
+ oflp->l_whence = iflp->l_whence;
+ oflp->l_start = (off_t) iflp->l_start;
+ oflp->l_len = (off_t) iflp->l_len;
+ oflp->l_pid = (pid_t) iflp->l_pid;
+
+}
+
+int
+svr4_sys_open(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_open_args *uap = v;
+ int error;
+ struct sys_open_args cup;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, flags) = svr4_to_bsd_flags(SCARG(uap, flags));
+ SCARG(&cup, mode) = SCARG(uap, mode);
+ error = sys_open(p, &cup, retval);
+
+ if (error)
+ return error;
+
+ if ((SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(p) &&
+ !(p->p_flag & P_CONTROLT)) {
+ struct filedesc *fdp = p->p_fd;
+ struct file *fp = fdp->fd_ofiles[*retval];
+
+ /* ignore any error, just give it a try */
+ if (fp->f_type == DTYPE_VNODE)
+ (fp->f_ops->fo_ioctl) (fp, TIOCSCTTY, (caddr_t) 0, p);
+ }
+ return 0;
+}
+
+
+int
+svr4_sys_creat(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_creat_args *uap = v;
+ struct sys_open_args cup;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, mode) = SCARG(uap, mode);
+ SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC;
+
+ return sys_open(p, &cup, retval);
+}
+
+
+int
+svr4_sys_access(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_access_args *uap = v;
+ struct sys_access_args cup;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, flags) = SCARG(uap, flags);
+
+ return sys_access(p, &cup, retval);
+}
+
+
+int
+svr4_sys_fcntl(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_fcntl_args *uap = v;
+ int error;
+ struct sys_fcntl_args fa;
+
+ SCARG(&fa, fd) = SCARG(uap, fd);
+ SCARG(&fa, cmd) = svr4_to_bsd_cmd(SCARG(uap, cmd));
+
+ switch (SCARG(&fa, cmd)) {
+ case F_DUPFD:
+ case F_GETFD:
+ case F_SETFD:
+ SCARG(&fa, arg) = SCARG(uap, arg);
+ return sys_fcntl(p, &fa, retval);
+
+ case F_GETFL:
+ SCARG(&fa, arg) = SCARG(uap, arg);
+ error = sys_fcntl(p, &fa, retval);
+ if (error)
+ return error;
+ *retval = bsd_to_svr4_flags(*retval);
+ return error;
+
+ case F_SETFL:
+ SCARG(&fa, arg) = (void *) svr4_to_bsd_flags(SCARG(uap, arg));
+ return sys_fcntl(p, &fa, retval);
+
+ case F_GETLK:
+ case F_SETLK:
+ case F_SETLKW:
+ {
+ struct svr4_flock ifl;
+ struct flock *flp, fl;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ flp = stackgap_alloc(&sg, sizeof(struct flock));
+ SCARG(&fa, arg) = (void *) flp;
+
+ error = copyin(SCARG(uap, arg), &ifl, sizeof ifl);
+ if (error)
+ return error;
+
+ svr4_to_bsd_flock(&ifl, &fl);
+
+ error = copyout(&fl, flp, sizeof fl);
+ if (error)
+ return error;
+
+ error = sys_fcntl(p, &fa, retval);
+ if (error || SCARG(&fa, cmd) != F_GETLK)
+ return error;
+
+ error = copyin(flp, &fl, sizeof fl);
+ if (error)
+ return error;
+
+ bsd_to_svr4_flock(&fl, &ifl);
+
+ return copyout(&ifl, SCARG(uap, arg), sizeof ifl);
+ }
+ default:
+ return ENOSYS;
+ }
+}
+
+
+static void
+svr4_pollscan(p, pl, nfd, retval)
+ struct proc *p;
+ struct svr4_pollfd *pl;
+ int nfd;
+ register_t *retval;
+{
+ register struct filedesc *fdp = p->p_fd;
+ register int msk, i;
+ struct file *fp;
+ int n = 0;
+ static int flag[3] = { FREAD, FWRITE, 0 };
+ static int pflag[3] = { SVR4_POLLIN|SVR4_POLLRDNORM,
+ SVR4_POLLOUT, SVR4_POLLERR };
+
+ /*
+ * XXX: We need to implement the rest of the flags.
+ */
+ for (i = 0; i < nfd; i++) {
+ fp = fdp->fd_ofiles[pl[i].fd];
+ if (fp == NULL) {
+ if (pl[i].events & SVR4_POLLNVAL) {
+ pl[i].revents |= SVR4_POLLNVAL;
+ n++;
+ }
+ continue;
+ }
+ for (msk = 0; msk < 3; msk++) {
+ if (pl[i].events & pflag[msk]) {
+ if ((*fp->f_ops->fo_select)(fp, flag[msk], p)) {
+ pl[i].revents |=
+ pflag[msk] & pl[i].events;
+ n++;
+ }
+ }
+ }
+ }
+ *retval = n;
+}
+
+
+/*
+ * We are using the same mechanism as select only we encode/decode args
+ * differently.
+ */
+int
+svr4_sys_poll(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_poll_args *uap = v;
+ int i, s;
+ int error, error2;
+ size_t sz = sizeof(struct svr4_pollfd) * SCARG(uap, nfds);
+ struct svr4_pollfd *pl;
+ int msec = SCARG(uap, timeout);
+ struct timeval atv;
+ int timo;
+ u_int ni;
+ int ncoll;
+ extern int nselcoll, selwait;
+
+ pl = (struct svr4_pollfd *) malloc(sz, M_TEMP, M_WAITOK);
+
+ if (error = copyin(SCARG(uap, fds), pl, sz))
+ goto bad;
+
+ for (i = 0; i < SCARG(uap, nfds); i++) {
+ DPRINTF(("pollfd %d, %x\n", pl[i].fd, pl[i].events));
+ pl[i].revents = 0;
+ }
+
+ if (msec != -1) {
+ atv.tv_sec = msec / 1000;
+ atv.tv_usec = (msec - (atv.tv_sec * 1000)) * 1000;
+
+ if (itimerfix(&atv)) {
+ error = EINVAL;
+ goto done;
+ }
+ s = splclock();
+ timeradd(&atv, &time, &atv);
+ timo = hzto(&atv);
+ /*
+ * Avoid inadvertently sleeping forever.
+ */
+ if (timo == 0)
+ timo = 1;
+ splx(s);
+ } else
+ timo = 0;
+
+retry:
+ ncoll = nselcoll;
+ p->p_flag |= P_SELECT;
+ svr4_pollscan(p, pl, SCARG(uap, nfds), retval);
+ if (*retval)
+ goto done;
+ s = splhigh();
+ if (timo && timercmp(&time, &atv, >=)) {
+ splx(s);
+ goto done;
+ }
+ if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) {
+ splx(s);
+ goto retry;
+ }
+ p->p_flag &= ~P_SELECT;
+ error = tsleep((caddr_t)&selwait, PSOCK | PCATCH, "svr4_poll", timo);
+ splx(s);
+ if (error == 0)
+ goto retry;
+
+done:
+ p->p_flag &= ~P_SELECT;
+ /* poll is not restarted after signals... */
+ if (error == ERESTART)
+ error = EINTR;
+ if (error == EWOULDBLOCK)
+ error = 0;
+
+ if (error2 = copyout(pl, SCARG(uap, fds), sz))
+ error = error2;
+
+bad:
+ free((char *) pl, M_TEMP);
+
+ return (error);
+}
diff --git a/sys/compat/svr4/svr4_fcntl.h b/sys/compat/svr4/svr4_fcntl.h
new file mode 100644
index 00000000000..3559b4a6dc3
--- /dev/null
+++ b/sys/compat/svr4/svr4_fcntl.h
@@ -0,0 +1,110 @@
+/* $NetBSD: svr4_fcntl.h,v 1.3 1994/10/29 00:43:19 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.
+ */
+
+#ifndef _SVR4_FCNTL_H_
+#define _SVR4_FCNTL_H_
+
+#include <compat/svr4/svr4_types.h>
+#include <sys/fcntl.h>
+
+#define SVR4_O_RDONLY 0x0000
+#define SVR4_O_WRONLY 0x0001
+#define SVR4_O_RDWR 0x0002
+#define SVR4_O_ACCMODE 0x0003
+#define SVR4_O_NDELAY 0x0004
+#define SVR4_O_APPEND 0x0008
+#define SVR4_O_SYNC 0x0010
+#define SVR4_O_RAIOSIG 0x0020
+#define SVR4_O_NONBLOCK 0x0080
+#define SVR4_O_CREAT 0x0100
+#define SVR4_O_TRUNC 0x0200
+#define SVR4_O_EXCL 0x0400
+#define SVR4_O_NOCTTY 0x0800
+#define SVR4_O_PRIV 0x1000
+
+
+#define SVR4_FD_CLOEXEC 1
+
+#define SVR4_F_DUPFD 0
+#define SVR4_F_GETFD 1
+#define SVR4_F_SETFD 2
+#define SVR4_F_GETFL 3
+#define SVR4_F_SETFL 4
+#define SVR4_F_GETLK_SVR3 5
+#define SVR4_F_SETLK 6
+#define SVR4_F_SETLKW 7
+#define SVR4_F_CHKFL 8
+
+#define SVR4_F_ALLOCSP 10
+#define SVR4_F_FREESP 11
+#define SVR4_F_GETLK 14
+
+#define SVR4_F_RSETLK 20
+#define SVR4_F_RGETLK 21
+#define SVR4_F_RSETLKW 22
+
+#define SVR4_F_GETOWN 23
+#define SVR4_F_SETOWN 24
+
+#define SVR4_F_CHSIZE_XENIX 0x6000
+#define SVR4_F_RDCHK_XENIX 0x6001
+#define SVR4_F_LK_UNLCK_XENIX 0x6300
+#define SVR4_F_LK_LOCK_XENIX 0x7200
+#define SVR4_F_LK_NBLCK_XENIX 0x6200
+#define SVR4_F_LK_RLCK_XENIX 0x7100
+#define SVR4_F_LK_NBRLCK_XENIX 0x6100
+
+#define SVR4_LK_CMDTYPE(x) (((x) >> 12) & 0x7)
+#define SVR4_LK_LCKTYPE(x) (((x) >> 8) & 0x7)
+
+#define SVR4_F_RDLCK 1
+#define SVR4_F_WRLCK 2
+#define SVR4_F_UNLCK 3
+
+struct svr4_flock_svr3 {
+ short l_type;
+ short l_whence;
+ svr4_off_t l_start;
+ svr4_off_t l_len;
+ short l_sysid;
+ svr4_o_pid_t l_pid;
+};
+
+
+struct svr4_flock {
+ short l_type;
+ short l_whence;
+ svr4_off_t l_start;
+ svr4_off_t l_len;
+ long l_sysid;
+ svr4_pid_t l_pid;
+ long pad[4];
+};
+
+#endif /* !_SVR4_FCNTL_H_ */
diff --git a/sys/compat/svr4/svr4_filio.c b/sys/compat/svr4/svr4_filio.c
new file mode 100644
index 00000000000..6f553986c67
--- /dev/null
+++ b/sys/compat/svr4/svr4_filio.c
@@ -0,0 +1,110 @@
+/* $NetBSD: svr4_filio.c,v 1.3 1995/10/07 06:27:40 mycroft 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/proc.h>
+#include <sys/systm.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/termios.h>
+#include <sys/tty.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <net/if.h>
+#include <sys/malloc.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_stropts.h>
+#include <compat/svr4/svr4_ioctl.h>
+#include <compat/svr4/svr4_filio.h>
+
+
+int
+svr4_filioctl(fp, cmd, data, p, retval)
+ struct file *fp;
+ u_long cmd;
+ caddr_t data;
+ struct proc *p;
+ register_t *retval;
+{
+ struct filedesc *fdp = p->p_fd;
+ int error;
+ int fd;
+ int num;
+ int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
+ fp->f_ops->fo_ioctl;
+
+ *retval = 0;
+
+ switch (cmd) {
+ case SVR4_FIOCLEX:
+ fd = fp - fdp->fd_ofiles[0];
+ fdp->fd_ofileflags[fd] |= UF_EXCLOSE;
+ return 0;
+
+ case SVR4_FIONCLEX:
+ fd = fp - fdp->fd_ofiles[0];
+ fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE;
+ return 0;
+
+ case SVR4_FIOGETOWN:
+ case SVR4_FIOSETOWN:
+ case SVR4_FIOASYNC:
+ case SVR4_FIONBIO:
+ case SVR4_FIONREAD:
+ if ((error = copyin(data, &num, sizeof(num))) != 0)
+ return error;
+
+ switch (cmd) {
+ case SVR4_FIOGETOWN: cmd = FIOGETOWN; break;
+ case SVR4_FIOSETOWN: cmd = FIOSETOWN; break;
+ case SVR4_FIOASYNC: cmd = FIOASYNC; break;
+ case SVR4_FIONBIO: cmd = FIONBIO; break;
+ case SVR4_FIONREAD: cmd = FIONREAD; break;
+ }
+
+ error = (*ctl)(fp, cmd, (caddr_t) &num, p);
+
+ if (error)
+ return error;
+
+ return copyout(&num, data, sizeof(num));
+
+ default:
+ DPRINTF(("Unknown svr4 filio %x\n", cmd));
+ return 0; /* ENOSYS really */
+ }
+}
diff --git a/sys/compat/svr4/svr4_filio.h b/sys/compat/svr4/svr4_filio.h
new file mode 100644
index 00000000000..676f8d802de
--- /dev/null
+++ b/sys/compat/svr4/svr4_filio.h
@@ -0,0 +1,44 @@
+/* $NetBSD: svr4_filio.h,v 1.2 1994/11/18 02:53:45 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.
+ */
+
+#ifndef _SVR4_FILIO_H_
+#define _SVR4_FILIO_H_
+
+#define SVR4_FIOC ('f' << 8)
+
+#define SVR4_FIOCLEX SVR4_IO('f', 1)
+#define SVR4_FIONCLEX SVR4_IO('f', 2)
+
+#define SVR4_FIOGETOWN SVR4_IOR('f', 123, int)
+#define SVR4_FIOSETOWN SVR4_IOW('f', 124, int)
+#define SVR4_FIOASYNC SVR4_IOW('f', 125, int)
+#define SVR4_FIONBIO SVR4_IOW('f', 126, int)
+#define SVR4_FIONREAD SVR4_IOR('f', 127, int)
+
+#endif /* !_SVR4_FILIO_H_ */
diff --git a/sys/compat/svr4/svr4_fuser.h b/sys/compat/svr4/svr4_fuser.h
new file mode 100644
index 00000000000..dd83b89c434
--- /dev/null
+++ b/sys/compat/svr4/svr4_fuser.h
@@ -0,0 +1,53 @@
+/* $NetBSD: svr4_fuser.h,v 1.3 1994/10/29 00:43: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.
+ */
+
+#ifndef _SVR4_FUSER_H_
+#define _SVR4_FUSER_H_
+
+#include <compat/svr4/svr4_types.h>
+
+struct svr4_f_user {
+ svr4_pid_t fu_pid;
+ int fu_flags;
+ uid_t fu_uid;
+};
+
+
+#define SVR4_F_FILE_ONLY 1
+#define SVR4_F_CONTAINED 2
+
+#define SVR4_F_CDIR 0x01
+#define SVR4_F_RDIR 0x02
+#define SVR4_F_TEXT 0x04
+#define SVR4_F_MAP 0x08
+#define SVR4_F_OPEN 0x10
+#define SVR4_F_TRACE 0x20
+#define SVR4_F_TTY 0x40
+
+#endif /* !_SVR4_FUSER_H_ */
diff --git a/sys/compat/svr4/svr4_hrt.h b/sys/compat/svr4/svr4_hrt.h
new file mode 100644
index 00000000000..ebbf9322518
--- /dev/null
+++ b/sys/compat/svr4/svr4_hrt.h
@@ -0,0 +1,86 @@
+/* $NetBSD: svr4_hrt.h,v 1.1 1994/11/18 02:56:09 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.
+ */
+
+#ifndef _SVR4_HRT_H_
+#define _SVR4_HRT_H_
+
+#define SVR4_HRT_CNTL 0
+#define SVR4_HRT_CNTL_RES 0
+#define SVR4_HRT_CNTL_TOFD 1
+#define SVR4_HRT_CNTL_START 2
+#define SVR4_HRT_CNTL_GET 3
+
+#define SVR4_HRT_ALRM 1
+#define SVR4_HRT_ALRM_DO 4
+#define SVR4_HRT_ALRM_REP 5
+#define SVR4_HRT_ALRM_TOD 6
+#define SVR4_HRT_ALRM_FUTREP 7
+#define SVR4_HRT_ALRM_TODREP 8
+#define SVR4_HRT_ALRM_PEND 9
+
+#define SVR4_HRT_SLP 2
+#define SVR4_HRT_SLP_INT 10
+#define SVR4_HRT_SLP_TOD 11
+
+#define SVR4_HRT_BSD 12
+#define SVR4_HRT_BSD_PEND 13
+#define SVR4_HRT_BSD_REP1 14
+#define SVR4_HRT_BSD_REP2 15
+#define SVR4_HRT_BSD_CANCEL 16
+
+#define SVR4_HRT_CAN 3
+
+#define SVR4_HRT_SEC 1
+#define SVR4_HRT_MSEC 1000
+#define SVR4_HRT_USEC 1000000
+#define SVR4_HRT_NSEC 1000000000
+
+#define SVR4_HRT_TRUNC 0
+#define SVR4_HRT_RND 1
+
+typedef struct {
+ u_long i_word1;
+ u_long i_word2;
+ int i_clock;
+} svr4_hrt_interval_t;
+
+typedef struct {
+ u_long h_sec;
+ long h_rem;
+ u_long h_res;
+} svr4_hrt_time_t;
+
+#define SVR4_HRT_DONE 1
+#define SVR4_HRT_ERROR 2
+
+#define SVR4_HRT_CLK_STD 1
+#define SVR4_HRT_CLK_USERVIRT 2
+#define SVR4_HRT_CLK_PROCVIRT 4
+
+#endif /* !_SVR4_HRT_H_ */
diff --git a/sys/compat/svr4/svr4_ioctl.c b/sys/compat/svr4/svr4_ioctl.c
new file mode 100644
index 00000000000..355e5135c87
--- /dev/null
+++ b/sys/compat/svr4/svr4_ioctl.c
@@ -0,0 +1,135 @@
+/* $NetBSD: svr4_ioctl.c,v 1.12 1995/10/07 06:27:41 mycroft 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/proc.h>
+#include <sys/systm.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/termios.h>
+#include <sys/tty.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <net/if.h>
+#include <sys/malloc.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_stropts.h>
+#include <compat/svr4/svr4_ioctl.h>
+#include <compat/svr4/svr4_termios.h>
+#include <compat/svr4/svr4_ttold.h>
+#include <compat/svr4/svr4_filio.h>
+#include <compat/svr4/svr4_sockio.h>
+
+#ifdef DEBUG_SVR4
+/*
+ * Decode an ioctl command symbolically
+ */
+void
+svr4_decode_cmd(cmd, dir, c, num, argsiz)
+ u_long cmd;
+ char *dir, *c;
+ int *num, *argsiz;
+{
+ if (cmd & SVR4_IOC_VOID)
+ *dir++ = 'V';
+ if (cmd & SVR4_IOC_IN)
+ *dir++ = 'R';
+ if (cmd & SVR4_IOC_OUT)
+ *dir++ = 'W';
+ *dir = '\0';
+ if (cmd & SVR4_IOC_INOUT)
+ *argsiz = (cmd >> 16) & 0xff;
+ else
+ *argsiz = -1;
+
+ *c = (cmd >> 8) & 0xff;
+ *num = cmd & 0xff;
+}
+#endif
+
+int
+svr4_sys_ioctl(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_ioctl_args *uap = v;
+ struct file *fp;
+ struct filedesc *fdp;
+ u_long cmd;
+#ifdef DEBUG_SVR4
+ char dir[4];
+ char c;
+ int num;
+ int argsiz;
+
+ svr4_decode_cmd(SCARG(uap, com), dir, &c, &num, &argsiz);
+
+ printf("svr4_ioctl(%d, _IO%s(%c, %d, %d), %x);\n", SCARG(uap, fd),
+ dir, c, num, argsiz, SCARG(uap, data));
+#endif
+ fdp = p->p_fd;
+ cmd = SCARG(uap, com);
+
+ if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
+ return EBADF;
+
+ if ((fp->f_flag & (FREAD | FWRITE)) == 0)
+ return EBADF;
+
+ switch (cmd & 0xff00) {
+ case SVR4_tIOC:
+ return svr4_ttoldioctl(fp, cmd, SCARG(uap, data), p, retval);
+
+ case SVR4_TIOC:
+ return svr4_termioctl(fp, cmd, SCARG(uap, data), p, retval);
+
+ case SVR4_STR:
+ return svr4_streamioctl(fp, cmd, SCARG(uap, data), p, retval);
+
+ case SVR4_FIOC:
+ return svr4_filioctl(fp, cmd, SCARG(uap, data), p, retval);
+
+ case SVR4_SIOC:
+ return svr4_sockioctl(fp, cmd, SCARG(uap, data), p, retval);
+
+ default:
+ DPRINTF(("Unimplemented ioctl %x\n", cmd));
+ return 0; /* XXX: really ENOSYS */
+ }
+}
diff --git a/sys/compat/svr4/svr4_ioctl.h b/sys/compat/svr4/svr4_ioctl.h
new file mode 100644
index 00000000000..ba35ae9701b
--- /dev/null
+++ b/sys/compat/svr4/svr4_ioctl.h
@@ -0,0 +1,57 @@
+/* $NetBSD: svr4_ioctl.h,v 1.4 1995/10/07 06:27:42 mycroft 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.
+ */
+
+#ifndef _SVR4_IOCTL_H_
+#define _SVR4_IOCTL_H_
+
+#define SVR4_IOC_VOID 0x20000000
+#define SVR4_IOC_OUT 0x40000000
+#define SVR4_IOC_IN 0x80000000
+#define SVR4_IOC_INOUT (SVR4_IOC_IN|SVR4_IOC_OUT)
+
+#define SVR4_IOC(inout,group,num,len) \
+ (inout | ((len & 0xff) << 16) | ((group) << 8) | (num))
+
+#define SVR4_IO(g,n) SVR4_IOC(SVR4_IOC_VOID, (g), (n), 0)
+#define SVR4_IOR(g,n,t) SVR4_IOC(SVR4_IOC_OUT, (g), (n), sizeof(t))
+#define SVR4_IOW(g,n,t) SVR4_IOC(SVR4_IOC_IN, (g), (n), sizeof(t))
+#define SVR4_IOWR(g,n,t) SVR4_IOC(SVR4_IOC_INOUT,(g), (n), sizeof(t))
+
+int svr4_streamioctl __P((struct file *fp, u_long cmd, caddr_t data,
+ struct proc *p, register_t *retval));
+int svr4_termioctl __P((struct file *fp, u_long cmd, caddr_t data,
+ struct proc *p, register_t *retval));
+int svr4_ttoldioctl __P((struct file *fp, u_long cmd, caddr_t data,
+ struct proc *p, register_t *retval));
+int svr4_filioctl __P((struct file *fp, u_long cmd, caddr_t data,
+ struct proc *p, register_t *retval));
+int svr4_sockioctl __P((struct file *fp, u_long cmd, caddr_t data,
+ struct proc *p, register_t *retval));
+
+#endif /* !_SVR4_IOCTL_H_ */
diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c
new file mode 100644
index 00000000000..bab1d019d8d
--- /dev/null
+++ b/sys/compat/svr4/svr4_misc.c
@@ -0,0 +1,1199 @@
+/* $NetBSD: svr4_misc.c,v 1.28 1995/10/09 11:24:17 mycroft 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.
+ */
+
+/*
+ * SVR4 compatibility module.
+ *
+ * SVR4 system calls that are implemented differently in BSD are
+ * handled here.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/dir.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/resource.h>
+#include <sys/resourcevar.h>
+#include <sys/socket.h>
+#include <sys/vnode.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <sys/utsname.h>
+#include <sys/unistd.h>
+#include <sys/times.h>
+#include <sys/sem.h>
+#include <sys/msg.h>
+
+#include <netinet/in.h>
+#include <sys/syscallargs.h>
+
+#include <miscfs/specfs/specdev.h>
+
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_time.h>
+#include <compat/svr4/svr4_dirent.h>
+#include <compat/svr4/svr4_ulimit.h>
+#include <compat/svr4/svr4_hrt.h>
+#include <compat/svr4/svr4_wait.h>
+#include <compat/svr4/svr4_statvfs.h>
+#include <compat/svr4/svr4_sysconfig.h>
+
+#include <vm/vm.h>
+/* XXX */ extern struct proc *pfind();
+
+static __inline clock_t timeval_to_clock_t __P((struct timeval *));
+static int svr4_setinfo __P((struct proc *, int, svr4_siginfo_t *));
+
+struct svr4_hrtcntl_args;
+static int svr4_hrtcntl __P((struct proc *, struct svr4_hrtcntl_args *,
+ register_t *));
+static void bsd_statfs_to_svr4_statvfs __P((const struct statfs *,
+ struct svr4_statvfs *));
+static struct proc *svr4_pfind __P((pid_t pid));
+
+int
+svr4_sys_wait(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_wait_args *uap = v;
+ struct sys_wait4_args w4;
+ int error;
+ size_t sz = sizeof(*SCARG(&w4, status));
+
+ SCARG(&w4, rusage) = NULL;
+ SCARG(&w4, options) = 0;
+
+ if (SCARG(uap, status) == NULL) {
+ caddr_t sg = stackgap_init(p->p_emul);
+ SCARG(&w4, status) = stackgap_alloc(&sg, sz);
+ }
+ else
+ SCARG(&w4, status) = SCARG(uap, status);
+
+ SCARG(&w4, pid) = WAIT_ANY;
+
+ if ((error = sys_wait4(p, &w4, retval)) != 0)
+ return error;
+
+ /*
+ * It looks like wait(2) on svr4/solaris/2.4 returns
+ * the status in retval[1], and the pid on retval[0].
+ * NB: this can break if register_t stops being an int.
+ */
+ return copyin(SCARG(&w4, status), &retval[1], sz);
+}
+
+
+int
+svr4_sys_execv(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_execv_args *uap = v;
+ struct sys_execve_args ex;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&ex, path) = SCARG(uap, path);
+ SCARG(&ex, argp) = SCARG(uap, argp);
+ SCARG(&ex, envp) = NULL;
+
+ return sys_execve(p, &ex, retval);
+}
+
+
+int
+svr4_sys_execve(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sys_execve_args *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+ SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ return sys_execve(p, uap, retval);
+}
+
+
+int
+svr4_sys_time(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_time_args *uap = v;
+ int error = 0;
+ struct timeval tv;
+
+ microtime(&tv);
+ if (SCARG(uap, t))
+ error = copyout(&tv.tv_sec, SCARG(uap, t),
+ sizeof(*(SCARG(uap, t))));
+ *retval = (int) tv.tv_sec;
+
+ return error;
+}
+
+
+/*
+ * Read SVR4-style directory entries. We suck them into kernel space so
+ * that they can be massaged before being copied out to user code. Like
+ * SunOS, we squish out `empty' entries.
+ *
+ * This is quite ugly, but what do you expect from compatibility code?
+ */
+int
+svr4_sys_getdents(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_getdents_args *uap = v;
+ register struct dirent *bdp;
+ struct vnode *vp;
+ caddr_t inp, buf; /* BSD-format */
+ int len, reclen; /* BSD-format */
+ caddr_t outp; /* SVR4-format */
+ int resid, svr4_reclen; /* SVR4-format */
+ struct file *fp;
+ struct uio auio;
+ struct iovec aiov;
+ struct svr4_dirent idb;
+ off_t off; /* true file offset */
+ int buflen, error, eofflag;
+ u_long *cookiebuf, *cookie;
+ int ncookies;
+
+ if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
+ return (error);
+
+ if ((fp->f_flag & FREAD) == 0)
+ return (EBADF);
+
+ vp = (struct vnode *)fp->f_data;
+
+ if (vp->v_type != VDIR) /* XXX vnode readdir op should do this */
+ return (EINVAL);
+
+ buflen = min(MAXBSIZE, SCARG(uap, nbytes));
+ buf = malloc(buflen, M_TEMP, M_WAITOK);
+ ncookies = buflen / 16;
+ cookiebuf = malloc(ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK);
+ VOP_LOCK(vp);
+ off = fp->f_offset;
+again:
+ aiov.iov_base = buf;
+ aiov.iov_len = buflen;
+ auio.uio_iov = &aiov;
+ auio.uio_iovcnt = 1;
+ auio.uio_rw = UIO_READ;
+ auio.uio_segflg = UIO_SYSSPACE;
+ auio.uio_procp = p;
+ auio.uio_resid = buflen;
+ auio.uio_offset = off;
+ /*
+ * First we read into the malloc'ed buffer, then
+ * we massage it into user space, one record at a time.
+ */
+ error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, cookiebuf,
+ ncookies);
+ if (error)
+ goto out;
+
+ inp = buf;
+ outp = SCARG(uap, buf);
+ resid = SCARG(uap, nbytes);
+ if ((len = buflen - auio.uio_resid) == 0)
+ goto eof;
+
+ for (cookie = cookiebuf; len > 0; len -= reclen) {
+ bdp = (struct dirent *)inp;
+ reclen = bdp->d_reclen;
+ if (reclen & 3)
+ panic("svr4_getdents");
+ off = *cookie++; /* each entry points to the next */
+ if (bdp->d_fileno == 0) {
+ inp += reclen; /* it is a hole; squish it out */
+ continue;
+ }
+ svr4_reclen = SVR4_RECLEN(&idb, bdp->d_namlen);
+ if (reclen > len || resid < svr4_reclen) {
+ /* entry too big for buffer, so just stop */
+ outp++;
+ break;
+ }
+ /*
+ * Massage in place to make a SVR4-shaped dirent (otherwise
+ * we have to worry about touching user memory outside of
+ * the copyout() call).
+ */
+ idb.d_ino = (svr4_ino_t)bdp->d_fileno;
+ idb.d_off = (svr4_off_t)off;
+ idb.d_reclen = (u_short)svr4_reclen;
+ strcpy(idb.d_name, bdp->d_name);
+ if ((error = copyout((caddr_t)&idb, outp, svr4_reclen)))
+ goto out;
+ /* advance past this real entry */
+ inp += reclen;
+ /* advance output past SVR4-shaped entry */
+ outp += svr4_reclen;
+ resid -= svr4_reclen;
+ }
+
+ /* if we squished out the whole block, try again */
+ if (outp == SCARG(uap, buf))
+ goto again;
+ fp->f_offset = off; /* update the vnode offset */
+
+eof:
+ *retval = SCARG(uap, nbytes) - resid;
+out:
+ VOP_UNLOCK(vp);
+ free(cookiebuf, M_TEMP);
+ free(buf, M_TEMP);
+ return error;
+}
+
+int
+svr4_sys_mmap(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_mmap_args *uap = v;
+ struct filedesc *fdp;
+ struct file *fp;
+ struct vnode *vp;
+ struct sys_mmap_args mm;
+ caddr_t rp;
+#define _MAP_NEW 0x80000000
+ /*
+ * Verify the arguments.
+ */
+ if (SCARG(uap, prot) & ~(PROT_READ | PROT_WRITE | PROT_EXEC))
+ return EINVAL; /* XXX still needed? */
+
+ SCARG(&mm, prot) = SCARG(uap, prot);
+ SCARG(&mm, len) = SCARG(uap, len);
+ SCARG(&mm, flags) = SCARG(uap, flags) & ~_MAP_NEW;
+ SCARG(&mm, fd) = SCARG(uap, fd);
+ SCARG(&mm, addr) = SCARG(uap, addr);
+ SCARG(&mm, pos) = SCARG(uap, pos);
+
+ rp = (caddr_t) round_page(p->p_vmspace->vm_daddr + MAXDSIZ);
+ if ((SCARG(&mm, flags) & MAP_FIXED) == 0 &&
+ SCARG(&mm, addr) != 0 && SCARG(&mm, addr) < rp)
+ SCARG(&mm, addr) = rp;
+
+ return sys_mmap(p, &mm, retval);
+}
+
+int
+svr4_sys_fchroot(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_fchroot_args *uap = v;
+ struct filedesc *fdp = p->p_fd;
+ struct vnode *vp;
+ struct file *fp;
+ int error;
+
+ if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
+ return error;
+ if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0)
+ return error;
+ vp = (struct vnode *) fp->f_data;
+ VOP_LOCK(vp);
+ if (vp->v_type != VDIR)
+ error = ENOTDIR;
+ else
+ error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p);
+ VOP_UNLOCK(vp);
+ if (error)
+ return error;
+ VREF(vp);
+ if (fdp->fd_rdir != NULL)
+ vrele(fdp->fd_rdir);
+ fdp->fd_rdir = vp;
+ return 0;
+}
+
+
+int
+svr4_sys_mknod(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_mknod_args *uap = v;
+ caddr_t sg = stackgap_init(p->p_emul);
+ SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ if (S_ISFIFO(SCARG(uap, mode))) {
+ struct sys_mkfifo_args ap;
+ SCARG(&ap, path) = SCARG(uap, path);
+ SCARG(&ap, mode) = SCARG(uap, mode);
+ return sys_mkfifo(p, &ap, retval);
+ } else {
+ struct sys_mknod_args ap;
+ SCARG(&ap, path) = SCARG(uap, path);
+ SCARG(&ap, mode) = SCARG(uap, mode);
+ SCARG(&ap, dev) = SCARG(uap, dev);
+ return sys_mknod(p, &ap, retval);
+ }
+}
+
+int
+svr4_sys_vhangup(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ return 0;
+}
+
+
+int
+svr4_sys_sysconfig(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_sysconfig_args *uap = v;
+ extern int maxfiles;
+
+ switch (SCARG(uap, name)) {
+ case SVR4_CONFIG_UNUSED:
+ *retval = 0;
+ break;
+ case SVR4_CONFIG_NGROUPS:
+ *retval = NGROUPS_MAX;
+ break;
+ case SVR4_CONFIG_CHILD_MAX:
+ *retval = maxproc;
+ break;
+ case SVR4_CONFIG_OPEN_FILES:
+ *retval = maxfiles;
+ break;
+ case SVR4_CONFIG_POSIX_VER:
+ *retval = 198808;
+ break;
+ case SVR4_CONFIG_PAGESIZE:
+ *retval = NBPG;
+ break;
+ case SVR4_CONFIG_CLK_TCK:
+ *retval = 60; /* should this be `hz', ie. 100? */
+ break;
+ case SVR4_CONFIG_XOPEN_VER:
+ *retval = 2; /* XXX: What should that be? */
+ break;
+ case SVR4_CONFIG_PROF_TCK:
+ *retval = 60; /* XXX: What should that be? */
+ break;
+ case SVR4_CONFIG_NPROC_CONF:
+ *retval = 1; /* Only one processor for now */
+ break;
+ case SVR4_CONFIG_NPROC_ONLN:
+ *retval = 1; /* And it better be online */
+ break;
+ case SVR4_CONFIG_AIO_LISTIO_MAX:
+ case SVR4_CONFIG_AIO_MAX:
+ case SVR4_CONFIG_AIO_PRIO_DELTA_MAX:
+ *retval = 0; /* No aio support */
+ break;
+ case SVR4_CONFIG_DELAYTIMER_MAX:
+ *retval = 0; /* No delaytimer support */
+ break;
+ case SVR4_CONFIG_MQ_OPEN_MAX:
+ *retval = msginfo.msgmni;
+ break;
+ case SVR4_CONFIG_MQ_PRIO_MAX:
+ *retval = 0; /* XXX: Don't know */
+ break;
+ case SVR4_CONFIG_RTSIG_MAX:
+ *retval = 0;
+ break;
+ case SVR4_CONFIG_SEM_NSEMS_MAX:
+ *retval = seminfo.semmni;
+ break;
+ case SVR4_CONFIG_SEM_VALUE_MAX:
+ *retval = seminfo.semvmx;
+ break;
+ case SVR4_CONFIG_SIGQUEUE_MAX:
+ *retval = 0; /* XXX: Don't know */
+ break;
+ case SVR4_CONFIG_SIGRT_MIN:
+ case SVR4_CONFIG_SIGRT_MAX:
+ *retval = 0; /* No real time signals */
+ break;
+ case SVR4_CONFIG_TIMER_MAX:
+ *retval = 3; /* XXX: real, virtual, profiling */
+ break;
+ case SVR4_CONFIG_PHYS_PAGES:
+ *retval = cnt.v_free_count; /* XXX: free instead of total */
+ break;
+ case SVR4_CONFIG_AVPHYS_PAGES:
+ *retval = cnt.v_active_count; /* XXX: active instead of avg */
+ break;
+ default:
+ return EINVAL;
+ }
+ return 0;
+}
+
+#define SVR4_RLIMIT_NOFILE 5 /* Other RLIMIT_* are the same */
+#define SVR4_RLIMIT_VMEM 6 /* Other RLIMIT_* are the same */
+#define SVR4_RLIM_NLIMITS 7
+
+int
+svr4_sys_getrlimit(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_getrlimit_args *uap = v;
+ struct compat_43_sys_getrlimit_args ap;
+
+ if (SCARG(uap, which) >= SVR4_RLIM_NLIMITS)
+ return EINVAL;
+
+ if (SCARG(uap, which) == SVR4_RLIMIT_NOFILE)
+ SCARG(uap, which) = RLIMIT_NOFILE;
+ if (SCARG(uap, which) == SVR4_RLIMIT_VMEM)
+ SCARG(uap, which) = RLIMIT_RSS;
+
+ SCARG(&ap, which) = SCARG(uap, which);
+ SCARG(&ap, rlp) = SCARG(uap, rlp);
+
+ return compat_43_sys_getrlimit(p, &ap, retval);
+}
+
+int
+svr4_sys_setrlimit(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_setrlimit_args *uap = v;
+ struct compat_43_sys_setrlimit_args ap;
+
+ if (SCARG(uap, which) >= SVR4_RLIM_NLIMITS)
+ return EINVAL;
+
+ if (SCARG(uap, which) == SVR4_RLIMIT_NOFILE)
+ SCARG(uap, which) = RLIMIT_NOFILE;
+ if (SCARG(uap, which) == SVR4_RLIMIT_VMEM)
+ SCARG(uap, which) = RLIMIT_RSS;
+
+ SCARG(&ap, which) = SCARG(uap, which);
+ SCARG(&ap, rlp) = SCARG(uap, rlp);
+
+ return compat_43_sys_setrlimit(p, uap, retval);
+}
+
+
+/* ARGSUSED */
+int
+svr4_sys_break(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_break_args *uap = v;
+ register struct vmspace *vm = p->p_vmspace;
+ vm_offset_t new, old;
+ int rv;
+ register int diff;
+
+ old = (vm_offset_t) vm->vm_daddr;
+ new = round_page(SCARG(uap, nsize));
+ diff = new - old;
+
+ DPRINTF(("break(1): old %x new %x diff %x\n", old, new, diff));
+
+ if (diff > p->p_rlimit[RLIMIT_DATA].rlim_cur)
+ return ENOMEM;
+
+ old = round_page(old + ctob(vm->vm_dsize));
+ DPRINTF(("break(2): dsize = %x ctob %x\n",
+ vm->vm_dsize, ctob(vm->vm_dsize)));
+
+ diff = new - old;
+ DPRINTF(("break(3): old %x new %x diff %x\n", old, new, diff));
+
+ if (diff > 0) {
+ rv = vm_allocate(&vm->vm_map, &old, diff, FALSE);
+ if (rv != KERN_SUCCESS) {
+ uprintf("sbrk: grow failed, return = %d\n", rv);
+ return ENOMEM;
+ }
+ vm->vm_dsize += btoc(diff);
+ } else if (diff < 0) {
+ diff = -diff;
+ rv = vm_deallocate(&vm->vm_map, new, diff);
+ if (rv != KERN_SUCCESS) {
+ uprintf("sbrk: shrink failed, return = %d\n", rv);
+ return ENOMEM;
+ }
+ vm->vm_dsize -= btoc(diff);
+ }
+ return 0;
+}
+
+static __inline clock_t
+timeval_to_clock_t(tv)
+ struct timeval *tv;
+{
+ return tv->tv_sec * hz + tv->tv_usec / (1000000 / hz);
+}
+
+int
+svr4_sys_times(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_times_args *uap = v;
+ int error;
+ struct tms tms;
+ struct timeval t;
+ struct rusage *ru;
+ struct rusage r;
+ struct sys_getrusage_args ga;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ ru = stackgap_alloc(&sg, sizeof(struct rusage));
+
+ SCARG(&ga, who) = RUSAGE_SELF;
+ SCARG(&ga, rusage) = ru;
+
+ error = sys_getrusage(p, &ga, retval);
+ if (error)
+ return error;
+
+ if (error = copyin(ru, &r, sizeof r))
+ return error;
+
+ tms.tms_utime = timeval_to_clock_t(&r.ru_utime);
+ tms.tms_stime = timeval_to_clock_t(&r.ru_stime);
+
+ SCARG(&ga, who) = RUSAGE_CHILDREN;
+ error = sys_getrusage(p, &ga, retval);
+ if (error)
+ return error;
+
+ if (error = copyin(ru, &r, sizeof r))
+ return error;
+
+ tms.tms_cutime = timeval_to_clock_t(&r.ru_utime);
+ tms.tms_cstime = timeval_to_clock_t(&r.ru_stime);
+
+ microtime(&t);
+ *retval = timeval_to_clock_t(&t);
+
+ return copyout(&tms, SCARG(uap, tp), sizeof(tms));
+}
+
+
+int
+svr4_sys_ulimit(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_ulimit_args *uap = v;
+
+ switch (SCARG(uap, cmd)) {
+ case SVR4_GFILLIM:
+ *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur / 512;
+ return 0;
+
+ case SVR4_SFILLIM:
+ {
+ int error;
+ struct sys_setrlimit_args srl;
+ struct rlimit krl;
+ caddr_t sg = stackgap_init(p->p_emul);
+ struct rlimit *url = (struct rlimit *)
+ stackgap_alloc(&sg, sizeof *url);
+
+ krl.rlim_cur = SCARG(uap, newlimit) * 512;
+ krl.rlim_max = p->p_rlimit[RLIMIT_FSIZE].rlim_max;
+
+ error = copyout(&krl, url, sizeof(*url));
+ if (error)
+ return error;
+
+ srl.which = RLIMIT_FSIZE;
+ srl.rlp = url;
+
+ error = sys_setrlimit(p, &srl, retval);
+ if (error)
+ return error;
+
+ *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur;
+ return 0;
+ }
+
+ case SVR4_GMEMLIM:
+ {
+ struct vmspace *vm = p->p_vmspace;
+ *retval = (long) vm->vm_daddr +
+ p->p_rlimit[RLIMIT_DATA].rlim_cur;
+ return 0;
+ }
+
+ case SVR4_GDESLIM:
+ *retval = p->p_rlimit[RLIMIT_NOFILE].rlim_cur;
+ return 0;
+
+ default:
+ return ENOSYS;
+ }
+}
+
+
+static struct proc *
+svr4_pfind(pid)
+ pid_t pid;
+{
+ struct proc *p;
+
+ /* look in the live processes */
+ if ((p = pfind(pid)) != NULL)
+ return p;
+
+ /* look in the zombies */
+ for (p = zombproc.lh_first; p != 0; p = p->p_list.le_next)
+ if (p->p_pid == pid)
+ return p;
+
+ return NULL;
+}
+
+
+int
+svr4_sys_pgrpsys(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_pgrpsys_args *uap = v;
+ int error;
+
+ switch (SCARG(uap, cmd)) {
+ case 0: /* getpgrp() */
+ *retval = p->p_pgrp->pg_id;
+ return 0;
+
+ case 1: /* setpgrp() */
+ {
+ struct sys_setpgid_args sa;
+
+ SCARG(&sa, pid) = 0;
+ SCARG(&sa, pgid) = 0;
+ if ((error = sys_setpgid(p, &sa, retval)) != 0)
+ return error;
+ *retval = p->p_pgrp->pg_id;
+ return 0;
+ }
+
+ case 2: /* getsid(pid) */
+ if (SCARG(uap, pid) != 0 &&
+ (p = svr4_pfind(SCARG(uap, pid))) == NULL)
+ return ESRCH;
+ /*
+ * we return the pid of the session leader for this
+ * process
+ */
+ *retval = (register_t) p->p_session->s_leader->p_pid;
+ return 0;
+
+ case 3: /* setsid() */
+ return sys_setsid(p, NULL, retval);
+
+ case 4: /* getpgid(pid) */
+
+ if (SCARG(uap, pid) != 0 &&
+ (p = svr4_pfind(SCARG(uap, pid))) == NULL)
+ return ESRCH;
+
+ *retval = (int) p->p_pgrp->pg_id;
+ return 0;
+
+ case 5: /* setpgid(pid, pgid); */
+ {
+ struct sys_setpgid_args sa;
+
+ SCARG(&sa, pid) = SCARG(uap, pid);
+ SCARG(&sa, pgid) = SCARG(uap, pgid);
+ return sys_setpgid(p, &sa, retval);
+ }
+
+ default:
+ return EINVAL;
+ }
+}
+
+#define syscallarg(x) union { x datum; register_t pad; }
+
+struct svr4_hrtcntl_args {
+ syscallarg(int) cmd;
+ syscallarg(int) fun;
+ syscallarg(int) clk;
+ syscallarg(svr4_hrt_interval_t *) iv;
+ syscallarg(svr4_hrt_time_t *) ti;
+};
+
+static int
+svr4_hrtcntl(p, uap, retval)
+ register struct proc *p;
+ register struct svr4_hrtcntl_args *uap;
+ register_t *retval;
+{
+ switch (SCARG(uap, fun)) {
+ case SVR4_HRT_CNTL_RES:
+ DPRINTF(("htrcntl(RES)\n"));
+ *retval = SVR4_HRT_USEC;
+ return 0;
+
+ case SVR4_HRT_CNTL_TOFD:
+ DPRINTF(("htrcntl(TOFD)\n"));
+ {
+ struct timeval tv;
+ svr4_hrt_time_t t;
+ if (SCARG(uap, clk) != SVR4_HRT_CLK_STD) {
+ DPRINTF(("clk == %d\n", SCARG(uap, clk)));
+ return EINVAL;
+ }
+ if (SCARG(uap, ti) == NULL) {
+ DPRINTF(("ti NULL\n"));
+ return EINVAL;
+ }
+ microtime(&tv);
+ t.h_sec = tv.tv_sec;
+ t.h_rem = tv.tv_usec;
+ t.h_res = SVR4_HRT_USEC;
+ return copyout(&t, SCARG(uap, ti), sizeof(t));
+ }
+
+ case SVR4_HRT_CNTL_START:
+ DPRINTF(("htrcntl(START)\n"));
+ return ENOSYS;
+
+ case SVR4_HRT_CNTL_GET:
+ DPRINTF(("htrcntl(GET)\n"));
+ return ENOSYS;
+ default:
+ DPRINTF(("Bad htrcntl command %d\n", SCARG(uap, fun)));
+ return ENOSYS;
+ }
+}
+
+int
+svr4_sys_hrtsys(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_hrtsys_args *uap = v;
+ int error;
+ struct timeval tv;
+
+ switch (SCARG(uap, cmd)) {
+ case SVR4_HRT_CNTL:
+ return svr4_hrtcntl(p, (struct svr4_hrtcntl_args *) uap,
+ retval);
+
+ case SVR4_HRT_ALRM:
+ DPRINTF(("hrtalarm\n"));
+ return ENOSYS;
+
+ case SVR4_HRT_SLP:
+ DPRINTF(("hrtsleep\n"));
+ return ENOSYS;
+
+ case SVR4_HRT_CAN:
+ DPRINTF(("hrtcancel\n"));
+ return ENOSYS;
+
+ default:
+ DPRINTF(("Bad hrtsys command %d\n", SCARG(uap, cmd)));
+ return EINVAL;
+ }
+}
+
+static int
+svr4_setinfo(p, st, s)
+ struct proc *p;
+ int st;
+ svr4_siginfo_t *s;
+{
+ svr4_siginfo_t i;
+
+ bzero(&i, sizeof(i));
+
+ i.si_signo = SVR4_SIGCHLD;
+ i.si_errno = 0; /* XXX? */
+
+ if (p) {
+ i.si_pid = p->p_pid;
+ i.si_stime = p->p_ru->ru_stime.tv_sec;
+ i.si_utime = p->p_ru->ru_utime.tv_sec;
+ }
+
+ if (WIFEXITED(st)) {
+ i.si_status = WEXITSTATUS(st);
+ i.si_code = SVR4_CLD_EXITED;
+ }
+ else if (WIFSTOPPED(st)) {
+ i.si_status = bsd_to_svr4_sig[WSTOPSIG(st)];
+
+ if (i.si_status == SVR4_SIGCONT)
+ i.si_code = SVR4_CLD_CONTINUED;
+ else
+ i.si_code = SVR4_CLD_STOPPED;
+ } else {
+ i.si_status = bsd_to_svr4_sig[WTERMSIG(st)];
+
+ if (WCOREDUMP(st))
+ i.si_code = SVR4_CLD_DUMPED;
+ else
+ i.si_code = SVR4_CLD_KILLED;
+ }
+
+ DPRINTF(("siginfo [pid %d signo %d code %d errno %d status %d]\n",
+ i.si_pid, i.si_signo, i.si_code, i.si_errno, i.si_status));
+
+ return copyout(&i, s, sizeof(i));
+}
+
+
+int
+svr4_sys_waitsys(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_waitsys_args *uap = v;
+ int nfound;
+ int error;
+ struct proc *q, *t;
+
+
+ switch (SCARG(uap, grp)) {
+ case SVR4_P_PID:
+ break;
+
+ case SVR4_P_PGID:
+ SCARG(uap, id) = -p->p_pgid;
+ break;
+
+ case SVR4_P_ALL:
+ SCARG(uap, id) = WAIT_ANY;
+ break;
+
+ default:
+ return EINVAL;
+ }
+
+ DPRINTF(("waitsys(%d, %d, %x, %x)\n",
+ SCARG(uap, grp), SCARG(uap, id), SCARG(uap, info),
+ SCARG(uap, options)));
+
+loop:
+ nfound = 0;
+ for (q = p->p_children.lh_first; q != 0; q = q->p_sibling.le_next) {
+ if (SCARG(uap, id) != WAIT_ANY &&
+ q->p_pid != SCARG(uap, id) &&
+ q->p_pgid != -SCARG(uap, id)) {
+ DPRINTF(("pid %d pgid %d != %d\n", q->p_pid,
+ q->p_pgid, SCARG(uap, id)));
+ continue;
+ }
+ nfound++;
+ if (q->p_stat == SZOMB &&
+ ((SCARG(uap, options) & (SVR4_WEXITED|SVR4_WTRAPPED)))) {
+ *retval = 0;
+ DPRINTF(("found %d\n", q->p_pid));
+ if ((error = svr4_setinfo(q, q->p_xstat,
+ SCARG(uap, info))) != 0)
+ return error;
+
+
+ if ((SCARG(uap, options) & SVR4_WNOWAIT)) {
+ DPRINTF(("Don't wait\n"));
+ return 0;
+ }
+
+ /*
+ * If we got the child via a ptrace 'attach',
+ * we need to give it back to the old parent.
+ */
+ if (q->p_oppid && (t = pfind(q->p_oppid))) {
+ q->p_oppid = 0;
+ proc_reparent(q, t);
+ psignal(t, SIGCHLD);
+ wakeup((caddr_t)t);
+ return 0;
+ }
+ q->p_xstat = 0;
+ ruadd(&p->p_stats->p_cru, q->p_ru);
+ FREE(q->p_ru, M_ZOMBIE);
+
+ /*
+ * Decrement the count of procs running with this uid.
+ */
+ (void)chgproccnt(q->p_cred->p_ruid, -1);
+
+ /*
+ * Free up credentials.
+ */
+ if (--q->p_cred->p_refcnt == 0) {
+ crfree(q->p_cred->pc_ucred);
+ FREE(q->p_cred, M_SUBPROC);
+ }
+
+ /*
+ * Release reference to text vnode
+ */
+ if (q->p_textvp)
+ vrele(q->p_textvp);
+
+ /*
+ * Finally finished with old proc entry.
+ * Unlink it from its process group and free it.
+ */
+ leavepgrp(q);
+ LIST_REMOVE(q, p_list); /* off zombproc */
+ LIST_REMOVE(q, p_sibling);
+
+ /*
+ * Give machine-dependent layer a chance
+ * to free anything that cpu_exit couldn't
+ * release while still running in process context.
+ */
+ cpu_wait(q);
+ FREE(q, M_PROC);
+ nprocs--;
+ return 0;
+ }
+ if (q->p_stat == SSTOP && (q->p_flag & P_WAITED) == 0 &&
+ (q->p_flag & P_TRACED ||
+ (SCARG(uap, options) & (SVR4_WSTOPPED|SVR4_WCONTINUED)))) {
+ DPRINTF(("jobcontrol %d\n", q->p_pid));
+ if (((SCARG(uap, options) & SVR4_WNOWAIT)) == 0)
+ q->p_flag |= P_WAITED;
+ else
+ DPRINTF(("Don't wait\n"));
+ *retval = 0;
+ return svr4_setinfo(q, W_STOPCODE(q->p_xstat),
+ SCARG(uap, info));
+ }
+ }
+
+ if (nfound == 0)
+ return ECHILD;
+
+ if (SCARG(uap, options) & SVR4_WNOHANG) {
+ *retval = 0;
+ if ((error = svr4_setinfo(NULL, 0, SCARG(uap, info))) != 0)
+ return error;
+ return 0;
+ }
+
+ if (error = tsleep((caddr_t)p, PWAIT | PCATCH, "svr4_wait", 0))
+ return error;
+ goto loop;
+}
+
+
+static void
+bsd_statfs_to_svr4_statvfs(bfs, sfs)
+ const struct statfs *bfs;
+ struct svr4_statvfs *sfs;
+{
+ sfs->f_bsize = bfs->f_bsize;
+ sfs->f_frsize = bfs->f_bsize / 8; /* XXX */
+ sfs->f_blocks = bfs->f_blocks;
+ sfs->f_bfree = bfs->f_bfree;
+ sfs->f_bavail = bfs->f_bavail;
+ sfs->f_files = bfs->f_files;
+ sfs->f_ffree = bfs->f_ffree;
+ sfs->f_favail = bfs->f_ffree;
+ sfs->f_fsid = bfs->f_fsid.val[0];
+ bcopy(bfs->f_fstypename, sfs->f_basetype, sizeof(sfs->f_basetype));
+ sfs->f_flag = 0;
+ if (bfs->f_flags & MNT_RDONLY)
+ sfs->f_flag |= SVR4_ST_RDONLY;
+ if (bfs->f_flags & MNT_NOSUID)
+ sfs->f_flag |= SVR4_ST_NOSUID;
+ sfs->f_namemax = MAXNAMLEN;
+ bcopy(bfs->f_fstypename, sfs->f_fstr, sizeof(sfs->f_fstr)); /* XXX */
+ bzero(sfs->f_filler, sizeof(sfs->f_filler));
+}
+
+
+int
+svr4_sys_statvfs(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_statvfs_args *uap = v;
+ struct sys_statfs_args fs_args;
+ caddr_t sg = stackgap_init(p->p_emul);
+ struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
+ struct statfs bfs;
+ struct svr4_statvfs sfs;
+ int error;
+
+ SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+ SCARG(&fs_args, path) = SCARG(uap, path);
+ SCARG(&fs_args, buf) = fs;
+
+ if ((error = sys_statfs(p, &fs_args, retval)) != 0)
+ return error;
+
+ if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
+ return error;
+
+ bsd_statfs_to_svr4_statvfs(&bfs, &sfs);
+
+ return copyout(&sfs, SCARG(uap, fs), sizeof(sfs));
+}
+
+
+int
+svr4_sys_fstatvfs(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_fstatvfs_args *uap = v;
+ struct sys_fstatfs_args fs_args;
+ caddr_t sg = stackgap_init(p->p_emul);
+ struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs));
+ struct statfs bfs;
+ struct svr4_statvfs sfs;
+ int error;
+
+ SCARG(&fs_args, fd) = SCARG(uap, fd);
+ SCARG(&fs_args, buf) = fs;
+
+ if ((error = sys_fstatfs(p, &fs_args, retval)) != 0)
+ return error;
+
+ if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0)
+ return error;
+
+ bsd_statfs_to_svr4_statvfs(&bfs, &sfs);
+
+ return copyout(&sfs, SCARG(uap, fs), sizeof(sfs));
+}
+
+int
+svr4_sys_alarm(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_alarm_args *uap = v;
+ int error;
+ struct itimerval *ntp, *otp, tp;
+ struct sys_setitimer_args sa;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ ntp = stackgap_alloc(&sg, sizeof(struct itimerval));
+ otp = stackgap_alloc(&sg, sizeof(struct itimerval));
+
+ timerclear(&tp.it_interval);
+ tp.it_value.tv_sec = SCARG(uap, sec);
+ tp.it_value.tv_usec = 0;
+
+ if ((error = copyout(&tp, ntp, sizeof(tp))) != 0)
+ return error;
+
+ SCARG(&sa, which) = ITIMER_REAL;
+ SCARG(&sa, itv) = ntp;
+ SCARG(&sa, oitv) = otp;
+
+ if ((error = sys_setitimer(p, &sa, retval)) != 0)
+ return error;
+
+ if ((error = copyin(otp, &tp, sizeof(tp))) != 0)
+ return error;
+
+ if (tp.it_value.tv_usec)
+ tp.it_value.tv_sec++;
+
+ *retval = (register_t) tp.it_value.tv_sec;
+
+ return 0;
+}
+
+
+int
+svr4_sys_gettimeofday(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_gettimeofday_args *uap = v;
+
+ if (SCARG(uap, tp)) {
+ struct timeval atv;
+
+ microtime(&atv);
+ return copyout(&atv, SCARG(uap, tp), sizeof (atv));
+ }
+
+ return 0;
+}
diff --git a/sys/compat/svr4/svr4_net.c b/sys/compat/svr4/svr4_net.c
new file mode 100644
index 00000000000..42f50403f54
--- /dev/null
+++ b/sys/compat/svr4/svr4_net.c
@@ -0,0 +1,171 @@
+/* $NetBSD: svr4_net.c,v 1.4 1994/12/14 20:20:26 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1994 Christos Zoulas
+ * All rights reserved.
+ *
+ * Redistribution ast use in source ast binary forms, with or without
+ * modification, are permitted provided that the following costitions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of costitions ast the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of costitions ast the following disclaimer in the
+ * documentation ast/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to estorse 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.
+ */
+
+/*
+ * Emulate /dev/{udp,tcp,...}
+ */
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/buf.h>
+#include <sys/malloc.h>
+#include <sys/ioctl.h>
+#include <sys/tty.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <sys/proc.h>
+#include <sys/vnode.h>
+#include <sys/device.h>
+
+
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_ioctl.h>
+#include <compat/svr4/svr4_stropts.h>
+
+/*
+ * Device minor numbers
+ */
+enum {
+ dev_arp = 26,
+ dev_icmp = 27,
+ dev_ip = 28,
+ dev_tcp = 35,
+ dev_udp = 36
+};
+
+static int svr4_netclose __P((struct file *fp, struct proc *p));
+
+static struct fileops svr4_netops = {
+ soo_read, soo_write, soo_ioctl, soo_select, svr4_netclose
+};
+
+
+/*
+ * Used by new config, but we don't need it.
+ */
+int
+svr4_netattach(n)
+ int n;
+{
+ return 0;
+}
+
+
+int
+svr4_netopen(dev, flag, mode, p)
+ dev_t dev;
+ int flag;
+ int mode;
+ struct proc *p;
+{
+ int type, protocol;
+ int fd;
+ struct file *fp;
+ struct socket *so;
+ int error;
+ struct svr4_strm *st;
+
+ DPRINTF(("netopen("));
+
+ if (p->p_dupfd >= 0)
+ return ENODEV;
+
+ switch (minor(dev)) {
+ case dev_udp:
+ type = SOCK_DGRAM;
+ protocol = IPPROTO_UDP;
+ DPRINTF(("udp, "));
+ break;
+
+ case dev_tcp:
+ type = SOCK_STREAM;
+ protocol = IPPROTO_TCP;
+ DPRINTF(("tcp, "));
+ break;
+
+ case dev_ip:
+ type = SOCK_RAW;
+ protocol = IPPROTO_IP;
+ DPRINTF(("ip, "));
+ break;
+
+ case dev_icmp:
+ type = SOCK_RAW;
+ protocol = IPPROTO_ICMP;
+ DPRINTF(("icmp, "));
+ break;
+
+ default:
+ DPRINTF(("%d);\n", minor(dev)));
+ return EOPNOTSUPP;
+ }
+
+ if ((error = falloc(p, &fp, &fd)) != 0)
+ return (error);
+
+ if ((error = socreate(AF_INET, &so, type, protocol)) != 0) {
+ DPRINTF(("socreate error %d\n", error));
+ p->p_fd->fd_ofiles[fd] = 0;
+ ffree(fp);
+ return error;
+ }
+
+ fp->f_flag = FREAD|FWRITE;
+ fp->f_type = DTYPE_SOCKET;
+ fp->f_ops = &svr4_netops;
+
+ st = malloc(sizeof(struct svr4_strm), M_NETADDR, M_WAITOK);
+ /* XXX: This is unused; ask for a field and make this legal */
+ so->so_tpcb = (caddr_t) st;
+ st->s_cmd = ~0;
+ fp->f_data = (caddr_t)so;
+ DPRINTF(("ok);\n"));
+
+ p->p_dupfd = fd;
+ return ENXIO;
+}
+
+static int
+svr4_netclose(fp, p)
+ struct file *fp;
+ struct proc *p;
+{
+ struct socket *so = (struct socket *) fp->f_data;
+ free((char *) so->so_tpcb, M_NETADDR);
+ return soo_close(fp, p);
+}
diff --git a/sys/compat/svr4/svr4_poll.h b/sys/compat/svr4/svr4_poll.h
new file mode 100644
index 00000000000..c63e5f2e91f
--- /dev/null
+++ b/sys/compat/svr4/svr4_poll.h
@@ -0,0 +1,50 @@
+/* $NetBSD: svr4_poll.h,v 1.2 1994/11/18 02:53:55 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.
+ */
+
+#ifndef _SVR4_POLL_H_
+#define _SVR4_POLL_H_
+
+struct svr4_pollfd {
+ int fd;
+ short events;
+ short revents;
+};
+
+#define SVR4_POLLIN 0x0001
+#define SVR4_POLLPRI 0x0002
+#define SVR4_POLLOUT 0x0004
+#define SVR4_POLLERR 0x0008
+#define SVR4_POLLHUP 0x0010
+#define SVR4_POLLNVAL 0x0020
+#define SVR4_POLLRDNORM 0x0040
+#define SVR4_POLLRDBAND 0x0080
+#define SVR4_POLLWRBAND 0x0100
+
+
+#endif /* !_SVR4_POLL_H_ */
diff --git a/sys/compat/svr4/svr4_siginfo.h b/sys/compat/svr4/svr4_siginfo.h
new file mode 100644
index 00000000000..0175de9dcec
--- /dev/null
+++ b/sys/compat/svr4/svr4_siginfo.h
@@ -0,0 +1,110 @@
+/* $NetBSD: svr4_siginfo.h,v 1.2 1995/07/04 19:47:05 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.
+ */
+
+#ifndef _SVR4_SIGINFO_H_
+#define _SVR4_SIGINFO_H_
+
+#define SVR4_ILL_ILLOPC 1
+#define SVR4_ILL_ILLOPN 2
+#define SVR4_ILL_ILLADR 3
+#define SVR4_ILL_ILLTRP 4
+#define SVR4_ILL_PRVOPC 5
+#define SVR4_ILL_PRVREG 6
+#define SVR4_ILL_COPROC 7
+#define SVR4_ILL_BADSTK 8
+
+#define SVR4_FPE_INTDIV 1
+#define SVR4_FPE_INTOVF 2
+#define SVR4_FPE_FLTDIV 3
+#define SVR4_FPE_FLTOVF 4
+#define SVR4_FPE_FLTUND 5
+#define SVR4_FPE_FLTRES 6
+#define SVR4_FPE_FLTINV 7
+#define SVR4_FPE_FLTSUB 8
+
+#define SVR4_SEGV_MAPERR 1
+#define SVR4_SEGV_ACCERR 2
+
+#define SVR4_BUS_ADRALN 1
+#define SVR4_BUS_ADRERR 2
+#define SVR4_BUS_OBJERR 3
+
+#define SVR4_TRAP_BRKPT 1
+#define SVR4_TRAP_TRACE 2
+
+#define SVR4_POLL_IN 1
+#define SVR4_POLL_OUT 2
+#define SVR4_POLL_MSG 3
+#define SVR4_POLL_ERR 4
+#define SVR4_POLL_PRI 5
+
+#define SVR4_CLD_EXITED 1
+#define SVR4_CLD_KILLED 2
+#define SVR4_CLD_DUMPED 3
+#define SVR4_CLD_TRAPPED 4
+#define SVR4_CLD_STOPPED 5
+#define SVR4_CLD_CONTINUED 6
+
+#define SVR4_EMT_TAGOVF 1
+
+typedef union svr4_siginfo {
+ char si_pad[128]; /* Total size; for future expansion */
+ struct {
+ int _signo;
+ int _code;
+ int _errno;
+ union {
+ struct {
+ svr4_pid_t _pid;
+ svr4_clock_t _utime;
+ int _status;
+ svr4_clock_t _stime;
+ } _child;
+
+ struct {
+ caddr_t _addr;
+ int _trap;
+ } _fault;
+ } _reason;
+ } _info;
+} svr4_siginfo_t;
+
+#define si_signo _info._signo
+#define si_code _info._code
+#define si_errno _info._errno
+
+#define si_pid _info._reason._child._pid
+#define si_stime _info._reason._child._stime
+#define si_status _info._reason._child._status
+#define si_utime _info._reason._child._utime
+
+#define si_addr _info._reason._fault._addr
+#define si_trap _info._reason._fault._trap
+
+#endif /* !_SVR4_SIGINFO_H_ */
diff --git a/sys/compat/svr4/svr4_signal.c b/sys/compat/svr4/svr4_signal.c
new file mode 100644
index 00000000000..21b65d2962e
--- /dev/null
+++ b/sys/compat/svr4/svr4_signal.c
@@ -0,0 +1,645 @@
+/* $NetBSD: svr4_signal.c,v 1.19 1995/10/07 06:27:46 mycroft 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/namei.h>
+#include <sys/proc.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/kernel.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/malloc.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_ucontext.h>
+
+#define sigemptyset(s) bzero((s), sizeof(*(s)))
+#define sigismember(s, n) (*(s) & sigmask(n))
+#define sigaddset(s, n) (*(s) |= sigmask(n))
+
+#define svr4_sigmask(n) (1 << (((n) - 1) & (32 - 1)))
+#define svr4_sigword(n) (((n) - 1) >> 5)
+#define svr4_sigemptyset(s) bzero((s), sizeof(*(s)))
+#define svr4_sigismember(s, n) ((s)->bits[svr4_sigword(n)] & svr4_sigmask(n))
+#define svr4_sigaddset(s, n) ((s)->bits[svr4_sigword(n)] |= svr4_sigmask(n))
+
+static inline int
+svr4_sigfillset(s)
+ svr4_sigset_t *s;
+{
+ int i;
+
+ svr4_sigemptyset(s);
+ for (i = 1; i < SVR4_NSIG; i++)
+ svr4_sigaddset(s, i);
+}
+
+int bsd_to_svr4_sig[] = {
+ 0,
+ SVR4_SIGHUP,
+ SVR4_SIGINT,
+ SVR4_SIGQUIT,
+ SVR4_SIGILL,
+ SVR4_SIGTRAP,
+ SVR4_SIGABRT,
+ SVR4_SIGEMT,
+ SVR4_SIGFPE,
+ SVR4_SIGKILL,
+ SVR4_SIGBUS,
+ SVR4_SIGSEGV,
+ SVR4_SIGSYS,
+ SVR4_SIGPIPE,
+ SVR4_SIGALRM,
+ SVR4_SIGTERM,
+ SVR4_SIGURG,
+ SVR4_SIGSTOP,
+ SVR4_SIGTSTP,
+ SVR4_SIGCONT,
+ SVR4_SIGCHLD,
+ SVR4_SIGTTIN,
+ SVR4_SIGTTOU,
+ SVR4_SIGIO,
+ SVR4_SIGXCPU,
+ SVR4_SIGXFSZ,
+ SVR4_SIGVTALRM,
+ SVR4_SIGPROF,
+ SVR4_SIGWINCH,
+ 0,
+ SVR4_SIGUSR1,
+ SVR4_SIGUSR2,
+};
+
+int svr4_to_bsd_sig[] = {
+ 0,
+ SIGHUP,
+ SIGINT,
+ SIGQUIT,
+ SIGILL,
+ SIGTRAP,
+ SIGABRT,
+ SIGEMT,
+ SIGFPE,
+ SIGKILL,
+ SIGBUS,
+ SIGSEGV,
+ SIGSYS,
+ SIGPIPE,
+ SIGALRM,
+ SIGTERM,
+ SIGUSR1,
+ SIGUSR2,
+ SIGCHLD,
+ 0,
+ SIGWINCH,
+ SIGURG,
+ SIGIO,
+ SIGSTOP,
+ SIGTSTP,
+ SIGCONT,
+ SIGTTIN,
+ SIGTTOU,
+ SIGVTALRM,
+ SIGPROF,
+ SIGXCPU,
+ SIGXFSZ,
+};
+
+void
+svr4_to_bsd_sigset(sss, bss)
+ const svr4_sigset_t *sss;
+ sigset_t *bss;
+{
+ int i, newsig;
+
+ sigemptyset(bss);
+ for (i = 1; i < SVR4_NSIG; i++) {
+ if (svr4_sigismember(sss, i)) {
+ newsig = svr4_to_bsd_sig[i];
+ if (newsig)
+ sigaddset(bss, newsig);
+ }
+ }
+}
+
+
+void
+bsd_to_svr4_sigset(bss, sss)
+ const sigset_t *bss;
+ svr4_sigset_t *sss;
+{
+ int i, newsig;
+
+ svr4_sigemptyset(sss);
+ for (i = 1; i < NSIG; i++) {
+ if (sigismember(bss, i)) {
+ newsig = bsd_to_svr4_sig[i];
+ if (newsig)
+ svr4_sigaddset(sss, newsig);
+ }
+ }
+}
+
+/*
+ * XXX: Only a subset of the flags is currently implemented.
+ */
+void
+svr4_to_bsd_sigaction(ssa, bsa)
+ const struct svr4_sigaction *ssa;
+ struct sigaction *bsa;
+{
+
+ bsa->sa_handler = ssa->sa_handler;
+ svr4_to_bsd_sigset(&ssa->sa_mask, &bsa->sa_mask);
+ bsa->sa_flags = 0;
+ if ((ssa->sa_flags & SVR4_SA_ONSTACK) != 0)
+ bsa->sa_flags |= SA_ONSTACK;
+ if ((ssa->sa_flags & SVR4_SA_RESTART) != 0)
+ bsa->sa_flags |= SA_RESTART;
+ if ((ssa->sa_flags & SVR4_SA_RESETHAND) != 0)
+ bsa->sa_flags |= SA_RESETHAND;
+ if ((ssa->sa_flags & SVR4_SA_NOCLDSTOP) != 0)
+ bsa->sa_flags |= SA_NOCLDSTOP;
+ if ((ssa->sa_flags & SVR4_SA_NODEFER) != 0)
+ bsa->sa_flags |= SA_NODEFER;
+}
+
+void
+bsd_to_svr4_sigaction(bsa, ssa)
+ const struct sigaction *bsa;
+ struct svr4_sigaction *ssa;
+{
+
+ ssa->sa_handler = bsa->sa_handler;
+ bsd_to_svr4_sigset(&bsa->sa_mask, &ssa->sa_mask);
+ ssa->sa_flags = 0;
+ if ((bsa->sa_flags & SA_ONSTACK) != 0)
+ ssa->sa_flags |= SA_ONSTACK;
+ if ((bsa->sa_flags & SA_RESETHAND) != 0)
+ ssa->sa_flags |= SA_RESETHAND;
+ if ((bsa->sa_flags & SA_RESTART) != 0)
+ ssa->sa_flags |= SA_RESTART;
+ if ((bsa->sa_flags & SA_NODEFER) != 0)
+ ssa->sa_flags |= SA_NODEFER;
+ if ((bsa->sa_flags & SA_NOCLDSTOP) != 0)
+ ssa->sa_flags |= SA_NOCLDSTOP;
+}
+
+void
+svr4_to_bsd_sigaltstack(sss, bss)
+ const struct svr4_sigaltstack *sss;
+ struct sigaltstack *bss;
+{
+
+ bss->ss_base = sss->ss_sp;
+ bss->ss_size = sss->ss_size;
+ bss->ss_flags = 0;
+
+ if ((sss->ss_flags & SVR4_SS_DISABLE) != 0)
+ bss->ss_flags |= SS_DISABLE;
+ if ((sss->ss_flags & SVR4_SS_ONSTACK) != 0)
+ bss->ss_flags |= SS_ONSTACK;
+}
+
+void
+bsd_to_svr4_sigaltstack(bss, sss)
+ const struct sigaltstack *bss;
+ struct svr4_sigaltstack *sss;
+{
+
+ sss->ss_sp = bss->ss_base;
+ sss->ss_size = bss->ss_size;
+ sss->ss_flags = 0;
+
+ if ((bss->ss_flags & SS_DISABLE) != 0)
+ sss->ss_flags |= SVR4_SS_DISABLE;
+ if ((bss->ss_flags & SS_ONSTACK) != 0)
+ sss->ss_flags |= SVR4_SS_ONSTACK;
+}
+
+int
+svr4_sys_sigaction(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_sigaction_args /* {
+ syscallarg(int) signum;
+ syscallarg(struct svr4_sigaction *) nsa;
+ syscallarg(struct svr4_sigaction *) osa;
+ } */ *uap = v;
+ struct svr4_sigaction *nssa, *ossa, tmpssa;
+ struct sigaction *nbsa, *obsa, tmpbsa;
+ struct sys_sigaction_args sa;
+ caddr_t sg;
+ int error;
+
+ sg = stackgap_init(p->p_emul);
+ nssa = SCARG(uap, nsa);
+ ossa = SCARG(uap, osa);
+
+ if (ossa != NULL)
+ obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ else
+ obsa = NULL;
+
+ if (nssa != NULL) {
+ nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ if ((error = copyin(nssa, &tmpssa, sizeof(tmpssa))) != 0)
+ return error;
+ svr4_to_bsd_sigaction(&tmpssa, &tmpbsa);
+ if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0)
+ return error;
+ } else
+ nbsa = NULL;
+
+ SCARG(&sa, signum) = svr4_to_bsd_sig[SCARG(uap, signum)];
+ SCARG(&sa, nsa) = nbsa;
+ SCARG(&sa, osa) = obsa;
+
+ if ((error = sys_sigaction(p, &sa, retval)) != 0)
+ return error;
+
+ if (ossa != NULL) {
+ if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0)
+ return error;
+ bsd_to_svr4_sigaction(&tmpbsa, &tmpssa);
+ if ((error = copyout(&tmpssa, ossa, sizeof(tmpssa))) != 0)
+ return error;
+ }
+
+ return 0;
+}
+
+int
+svr4_sys_sigaltstack(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_sigaltstack_args /* {
+ syscallarg(struct svr4_sigaltstack *) nss;
+ syscallarg(struct svr4_sigaltstack *) oss;
+ } */ *uap = v;
+ struct svr4_sigaltstack *nsss, *osss, tmpsss;
+ struct sigaltstack *nbss, *obss, tmpbss;
+ struct sys_sigaltstack_args sa;
+ caddr_t sg;
+ int error;
+
+ sg = stackgap_init(p->p_emul);
+ nsss = SCARG(uap, nss);
+ osss = SCARG(uap, oss);
+
+ if (osss != NULL)
+ obss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
+ else
+ obss = NULL;
+
+ if (nsss != NULL) {
+ nbss = stackgap_alloc(&sg, sizeof(struct sigaltstack));
+ if ((error = copyin(nsss, &tmpsss, sizeof(tmpsss))) != 0)
+ return error;
+ svr4_to_bsd_sigaltstack(&tmpsss, &tmpbss);
+ if ((error = copyout(&tmpbss, nbss, sizeof(tmpbss))) != 0)
+ return error;
+ } else
+ nbss = NULL;
+
+ SCARG(&sa, nss) = nbss;
+ SCARG(&sa, oss) = obss;
+
+ if ((error = sys_sigaltstack(p, &sa, retval)) != 0)
+ return error;
+
+ if (obss != NULL) {
+ if ((error = copyin(obss, &tmpbss, sizeof(tmpbss))) != 0)
+ return error;
+ bsd_to_svr4_sigaltstack(&tmpbss, &tmpsss);
+ if ((error = copyout(&tmpsss, osss, sizeof(tmpsss))) != 0)
+ return error;
+ }
+
+ return 0;
+}
+
+/*
+ * Stolen from the ibcs2 one
+ */
+int
+svr4_sys_signal(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_signal_args /* {
+ syscallarg(int) signum;
+ syscallarg(svr4_sig_t) handler;
+ } */ *uap = v;
+ int signum = svr4_to_bsd_sig[SVR4_SIGNO(SCARG(uap, signum))];
+ int error;
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ if (signum <= 0 || signum >= SVR4_NSIG) {
+ if (SVR4_SIGCALL(SCARG(uap, signum)) == SVR4_SIGNAL_MASK ||
+ SVR4_SIGCALL(SCARG(uap, signum)) == SVR4_SIGDEFER_MASK)
+ *retval = (int)SVR4_SIG_ERR;
+ return EINVAL;
+ }
+
+ switch (SVR4_SIGCALL(SCARG(uap, signum))) {
+ case SVR4_SIGDEFER_MASK:
+ /*
+ * sigset is identical to signal() except
+ * that SIG_HOLD is allowed as
+ * an action.
+ */
+ if (SCARG(uap, handler) == SVR4_SIG_HOLD) {
+ struct sys_sigprocmask_args sa;
+
+ SCARG(&sa, how) = SIG_BLOCK;
+ SCARG(&sa, mask) = sigmask(signum);
+ return sys_sigprocmask(p, &sa, retval);
+ }
+ /* FALLTHROUGH */
+
+ case SVR4_SIGNAL_MASK:
+ {
+ struct sys_sigaction_args sa_args;
+ struct sigaction *nbsa, *obsa, sa;
+
+ nbsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ SCARG(&sa_args, signum) = signum;
+ SCARG(&sa_args, nsa) = nbsa;
+ SCARG(&sa_args, osa) = obsa;
+
+ sa.sa_handler = SCARG(uap, handler);
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+#if 0
+ if (signum != SIGALRM)
+ sa.sa_flags = SA_RESTART;
+#endif
+ if ((error = copyout(&sa, nbsa, sizeof(sa))) != 0)
+ return error;
+ if ((error = sys_sigaction(p, &sa_args, retval)) != 0) {
+ DPRINTF(("signal: sigaction failed: %d\n",
+ error));
+ *retval = (int)SVR4_SIG_ERR;
+ return error;
+ }
+ if ((error = copyin(obsa, &sa, sizeof(sa))) != 0)
+ return error;
+ *retval = (int)sa.sa_handler;
+ return 0;
+ }
+
+ case SVR4_SIGHOLD_MASK:
+ {
+ struct sys_sigprocmask_args sa;
+
+ SCARG(&sa, how) = SIG_BLOCK;
+ SCARG(&sa, mask) = sigmask(signum);
+ return sys_sigprocmask(p, &sa, retval);
+ }
+
+ case SVR4_SIGRELSE_MASK:
+ {
+ struct sys_sigprocmask_args sa;
+
+ SCARG(&sa, how) = SIG_UNBLOCK;
+ SCARG(&sa, mask) = sigmask(signum);
+ return sys_sigprocmask(p, &sa, retval);
+ }
+
+ case SVR4_SIGIGNORE_MASK:
+ {
+ struct sys_sigaction_args sa_args;
+ struct sigaction *bsa, sa;
+
+ bsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ SCARG(&sa_args, signum) = signum;
+ SCARG(&sa_args, nsa) = bsa;
+ SCARG(&sa_args, osa) = NULL;
+
+ sa.sa_handler = SIG_IGN;
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = 0;
+ if ((error = copyout(&sa, bsa, sizeof(sa))) != 0)
+ return error;
+ if ((error = sys_sigaction(p, &sa_args, retval)) != 0) {
+ DPRINTF(("sigignore: sigaction failed\n"));
+ return error;
+ }
+ return 0;
+ }
+
+ case SVR4_SIGPAUSE_MASK:
+ {
+ struct sys_sigsuspend_args sa;
+
+ SCARG(&sa, mask) = p->p_sigmask & ~sigmask(signum);
+ return sys_sigsuspend(p, &sa, retval);
+ }
+
+ default:
+ return ENOSYS;
+ }
+}
+
+int
+svr4_sys_sigprocmask(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_sigprocmask_args /* {
+ syscallarg(int) how;
+ syscallarg(svr4_sigset_t *) set;
+ syscallarg(svr4_sigset_t *) oset;
+ } */ *uap = v;
+ svr4_sigset_t sss;
+ sigset_t bss;
+ int error = 0;
+
+ if (SCARG(uap, oset) != NULL) {
+ /* Fix the return value first if needed */
+ bsd_to_svr4_sigset(&p->p_sigmask, &sss);
+ if ((error = copyout(&sss, SCARG(uap, oset), sizeof(sss))) != 0)
+ return error;
+ }
+
+ if (SCARG(uap, set) == NULL)
+ /* Just examine */
+ return 0;
+
+ if ((error = copyin(SCARG(uap, set), &sss, sizeof(sss))) != 0)
+ return error;
+
+ svr4_to_bsd_sigset(&sss, &bss);
+
+ (void) splhigh();
+
+ switch (SCARG(uap, how)) {
+ case SVR4_SIG_BLOCK:
+ p->p_sigmask |= bss & ~sigcantmask;
+ break;
+
+ case SVR4_SIG_UNBLOCK:
+ p->p_sigmask &= ~bss;
+ break;
+
+ case SVR4_SIG_SETMASK:
+ p->p_sigmask = bss & ~sigcantmask;
+ break;
+
+ default:
+ error = EINVAL;
+ break;
+ }
+
+ (void) spl0();
+
+ return error;
+}
+
+int
+svr4_sys_sigpending(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_sigpending_args /* {
+ syscallarg(int) what;
+ syscallarg(svr4_sigset_t *) mask;
+ } */ *uap = v;
+ sigset_t bss;
+ svr4_sigset_t sss;
+
+ switch (SCARG(uap, what)) {
+ case 1: /* sigpending */
+ if (SCARG(uap, mask) == NULL)
+ return 0;
+ bss = p->p_siglist & p->p_sigmask;
+ bsd_to_svr4_sigset(&bss, &sss);
+ break;
+
+ case 2: /* sigfillset */
+ svr4_sigfillset(&sss);
+ break;
+
+ default:
+ return EINVAL;
+ }
+
+ return copyout(&sss, SCARG(uap, mask), sizeof(sss));
+}
+
+int
+svr4_sys_sigsuspend(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_sigsuspend_args /* {
+ syscallarg(svr4_sigset_t *) ss;
+ } */ *uap = v;
+ svr4_sigset_t sss;
+ sigset_t bss;
+ struct sys_sigsuspend_args sa;
+ int error;
+
+ if ((error = copyin(SCARG(uap, ss), &sss, sizeof(sss))) != 0)
+ return error;
+
+ svr4_to_bsd_sigset(&sss, &bss);
+
+ SCARG(&sa, mask) = bss;
+ return sys_sigsuspend(p, &sa, retval);
+}
+
+int
+svr4_sys_kill(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_kill_args /* {
+ syscallarg(int) pid;
+ syscallarg(int) signum;
+ } */ *uap = v;
+ struct sys_kill_args ka;
+
+ SCARG(&ka, pid) = SCARG(uap, pid);
+ SCARG(&ka, signum) = svr4_to_bsd_sig[SCARG(uap, signum)];
+ return sys_kill(p, &ka, retval);
+}
+
+int
+svr4_sys_context(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_context_args /* {
+ syscallarg(int) func;
+ syscallarg(struct svr4_ucontext *) uc;
+ } */ *uap = v;
+ struct svr4_ucontext uc;
+ int error;
+ *retval = 0;
+
+ switch (SCARG(uap, func)) {
+ case 0:
+ DPRINTF(("getcontext(%x)\n", SCARG(uap, uc)));
+ svr4_getcontext(p, &uc, p->p_sigmask,
+ p->p_sigacts->ps_sigstk.ss_flags & SS_ONSTACK);
+ return copyout(&uc, SCARG(uap, uc), sizeof(uc));
+
+ case 1:
+ DPRINTF(("setcontext(%x)\n", SCARG(uap, uc)));
+ if ((error = copyin(SCARG(uap, uc), &uc, sizeof(uc))) != 0)
+ return error;
+ return svr4_setcontext(p, &uc);
+
+ default:
+ DPRINTF(("context(%d, %x)\n", SCARG(uap, func),
+ SCARG(uap, uc)));
+ return ENOSYS;
+ }
+ return 0;
+}
diff --git a/sys/compat/svr4/svr4_signal.h b/sys/compat/svr4/svr4_signal.h
new file mode 100644
index 00000000000..8dfeee42749
--- /dev/null
+++ b/sys/compat/svr4/svr4_signal.h
@@ -0,0 +1,128 @@
+/* $NetBSD: svr4_signal.h,v 1.13 1995/08/14 02:22:20 mycroft 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.
+ */
+
+#ifndef _SVR4_SIGNAL_H_
+#define _SVR4_SIGNAL_H_
+
+#include <compat/svr4/svr4_siginfo.h>
+
+#define SVR4_SIGHUP 1
+#define SVR4_SIGINT 2
+#define SVR4_SIGQUIT 3
+#define SVR4_SIGILL 4
+#define SVR4_SIGTRAP 5
+#define SVR4_SIGIOT 6
+#define SVR4_SIGABRT 6
+#define SVR4_SIGEMT 7
+#define SVR4_SIGFPE 8
+#define SVR4_SIGKILL 9
+#define SVR4_SIGBUS 10
+#define SVR4_SIGSEGV 11
+#define SVR4_SIGSYS 12
+#define SVR4_SIGPIPE 13
+#define SVR4_SIGALRM 14
+#define SVR4_SIGTERM 15
+#define SVR4_SIGUSR1 16
+#define SVR4_SIGUSR2 17
+#define SVR4_SIGCLD 18
+#define SVR4_SIGCHLD 18
+#define SVR4_SIGPWR 19
+#define SVR4_SIGWINCH 20
+#define SVR4_SIGURG 21
+#define SVR4_SIGPOLL 22
+#define SVR4_SIGIO 22
+#define SVR4_SIGSTOP 23
+#define SVR4_SIGTSTP 24
+#define SVR4_SIGCONT 25
+#define SVR4_SIGTTIN 26
+#define SVR4_SIGTTOU 27
+#define SVR4_SIGVTALRM 28
+#define SVR4_SIGPROF 29
+#define SVR4_SIGXCPU 30
+#define SVR4_SIGXFSZ 31
+#define SVR4_NSIG 32
+
+#define SVR4_SIGNO_MASK 0x00FF
+#define SVR4_SIGNAL_MASK 0x0000
+#define SVR4_SIGDEFER_MASK 0x0100
+#define SVR4_SIGHOLD_MASK 0x0200
+#define SVR4_SIGRELSE_MASK 0x0400
+#define SVR4_SIGIGNORE_MASK 0x0800
+#define SVR4_SIGPAUSE_MASK 0x1000
+
+#define SVR4_SIGNO(x) ((x) & SVR4_SIGNO_MASK)
+#define SVR4_SIGCALL(x) ((x) & ~SVR4_SIGNO_MASK)
+
+#define SVR4_SIG_DFL (void(*)())0
+#define SVR4_SIG_ERR (void(*)())-1
+#define SVR4_SIG_IGN (void(*)())1
+#define SVR4_SIG_HOLD (void(*)())2
+
+#define SVR4_SIG_BLOCK 1
+#define SVR4_SIG_UNBLOCK 2
+#define SVR4_SIG_SETMASK 3
+
+typedef struct {
+ u_long bits[4];
+} svr4_sigset_t;
+typedef void (*svr4_sig_t) __P((int));
+
+struct svr4_sigaction {
+ int sa_flags;
+ svr4_sig_t sa_handler;
+ svr4_sigset_t sa_mask;
+ int sa_reserved[2];
+};
+
+struct svr4_sigaltstack {
+ char *ss_sp;
+ int ss_size;
+ int ss_flags;
+};
+
+/* sa_flags */
+#define SVR4_SA_ONSTACK 0x00000001
+#define SVR4_SA_RESETHAND 0x00000002
+#define SVR4_SA_RESTART 0x00000004
+#define SVR4_SA_SIGINFO 0x00000008
+#define SVR4_SA_NODEFER 0x00000010
+#define SVR4_SA_NOCLDWAIT 0x00010000 /* No zombies */
+#define SVR4_SA_NOCLDSTOP 0x00020000 /* No jcl */
+
+/* ss_flags */
+#define SVR4_SS_ONSTACK 0x00000001
+#define SVR4_SS_DISABLE 0x00000002
+
+extern int bsd_to_svr4_sig[];
+void bsd_to_svr4_sigaltstack __P((const struct sigaltstack *, struct svr4_sigaltstack *));
+void bsd_to_svr4_sigset __P((const sigset_t *, svr4_sigset_t *));
+void svr4_to_bsd_sigaltstack __P((const struct svr4_sigaltstack *, struct sigaltstack *));
+void svr4_to_bsd_sigset __P((const svr4_sigset_t *, sigset_t *));
+
+#endif /* !_SVR4_SIGNAL_H_ */
diff --git a/sys/compat/svr4/svr4_sockio.c b/sys/compat/svr4/svr4_sockio.c
new file mode 100644
index 00000000000..5251ac761f9
--- /dev/null
+++ b/sys/compat/svr4/svr4_sockio.c
@@ -0,0 +1,144 @@
+/* $NetBSD: svr4_sockio.c,v 1.5 1995/10/07 06:27:48 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1995 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/proc.h>
+#include <sys/systm.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/termios.h>
+#include <sys/tty.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <net/if.h>
+#include <sys/malloc.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_stropts.h>
+#include <compat/svr4/svr4_ioctl.h>
+#include <compat/svr4/svr4_sockio.h>
+
+static int bsd_to_svr4_flags __P((int));
+
+#define bsd_to_svr4_flag(a) \
+ if (bf & __CONCAT(I,a)) sf |= __CONCAT(SVR4_I,a)
+
+static int
+bsd_to_svr4_flags(bf)
+ int bf;
+{
+ int sf = 0;
+ bsd_to_svr4_flag(FF_UP);
+ bsd_to_svr4_flag(FF_BROADCAST);
+ bsd_to_svr4_flag(FF_DEBUG);
+ bsd_to_svr4_flag(FF_LOOPBACK);
+ bsd_to_svr4_flag(FF_POINTOPOINT);
+ bsd_to_svr4_flag(FF_NOTRAILERS);
+ bsd_to_svr4_flag(FF_RUNNING);
+ bsd_to_svr4_flag(FF_NOARP);
+ bsd_to_svr4_flag(FF_PROMISC);
+ bsd_to_svr4_flag(FF_ALLMULTI);
+ bsd_to_svr4_flag(FF_MULTICAST);
+ return sf;
+}
+
+int
+svr4_sockioctl(fp, cmd, data, p, retval)
+ struct file *fp;
+ u_long cmd;
+ caddr_t data;
+ struct proc *p;
+ register_t *retval;
+{
+ struct filedesc *fdp = p->p_fd;
+ caddr_t sg = stackgap_init(p->p_emul);
+ int error;
+ int fd;
+ int num;
+ int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
+ fp->f_ops->fo_ioctl;
+
+ *retval = 0;
+
+ switch (cmd) {
+ case SVR4_SIOCGIFNUM:
+ {
+ extern int if_index;
+
+ DPRINTF(("SIOCGIFNUM %d\n", if_index));
+ return copyout(&if_index, data, sizeof(if_index));
+ }
+
+ case SVR4_SIOCGIFFLAGS:
+ {
+ struct ifreq br;
+ struct svr4_ifreq sr;
+
+ if ((error = copyin(data, &sr, sizeof(sr))) != 0)
+ return error;
+
+ (void) strcpy(br.ifr_name, sr.svr4_ifr_name);
+ if ((error = (*ctl)(fp, SIOCGIFFLAGS,
+ (caddr_t) &br, p)) != 0)
+ return error;
+
+ sr.svr4_ifr_flags = bsd_to_svr4_flags(br.ifr_flags);
+ DPRINTF(("SIOCGIFFLAGS %s = %d\n",
+ sr.svr4_ifr_name, sr.svr4_ifr_flags));
+ return 0;
+ }
+
+ case SVR4_SIOCGIFCONF:
+ {
+ struct svr4_ifconf sc;
+
+ if ((error = copyin(data, &sc, sizeof(sc))) != 0)
+ return error;
+
+ if ((error = (*ctl)(fp, OSIOCGIFCONF,
+ (caddr_t) &sc, p)) != 0)
+ return error;
+
+ DPRINTF(("SIOCGIFCONF\n"));
+ return 0;
+ }
+
+
+ default:
+ DPRINTF(("Unknown svr4 sockio %x\n", cmd));
+ return 0; /* ENOSYS really */
+ }
+}
diff --git a/sys/compat/svr4/svr4_sockio.h b/sys/compat/svr4/svr4_sockio.h
new file mode 100644
index 00000000000..efa9db8f3ca
--- /dev/null
+++ b/sys/compat/svr4/svr4_sockio.h
@@ -0,0 +1,92 @@
+/* $NetBSD: svr4_sockio.h,v 1.2 1995/07/04 23:00:13 christos Exp $ */
+
+/*
+ * Copyright (c) 1995 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.
+ */
+
+#ifndef _SVR4_SOCKIO_H_
+#define _SVR4_SOCKIO_H_
+
+#define SVR4_IFF_UP 0x0001
+#define SVR4_IFF_BROADCAST 0x0002
+#define SVR4_IFF_DEBUG 0x0004
+#define SVR4_IFF_LOOPBACK 0x0008
+#define SVR4_IFF_POINTOPOINT 0x0010
+#define SVR4_IFF_NOTRAILERS 0x0020
+#define SVR4_IFF_RUNNING 0x0040
+#define SVR4_IFF_NOARP 0x0080
+#define SVR4_IFF_PROMISC 0x0100
+#define SVR4_IFF_ALLMULTI 0x0200
+#define SVR4_IFF_INTELLIGENT 0x0400
+#define SVR4_IFF_MULTICAST 0x0800
+#define SVR4_IFF_MULTI_BCAST 0x1000
+#define SVR4_IFF_UNNUMBERED 0x2000
+#define SVR4_IFF_PRIVATE 0x8000
+
+struct svr4_ifreq {
+#define SVR4_IFNAMSIZ 16
+ char svr4_ifr_name[SVR4_IFNAMSIZ];
+ union {
+ struct osockaddr ifru_addr;
+ struct osockaddr ifru_dstaddr;
+ struct osockaddr ifru_broadaddr;
+ short ifru_flags;
+ int ifru_metric;
+ char ifru_data;
+ char ifru_enaddr[6];
+ int if_muxid[2];
+
+ } ifr_ifru;
+
+#define svr4_ifr_addr ifr_ifru.ifru_addr
+#define svr4_ifr_dstaddr ifr_ifru.ifru_dstaddr
+#define svr4_ifr_broadaddr ifr_ifru.ifru_broadaddr
+#define svr4_ifr_flags ifr_ifru.ifru_flags
+#define svr4_ifr_metric ifr_ifru.ifru_metric
+#define svr4_ifr_data ifr_ifru.ifru_data
+#define svr4_ifr_enaddr ifr_ifru.ifru_enaddr
+#define svr4_ifr_muxid ifr_ifru.ifru_muxid
+
+};
+
+struct svr4_ifconf {
+ int svr4_ifc_len;
+ union {
+ caddr_t ifcu_buf;
+ struct svr4_ifreq *ifcu_req;
+ } ifc_ifcu;
+
+#define svr4_ifc_buf ifc_ifcu.ifcu_buf
+#define svr4_ifc_req ifc_ifcu.ifcu_req
+};
+
+#define SVR4_SIOC ('i' << 8)
+
+#define SVR4_SIOCGIFFLAGS SVR4_IOWR('i', 17, struct svr4_ifreq)
+#define SVR4_SIOCGIFCONF SVR4_IOWR('i', 20, struct svr4_ifconf)
+#define SVR4_SIOCGIFNUM SVR4_IOR('i', 87, int)
+
+#endif /* !_SVR4_SOCKIO_H_ */
diff --git a/sys/compat/svr4/svr4_sockmod.h b/sys/compat/svr4/svr4_sockmod.h
new file mode 100644
index 00000000000..89983b4cd63
--- /dev/null
+++ b/sys/compat/svr4/svr4_sockmod.h
@@ -0,0 +1,78 @@
+/* $NetBSD: svr4_sockmod.h,v 1.3 1995/03/31 03:06:32 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.
+ */
+
+#ifndef _SVR4_SOCKMOD_H_
+#define _SVR4_SOCKMOD_H_
+
+#define SVR4_SIMOD ('I' << 8)
+
+#define SVR4_SI_OGETUDATA (SVR4_SIMOD|101)
+#define SVR4_SI_SHUTDOWN (SVR4_SIMOD|102)
+#define SVR4_SI_LISTEN (SVR4_SIMOD|103)
+#define SVR4_SI_SETMYNAME (SVR4_SIMOD|104)
+#define SVR4_SI_SETPEERNAME (SVR4_SIMOD|105)
+#define SVR4_SI_GETINTRANSIT (SVR4_SIMOD|106)
+#define SVR4_SI_TCL_LINK (SVR4_SIMOD|107)
+#define SVR4_SI_TCL_UNLINK (SVR4_SIMOD|108)
+#define SVR4_SI_SOCKPARAMS (SVR4_SIMOD|109)
+#define SVR4_SI_GETUDATA (SVR4_SIMOD|110)
+
+
+#define SVR4_SOCK_RAW 1
+#define SVR4_SOCK_STREAM 2
+#define SVR4_SOCK_DGRAM 3
+
+struct svr4_si_sockparms {
+ int family;
+ int type;
+ int protocol;
+};
+
+struct svr4_si_oudata {
+ int tidusize;
+ int addrsize;
+ int optsize;
+ int etsdusize;
+ int servtype;
+ int so_state;
+ int so_options;
+};
+
+struct svr4_si_udata {
+ int tidusize;
+ int addrsize;
+ int optsize;
+ int etsdusize;
+ int servtype;
+ int so_state;
+ int so_options;
+ int tsdusize;
+ struct svr4_si_sockparms sockparms;
+};
+#endif /* !_SVR4_SOCKMOD_H_ */
diff --git a/sys/compat/svr4/svr4_stat.c b/sys/compat/svr4/svr4_stat.c
new file mode 100644
index 00000000000..b49e517b4fa
--- /dev/null
+++ b/sys/compat/svr4/svr4_stat.c
@@ -0,0 +1,503 @@
+/* $NetBSD: svr4_stat.c,v 1.13 1995/10/07 06:27:49 mycroft 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/namei.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/mount.h>
+#include <sys/malloc.h>
+
+#include <sys/time.h>
+#include <sys/ucred.h>
+#include <vm/vm.h>
+#include <sys/sysctl.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_stat.h>
+#include <compat/svr4/svr4_ustat.h>
+#include <compat/svr4/svr4_fuser.h>
+#include <compat/svr4/svr4_utsname.h>
+#include <compat/svr4/svr4_systeminfo.h>
+
+#define syscallarg(x) union { x datum; register_t pad; }
+
+#ifdef sparc
+/*
+ * Solaris-2.4 on the sparc has the old stat call using the new
+ * stat data structure...
+ */
+# define SVR4_NO_OSTAT
+#endif
+
+static void
+bsd_to_svr4_stat(st, st4)
+ struct stat *st;
+ struct svr4_stat *st4;
+{
+ bzero(st4, sizeof(*st4));
+ st4->st_dev = st->st_dev;
+ st4->st_ino = st->st_ino;
+ st4->st_mode = st->st_mode;
+ st4->st_nlink = st->st_nlink;
+ st4->st_uid = st->st_uid;
+ st4->st_gid = st->st_gid;
+ st4->st_rdev = st->st_rdev;
+ st4->st_size = st->st_size;
+ st4->st_atim = st->st_atimespec.ts_sec;
+ st4->st_mtim = st->st_mtimespec.ts_sec;
+ st4->st_ctim = st->st_ctimespec.ts_sec;
+}
+
+
+static void
+bsd_to_svr4_xstat(st, st4)
+ struct stat *st;
+ struct svr4_xstat *st4;
+{
+ bzero(st4, sizeof(*st4));
+ st4->st_dev = st->st_dev;
+ st4->st_ino = st->st_ino;
+ st4->st_mode = st->st_mode;
+ st4->st_nlink = st->st_nlink;
+ st4->st_uid = st->st_uid;
+ st4->st_gid = st->st_gid;
+ st4->st_rdev = st->st_rdev;
+ st4->st_size = st->st_size;
+ st4->st_atim = st->st_atimespec;
+ st4->st_mtim = st->st_mtimespec;
+ st4->st_ctim = st->st_ctimespec;
+ st4->st_blksize = st->st_blksize;
+ st4->st_blocks = st->st_blocks;
+ strcpy(st4->st_fstype, "unknown");
+}
+
+
+int
+svr4_sys_stat(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_stat_args *uap = v;
+#ifdef SVR4_NO_OSTAT
+ struct svr4_sys_xstat_args cup;
+
+ SCARG(&cup, two) = 2;
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, ub) = (struct svr4_xstat *) SCARG(uap, ub);
+ return svr4_sys_xstat(p, &cup, retval);
+#else
+ struct stat st;
+ struct svr4_stat svr4_st;
+ struct sys_stat_args cup;
+ int error;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
+
+
+ if ((error = sys_stat(p, &cup, retval)) != 0)
+ return error;
+
+ if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
+ return error;
+
+ bsd_to_svr4_stat(&st, &svr4_st);
+
+ if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
+ return error;
+
+ return 0;
+#endif
+}
+
+int
+svr4_sys_lstat(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_lstat_args *uap = v;
+#ifdef SVR4_NO_OSTAT
+ struct svr4_sys_lxstat_args cup;
+
+ SCARG(&cup, two) = 2;
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, ub) = (struct svr4_xstat *) SCARG(uap, ub);
+ return svr4_sys_lxstat(p, &cup, retval);
+#else
+ struct stat st;
+ struct svr4_stat svr4_st;
+ struct sys_lstat_args cup;
+ int error;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
+
+ if ((error = sys_lstat(p, &cup, retval)) != 0)
+ return error;
+
+ if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
+ return error;
+
+ bsd_to_svr4_stat(&st, &svr4_st);
+
+ if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
+ return error;
+
+ return 0;
+#endif
+}
+
+int
+svr4_sys_fstat(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_fstat_args *uap = v;
+#ifdef SVR4_NO_OSTAT
+ struct svr4_sys_fxstat_args cup;
+
+ SCARG(&cup, two) = 2;
+ SCARG(&cup, fd) = SCARG(uap, fd);
+ SCARG(&cup, sb) = (struct svr4_xstat *) SCARG(uap, sb);
+ return svr4_sys_fxstat(p, &cup, retval);
+#else
+ struct stat st;
+ struct svr4_stat svr4_st;
+ struct sys_fstat_args cup;
+ int error;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ SCARG(&cup, fd) = SCARG(uap, fd);
+ SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
+
+ if ((error = sys_fstat(p, &cup, retval)) != 0)
+ return error;
+
+ if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
+ return error;
+
+ bsd_to_svr4_stat(&st, &svr4_st);
+
+ if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
+ return error;
+
+ return 0;
+#endif
+}
+
+
+int
+svr4_sys_xstat(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_xstat_args *uap = v;
+ struct stat st;
+ struct svr4_xstat svr4_st;
+ struct sys_stat_args cup;
+ int error;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
+
+ if ((error = sys_stat(p, &cup, retval)) != 0)
+ return error;
+
+ if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
+ return error;
+
+ bsd_to_svr4_xstat(&st, &svr4_st);
+
+ if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
+ return error;
+
+ return 0;
+}
+
+int
+svr4_sys_lxstat(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_lxstat_args *uap = v;
+ struct stat st;
+ struct svr4_xstat svr4_st;
+ struct sys_lstat_args cup;
+ int error;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+ SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
+
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat));
+
+ if ((error = sys_lstat(p, &cup, retval)) != 0)
+ return error;
+
+ if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0)
+ return error;
+
+ bsd_to_svr4_xstat(&st, &svr4_st);
+
+ if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0)
+ return error;
+
+ return 0;
+}
+
+int
+svr4_sys_fxstat(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_fxstat_args *uap = v;
+ struct stat st;
+ struct svr4_xstat svr4_st;
+ struct sys_fstat_args cup;
+ int error;
+
+ caddr_t sg = stackgap_init(p->p_emul);
+
+ SCARG(&cup, fd) = SCARG(uap, fd);
+ SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat));
+
+ if ((error = sys_fstat(p, &cup, retval)) != 0)
+ return error;
+
+ if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0)
+ return error;
+
+ bsd_to_svr4_xstat(&st, &svr4_st);
+
+ if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0)
+ return error;
+
+ return 0;
+}
+
+struct svr4_ustat_args {
+ syscallarg(svr4_dev_t) dev;
+ syscallarg(struct svr4_ustat *) name;
+};
+
+int
+svr4_ustat(p, uap, retval)
+ register struct proc *p;
+ struct svr4_ustat_args /* {
+ syscallarg(svr4_dev_t) dev;
+ syscallarg(struct svr4_ustat *) name;
+ } */ *uap;
+ register_t *retval;
+{
+ struct svr4_ustat us;
+ int error;
+
+ bzero(&us, sizeof us);
+
+ /*
+ * XXX: should set f_tfree and f_tinode at least
+ * How do we translate dev -> fstat? (and then to svr4_ustat)
+ */
+ if (error = copyout(&us, SCARG(uap, name), sizeof us))
+ return (error);
+
+ return 0;
+}
+
+
+
+int
+svr4_sys_uname(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_uname_args *uap = v;
+ struct svr4_utsname sut;
+ extern char ostype[], hostname[], osrelease[], version[], machine[];
+
+
+ bzero(&sut, sizeof(sut));
+
+ strncpy(sut.sysname, ostype, sizeof(sut.sysname));
+ sut.sysname[sizeof(sut.sysname) - 1] = '\0';
+
+ strncpy(sut.nodename, hostname, sizeof(sut.nodename));
+ sut.nodename[sizeof(sut.nodename) - 1] = '\0';
+
+ strncpy(sut.release, osrelease, sizeof(sut.release));
+ sut.release[sizeof(sut.release) - 1] = '\0';
+
+ strncpy(sut.version, version, sizeof(sut.version));
+ sut.version[sizeof(sut.version) - 1] = '\0';
+
+ strncpy(sut.machine, machine, sizeof(sut.machine));
+ sut.machine[sizeof(sut.machine) - 1] = '\0';
+
+ return copyout((caddr_t) &sut, (caddr_t) SCARG(uap, name),
+ sizeof(struct svr4_utsname));
+}
+
+int
+svr4_sys_systeminfo(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_systeminfo_args *uap = v;
+ char *str;
+ int name;
+ int error;
+ long len;
+ extern char ostype[], hostname[], osrelease[],
+ version[], machine[], domainname[];
+
+ u_int rlen = SCARG(uap, len);
+
+ switch (SCARG(uap, what)) {
+ case SVR4_SI_SYSNAME:
+ str = ostype;
+ break;
+
+ case SVR4_SI_HOSTNAME:
+ str = hostname;
+ break;
+
+ case SVR4_SI_RELEASE:
+ str = osrelease;
+ break;
+
+ case SVR4_SI_VERSION:
+ str = version;
+ break;
+
+ case SVR4_SI_MACHINE:
+ str = machine;
+ break;
+
+ case SVR4_SI_ARCHITECTURE:
+ str = machine;
+ break;
+
+ case SVR4_SI_HW_SERIAL:
+ str = "0";
+ break;
+
+ case SVR4_SI_HW_PROVIDER:
+ str = ostype;
+ break;
+
+ case SVR4_SI_SRPC_DOMAIN:
+ str = domainname;
+ break;
+
+ case SVR4_SI_SET_HOSTNAME:
+ if (error = suser(p->p_ucred, &p->p_acflag))
+ return error;
+ name = KERN_HOSTNAME;
+ return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen);
+
+ case SVR4_SI_SET_SRPC_DOMAIN:
+ if (error = suser(p->p_ucred, &p->p_acflag))
+ return error;
+ name = KERN_DOMAINNAME;
+ return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen);
+
+ default:
+ DPRINTF(("Bad systeminfo command %d\n", SCARG(uap, what)));
+ return ENOSYS;
+ }
+
+ len = strlen(str) + 1;
+ if (len > rlen)
+ len = rlen;
+
+ return copyout(str, SCARG(uap, buf), len);
+}
+
+
+int
+svr4_sys_utssys(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_utssys_args *uap = v;
+
+ switch (SCARG(uap, sel)) {
+ case 0: /* uname(2) */
+ {
+ struct svr4_sys_uname_args ua;
+ SCARG(&ua, name) = SCARG(uap, a1);
+ return svr4_sys_uname(p, &ua, retval);
+ }
+
+ case 2: /* ustat(2) */
+ {
+ struct svr4_ustat_args ua;
+ SCARG(&ua, dev) = (svr4_dev_t) SCARG(uap, a2);
+ SCARG(&ua, name) = SCARG(uap, a1);
+ return svr4_ustat(p, &ua, retval);
+ }
+
+ case 3: /* fusers(2) */
+ return ENOSYS;
+
+ default:
+ return ENOSYS;
+ }
+ return ENOSYS;
+}
diff --git a/sys/compat/svr4/svr4_stat.h b/sys/compat/svr4/svr4_stat.h
new file mode 100644
index 00000000000..7af8232bf4c
--- /dev/null
+++ b/sys/compat/svr4/svr4_stat.h
@@ -0,0 +1,71 @@
+/* $NetBSD: svr4_stat.h,v 1.3 1994/10/29 00:43:27 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.
+ */
+
+#ifndef _SVR4_STAT_H_
+#define _SVR4_STAT_H_
+
+#include <compat/svr4/svr4_types.h>
+#include <sys/stat.h>
+
+struct svr4_stat {
+ svr4_o_dev_t st_dev;
+ svr4_o_ino_t st_ino;
+ svr4_o_mode_t st_mode;
+ svr4_o_nlink_t st_nlink;
+ svr4_o_uid_t st_uid;
+ svr4_o_gid_t st_gid;
+ svr4_o_dev_t st_rdev;
+ svr4_off_t st_size;
+ svr4_time_t st_atim;
+ svr4_time_t st_mtim;
+ svr4_time_t st_ctim;
+};
+
+struct svr4_xstat {
+ svr4_dev_t st_dev;
+ long st_pad1[3];
+ svr4_ino_t st_ino;
+ svr4_mode_t st_mode;
+ svr4_nlink_t st_nlink;
+ svr4_uid_t st_uid;
+ svr4_gid_t st_gid;
+ svr4_dev_t st_rdev;
+ long st_pad2[2];
+ svr4_off_t st_size;
+ long st_pad3;
+ svr4_timestruc_t st_atim;
+ svr4_timestruc_t st_mtim;
+ svr4_timestruc_t st_ctim;
+ long st_blksize;
+ long st_blocks;
+ char st_fstype[16];
+ long st_pad4[8];
+};
+
+#endif /* !_SVR4_STAT_H_ */
diff --git a/sys/compat/svr4/svr4_statvfs.h b/sys/compat/svr4/svr4_statvfs.h
new file mode 100644
index 00000000000..d5f592018ff
--- /dev/null
+++ b/sys/compat/svr4/svr4_statvfs.h
@@ -0,0 +1,54 @@
+/* $NetBSD: svr4_statvfs.h,v 1.1 1995/01/08 21:31:39 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.
+ */
+
+#ifndef _SVR4_STATVFS_H_
+#define _SVR4_STATVFS_H_
+
+typedef struct svr4_statvfs {
+ u_long f_bsize;
+ u_long f_frsize;
+ u_long f_blocks;
+ u_long f_bfree;
+ u_long f_bavail;
+ u_long f_files;
+ u_long f_ffree;
+ u_long f_favail;
+ u_long f_fsid;
+ char f_basetype[16];
+ u_long f_flag;
+ u_long f_namemax;
+ char f_fstr[32];
+ u_long f_filler[16];
+} svr4_statvfs_t;
+
+#define SVR4_ST_RDONLY 0x01
+#define SVR4_ST_NOSUID 0x02
+#define SVR4_ST_NOTRUNC 0x04
+
+#endif /* !_SVR4_STATVFS_H_ */
diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c
new file mode 100644
index 00000000000..f052f7fbc6f
--- /dev/null
+++ b/sys/compat/svr4/svr4_stream.c
@@ -0,0 +1,971 @@
+/* $NetBSD: svr4_stream.c,v 1.9 1995/10/07 06:27:52 mycroft 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.
+ */
+
+/*
+ * Pretend that we have streams...
+ */
+
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/systm.h>
+#include <sys/buf.h>
+#include <sys/malloc.h>
+#include <sys/ioctl.h>
+#include <sys/tty.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/select.h>
+#include <sys/socket.h>
+#include <sys/socketvar.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <sys/mount.h>
+#include <sys/proc.h>
+#include <sys/vnode.h>
+#include <sys/device.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_stropts.h>
+#include <compat/svr4/svr4_timod.h>
+#include <compat/svr4/svr4_sockmod.h>
+#include <compat/svr4/svr4_ioctl.h>
+
+static void svr4_getparm __P((struct socket *, struct svr4_si_sockparms *));
+static int svr4_sockmod __P((struct file *, struct svr4_strioctl *,
+ struct proc *));
+static int svr4_timod __P((struct file *, struct svr4_strioctl *,
+ struct proc *));
+#ifdef DEBUG_SVR4
+static int svr4_showioc __P((const char *, struct svr4_strioctl *));
+static int svr4_getstrbuf __P((struct svr4_strbuf *));
+static void svr4_showmsg __P((const char *, int, struct svr4_strbuf *,
+ struct svr4_strbuf *, int));
+#endif /* DEBUG_SVR4 */
+
+
+static void
+svr4_getparm(so, pa)
+ struct socket *so;
+ struct svr4_si_sockparms *pa;
+{
+ pa->family = AF_INET;
+
+ switch (so->so_type) {
+ case SOCK_DGRAM:
+ pa->type = SVR4_SOCK_DGRAM;
+ pa->protocol = IPPROTO_UDP;
+ return;
+
+ case SOCK_STREAM:
+ pa->type = SVR4_SOCK_STREAM;
+ pa->protocol = IPPROTO_TCP;
+ return;
+
+ case SOCK_RAW:
+ pa->type = SVR4_SOCK_RAW;
+ pa->protocol = IPPROTO_RAW;
+ return;
+
+ default:
+ pa->type = 0;
+ pa->protocol = 0;
+ return;
+ }
+}
+
+
+static int
+svr4_sockmod(fp, ioc, p)
+ struct file *fp;
+ struct svr4_strioctl *ioc;
+ struct proc *p;
+{
+ int error;
+
+ switch (ioc->cmd) {
+ case SVR4_SI_OGETUDATA:
+ DPRINTF(("SI_OGETUDATA\n"));
+ {
+ struct svr4_si_oudata ud;
+ struct svr4_si_sockparms pa;
+ struct socket *so = (struct socket *) fp->f_data;
+
+ if (sizeof(ud) != ioc->len) {
+ DPRINTF(("Wrong size %d != %d\n",
+ sizeof(ud), ioc->len));
+ return EINVAL;
+ }
+
+ if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0)
+ return error;
+
+ /* I have no idea what these should be! */
+ ud.tidusize = 16384;
+ ud.addrsize = sizeof(struct sockaddr_in);
+ ud.optsize = 128;
+
+ svr4_getparm(so, &pa);
+
+ if (pa.type == SVR4_SOCK_STREAM)
+ ud.etsdusize = 1;
+ else
+ ud.etsdusize = 0;
+
+ ud.servtype = pa.type;
+
+ /* XXX: Fixme */
+ ud.so_state = 0;
+ ud.so_options = 0;
+ return copyout(&ud, ioc->buf, sizeof(ud));
+ }
+
+ case SVR4_SI_SHUTDOWN:
+ DPRINTF(("SI_SHUTDOWN\n"));
+ return 0;
+
+ case SVR4_SI_LISTEN:
+ DPRINTF(("SI_LISTEN\n"));
+ return 0;
+
+ case SVR4_SI_SETMYNAME:
+ DPRINTF(("SI_SETMYNAME\n"));
+ return 0;
+
+ case SVR4_SI_SETPEERNAME:
+ DPRINTF(("SI_SETPEERNAME\n"));
+ return 0;
+
+ case SVR4_SI_GETINTRANSIT:
+ DPRINTF(("SI_GETINTRANSIT\n"));
+ return 0;
+
+ case SVR4_SI_TCL_LINK:
+ DPRINTF(("SI_TCL_LINK\n"));
+ return 0;
+
+ case SVR4_SI_TCL_UNLINK:
+ DPRINTF(("SI_TCL_UNLINK\n"));
+ return 0;
+
+ case SVR4_SI_SOCKPARAMS:
+ DPRINTF(("SI_SOCKPARAMS\n"));
+ {
+ struct socket *so = (struct socket *) fp->f_data;
+ struct svr4_si_sockparms pa;
+
+ svr4_getparm(so, &pa);
+ return copyout(&pa, ioc->buf, sizeof(pa));
+ }
+ return 0;
+
+ case SVR4_SI_GETUDATA:
+ DPRINTF(("SI_GETUDATA\n"));
+ {
+ struct svr4_si_udata ud;
+ struct socket *so = (struct socket *) fp->f_data;
+
+ if (sizeof(ud) != ioc->len) {
+ DPRINTF(("Wrong size %d != %d\n",
+ sizeof(ud), ioc->len));
+ return EINVAL;
+ }
+
+ if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0)
+ return error;
+
+ /* I have no idea what these should be! */
+ ud.tidusize = 16384;
+ ud.addrsize = sizeof(struct sockaddr_in);
+ ud.optsize = 128;
+ ud.tsdusize = 16384;
+
+ svr4_getparm(so, &ud.sockparms);
+
+ if (ud.sockparms.type == SVR4_SOCK_STREAM)
+ ud.etsdusize = 1;
+ else
+ ud.etsdusize = 0;
+
+ ud.servtype = ud.sockparms.type;
+
+ /* XXX: Fixme */
+ ud.so_state = 0;
+ ud.so_options = 0;
+ return copyout(&ud, ioc->buf, sizeof(ud));
+ }
+ return 0;
+
+ default:
+ DPRINTF(("Unknown sockmod ioctl %x\n", ioc->cmd));
+ return 0;
+
+ }
+}
+
+static int
+svr4_timod(fp, ioc, p)
+ struct file *fp;
+ struct svr4_strioctl *ioc;
+ struct proc *p;
+{
+ int error;
+
+ switch (ioc->cmd) {
+ case SVR4_TI_GETINFO:
+ DPRINTF(("TI_GETINFO\n"));
+ {
+ struct svr4_infocmd info;
+
+ bzero(&info, sizeof(info));
+
+ if ((error = copyin(ioc->buf, &info, ioc->len)) != 0)
+ return error;
+
+ if (info.cmd != SVR4_TI_INFO_REQUEST)
+ return EINVAL;
+
+ info.cmd = SVR4_TI_INFO_REPLY;
+ info.tsdu = 0;
+ info.etsdu = 1;
+ info.cdata = -2;
+ info.ddata = -2;
+ info.addr = 16;
+ info.opt = -1;
+ info.tidu = 16384;
+ info.serv = 2;
+ info.current = 0;
+ info.provider = 2;
+
+ ioc->len = sizeof(info);
+ if ((error = copyout(&info, ioc->buf, ioc->len)) != 0)
+ return error;
+ }
+ return 0;
+
+ case SVR4_TI_OPTMGMT:
+ DPRINTF(("TI_OPTMGMT\n"));
+ return 0;
+
+ case SVR4_TI_BIND:
+ DPRINTF(("TI_BIND\n"));
+ {
+ struct svr4_strmcmd bnd;
+ bzero(&bnd, sizeof(bnd));
+
+ if ((error = copyin(ioc->buf, &bnd, ioc->len)) != 0)
+ return error;
+
+ if (bnd.cmd != SVR4_TI_BIND_REQUEST)
+ return EINVAL;
+
+ ioc->len = 32;
+
+ bzero(&bnd, sizeof(bnd));
+
+ bnd.cmd = SVR4_TI_BIND_REPLY;
+ bnd.len = sizeof(struct sockaddr_in);
+ bnd.offs = 0x10;
+
+ if ((error = copyout(&bnd, ioc->buf, ioc->len)) != 0)
+ return error;
+ }
+ return 0;
+
+ case SVR4_TI_UNBIND:
+ DPRINTF(("TI_UNBIND\n"));
+ return 0;
+
+ case SVR4_TI_GETMYNAME:
+ DPRINTF(("TI_GETMYNAME\n"));
+ return 0;
+
+ case SVR4_TI_GETPEERNAME:
+ DPRINTF(("TI_GETPEERNAME\n"));
+ return 0;
+
+ case SVR4_TI_SETMYNAME:
+ DPRINTF(("TI_SETMYNAME\n"));
+ return 0;
+
+ case SVR4_TI_SETPEERNAME:
+ DPRINTF(("TI_SETPEERNAME\n"));
+ return 0;
+
+ default:
+ DPRINTF(("Unknown timod ioctl %x\n", ioc->cmd));
+ return 0;
+ }
+}
+
+
+#ifdef DEBUG_SVR4
+static int
+svr4_showioc(str, ioc)
+ const char *str;
+ struct svr4_strioctl *ioc;
+{
+ char *ptr = (char *) malloc(ioc->len, M_TEMP, M_WAITOK);
+ int error;
+ int i;
+
+ printf("%s cmd = %d, timeout = %d, len = %d, buf = %x { ",
+ str, ioc->cmd, ioc->timeout, ioc->len, ioc->buf);
+
+ if ((error = copyin(ioc->buf, ptr, ioc->len)) != 0) {
+ free((char *) ptr, M_TEMP);
+ return error;
+ }
+
+ for (i = 0; i < ioc->len; i++)
+ printf("%x ", (unsigned char) ptr[i]);
+
+ printf("}\n");
+
+ free((char *) ptr, M_TEMP);
+ return 0;
+}
+#endif /* DEBUG_SVR4 */
+
+
+int
+svr4_streamioctl(fp, cmd, dat, p, retval)
+ struct file *fp;
+ u_long cmd;
+ caddr_t dat;
+ struct proc *p;
+ register_t *retval;
+{
+ struct svr4_strioctl ioc;
+ int error;
+
+ *retval = 0;
+
+ /*
+ * All the following stuff assumes "sockmod" is pushed...
+ */
+ switch (cmd) {
+ case SVR4_I_NREAD:
+ DPRINTF(("I_NREAD\n"));
+ {
+ int nread = 0; /* XXX: is that FIONREAD? */
+ if ((error = copyout(&nread, dat, sizeof(nread))) != 0)
+ return error;
+ }
+ return 0;
+
+ case SVR4_I_PUSH:
+ DPRINTF(("I_PUSH\n"));
+ return 0;
+
+ case SVR4_I_POP:
+ DPRINTF(("I_POP\n"));
+ return 0;
+
+ case SVR4_I_LOOK:
+ DPRINTF(("I_LOOK\n"));
+ return 0;
+
+ case SVR4_I_FLUSH:
+ DPRINTF(("I_FLUSH\n"));
+ return 0;
+
+ case SVR4_I_SRDOPT:
+ DPRINTF(("I_SRDOPT\n"));
+ return 0;
+
+ case SVR4_I_GRDOPT:
+ DPRINTF(("I_GRDOPT\n"));
+ return 0;
+
+ case SVR4_I_STR:
+ DPRINTF(("I_STR\n"));
+ if ((error = copyin(dat, &ioc, sizeof(ioc))) != 0)
+ return error;
+
+#ifdef DEBUG_SVR4
+ if ((error = svr4_showioc(">", &ioc)) != 0)
+ return error;
+#endif /* DEBUG_SVR4 */
+ switch (ioc.cmd & 0xff00) {
+ case SVR4_SIMOD:
+ if ((error = svr4_sockmod(fp, &ioc, p)) != 0)
+ return error;
+ break;
+
+ case SVR4_TIMOD:
+ if ((error = svr4_timod(fp, &ioc, p)) != 0)
+ return error;
+ break;
+
+ default:
+ DPRINTF(("Unimplemented module %c %d\n",
+ (char) (cmd >> 8), cmd & 0xff));
+ return 0;
+ }
+
+#ifdef DEBUG_SVR4
+ if ((error = svr4_showioc("<", &ioc)) != 0)
+ return error;
+#endif /* DEBUG_SVR4 */
+ return copyout(&ioc, dat, sizeof(ioc));
+
+ case SVR4_I_SETSIG:
+ DPRINTF(("I_SETSIG\n"));
+ return 0;
+
+ case SVR4_I_GETSIG:
+ DPRINTF(("I_GETSIG\n"));
+ return EINVAL;
+
+ case SVR4_I_FIND:
+ DPRINTF(("I_FIND\n"));
+ /*
+ * Here we are not pushing modules really, we just
+ * pretend all are present
+ */
+ *retval = 1;
+ return 0;
+
+ case SVR4_I_LINK:
+ DPRINTF(("I_LINK\n"));
+ return 0;
+
+ case SVR4_I_UNLINK:
+ DPRINTF(("I_UNLINK\n"));
+ return 0;
+
+ case SVR4_I_ERECVFD:
+ DPRINTF(("I_ERECVFD\n"));
+ return 0;
+
+ case SVR4_I_PEEK:
+ DPRINTF(("I_PEEK\n"));
+ return 0;
+
+ case SVR4_I_FDINSERT:
+ DPRINTF(("I_FDINSERT\n"));
+ return 0;
+
+ case SVR4_I_SENDFD:
+ DPRINTF(("I_SENDFD\n"));
+ return 0;
+
+ case SVR4_I_RECVFD:
+ DPRINTF(("I_RECVFD\n"));
+ return 0;
+
+ case SVR4_I_SWROPT:
+ DPRINTF(("I_SWROPT\n"));
+ return 0;
+
+ case SVR4_I_GWROPT:
+ DPRINTF(("I_GWROPT\n"));
+ return 0;
+
+ case SVR4_I_LIST:
+ DPRINTF(("I_LIST\n"));
+ return 0;
+
+ case SVR4_I_PLINK:
+ DPRINTF(("I_PLINK\n"));
+ return 0;
+
+ case SVR4_I_PUNLINK:
+ DPRINTF(("I_PUNLINK\n"));
+ return 0;
+
+ case SVR4_I_SETEV:
+ DPRINTF(("I_SETEV\n"));
+ return 0;
+
+ case SVR4_I_GETEV:
+ DPRINTF(("I_GETEV\n"));
+ return 0;
+
+ case SVR4_I_STREV:
+ DPRINTF(("I_STREV\n"));
+ return 0;
+
+ case SVR4_I_UNSTREV:
+ DPRINTF(("I_UNSTREV\n"));
+ return 0;
+
+ case SVR4_I_FLUSHBAND:
+ DPRINTF(("I_FLUSHBAND\n"));
+ return 0;
+
+ case SVR4_I_CKBAND:
+ DPRINTF(("I_CKBAND\n"));
+ return 0;
+
+ case SVR4_I_GETBAND:
+ DPRINTF(("I_GETBANK\n"));
+ return 0;
+
+ case SVR4_I_ATMARK:
+ DPRINTF(("I_ATMARK\n"));
+ return 0;
+
+ case SVR4_I_SETCLTIME:
+ DPRINTF(("I_SETCLTIME\n"));
+ return 0;
+
+ case SVR4_I_GETCLTIME:
+ DPRINTF(("I_GETCLTIME\n"));
+ return 0;
+
+ case SVR4_I_CANPUT:
+ DPRINTF(("I_CANPUT\n"));
+ return 0;
+
+ default:
+ DPRINTF(("unimpl cmd = %x\n", cmd));
+ break;
+ }
+
+ return 0;
+}
+
+
+#ifdef DEBUG_SVR4
+static int
+svr4_getstrbuf(str)
+ struct svr4_strbuf *str;
+{
+ int error;
+ int i;
+ char *ptr = NULL;
+ int maxlen = str->maxlen;
+ int len = str->len;
+
+ if (maxlen < 0)
+ maxlen = 0;
+
+ if (len >= maxlen || len <= 0)
+ len = maxlen;
+
+ if (len != 0) {
+ ptr = malloc(len, M_TEMP, M_WAITOK);
+
+ if ((error = copyin(str->buf, ptr, len)) != 0) {
+ free((char *) ptr, M_TEMP);
+ return error;
+ }
+ }
+
+ printf(", { %d, %d, %x=[ ", str->maxlen, str->len, str->buf);
+ for (i = 0; i < len; i++) {
+ printf("%x ", (unsigned char) ptr[i]);
+ if (i > 20) {
+ printf("...");
+ break;
+ }
+ }
+ printf("]}");
+
+ if (ptr)
+ free((char *) ptr, M_TEMP);
+
+ return 0;
+}
+
+
+static void
+svr4_showmsg(str, fd, ctl, dat, flags)
+ const char *str;
+ int fd;
+ struct svr4_strbuf *ctl;
+ struct svr4_strbuf *dat;
+ int flags;
+{
+ struct svr4_strbuf buf;
+ int error;
+
+ printf("%s(%d", str, fd);
+ if (ctl != NULL) {
+ if ((error = copyin(ctl, &buf, sizeof(buf))) != 0)
+ return;
+ svr4_getstrbuf(&buf);
+ }
+ else
+ printf(", NULL");
+
+ if (dat != NULL) {
+ if ((error = copyin(dat, &buf, sizeof(buf))) != 0)
+ return;
+ svr4_getstrbuf(&buf);
+ }
+ else
+ printf(", NULL");
+
+ printf(", %x);\n", flags);
+}
+#endif /* DEBUG_SVR4 */
+
+
+int
+svr4_sys_putmsg(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_putmsg_args *uap = v;
+ struct filedesc *fdp = p->p_fd;
+ struct file *fp;
+ struct svr4_strbuf dat, ctl;
+ struct svr4_strmcmd sc;
+ struct svr4_netaddr *na;
+ struct socket *so;
+ struct svr4_strm *st;
+ int error;
+ struct sockaddr_in sa, *sap;
+ caddr_t sg;
+
+ if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
+ return EBADF;
+
+#ifdef DEBUG_SVR4
+ svr4_showmsg(">putmsg", SCARG(uap, fd), SCARG(uap, ctl),
+ SCARG(uap, dat), SCARG(uap, flags));
+#endif /* DEBUG_SVR4 */
+
+ if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
+ return EBADF;
+
+ if (SCARG(uap, ctl) != NULL) {
+ if ((error = copyin(SCARG(uap, ctl), &ctl, sizeof(ctl))) != 0)
+ return error;
+ }
+ else
+ ctl.len = -1;
+
+ if (SCARG(uap, dat) != NULL) {
+ if ((error = copyin(SCARG(uap, dat), &dat, sizeof(dat))) != 0)
+ return error;
+ }
+ else
+ dat.len = -1;
+
+ /*
+ * Only for sockets for now.
+ */
+ if (fp == NULL || fp->f_type != DTYPE_SOCKET) {
+ DPRINTF(("putmsg: bad file type\n"));
+ return EINVAL;
+ }
+
+ so = (struct socket *) fp->f_data;
+ st = (struct svr4_strm *) so->so_tpcb;
+
+
+ if (ctl.len > sizeof(sc)) {
+ DPRINTF(("putmsg: Bad control size %d != %d\n", ctl.len,
+ sizeof(struct svr4_strmcmd)));
+ return EINVAL;
+ }
+
+ if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0)
+ return error;
+
+ if (sc.len != sizeof(sa)) {
+ DPRINTF(("putmsg: Cannot handle variable address lengths\n"));
+ return ENOSYS;
+ }
+
+ na = SVR4_ADDROF(&sc);
+ bzero(&sa, sizeof(sa));
+ sa.sin_family = na->family;
+ sa.sin_port = na->port;
+ sa.sin_addr.s_addr = na->addr;
+
+ sg = stackgap_init(p->p_emul);
+ sap = (struct sockaddr_in *) stackgap_alloc(&sg,
+ sizeof(struct sockaddr_in));
+
+ if ((error = copyout(&sa, sap, sizeof(sa))) != 0)
+ return error;
+
+ switch (st->s_cmd = sc.cmd) {
+ case SVR4_TI_CONNECT_REQUEST: /* connect */
+ {
+ struct sys_connect_args co;
+
+ co.s = SCARG(uap, fd);
+ co.name = (caddr_t) sap;
+ co.namelen = (int) sizeof(sa);
+ return sys_connect(p, &co, retval);
+ }
+
+ case SVR4_TI_SENDTO_REQUEST: /* sendto */
+ {
+ struct msghdr msg;
+ struct iovec aiov;
+ msg.msg_name = (caddr_t) sap;
+ msg.msg_namelen = sizeof(sa);
+ msg.msg_iov = &aiov;
+ msg.msg_iovlen = 1;
+ msg.msg_control = 0;
+#ifdef COMPAT_OLDSOCK
+ msg.msg_flags = 0;
+#endif /* COMPAT_OLDSOCK */
+ aiov.iov_base = dat.buf;
+ aiov.iov_len = dat.len;
+ error = sendit(p, SCARG(uap, fd), &msg,
+ SCARG(uap, flags), retval);
+
+ *retval = 0;
+ return error;
+ }
+ default:
+ DPRINTF(("putmsg: Unimplemented command %x\n", sc.cmd));
+ return ENOSYS;
+ }
+}
+
+
+int
+svr4_sys_getmsg(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct svr4_sys_getmsg_args *uap = v;
+ struct filedesc *fdp = p->p_fd;
+ struct file *fp;
+ struct sys_getpeername_args ga;
+ struct svr4_strbuf dat, ctl;
+ struct svr4_strmcmd sc;
+ struct svr4_netaddr *na;
+ int error;
+ struct msghdr msg;
+ struct iovec aiov;
+ struct sockaddr_in sa, *sap;
+ struct socket *so;
+ struct svr4_strm *st;
+ int *flen;
+ int fl;
+ caddr_t sg;
+
+ if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
+ return EBADF;
+
+ bzero(&sc, sizeof(sc));
+
+#ifdef DEBUG_SVR4
+ svr4_showmsg(">getmsg", SCARG(uap, fd), SCARG(uap, ctl),
+ SCARG(uap, dat), 0);
+#endif /* DEBUG_SVR4 */
+
+ if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL)
+ return EBADF;
+
+ if (SCARG(uap, ctl) != NULL) {
+ if ((error = copyin(SCARG(uap, ctl), &ctl, sizeof(ctl))) != 0)
+ return error;
+ }
+ else {
+ ctl.len = -1;
+ ctl.maxlen = 0;
+ }
+
+ if (SCARG(uap, dat) != NULL) {
+ if ((error = copyin(SCARG(uap, dat), &dat, sizeof(dat))) != 0)
+ return error;
+ }
+ else {
+ dat.len = -1;
+ dat.maxlen = 0;
+ }
+
+ /*
+ * Only for sockets for now.
+ */
+ if (fp == NULL || fp->f_type != DTYPE_SOCKET) {
+ DPRINTF(("getmsg: bad file type\n"));
+ return EINVAL;
+ }
+
+ so = (struct socket *) fp->f_data;
+ st = (struct svr4_strm *) so->so_tpcb;
+
+ if (ctl.maxlen == -1 || dat.maxlen == -1) {
+ DPRINTF(("getmsg: Cannot handle -1 maxlen (yet)\n"));
+ return ENOSYS;
+ }
+
+ sg = stackgap_init(p->p_emul);
+ sap = (struct sockaddr_in *) stackgap_alloc(&sg,
+ sizeof(struct sockaddr_in));
+ flen = (int *) stackgap_alloc(&sg, sizeof(*flen));
+
+ fl = sizeof(sa);
+ if ((error = copyout(&fl, flen, sizeof(fl))) != 0)
+ return error;
+
+
+ switch (st->s_cmd) {
+ case SVR4_TI_CONNECT_REQUEST:
+ /*
+ * We do the connect in one step, so the putmsg should
+ * have gotten the error.
+ */
+ sc.cmd = SVR4_TI_OK_REPLY;
+ sc.len = 0;
+
+ ctl.len = 8;
+ dat.len = -1;
+ fl = 1;
+ break;
+
+ case SVR4_TI_OK_REPLY:
+ /*
+ * We are immediately after a connect reply, so we send
+ * an connect verification.
+ */
+ SCARG(&ga, fdes) = SCARG(uap, fd);
+ SCARG(&ga, asa) = (caddr_t) sap;
+ SCARG(&ga, alen) = flen;
+
+ if ((error = sys_getpeername(p, &ga, retval)) != 0) {
+ DPRINTF(("getmsg: getpeername failed %d\n", error));
+ return error;
+ }
+
+ if ((error = copyin(sap, &sa, sizeof(sa))) != 0)
+ return error;
+
+ sc.cmd = SVR4_TI_CONNECT_REPLY;
+ sc.len = sizeof(struct sockaddr_in);
+ sc.offs = 0x18;
+ sc.pad[0] = 0x4;
+ sc.pad[1] = 0x14;
+ sc.pad[2] = 0x04000402;
+ na = SVR4_ADDROF(&sc);
+
+ na->family = sa.sin_family;
+ na->port = sa.sin_port;
+ na->addr = sa.sin_addr.s_addr;
+
+ ctl.len = 40;
+ dat.len = -1;
+ fl = 0;
+ break;
+
+ case SVR4_TI_SENDTO_REQUEST:
+ if (ctl.maxlen > 36 && ctl.len < 36)
+ ctl.len = 36;
+
+ if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0)
+ return error;
+
+
+ na = SVR4_ADDROF(&sc);
+
+ bzero(&sa, sizeof(sa));
+ sa.sin_family = na->family;
+ sa.sin_port = na->port;
+ sa.sin_addr.s_addr = na->addr;
+
+ if ((error = copyout(&sa, sap, sizeof(sa))) != 0)
+ return error;
+
+ msg.msg_name = (caddr_t) sap;
+ msg.msg_namelen = sizeof(sa);
+ msg.msg_iov = &aiov;
+ msg.msg_iovlen = 1;
+ msg.msg_control = 0;
+ aiov.iov_base = dat.buf;
+ aiov.iov_len = dat.maxlen;
+ msg.msg_flags = 0;
+
+ error = recvit(p, SCARG(uap, fd), &msg, flen, retval);
+
+ if (error) {
+ DPRINTF(("getmsg: recvit failed %d\n", error))
+ return error;
+ }
+
+
+ if ((error = copyin(msg.msg_name, &sa, sizeof(sa))) != 0)
+ return error;
+
+ sc.cmd = SVR4_TI_RECVFROM_REPLY;
+ sc.len = sizeof(sa);
+
+ na->family = sa.sin_family;
+ na->port = sa.sin_port;
+ na->addr = sa.sin_addr.s_addr;
+
+ dat.len = *retval;
+ fl = 0;
+ break;
+
+ default:
+ DPRINTF(("getmsg: Unknown state %x\n", st->s_cmd));
+ return EINVAL;
+ }
+
+
+ st->s_cmd = sc.cmd;
+ if (SCARG(uap, ctl)) {
+ if (ctl.len != -1)
+ if ((error = copyout(&sc, ctl.buf, ctl.len)) != 0)
+ return error;
+
+ if ((error = copyout(&ctl, SCARG(uap, ctl), sizeof(ctl))) != 0)
+ return error;
+ }
+
+ if (SCARG(uap, dat)) {
+ if ((error = copyout(&dat, SCARG(uap, dat), sizeof(dat))) != 0)
+ return error;
+ }
+
+ if (SCARG(uap, flags)) { /* XXX: Need translation */
+ if ((error = copyout(&fl, SCARG(uap, flags), sizeof(fl))) != 0)
+ return error;
+ }
+
+ *retval = 0;
+
+#ifdef DEBUG_SVR4
+ svr4_showmsg("<getmsg", SCARG(uap, fd), SCARG(uap, ctl),
+ SCARG(uap, dat), fl);
+#endif /* DEBUG_SVR4 */
+ return error;
+}
diff --git a/sys/compat/svr4/svr4_stropts.h b/sys/compat/svr4/svr4_stropts.h
new file mode 100644
index 00000000000..ff83734a1cf
--- /dev/null
+++ b/sys/compat/svr4/svr4_stropts.h
@@ -0,0 +1,126 @@
+/* $NetBSD: svr4_stropts.h,v 1.5 1995/10/07 06:27:53 mycroft 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.
+ */
+
+#ifndef _SVR4_STROPTS_H_
+#define _SVR4_STROPTS_H_
+
+
+struct svr4_strbuf {
+ int maxlen;
+ int len;
+ char *buf;
+};
+
+#define SVR4_STR ('S' << 8)
+#define SVR4_I_NREAD (SVR4_STR| 1)
+#define SVR4_I_PUSH (SVR4_STR| 2)
+#define SVR4_I_POP (SVR4_STR| 3)
+#define SVR4_I_LOOK (SVR4_STR| 4)
+#define SVR4_I_FLUSH (SVR4_STR| 5)
+#define SVR4_I_SRDOPT (SVR4_STR| 6)
+#define SVR4_I_GRDOPT (SVR4_STR| 7)
+#define SVR4_I_STR (SVR4_STR| 8)
+#define SVR4_I_SETSIG (SVR4_STR| 9)
+#define SVR4_I_GETSIG (SVR4_STR|10)
+#define SVR4_I_FIND (SVR4_STR|11)
+#define SVR4_I_LINK (SVR4_STR|12)
+#define SVR4_I_UNLINK (SVR4_STR|13)
+#define SVR4_I_ERECVFD (SVR4_STR|14)
+#define SVR4_I_PEEK (SVR4_STR|15)
+#define SVR4_I_FDINSERT (SVR4_STR|16)
+#define SVR4_I_SENDFD (SVR4_STR|17)
+#define SVR4_I_RECVFD (SVR4_STR|18)
+#define SVR4_I_SWROPT (SVR4_STR|19)
+#define SVR4_I_GWROPT (SVR4_STR|20)
+#define SVR4_I_LIST (SVR4_STR|21)
+#define SVR4_I_PLINK (SVR4_STR|22)
+#define SVR4_I_PUNLINK (SVR4_STR|23)
+#define SVR4_I_SETEV (SVR4_STR|24)
+#define SVR4_I_GETEV (SVR4_STR|25)
+#define SVR4_I_STREV (SVR4_STR|26)
+#define SVR4_I_UNSTREV (SVR4_STR|27)
+#define SVR4_I_FLUSHBAND (SVR4_STR|28)
+#define SVR4_I_CKBAND (SVR4_STR|29)
+#define SVR4_I_GETBAND (SVR4_STR|30)
+#define SVR4_I_ATMARK (SVR4_STR|31)
+#define SVR4_I_SETCLTIME (SVR4_STR|32)
+#define SVR4_I_GETCLTIME (SVR4_STR|33)
+#define SVR4_I_CANPUT (SVR4_STR|34)
+
+/* Struct passed for SVR4_I_STR */
+struct svr4_strioctl {
+ u_long cmd;
+ int timeout;
+ int len;
+ char *buf;
+};
+
+
+/*
+ * Our internal state for the stream
+ * For now we keep almost nothing... In the future we can keep more
+ * streams state.
+ */
+struct svr4_strm {
+ int s_cmd; /* last getmsg reply or putmsg request */
+};
+
+/*
+ * The following structures are determined empirically.
+ */
+struct svr4_strmcmd {
+ long cmd; /* command ? */
+ long len; /* Address len */
+ long offs; /* Address offset */
+ long pad[61];
+};
+
+struct svr4_infocmd {
+ long cmd;
+ long tsdu;
+ long etsdu;
+ long cdata;
+ long ddata;
+ long addr;
+ long opt;
+ long tidu;
+ long serv;
+ long current;
+ long provider;
+};
+
+struct svr4_netaddr {
+ u_short family;
+ u_short port;
+ u_long addr;
+};
+
+#define SVR4_ADDROF(sc) (struct svr4_netaddr *) (((char *) (sc)) + (sc)->offs)
+
+#endif /* !_SVR4_STROPTS */
diff --git a/sys/compat/svr4/svr4_syscall.h b/sys/compat/svr4/svr4_syscall.h
new file mode 100644
index 00000000000..2a3076df8e8
--- /dev/null
+++ b/sys/compat/svr4/svr4_syscall.h
@@ -0,0 +1,110 @@
+/*
+ * System call numbers.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp
+ */
+
+#define SVR4_SYS_syscall 0
+#define SVR4_SYS_exit 1
+#define SVR4_SYS_fork 2
+#define SVR4_SYS_read 3
+#define SVR4_SYS_write 4
+#define SVR4_SYS_open 5
+#define SVR4_SYS_close 6
+#define SVR4_SYS_wait 7
+#define SVR4_SYS_creat 8
+#define SVR4_SYS_link 9
+#define SVR4_SYS_unlink 10
+#define SVR4_SYS_execv 11
+#define SVR4_SYS_chdir 12
+#define SVR4_SYS_time 13
+#define SVR4_SYS_mknod 14
+#define SVR4_SYS_chmod 15
+#define SVR4_SYS_chown 16
+#define SVR4_SYS_break 17
+#define SVR4_SYS_stat 18
+#define SVR4_SYS_lseek 19
+#define SVR4_SYS_getpid 20
+#define SVR4_SYS_setuid 23
+#define SVR4_SYS_getuid 24
+#define SVR4_SYS_alarm 27
+#define SVR4_SYS_fstat 28
+#define SVR4_SYS_access 33
+#define SVR4_SYS_sync 36
+#define SVR4_SYS_kill 37
+#define SVR4_SYS_pgrpsys 39
+#define SVR4_SYS_dup 41
+#define SVR4_SYS_pipe 42
+#define SVR4_SYS_times 43
+#define SVR4_SYS_setgid 46
+#define SVR4_SYS_getgid 47
+#define SVR4_SYS_signal 48
+#define SVR4_SYS_sysarch 50
+#define SVR4_SYS_ioctl 54
+#define SVR4_SYS_utssys 57
+#define SVR4_SYS_fsync 58
+#define SVR4_SYS_execve 59
+#define SVR4_SYS_umask 60
+#define SVR4_SYS_chroot 61
+#define SVR4_SYS_fcntl 62
+#define SVR4_SYS_ulimit 63
+ /* 70 is obsolete advfs */
+ /* 71 is obsolete unadvfs */
+ /* 72 is obsolete rmount */
+ /* 73 is obsolete rumount */
+ /* 74 is obsolete rfstart */
+ /* 75 is obsolete sigret */
+ /* 76 is obsolete rdebug */
+ /* 77 is obsolete rfstop */
+#define SVR4_SYS_rmdir 79
+#define SVR4_SYS_mkdir 80
+#define SVR4_SYS_getdents 81
+ /* 82 is obsolete libattach */
+ /* 83 is obsolete libdetach */
+#define SVR4_SYS_getmsg 85
+#define SVR4_SYS_putmsg 86
+#define SVR4_SYS_poll 87
+#define SVR4_SYS_lstat 88
+#define SVR4_SYS_symlink 89
+#define SVR4_SYS_readlink 90
+#define SVR4_SYS_getgroups 91
+#define SVR4_SYS_setgroups 92
+#define SVR4_SYS_fchmod 93
+#define SVR4_SYS_fchown 94
+#define SVR4_SYS_sigprocmask 95
+#define SVR4_SYS_sigsuspend 96
+#define SVR4_SYS_sigaltstack 97
+#define SVR4_SYS_sigaction 98
+#define SVR4_SYS_sigpending 99
+#define SVR4_SYS_context 100
+#define SVR4_SYS_statvfs 103
+#define SVR4_SYS_fstatvfs 104
+#define SVR4_SYS_waitsys 107
+#define SVR4_SYS_hrtsys 109
+#define SVR4_SYS_mmap 115
+#define SVR4_SYS_mprotect 116
+#define SVR4_SYS_munmap 117
+#define SVR4_SYS_fpathconf 118
+#define SVR4_SYS_vfork 119
+#define SVR4_SYS_fchdir 120
+#define SVR4_SYS_readv 121
+#define SVR4_SYS_writev 122
+#define SVR4_SYS_xstat 123
+#define SVR4_SYS_lxstat 124
+#define SVR4_SYS_fxstat 125
+#define SVR4_SYS_setrlimit 128
+#define SVR4_SYS_getrlimit 129
+#define SVR4_SYS_rename 134
+#define SVR4_SYS_uname 135
+#define SVR4_SYS_setegid 136
+#define SVR4_SYS_sysconfig 137
+#define SVR4_SYS_adjtime 138
+#define SVR4_SYS_systeminfo 139
+#define SVR4_SYS_seteuid 141
+#define SVR4_SYS_fchroot 153
+#define SVR4_SYS_vhangup 155
+#define SVR4_SYS_gettimeofday 156
+#define SVR4_SYS_getitimer 157
+#define SVR4_SYS_setitimer 158
+#define SVR4_SYS_MAXSYSCALL 187
diff --git a/sys/compat/svr4/svr4_syscallargs.h b/sys/compat/svr4/svr4_syscallargs.h
new file mode 100644
index 00000000000..79b22a29872
--- /dev/null
+++ b/sys/compat/svr4/svr4_syscallargs.h
@@ -0,0 +1,369 @@
+/*
+ * System call argument lists.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp
+ */
+
+#define syscallarg(x) union { x datum; register_t pad; }
+
+struct svr4_sys_open_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+};
+
+struct svr4_sys_wait_args {
+ syscallarg(int *) status;
+};
+
+struct svr4_sys_creat_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+};
+
+struct svr4_sys_execv_args {
+ syscallarg(char *) path;
+ syscallarg(char **) argp;
+};
+
+struct svr4_sys_time_args {
+ syscallarg(svr4_time_t *) t;
+};
+
+struct svr4_sys_mknod_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ syscallarg(int) dev;
+};
+
+struct svr4_sys_break_args {
+ syscallarg(caddr_t) nsize;
+};
+
+struct svr4_sys_stat_args {
+ syscallarg(char *) path;
+ syscallarg(struct svr4_stat *) ub;
+};
+
+struct svr4_sys_alarm_args {
+ syscallarg(unsigned) sec;
+};
+
+struct svr4_sys_fstat_args {
+ syscallarg(int) fd;
+ syscallarg(struct svr4_stat *) sb;
+};
+
+struct svr4_sys_access_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+};
+
+struct svr4_sys_kill_args {
+ syscallarg(int) pid;
+ syscallarg(int) signum;
+};
+
+struct svr4_sys_pgrpsys_args {
+ syscallarg(int) cmd;
+ syscallarg(int) pid;
+ syscallarg(int) pgid;
+};
+
+struct svr4_sys_times_args {
+ syscallarg(struct tms *) tp;
+};
+
+struct svr4_sys_signal_args {
+ syscallarg(int) signum;
+ syscallarg(svr4_sig_t) handler;
+};
+
+struct svr4_sys_sysarch_args {
+ syscallarg(int) op;
+ syscallarg(void *) a1;
+};
+
+struct svr4_sys_ioctl_args {
+ syscallarg(int) fd;
+ syscallarg(u_long) com;
+ syscallarg(caddr_t) data;
+};
+
+struct svr4_sys_utssys_args {
+ syscallarg(void *) a1;
+ syscallarg(void *) a2;
+ syscallarg(int) sel;
+ syscallarg(void *) a3;
+};
+
+struct svr4_sys_execve_args {
+ syscallarg(char *) path;
+ syscallarg(char **) argp;
+ syscallarg(char **) envp;
+};
+
+struct svr4_sys_fcntl_args {
+ syscallarg(int) fd;
+ syscallarg(int) cmd;
+ syscallarg(char *) arg;
+};
+
+struct svr4_sys_ulimit_args {
+ syscallarg(int) cmd;
+ syscallarg(long) newlimit;
+};
+
+struct svr4_sys_getdents_args {
+ syscallarg(int) fd;
+ syscallarg(char *) buf;
+ syscallarg(int) nbytes;
+};
+
+struct svr4_sys_getmsg_args {
+ syscallarg(int) fd;
+ syscallarg(struct svr4_strbuf *) ctl;
+ syscallarg(struct svr4_strbuf *) dat;
+ syscallarg(int *) flags;
+};
+
+struct svr4_sys_putmsg_args {
+ syscallarg(int) fd;
+ syscallarg(struct svr4_strbuf *) ctl;
+ syscallarg(struct svr4_strbuf *) dat;
+ syscallarg(int) flags;
+};
+
+struct svr4_sys_poll_args {
+ syscallarg(struct svr4_pollfd *) fds;
+ syscallarg(long) nfds;
+ syscallarg(int) timeout;
+};
+
+struct svr4_sys_lstat_args {
+ syscallarg(char *) path;
+ syscallarg(struct svr4_stat *) ub;
+};
+
+struct svr4_sys_sigprocmask_args {
+ syscallarg(int) how;
+ syscallarg(svr4_sigset_t *) set;
+ syscallarg(svr4_sigset_t *) oset;
+};
+
+struct svr4_sys_sigsuspend_args {
+ syscallarg(svr4_sigset_t *) ss;
+};
+
+struct svr4_sys_sigaltstack_args {
+ syscallarg(struct svr4_sigaltstack *) nss;
+ syscallarg(struct svr4_sigaltstack *) oss;
+};
+
+struct svr4_sys_sigaction_args {
+ syscallarg(int) signum;
+ syscallarg(struct svr4_sigaction *) nsa;
+ syscallarg(struct svr4_sigaction *) osa;
+};
+
+struct svr4_sys_sigpending_args {
+ syscallarg(int) what;
+ syscallarg(svr4_sigset_t *) mask;
+};
+
+struct svr4_sys_context_args {
+ syscallarg(int) func;
+ syscallarg(struct svr4_ucontext *) uc;
+};
+
+struct svr4_sys_statvfs_args {
+ syscallarg(char *) path;
+ syscallarg(struct svr4_statvfs *) fs;
+};
+
+struct svr4_sys_fstatvfs_args {
+ syscallarg(int) fd;
+ syscallarg(struct svr4_statvfs *) fs;
+};
+
+struct svr4_sys_waitsys_args {
+ syscallarg(int) grp;
+ syscallarg(int) id;
+ syscallarg(union svr4_siginfo *) info;
+ syscallarg(int) options;
+};
+
+struct svr4_sys_hrtsys_args {
+ syscallarg(int) cmd;
+ syscallarg(int) fun;
+ syscallarg(int) sub;
+ syscallarg(void *) rv1;
+ syscallarg(void *) rv2;
+};
+
+struct svr4_sys_mmap_args {
+ syscallarg(svr4_caddr_t) addr;
+ syscallarg(svr4_size_t) len;
+ syscallarg(int) prot;
+ syscallarg(int) flags;
+ syscallarg(int) fd;
+ syscallarg(svr4_off_t) pos;
+};
+
+struct svr4_sys_xstat_args {
+ syscallarg(int) two;
+ syscallarg(char *) path;
+ syscallarg(struct svr4_xstat *) ub;
+};
+
+struct svr4_sys_lxstat_args {
+ syscallarg(int) two;
+ syscallarg(char *) path;
+ syscallarg(struct svr4_xstat *) ub;
+};
+
+struct svr4_sys_fxstat_args {
+ syscallarg(int) two;
+ syscallarg(int) fd;
+ syscallarg(struct svr4_xstat *) sb;
+};
+
+struct svr4_sys_setrlimit_args {
+ syscallarg(int) which;
+ syscallarg(struct ogetrlimit *) rlp;
+};
+
+struct svr4_sys_getrlimit_args {
+ syscallarg(int) which;
+ syscallarg(struct ogetrlimit *) rlp;
+};
+
+struct svr4_sys_uname_args {
+ syscallarg(struct svr4_utsname *) name;
+ syscallarg(int) dummy;
+};
+
+struct svr4_sys_sysconfig_args {
+ syscallarg(int) name;
+};
+
+struct svr4_sys_systeminfo_args {
+ syscallarg(int) what;
+ syscallarg(char *) buf;
+ syscallarg(long) len;
+};
+
+struct svr4_sys_fchroot_args {
+ syscallarg(int) fd;
+};
+
+struct svr4_sys_gettimeofday_args {
+ syscallarg(struct timeval *) tp;
+};
+
+/*
+ * System call prototypes.
+ */
+
+int sys_nosys __P((struct proc *, void *, register_t *));
+int sys_exit __P((struct proc *, void *, register_t *));
+int sys_fork __P((struct proc *, void *, register_t *));
+int sys_read __P((struct proc *, void *, register_t *));
+int sys_write __P((struct proc *, void *, register_t *));
+int svr4_sys_open __P((struct proc *, void *, register_t *));
+int sys_close __P((struct proc *, void *, register_t *));
+int svr4_sys_wait __P((struct proc *, void *, register_t *));
+int svr4_sys_creat __P((struct proc *, void *, register_t *));
+int sys_link __P((struct proc *, void *, register_t *));
+int sys_unlink __P((struct proc *, void *, register_t *));
+int svr4_sys_execv __P((struct proc *, void *, register_t *));
+int sys_chdir __P((struct proc *, void *, register_t *));
+int svr4_sys_time __P((struct proc *, void *, register_t *));
+int svr4_sys_mknod __P((struct proc *, void *, register_t *));
+int sys_chmod __P((struct proc *, void *, register_t *));
+int sys_chown __P((struct proc *, void *, register_t *));
+int svr4_sys_break __P((struct proc *, void *, register_t *));
+int svr4_sys_stat __P((struct proc *, void *, register_t *));
+int compat_43_sys_lseek __P((struct proc *, void *, register_t *));
+int sys_getpid __P((struct proc *, void *, register_t *));
+int sys_setuid __P((struct proc *, void *, register_t *));
+int sys_getuid __P((struct proc *, void *, register_t *));
+int svr4_sys_alarm __P((struct proc *, void *, register_t *));
+int svr4_sys_fstat __P((struct proc *, void *, register_t *));
+int svr4_sys_access __P((struct proc *, void *, register_t *));
+int sys_sync __P((struct proc *, void *, register_t *));
+int svr4_sys_kill __P((struct proc *, void *, register_t *));
+int svr4_sys_pgrpsys __P((struct proc *, void *, register_t *));
+int sys_dup __P((struct proc *, void *, register_t *));
+int sys_pipe __P((struct proc *, void *, register_t *));
+int svr4_sys_times __P((struct proc *, void *, register_t *));
+int sys_setgid __P((struct proc *, void *, register_t *));
+int sys_getgid __P((struct proc *, void *, register_t *));
+int svr4_sys_signal __P((struct proc *, void *, register_t *));
+#ifdef SYSVMSG
+#else
+#endif
+int svr4_sys_sysarch __P((struct proc *, void *, register_t *));
+#ifdef SYSVSHM
+#else
+#endif
+#ifdef SYSVSEM
+#else
+#endif
+int svr4_sys_ioctl __P((struct proc *, void *, register_t *));
+int svr4_sys_utssys __P((struct proc *, void *, register_t *));
+int sys_fsync __P((struct proc *, void *, register_t *));
+int svr4_sys_execve __P((struct proc *, void *, register_t *));
+int sys_umask __P((struct proc *, void *, register_t *));
+int sys_chroot __P((struct proc *, void *, register_t *));
+int svr4_sys_fcntl __P((struct proc *, void *, register_t *));
+int svr4_sys_ulimit __P((struct proc *, void *, register_t *));
+int sys_rmdir __P((struct proc *, void *, register_t *));
+int sys_mkdir __P((struct proc *, void *, register_t *));
+int svr4_sys_getdents __P((struct proc *, void *, register_t *));
+int svr4_sys_getmsg __P((struct proc *, void *, register_t *));
+int svr4_sys_putmsg __P((struct proc *, void *, register_t *));
+int svr4_sys_poll __P((struct proc *, void *, register_t *));
+int svr4_sys_lstat __P((struct proc *, void *, register_t *));
+int sys_symlink __P((struct proc *, void *, register_t *));
+int sys_readlink __P((struct proc *, void *, register_t *));
+int sys_getgroups __P((struct proc *, void *, register_t *));
+int sys_setgroups __P((struct proc *, void *, register_t *));
+int sys_fchmod __P((struct proc *, void *, register_t *));
+int sys_fchown __P((struct proc *, void *, register_t *));
+int svr4_sys_sigprocmask __P((struct proc *, void *, register_t *));
+int svr4_sys_sigsuspend __P((struct proc *, void *, register_t *));
+int svr4_sys_sigaltstack __P((struct proc *, void *, register_t *));
+int svr4_sys_sigaction __P((struct proc *, void *, register_t *));
+int svr4_sys_sigpending __P((struct proc *, void *, register_t *));
+int svr4_sys_context __P((struct proc *, void *, register_t *));
+int svr4_sys_statvfs __P((struct proc *, void *, register_t *));
+int svr4_sys_fstatvfs __P((struct proc *, void *, register_t *));
+int svr4_sys_waitsys __P((struct proc *, void *, register_t *));
+int svr4_sys_hrtsys __P((struct proc *, void *, register_t *));
+int svr4_sys_mmap __P((struct proc *, void *, register_t *));
+int sys_mprotect __P((struct proc *, void *, register_t *));
+int sys_munmap __P((struct proc *, void *, register_t *));
+int sys_fpathconf __P((struct proc *, void *, register_t *));
+int sys_vfork __P((struct proc *, void *, register_t *));
+int sys_fchdir __P((struct proc *, void *, register_t *));
+int sys_readv __P((struct proc *, void *, register_t *));
+int sys_writev __P((struct proc *, void *, register_t *));
+int svr4_sys_xstat __P((struct proc *, void *, register_t *));
+int svr4_sys_lxstat __P((struct proc *, void *, register_t *));
+int svr4_sys_fxstat __P((struct proc *, void *, register_t *));
+int svr4_sys_setrlimit __P((struct proc *, void *, register_t *));
+int svr4_sys_getrlimit __P((struct proc *, void *, register_t *));
+int sys_rename __P((struct proc *, void *, register_t *));
+int svr4_sys_uname __P((struct proc *, void *, register_t *));
+int sys_setegid __P((struct proc *, void *, register_t *));
+int svr4_sys_sysconfig __P((struct proc *, void *, register_t *));
+int sys_adjtime __P((struct proc *, void *, register_t *));
+int svr4_sys_systeminfo __P((struct proc *, void *, register_t *));
+int sys_seteuid __P((struct proc *, void *, register_t *));
+int svr4_sys_fchroot __P((struct proc *, void *, register_t *));
+int svr4_sys_vhangup __P((struct proc *, void *, register_t *));
+int svr4_sys_gettimeofday __P((struct proc *, void *, register_t *));
+int sys_getitimer __P((struct proc *, void *, register_t *));
+int sys_setitimer __P((struct proc *, void *, register_t *));
diff --git a/sys/compat/svr4/svr4_syscalls.c b/sys/compat/svr4/svr4_syscalls.c
new file mode 100644
index 00000000000..8019c68e7e8
--- /dev/null
+++ b/sys/compat/svr4/svr4_syscalls.c
@@ -0,0 +1,208 @@
+/*
+ * System call names.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp
+ */
+
+char *svr4_syscallnames[] = {
+ "syscall", /* 0 = syscall */
+ "exit", /* 1 = exit */
+ "fork", /* 2 = fork */
+ "read", /* 3 = read */
+ "write", /* 4 = write */
+ "open", /* 5 = open */
+ "close", /* 6 = close */
+ "wait", /* 7 = wait */
+ "creat", /* 8 = creat */
+ "link", /* 9 = link */
+ "unlink", /* 10 = unlink */
+ "execv", /* 11 = execv */
+ "chdir", /* 12 = chdir */
+ "time", /* 13 = time */
+ "mknod", /* 14 = mknod */
+ "chmod", /* 15 = chmod */
+ "chown", /* 16 = chown */
+ "break", /* 17 = break */
+ "stat", /* 18 = stat */
+ "lseek", /* 19 = lseek */
+ "getpid", /* 20 = getpid */
+ "#21 (unimplemented old_mount)", /* 21 = unimplemented old_mount */
+ "#22 (unimplemented System V umount)", /* 22 = unimplemented System V umount */
+ "setuid", /* 23 = setuid */
+ "getuid", /* 24 = getuid */
+ "#25 (unimplemented stime)", /* 25 = unimplemented stime */
+ "#26 (unimplemented ptrace)", /* 26 = unimplemented ptrace */
+ "alarm", /* 27 = alarm */
+ "fstat", /* 28 = fstat */
+ "#29 (unimplemented pause)", /* 29 = unimplemented pause */
+ "#30 (unimplemented utime)", /* 30 = unimplemented utime */
+ "#31 (unimplemented was stty)", /* 31 = unimplemented was stty */
+ "#32 (unimplemented was gtty)", /* 32 = unimplemented was gtty */
+ "access", /* 33 = access */
+ "#34 (unimplemented nice)", /* 34 = unimplemented nice */
+ "#35 (unimplemented statfs)", /* 35 = unimplemented statfs */
+ "sync", /* 36 = sync */
+ "kill", /* 37 = kill */
+ "#38 (unimplemented fstatfs)", /* 38 = unimplemented fstatfs */
+ "pgrpsys", /* 39 = pgrpsys */
+ "#40 (unimplemented xenix)", /* 40 = unimplemented xenix */
+ "dup", /* 41 = dup */
+ "pipe", /* 42 = pipe */
+ "times", /* 43 = times */
+ "#44 (unimplemented profil)", /* 44 = unimplemented profil */
+ "#45 (unimplemented plock)", /* 45 = unimplemented plock */
+ "setgid", /* 46 = setgid */
+ "getgid", /* 47 = getgid */
+ "signal", /* 48 = signal */
+#ifdef SYSVMSG
+ "#49 (unimplemented { int sys_msgsys ( int which , int a2 , int a3 , int a4 , int a5 , int a6 ) ; })", /* 49 = unimplemented { int sys_msgsys ( int which , int a2 , int a3 , int a4 , int a5 , int a6 ) ; } */
+#else
+ "#49 (unimplemented msgsys)", /* 49 = unimplemented msgsys */
+#endif
+ "sysarch", /* 50 = sysarch */
+ "#51 (unimplemented acct)", /* 51 = unimplemented acct */
+#ifdef SYSVSHM
+ "#52 (unimplemented { int sys_shmsys ( int which , int a2 , int a3 , int a4 ) ; })", /* 52 = unimplemented { int sys_shmsys ( int which , int a2 , int a3 , int a4 ) ; } */
+#else
+ "#52 (unimplemented shmsys)", /* 52 = unimplemented shmsys */
+#endif
+#ifdef SYSVSEM
+ "#53 (unimplemented { int sys_semsys ( int which , int a2 , int a3 , int a4 , int a5 ) ; })", /* 53 = unimplemented { int sys_semsys ( int which , int a2 , int a3 , int a4 , int a5 ) ; } */
+#else
+ "#53 (unimplemented semsys)", /* 53 = unimplemented semsys */
+#endif
+ "ioctl", /* 54 = ioctl */
+ "#55 (unimplemented uadmin)", /* 55 = unimplemented uadmin */
+ "#56 (unimplemented exch)", /* 56 = unimplemented exch */
+ "utssys", /* 57 = utssys */
+ "fsync", /* 58 = fsync */
+ "execve", /* 59 = execve */
+ "umask", /* 60 = umask */
+ "chroot", /* 61 = chroot */
+ "fcntl", /* 62 = fcntl */
+ "ulimit", /* 63 = ulimit */
+ "#64 (unimplemented reserved for unix/pc)", /* 64 = unimplemented reserved for unix/pc */
+ "#65 (unimplemented reserved for unix/pc)", /* 65 = unimplemented reserved for unix/pc */
+ "#66 (unimplemented reserved for unix/pc)", /* 66 = unimplemented reserved for unix/pc */
+ "#67 (unimplemented reserved for unix/pc)", /* 67 = unimplemented reserved for unix/pc */
+ "#68 (unimplemented reserved for unix/pc)", /* 68 = unimplemented reserved for unix/pc */
+ "#69 (unimplemented reserved for unix/pc)", /* 69 = unimplemented reserved for unix/pc */
+ "#70 (obsolete advfs)", /* 70 = obsolete advfs */
+ "#71 (obsolete unadvfs)", /* 71 = obsolete unadvfs */
+ "#72 (obsolete rmount)", /* 72 = obsolete rmount */
+ "#73 (obsolete rumount)", /* 73 = obsolete rumount */
+ "#74 (obsolete rfstart)", /* 74 = obsolete rfstart */
+ "#75 (obsolete sigret)", /* 75 = obsolete sigret */
+ "#76 (obsolete rdebug)", /* 76 = obsolete rdebug */
+ "#77 (obsolete rfstop)", /* 77 = obsolete rfstop */
+ "#78 (unimplemented rfsys)", /* 78 = unimplemented rfsys */
+ "rmdir", /* 79 = rmdir */
+ "mkdir", /* 80 = mkdir */
+ "getdents", /* 81 = getdents */
+ "#82 (obsolete libattach)", /* 82 = obsolete libattach */
+ "#83 (obsolete libdetach)", /* 83 = obsolete libdetach */
+ "#84 (unimplemented sysfs)", /* 84 = unimplemented sysfs */
+ "getmsg", /* 85 = getmsg */
+ "putmsg", /* 86 = putmsg */
+ "poll", /* 87 = poll */
+ "lstat", /* 88 = lstat */
+ "symlink", /* 89 = symlink */
+ "readlink", /* 90 = readlink */
+ "getgroups", /* 91 = getgroups */
+ "setgroups", /* 92 = setgroups */
+ "fchmod", /* 93 = fchmod */
+ "fchown", /* 94 = fchown */
+ "sigprocmask", /* 95 = sigprocmask */
+ "sigsuspend", /* 96 = sigsuspend */
+ "sigaltstack", /* 97 = sigaltstack */
+ "sigaction", /* 98 = sigaction */
+ "sigpending", /* 99 = sigpending */
+ "context", /* 100 = context */
+ "#101 (unimplemented evsys)", /* 101 = unimplemented evsys */
+ "#102 (unimplemented evtrapret)", /* 102 = unimplemented evtrapret */
+ "statvfs", /* 103 = statvfs */
+ "fstatvfs", /* 104 = fstatvfs */
+ "#105 (unimplemented)", /* 105 = unimplemented */
+ "#106 (unimplemented nfssvc)", /* 106 = unimplemented nfssvc */
+ "waitsys", /* 107 = waitsys */
+ "#108 (unimplemented sigsendsys)", /* 108 = unimplemented sigsendsys */
+ "hrtsys", /* 109 = hrtsys */
+ "#110 (unimplemented acancel)", /* 110 = unimplemented acancel */
+ "#111 (unimplemented async)", /* 111 = unimplemented async */
+ "#112 (unimplemented priocntlsys)", /* 112 = unimplemented priocntlsys */
+ "#113 (unimplemented pathconf)", /* 113 = unimplemented pathconf */
+ "#114 (unimplemented mincore)", /* 114 = unimplemented mincore */
+ "mmap", /* 115 = mmap */
+ "mprotect", /* 116 = mprotect */
+ "munmap", /* 117 = munmap */
+ "fpathconf", /* 118 = fpathconf */
+ "vfork", /* 119 = vfork */
+ "fchdir", /* 120 = fchdir */
+ "readv", /* 121 = readv */
+ "writev", /* 122 = writev */
+ "xstat", /* 123 = xstat */
+ "lxstat", /* 124 = lxstat */
+ "fxstat", /* 125 = fxstat */
+ "#126 (unimplemented xmknod)", /* 126 = unimplemented xmknod */
+ "#127 (unimplemented clocal)", /* 127 = unimplemented clocal */
+ "setrlimit", /* 128 = setrlimit */
+ "getrlimit", /* 129 = getrlimit */
+ "#130 (unimplemented lchown)", /* 130 = unimplemented lchown */
+ "#131 (unimplemented memcntl)", /* 131 = unimplemented memcntl */
+ "#132 (unimplemented getpmsg)", /* 132 = unimplemented getpmsg */
+ "#133 (unimplemented putpmsg)", /* 133 = unimplemented putpmsg */
+ "rename", /* 134 = rename */
+ "uname", /* 135 = uname */
+ "setegid", /* 136 = setegid */
+ "sysconfig", /* 137 = sysconfig */
+ "adjtime", /* 138 = adjtime */
+ "systeminfo", /* 139 = systeminfo */
+ "#140 (unimplemented)", /* 140 = unimplemented */
+ "seteuid", /* 141 = seteuid */
+ "#142 (unimplemented vtrace)", /* 142 = unimplemented vtrace */
+ "#143 (unimplemented fork1)", /* 143 = unimplemented fork1 */
+ "#144 (unimplemented sigwait)", /* 144 = unimplemented sigwait */
+ "#145 (unimplemented lwp_info)", /* 145 = unimplemented lwp_info */
+ "#146 (unimplemented yield)", /* 146 = unimplemented yield */
+ "#147 (unimplemented lwp_sema_p)", /* 147 = unimplemented lwp_sema_p */
+ "#148 (unimplemented lwp_sema_v)", /* 148 = unimplemented lwp_sema_v */
+ "#149 (unimplemented)", /* 149 = unimplemented */
+ "#150 (unimplemented)", /* 150 = unimplemented */
+ "#151 (unimplemented)", /* 151 = unimplemented */
+ "#152 (unimplemented modctl)", /* 152 = unimplemented modctl */
+ "fchroot", /* 153 = fchroot */
+ "#154 (unimplemented utimes)", /* 154 = unimplemented utimes */
+ "vhangup", /* 155 = vhangup */
+ "gettimeofday", /* 156 = gettimeofday */
+ "getitimer", /* 157 = getitimer */
+ "setitimer", /* 158 = setitimer */
+ "#159 (unimplemented lwp_create)", /* 159 = unimplemented lwp_create */
+ "#160 (unimplemented lwp_exit)", /* 160 = unimplemented lwp_exit */
+ "#161 (unimplemented lwp_suspend)", /* 161 = unimplemented lwp_suspend */
+ "#162 (unimplemented lwp_continue)", /* 162 = unimplemented lwp_continue */
+ "#163 (unimplemented lwp_kill)", /* 163 = unimplemented lwp_kill */
+ "#164 (unimplemented lwp_self)", /* 164 = unimplemented lwp_self */
+ "#165 (unimplemented lwp_getprivate)", /* 165 = unimplemented lwp_getprivate */
+ "#166 (unimplemented lwp_setprivate)", /* 166 = unimplemented lwp_setprivate */
+ "#167 (unimplemented lwp_wait)", /* 167 = unimplemented lwp_wait */
+ "#168 (unimplemented lwp_mutex_unlock)", /* 168 = unimplemented lwp_mutex_unlock */
+ "#169 (unimplemented lwp_mutex_lock)", /* 169 = unimplemented lwp_mutex_lock */
+ "#170 (unimplemented lwp_cond_wait)", /* 170 = unimplemented lwp_cond_wait */
+ "#171 (unimplemented lwp_cond_signal)", /* 171 = unimplemented lwp_cond_signal */
+ "#172 (unimplemented lwp_cond_broadcast)", /* 172 = unimplemented lwp_cond_broadcast */
+ "#173 (unimplemented pread)", /* 173 = unimplemented pread */
+ "#174 (unimplemented pwrite)", /* 174 = unimplemented pwrite */
+ "#175 (unimplemented llseek)", /* 175 = unimplemented llseek */
+ "#176 (unimplemented inst_sync)", /* 176 = unimplemented inst_sync */
+ "#177 (unimplemented)", /* 177 = unimplemented */
+ "#178 (unimplemented)", /* 178 = unimplemented */
+ "#179 (unimplemented)", /* 179 = unimplemented */
+ "#180 (unimplemented)", /* 180 = unimplemented */
+ "#181 (unimplemented)", /* 181 = unimplemented */
+ "#182 (unimplemented)", /* 182 = unimplemented */
+ "#183 (unimplemented)", /* 183 = unimplemented */
+ "#184 (unimplemented)", /* 184 = unimplemented */
+ "#185 (unimplemented)", /* 185 = unimplemented */
+ "#186 (unimplemented auditsys)", /* 186 = unimplemented auditsys */
+};
diff --git a/sys/compat/svr4/svr4_sysconfig.h b/sys/compat/svr4/svr4_sysconfig.h
new file mode 100644
index 00000000000..b487ac86414
--- /dev/null
+++ b/sys/compat/svr4/svr4_sysconfig.h
@@ -0,0 +1,61 @@
+/* $NetBSD: svr4_sysconfig.h,v 1.1 1995/07/02 06:16:10 christos Exp $ */
+
+/*
+ * Copyright (c) 1995 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.
+ */
+
+#ifndef _SVR4_SYSCONFIG_H_
+#define _SVR4_SYSCONFIG_H_
+
+#define SVR4_CONFIG_UNUSED 0x01
+#define SVR4_CONFIG_NGROUPS 0x02
+#define SVR4_CONFIG_CHILD_MAX 0x03
+#define SVR4_CONFIG_OPEN_FILES 0x04
+#define SVR4_CONFIG_POSIX_VER 0x05
+#define SVR4_CONFIG_PAGESIZE 0x06
+#define SVR4_CONFIG_CLK_TCK 0x07
+#define SVR4_CONFIG_XOPEN_VER 0x08
+#define SVR4_CONFIG_UNUSED_9 0x09
+#define SVR4_CONFIG_PROF_TCK 0x0a
+#define SVR4_CONFIG_NPROC_CONF 0x0b
+#define SVR4_CONFIG_NPROC_ONLN 0x0c
+#define SVR4_CONFIG_AIO_LISTIO_MAX 0x0e
+#define SVR4_CONFIG_AIO_MAX 0x0f
+#define SVR4_CONFIG_AIO_PRIO_DELTA_MAX 0x10
+#define SVR4_CONFIG_DELAYTIMER_MAX 0x11
+#define SVR4_CONFIG_MQ_OPEN_MAX 0x12
+#define SVR4_CONFIG_MQ_PRIO_MAX 0x13
+#define SVR4_CONFIG_RTSIG_MAX 0x14
+#define SVR4_CONFIG_SEM_NSEMS_MAX 0x15
+#define SVR4_CONFIG_SEM_VALUE_MAX 0x16
+#define SVR4_CONFIG_SIGQUEUE_MAX 0x17
+#define SVR4_CONFIG_SIGRT_MIN 0x18
+#define SVR4_CONFIG_SIGRT_MAX 0x19
+#define SVR4_CONFIG_TIMER_MAX 0x20
+#define SVR4_CONFIG_PHYS_PAGES 0x21
+#define SVR4_CONFIG_AVPHYS_PAGES 0x22
+
+#endif /* !_SVR4_SYSCONFIG_H_ */
diff --git a/sys/compat/svr4/svr4_sysent.c b/sys/compat/svr4/svr4_sysent.c
new file mode 100644
index 00000000000..0ebc6629df5
--- /dev/null
+++ b/sys/compat/svr4/svr4_sysent.c
@@ -0,0 +1,430 @@
+/*
+ * System call switch table.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signal.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_ucontext.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_statvfs.h>
+
+#ifdef COMPAT_43
+#define compat_43(func) __CONCAT(compat_43_,func)
+#else
+#define compat_43(func) sys_nosys
+#endif
+
+#ifdef COMPAT_09
+#define compat_09(func) __CONCAT(compat_09_,func)
+#else
+#define compat_09(func) sys_nosys
+#endif
+
+#ifdef COMPAT_10
+#define compat_10(func) __CONCAT(compat_10_,func)
+#else
+#define compat_10(func) sys_nosys
+#endif
+
+#define s(type) sizeof(type)
+
+struct sysent svr4_sysent[] = {
+ { 0, 0,
+ sys_nosys }, /* 0 = syscall */
+ { 1, s(struct sys_exit_args),
+ sys_exit }, /* 1 = exit */
+ { 0, 0,
+ sys_fork }, /* 2 = fork */
+ { 3, s(struct sys_read_args),
+ sys_read }, /* 3 = read */
+ { 3, s(struct sys_write_args),
+ sys_write }, /* 4 = write */
+ { 3, s(struct svr4_sys_open_args),
+ svr4_sys_open }, /* 5 = open */
+ { 1, s(struct sys_close_args),
+ sys_close }, /* 6 = close */
+ { 1, s(struct svr4_sys_wait_args),
+ svr4_sys_wait }, /* 7 = wait */
+ { 2, s(struct svr4_sys_creat_args),
+ svr4_sys_creat }, /* 8 = creat */
+ { 2, s(struct sys_link_args),
+ sys_link }, /* 9 = link */
+ { 1, s(struct sys_unlink_args),
+ sys_unlink }, /* 10 = unlink */
+ { 2, s(struct svr4_sys_execv_args),
+ svr4_sys_execv }, /* 11 = execv */
+ { 1, s(struct sys_chdir_args),
+ sys_chdir }, /* 12 = chdir */
+ { 1, s(struct svr4_sys_time_args),
+ svr4_sys_time }, /* 13 = time */
+ { 3, s(struct svr4_sys_mknod_args),
+ svr4_sys_mknod }, /* 14 = mknod */
+ { 2, s(struct sys_chmod_args),
+ sys_chmod }, /* 15 = chmod */
+ { 3, s(struct sys_chown_args),
+ sys_chown }, /* 16 = chown */
+ { 1, s(struct svr4_sys_break_args),
+ svr4_sys_break }, /* 17 = break */
+ { 2, s(struct svr4_sys_stat_args),
+ svr4_sys_stat }, /* 18 = stat */
+ { 3, s(struct compat_43_sys_lseek_args),
+ compat_43_sys_lseek }, /* 19 = lseek */
+ { 0, 0,
+ sys_getpid }, /* 20 = getpid */
+ { 0, 0,
+ sys_nosys }, /* 21 = unimplemented old_mount */
+ { 0, 0,
+ sys_nosys }, /* 22 = unimplemented System V umount */
+ { 1, s(struct sys_setuid_args),
+ sys_setuid }, /* 23 = setuid */
+ { 0, 0,
+ sys_getuid }, /* 24 = getuid */
+ { 0, 0,
+ sys_nosys }, /* 25 = unimplemented stime */
+ { 0, 0,
+ sys_nosys }, /* 26 = unimplemented ptrace */
+ { 1, s(struct svr4_sys_alarm_args),
+ svr4_sys_alarm }, /* 27 = alarm */
+ { 2, s(struct svr4_sys_fstat_args),
+ svr4_sys_fstat }, /* 28 = fstat */
+ { 0, 0,
+ sys_nosys }, /* 29 = unimplemented pause */
+ { 0, 0,
+ sys_nosys }, /* 30 = unimplemented utime */
+ { 0, 0,
+ sys_nosys }, /* 31 = unimplemented was stty */
+ { 0, 0,
+ sys_nosys }, /* 32 = unimplemented was gtty */
+ { 2, s(struct svr4_sys_access_args),
+ svr4_sys_access }, /* 33 = access */
+ { 0, 0,
+ sys_nosys }, /* 34 = unimplemented nice */
+ { 0, 0,
+ sys_nosys }, /* 35 = unimplemented statfs */
+ { 0, 0,
+ sys_sync }, /* 36 = sync */
+ { 2, s(struct svr4_sys_kill_args),
+ svr4_sys_kill }, /* 37 = kill */
+ { 0, 0,
+ sys_nosys }, /* 38 = unimplemented fstatfs */
+ { 3, s(struct svr4_sys_pgrpsys_args),
+ svr4_sys_pgrpsys }, /* 39 = pgrpsys */
+ { 0, 0,
+ sys_nosys }, /* 40 = unimplemented xenix */
+ { 1, s(struct sys_dup_args),
+ sys_dup }, /* 41 = dup */
+ { 0, 0,
+ sys_pipe }, /* 42 = pipe */
+ { 1, s(struct svr4_sys_times_args),
+ svr4_sys_times }, /* 43 = times */
+ { 0, 0,
+ sys_nosys }, /* 44 = unimplemented profil */
+ { 0, 0,
+ sys_nosys }, /* 45 = unimplemented plock */
+ { 1, s(struct sys_setgid_args),
+ sys_setgid }, /* 46 = setgid */
+ { 0, 0,
+ sys_getgid }, /* 47 = getgid */
+ { 2, s(struct svr4_sys_signal_args),
+ svr4_sys_signal }, /* 48 = signal */
+#ifdef SYSVMSG
+ { 0, 0,
+ sys_nosys }, /* 49 = unimplemented { int sys_msgsys ( int which , int a2 , int a3 , int a4 , int a5 , int a6 ) ; } */
+#else
+ { 0, 0,
+ sys_nosys }, /* 49 = unimplemented msgsys */
+#endif
+ { 2, s(struct svr4_sys_sysarch_args),
+ svr4_sys_sysarch }, /* 50 = sysarch */
+ { 0, 0,
+ sys_nosys }, /* 51 = unimplemented acct */
+#ifdef SYSVSHM
+ { 0, 0,
+ sys_nosys }, /* 52 = unimplemented { int sys_shmsys ( int which , int a2 , int a3 , int a4 ) ; } */
+#else
+ { 0, 0,
+ sys_nosys }, /* 52 = unimplemented shmsys */
+#endif
+#ifdef SYSVSEM
+ { 0, 0,
+ sys_nosys }, /* 53 = unimplemented { int sys_semsys ( int which , int a2 , int a3 , int a4 , int a5 ) ; } */
+#else
+ { 0, 0,
+ sys_nosys }, /* 53 = unimplemented semsys */
+#endif
+ { 3, s(struct svr4_sys_ioctl_args),
+ svr4_sys_ioctl }, /* 54 = ioctl */
+ { 0, 0,
+ sys_nosys }, /* 55 = unimplemented uadmin */
+ { 0, 0,
+ sys_nosys }, /* 56 = unimplemented exch */
+ { 4, s(struct svr4_sys_utssys_args),
+ svr4_sys_utssys }, /* 57 = utssys */
+ { 1, s(struct sys_fsync_args),
+ sys_fsync }, /* 58 = fsync */
+ { 3, s(struct svr4_sys_execve_args),
+ svr4_sys_execve }, /* 59 = execve */
+ { 1, s(struct sys_umask_args),
+ sys_umask }, /* 60 = umask */
+ { 1, s(struct sys_chroot_args),
+ sys_chroot }, /* 61 = chroot */
+ { 3, s(struct svr4_sys_fcntl_args),
+ svr4_sys_fcntl }, /* 62 = fcntl */
+ { 2, s(struct svr4_sys_ulimit_args),
+ svr4_sys_ulimit }, /* 63 = ulimit */
+ { 0, 0,
+ sys_nosys }, /* 64 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ sys_nosys }, /* 65 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ sys_nosys }, /* 66 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ sys_nosys }, /* 67 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ sys_nosys }, /* 68 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ sys_nosys }, /* 69 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ sys_nosys }, /* 70 = obsolete advfs */
+ { 0, 0,
+ sys_nosys }, /* 71 = obsolete unadvfs */
+ { 0, 0,
+ sys_nosys }, /* 72 = obsolete rmount */
+ { 0, 0,
+ sys_nosys }, /* 73 = obsolete rumount */
+ { 0, 0,
+ sys_nosys }, /* 74 = obsolete rfstart */
+ { 0, 0,
+ sys_nosys }, /* 75 = obsolete sigret */
+ { 0, 0,
+ sys_nosys }, /* 76 = obsolete rdebug */
+ { 0, 0,
+ sys_nosys }, /* 77 = obsolete rfstop */
+ { 0, 0,
+ sys_nosys }, /* 78 = unimplemented rfsys */
+ { 1, s(struct sys_rmdir_args),
+ sys_rmdir }, /* 79 = rmdir */
+ { 2, s(struct sys_mkdir_args),
+ sys_mkdir }, /* 80 = mkdir */
+ { 3, s(struct svr4_sys_getdents_args),
+ svr4_sys_getdents }, /* 81 = getdents */
+ { 0, 0,
+ sys_nosys }, /* 82 = obsolete libattach */
+ { 0, 0,
+ sys_nosys }, /* 83 = obsolete libdetach */
+ { 0, 0,
+ sys_nosys }, /* 84 = unimplemented sysfs */
+ { 4, s(struct svr4_sys_getmsg_args),
+ svr4_sys_getmsg }, /* 85 = getmsg */
+ { 4, s(struct svr4_sys_putmsg_args),
+ svr4_sys_putmsg }, /* 86 = putmsg */
+ { 3, s(struct svr4_sys_poll_args),
+ svr4_sys_poll }, /* 87 = poll */
+ { 2, s(struct svr4_sys_lstat_args),
+ svr4_sys_lstat }, /* 88 = lstat */
+ { 2, s(struct sys_symlink_args),
+ sys_symlink }, /* 89 = symlink */
+ { 3, s(struct sys_readlink_args),
+ sys_readlink }, /* 90 = readlink */
+ { 2, s(struct sys_getgroups_args),
+ sys_getgroups }, /* 91 = getgroups */
+ { 2, s(struct sys_setgroups_args),
+ sys_setgroups }, /* 92 = setgroups */
+ { 2, s(struct sys_fchmod_args),
+ sys_fchmod }, /* 93 = fchmod */
+ { 3, s(struct sys_fchown_args),
+ sys_fchown }, /* 94 = fchown */
+ { 3, s(struct svr4_sys_sigprocmask_args),
+ svr4_sys_sigprocmask }, /* 95 = sigprocmask */
+ { 1, s(struct svr4_sys_sigsuspend_args),
+ svr4_sys_sigsuspend }, /* 96 = sigsuspend */
+ { 2, s(struct svr4_sys_sigaltstack_args),
+ svr4_sys_sigaltstack }, /* 97 = sigaltstack */
+ { 3, s(struct svr4_sys_sigaction_args),
+ svr4_sys_sigaction }, /* 98 = sigaction */
+ { 2, s(struct svr4_sys_sigpending_args),
+ svr4_sys_sigpending }, /* 99 = sigpending */
+ { 2, s(struct svr4_sys_context_args),
+ svr4_sys_context }, /* 100 = context */
+ { 0, 0,
+ sys_nosys }, /* 101 = unimplemented evsys */
+ { 0, 0,
+ sys_nosys }, /* 102 = unimplemented evtrapret */
+ { 2, s(struct svr4_sys_statvfs_args),
+ svr4_sys_statvfs }, /* 103 = statvfs */
+ { 2, s(struct svr4_sys_fstatvfs_args),
+ svr4_sys_fstatvfs }, /* 104 = fstatvfs */
+ { 0, 0,
+ sys_nosys }, /* 105 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 106 = unimplemented nfssvc */
+ { 4, s(struct svr4_sys_waitsys_args),
+ svr4_sys_waitsys }, /* 107 = waitsys */
+ { 0, 0,
+ sys_nosys }, /* 108 = unimplemented sigsendsys */
+ { 5, s(struct svr4_sys_hrtsys_args),
+ svr4_sys_hrtsys }, /* 109 = hrtsys */
+ { 0, 0,
+ sys_nosys }, /* 110 = unimplemented acancel */
+ { 0, 0,
+ sys_nosys }, /* 111 = unimplemented async */
+ { 0, 0,
+ sys_nosys }, /* 112 = unimplemented priocntlsys */
+ { 0, 0,
+ sys_nosys }, /* 113 = unimplemented pathconf */
+ { 0, 0,
+ sys_nosys }, /* 114 = unimplemented mincore */
+ { 6, s(struct svr4_sys_mmap_args),
+ svr4_sys_mmap }, /* 115 = mmap */
+ { 3, s(struct sys_mprotect_args),
+ sys_mprotect }, /* 116 = mprotect */
+ { 2, s(struct sys_munmap_args),
+ sys_munmap }, /* 117 = munmap */
+ { 2, s(struct sys_fpathconf_args),
+ sys_fpathconf }, /* 118 = fpathconf */
+ { 0, 0,
+ sys_vfork }, /* 119 = vfork */
+ { 1, s(struct sys_fchdir_args),
+ sys_fchdir }, /* 120 = fchdir */
+ { 3, s(struct sys_readv_args),
+ sys_readv }, /* 121 = readv */
+ { 3, s(struct sys_writev_args),
+ sys_writev }, /* 122 = writev */
+ { 3, s(struct svr4_sys_xstat_args),
+ svr4_sys_xstat }, /* 123 = xstat */
+ { 3, s(struct svr4_sys_lxstat_args),
+ svr4_sys_lxstat }, /* 124 = lxstat */
+ { 3, s(struct svr4_sys_fxstat_args),
+ svr4_sys_fxstat }, /* 125 = fxstat */
+ { 0, 0,
+ sys_nosys }, /* 126 = unimplemented xmknod */
+ { 0, 0,
+ sys_nosys }, /* 127 = unimplemented clocal */
+ { 2, s(struct svr4_sys_setrlimit_args),
+ svr4_sys_setrlimit }, /* 128 = setrlimit */
+ { 2, s(struct svr4_sys_getrlimit_args),
+ svr4_sys_getrlimit }, /* 129 = getrlimit */
+ { 0, 0,
+ sys_nosys }, /* 130 = unimplemented lchown */
+ { 0, 0,
+ sys_nosys }, /* 131 = unimplemented memcntl */
+ { 0, 0,
+ sys_nosys }, /* 132 = unimplemented getpmsg */
+ { 0, 0,
+ sys_nosys }, /* 133 = unimplemented putpmsg */
+ { 2, s(struct sys_rename_args),
+ sys_rename }, /* 134 = rename */
+ { 2, s(struct svr4_sys_uname_args),
+ svr4_sys_uname }, /* 135 = uname */
+ { 1, s(struct sys_setegid_args),
+ sys_setegid }, /* 136 = setegid */
+ { 1, s(struct svr4_sys_sysconfig_args),
+ svr4_sys_sysconfig }, /* 137 = sysconfig */
+ { 2, s(struct sys_adjtime_args),
+ sys_adjtime }, /* 138 = adjtime */
+ { 3, s(struct svr4_sys_systeminfo_args),
+ svr4_sys_systeminfo }, /* 139 = systeminfo */
+ { 0, 0,
+ sys_nosys }, /* 140 = unimplemented */
+ { 1, s(struct sys_seteuid_args),
+ sys_seteuid }, /* 141 = seteuid */
+ { 0, 0,
+ sys_nosys }, /* 142 = unimplemented vtrace */
+ { 0, 0,
+ sys_nosys }, /* 143 = unimplemented fork1 */
+ { 0, 0,
+ sys_nosys }, /* 144 = unimplemented sigwait */
+ { 0, 0,
+ sys_nosys }, /* 145 = unimplemented lwp_info */
+ { 0, 0,
+ sys_nosys }, /* 146 = unimplemented yield */
+ { 0, 0,
+ sys_nosys }, /* 147 = unimplemented lwp_sema_p */
+ { 0, 0,
+ sys_nosys }, /* 148 = unimplemented lwp_sema_v */
+ { 0, 0,
+ sys_nosys }, /* 149 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 150 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 151 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 152 = unimplemented modctl */
+ { 1, s(struct svr4_sys_fchroot_args),
+ svr4_sys_fchroot }, /* 153 = fchroot */
+ { 0, 0,
+ sys_nosys }, /* 154 = unimplemented utimes */
+ { 0, 0,
+ svr4_sys_vhangup }, /* 155 = vhangup */
+ { 1, s(struct svr4_sys_gettimeofday_args),
+ svr4_sys_gettimeofday }, /* 156 = gettimeofday */
+ { 2, s(struct sys_getitimer_args),
+ sys_getitimer }, /* 157 = getitimer */
+ { 3, s(struct sys_setitimer_args),
+ sys_setitimer }, /* 158 = setitimer */
+ { 0, 0,
+ sys_nosys }, /* 159 = unimplemented lwp_create */
+ { 0, 0,
+ sys_nosys }, /* 160 = unimplemented lwp_exit */
+ { 0, 0,
+ sys_nosys }, /* 161 = unimplemented lwp_suspend */
+ { 0, 0,
+ sys_nosys }, /* 162 = unimplemented lwp_continue */
+ { 0, 0,
+ sys_nosys }, /* 163 = unimplemented lwp_kill */
+ { 0, 0,
+ sys_nosys }, /* 164 = unimplemented lwp_self */
+ { 0, 0,
+ sys_nosys }, /* 165 = unimplemented lwp_getprivate */
+ { 0, 0,
+ sys_nosys }, /* 166 = unimplemented lwp_setprivate */
+ { 0, 0,
+ sys_nosys }, /* 167 = unimplemented lwp_wait */
+ { 0, 0,
+ sys_nosys }, /* 168 = unimplemented lwp_mutex_unlock */
+ { 0, 0,
+ sys_nosys }, /* 169 = unimplemented lwp_mutex_lock */
+ { 0, 0,
+ sys_nosys }, /* 170 = unimplemented lwp_cond_wait */
+ { 0, 0,
+ sys_nosys }, /* 171 = unimplemented lwp_cond_signal */
+ { 0, 0,
+ sys_nosys }, /* 172 = unimplemented lwp_cond_broadcast */
+ { 0, 0,
+ sys_nosys }, /* 173 = unimplemented pread */
+ { 0, 0,
+ sys_nosys }, /* 174 = unimplemented pwrite */
+ { 0, 0,
+ sys_nosys }, /* 175 = unimplemented llseek */
+ { 0, 0,
+ sys_nosys }, /* 176 = unimplemented inst_sync */
+ { 0, 0,
+ sys_nosys }, /* 177 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 178 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 179 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 180 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 181 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 182 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 183 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 184 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 185 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 186 = unimplemented auditsys */
+};
+
diff --git a/sys/compat/svr4/svr4_systeminfo.h b/sys/compat/svr4/svr4_systeminfo.h
new file mode 100644
index 00000000000..aa51734f92a
--- /dev/null
+++ b/sys/compat/svr4/svr4_systeminfo.h
@@ -0,0 +1,45 @@
+/* $NetBSD: svr4_systeminfo.h,v 1.2 1994/11/18 02:54:18 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.
+ */
+
+#ifndef _SVR4_SYSTEMINFO_H_
+#define _SVR4_SYSTEMINFO_H_
+
+#define SVR4_SI_SYSNAME 1
+#define SVR4_SI_HOSTNAME 2
+#define SVR4_SI_RELEASE 3
+#define SVR4_SI_VERSION 4
+#define SVR4_SI_MACHINE 5
+#define SVR4_SI_ARCHITECTURE 6
+#define SVR4_SI_HW_SERIAL 7
+#define SVR4_SI_HW_PROVIDER 8
+#define SVR4_SI_SRPC_DOMAIN 9
+#define SVR4_SI_SET_HOSTNAME 258
+#define SVR4_SI_SET_SRPC_DOMAIN 265
+
+#endif /* !_SVR4_SYSTEMINFO_H_ */
diff --git a/sys/compat/svr4/svr4_termios.c b/sys/compat/svr4/svr4_termios.c
new file mode 100644
index 00000000000..984c7b514a1
--- /dev/null
+++ b/sys/compat/svr4/svr4_termios.c
@@ -0,0 +1,547 @@
+/* $NetBSD: svr4_termios.c,v 1.5 1995/10/07 06:27:55 mycroft 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/proc.h>
+#include <sys/systm.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/termios.h>
+#include <sys/tty.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <net/if.h>
+#include <sys/malloc.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_stropts.h>
+#include <compat/svr4/svr4_termios.h>
+
+
+#ifndef __CONCAT3
+# if __STDC__
+# define __CONCAT3(a,b,c) a ## b ## c
+# else
+# define __CONCAT3(a,b,c) a/**/b/**/c
+# endif
+#endif
+
+static u_long bsd_to_svr4_speed __P((u_long sp, u_long mask));
+static u_long svr4_to_bsd_speed __P((u_long sp, u_long mask));
+static void svr4_to_bsd_termios __P((const struct svr4_termios *st,
+ struct termios *bt));
+static void bsd_to_svr4_termios __P((const struct termios *bt,
+ struct svr4_termios *st));
+static void svr4_termio_to_termios __P((const struct svr4_termio *t,
+ struct svr4_termios *ts));
+static void svr4_termios_to_termio __P((const struct svr4_termios *ts,
+ struct svr4_termio *t));
+
+#define undefined_char(a,b) /**/
+#define undefined_flag1(f,a,b) /**/
+#define undefined_flag2(f,a,b,c1,t1,c2,t2) /**/
+#define undefined_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) /**/
+
+#define svr4_to_bsd_char(a,b) \
+ if (st->c_cc[__CONCAT(a,b)] == SVR4_POSIX_VDISABLE) \
+ bt->c_cc[__CONCAT(a,b)] = _POSIX_VDISABLE; \
+ else \
+ bt->c_cc[__CONCAT(a,b)] = st->c_cc[__CONCAT3(SVR4_,a,b)]
+
+#define svr4_to_bsd_flag1(f,a,b) \
+ if (st->f & __CONCAT3(SVR4_,a,b)) \
+ bt->f |= __CONCAT(a,b); \
+ else \
+ bt->f &= ~__CONCAT(a,b)
+
+#define svr4_to_bsd_flag2(f,a,b,c1,t1,c2,t2) \
+ bt->f &= ~__CONCAT(a,b); \
+ switch (st->f & __CONCAT3(SVR4_,a,b)) { \
+ case __CONCAT3(SVR4_,c1,t1): bt->f |= __CONCAT(c1,t1); break; \
+ case __CONCAT3(SVR4_,c2,t2): bt->f |= __CONCAT(c2,t2); break; \
+ }
+
+#define svr4_to_bsd_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) \
+ bt->f &= ~__CONCAT(a,b); \
+ switch (st->f & __CONCAT3(SVR4_,a,b)) { \
+ case __CONCAT3(SVR4_,c1,t1): bt->f |= __CONCAT(c1,t1); break; \
+ case __CONCAT3(SVR4_,c2,t2): bt->f |= __CONCAT(c2,t2); break; \
+ case __CONCAT3(SVR4_,c3,t3): bt->f |= __CONCAT(c3,t3); break; \
+ case __CONCAT3(SVR4_,c4,t4): bt->f |= __CONCAT(c4,t4); break; \
+ }
+
+
+#define bsd_to_svr4_char(a,b) \
+ if (bt->c_cc[__CONCAT(a,b)] == _POSIX_VDISABLE) \
+ st->c_cc[__CONCAT3(SVR4_,a,b)] = SVR4_POSIX_VDISABLE; \
+ else \
+ st->c_cc[__CONCAT3(SVR4_,a,b)] = bt->c_cc[__CONCAT(a,b)]
+
+#define bsd_to_svr4_flag1(f,a,b) \
+ if (bt->f & __CONCAT(a,b)) \
+ st->f |= __CONCAT3(SVR4_,a,b); \
+ else \
+ st->f &= ~__CONCAT3(SVR4_,a,b)
+
+#define bsd_to_svr4_flag2(f,a,b,c1,t1,c2,t2) \
+ st->f &= ~__CONCAT(a,b); \
+ switch (bt->f & __CONCAT(a,b)) { \
+ case __CONCAT(c1,t1): st->f |= __CONCAT3(SVR4_,c1,t1); break; \
+ case __CONCAT(c2,t2): st->f |= __CONCAT3(SVR4_,c2,t2); break; \
+ }
+
+#define bsd_to_svr4_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) \
+ st->f &= ~__CONCAT(a,b); \
+ switch (bt->f & __CONCAT(a,b)) { \
+ case __CONCAT(c1,t1): st->f |= __CONCAT3(SVR4_,c1,t1); break; \
+ case __CONCAT(c2,t2): st->f |= __CONCAT3(SVR4_,c2,t2); break; \
+ case __CONCAT(c3,t3): st->f |= __CONCAT3(SVR4_,c3,t3); break; \
+ case __CONCAT(c4,t4): st->f |= __CONCAT3(SVR4_,c4,t4); break; \
+ }
+
+static u_long
+bsd_to_svr4_speed(sp, mask)
+ u_long sp;
+ u_long mask;
+{
+ switch (sp) {
+#undef getval
+#define getval(a,b) case __CONCAT(a,b): sp = __CONCAT3(SVR4_,a,b)
+ getval(B,0);
+ getval(B,50);
+ getval(B,75);
+ getval(B,110);
+ getval(B,134);
+ getval(B,150);
+ getval(B,200);
+ getval(B,300);
+ getval(B,600);
+ getval(B,1200);
+ getval(B,1800);
+ getval(B,2400);
+ getval(B,4800);
+ getval(B,9600);
+ getval(B,19200);
+ getval(B,38400);
+ default: sp = SVR4_B9600; /* XXX */
+ }
+
+ while ((mask & 1) == 0) {
+ mask >>= 1;
+ sp <<= 1;
+ }
+
+ return sp;
+}
+
+
+static u_long
+svr4_to_bsd_speed(sp, mask)
+ u_long sp;
+ u_long mask;
+{
+ while ((mask & 1) == 0) {
+ mask >>= 1;
+ sp >>= 1;
+ }
+
+ switch (sp & mask) {
+#undef getval
+#define getval(a,b) case __CONCAT3(SVR4_,a,b): return __CONCAT(a,b)
+ getval(B,0);
+ getval(B,50);
+ getval(B,75);
+ getval(B,110);
+ getval(B,134);
+ getval(B,150);
+ getval(B,200);
+ getval(B,300);
+ getval(B,600);
+ getval(B,1200);
+ getval(B,1800);
+ getval(B,2400);
+ getval(B,4800);
+ getval(B,9600);
+ getval(B,19200);
+ getval(B,38400);
+ default: return B9600; /* XXX */
+ }
+}
+
+
+static void
+svr4_to_bsd_termios(st, bt)
+ const struct svr4_termios *st;
+ struct termios *bt;
+{
+ /* control characters */
+ svr4_to_bsd_char(V,INTR);
+ svr4_to_bsd_char(V,QUIT);
+ svr4_to_bsd_char(V,ERASE);
+ svr4_to_bsd_char(V,KILL);
+ svr4_to_bsd_char(V,EOF);
+ svr4_to_bsd_char(V,EOL);
+ svr4_to_bsd_char(V,EOL2);
+ svr4_to_bsd_char(V,MIN);
+ svr4_to_bsd_char(V,TIME);
+ undefined_char(V,SWTCH);
+ svr4_to_bsd_char(V,START);
+ svr4_to_bsd_char(V,STOP);
+ svr4_to_bsd_char(V,SUSP);
+ svr4_to_bsd_char(V,DSUSP);
+ svr4_to_bsd_char(V,REPRINT);
+ svr4_to_bsd_char(V,DISCARD);
+ svr4_to_bsd_char(V,WERASE);
+ svr4_to_bsd_char(V,LNEXT);
+
+ /* Input modes */
+ svr4_to_bsd_flag1(c_iflag,I,GNBRK);
+ svr4_to_bsd_flag1(c_iflag,B,RKINT);
+ svr4_to_bsd_flag1(c_iflag,I,GNPAR);
+ svr4_to_bsd_flag1(c_iflag,P,ARMRK);
+ svr4_to_bsd_flag1(c_iflag,I,NPCK);
+ svr4_to_bsd_flag1(c_iflag,I,STRIP);
+ svr4_to_bsd_flag1(c_iflag,I,NLCR);
+ svr4_to_bsd_flag1(c_iflag,I,GNCR);
+ svr4_to_bsd_flag1(c_iflag,I,CRNL);
+ undefined_flag1(c_iflag,I,UCLC);
+ svr4_to_bsd_flag1(c_iflag,I,XON);
+ svr4_to_bsd_flag1(c_iflag,I,XANY);
+ svr4_to_bsd_flag1(c_iflag,I,XOFF);
+ svr4_to_bsd_flag1(c_iflag,I,MAXBEL);
+ undefined_flag1(c_iflag,D,OSMODE);
+
+ /* Output modes */
+ svr4_to_bsd_flag1(c_oflag,O,POST);
+ undefined_flag1(c_oflag,O,LCUC);
+ svr4_to_bsd_flag1(c_oflag,O,NLCR);
+ undefined_flag1(c_oflag,O,CRNL);
+ undefined_flag1(c_oflag,O,NOCR);
+ undefined_flag1(c_oflag,O,NLRET);
+ undefined_flag1(c_oflag,O,FILL);
+ undefined_flag1(c_oflag,O,FDEL);
+ undefined_flag2(c_oflag,N,LDLY,N,L0,N,L1);
+ undefined_flag4(c_oflag,C,RDLY,C,R0,C,R1,C,R2,C,R3);
+ undefined_flag4(c_oflag,T,ABDLY,T,AB0,T,AB1,T,AB2,T,AB3);
+ undefined_flag2(c_oflag,B,SDLY,B,S0,B,S1);
+ undefined_flag2(c_oflag,V,TDLY,V,T0,V,T1);
+ undefined_flag2(c_oflag,F,FDLY,F,F0,F,F1);
+ undefined_flag1(c_oflag,P,AGEOUT);
+ undefined_flag1(c_oflag,W,RAP);
+
+ /* Control modes */
+ bt->c_ospeed = svr4_to_bsd_speed(st->c_cflag, SVR4_CBAUD);
+ svr4_to_bsd_flag4(c_cflag,C,SIZE,C,S5,C,S6,C,S7,C,S8)
+ svr4_to_bsd_flag1(c_cflag,C,STOPB);
+ svr4_to_bsd_flag1(c_cflag,C,READ);
+ svr4_to_bsd_flag1(c_cflag,P,ARENB);
+ svr4_to_bsd_flag1(c_cflag,P,ARODD);
+ svr4_to_bsd_flag1(c_cflag,H,UPCL);
+ svr4_to_bsd_flag1(c_cflag,C,LOCAL);
+ undefined_flag1(c_cflag,R,CV1EN);
+ undefined_flag1(c_cflag,X,MT1EN);
+ undefined_flag1(c_cflag,L,OBLK);
+ undefined_flag1(c_cflag,X,CLUDE);
+ bt->c_ispeed = svr4_to_bsd_speed(st->c_cflag, SVR4_CIBAUD);
+ undefined_flag1(c_cflag,P,AREXT);
+
+ /* line discipline modes */
+ svr4_to_bsd_flag1(c_lflag,I,SIG);
+ svr4_to_bsd_flag1(c_lflag,I,CANON);
+ undefined_flag1(c_lflag,X,CASE);
+ svr4_to_bsd_flag1(c_lflag,E,CHO);
+ svr4_to_bsd_flag1(c_lflag,E,CHOE);
+ svr4_to_bsd_flag1(c_lflag,E,CHOK);
+ svr4_to_bsd_flag1(c_lflag,E,CHONL);
+ svr4_to_bsd_flag1(c_lflag,N,OFLSH);
+ svr4_to_bsd_flag1(c_lflag,T,OSTOP);
+ svr4_to_bsd_flag1(c_lflag,E,CHOCTL);
+ svr4_to_bsd_flag1(c_lflag,E,CHOPRT);
+ svr4_to_bsd_flag1(c_lflag,E,CHOKE);
+ undefined_flag1(c_lflag,D,EFECHO);
+ svr4_to_bsd_flag1(c_lflag,F,LUSHO);
+ svr4_to_bsd_flag1(c_lflag,P,ENDIN);
+ svr4_to_bsd_flag1(c_lflag,I,EXTEN);
+}
+
+
+static void
+bsd_to_svr4_termios(bt, st)
+ const struct termios *bt;
+ struct svr4_termios *st;
+{
+ /* control characters */
+ bsd_to_svr4_char(V,INTR);
+ bsd_to_svr4_char(V,QUIT);
+ bsd_to_svr4_char(V,ERASE);
+ bsd_to_svr4_char(V,KILL);
+ bsd_to_svr4_char(V,EOF);
+ bsd_to_svr4_char(V,EOL);
+ bsd_to_svr4_char(V,EOL2);
+ bsd_to_svr4_char(V,MIN);
+ bsd_to_svr4_char(V,TIME);
+ undefined_char(V,SWTCH);
+ bsd_to_svr4_char(V,START);
+ bsd_to_svr4_char(V,STOP);
+ bsd_to_svr4_char(V,SUSP);
+ bsd_to_svr4_char(V,DSUSP);
+ bsd_to_svr4_char(V,REPRINT);
+ bsd_to_svr4_char(V,DISCARD);
+ bsd_to_svr4_char(V,WERASE);
+ bsd_to_svr4_char(V,LNEXT);
+
+ /* Input modes */
+ bsd_to_svr4_flag1(c_iflag,I,GNBRK);
+ bsd_to_svr4_flag1(c_iflag,B,RKINT);
+ bsd_to_svr4_flag1(c_iflag,I,GNPAR);
+ bsd_to_svr4_flag1(c_iflag,P,ARMRK);
+ bsd_to_svr4_flag1(c_iflag,I,NPCK);
+ bsd_to_svr4_flag1(c_iflag,I,STRIP);
+ bsd_to_svr4_flag1(c_iflag,I,NLCR);
+ bsd_to_svr4_flag1(c_iflag,I,GNCR);
+ bsd_to_svr4_flag1(c_iflag,I,CRNL);
+ undefined_flag1(c_iflag,I,UCLC);
+ bsd_to_svr4_flag1(c_iflag,I,XON);
+ bsd_to_svr4_flag1(c_iflag,I,XANY);
+ bsd_to_svr4_flag1(c_iflag,I,XOFF);
+ bsd_to_svr4_flag1(c_iflag,I,MAXBEL);
+ undefined_flag1(c_iflag,D,OSMODE);
+
+ /* Output modes */
+ bsd_to_svr4_flag1(c_oflag,O,POST);
+ undefined_flag1(c_oflag,O,LCUC);
+ undefined_flag1(c_oflag,O,NLCR);
+ undefined_flag1(c_oflag,O,CRNL);
+ undefined_flag1(c_oflag,O,NOCR);
+ undefined_flag1(c_oflag,O,NLRET);
+ undefined_flag1(c_oflag,O,FILL);
+ undefined_flag1(c_oflag,O,FDEL);
+ undefined_flag2(c_oflag,N,LDLY,N,L0,N,L1);
+ undefined_flag4(c_oflag,C,RDLY,C,R0,C,R1,C,R2,C,R3);
+ undefined_flag4(c_oflag,T,ABDLY,T,AB0,T,AB1,T,AB2,T,AB3);
+ undefined_flag2(c_oflag,B,SDLY,B,S0,B,S1);
+ undefined_flag2(c_oflag,V,TDLY,V,T0,V,T1);
+ undefined_flag2(c_oflag,F,FDLY,F,F0,F,F1);
+ undefined_flag1(c_oflag,P,AGEOUT);
+ undefined_flag1(c_oflag,W,RAP);
+
+ /* Control modes */
+ st->c_cflag &= ~SVR4_CBAUD;
+ st->c_cflag |= bsd_to_svr4_speed(bt->c_ospeed, SVR4_CBAUD);
+ bsd_to_svr4_flag4(c_cflag,C,SIZE,C,S5,C,S6,C,S7,C,S8)
+ bsd_to_svr4_flag1(c_cflag,C,STOPB);
+ bsd_to_svr4_flag1(c_cflag,C,READ);
+ bsd_to_svr4_flag1(c_cflag,P,ARENB);
+ bsd_to_svr4_flag1(c_cflag,P,ARODD);
+ bsd_to_svr4_flag1(c_cflag,H,UPCL);
+ bsd_to_svr4_flag1(c_cflag,C,LOCAL);
+ undefined_flag1(c_cflag,R,CV1EN);
+ undefined_flag1(c_cflag,X,MT1EN);
+ undefined_flag1(c_cflag,L,OBLK);
+ undefined_flag1(c_cflag,X,CLUDE);
+ st->c_cflag &= ~SVR4_CIBAUD;
+ st->c_cflag |= bsd_to_svr4_speed(bt->c_ispeed, SVR4_CIBAUD);
+
+ undefined_flag1(c_oflag,P,AREXT);
+
+ /* line discipline modes */
+ bsd_to_svr4_flag1(c_lflag,I,SIG);
+ bsd_to_svr4_flag1(c_lflag,I,CANON);
+ undefined_flag1(c_lflag,X,CASE);
+ bsd_to_svr4_flag1(c_lflag,E,CHO);
+ bsd_to_svr4_flag1(c_lflag,E,CHOE);
+ bsd_to_svr4_flag1(c_lflag,E,CHOK);
+ bsd_to_svr4_flag1(c_lflag,E,CHONL);
+ bsd_to_svr4_flag1(c_lflag,N,OFLSH);
+ bsd_to_svr4_flag1(c_lflag,T,OSTOP);
+ bsd_to_svr4_flag1(c_lflag,E,CHOCTL);
+ bsd_to_svr4_flag1(c_lflag,E,CHOPRT);
+ bsd_to_svr4_flag1(c_lflag,E,CHOKE);
+ undefined_flag1(c_lflag,D,EFECHO);
+ bsd_to_svr4_flag1(c_lflag,F,LUSHO);
+ bsd_to_svr4_flag1(c_lflag,P,ENDIN);
+ bsd_to_svr4_flag1(c_lflag,I,EXTEN);
+}
+
+
+static void
+svr4_termio_to_termios(t, ts)
+ const struct svr4_termio *t;
+ struct svr4_termios *ts;
+{
+ int i;
+
+ ts->c_iflag = (svr4_tcflag_t) t->c_iflag;
+ ts->c_oflag = (svr4_tcflag_t) t->c_oflag;
+ ts->c_cflag = (svr4_tcflag_t) t->c_cflag;
+ ts->c_lflag = (svr4_tcflag_t) t->c_lflag;
+
+ for (i = 0; i < SVR4_NCC; i++)
+ ts->c_cc[i] = (svr4_cc_t) t->c_cc[i];
+}
+
+
+static void
+svr4_termios_to_termio(ts, t)
+ const struct svr4_termios *ts;
+ struct svr4_termio *t;
+{
+ int i;
+
+ t->c_iflag = (u_short) ts->c_iflag;
+ t->c_oflag = (u_short) ts->c_oflag;
+ t->c_cflag = (u_short) ts->c_cflag;
+ t->c_lflag = (u_short) ts->c_lflag;
+ t->c_line = 0; /* XXX */
+
+ for (i = 0; i < SVR4_NCC; i++)
+ t->c_cc[i] = (u_char) ts->c_cc[i];
+}
+
+int
+svr4_termioctl(fp, cmd, data, p, retval)
+ struct file *fp;
+ u_long cmd;
+ caddr_t data;
+ struct proc *p;
+ register_t *retval;
+{
+ struct termios bt;
+ struct svr4_termios st;
+ struct svr4_termio t;
+ int error;
+ int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
+ fp->f_ops->fo_ioctl;
+
+ *retval = 0;
+
+ switch (cmd) {
+ case SVR4_TCGETA:
+ case SVR4_TCGETS:
+ if ((error = (*ctl)(fp, TIOCGETA, (caddr_t) &bt, p)) != 0)
+ return error;
+
+#ifdef DEBUG_SVR4
+ {
+ int i;
+ printf("iflag=%o oflag=%o cflag=%o lflag=%o\n",
+ bt.c_iflag, bt.c_oflag, bt.c_lflag);
+ printf("cc: ");
+ for (i = 0; i < NCCS; i++)
+ printf("%o ", bt.c_cc[i]);
+ printf("\n");
+ }
+#endif
+
+ bsd_to_svr4_termios(&bt, &st);
+
+ DPRINTF(("ioctl(TCGET[A|S]);\n"));
+
+#ifdef DEBUG_SVR4
+ {
+ int i;
+ printf("iflag=%o oflag=%o cflag=%o lflag=%o\n",
+ st.c_iflag, st.c_oflag, st.c_lflag);
+ printf("cc: ");
+ for (i = 0; i < SVR4_NCCS; i++)
+ printf("%o ", st.c_cc[i]);
+ printf("\n");
+ }
+#endif
+
+ if (cmd == SVR4_TCGETA) {
+ svr4_termios_to_termio(&st, &t);
+ return copyout(&t, data, sizeof(t));
+ }
+ else {
+ return copyout(&st, data, sizeof(st));
+ }
+
+ case SVR4_TCSETA:
+ case SVR4_TCSETS:
+ case SVR4_TCSETAW:
+ case SVR4_TCSETSW:
+ case SVR4_TCSETAF:
+ case SVR4_TCSETSF:
+ /* get full BSD termios so we don't lose information */
+ if ((error = (*ctl)(fp, TIOCGETA, (caddr_t) &bt, p)) != 0)
+ return error;
+
+ switch (cmd) {
+ case SVR4_TCSETS:
+ case SVR4_TCSETSW:
+ case SVR4_TCSETSF:
+ if ((error = copyin(data, &st, sizeof(st))) != 0)
+ return error;
+ break;
+
+ case SVR4_TCSETA:
+ case SVR4_TCSETAW:
+ case SVR4_TCSETAF:
+ if ((error = copyin(data, &t, sizeof(t))) != 0)
+ return error;
+
+ svr4_termio_to_termios(&t, &st);
+ break;
+ }
+
+ svr4_to_bsd_termios(&st, &bt);
+
+ switch (cmd) {
+ case SVR4_TCSETA:
+ case SVR4_TCSETS:
+ DPRINTF(("ioctl(TCSET[A|S]);\n"));
+ cmd = TIOCSETA;
+ break;
+ case SVR4_TCSETAW:
+ case SVR4_TCSETSW:
+ DPRINTF(("ioctl(TCSET[A|S]W);\n"));
+ cmd = TIOCSETAW;
+ break;
+ case SVR4_TCSETAF:
+ case SVR4_TCSETSF:
+ DPRINTF(("ioctl(TCSET[A|S]F);\n"));
+ cmd = TIOCSETAF;
+ break;
+ }
+
+ return (*ctl)(fp, cmd, (caddr_t) &bt, p);
+
+ default:
+ DPRINTF(("Unknown svr4 termios %x\n", cmd));
+ return ENOSYS;
+ }
+}
diff --git a/sys/compat/svr4/svr4_termios.h b/sys/compat/svr4/svr4_termios.h
new file mode 100644
index 00000000000..930c696b833
--- /dev/null
+++ b/sys/compat/svr4/svr4_termios.h
@@ -0,0 +1,217 @@
+/* $NetBSD: svr4_termios.h,v 1.2 1994/11/18 02:54:21 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.
+ */
+
+#ifndef _SVR4_TERMIOS_H_
+#define _SVR4_TERMIOS_H_
+
+#define SVR4_POSIX_VDISABLE 0
+#define SVR4_NCC 8
+#define SVR4_NCCS 19
+
+typedef u_long svr4_tcflag_t;
+typedef u_char svr4_cc_t;
+typedef u_long svr4_speed_t;
+
+struct svr4_termios {
+ svr4_tcflag_t c_iflag;
+ svr4_tcflag_t c_oflag;
+ svr4_tcflag_t c_cflag;
+ svr4_tcflag_t c_lflag;
+ svr4_cc_t c_cc[SVR4_NCCS];
+};
+
+struct svr4_termio {
+ u_short c_iflag;
+ u_short c_oflag;
+ u_short c_cflag;
+ u_short c_lflag;
+ char c_line;
+ u_char c_cc[SVR4_NCC];
+};
+
+/* control characters */
+#define SVR4_VINTR 0
+#define SVR4_VQUIT 1
+#define SVR4_VERASE 2
+#define SVR4_VKILL 3
+#define SVR4_VEOF 4
+#define SVR4_VEOL 5
+#define SVR4_VEOL2 6
+#define SVR4_VMIN 4
+#define SVR4_VTIME 5
+#define SVR4_VSWTCH 7
+#define SVR4_VSTART 8
+#define SVR4_VSTOP 9
+#define SVR4_VSUSP 10
+#define SVR4_VDSUSP 11
+#define SVR4_VREPRINT 12
+#define SVR4_VDISCARD 13
+#define SVR4_VWERASE 14
+#define SVR4_VLNEXT 15
+
+/* Input modes */
+#define SVR4_IGNBRK 00000001
+#define SVR4_BRKINT 00000002
+#define SVR4_IGNPAR 00000004
+#define SVR4_PARMRK 00000010
+#define SVR4_INPCK 00000020
+#define SVR4_ISTRIP 00000040
+#define SVR4_INLCR 00000100
+#define SVR4_IGNCR 00000200
+#define SVR4_ICRNL 00000400
+#define SVR4_IUCLC 00001000
+#define SVR4_IXON 00002000
+#define SVR4_IXANY 00004000
+#define SVR4_IXOFF 00010000
+#define SVR4_IMAXBEL 00020000
+#define SVR4_DOSMODE 00100000
+
+/* Output modes */
+#define SVR4_OPOST 00000001
+#define SVR4_OLCUC 00000002
+#define SVR4_ONLCR 00000004
+#define SVR4_OCRNL 00000010
+#define SVR4_ONOCR 00000020
+#define SVR4_ONLRET 00000040
+#define SVR4_OFILL 00000100
+#define SVR4_OFDEL 00000200
+#define SVR4_NLDLY 00000400
+#define SVR4_NL0 00000000
+#define SVR4_NL1 00000400
+#define SVR4_CRDLY 00003000
+#define SVR4_CR0 00000000
+#define SVR4_CR1 00001000
+#define SVR4_CR2 00002000
+#define SVR4_CR3 00003000
+#define SVR4_TABDLY 00014000
+#define SVR4_TAB0 00000000
+#define SVR4_TAB1 00004000
+#define SVR4_TAB2 00010000
+#define SVR4_TAB3 00014000
+#define SVR4_XTABS 00014000
+#define SVR4_BSDLY 00020000
+#define SVR4_BS0 00000000
+#define SVR4_BS1 00020000
+#define SVR4_VTDLY 00040000
+#define SVR4_VT0 00000000
+#define SVR4_VT1 00040000
+#define SVR4_FFDLY 00100000
+#define SVR4_FF0 00000000
+#define SVR4_FF1 00100000
+#define SVR4_PAGEOUT 00200000
+#define SVR4_WRAP 00400000
+
+/* Control modes */
+#define SVR4_CBAUD 00000017
+#define SVR4_CSIZE 00000060
+#define SVR4_CS5 00000000
+#define SVR4_CS6 00000200
+#define SVR4_CS7 00000040
+#define SVR4_CS8 00000006
+#define SVR4_CSTOPB 00000100
+#define SVR4_CREAD 00000200
+#define SVR4_PARENB 00000400
+#define SVR4_PARODD 00001000
+#define SVR4_HUPCL 00002000
+#define SVR4_CLOCAL 00004000
+#define SVR4_RCV1EN 00010000
+#define SVR4_XMT1EN 00020000
+#define SVR4_LOBLK 00040000
+#define SVR4_XCLUDE 00100000
+#define SVR4_CIBAUD 03600000
+#define SVR4_PAREXT 04000000
+
+/* line discipline modes */
+#define SVR4_ISIG 00000001
+#define SVR4_ICANON 00000002
+#define SVR4_XCASE 00000004
+#define SVR4_ECHO 00000010
+#define SVR4_ECHOE 00000020
+#define SVR4_ECHOK 00000040
+#define SVR4_ECHONL 00000100
+#define SVR4_NOFLSH 00000200
+#define SVR4_TOSTOP 00000400
+#define SVR4_ECHOCTL 00001000
+#define SVR4_ECHOPRT 00002000
+#define SVR4_ECHOKE 00004000
+#define SVR4_DEFECHO 00010000
+#define SVR4_FLUSHO 00020000
+#define SVR4_PENDIN 00040000
+#define SVR4_IEXTEN 00100000
+
+#define SVR4_TIOC ('T' << 8)
+
+#define SVR4_TCGETA (SVR4_TIOC| 1)
+#define SVR4_TCSETA (SVR4_TIOC| 2)
+#define SVR4_TCSETAW (SVR4_TIOC| 3)
+#define SVR4_TCSETAF (SVR4_TIOC| 4)
+#define SVR4_TCSBRK (SVR4_TIOC| 5)
+#define SVR4_TCXONC (SVR4_TIOC| 6)
+#define SVR4_TCFLSH (SVR4_TIOC| 7)
+#define SVR4_TIOCKBON (SVR4_TIOC| 8)
+#define SVR4_TIOCKBOF (SVR4_TIOC| 9)
+#define SVR4_KBENABLED (SVR4_TIOC|10)
+#define SVR4_TCGETS (SVR4_TIOC|13)
+#define SVR4_TCSETS (SVR4_TIOC|14)
+#define SVR4_TCSETSW (SVR4_TIOC|15)
+#define SVR4_TCSETSF (SVR4_TIOC|16)
+#define SVR4_TCDSET (SVR4_TIOC|32)
+#define SVR4_RTS_TOG (SVR4_TIOC|33)
+#define SVR4_TCGETSC (SVR4_TIOC|34)
+#define SVR4_TCSETSC (SVR4_TIOC|35)
+#define SVR4_TCMOUSE (SVR4_TIOC|36)
+#define SVR4_TIOCGWINSZ (SVR4_TIOC|104)
+#define SVR4_TIOCSWINSZ (SVR4_TIOC|103)
+
+struct svr4_winsize {
+ u_short ws_row;
+ u_short ws_col;
+ u_short ws_xpixel;
+ u_short ws_ypixel;
+};
+
+
+#define SVR4_B0 0
+#define SVR4_B50 1
+#define SVR4_B75 2
+#define SVR4_B110 3
+#define SVR4_B134 4
+#define SVR4_B150 5
+#define SVR4_B200 6
+#define SVR4_B300 7
+#define SVR4_B600 8
+#define SVR4_B1200 9
+#define SVR4_B1800 10
+#define SVR4_B2400 11
+#define SVR4_B4800 12
+#define SVR4_B9600 13
+#define SVR4_B19200 14
+#define SVR4_B38400 15
+
+#endif /* !_SVR4_TERMIOS_H_ */
diff --git a/sys/compat/svr4/svr4_time.h b/sys/compat/svr4/svr4_time.h
new file mode 100644
index 00000000000..8944788c4a2
--- /dev/null
+++ b/sys/compat/svr4/svr4_time.h
@@ -0,0 +1,36 @@
+/* $NetBSD: svr4_time.h,v 1.3 1994/10/29 00:43:28 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.
+ */
+
+#ifndef _SVR4_TIME_H_
+#define _SVR4_TIME_H_
+
+#include <compat/svr4/svr4_types.h>
+#include <sys/time.h>
+
+#endif /* !_SVR4_TIME_H_ */
diff --git a/sys/compat/svr4/svr4_timod.h b/sys/compat/svr4/svr4_timod.h
new file mode 100644
index 00000000000..e40a93887b9
--- /dev/null
+++ b/sys/compat/svr4/svr4_timod.h
@@ -0,0 +1,60 @@
+/* $NetBSD: svr4_timod.h,v 1.3 1995/01/10 00:04:11 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.
+ */
+
+#ifndef _SVR4_TIMOD_H_
+#define _SVR4_TIMOD_H_
+
+#define SVR4_TIMOD ('T' << 8)
+#define SVR4_TI_GETINFO (SVR4_TIMOD|140)
+#define SVR4_TI_OPTMGMT (SVR4_TIMOD|141)
+#define SVR4_TI_BIND (SVR4_TIMOD|142)
+#define SVR4_TI_UNBIND (SVR4_TIMOD|143)
+#define SVR4_TI_GETMYNAME (SVR4_TIMOD|144)
+#define SVR4_TI_GETPEERNAME (SVR4_TIMOD|145)
+#define SVR4_TI_SETMYNAME (SVR4_TIMOD|146)
+#define SVR4_TI_SETPEERNAME (SVR4_TIMOD|147)
+
+#define SVR4_TI_CONNECT_REQUEST 0x00
+#define SVR4_TI_INFO_REQUEST 0x05
+#define SVR4_TI_BIND_REQUEST 0x06
+#define SVR4_TI_SENDTO_REQUEST 0x08
+
+#define SVR4_TI_CONNECT_REPLY 0x0c
+#define SVR4_TI_INFO_REPLY 0x10
+#define SVR4_TI_BIND_REPLY 0x11
+#define SVR4_TI_OK_REPLY 0x13
+#define SVR4_TI_RECVFROM_REPLY 0x14
+
+struct svr4_netbuf {
+ u_int maxlen;
+ u_int len;
+ char *buf;
+};
+
+#endif /* !_SVR4_TIMOD_H_ */
diff --git a/sys/compat/svr4/svr4_ttold.c b/sys/compat/svr4/svr4_ttold.c
new file mode 100644
index 00000000000..dd71697e779
--- /dev/null
+++ b/sys/compat/svr4/svr4_ttold.c
@@ -0,0 +1,287 @@
+/* $NetBSD: svr4_ttold.c,v 1.6 1995/10/07 06:27:56 mycroft 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/proc.h>
+#include <sys/systm.h>
+#include <sys/file.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/termios.h>
+#include <sys/tty.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <net/if.h>
+#include <sys/malloc.h>
+
+#include <sys/syscallargs.h>
+
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_util.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_stropts.h>
+#include <compat/svr4/svr4_ttold.h>
+
+static void svr4_tchars_to_bsd_tchars __P((const struct svr4_tchars *st,
+ struct tchars *bt));
+static void bsd_tchars_to_svr4_tchars __P((const struct tchars *bt,
+ struct svr4_tchars *st));
+static void svr4_sgttyb_to_bsd_sgttyb __P((const struct svr4_sgttyb *ss,
+ struct sgttyb *bs));
+static void bsd_sgttyb_to_svr4_sgttyb __P((const struct sgttyb *bs,
+ struct svr4_sgttyb *ss));
+static void svr4_ltchars_to_bsd_ltchars __P((const struct svr4_ltchars *sl,
+ struct ltchars *bl));
+static void bsd_ltchars_to_svr4_ltchars __P((const struct ltchars *bl,
+ struct svr4_ltchars *sl));
+
+static void
+svr4_tchars_to_bsd_tchars(st, bt)
+ const struct svr4_tchars *st;
+ struct tchars *bt;
+{
+ bt->t_intrc = st->t_intrc;
+ bt->t_quitc = st->t_quitc;
+ bt->t_startc = st->t_startc;
+ bt->t_stopc = st->t_stopc;
+ bt->t_eofc = st->t_eofc;
+ bt->t_brkc = st->t_brkc;
+}
+
+
+static void
+bsd_tchars_to_svr4_tchars(bt, st)
+ const struct tchars *bt;
+ struct svr4_tchars *st;
+{
+ st->t_intrc = bt->t_intrc;
+ st->t_quitc = bt->t_quitc;
+ st->t_startc = bt->t_startc;
+ st->t_stopc = bt->t_stopc;
+ st->t_eofc = bt->t_eofc;
+ st->t_brkc = bt->t_brkc;
+}
+
+
+static void
+svr4_sgttyb_to_bsd_sgttyb(ss, bs)
+ const struct svr4_sgttyb *ss;
+ struct sgttyb *bs;
+{
+ bs->sg_ispeed = ss->sg_ispeed;
+ bs->sg_ospeed = ss->sg_ospeed;
+ bs->sg_erase = ss->sg_erase;
+ bs->sg_kill = ss->sg_kill;
+ bs->sg_flags = ss->sg_flags;
+};
+
+
+static void
+bsd_sgttyb_to_svr4_sgttyb(bs, ss)
+ const struct sgttyb *bs;
+ struct svr4_sgttyb *ss;
+{
+ ss->sg_ispeed = bs->sg_ispeed;
+ ss->sg_ospeed = bs->sg_ospeed;
+ ss->sg_erase = bs->sg_erase;
+ ss->sg_kill = bs->sg_kill;
+ ss->sg_flags = bs->sg_flags;
+}
+
+
+static void
+svr4_ltchars_to_bsd_ltchars(sl, bl)
+ const struct svr4_ltchars *sl;
+ struct ltchars *bl;
+{
+ bl->t_suspc = sl->t_suspc;
+ bl->t_dsuspc = sl->t_dsuspc;
+ bl->t_rprntc = sl->t_rprntc;
+ bl->t_flushc = sl->t_flushc;
+ bl->t_werasc = sl->t_werasc;
+ bl->t_lnextc = sl->t_lnextc;
+}
+
+
+static void
+bsd_ltchars_to_svr4_ltchars(bl, sl)
+ const struct ltchars *bl;
+ struct svr4_ltchars *sl;
+{
+ sl->t_suspc = bl->t_suspc;
+ sl->t_dsuspc = bl->t_dsuspc;
+ sl->t_rprntc = bl->t_rprntc;
+ sl->t_flushc = bl->t_flushc;
+ sl->t_werasc = bl->t_werasc;
+ sl->t_lnextc = bl->t_lnextc;
+}
+
+
+int
+svr4_ttoldioctl(fp, cmd, data, p, retval)
+ struct file *fp;
+ u_long cmd;
+ caddr_t data;
+ struct proc *p;
+ register_t *retval;
+{
+ int error;
+ int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) =
+ fp->f_ops->fo_ioctl;
+
+ *retval = 0;
+
+ switch (cmd) {
+ case SVR4_TIOCGPGRP:
+ {
+ pid_t pid;
+
+ if ((error = (*ctl)(fp, TIOCGPGRP,
+ (caddr_t) &pid, p)) != 0)
+ return error;
+
+ DPRINTF(("TIOCGPGRP %d", pid));
+
+ if ((error = copyout(&pid, data, sizeof(pid))) != 0)
+ return error;
+
+ }
+
+ case SVR4_TIOCSPGRP:
+ {
+ pid_t pid;
+
+ if ((error = copyin(data, &pid, sizeof(pid))) != 0)
+ return error;
+
+ DPRINTF(("TIOCSPGRP %d", pid));
+
+ return (*ctl)(fp, TIOCSPGRP, (caddr_t) &pid, p);
+ }
+
+ case SVR4_TIOCGSID:
+ {
+ pid_t pid;
+
+ if ((error = (*ctl)(fp, TIOCGSID,
+ (caddr_t) &pid, p)) != 0)
+ return error;
+
+ DPRINTF(("TIOCGSID %d", pid));
+
+ return copyout(&pid, data, sizeof(pid));
+ }
+
+ case SVR4_TIOCGETP:
+ {
+ struct sgttyb bs;
+ struct svr4_sgttyb ss;
+
+ error = (*ctl)(fp, TIOCGETP, (caddr_t) &bs, p);
+ if (error)
+ return error;
+
+ bsd_sgttyb_to_svr4_sgttyb(&bs, &ss);
+ return copyout(&ss, data, sizeof(ss));
+ }
+
+ case SVR4_TIOCSETP:
+ case SVR4_TIOCSETN:
+ {
+ struct sgttyb bs;
+ struct svr4_sgttyb ss;
+
+ if ((error = copyin(data, &ss, sizeof(ss))) != 0)
+ return error;
+
+ svr4_sgttyb_to_bsd_sgttyb(&ss, &bs);
+
+ cmd = (cmd == SVR4_TIOCSETP) ? TIOCSETP : TIOCSETN;
+ return (*ctl)(fp, cmd, (caddr_t) &bs, p);
+ }
+
+ case SVR4_TIOCGETC:
+ {
+ struct tchars bt;
+ struct svr4_tchars st;
+
+ error = (*ctl)(fp, TIOCGETC, (caddr_t) &bt, p);
+ if (error)
+ return error;
+
+ bsd_tchars_to_svr4_tchars(&bt, &st);
+ return copyout(&st, data, sizeof(st));
+ }
+
+ case SVR4_TIOCSETC:
+ {
+ struct tchars bt;
+ struct svr4_tchars st;
+
+ if ((error = copyin(data, &st, sizeof(st))) != 0)
+ return error;
+
+ svr4_tchars_to_bsd_tchars(&st, &bt);
+
+ return (*ctl)(fp, TIOCSETC, (caddr_t) &bt, p);
+ }
+
+ case SVR4_TIOCGLTC:
+ {
+ struct ltchars bl;
+ struct svr4_ltchars sl;
+
+ error = (*ctl)(fp, TIOCGLTC, (caddr_t) &bl, p);
+ if (error)
+ return error;
+
+ bsd_ltchars_to_svr4_ltchars(&bl, &sl);
+ return copyout(&sl, data, sizeof(sl));
+ }
+
+ case SVR4_TIOCSLTC:
+ {
+ struct ltchars bl;
+ struct svr4_ltchars sl;
+
+ if ((error = copyin(data, &sl, sizeof(sl))) != 0)
+ return error;
+
+ svr4_ltchars_to_bsd_ltchars(&sl, &bl);
+
+ return (*ctl)(fp, TIOCSLTC, (caddr_t) &bl, p);
+ }
+
+ default:
+ DPRINTF(("Unknown svr4 ttold %x\n", cmd));
+ return 0; /* ENOSYS really */
+ }
+}
diff --git a/sys/compat/svr4/svr4_ttold.h b/sys/compat/svr4/svr4_ttold.h
new file mode 100644
index 00000000000..287d4ca63f4
--- /dev/null
+++ b/sys/compat/svr4/svr4_ttold.h
@@ -0,0 +1,121 @@
+/* $NetBSD: svr4_ttold.h,v 1.2 1994/11/18 02:54:25 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.
+ */
+
+#ifndef _SVR4_TTOLD_H_
+#define _SVR4_TTOLD_H_
+
+struct svr4_tchars {
+ char t_intrc;
+ char t_quitc;
+ char t_startc;
+ char t_stopc;
+ char t_eofc;
+ char t_brkc;
+};
+
+struct svr4_sgttyb {
+ u_char sg_ispeed;
+ u_char sg_ospeed;
+ u_char sg_erase;
+ u_char sg_kill;
+ int sg_flags;
+};
+
+struct svr4_ltchars {
+ char t_suspc;
+ char t_dsuspc;
+ char t_rprntc;
+ char t_flushc;
+ char t_werasc;
+ char t_lnextc;
+};
+
+#ifndef SVR4_tIOC
+#define SVR4_tIOC ('t' << 8)
+#endif
+
+#define SVR4_TIOCGETD (SVR4_tIOC | 0)
+#define SVR4_TIOCSETD (SVR4_tIOC | 1)
+#define SVR4_TIOCHPCL (SVR4_tIOC | 2)
+#define SVR4_TIOCGETP (SVR4_tIOC | 8)
+#define SVR4_TIOCSETP (SVR4_tIOC | 9)
+#define SVR4_TIOCSETN (SVR4_tIOC | 10)
+#define SVR4_TIOCEXCL (SVR4_tIOC | 13)
+#define SVR4_TIOCNXCL (SVR4_tIOC | 14)
+#define SVR4_TIOCFLUSH (SVR4_tIOC | 16)
+#define SVR4_TIOCSETC (SVR4_tIOC | 17)
+#define SVR4_TIOCGETC (SVR4_tIOC | 18)
+#define SVR4_TIOCGPGRP (SVR4_tIOC | 20)
+#define SVR4_TIOCSPGRP (SVR4_tIOC | 21)
+#define SVR4_TIOCGSID (SVR4_tIOC | 22)
+#define SVR4_TIOCSTI (SVR4_tIOC | 23)
+#define SVR4_TIOCSSID (SVR4_tIOC | 24)
+#define SVR4_TIOCMSET (SVR4_tIOC | 26)
+#define SVR4_TIOCMBIS (SVR4_tIOC | 27)
+#define SVR4_TIOCMBIC (SVR4_tIOC | 28)
+#define SVR4_TIOCMGET (SVR4_tIOC | 29)
+#define SVR4_TIOCREMOTE (SVR4_tIOC | 30)
+#define SVR4_TIOCSIGNAL (SVR4_tIOC | 31)
+
+#define SVR4_TIOCSTART (SVR4_tIOC | 110)
+#define SVR4_TIOCSTOP (SVR4_tIOC | 111)
+#define SVR4_TIOCNOTTY (SVR4_tIOC | 113)
+#define SVR4_TIOCOUTQ (SVR4_tIOC | 115)
+#define SVR4_TIOCGLTC (SVR4_tIOC | 116)
+#define SVR4_TIOCSLTC (SVR4_tIOC | 117)
+#define SVR4_TIOCCDTR (SVR4_tIOC | 120)
+#define SVR4_TIOCSDTR (SVR4_tIOC | 121)
+#define SVR4_TIOCCBRK (SVR4_tIOC | 122)
+#define SVR4_TIOCSBRK (SVR4_tIOC | 123)
+#define SVR4_TIOCLGET (SVR4_tIOC | 124)
+#define SVR4_TIOCLSET (SVR4_tIOC | 125)
+#define SVR4_TIOCLBIC (SVR4_tIOC | 126)
+#define SVR4_TIOCLBIS (SVR4_tIOC | 127)
+
+#define SVR4_TIOCM_LE 0001
+#define SVR4_TIOCM_DTR 0002
+#define SVR4_TIOCM_RTS 0004
+#define SVR4_TIOCM_ST 0010
+#define SVR4_TIOCM_SR 0020
+#define SVR4_TIOCM_CTS 0040
+#define SVR4_TIOCM_CAR 0100
+#define SVR4_TIOCM_CD SVR4_TIOCM_CAR
+#define SVR4_TIOCM_RNG 0200
+#define SVR4_TIOCM_RI SVR4_TIOCM_RNG
+#define SVR4_TIOCM_DSR 0400
+
+#define SVR4_OTTYDISC 0
+#define SVR4_NETLDISC 1
+#define SVR4_NTTYDISC 2
+#define SVR4_TABLDISC 3
+#define SVR4_NTABLDISC 4
+#define SVR4_MOUSELDISC 5
+#define SVR4_KBDLDISC 6
+
+#endif /* !_SVR4_TTOLD_H_ */
diff --git a/sys/compat/svr4/svr4_types.h b/sys/compat/svr4/svr4_types.h
new file mode 100644
index 00000000000..ba553d432fd
--- /dev/null
+++ b/sys/compat/svr4/svr4_types.h
@@ -0,0 +1,57 @@
+/* $NetBSD: svr4_types.h,v 1.6 1995/08/14 01:12:50 mycroft 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.
+ */
+
+#ifndef _SVR4_TYPES_H_
+#define _SVR4_TYPES_H_
+
+typedef long svr4_off_t;
+typedef u_long svr4_dev_t;
+typedef u_long svr4_ino_t;
+typedef u_long svr4_mode_t;
+typedef u_long svr4_nlink_t;
+typedef long svr4_uid_t;
+typedef long svr4_gid_t;
+typedef long svr4_daddr_t;
+typedef long svr4_pid_t;
+typedef long svr4_time_t;
+typedef char *svr4_caddr_t;
+typedef u_int svr4_size_t;
+
+typedef short svr4_o_dev_t;
+typedef short svr4_o_pid_t;
+typedef u_short svr4_o_ino_t;
+typedef u_short svr4_o_mode_t;
+typedef short svr4_o_nlink_t;
+typedef u_short svr4_o_uid_t;
+typedef u_short svr4_o_gid_t;
+typedef long svr4_clock_t;
+
+typedef struct timespec svr4_timestruc_t;
+
+#endif /* !_SVR4_TYPES_H_ */
diff --git a/sys/compat/svr4/svr4_ucontext.h b/sys/compat/svr4/svr4_ucontext.h
new file mode 100644
index 00000000000..5359acaa685
--- /dev/null
+++ b/sys/compat/svr4/svr4_ucontext.h
@@ -0,0 +1,76 @@
+/* $NetBSD: svr4_ucontext.h,v 1.3 1995/08/14 01:13:29 mycroft 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.
+ */
+
+#ifndef _SVR4_UCONTEXT_H_
+#define _SVR4_UCONTEXT_H_
+
+#include <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_signal.h>
+#include <machine/svr4_machdep.h>
+
+/*
+ * Machine context
+ */
+
+#define SVR4_UC_SIGMASK 0x01
+#define SVR4_UC_STACK 0x02
+
+#define SVR4_UC_CPU 0x04
+#define SVR4_UC_FPU 0x08
+#define SVR4_UC_WEITEK 0x10
+
+#define SVR4_UC_MCONTEXT (SVR4_UC_CPU|SVR4_UC_FPU|SVR4_UC_WEITEK)
+
+#define SVR4_UC_ALL (SVR4_UC_SIGMASK|SVR4_UC_STACK|SVR4_UC_MCONTEXT)
+
+typedef struct svr4_ucontext {
+ u_long uc_flags;
+ struct svr4_ucontext *uc_link;
+ svr4_sigset_t uc_sigmask;
+ struct svr4_sigaltstack uc_stack;
+ svr4_mcontext_t uc_mcontext;
+ long uc_pad[5];
+} svr4_ucontext_t;
+
+#define SVR4_UC_GETREGSET 0
+#define SVR4_UC_SETREGSET 1
+
+/*
+ * Signal frame
+ */
+struct svr4_sigframe {
+ int sf_signum;
+ union svr4_siginfo *sf_sip;
+ struct svr4_ucontext *sf_ucp;
+ sig_t sf_handler;
+ struct svr4_ucontext sf_uc;
+ union svr4_siginfo sf_si;
+};
+
+#endif /* !_SVR4_UCONTEXT_H_ */
diff --git a/sys/compat/svr4/svr4_ulimit.h b/sys/compat/svr4/svr4_ulimit.h
new file mode 100644
index 00000000000..270ba05b4fe
--- /dev/null
+++ b/sys/compat/svr4/svr4_ulimit.h
@@ -0,0 +1,40 @@
+/* $NetBSD: svr4_ulimit.h,v 1.2 1994/11/18 02:54:29 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.
+ */
+
+#ifndef _SVR4_ULIMIT_H_
+#define _SVR4_ULIMIT_H_
+
+#define SVR4_GFILLIM 1
+#define SVR4_SFILLIM 2
+#define SVR4_GMEMLIM 3
+#define SVR4_GDESLIM 4
+#define SVR4_GTXTOFF 64
+
+
+#endif /* !_SVR4_ULIMIT_H_ */
diff --git a/sys/compat/svr4/svr4_ustat.h b/sys/compat/svr4/svr4_ustat.h
new file mode 100644
index 00000000000..af9f808a605
--- /dev/null
+++ b/sys/compat/svr4/svr4_ustat.h
@@ -0,0 +1,42 @@
+/* $NetBSD: svr4_ustat.h,v 1.3 1994/10/29 00:43:30 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.
+ */
+
+#ifndef _SVR4_USTAT_H_
+#define _SVR4_USTAT_H_
+
+#include <compat/svr4/svr4_types.h>
+
+struct svr4_ustat {
+ svr4_daddr_t f_tfree;
+ svr4_ino_t f_tinode;
+ char f_fname[6];
+ char f_fpack[6];
+};
+
+#endif /* !_SVR4_USTAT_H_ */
diff --git a/sys/compat/svr4/svr4_util.h b/sys/compat/svr4/svr4_util.h
new file mode 100644
index 00000000000..d4211410bc4
--- /dev/null
+++ b/sys/compat/svr4/svr4_util.h
@@ -0,0 +1,46 @@
+/* $NetBSD: svr4_util.h,v 1.7 1995/06/24 20:29:31 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.
+ */
+
+#ifndef _SVR4_UTIL_H_
+#define _SVR4_UTIL_H_
+
+#include <compat/common/compat_util.h>
+
+#ifdef DEBUG_SVR4
+#define DPRINTF(a) printf a;
+#else
+#define DPRINTF(a)
+#endif
+
+extern const char svr4_emul_path[];
+
+#define SVR4_CHECK_ALT_EXIST(p, sgp, path) \
+ CHECK_ALT_EXIST(p, sgp, svr4_emul_path, path)
+
+#endif /* !_SVR4_UTIL_H_ */
diff --git a/sys/compat/svr4/svr4_utsname.h b/sys/compat/svr4/svr4_utsname.h
new file mode 100644
index 00000000000..73c0805a319
--- /dev/null
+++ b/sys/compat/svr4/svr4_utsname.h
@@ -0,0 +1,44 @@
+/* $NetBSD: svr4_utsname.h,v 1.3 1994/10/29 00:43:33 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.
+ */
+
+#ifndef _SVR4_UTSNAME_H_
+#define _SVR4_UTSNAME_H_
+
+#include <compat/svr4/svr4_types.h>
+#include <sys/utsname.h>
+
+struct svr4_utsname {
+ char sysname[257];
+ char nodename[257];
+ char release[257];
+ char version[257];
+ char machine[257];
+};
+
+#endif /* !_SVR4_UTSNAME_H_ */
diff --git a/sys/compat/svr4/svr4_wait.h b/sys/compat/svr4/svr4_wait.h
new file mode 100644
index 00000000000..e726c67c970
--- /dev/null
+++ b/sys/compat/svr4/svr4_wait.h
@@ -0,0 +1,55 @@
+/* $NetBSD: svr4_wait.h,v 1.5 1995/03/31 03:06:50 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.
+ */
+
+#ifndef _SVR4_WAIT_H_
+#define _SVR4_WAIT_H_
+
+
+#define SVR4_P_PID 0
+#define SVR4_P_PPID 1
+#define SVR4_P_PGID 2
+#define SVR4_P_SID 3
+#define SVR4_P_CID 4
+#define SVR4_P_UID 5
+#define SVR4_P_GID 6
+#define SVR4_P_ALL 7
+
+#define SVR4_WEXITED 0x01
+#define SVR4_WTRAPPED 0x02
+#define SVR4_WSTOPPED 0x04
+#define SVR4_WCONTINUED 0x08
+#define SVR4_WUNDEF1 0x10
+#define SVR4_WUNDEF2 0x20
+#define SVR4_WNOHANG 0x40
+#define SVR4_WNOWAIT 0x80
+
+#define SVR4_WOPTMASK (SVR4_WEXITED|SVR4_WTRAPPED|SVR4_WSTOPPED|\
+ SVR4_WCONTINUED|SVR4_WNOHANG|SVR4_WNOWAIT)
+
+#endif /* !_SVR4_WAIT_H_ */
diff --git a/sys/compat/svr4/syscalls.conf b/sys/compat/svr4/syscalls.conf
new file mode 100644
index 00000000000..2cb29b9c956
--- /dev/null
+++ b/sys/compat/svr4/syscalls.conf
@@ -0,0 +1,12 @@
+# $NetBSD: syscalls.conf,v 1.3 1994/10/26 05:28:08 cgd Exp $
+
+sysnames="svr4_syscalls.c"
+sysnumhdr="svr4_syscall.h"
+syssw="svr4_sysent.c"
+sysarghdr="svr4_syscallargs.h"
+compatopts="compat_43 compat_09 compat_10"
+libcompatopts=""
+
+switchname="svr4_sysent"
+namesname="svr4_syscallnames"
+constprefix="SVR4_SYS_"
diff --git a/sys/compat/svr4/syscalls.master b/sys/compat/svr4/syscalls.master
new file mode 100644
index 00000000000..23c9202537a
--- /dev/null
+++ b/sys/compat/svr4/syscalls.master
@@ -0,0 +1,276 @@
+ $NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp $
+
+; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
+
+; NetBSD COMPAT_SVR4 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
+;
+; 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 <compat/svr4/svr4_types.h>
+#include <compat/svr4/svr4_signal.h>
+#include <compat/svr4/svr4_ucontext.h>
+#include <compat/svr4/svr4_syscallargs.h>
+#include <compat/svr4/svr4_statvfs.h>
+
+0 NOARGS { int sys_nosys(void); } syscall
+1 NOARGS { int sys_exit(int rval); }
+2 NOARGS { int sys_fork(void); }
+3 NOARGS { int sys_read(int fd, char *buf, u_int nbyte); }
+4 NOARGS { int sys_write(int fd, char *buf, u_int nbyte); }
+5 STD { int svr4_sys_open(char *path, int flags, int mode); }
+6 NOARGS { int sys_close(int fd); }
+7 STD { int svr4_sys_wait(int *status); }
+8 STD { int svr4_sys_creat(char *path, int mode); }
+9 NOARGS { int sys_link(char *path, char *link); }
+10 NOARGS { int sys_unlink(char *path); }
+11 STD { int svr4_sys_execv(char *path, char **argp); }
+12 NOARGS { int sys_chdir(char *path); }
+13 STD { int svr4_sys_time(svr4_time_t *t); }
+14 STD { int svr4_sys_mknod(char* path, int mode, int dev); }
+15 NOARGS { int sys_chmod(char *path, int mode); }
+16 NOARGS { int sys_chown(char *path, int uid, int gid); }
+17 STD { int svr4_sys_break(caddr_t nsize); }
+18 STD { int svr4_sys_stat(char* path, struct svr4_stat* ub); }
+19 NOARGS { long compat_43_sys_lseek(int fd, long offset, \
+ int whence); }
+20 NOARGS { pid_t sys_getpid(void); }
+21 UNIMPL old_mount
+22 UNIMPL System V umount
+23 NOARGS { int sys_setuid(uid_t uid); }
+24 NOARGS { uid_t sys_getuid(void); }
+25 UNIMPL stime
+26 UNIMPL ptrace
+27 STD { int svr4_sys_alarm(unsigned sec); }
+28 STD { int svr4_sys_fstat(int fd, struct svr4_stat *sb); }
+29 UNIMPL pause
+30 UNIMPL utime
+31 UNIMPL was stty
+32 UNIMPL was gtty
+33 STD { int svr4_sys_access(char *path, int flags); }
+34 UNIMPL nice
+35 UNIMPL statfs
+36 NOARGS { int sys_sync(void); }
+37 STD { int svr4_sys_kill(int pid, int signum); }
+38 UNIMPL fstatfs
+39 STD { int svr4_sys_pgrpsys(int cmd, int pid, int pgid); }
+40 UNIMPL xenix
+41 NOARGS { int sys_dup(u_int fd); }
+42 NOARGS { int sys_pipe(void); }
+43 STD { int svr4_sys_times(struct tms *tp); }
+44 UNIMPL profil
+45 UNIMPL plock
+46 NOARGS { int sys_setgid(gid_t gid); }
+47 NOARGS { gid_t sys_getgid(void); }
+48 STD { int svr4_sys_signal(int signum, svr4_sig_t handler); }
+#ifdef SYSVMSG
+49 UNIMPL { int sys_msgsys(int which, int a2, int a3, int a4, \
+ int a5, int a6); }
+#else
+49 UNIMPL msgsys
+#endif
+50 STD { int svr4_sys_sysarch(int op, void *a1); }
+51 UNIMPL acct
+#ifdef SYSVSHM
+52 UNIMPL { int sys_shmsys(int which, int a2, int a3, int a4); }
+#else
+52 UNIMPL shmsys
+#endif
+#ifdef SYSVSEM
+53 UNIMPL { int sys_semsys(int which, int a2, int a3, int a4, \
+ int a5); }
+#else
+53 UNIMPL semsys
+#endif
+54 STD { int svr4_sys_ioctl(int fd, u_long com, \
+ caddr_t data); }
+55 UNIMPL uadmin
+56 UNIMPL exch
+57 STD { int svr4_sys_utssys(void *a1, void *a2, int sel, \
+ void *a3); }
+58 NOARGS { int sys_fsync(int fd); }
+59 STD { int svr4_sys_execve(char *path, char **argp, \
+ char **envp); }
+60 NOARGS { int sys_umask(int newmask); }
+61 NOARGS { int sys_chroot(char *path); }
+62 STD { int svr4_sys_fcntl(int fd, int cmd, char *arg); }
+63 STD { long svr4_sys_ulimit(int cmd, long newlimit); }
+64 UNIMPL reserved for unix/pc
+65 UNIMPL reserved for unix/pc
+66 UNIMPL reserved for unix/pc
+67 UNIMPL reserved for unix/pc
+68 UNIMPL reserved for unix/pc
+69 UNIMPL reserved for unix/pc
+70 OBSOL advfs
+71 OBSOL unadvfs
+72 OBSOL rmount
+73 OBSOL rumount
+74 OBSOL rfstart
+75 OBSOL sigret
+76 OBSOL rdebug
+77 OBSOL rfstop
+78 UNIMPL rfsys
+79 NOARGS { int sys_rmdir(char *path); }
+80 NOARGS { int sys_mkdir(char *path, int mode); }
+81 STD { int svr4_sys_getdents(int fd, char *buf, int nbytes); }
+82 OBSOL libattach
+83 OBSOL libdetach
+84 UNIMPL sysfs
+85 STD { int svr4_sys_getmsg(int fd, struct svr4_strbuf *ctl, \
+ struct svr4_strbuf *dat, int *flags); }
+86 STD { int svr4_sys_putmsg(int fd, struct svr4_strbuf *ctl, \
+ struct svr4_strbuf *dat, int flags); }
+87 STD { int svr4_sys_poll(struct svr4_pollfd *fds, \
+ long nfds, int timeout); }
+88 STD { int svr4_sys_lstat(char *path, \
+ struct svr4_stat *ub); }
+89 NOARGS { int sys_symlink(char *path, char *link); }
+90 NOARGS { int sys_readlink(char *path, char *buf, int count); }
+91 NOARGS { int sys_getgroups(u_int gidsetsize, gid_t *gidset); }
+92 NOARGS { int sys_setgroups(u_int gidsetsize, gid_t *gidset); }
+93 NOARGS { int sys_fchmod(int fd, int mode); }
+94 NOARGS { int sys_fchown(int fd, int uid, int gid); }
+95 STD { int svr4_sys_sigprocmask(int how, \
+ svr4_sigset_t *set, svr4_sigset_t *oset); }
+96 STD { int svr4_sys_sigsuspend(svr4_sigset_t *ss); }
+97 STD { int svr4_sys_sigaltstack(struct svr4_sigaltstack *nss, \
+ struct svr4_sigaltstack *oss); }
+98 STD { int svr4_sys_sigaction(int signum, \
+ struct svr4_sigaction *nsa, \
+ struct svr4_sigaction *osa); }
+99 STD { int svr4_sys_sigpending(int what, \
+ svr4_sigset_t *mask); }
+100 STD { int svr4_sys_context(int func, \
+ struct svr4_ucontext *uc); }
+101 UNIMPL evsys
+102 UNIMPL evtrapret
+103 STD { int svr4_sys_statvfs(char *path, \
+ struct svr4_statvfs *fs); }
+104 STD { int svr4_sys_fstatvfs(int fd, \
+ struct svr4_statvfs *fs); }
+105 UNIMPL
+106 UNIMPL nfssvc
+107 STD { int svr4_sys_waitsys(int grp, int id, \
+ union svr4_siginfo *info, int options); }
+108 UNIMPL sigsendsys
+109 STD { int svr4_sys_hrtsys(int cmd, int fun, int sub, \
+ void *rv1, void *rv2); }
+110 UNIMPL acancel
+111 UNIMPL async
+112 UNIMPL priocntlsys
+113 UNIMPL pathconf
+114 UNIMPL mincore
+115 STD { int svr4_sys_mmap(svr4_caddr_t addr, \
+ svr4_size_t len, int prot, int flags, int fd, \
+ svr4_off_t pos); }
+116 NOARGS { int sys_mprotect(caddr_t addr, int len, int prot); }
+117 NOARGS { int sys_munmap(caddr_t addr, int len); }
+118 NOARGS { int sys_fpathconf(int fd, int name); }
+119 NOARGS { int sys_vfork(void); }
+120 NOARGS { int sys_fchdir(int fd); }
+121 NOARGS { int sys_readv(int fd, struct iovec *iovp, u_int iovcnt); }
+122 NOARGS { int sys_writev(int fd, struct iovec *iovp, \
+ u_int iovcnt); }
+123 STD { int svr4_sys_xstat(int two, char *path, \
+ struct svr4_xstat *ub); }
+124 STD { int svr4_sys_lxstat(int two, char *path, \
+ struct svr4_xstat *ub); }
+125 STD { int svr4_sys_fxstat(int two, int fd, \
+ struct svr4_xstat *sb); }
+126 UNIMPL xmknod
+127 UNIMPL clocal
+128 STD { int svr4_sys_setrlimit(int which, \
+ struct ogetrlimit *rlp); }
+129 STD { int svr4_sys_getrlimit(int which, \
+ struct ogetrlimit *rlp); }
+130 UNIMPL lchown
+131 UNIMPL memcntl
+132 UNIMPL getpmsg
+133 UNIMPL putpmsg
+134 NOARGS { int sys_rename(char *from, char *to); }
+135 STD { int svr4_sys_uname(struct svr4_utsname* name, \
+ int dummy); }
+136 NOARGS { int sys_setegid(gid_t egid); }
+137 STD { int svr4_sys_sysconfig(int name); }
+138 NOARGS { int sys_adjtime(struct timeval *delta, \
+ struct timeval *olddelta); }
+139 STD { long svr4_sys_systeminfo(int what, char *buf, \
+ long len); }
+140 UNIMPL
+141 NOARGS { int sys_seteuid(uid_t euid); }
+142 UNIMPL vtrace
+143 UNIMPL fork1
+144 UNIMPL sigwait
+145 UNIMPL lwp_info
+146 UNIMPL yield
+147 UNIMPL lwp_sema_p
+148 UNIMPL lwp_sema_v
+149 UNIMPL
+150 UNIMPL
+151 UNIMPL
+152 UNIMPL modctl
+153 STD { int svr4_sys_fchroot(int fd); }
+154 UNIMPL utimes
+155 STD { int svr4_sys_vhangup(void); }
+156 STD { int svr4_sys_gettimeofday(struct timeval *tp); }
+157 NOARGS { int sys_getitimer(u_int which, \
+ struct itimerval *itv); }
+158 NOARGS { int sys_setitimer(u_int which, \
+ struct itimerval *itv, struct itimerval *oitv); }
+159 UNIMPL lwp_create
+160 UNIMPL lwp_exit
+161 UNIMPL lwp_suspend
+162 UNIMPL lwp_continue
+163 UNIMPL lwp_kill
+164 UNIMPL lwp_self
+165 UNIMPL lwp_getprivate
+166 UNIMPL lwp_setprivate
+167 UNIMPL lwp_wait
+168 UNIMPL lwp_mutex_unlock
+169 UNIMPL lwp_mutex_lock
+170 UNIMPL lwp_cond_wait
+171 UNIMPL lwp_cond_signal
+172 UNIMPL lwp_cond_broadcast
+173 UNIMPL pread
+174 UNIMPL pwrite
+175 UNIMPL llseek
+176 UNIMPL inst_sync
+177 UNIMPL
+178 UNIMPL
+179 UNIMPL
+180 UNIMPL
+181 UNIMPL
+182 UNIMPL
+183 UNIMPL
+184 UNIMPL
+185 UNIMPL
+186 UNIMPL auditsys
diff --git a/sys/compat/ultrix/files.ultrix b/sys/compat/ultrix/files.ultrix
new file mode 100644
index 00000000000..d54c76ef9e3
--- /dev/null
+++ b/sys/compat/ultrix/files.ultrix
@@ -0,0 +1,11 @@
+# $NetBSD: files.ultrix,v 1.1 1995/09/20 00:15:19 thorpej Exp $
+#
+# Config file description for machine-independent Ultrix compat code.
+# Included by ports that need it.
+
+# ports should define any machine-specific files they need in their
+# own file lists.
+
+file compat/ultrix/ultrix_misc.c compat_ultrix
+file compat/ultrix/ultrix_syscalls.c compat_ultrix
+file compat/ultrix/ultrix_sysent.c compat_ultrix
diff --git a/sys/compat/ultrix/syscalls.conf b/sys/compat/ultrix/syscalls.conf
new file mode 100644
index 00000000000..6b5702359e9
--- /dev/null
+++ b/sys/compat/ultrix/syscalls.conf
@@ -0,0 +1,12 @@
+# $NetBSD: syscalls.conf,v 1.1 1994/11/23 17:49:06 dean Exp $
+
+sysnames="ultrix_syscalls.c"
+sysnumhdr="ultrix_syscall.h"
+syssw="ultrix_sysent.c"
+sysarghdr="ultrix_syscallargs.h"
+compatopts="compat_43 compat_09 compat_10"
+libcompatopts=""
+
+switchname="ultrix_sysent"
+namesname="ultrix_syscallnames"
+constprefix="ULTRIX_SYS_"
diff --git a/sys/compat/ultrix/syscalls.master b/sys/compat/ultrix/syscalls.master
new file mode 100644
index 00000000000..6b203215e58
--- /dev/null
+++ b/sys/compat/ultrix/syscalls.master
@@ -0,0 +1,355 @@
+ $NetBSD: syscalls.master,v 1.11 1995/10/07 06:28:00 mycroft Exp $
+
+; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
+
+; NetBSD COMPAT_ULTRIX 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
+;
+; 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 <compat/ultrix/ultrix_syscallargs.h>
+
+0 NOARGS { int sys_nosys(void); } syscall
+1 NOARGS { int sys_exit(int rval); }
+2 NOARGS { int sys_fork(void); }
+3 NOARGS { int sys_read(int fd, char *buf, u_int nbyte); }
+4 NOARGS { int sys_write(int fd, char *buf, u_int nbyte); }
+5 STD { int ultrix_sys_open(char *path, int flags, \
+ int mode); }
+6 NOARGS { int sys_close(int fd); }
+7 UNIMPL old_wait
+8 NOARGS { int compat_43_sys_creat(char *path, int mode); }
+9 NOARGS { int sys_link(char *path, char *link); }
+10 NOARGS { int sys_unlink(char *path); }
+11 STD { int ultrix_sys_execv(char *path, char **argp); }
+12 NOARGS { int sys_chdir(char *path); }
+13 OBSOL time
+14 STD { int ultrix_sys_mknod(char *path, int mode, int dev); }
+15 NOARGS { int sys_chmod(char *path, int mode); }
+16 NOARGS { int sys_chown(char *path, int uid, int gid); }
+17 NOARGS { int sys_obreak(char *nsize); } break
+18 OBSOL stat
+19 NOARGS { long compat_43_sys_lseek(int fd, long offset, \
+ int whence); }
+20 NOARGS { pid_t sys_getpid(void); }
+21 OBSOL mount
+22 OBSOL sysV_unmount
+23 NOARGS { int sys_setuid(uid_t uid); }
+24 NOARGS { uid_t sys_getuid(void); }
+25 OBSOL v7 stime
+26 OBSOL v7 ptrace
+27 OBSOL v7 alarm
+28 OBSOL v7 fstat
+29 OBSOL v7 pause
+30 OBSOL v7 utime
+31 OBSOL v7 stty
+32 OBSOL v7 gtty
+33 NOARGS { int sys_access(char *path, int flags); }
+34 OBSOL v7 nice
+35 OBSOL v7 ftime
+36 NOARGS { int sys_sync(void); }
+37 NOARGS { int sys_kill(int pid, int signum); }
+38 NOARGS { int compat_43_sys_stat(char *path, \
+ struct ostat *ub); } ostat
+39 OBSOL v7 setpgrp
+40 NOARGS { int compat_43_sys_lstat(char *path, \
+ struct ostat *ub); } olstat
+41 NOARGS { int sys_dup(u_int fd); }
+42 NOARGS { int sys_pipe(void); }
+43 OBSOL v7 times
+44 NOARGS { int sys_profil(caddr_t samples, u_int size, \
+ u_int offset, u_int scale); }
+45 UNIMPL
+46 OBSOL v7 setgid
+47 NOARGS { gid_t sys_getgid(void); }
+48 UNIMPL ssig
+49 UNIMPL reserved for USG
+50 UNIMPL reserved for USG
+51 NOARGS { int sys_acct(char *path); }
+52 UNIMPL
+53 UNIMPL syslock
+54 NOARGS { int sys_ioctl(int fd, u_long com, caddr_t data); }
+55 NOARGS { int sys_reboot(int opt); }
+56 UNIMPL v7 mpxchan
+57 NOARGS { int sys_symlink(char *path, char *link); }
+58 NOARGS { int sys_readlink(char *path, char *buf, int count); }
+59 NOARGS { int sys_execve(char *path, char **argp, \
+ char **envp); }
+60 NOARGS { int sys_umask(int newmask); }
+61 NOARGS { int sys_chroot(char *path); }
+62 NOARGS { int compat_43_sys_fstat(int fd, struct ostat *sb); }
+63 UNIMPL
+64 NOARGS { int compat_43_sys_getpagesize(void); }
+65 UNIMPL mremap
+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 STD { int ultrix_sys_mmap(caddr_t addr, size_t len, \
+ int prot, u_int flags, int fd, long pos); }
+72 NOARGS { int sys_ovadvise(int anom); } vadvise
+73 NOARGS { int sys_munmap(caddr_t addr, size_t len); }
+74 NOARGS { int sys_mprotect(caddr_t addr, size_t len, \
+ int prot); }
+75 NOARGS { int sys_madvise(caddr_t addr, size_t len, \
+ int behav); }
+76 STD { int ultrix_sys_vhangup(void); }
+77 UNIMPL old vlimit
+78 NOARGS { int sys_mincore(caddr_t addr, int len, char *vec); }
+79 NOARGS { int sys_getgroups(u_int gidsetsize, gid_t *gidset); }
+80 NOARGS { int sys_setgroups(u_int gidsetsize, gid_t *gidset); }
+81 NOARGS { int sys_getpgrp(void); }
+82 STD { int ultrix_sys_setpgrp(int pid, int pgid); }
+83 NOARGS { int sys_setitimer(u_int which, \
+ struct itimerval *itv, struct itimerval *oitv); }
+84 STD { int ultrix_sys_wait3(int *status, int options, \
+ struct rusage *rusage);}
+85 NOARGS { int sys_swapon(char *name); }
+86 NOARGS { int sys_getitimer(u_int which, \
+ struct itimerval *itv); }
+87 NOARGS { int compat_43_sys_gethostname(char *hostname, \
+ u_int len); }
+88 NOARGS { int compat_43_sys_sethostname(char *hostname, \
+ u_int len); }
+89 NOARGS { int compat_43_sys_getdtablesize(void); }
+90 NOARGS { int sys_dup2(u_int from, u_int to); }
+91 UNIMPL getdopt
+92 NOARGS { int sys_fcntl(int fd, int cmd, void *arg); }
+93 NOARGS { int sys_select(u_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, caddr_t name, int namelen); }
+99 NOARGS { int compat_43_sys_accept(int s, caddr_t name, \
+ int *anamelen); }
+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); }
+102 NOARGS { int compat_43_sys_recv(int s, caddr_t buf, int len, \
+ int flags); }
+103 NOARGS { int sys_sigreturn(struct sigcontext *sigcntxp); }
+104 NOARGS { int sys_bind(int s, caddr_t name, int namelen); }
+105 STD { int ultrix_sys_setsockopt(int s, int level, \
+ int name, caddr_t val, int valsize); }
+106 NOARGS { int sys_listen(int s, int backlog); }
+107 UNIMPL vtimes
+108 NOARGS { int compat_43_sys_sigvec(int signum, \
+ struct sigvec *nsv, struct sigvec *osv); }
+109 NOARGS { int compat_43_sys_sigblock(int mask); }
+110 NOARGS { int compat_43_sys_sigsetmask(int mask); }
+111 NOARGS { int sys_sigsuspend(int mask); }
+112 NOARGS { int compat_43_sys_sigstack(struct sigstack *nss, \
+ struct sigstack *oss); }
+113 NOARGS { int compat_43_sys_recvmsg(int s, \
+ struct omsghdr *msg, int flags); }
+114 NOARGS { int compat_43_sys_sendmsg(int s, caddr_t msg, \
+ int flags); }
+115 OBSOL vtrace
+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, \
+ caddr_t val, int *avalsize); }
+119 UNIMPL resuba
+120 NOARGS { int sys_readv(int fd, struct iovec *iovp, \
+ u_int iovcnt); }
+121 NOARGS { int sys_writev(int fd, struct iovec *iovp, \
+ u_int iovcnt); }
+122 NOARGS { int sys_settimeofday(struct timeval *tv, \
+ struct timezone *tzp); }
+123 NOARGS { int sys_fchown(int fd, int uid, int 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); }
+126 NOARGS { int compat_43_sys_setreuid(int ruid, int euid); }
+127 NOARGS { int compat_43_sys_setregid(int rgid, int egid); }
+128 NOARGS { int sys_rename(char *from, char *to); }
+129 NOARGS { int compat_43_sys_truncate(char *path, long length); }
+130 NOARGS { int compat_43_sys_ftruncate(int fd, long length); }
+131 NOARGS { int sys_flock(int fd, int how); }
+132 UNIMPL
+133 NOARGS { int sys_sendto(int s, caddr_t buf, size_t len, \
+ int flags, caddr_t to, int 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(char *path, int mode); }
+137 NOARGS { int sys_rmdir(char *path); }
+138 NOARGS { int sys_utimes(char *path, struct timeval *tptr); }
+139 STD { int ultrix_sys_sigcleanup(struct sigcontext *sigcntxp); }
+140 NOARGS { int sys_adjtime(struct timeval *delta, \
+ struct timeval *olddelta); }
+141 NOARGS { int compat_43_sys_getpeername(int fdes, caddr_t asa, \
+ int *alen); }
+142 NOARGS { int compat_43_sys_gethostid(void); }
+143 UNIMPL old sethostid
+144 NOARGS { int compat_43_sys_getrlimit(u_int which, \
+ struct orlimit *rlp); }
+145 NOARGS { int compat_43_sys_setrlimit(u_int which, \
+ struct orlimit *rlp); }
+146 NOARGS { int compat_43_sys_killpg(int pgid, int signum); }
+147 UNIMPL
+148 UNIMPL setquota
+149 UNIMPL quota /* needs to be nullop to boot on Ultrix root partition*/
+150 NOARGS { int compat_43_sys_getsockname(int fdes, caddr_t asa, \
+ int *alen); }
+151 UNIMPL sysmips /* 4 args */
+152 UNIMPL cacheflush /* 4 args */
+153 UNIMPL cachectl /* 3 args */
+154 UNIMPL
+155 UNIMPL atomic_op
+156 UNIMPL
+157 UNIMPL
+#ifdef NFSSERVER
+158 STD { int ultrix_sys_nfssvc(int fd); }
+#else
+158 UNIMPL
+#endif
+159 NOARGS { int compat_43_sys_getdirentries(int fd, char *buf, \
+ u_int count, long *basep); }
+160 STD { int ultrix_sys_statfs(char *path, \
+ struct ultrix_statfs *buf); }
+161 STD { int ultrix_sys_fstatfs(int fd, \
+ struct ultrix_statfs *buf); }
+162 UNIMPL umount
+#ifdef NFSCLIENT
+163 NOARGS { int async_daemon(void); }
+164 NOARGS { int sys_getfh(char *fname, fhandle_t *fhp); }
+#else
+163 UNIMPL async_daemon
+164 UNIMPL getfh
+#endif
+165 NOARGS { int compat_09_sys_getdomainname(char *domainname, \
+ int len); }
+166 NOARGS { int compat_09_sys_setdomainname(char *domainname, \
+ int len); }
+167 UNIMPL
+168 STD { int ultrix_sys_quotactl(int cmd, char *special, \
+ int uid, caddr_t addr); }
+169 STD { int ultrix_sys_exportfs(char *path, char *ex); }
+170 UNIMPL mount
+171 UNIMPL 4 hdwconf
+172 UNIMPL msgctl
+173 UNIMPL msgget
+174 UNIMPL msgrcv
+175 UNIMPL msgsnd
+176 UNIMPL semctl
+177 UNIMPL semget
+178 UNIMPL semop
+179 STD { int ultrix_sys_uname(struct ultrix_utsname *name); }
+180 UNIMPL shmsys
+181 UNIMPL 0 plock
+182 UNIMPL 0 lockf
+183 STD { int ultrix_sys_ustat(int dev, \
+ struct ultrix_ustat *buf); }
+184 UNIMPL getmnt
+185 UNIMPL notdef
+186 UNIMPL notdef
+187 STD { int ultrix_sys_sigpending(int *mask); }
+188 NOARGS { int sys_setsid(void); }
+189 STD { int ultrix_sys_waitpid(int pid, int *status, \
+ int options); }
+190 UNIMPL
+191 UNIMPL
+192 UNIMPL
+193 UNIMPL
+194 UNIMPL
+195 UNIMPL
+196 UNIMPL
+197 UNIMPL
+198 UNIMPL
+199 UNIMPL
+200 UNIMPL
+201 UNIMPL
+202 UNIMPL
+203 UNIMPL
+204 UNIMPL
+205 UNIMPL
+206 UNIMPL
+207 UNIMPL
+208 UNIMPL
+209 UNIMPL
+210 UNIMPL
+211 UNIMPL
+212 UNIMPL
+213 UNIMPL
+214 UNIMPL
+215 UNIMPL
+216 UNIMPL
+217 UNIMPL
+218 UNIMPL
+219 UNIMPL
+220 UNIMPL
+221 UNIMPL
+222 UNIMPL
+223 UNIMPL
+224 UNIMPL
+225 UNIMPL
+226 UNIMPL
+227 UNIMPL
+228 UNIMPL
+229 UNIMPL
+230 UNIMPL
+231 UNIMPL
+232 UNIMPL
+233 UNIMPL 1 utc_gettime
+234 UNIMPL 2 utc_adjtime
+235 UNIMPL
+236 UNIMPL
+237 UNIMPL
+238 UNIMPL
+239 UNIMPL
+240 UNIMPL
+241 UNIMPL
+242 UNIMPL
+243 UNIMPL
+244 UNIMPL
+245 UNIMPL
+246 UNIMPL
+247 UNIMPL
+248 UNIMPL
+249 UNIMPL
+250 UNIMPL
+251 UNIMPL
+252 UNIMPL audctl /*Make no-op for installation on Ultrix rootpartition?*/
+253 UNIMPL audgen /*Make no-op for installation on Ultrix rootpartition?*/
+254 UNIMPL startcpu
+255 UNIMPL stopcpu
+256 STD { int ultrix_sys_getsysinfo(unsigned op, char *buffer, \
+ unsigned nbytes, int *start, char *arg); }
+257 STD { int ultrix_sys_setsysinfo(unsigned op, char *buffer, \
+ unsigned nbytes, unsigned arg, unsigned flag); }
+
diff --git a/sys/compat/ultrix/ultrix_misc.c b/sys/compat/ultrix/ultrix_misc.c
new file mode 100644
index 00000000000..620d3fef5d1
--- /dev/null
+++ b/sys/compat/ultrix/ultrix_misc.c
@@ -0,0 +1,598 @@
+/* $NetBSD: ultrix_misc.c,v 1.16 1995/10/07 06:28:02 mycroft Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * 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, Lawrence Berkeley Laboratory.
+ *
+ * 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.
+ *
+ *
+ * @(#)sun_misc.c 8.1 (Berkeley) 6/18/93
+ *
+ * from: Header: sun_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
+ */
+
+/*
+ * SunOS compatibility module.
+ *
+ * SunOS system calls that are implemented differently in BSD are
+ * handled here.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/dir.h>
+#include <sys/proc.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/kernel.h>
+#include <sys/exec.h>
+#include <sys/malloc.h>
+#include <sys/mbuf.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/resource.h>
+#include <sys/resourcevar.h>
+#include <sys/signal.h>
+#include <sys/signalvar.h>
+#include <sys/socket.h>
+#include <sys/vnode.h>
+#include <sys/uio.h>
+#include <sys/wait.h>
+#include <sys/utsname.h>
+#include <sys/unistd.h>
+#include <sys/syscallargs.h>
+
+#include <compat/ultrix/ultrix_syscall.h>
+#include <compat/ultrix/ultrix_syscallargs.h>
+
+#include <netinet/in.h>
+
+#include <miscfs/specfs/specdev.h>
+
+#include <nfs/rpcv2.h>
+#include <nfs/nfsv2.h>
+#include <nfs/nfs.h>
+
+#include <vm/vm.h>
+
+extern struct sysent ultrix_sysent[];
+extern char *ultrix_syscallnames[];
+extern void cpu_exec_ecoff_setregs __P((struct proc *, struct exec_package *,
+ u_long, register_t *));
+struct emul emul_ultrix = {
+ "ultrix",
+ NULL,
+ sendsig,
+ ULTRIX_SYS_syscall,
+ ULTRIX_SYS_MAXSYSCALL,
+ ultrix_sysent,
+ ultrix_syscallnames,
+ 0,
+ copyargs,
+ cpu_exec_ecoff_setregs,
+ 0,
+ 0,
+};
+
+#define GSI_PROG_ENV 1
+
+ultrix_sys_getsysinfo(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_getsysinfo_args *uap = v;
+ static short progenv = 0;
+
+ switch (SCARG(uap, op)) {
+ /* operations implemented: */
+ case GSI_PROG_ENV:
+ if (SCARG(uap, nbytes) < sizeof(short))
+ return EINVAL;
+ *retval = 1;
+ return (copyout(&progenv, SCARG(uap, buffer), sizeof(short)));
+ default:
+ *retval = 0; /* info unavail */
+ return 0;
+ }
+}
+
+ultrix_sys_setsysinfo(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_setsysinfo_args *uap = v;
+ *retval = 0;
+ return 0;
+}
+
+ultrix_sys_waitpid(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_waitpid_args *uap = v;
+ struct sys_wait4_args ua;
+
+ SCARG(&ua, pid) = SCARG(uap, pid);
+ SCARG(&ua, status) = SCARG(uap, status);
+ SCARG(&ua, options) = SCARG(uap, options);
+ SCARG(&ua, rusage) = 0;
+
+ return (sys_wait4(p, &ua, retval));
+}
+
+ultrix_sys_wait3(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_wait3_args *uap = v;
+ struct sys_wait4_args ua;
+
+ SCARG(&ua, pid) = -1;
+ SCARG(&ua, status) = SCARG(uap, status);
+ SCARG(&ua, options) = SCARG(uap, options);
+ SCARG(&ua, rusage) = SCARG(uap, rusage);
+
+ return (sys_wait4(p, &ua, retval));
+}
+
+ultrix_sys_execv(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_execv_args *uap = v;
+ struct sys_execve_args ouap;
+
+ SCARG(&ouap, path) = SCARG(uap, path);
+ SCARG(&ouap, argp) = SCARG(uap, argp);
+ SCARG(&ouap, envp) = NULL;
+
+ return (sys_execve(p, &ouap, retval));
+}
+
+#if defined(NFSCLIENT)
+async_daemon(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct sys_nfssvc_args ouap;
+
+ SCARG(&ouap, flag) = NFSSVC_BIOD;
+ SCARG(&ouap, argp) = NULL;
+
+ return (sys_nfssvc(p, &ouap, retval));
+}
+#endif /* NFSCLIENT */
+
+ultrix_sys_sigpending(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_sigpending_args *uap = v;
+ int mask = p->p_siglist & p->p_sigmask;
+
+ return (copyout((caddr_t)&mask, (caddr_t)SCARG(uap, mask), sizeof(int)));
+}
+
+#if 0
+/* XXX: Temporary until sys/dir.h, include/dirent.h and sys/dirent.h are fixed */
+struct dirent {
+ u_long d_fileno; /* file number of entry */
+ u_short d_reclen; /* length of this record */
+ u_short d_namlen; /* length of string in d_name */
+ char d_name[255 + 1]; /* name must be no longer than this */
+};
+#endif
+
+#define SUN__MAP_NEW 0x80000000 /* if not, old mmap & cannot handle */
+
+ultrix_sys_mmap(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct ultrix_sys_mmap_args *uap = v;
+ struct sys_mmap_args ouap;
+ register struct filedesc *fdp;
+ register struct file *fp;
+ register struct vnode *vp;
+
+ /*
+ * Verify the arguments.
+ */
+ if (SCARG(uap, prot) & ~(PROT_READ|PROT_WRITE|PROT_EXEC))
+ return (EINVAL); /* XXX still needed? */
+
+ if ((SCARG(uap, flags) & SUN__MAP_NEW) == 0)
+ return (EINVAL);
+
+ SCARG(&ouap, flags) = SCARG(uap, flags) & ~SUN__MAP_NEW;
+ SCARG(&ouap, addr) = SCARG(uap, addr);
+
+ if ((SCARG(&ouap, flags) & MAP_FIXED) == 0 &&
+ SCARG(&ouap, addr) != 0 &&
+ SCARG(&ouap, addr) < (caddr_t)round_page(p->p_vmspace->vm_daddr+MAXDSIZ))
+ SCARG(&ouap, addr) = (caddr_t)round_page(p->p_vmspace->vm_daddr+MAXDSIZ);
+
+ SCARG(&ouap, len) = SCARG(uap, len);
+ SCARG(&ouap, prot) = SCARG(uap, prot);
+ SCARG(&ouap, fd) = SCARG(uap, fd);
+ SCARG(&ouap, pos) = SCARG(uap, pos);
+
+ /*
+ * Special case: if fd refers to /dev/zero, map as MAP_ANON. (XXX)
+ */
+ fdp = p->p_fd;
+ if ((unsigned)SCARG(&ouap, fd) < fdp->fd_nfiles && /*XXX*/
+ (fp = fdp->fd_ofiles[SCARG(&ouap, fd)]) != NULL && /*XXX*/
+ fp->f_type == DTYPE_VNODE && /*XXX*/
+ (vp = (struct vnode *)fp->f_data)->v_type == VCHR && /*XXX*/
+ iszerodev(vp->v_rdev)) { /*XXX*/
+ SCARG(&ouap, flags) |= MAP_ANON;
+ SCARG(&ouap, fd) = -1;
+ }
+
+ return (sys_mmap(p, &ouap, retval));
+}
+
+ultrix_sys_setsockopt(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ register struct ultrix_sys_setsockopt_args *uap = v;
+ struct file *fp;
+ struct mbuf *m = NULL;
+ int error;
+
+ if (error = getsock(p->p_fd, SCARG(uap, s), &fp))
+ return (error);
+#define SO_DONTLINGER (~SO_LINGER)
+ if (SCARG(uap, name) == SO_DONTLINGER) {
+ m = m_get(M_WAIT, MT_SOOPTS);
+ if (m == NULL)
+ return (ENOBUFS);
+ mtod(m, struct linger *)->l_onoff = 0;
+ m->m_len = sizeof(struct linger);
+ return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
+ SO_LINGER, m));
+ }
+ if (SCARG(uap, valsize) > MLEN)
+ return (EINVAL);
+ if (SCARG(uap, val)) {
+ m = m_get(M_WAIT, MT_SOOPTS);
+ if (m == NULL)
+ return (ENOBUFS);
+ if (error = copyin(SCARG(uap, val), mtod(m, caddr_t),
+ (u_int)SCARG(uap, valsize))) {
+ (void) m_free(m);
+ return (error);
+ }
+ m->m_len = SCARG(uap, valsize);
+ }
+ return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
+ SCARG(uap, name), m));
+}
+
+struct ultrix_utsname {
+ char sysname[9];
+ char nodename[9];
+ char nodeext[65-9];
+ char release[9];
+ char version[9];
+ char machine[9];
+};
+
+ultrix_sys_uname(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_uname_args *uap = v;
+ struct ultrix_utsname sut;
+ extern char ostype[], machine[], osrelease[];
+
+ bzero(&sut, sizeof(sut));
+
+ bcopy(ostype, sut.sysname, sizeof(sut.sysname) - 1);
+ bcopy(hostname, sut.nodename, sizeof(sut.nodename));
+ sut.nodename[sizeof(sut.nodename)-1] = '\0';
+ bcopy(osrelease, sut.release, sizeof(sut.release) - 1);
+ bcopy("1", sut.version, sizeof(sut.version) - 1);
+ bcopy(machine, sut.machine, sizeof(sut.machine) - 1);
+
+ return copyout((caddr_t)&sut, (caddr_t)SCARG(uap, name),
+ sizeof(struct ultrix_utsname));
+}
+
+int
+ultrix_sys_setpgrp(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_setpgrp_args *uap = v;
+
+ /*
+ * difference to our setpgid call is to include backwards
+ * compatibility to pre-setsid() binaries. Do setsid()
+ * instead of setpgid() in those cases where the process
+ * tries to create a new session the old way.
+ */
+ if (!SCARG(uap, pgid) &&
+ (!SCARG(uap, pid) || SCARG(uap, pid) == p->p_pid))
+ return sys_setsid(p, uap, retval);
+ else
+ return sys_setpgid(p, uap, retval);
+}
+
+ultrix_sys_open(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_open_args *uap = v;
+ int l, r;
+ int noctty;
+ int ret;
+
+ /* convert mode into NetBSD mode */
+ l = SCARG(uap, mode);
+ noctty = l & 0x8000;
+ r = (l & (0x0001 | 0x0002 | 0x0008 | 0x0040 | 0x0200 | 0x0400 | 0x0800));
+ r |= ((l & (0x0004 | 0x1000 | 0x4000)) ? O_NONBLOCK : 0);
+ r |= ((l & 0x0080) ? O_SHLOCK : 0);
+ r |= ((l & 0x0100) ? O_EXLOCK : 0);
+ r |= ((l & 0x2000) ? O_FSYNC : 0);
+
+ SCARG(uap, flags) = r;
+ ret = sys_open(p, (struct sys_open_args *)uap, retval);
+
+ if (!ret && !noctty && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
+ struct filedesc *fdp = p->p_fd;
+ struct file *fp = fdp->fd_ofiles[*retval];
+
+ /* ignore any error, just give it a try */
+ if (fp->f_type == DTYPE_VNODE)
+ (fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, (caddr_t)0, p);
+ }
+ return ret;
+}
+
+#if defined (NFSSERVER)
+ultrix_sys_nfssvc(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_nfssvc_args *uap = v;
+ struct emul *e = p->p_emul;
+ struct sys_nfssvc_args outuap;
+ struct sockaddr sa;
+ int error;
+
+#if 0
+ bzero(&outuap, sizeof outuap);
+ SCARG(&outuap, fd) = SCARG(uap, fd);
+ SCARG(&outuap, mskval) = STACKGAPBASE;
+ SCARG(&outuap, msklen) = sizeof sa;
+ SCARG(&outuap, mtchval) = outuap.mskval + sizeof sa;
+ SCARG(&outuap, mtchlen) = sizeof sa;
+
+ bzero(&sa, sizeof sa);
+ if (error = copyout(&sa, SCARG(&outuap, mskval), SCARG(&outuap, msklen)))
+ return (error);
+ if (error = copyout(&sa, SCARG(&outuap, mtchval), SCARG(&outuap, mtchlen)))
+ return (error);
+
+ return nfssvc(p, &outuap, retval);
+#else
+ return (ENOSYS);
+#endif
+}
+#endif /* NFSSERVER */
+
+struct ultrix_ustat {
+ daddr_t f_tfree; /* total free */
+ ino_t f_tinode; /* total inodes free */
+ char f_fname[6]; /* filsys name */
+ char f_fpack[6]; /* filsys pack name */
+};
+
+ultrix_sys_ustat(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_ustat_args *uap = v;
+ struct ultrix_ustat us;
+ int error;
+
+ bzero(&us, sizeof us);
+
+ /*
+ * XXX: should set f_tfree and f_tinode at least
+ * How do we translate dev -> fstat? (and then to ultrix_ustat)
+ */
+
+ if (error = copyout(&us, SCARG(uap, buf), sizeof us))
+ return (error);
+ return 0;
+}
+
+ultrix_sys_quotactl(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_quotactl_args *uap = v;
+
+ return EINVAL;
+}
+
+ultrix_sys_vhangup(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+
+ return 0;
+}
+
+struct ultrix_statfs {
+ long f_type; /* type of info, zero for now */
+ long f_bsize; /* fundamental file system block size */
+ long f_blocks; /* total blocks in file system */
+ long f_bfree; /* free blocks */
+ long f_bavail; /* free blocks available to non-super-user */
+ long f_files; /* total file nodes in file system */
+ long f_ffree; /* free file nodes in fs */
+ fsid_t f_fsid; /* file system id */
+ long f_spare[7]; /* spare for later */
+};
+
+static
+sunstatfs(sp, buf)
+ struct statfs *sp;
+ caddr_t buf;
+{
+ struct ultrix_statfs ssfs;
+
+ bzero(&ssfs, sizeof ssfs);
+ ssfs.f_type = 0;
+ ssfs.f_bsize = sp->f_bsize;
+ ssfs.f_blocks = sp->f_blocks;
+ ssfs.f_bfree = sp->f_bfree;
+ ssfs.f_bavail = sp->f_bavail;
+ ssfs.f_files = sp->f_files;
+ ssfs.f_ffree = sp->f_ffree;
+ ssfs.f_fsid = sp->f_fsid;
+ return copyout((caddr_t)&ssfs, buf, sizeof ssfs);
+}
+
+ultrix_sys_statfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_statfs_args *uap = v;
+ register struct mount *mp;
+ register struct statfs *sp;
+ int error;
+ struct nameidata nd;
+
+ NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
+ if (error = namei(&nd))
+ return (error);
+ mp = nd.ni_vp->v_mount;
+ sp = &mp->mnt_stat;
+ vrele(nd.ni_vp);
+ if (error = VFS_STATFS(mp, sp, p))
+ return (error);
+ sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
+ return sunstatfs(sp, (caddr_t)SCARG(uap, buf));
+}
+
+ultrix_sys_fstatfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_fstatfs_args *uap = v;
+ struct file *fp;
+ struct mount *mp;
+ register struct statfs *sp;
+ int error;
+
+ if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp))
+ return (error);
+ mp = ((struct vnode *)fp->f_data)->v_mount;
+ sp = &mp->mnt_stat;
+ if (error = VFS_STATFS(mp, sp, p))
+ return (error);
+ sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
+ return sunstatfs(sp, (caddr_t)SCARG(uap, buf));
+}
+
+ultrix_sys_exportfs(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_exportfs_args *uap = v;
+
+ /*
+ * XXX: should perhaps translate into a mount(2)
+ * with MOUNT_EXPORT?
+ */
+ return 0;
+}
+
+ultrix_sys_mknod(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_mknod_args *uap = v;
+
+ if (S_ISFIFO(SCARG(uap, mode)))
+ return sys_mkfifo(p, uap, retval);
+
+ return sys_mknod(p, (struct sys_mknod_args *)uap, retval);
+}
+
+int
+ultrix_sys_sigcleanup(p, v, retval)
+ struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ultrix_sys_sigcleanup_args *uap = v;
+
+ return sys_sigreturn(p, (struct sys_sigreturn_args *)uap, retval);
+}
diff --git a/sys/compat/ultrix/ultrix_syscall.h b/sys/compat/ultrix/ultrix_syscall.h
new file mode 100644
index 00000000000..3ac40c25b31
--- /dev/null
+++ b/sys/compat/ultrix/ultrix_syscall.h
@@ -0,0 +1,156 @@
+/*
+ * System call numbers.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.11 1995/10/07 06:28:00 mycroft Exp
+ */
+
+#define ULTRIX_SYS_syscall 0
+#define ULTRIX_SYS_exit 1
+#define ULTRIX_SYS_fork 2
+#define ULTRIX_SYS_read 3
+#define ULTRIX_SYS_write 4
+#define ULTRIX_SYS_open 5
+#define ULTRIX_SYS_close 6
+#define ULTRIX_SYS_creat 8
+#define ULTRIX_SYS_link 9
+#define ULTRIX_SYS_unlink 10
+#define ULTRIX_SYS_execv 11
+#define ULTRIX_SYS_chdir 12
+ /* 13 is obsolete time */
+#define ULTRIX_SYS_mknod 14
+#define ULTRIX_SYS_chmod 15
+#define ULTRIX_SYS_chown 16
+#define ULTRIX_SYS_break 17
+ /* 18 is obsolete stat */
+#define ULTRIX_SYS_lseek 19
+#define ULTRIX_SYS_getpid 20
+ /* 21 is obsolete mount */
+ /* 22 is obsolete sysV_unmount */
+#define ULTRIX_SYS_setuid 23
+#define ULTRIX_SYS_getuid 24
+ /* 25 is obsolete v7 stime */
+ /* 26 is obsolete v7 ptrace */
+ /* 27 is obsolete v7 alarm */
+ /* 28 is obsolete v7 fstat */
+ /* 29 is obsolete v7 pause */
+ /* 30 is obsolete v7 utime */
+ /* 31 is obsolete v7 stty */
+ /* 32 is obsolete v7 gtty */
+#define ULTRIX_SYS_access 33
+ /* 34 is obsolete v7 nice */
+ /* 35 is obsolete v7 ftime */
+#define ULTRIX_SYS_sync 36
+#define ULTRIX_SYS_kill 37
+#define ULTRIX_SYS_ostat 38
+ /* 39 is obsolete v7 setpgrp */
+#define ULTRIX_SYS_olstat 40
+#define ULTRIX_SYS_dup 41
+#define ULTRIX_SYS_pipe 42
+ /* 43 is obsolete v7 times */
+#define ULTRIX_SYS_profil 44
+ /* 46 is obsolete v7 setgid */
+#define ULTRIX_SYS_getgid 47
+#define ULTRIX_SYS_acct 51
+#define ULTRIX_SYS_ioctl 54
+#define ULTRIX_SYS_reboot 55
+#define ULTRIX_SYS_symlink 57
+#define ULTRIX_SYS_readlink 58
+#define ULTRIX_SYS_execve 59
+#define ULTRIX_SYS_umask 60
+#define ULTRIX_SYS_chroot 61
+#define ULTRIX_SYS_fstat 62
+#define ULTRIX_SYS_getpagesize 64
+#define ULTRIX_SYS_vfork 66
+ /* 67 is obsolete vread */
+ /* 68 is obsolete vwrite */
+#define ULTRIX_SYS_sbrk 69
+#define ULTRIX_SYS_sstk 70
+#define ULTRIX_SYS_mmap 71
+#define ULTRIX_SYS_vadvise 72
+#define ULTRIX_SYS_munmap 73
+#define ULTRIX_SYS_mprotect 74
+#define ULTRIX_SYS_madvise 75
+#define ULTRIX_SYS_vhangup 76
+#define ULTRIX_SYS_mincore 78
+#define ULTRIX_SYS_getgroups 79
+#define ULTRIX_SYS_setgroups 80
+#define ULTRIX_SYS_getpgrp 81
+#define ULTRIX_SYS_setpgrp 82
+#define ULTRIX_SYS_setitimer 83
+#define ULTRIX_SYS_wait3 84
+#define ULTRIX_SYS_swapon 85
+#define ULTRIX_SYS_getitimer 86
+#define ULTRIX_SYS_gethostname 87
+#define ULTRIX_SYS_sethostname 88
+#define ULTRIX_SYS_getdtablesize 89
+#define ULTRIX_SYS_dup2 90
+#define ULTRIX_SYS_fcntl 92
+#define ULTRIX_SYS_select 93
+#define ULTRIX_SYS_fsync 95
+#define ULTRIX_SYS_setpriority 96
+#define ULTRIX_SYS_socket 97
+#define ULTRIX_SYS_connect 98
+#define ULTRIX_SYS_accept 99
+#define ULTRIX_SYS_getpriority 100
+#define ULTRIX_SYS_send 101
+#define ULTRIX_SYS_recv 102
+#define ULTRIX_SYS_sigreturn 103
+#define ULTRIX_SYS_bind 104
+#define ULTRIX_SYS_setsockopt 105
+#define ULTRIX_SYS_listen 106
+#define ULTRIX_SYS_sigvec 108
+#define ULTRIX_SYS_sigblock 109
+#define ULTRIX_SYS_sigsetmask 110
+#define ULTRIX_SYS_sigsuspend 111
+#define ULTRIX_SYS_sigstack 112
+#define ULTRIX_SYS_recvmsg 113
+#define ULTRIX_SYS_sendmsg 114
+ /* 115 is obsolete vtrace */
+#define ULTRIX_SYS_gettimeofday 116
+#define ULTRIX_SYS_getrusage 117
+#define ULTRIX_SYS_getsockopt 118
+#define ULTRIX_SYS_readv 120
+#define ULTRIX_SYS_writev 121
+#define ULTRIX_SYS_settimeofday 122
+#define ULTRIX_SYS_fchown 123
+#define ULTRIX_SYS_fchmod 124
+#define ULTRIX_SYS_recvfrom 125
+#define ULTRIX_SYS_setreuid 126
+#define ULTRIX_SYS_setregid 127
+#define ULTRIX_SYS_rename 128
+#define ULTRIX_SYS_truncate 129
+#define ULTRIX_SYS_ftruncate 130
+#define ULTRIX_SYS_flock 131
+#define ULTRIX_SYS_sendto 133
+#define ULTRIX_SYS_shutdown 134
+#define ULTRIX_SYS_socketpair 135
+#define ULTRIX_SYS_mkdir 136
+#define ULTRIX_SYS_rmdir 137
+#define ULTRIX_SYS_utimes 138
+#define ULTRIX_SYS_sigcleanup 139
+#define ULTRIX_SYS_adjtime 140
+#define ULTRIX_SYS_getpeername 141
+#define ULTRIX_SYS_gethostid 142
+#define ULTRIX_SYS_getrlimit 144
+#define ULTRIX_SYS_setrlimit 145
+#define ULTRIX_SYS_killpg 146
+#define ULTRIX_SYS_getsockname 150
+#define ULTRIX_SYS_nfssvc 158
+#define ULTRIX_SYS_getdirentries 159
+#define ULTRIX_SYS_statfs 160
+#define ULTRIX_SYS_fstatfs 161
+#define ULTRIX_SYS_async_daemon 163
+#define ULTRIX_SYS_getfh 164
+#define ULTRIX_SYS_getdomainname 165
+#define ULTRIX_SYS_setdomainname 166
+#define ULTRIX_SYS_quotactl 168
+#define ULTRIX_SYS_exportfs 169
+#define ULTRIX_SYS_uname 179
+#define ULTRIX_SYS_ustat 183
+#define ULTRIX_SYS_sigpending 187
+#define ULTRIX_SYS_setsid 188
+#define ULTRIX_SYS_waitpid 189
+#define ULTRIX_SYS_getsysinfo 256
+#define ULTRIX_SYS_setsysinfo 257
+#define ULTRIX_SYS_MAXSYSCALL 258
diff --git a/sys/compat/ultrix/ultrix_syscallargs.h b/sys/compat/ultrix/ultrix_syscallargs.h
new file mode 100644
index 00000000000..ac03a0be564
--- /dev/null
+++ b/sys/compat/ultrix/ultrix_syscallargs.h
@@ -0,0 +1,257 @@
+/*
+ * System call argument lists.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.11 1995/10/07 06:28:00 mycroft Exp
+ */
+
+#define syscallarg(x) union { x datum; register_t pad; }
+
+struct ultrix_sys_open_args {
+ syscallarg(char *) path;
+ syscallarg(int) flags;
+ syscallarg(int) mode;
+};
+
+struct ultrix_sys_execv_args {
+ syscallarg(char *) path;
+ syscallarg(char **) argp;
+};
+
+struct ultrix_sys_mknod_args {
+ syscallarg(char *) path;
+ syscallarg(int) mode;
+ syscallarg(int) dev;
+};
+
+struct ultrix_sys_mmap_args {
+ syscallarg(caddr_t) addr;
+ syscallarg(size_t) len;
+ syscallarg(int) prot;
+ syscallarg(u_int) flags;
+ syscallarg(int) fd;
+ syscallarg(long) pos;
+};
+
+struct ultrix_sys_setpgrp_args {
+ syscallarg(int) pid;
+ syscallarg(int) pgid;
+};
+
+struct ultrix_sys_wait3_args {
+ syscallarg(int *) status;
+ syscallarg(int) options;
+ syscallarg(struct rusage *) rusage;
+};
+
+struct ultrix_sys_setsockopt_args {
+ syscallarg(int) s;
+ syscallarg(int) level;
+ syscallarg(int) name;
+ syscallarg(caddr_t) val;
+ syscallarg(int) valsize;
+};
+
+struct ultrix_sys_sigcleanup_args {
+ syscallarg(struct sigcontext *) sigcntxp;
+};
+
+struct ultrix_sys_nfssvc_args {
+ syscallarg(int) fd;
+};
+
+struct ultrix_sys_statfs_args {
+ syscallarg(char *) path;
+ syscallarg(struct ultrix_statfs *) buf;
+};
+
+struct ultrix_sys_fstatfs_args {
+ syscallarg(int) fd;
+ syscallarg(struct ultrix_statfs *) buf;
+};
+
+struct ultrix_sys_quotactl_args {
+ syscallarg(int) cmd;
+ syscallarg(char *) special;
+ syscallarg(int) uid;
+ syscallarg(caddr_t) addr;
+};
+
+struct ultrix_sys_exportfs_args {
+ syscallarg(char *) path;
+ syscallarg(char *) ex;
+};
+
+struct ultrix_sys_uname_args {
+ syscallarg(struct ultrix_utsname *) name;
+};
+
+struct ultrix_sys_ustat_args {
+ syscallarg(int) dev;
+ syscallarg(struct ultrix_ustat *) buf;
+};
+
+struct ultrix_sys_sigpending_args {
+ syscallarg(int *) mask;
+};
+
+struct ultrix_sys_waitpid_args {
+ syscallarg(int) pid;
+ syscallarg(int *) status;
+ syscallarg(int) options;
+};
+
+struct ultrix_sys_getsysinfo_args {
+ syscallarg(unsigned) op;
+ syscallarg(char *) buffer;
+ syscallarg(unsigned) nbytes;
+ syscallarg(int *) start;
+ syscallarg(char *) arg;
+};
+
+struct ultrix_sys_setsysinfo_args {
+ syscallarg(unsigned) op;
+ syscallarg(char *) buffer;
+ syscallarg(unsigned) nbytes;
+ syscallarg(unsigned) arg;
+ syscallarg(unsigned) flag;
+};
+
+/*
+ * System call prototypes.
+ */
+
+int sys_nosys __P((struct proc *, void *, register_t *));
+int sys_exit __P((struct proc *, void *, register_t *));
+int sys_fork __P((struct proc *, void *, register_t *));
+int sys_read __P((struct proc *, void *, register_t *));
+int sys_write __P((struct proc *, void *, register_t *));
+int ultrix_sys_open __P((struct proc *, void *, register_t *));
+int sys_close __P((struct proc *, void *, register_t *));
+int compat_43_sys_creat __P((struct proc *, void *, register_t *));
+int sys_link __P((struct proc *, void *, register_t *));
+int sys_unlink __P((struct proc *, void *, register_t *));
+int ultrix_sys_execv __P((struct proc *, void *, register_t *));
+int sys_chdir __P((struct proc *, void *, register_t *));
+int ultrix_sys_mknod __P((struct proc *, void *, register_t *));
+int sys_chmod __P((struct proc *, void *, register_t *));
+int sys_chown __P((struct proc *, void *, register_t *));
+int sys_obreak __P((struct proc *, void *, register_t *));
+int compat_43_sys_lseek __P((struct proc *, void *, register_t *));
+int sys_getpid __P((struct proc *, void *, register_t *));
+int sys_setuid __P((struct proc *, void *, register_t *));
+int sys_getuid __P((struct proc *, void *, register_t *));
+int sys_access __P((struct proc *, void *, register_t *));
+int sys_sync __P((struct proc *, void *, register_t *));
+int sys_kill __P((struct proc *, void *, register_t *));
+int compat_43_sys_stat __P((struct proc *, void *, register_t *));
+int compat_43_sys_lstat __P((struct proc *, void *, register_t *));
+int sys_dup __P((struct proc *, void *, register_t *));
+int sys_pipe __P((struct proc *, void *, register_t *));
+int sys_profil __P((struct proc *, void *, register_t *));
+int sys_getgid __P((struct proc *, void *, register_t *));
+int sys_acct __P((struct proc *, void *, register_t *));
+int sys_ioctl __P((struct proc *, void *, register_t *));
+int sys_reboot __P((struct proc *, void *, register_t *));
+int sys_symlink __P((struct proc *, void *, register_t *));
+int sys_readlink __P((struct proc *, void *, register_t *));
+int sys_execve __P((struct proc *, void *, register_t *));
+int sys_umask __P((struct proc *, void *, register_t *));
+int sys_chroot __P((struct proc *, void *, register_t *));
+int compat_43_sys_fstat __P((struct proc *, void *, register_t *));
+int compat_43_sys_getpagesize __P((struct proc *, void *, register_t *));
+int sys_vfork __P((struct proc *, void *, register_t *));
+int sys_sbrk __P((struct proc *, void *, register_t *));
+int sys_sstk __P((struct proc *, void *, register_t *));
+int ultrix_sys_mmap __P((struct proc *, void *, register_t *));
+int sys_ovadvise __P((struct proc *, void *, register_t *));
+int sys_munmap __P((struct proc *, void *, register_t *));
+int sys_mprotect __P((struct proc *, void *, register_t *));
+int sys_madvise __P((struct proc *, void *, register_t *));
+int ultrix_sys_vhangup __P((struct proc *, void *, register_t *));
+int sys_mincore __P((struct proc *, void *, register_t *));
+int sys_getgroups __P((struct proc *, void *, register_t *));
+int sys_setgroups __P((struct proc *, void *, register_t *));
+int sys_getpgrp __P((struct proc *, void *, register_t *));
+int ultrix_sys_setpgrp __P((struct proc *, void *, register_t *));
+int sys_setitimer __P((struct proc *, void *, register_t *));
+int ultrix_sys_wait3 __P((struct proc *, void *, register_t *));
+int sys_swapon __P((struct proc *, void *, register_t *));
+int sys_getitimer __P((struct proc *, void *, register_t *));
+int compat_43_sys_gethostname __P((struct proc *, void *, register_t *));
+int compat_43_sys_sethostname __P((struct proc *, void *, register_t *));
+int compat_43_sys_getdtablesize __P((struct proc *, void *, register_t *));
+int sys_dup2 __P((struct proc *, void *, register_t *));
+int sys_fcntl __P((struct proc *, void *, register_t *));
+int sys_select __P((struct proc *, void *, register_t *));
+int sys_fsync __P((struct proc *, void *, register_t *));
+int sys_setpriority __P((struct proc *, void *, register_t *));
+int sys_socket __P((struct proc *, void *, register_t *));
+int sys_connect __P((struct proc *, void *, register_t *));
+int compat_43_sys_accept __P((struct proc *, void *, register_t *));
+int sys_getpriority __P((struct proc *, void *, register_t *));
+int compat_43_sys_send __P((struct proc *, void *, register_t *));
+int compat_43_sys_recv __P((struct proc *, void *, register_t *));
+int sys_sigreturn __P((struct proc *, void *, register_t *));
+int sys_bind __P((struct proc *, void *, register_t *));
+int ultrix_sys_setsockopt __P((struct proc *, void *, register_t *));
+int sys_listen __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigvec __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigblock __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigsetmask __P((struct proc *, void *, register_t *));
+int sys_sigsuspend __P((struct proc *, void *, register_t *));
+int compat_43_sys_sigstack __P((struct proc *, void *, register_t *));
+int compat_43_sys_recvmsg __P((struct proc *, void *, register_t *));
+int compat_43_sys_sendmsg __P((struct proc *, void *, register_t *));
+int sys_gettimeofday __P((struct proc *, void *, register_t *));
+int sys_getrusage __P((struct proc *, void *, register_t *));
+int sys_getsockopt __P((struct proc *, void *, register_t *));
+int sys_readv __P((struct proc *, void *, register_t *));
+int sys_writev __P((struct proc *, void *, register_t *));
+int sys_settimeofday __P((struct proc *, void *, register_t *));
+int sys_fchown __P((struct proc *, void *, register_t *));
+int sys_fchmod __P((struct proc *, void *, register_t *));
+int compat_43_sys_recvfrom __P((struct proc *, void *, register_t *));
+int compat_43_sys_setreuid __P((struct proc *, void *, register_t *));
+int compat_43_sys_setregid __P((struct proc *, void *, register_t *));
+int sys_rename __P((struct proc *, void *, register_t *));
+int compat_43_sys_truncate __P((struct proc *, void *, register_t *));
+int compat_43_sys_ftruncate __P((struct proc *, void *, register_t *));
+int sys_flock __P((struct proc *, void *, register_t *));
+int sys_sendto __P((struct proc *, void *, register_t *));
+int sys_shutdown __P((struct proc *, void *, register_t *));
+int sys_socketpair __P((struct proc *, void *, register_t *));
+int sys_mkdir __P((struct proc *, void *, register_t *));
+int sys_rmdir __P((struct proc *, void *, register_t *));
+int sys_utimes __P((struct proc *, void *, register_t *));
+int ultrix_sys_sigcleanup __P((struct proc *, void *, register_t *));
+int sys_adjtime __P((struct proc *, void *, register_t *));
+int compat_43_sys_getpeername __P((struct proc *, void *, register_t *));
+int compat_43_sys_gethostid __P((struct proc *, void *, register_t *));
+int compat_43_sys_getrlimit __P((struct proc *, void *, register_t *));
+int compat_43_sys_setrlimit __P((struct proc *, void *, register_t *));
+int compat_43_sys_killpg __P((struct proc *, void *, register_t *));
+int compat_43_sys_getsockname __P((struct proc *, void *, register_t *));
+#ifdef NFSSERVER
+int ultrix_sys_nfssvc __P((struct proc *, void *, register_t *));
+#else
+#endif
+int compat_43_sys_getdirentries __P((struct proc *, void *, register_t *));
+int ultrix_sys_statfs __P((struct proc *, void *, register_t *));
+int ultrix_sys_fstatfs __P((struct proc *, void *, register_t *));
+#ifdef NFSCLIENT
+int async_daemon __P((struct proc *, void *, register_t *));
+int sys_getfh __P((struct proc *, void *, register_t *));
+#else
+#endif
+int compat_09_sys_getdomainname __P((struct proc *, void *, register_t *));
+int compat_09_sys_setdomainname __P((struct proc *, void *, register_t *));
+int ultrix_sys_quotactl __P((struct proc *, void *, register_t *));
+int ultrix_sys_exportfs __P((struct proc *, void *, register_t *));
+int ultrix_sys_uname __P((struct proc *, void *, register_t *));
+int ultrix_sys_ustat __P((struct proc *, void *, register_t *));
+int ultrix_sys_sigpending __P((struct proc *, void *, register_t *));
+int sys_setsid __P((struct proc *, void *, register_t *));
+int ultrix_sys_waitpid __P((struct proc *, void *, register_t *));
+int ultrix_sys_getsysinfo __P((struct proc *, void *, register_t *));
+int ultrix_sys_setsysinfo __P((struct proc *, void *, register_t *));
diff --git a/sys/compat/ultrix/ultrix_syscalls.c b/sys/compat/ultrix/ultrix_syscalls.c
new file mode 100644
index 00000000000..f0695ed78f2
--- /dev/null
+++ b/sys/compat/ultrix/ultrix_syscalls.c
@@ -0,0 +1,276 @@
+/*
+ * System call names.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.11 1995/10/07 06:28:00 mycroft Exp
+ */
+
+char *ultrix_syscallnames[] = {
+ "syscall", /* 0 = syscall */
+ "exit", /* 1 = exit */
+ "fork", /* 2 = fork */
+ "read", /* 3 = read */
+ "write", /* 4 = write */
+ "open", /* 5 = open */
+ "close", /* 6 = close */
+ "#7 (unimplemented old_wait)", /* 7 = unimplemented old_wait */
+ "creat", /* 8 = creat */
+ "link", /* 9 = link */
+ "unlink", /* 10 = unlink */
+ "execv", /* 11 = execv */
+ "chdir", /* 12 = chdir */
+ "#13 (obsolete time)", /* 13 = obsolete time */
+ "mknod", /* 14 = mknod */
+ "chmod", /* 15 = chmod */
+ "chown", /* 16 = chown */
+ "break", /* 17 = break */
+ "#18 (obsolete stat)", /* 18 = obsolete stat */
+ "lseek", /* 19 = lseek */
+ "getpid", /* 20 = getpid */
+ "#21 (obsolete mount)", /* 21 = obsolete mount */
+ "#22 (obsolete sysV_unmount)", /* 22 = obsolete sysV_unmount */
+ "setuid", /* 23 = setuid */
+ "getuid", /* 24 = getuid */
+ "#25 (obsolete v7 stime)", /* 25 = obsolete v7 stime */
+ "#26 (obsolete v7 ptrace)", /* 26 = obsolete v7 ptrace */
+ "#27 (obsolete v7 alarm)", /* 27 = obsolete v7 alarm */
+ "#28 (obsolete v7 fstat)", /* 28 = obsolete v7 fstat */
+ "#29 (obsolete v7 pause)", /* 29 = obsolete v7 pause */
+ "#30 (obsolete v7 utime)", /* 30 = obsolete v7 utime */
+ "#31 (obsolete v7 stty)", /* 31 = obsolete v7 stty */
+ "#32 (obsolete v7 gtty)", /* 32 = obsolete v7 gtty */
+ "access", /* 33 = access */
+ "#34 (obsolete v7 nice)", /* 34 = obsolete v7 nice */
+ "#35 (obsolete v7 ftime)", /* 35 = obsolete v7 ftime */
+ "sync", /* 36 = sync */
+ "kill", /* 37 = kill */
+ "ostat", /* 38 = ostat */
+ "#39 (obsolete v7 setpgrp)", /* 39 = obsolete v7 setpgrp */
+ "olstat", /* 40 = olstat */
+ "dup", /* 41 = dup */
+ "pipe", /* 42 = pipe */
+ "#43 (obsolete v7 times)", /* 43 = obsolete v7 times */
+ "profil", /* 44 = profil */
+ "#45 (unimplemented)", /* 45 = unimplemented */
+ "#46 (obsolete v7 setgid)", /* 46 = obsolete v7 setgid */
+ "getgid", /* 47 = getgid */
+ "#48 (unimplemented ssig)", /* 48 = unimplemented ssig */
+ "#49 (unimplemented reserved for USG)", /* 49 = unimplemented reserved for USG */
+ "#50 (unimplemented reserved for USG)", /* 50 = unimplemented reserved for USG */
+ "acct", /* 51 = acct */
+ "#52 (unimplemented)", /* 52 = unimplemented */
+ "#53 (unimplemented syslock)", /* 53 = unimplemented syslock */
+ "ioctl", /* 54 = ioctl */
+ "reboot", /* 55 = reboot */
+ "#56 (unimplemented v7 mpxchan)", /* 56 = unimplemented v7 mpxchan */
+ "symlink", /* 57 = symlink */
+ "readlink", /* 58 = readlink */
+ "execve", /* 59 = execve */
+ "umask", /* 60 = umask */
+ "chroot", /* 61 = chroot */
+ "fstat", /* 62 = fstat */
+ "#63 (unimplemented)", /* 63 = unimplemented */
+ "getpagesize", /* 64 = getpagesize */
+ "#65 (unimplemented mremap)", /* 65 = unimplemented mremap */
+ "vfork", /* 66 = vfork */
+ "#67 (obsolete vread)", /* 67 = obsolete vread */
+ "#68 (obsolete vwrite)", /* 68 = obsolete vwrite */
+ "sbrk", /* 69 = sbrk */
+ "sstk", /* 70 = sstk */
+ "mmap", /* 71 = mmap */
+ "vadvise", /* 72 = vadvise */
+ "munmap", /* 73 = munmap */
+ "mprotect", /* 74 = mprotect */
+ "madvise", /* 75 = madvise */
+ "vhangup", /* 76 = vhangup */
+ "#77 (unimplemented old vlimit)", /* 77 = unimplemented old vlimit */
+ "mincore", /* 78 = mincore */
+ "getgroups", /* 79 = getgroups */
+ "setgroups", /* 80 = setgroups */
+ "getpgrp", /* 81 = getpgrp */
+ "setpgrp", /* 82 = setpgrp */
+ "setitimer", /* 83 = setitimer */
+ "wait3", /* 84 = wait3 */
+ "swapon", /* 85 = swapon */
+ "getitimer", /* 86 = getitimer */
+ "gethostname", /* 87 = gethostname */
+ "sethostname", /* 88 = sethostname */
+ "getdtablesize", /* 89 = getdtablesize */
+ "dup2", /* 90 = dup2 */
+ "#91 (unimplemented getdopt)", /* 91 = unimplemented getdopt */
+ "fcntl", /* 92 = fcntl */
+ "select", /* 93 = select */
+ "#94 (unimplemented setdopt)", /* 94 = unimplemented setdopt */
+ "fsync", /* 95 = fsync */
+ "setpriority", /* 96 = setpriority */
+ "socket", /* 97 = socket */
+ "connect", /* 98 = connect */
+ "accept", /* 99 = accept */
+ "getpriority", /* 100 = getpriority */
+ "send", /* 101 = send */
+ "recv", /* 102 = recv */
+ "sigreturn", /* 103 = sigreturn */
+ "bind", /* 104 = bind */
+ "setsockopt", /* 105 = setsockopt */
+ "listen", /* 106 = listen */
+ "#107 (unimplemented vtimes)", /* 107 = unimplemented vtimes */
+ "sigvec", /* 108 = sigvec */
+ "sigblock", /* 109 = sigblock */
+ "sigsetmask", /* 110 = sigsetmask */
+ "sigsuspend", /* 111 = sigsuspend */
+ "sigstack", /* 112 = sigstack */
+ "recvmsg", /* 113 = recvmsg */
+ "sendmsg", /* 114 = sendmsg */
+ "#115 (obsolete vtrace)", /* 115 = obsolete vtrace */
+ "gettimeofday", /* 116 = gettimeofday */
+ "getrusage", /* 117 = getrusage */
+ "getsockopt", /* 118 = getsockopt */
+ "#119 (unimplemented resuba)", /* 119 = unimplemented resuba */
+ "readv", /* 120 = readv */
+ "writev", /* 121 = writev */
+ "settimeofday", /* 122 = settimeofday */
+ "fchown", /* 123 = fchown */
+ "fchmod", /* 124 = fchmod */
+ "recvfrom", /* 125 = recvfrom */
+ "setreuid", /* 126 = setreuid */
+ "setregid", /* 127 = setregid */
+ "rename", /* 128 = rename */
+ "truncate", /* 129 = truncate */
+ "ftruncate", /* 130 = ftruncate */
+ "flock", /* 131 = flock */
+ "#132 (unimplemented)", /* 132 = unimplemented */
+ "sendto", /* 133 = sendto */
+ "shutdown", /* 134 = shutdown */
+ "socketpair", /* 135 = socketpair */
+ "mkdir", /* 136 = mkdir */
+ "rmdir", /* 137 = rmdir */
+ "utimes", /* 138 = utimes */
+ "sigcleanup", /* 139 = sigcleanup */
+ "adjtime", /* 140 = adjtime */
+ "getpeername", /* 141 = getpeername */
+ "gethostid", /* 142 = gethostid */
+ "#143 (unimplemented old sethostid)", /* 143 = unimplemented old sethostid */
+ "getrlimit", /* 144 = getrlimit */
+ "setrlimit", /* 145 = setrlimit */
+ "killpg", /* 146 = killpg */
+ "#147 (unimplemented)", /* 147 = unimplemented */
+ "#148 (unimplemented setquota)", /* 148 = unimplemented setquota */
+ "#149 (unimplemented quota / * needs to be nullop to boot on Ultrix root partition * /)", /* 149 = unimplemented quota / * needs to be nullop to boot on Ultrix root partition * / */
+ "getsockname", /* 150 = getsockname */
+ "#151 (unimplemented sysmips / * 4 args * /)", /* 151 = unimplemented sysmips / * 4 args * / */
+ "#152 (unimplemented cacheflush / * 4 args * /)", /* 152 = unimplemented cacheflush / * 4 args * / */
+ "#153 (unimplemented cachectl / * 3 args * /)", /* 153 = unimplemented cachectl / * 3 args * / */
+ "#154 (unimplemented)", /* 154 = unimplemented */
+ "#155 (unimplemented atomic_op)", /* 155 = unimplemented atomic_op */
+ "#156 (unimplemented)", /* 156 = unimplemented */
+ "#157 (unimplemented)", /* 157 = unimplemented */
+#ifdef NFSSERVER
+ "nfssvc", /* 158 = nfssvc */
+#else
+ "#158 (unimplemented)", /* 158 = unimplemented */
+#endif
+ "getdirentries", /* 159 = getdirentries */
+ "statfs", /* 160 = statfs */
+ "fstatfs", /* 161 = fstatfs */
+ "#162 (unimplemented umount)", /* 162 = unimplemented umount */
+#ifdef NFSCLIENT
+ "async_daemon", /* 163 = async_daemon */
+ "getfh", /* 164 = getfh */
+#else
+ "#163 (unimplemented async_daemon)", /* 163 = unimplemented async_daemon */
+ "#164 (unimplemented getfh)", /* 164 = unimplemented getfh */
+#endif
+ "getdomainname", /* 165 = getdomainname */
+ "setdomainname", /* 166 = setdomainname */
+ "#167 (unimplemented)", /* 167 = unimplemented */
+ "quotactl", /* 168 = quotactl */
+ "exportfs", /* 169 = exportfs */
+ "#170 (unimplemented mount)", /* 170 = unimplemented mount */
+ "#171 (unimplemented 4 hdwconf)", /* 171 = unimplemented 4 hdwconf */
+ "#172 (unimplemented msgctl)", /* 172 = unimplemented msgctl */
+ "#173 (unimplemented msgget)", /* 173 = unimplemented msgget */
+ "#174 (unimplemented msgrcv)", /* 174 = unimplemented msgrcv */
+ "#175 (unimplemented msgsnd)", /* 175 = unimplemented msgsnd */
+ "#176 (unimplemented semctl)", /* 176 = unimplemented semctl */
+ "#177 (unimplemented semget)", /* 177 = unimplemented semget */
+ "#178 (unimplemented semop)", /* 178 = unimplemented semop */
+ "uname", /* 179 = uname */
+ "#180 (unimplemented shmsys)", /* 180 = unimplemented shmsys */
+ "#181 (unimplemented 0 plock)", /* 181 = unimplemented 0 plock */
+ "#182 (unimplemented 0 lockf)", /* 182 = unimplemented 0 lockf */
+ "ustat", /* 183 = ustat */
+ "#184 (unimplemented getmnt)", /* 184 = unimplemented getmnt */
+ "#185 (unimplemented notdef)", /* 185 = unimplemented notdef */
+ "#186 (unimplemented notdef)", /* 186 = unimplemented notdef */
+ "sigpending", /* 187 = sigpending */
+ "setsid", /* 188 = setsid */
+ "waitpid", /* 189 = waitpid */
+ "#190 (unimplemented)", /* 190 = unimplemented */
+ "#191 (unimplemented)", /* 191 = unimplemented */
+ "#192 (unimplemented)", /* 192 = unimplemented */
+ "#193 (unimplemented)", /* 193 = unimplemented */
+ "#194 (unimplemented)", /* 194 = unimplemented */
+ "#195 (unimplemented)", /* 195 = unimplemented */
+ "#196 (unimplemented)", /* 196 = unimplemented */
+ "#197 (unimplemented)", /* 197 = unimplemented */
+ "#198 (unimplemented)", /* 198 = unimplemented */
+ "#199 (unimplemented)", /* 199 = unimplemented */
+ "#200 (unimplemented)", /* 200 = unimplemented */
+ "#201 (unimplemented)", /* 201 = unimplemented */
+ "#202 (unimplemented)", /* 202 = unimplemented */
+ "#203 (unimplemented)", /* 203 = unimplemented */
+ "#204 (unimplemented)", /* 204 = unimplemented */
+ "#205 (unimplemented)", /* 205 = unimplemented */
+ "#206 (unimplemented)", /* 206 = unimplemented */
+ "#207 (unimplemented)", /* 207 = unimplemented */
+ "#208 (unimplemented)", /* 208 = unimplemented */
+ "#209 (unimplemented)", /* 209 = unimplemented */
+ "#210 (unimplemented)", /* 210 = unimplemented */
+ "#211 (unimplemented)", /* 211 = unimplemented */
+ "#212 (unimplemented)", /* 212 = unimplemented */
+ "#213 (unimplemented)", /* 213 = unimplemented */
+ "#214 (unimplemented)", /* 214 = unimplemented */
+ "#215 (unimplemented)", /* 215 = unimplemented */
+ "#216 (unimplemented)", /* 216 = unimplemented */
+ "#217 (unimplemented)", /* 217 = unimplemented */
+ "#218 (unimplemented)", /* 218 = unimplemented */
+ "#219 (unimplemented)", /* 219 = unimplemented */
+ "#220 (unimplemented)", /* 220 = unimplemented */
+ "#221 (unimplemented)", /* 221 = unimplemented */
+ "#222 (unimplemented)", /* 222 = unimplemented */
+ "#223 (unimplemented)", /* 223 = unimplemented */
+ "#224 (unimplemented)", /* 224 = unimplemented */
+ "#225 (unimplemented)", /* 225 = unimplemented */
+ "#226 (unimplemented)", /* 226 = unimplemented */
+ "#227 (unimplemented)", /* 227 = unimplemented */
+ "#228 (unimplemented)", /* 228 = unimplemented */
+ "#229 (unimplemented)", /* 229 = unimplemented */
+ "#230 (unimplemented)", /* 230 = unimplemented */
+ "#231 (unimplemented)", /* 231 = unimplemented */
+ "#232 (unimplemented)", /* 232 = unimplemented */
+ "#233 (unimplemented 1 utc_gettime)", /* 233 = unimplemented 1 utc_gettime */
+ "#234 (unimplemented 2 utc_adjtime)", /* 234 = unimplemented 2 utc_adjtime */
+ "#235 (unimplemented)", /* 235 = unimplemented */
+ "#236 (unimplemented)", /* 236 = unimplemented */
+ "#237 (unimplemented)", /* 237 = unimplemented */
+ "#238 (unimplemented)", /* 238 = unimplemented */
+ "#239 (unimplemented)", /* 239 = unimplemented */
+ "#240 (unimplemented)", /* 240 = unimplemented */
+ "#241 (unimplemented)", /* 241 = unimplemented */
+ "#242 (unimplemented)", /* 242 = unimplemented */
+ "#243 (unimplemented)", /* 243 = unimplemented */
+ "#244 (unimplemented)", /* 244 = unimplemented */
+ "#245 (unimplemented)", /* 245 = unimplemented */
+ "#246 (unimplemented)", /* 246 = unimplemented */
+ "#247 (unimplemented)", /* 247 = unimplemented */
+ "#248 (unimplemented)", /* 248 = unimplemented */
+ "#249 (unimplemented)", /* 249 = unimplemented */
+ "#250 (unimplemented)", /* 250 = unimplemented */
+ "#251 (unimplemented)", /* 251 = unimplemented */
+ "#252 (unimplemented audctl / * Make no-op for installation on Ultrix rootpartition? * /)", /* 252 = unimplemented audctl / * Make no-op for installation on Ultrix rootpartition? * / */
+ "#253 (unimplemented audgen / * Make no-op for installation on Ultrix rootpartition? * /)", /* 253 = unimplemented audgen / * Make no-op for installation on Ultrix rootpartition? * / */
+ "#254 (unimplemented startcpu)", /* 254 = unimplemented startcpu */
+ "#255 (unimplemented stopcpu)", /* 255 = unimplemented stopcpu */
+ "getsysinfo", /* 256 = getsysinfo */
+ "setsysinfo", /* 257 = setsysinfo */
+};
diff --git a/sys/compat/ultrix/ultrix_sysent.c b/sys/compat/ultrix/ultrix_sysent.c
new file mode 100644
index 00000000000..fdf44822eb1
--- /dev/null
+++ b/sys/compat/ultrix/ultrix_sysent.c
@@ -0,0 +1,565 @@
+/*
+ * System call switch table.
+ *
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.11 1995/10/07 06:28:00 mycroft Exp
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/signal.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <compat/ultrix/ultrix_syscallargs.h>
+
+#ifdef COMPAT_43
+#define compat_43(func) __CONCAT(compat_43_,func)
+#else
+#define compat_43(func) sys_nosys
+#endif
+
+#ifdef COMPAT_09
+#define compat_09(func) __CONCAT(compat_09_,func)
+#else
+#define compat_09(func) sys_nosys
+#endif
+
+#ifdef COMPAT_10
+#define compat_10(func) __CONCAT(compat_10_,func)
+#else
+#define compat_10(func) sys_nosys
+#endif
+
+#define s(type) sizeof(type)
+
+struct sysent ultrix_sysent[] = {
+ { 0, 0,
+ sys_nosys }, /* 0 = syscall */
+ { 1, s(struct sys_exit_args),
+ sys_exit }, /* 1 = exit */
+ { 0, 0,
+ sys_fork }, /* 2 = fork */
+ { 3, s(struct sys_read_args),
+ sys_read }, /* 3 = read */
+ { 3, s(struct sys_write_args),
+ sys_write }, /* 4 = write */
+ { 3, s(struct ultrix_sys_open_args),
+ ultrix_sys_open }, /* 5 = open */
+ { 1, s(struct sys_close_args),
+ sys_close }, /* 6 = close */
+ { 0, 0,
+ sys_nosys }, /* 7 = unimplemented old_wait */
+ { 2, s(struct compat_43_sys_creat_args),
+ compat_43_sys_creat }, /* 8 = creat */
+ { 2, s(struct sys_link_args),
+ sys_link }, /* 9 = link */
+ { 1, s(struct sys_unlink_args),
+ sys_unlink }, /* 10 = unlink */
+ { 2, s(struct ultrix_sys_execv_args),
+ ultrix_sys_execv }, /* 11 = execv */
+ { 1, s(struct sys_chdir_args),
+ sys_chdir }, /* 12 = chdir */
+ { 0, 0,
+ sys_nosys }, /* 13 = obsolete time */
+ { 3, s(struct ultrix_sys_mknod_args),
+ ultrix_sys_mknod }, /* 14 = mknod */
+ { 2, s(struct sys_chmod_args),
+ sys_chmod }, /* 15 = chmod */
+ { 3, s(struct sys_chown_args),
+ sys_chown }, /* 16 = chown */
+ { 1, s(struct sys_obreak_args),
+ sys_obreak }, /* 17 = break */
+ { 0, 0,
+ sys_nosys }, /* 18 = obsolete stat */
+ { 3, s(struct compat_43_sys_lseek_args),
+ compat_43_sys_lseek }, /* 19 = lseek */
+ { 0, 0,
+ sys_getpid }, /* 20 = getpid */
+ { 0, 0,
+ sys_nosys }, /* 21 = obsolete mount */
+ { 0, 0,
+ sys_nosys }, /* 22 = obsolete sysV_unmount */
+ { 1, s(struct sys_setuid_args),
+ sys_setuid }, /* 23 = setuid */
+ { 0, 0,
+ sys_getuid }, /* 24 = getuid */
+ { 0, 0,
+ sys_nosys }, /* 25 = obsolete v7 stime */
+ { 0, 0,
+ sys_nosys }, /* 26 = obsolete v7 ptrace */
+ { 0, 0,
+ sys_nosys }, /* 27 = obsolete v7 alarm */
+ { 0, 0,
+ sys_nosys }, /* 28 = obsolete v7 fstat */
+ { 0, 0,
+ sys_nosys }, /* 29 = obsolete v7 pause */
+ { 0, 0,
+ sys_nosys }, /* 30 = obsolete v7 utime */
+ { 0, 0,
+ sys_nosys }, /* 31 = obsolete v7 stty */
+ { 0, 0,
+ sys_nosys }, /* 32 = obsolete v7 gtty */
+ { 2, s(struct sys_access_args),
+ sys_access }, /* 33 = access */
+ { 0, 0,
+ sys_nosys }, /* 34 = obsolete v7 nice */
+ { 0, 0,
+ sys_nosys }, /* 35 = obsolete v7 ftime */
+ { 0, 0,
+ sys_sync }, /* 36 = sync */
+ { 2, s(struct sys_kill_args),
+ sys_kill }, /* 37 = kill */
+ { 2, s(struct compat_43_sys_stat_args),
+ compat_43_sys_stat }, /* 38 = ostat */
+ { 0, 0,
+ sys_nosys }, /* 39 = obsolete v7 setpgrp */
+ { 2, s(struct compat_43_sys_lstat_args),
+ compat_43_sys_lstat }, /* 40 = olstat */
+ { 1, s(struct sys_dup_args),
+ sys_dup }, /* 41 = dup */
+ { 0, 0,
+ sys_pipe }, /* 42 = pipe */
+ { 0, 0,
+ sys_nosys }, /* 43 = obsolete v7 times */
+ { 4, s(struct sys_profil_args),
+ sys_profil }, /* 44 = profil */
+ { 0, 0,
+ sys_nosys }, /* 45 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 46 = obsolete v7 setgid */
+ { 0, 0,
+ sys_getgid }, /* 47 = getgid */
+ { 0, 0,
+ sys_nosys }, /* 48 = unimplemented ssig */
+ { 0, 0,
+ sys_nosys }, /* 49 = unimplemented reserved for USG */
+ { 0, 0,
+ sys_nosys }, /* 50 = unimplemented reserved for USG */
+ { 1, s(struct sys_acct_args),
+ sys_acct }, /* 51 = acct */
+ { 0, 0,
+ sys_nosys }, /* 52 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 53 = unimplemented syslock */
+ { 3, s(struct sys_ioctl_args),
+ sys_ioctl }, /* 54 = ioctl */
+ { 1, s(struct sys_reboot_args),
+ sys_reboot }, /* 55 = reboot */
+ { 0, 0,
+ sys_nosys }, /* 56 = unimplemented v7 mpxchan */
+ { 2, s(struct sys_symlink_args),
+ sys_symlink }, /* 57 = symlink */
+ { 3, s(struct sys_readlink_args),
+ sys_readlink }, /* 58 = readlink */
+ { 3, s(struct sys_execve_args),
+ sys_execve }, /* 59 = execve */
+ { 1, s(struct sys_umask_args),
+ sys_umask }, /* 60 = umask */
+ { 1, s(struct sys_chroot_args),
+ sys_chroot }, /* 61 = chroot */
+ { 2, s(struct compat_43_sys_fstat_args),
+ compat_43_sys_fstat }, /* 62 = fstat */
+ { 0, 0,
+ sys_nosys }, /* 63 = unimplemented */
+ { 0, 0,
+ compat_43_sys_getpagesize }, /* 64 = getpagesize */
+ { 0, 0,
+ sys_nosys }, /* 65 = unimplemented mremap */
+ { 0, 0,
+ sys_vfork }, /* 66 = vfork */
+ { 0, 0,
+ sys_nosys }, /* 67 = obsolete vread */
+ { 0, 0,
+ sys_nosys }, /* 68 = obsolete vwrite */
+ { 1, s(struct sys_sbrk_args),
+ sys_sbrk }, /* 69 = sbrk */
+ { 1, s(struct sys_sstk_args),
+ sys_sstk }, /* 70 = sstk */
+ { 6, s(struct ultrix_sys_mmap_args),
+ ultrix_sys_mmap }, /* 71 = mmap */
+ { 1, s(struct sys_ovadvise_args),
+ sys_ovadvise }, /* 72 = vadvise */
+ { 2, s(struct sys_munmap_args),
+ sys_munmap }, /* 73 = munmap */
+ { 3, s(struct sys_mprotect_args),
+ sys_mprotect }, /* 74 = mprotect */
+ { 3, s(struct sys_madvise_args),
+ sys_madvise }, /* 75 = madvise */
+ { 0, 0,
+ ultrix_sys_vhangup }, /* 76 = vhangup */
+ { 0, 0,
+ sys_nosys }, /* 77 = unimplemented old vlimit */
+ { 3, s(struct sys_mincore_args),
+ sys_mincore }, /* 78 = mincore */
+ { 2, s(struct sys_getgroups_args),
+ sys_getgroups }, /* 79 = getgroups */
+ { 2, s(struct sys_setgroups_args),
+ sys_setgroups }, /* 80 = setgroups */
+ { 0, 0,
+ sys_getpgrp }, /* 81 = getpgrp */
+ { 2, s(struct ultrix_sys_setpgrp_args),
+ ultrix_sys_setpgrp }, /* 82 = setpgrp */
+ { 3, s(struct sys_setitimer_args),
+ sys_setitimer }, /* 83 = setitimer */
+ { 3, s(struct ultrix_sys_wait3_args),
+ ultrix_sys_wait3 }, /* 84 = wait3 */
+ { 1, s(struct sys_swapon_args),
+ sys_swapon }, /* 85 = swapon */
+ { 2, s(struct sys_getitimer_args),
+ sys_getitimer }, /* 86 = getitimer */
+ { 2, s(struct compat_43_sys_gethostname_args),
+ compat_43_sys_gethostname }, /* 87 = gethostname */
+ { 2, s(struct compat_43_sys_sethostname_args),
+ compat_43_sys_sethostname }, /* 88 = sethostname */
+ { 0, 0,
+ compat_43_sys_getdtablesize }, /* 89 = getdtablesize */
+ { 2, s(struct sys_dup2_args),
+ sys_dup2 }, /* 90 = dup2 */
+ { 0, 0,
+ sys_nosys }, /* 91 = unimplemented getdopt */
+ { 3, s(struct sys_fcntl_args),
+ sys_fcntl }, /* 92 = fcntl */
+ { 5, s(struct sys_select_args),
+ sys_select }, /* 93 = select */
+ { 0, 0,
+ sys_nosys }, /* 94 = unimplemented setdopt */
+ { 1, s(struct sys_fsync_args),
+ sys_fsync }, /* 95 = fsync */
+ { 3, s(struct sys_setpriority_args),
+ sys_setpriority }, /* 96 = setpriority */
+ { 3, s(struct sys_socket_args),
+ sys_socket }, /* 97 = socket */
+ { 3, s(struct sys_connect_args),
+ sys_connect }, /* 98 = connect */
+ { 3, s(struct compat_43_sys_accept_args),
+ compat_43_sys_accept }, /* 99 = accept */
+ { 2, s(struct sys_getpriority_args),
+ sys_getpriority }, /* 100 = getpriority */
+ { 4, s(struct compat_43_sys_send_args),
+ compat_43_sys_send }, /* 101 = send */
+ { 4, s(struct compat_43_sys_recv_args),
+ compat_43_sys_recv }, /* 102 = recv */
+ { 1, s(struct sys_sigreturn_args),
+ sys_sigreturn }, /* 103 = sigreturn */
+ { 3, s(struct sys_bind_args),
+ sys_bind }, /* 104 = bind */
+ { 5, s(struct ultrix_sys_setsockopt_args),
+ ultrix_sys_setsockopt }, /* 105 = setsockopt */
+ { 2, s(struct sys_listen_args),
+ sys_listen }, /* 106 = listen */
+ { 0, 0,
+ sys_nosys }, /* 107 = unimplemented vtimes */
+ { 3, s(struct compat_43_sys_sigvec_args),
+ compat_43_sys_sigvec }, /* 108 = sigvec */
+ { 1, s(struct compat_43_sys_sigblock_args),
+ compat_43_sys_sigblock }, /* 109 = sigblock */
+ { 1, s(struct compat_43_sys_sigsetmask_args),
+ compat_43_sys_sigsetmask }, /* 110 = sigsetmask */
+ { 1, s(struct sys_sigsuspend_args),
+ sys_sigsuspend }, /* 111 = sigsuspend */
+ { 2, s(struct compat_43_sys_sigstack_args),
+ compat_43_sys_sigstack }, /* 112 = sigstack */
+ { 3, s(struct compat_43_sys_recvmsg_args),
+ compat_43_sys_recvmsg }, /* 113 = recvmsg */
+ { 3, s(struct compat_43_sys_sendmsg_args),
+ compat_43_sys_sendmsg }, /* 114 = sendmsg */
+ { 0, 0,
+ sys_nosys }, /* 115 = obsolete vtrace */
+ { 2, s(struct sys_gettimeofday_args),
+ sys_gettimeofday }, /* 116 = gettimeofday */
+ { 2, s(struct sys_getrusage_args),
+ sys_getrusage }, /* 117 = getrusage */
+ { 5, s(struct sys_getsockopt_args),
+ sys_getsockopt }, /* 118 = getsockopt */
+ { 0, 0,
+ sys_nosys }, /* 119 = unimplemented resuba */
+ { 3, s(struct sys_readv_args),
+ sys_readv }, /* 120 = readv */
+ { 3, s(struct sys_writev_args),
+ sys_writev }, /* 121 = writev */
+ { 2, s(struct sys_settimeofday_args),
+ sys_settimeofday }, /* 122 = settimeofday */
+ { 3, s(struct sys_fchown_args),
+ sys_fchown }, /* 123 = fchown */
+ { 2, s(struct sys_fchmod_args),
+ sys_fchmod }, /* 124 = fchmod */
+ { 6, s(struct compat_43_sys_recvfrom_args),
+ compat_43_sys_recvfrom }, /* 125 = recvfrom */
+ { 2, s(struct compat_43_sys_setreuid_args),
+ compat_43_sys_setreuid }, /* 126 = setreuid */
+ { 2, s(struct compat_43_sys_setregid_args),
+ compat_43_sys_setregid }, /* 127 = setregid */
+ { 2, s(struct sys_rename_args),
+ sys_rename }, /* 128 = rename */
+ { 2, s(struct compat_43_sys_truncate_args),
+ compat_43_sys_truncate }, /* 129 = truncate */
+ { 2, s(struct compat_43_sys_ftruncate_args),
+ compat_43_sys_ftruncate }, /* 130 = ftruncate */
+ { 2, s(struct sys_flock_args),
+ sys_flock }, /* 131 = flock */
+ { 0, 0,
+ sys_nosys }, /* 132 = unimplemented */
+ { 6, s(struct sys_sendto_args),
+ sys_sendto }, /* 133 = sendto */
+ { 2, s(struct sys_shutdown_args),
+ sys_shutdown }, /* 134 = shutdown */
+ { 4, s(struct sys_socketpair_args),
+ sys_socketpair }, /* 135 = socketpair */
+ { 2, s(struct sys_mkdir_args),
+ sys_mkdir }, /* 136 = mkdir */
+ { 1, s(struct sys_rmdir_args),
+ sys_rmdir }, /* 137 = rmdir */
+ { 2, s(struct sys_utimes_args),
+ sys_utimes }, /* 138 = utimes */
+ { 1, s(struct ultrix_sys_sigcleanup_args),
+ ultrix_sys_sigcleanup }, /* 139 = sigcleanup */
+ { 2, s(struct sys_adjtime_args),
+ sys_adjtime }, /* 140 = adjtime */
+ { 3, s(struct compat_43_sys_getpeername_args),
+ compat_43_sys_getpeername }, /* 141 = getpeername */
+ { 0, 0,
+ compat_43_sys_gethostid }, /* 142 = gethostid */
+ { 0, 0,
+ sys_nosys }, /* 143 = unimplemented old sethostid */
+ { 2, s(struct compat_43_sys_getrlimit_args),
+ compat_43_sys_getrlimit }, /* 144 = getrlimit */
+ { 2, s(struct compat_43_sys_setrlimit_args),
+ compat_43_sys_setrlimit }, /* 145 = setrlimit */
+ { 2, s(struct compat_43_sys_killpg_args),
+ compat_43_sys_killpg }, /* 146 = killpg */
+ { 0, 0,
+ sys_nosys }, /* 147 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 148 = unimplemented setquota */
+ { 0, 0,
+ sys_nosys }, /* 149 = unimplemented quota / * needs to be nullop to boot on Ultrix root partition * / */
+ { 3, s(struct compat_43_sys_getsockname_args),
+ compat_43_sys_getsockname }, /* 150 = getsockname */
+ { 0, 0,
+ sys_nosys }, /* 151 = unimplemented sysmips / * 4 args * / */
+ { 0, 0,
+ sys_nosys }, /* 152 = unimplemented cacheflush / * 4 args * / */
+ { 0, 0,
+ sys_nosys }, /* 153 = unimplemented cachectl / * 3 args * / */
+ { 0, 0,
+ sys_nosys }, /* 154 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 155 = unimplemented atomic_op */
+ { 0, 0,
+ sys_nosys }, /* 156 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 157 = unimplemented */
+#ifdef NFSSERVER
+ { 1, s(struct ultrix_sys_nfssvc_args),
+ ultrix_sys_nfssvc }, /* 158 = nfssvc */
+#else
+ { 0, 0,
+ sys_nosys }, /* 158 = unimplemented */
+#endif
+ { 4, s(struct compat_43_sys_getdirentries_args),
+ compat_43_sys_getdirentries }, /* 159 = getdirentries */
+ { 2, s(struct ultrix_sys_statfs_args),
+ ultrix_sys_statfs }, /* 160 = statfs */
+ { 2, s(struct ultrix_sys_fstatfs_args),
+ ultrix_sys_fstatfs }, /* 161 = fstatfs */
+ { 0, 0,
+ sys_nosys }, /* 162 = unimplemented umount */
+#ifdef NFSCLIENT
+ { 0, 0,
+ async_daemon }, /* 163 = async_daemon */
+ { 2, s(struct sys_getfh_args),
+ sys_getfh }, /* 164 = getfh */
+#else
+ { 0, 0,
+ sys_nosys }, /* 163 = unimplemented async_daemon */
+ { 0, 0,
+ sys_nosys }, /* 164 = unimplemented getfh */
+#endif
+ { 2, s(struct compat_09_sys_getdomainname_args),
+ compat_09_sys_getdomainname }, /* 165 = getdomainname */
+ { 2, s(struct compat_09_sys_setdomainname_args),
+ compat_09_sys_setdomainname }, /* 166 = setdomainname */
+ { 0, 0,
+ sys_nosys }, /* 167 = unimplemented */
+ { 4, s(struct ultrix_sys_quotactl_args),
+ ultrix_sys_quotactl }, /* 168 = quotactl */
+ { 2, s(struct ultrix_sys_exportfs_args),
+ ultrix_sys_exportfs }, /* 169 = exportfs */
+ { 0, 0,
+ sys_nosys }, /* 170 = unimplemented mount */
+ { 0, 0,
+ sys_nosys }, /* 171 = unimplemented 4 hdwconf */
+ { 0, 0,
+ sys_nosys }, /* 172 = unimplemented msgctl */
+ { 0, 0,
+ sys_nosys }, /* 173 = unimplemented msgget */
+ { 0, 0,
+ sys_nosys }, /* 174 = unimplemented msgrcv */
+ { 0, 0,
+ sys_nosys }, /* 175 = unimplemented msgsnd */
+ { 0, 0,
+ sys_nosys }, /* 176 = unimplemented semctl */
+ { 0, 0,
+ sys_nosys }, /* 177 = unimplemented semget */
+ { 0, 0,
+ sys_nosys }, /* 178 = unimplemented semop */
+ { 1, s(struct ultrix_sys_uname_args),
+ ultrix_sys_uname }, /* 179 = uname */
+ { 0, 0,
+ sys_nosys }, /* 180 = unimplemented shmsys */
+ { 0, 0,
+ sys_nosys }, /* 181 = unimplemented 0 plock */
+ { 0, 0,
+ sys_nosys }, /* 182 = unimplemented 0 lockf */
+ { 2, s(struct ultrix_sys_ustat_args),
+ ultrix_sys_ustat }, /* 183 = ustat */
+ { 0, 0,
+ sys_nosys }, /* 184 = unimplemented getmnt */
+ { 0, 0,
+ sys_nosys }, /* 185 = unimplemented notdef */
+ { 0, 0,
+ sys_nosys }, /* 186 = unimplemented notdef */
+ { 1, s(struct ultrix_sys_sigpending_args),
+ ultrix_sys_sigpending }, /* 187 = sigpending */
+ { 0, 0,
+ sys_setsid }, /* 188 = setsid */
+ { 3, s(struct ultrix_sys_waitpid_args),
+ ultrix_sys_waitpid }, /* 189 = waitpid */
+ { 0, 0,
+ sys_nosys }, /* 190 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 191 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 192 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 193 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 194 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 195 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 196 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 197 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 198 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 199 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 200 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 201 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 202 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 203 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 204 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 205 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 206 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 207 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 208 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 209 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 210 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 211 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 212 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 213 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 214 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 215 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 216 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 217 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 218 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 219 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 220 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 221 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 222 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 223 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 224 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 225 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 226 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 227 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 228 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 229 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 230 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 231 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 232 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 233 = unimplemented 1 utc_gettime */
+ { 0, 0,
+ sys_nosys }, /* 234 = unimplemented 2 utc_adjtime */
+ { 0, 0,
+ sys_nosys }, /* 235 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 236 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 237 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 238 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 239 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 240 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 241 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 242 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 243 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 244 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 245 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 246 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 247 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 248 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 249 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 250 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 251 = unimplemented */
+ { 0, 0,
+ sys_nosys }, /* 252 = unimplemented audctl / * Make no-op for installation on Ultrix rootpartition? * / */
+ { 0, 0,
+ sys_nosys }, /* 253 = unimplemented audgen / * Make no-op for installation on Ultrix rootpartition? * / */
+ { 0, 0,
+ sys_nosys }, /* 254 = unimplemented startcpu */
+ { 0, 0,
+ sys_nosys }, /* 255 = unimplemented stopcpu */
+ { 5, s(struct ultrix_sys_getsysinfo_args),
+ ultrix_sys_getsysinfo }, /* 256 = getsysinfo */
+ { 5, s(struct ultrix_sys_setsysinfo_args),
+ ultrix_sys_setsysinfo }, /* 257 = setsysinfo */
+};
+