summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorswallace <swallace@FreeBSD.org>1995-10-10 07:27:24 +0000
committerswallace <swallace@FreeBSD.org>1995-10-10 07:27:24 +0000
commite2b7ea019e93c79967d0d384dd8a1467b33c093f (patch)
tree20f8e781dede0459deaba0714effbaf354b8cf60
parentfd4cf9ebc4d1bb8a1fecd87fabbda9ab907fcb9f (diff)
downloadFreeBSD-src-e2b7ea019e93c79967d0d384dd8a1467b33c093f.zip
FreeBSD-src-e2b7ea019e93c79967d0d384dd8a1467b33c093f.tar.gz
Import of original NetBSD's ibcs2 emulator sources by Scott Bartram,
which is used as a basis for a more complete and cleaner ibcs2 emulator. (snapshot about May 1995 with a few files from September 1995) Some files and code from old emulator still remains. New files, features, and changes have been implemented by myself, which will be shown in following commits.
-rw-r--r--sys/i386/ibcs2/ibcs2_dirent.h57
-rw-r--r--sys/i386/ibcs2/ibcs2_errno.c118
-rw-r--r--sys/i386/ibcs2/ibcs2_errno.h153
-rw-r--r--sys/i386/ibcs2/ibcs2_fcntl.c305
-rw-r--r--sys/i386/ibcs2/ibcs2_fcntl.h76
-rw-r--r--sys/i386/ibcs2/ibcs2_ioctl.c1262
-rw-r--r--sys/i386/ibcs2/ibcs2_ipc.c419
-rw-r--r--sys/i386/ibcs2/ibcs2_misc.c1678
-rw-r--r--sys/i386/ibcs2/ibcs2_mount.h41
-rw-r--r--sys/i386/ibcs2/ibcs2_signal.c786
-rw-r--r--sys/i386/ibcs2/ibcs2_signal.h105
-rw-r--r--sys/i386/ibcs2/ibcs2_socksys.c1501
-rw-r--r--sys/i386/ibcs2/ibcs2_socksys.h466
-rw-r--r--sys/i386/ibcs2/ibcs2_stat.c244
-rw-r--r--sys/i386/ibcs2/ibcs2_stat.h89
-rw-r--r--sys/i386/ibcs2/ibcs2_statfs.h48
-rw-r--r--sys/i386/ibcs2/ibcs2_stropts.h48
-rw-r--r--sys/i386/ibcs2/ibcs2_syscall.h97
-rw-r--r--sys/i386/ibcs2/ibcs2_sysent.c984
-rw-r--r--sys/i386/ibcs2/ibcs2_termios.h235
-rw-r--r--sys/i386/ibcs2/ibcs2_time.h50
-rw-r--r--sys/i386/ibcs2/ibcs2_timeb.h45
-rw-r--r--sys/i386/ibcs2/ibcs2_types.h54
-rw-r--r--sys/i386/ibcs2/ibcs2_unistd.h75
-rw-r--r--sys/i386/ibcs2/ibcs2_ustat.h46
-rw-r--r--sys/i386/ibcs2/ibcs2_util.c178
-rw-r--r--sys/i386/ibcs2/ibcs2_util.h82
-rw-r--r--sys/i386/ibcs2/ibcs2_utime.h41
-rw-r--r--sys/i386/ibcs2/ibcs2_utsname.h45
-rw-r--r--sys/i386/ibcs2/syscalls.conf12
-rw-r--r--sys/i386/ibcs2/syscalls.master243
31 files changed, 5340 insertions, 4243 deletions
diff --git a/sys/i386/ibcs2/ibcs2_dirent.h b/sys/i386/ibcs2/ibcs2_dirent.h
new file mode 100644
index 0000000..f93e3a9
--- /dev/null
+++ b/sys/i386/ibcs2/ibcs2_dirent.h
@@ -0,0 +1,57 @@
+/* $NetBSD: ibcs2_dirent.h,v 1.2 1994/10/26 02:52:51 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_DIRENT_H
+#define _IBCS2_DIRENT_H 1
+
+#include <compat/ibcs2/ibcs2_types.h>
+
+#define IBCS2_MAXNAMLEN 512
+#define IBCS2_DIRBUF 1048
+
+typedef struct {
+ int dd_fd;
+ int dd_loc;
+ int dd_size;
+ char *dd_buf;
+} IBCS2_DIR;
+
+struct ibcs2_dirent {
+ ibcs2_ino_t d_ino;
+ short d_pad;
+ ibcs2_off_t d_off;
+ u_short d_reclen;
+ char d_name[1];
+};
+
+#endif /* _IBCS2_DIRENT_H */
diff --git a/sys/i386/ibcs2/ibcs2_errno.c b/sys/i386/ibcs2/ibcs2_errno.c
new file mode 100644
index 0000000..48cb88e
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_errno.h b/sys/i386/ibcs2/ibcs2_errno.h
new file mode 100644
index 0000000..30ed824
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_fcntl.c b/sys/i386/ibcs2/ibcs2_fcntl.c
new file mode 100644
index 0000000..4dede8c
--- /dev/null
+++ b/sys/i386/ibcs2/ibcs2_fcntl.c
@@ -0,0 +1,305 @@
+/*
+ * 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_open(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_open_args *uap;
+ int *retval;
+{
+ int noctty = SCARG(uap, flags) & IBCS2_O_NOCTTY;
+ int ret;
+ caddr_t sg = stackgap_init();
+
+ SCARG(uap, flags) = cvt_o_flags(SCARG(uap, flags));
+ if (SCARG(uap, flags) & O_CREAT)
+ CHECKALTCREAT(p, &sg, SCARG(uap, path));
+ else
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ ret = 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_creat(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_creat_args *uap;
+ int *retval;
+{
+ struct open_args cup;
+ caddr_t sg = stackgap_init();
+
+ CHECKALTCREAT(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 open(p, &cup, retval);
+}
+
+int
+ibcs2_access(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_access_args *uap;
+ int *retval;
+{
+ struct access_args cup;
+ caddr_t sg = stackgap_init();
+
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, flags) = SCARG(uap, flags);
+ return access(p, &cup, retval);
+}
+
+int
+ibcs2_fcntl(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_fcntl_args *uap;
+ int *retval;
+{
+ int error;
+ struct 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 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 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 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 = 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 fcntl(p, &fa, retval);
+
+ case IBCS2_F_GETLK:
+ {
+ caddr_t sg = stackgap_init();
+ 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 = 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();
+ 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 fcntl(p, &fa, retval);
+ }
+
+ case IBCS2_F_SETLKW:
+ {
+ caddr_t sg = stackgap_init();
+ 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 fcntl(p, &fa, retval);
+ }
+ }
+ return ENOSYS;
+}
diff --git a/sys/i386/ibcs2/ibcs2_fcntl.h b/sys/i386/ibcs2/ibcs2_fcntl.h
new file mode 100644
index 0000000..b75537c
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_ioctl.c b/sys/i386/ibcs2/ibcs2_ioctl.c
index ecb9725..9b45f50 100644
--- a/sys/i386/ibcs2/ibcs2_ioctl.c
+++ b/sys/i386/ibcs2/ibcs2_ioctl.c
@@ -1,19 +1,18 @@
-/*-
- * Copyright (c) 1994 Søren Schmidt
- * Copyright (c) 1994 Sean Eric Fagan
+/* $NetBSD: ibcs2_ioctl.c,v 1.6 1995/03/14 15:12:28 scottb 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
- * in this position and unchanged.
- * 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 withough specific prior written permission
+ * 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
@@ -25,889 +24,464 @@
* 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.
- *
- * $Id: ibcs2_ioctl.c,v 1.13 1994/10/12 20:28:06 sos Exp $
*/
-#include <i386/ibcs2/ibcs2.h>
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/namei.h>
+#include <sys/dir.h>
#include <sys/proc.h>
-#include <sys/ioctl.h>
-#include <sys/ioctl_compat.h>
#include <sys/file.h>
+#include <sys/stat.h>
#include <sys/filedesc.h>
-#include <sys/tty.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 <machine/console.h>
-
-struct ibcs2_termio {
- unsigned short c_iflag;
- unsigned short c_oflag;
- unsigned short c_cflag;
- unsigned short c_lflag;
- char c_line;
- unsigned char c_cc[IBCS2_NCC];
-};
-
-struct ibcs2_termios {
- unsigned short c_iflag;
- unsigned short c_oflag;
- unsigned short c_cflag;
- unsigned short c_lflag;
- char c_line;
- unsigned char c_cc[IBCS2_NCCS];
- char c_ispeed;
- char c_ospeed;
-};
-
-struct ibcs2_winsize {
- char bytex, bytey;
- short bitx, bity;
-};
+#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 },
- { 57600, 15 }, { 115200, 15 }, {-1, -1 }
+ { 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 int
-ibcs2_to_bsd_speed(int code, struct speedtab *table)
-{
- for ( ; table->sp_code != -1; table++)
- if (table->sp_code == code)
- return (table->sp_speed);
- return -1;
-}
-
-static int
-bsd_to_ibcs2_speed(int speed, struct speedtab *table)
-{
- for ( ; table->sp_speed != -1; table++)
- if (table->sp_speed == speed)
- return (table->sp_code);
- return -1;
-}
+static u_long s2btab[] = {
+ 0,
+ 50,
+ 75,
+ 110,
+ 134,
+ 150,
+ 200,
+ 300,
+ 600,
+ 1200,
+ 1800,
+ 2400,
+ 4800,
+ 9600,
+ 19200,
+ 38400,
+};
static void
-bsd_termios_to_ibcs2_termio(struct termios *bsd_termios,
- struct ibcs2_termio *ibcs2_termio)
+stios2btios(st, bt)
+ struct ibcs2_termios *st;
+ struct termios *bt;
{
- int speed;
-
- if (ibcs2_trace & IBCS2_TRACE_IOCTLCNV) {
- int i;
- printf("IBCS2: BSD termios structure (input):\n");
- printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n",
- bsd_termios->c_iflag, bsd_termios->c_oflag,
- bsd_termios->c_cflag, bsd_termios->c_lflag,
- bsd_termios->c_ispeed, bsd_termios->c_ospeed);
- printf("c_cc ");
- for (i=0; i<NCCS; i++)
- printf("%02x ", bsd_termios->c_cc[i]);
- printf("\n");
- }
-
- ibcs2_termio->c_iflag = bsd_termios->c_iflag &
- (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK
- |ISTRIP|INLCR|IGNCR|ICRNL|IXANY);
- if (bsd_termios->c_iflag & IXON)
- ibcs2_termio->c_iflag |= IBCS2_IXON;
- if (bsd_termios->c_iflag & IXOFF)
- ibcs2_termio->c_iflag |= IBCS2_IXOFF;
-
- ibcs2_termio->c_oflag = 0;
- if (bsd_termios->c_oflag & OPOST)
- ibcs2_termio->c_oflag |= IBCS2_OPOST;
- if (bsd_termios->c_oflag & ONLCR)
- ibcs2_termio->c_oflag |= IBCS2_ONLCR;
- if (bsd_termios->c_oflag & OXTABS)
- ibcs2_termio->c_oflag |= (IBCS2_TAB1|IBCS2_TAB2);
-
- speed = bsd_to_ibcs2_speed(bsd_termios->c_ospeed, sptab);
-
- ibcs2_termio->c_cflag = speed >= 0 ? speed : 0;
- ibcs2_termio->c_cflag |= (bsd_termios->c_cflag & CSIZE) >> 4; /* XXX */
- if (bsd_termios->c_cflag & CSTOPB)
- ibcs2_termio->c_cflag |= IBCS2_CSTOPB;
- if (bsd_termios->c_cflag & PARENB)
- ibcs2_termio->c_cflag |= IBCS2_PARENB;
- if (bsd_termios->c_cflag & PARODD)
- ibcs2_termio->c_cflag |= IBCS2_PARODD;
- if (bsd_termios->c_cflag & HUPCL)
- ibcs2_termio->c_cflag |= IBCS2_HUPCL;
- if (bsd_termios->c_cflag & CLOCAL)
- ibcs2_termio->c_cflag |= IBCS2_CLOCAL;
-
- ibcs2_termio->c_lflag = 0;
- if (bsd_termios->c_lflag & ISIG)
- ibcs2_termio->c_lflag |= IBCS2_ISIG;
- if (bsd_termios->c_lflag & ICANON)
- ibcs2_termio->c_lflag |= IBCS2_ICANON;
- if (bsd_termios->c_lflag & ECHO)
- ibcs2_termio->c_lflag |= IBCS2_ECHO;
- if (bsd_termios->c_lflag & ECHOE)
- ibcs2_termio->c_lflag |= IBCS2_ECHOE;
- if (bsd_termios->c_lflag & ECHOK)
- ibcs2_termio->c_lflag |= IBCS2_ECHOK;
- if (bsd_termios->c_lflag & ECHONL)
- ibcs2_termio->c_lflag |= IBCS2_ECHONL;
- if (bsd_termios->c_lflag & NOFLSH)
- ibcs2_termio->c_lflag |= IBCS2_NOFLSH;
- if (bsd_termios->c_lflag & ECHOCTL)
- ibcs2_termio->c_lflag |= 0x0200; /* XXX */
- if (bsd_termios->c_lflag & ECHOPRT)
- ibcs2_termio->c_lflag |= 0x0400; /* XXX */
- if (bsd_termios->c_lflag & ECHOKE)
- ibcs2_termio->c_lflag |= 0x0800; /* XXX */
- if (bsd_termios->c_lflag & IEXTEN)
- ibcs2_termio->c_lflag |= 0x8000; /* XXX */
-
- ibcs2_termio->c_cc[IBCS2_VINTR] = bsd_termios->c_cc[VINTR];
- ibcs2_termio->c_cc[IBCS2_VQUIT] = bsd_termios->c_cc[VQUIT];
- ibcs2_termio->c_cc[IBCS2_VERASE] = bsd_termios->c_cc[VERASE];
- ibcs2_termio->c_cc[IBCS2_VKILL] = bsd_termios->c_cc[VKILL];
- if (bsd_termios->c_lflag & ICANON) {
- ibcs2_termio->c_cc[IBCS2_VEOF] = bsd_termios->c_cc[VEOF];
- ibcs2_termio->c_cc[IBCS2_VEOL] = bsd_termios->c_cc[VEOL];
- } else {
- ibcs2_termio->c_cc[IBCS2_VMIN] = bsd_termios->c_cc[VMIN];
- ibcs2_termio->c_cc[IBCS2_VTIME] = bsd_termios->c_cc[VTIME];
- }
- ibcs2_termio->c_cc[IBCS2_VEOL2] = bsd_termios->c_cc[VEOL2];
- ibcs2_termio->c_cc[IBCS2_VSWTCH] = 0xff;
- ibcs2_termio->c_line = 0;
-
- if (ibcs2_trace & IBCS2_TRACE_IOCTLCNV) {
- int i;
- printf("IBCS2: IBCS2 termio structure (output):\n");
- printf("i=%08x o=%08x c=%08x l=%08x speed=%d line=%d\n",
- ibcs2_termio->c_iflag, ibcs2_termio->c_oflag,
- ibcs2_termio->c_cflag, ibcs2_termio->c_lflag,
- ibcs2_to_bsd_speed(
- ibcs2_termio->c_cflag & IBCS2_CBAUD, sptab),
- ibcs2_termio->c_line);
- printf("c_cc ");
- for (i=0; i<IBCS2_NCC; i++)
- printf("%02x ", ibcs2_termio->c_cc[i]);
- printf("\n");
+ 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;
+ 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;
+ 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
-ibcs2_termio_to_bsd_termios(struct ibcs2_termio *ibcs2_termio,
- struct termios *bsd_termios)
+btios2stios(bt, st)
+ struct termios *bt;
+ struct ibcs2_termios *st;
{
- int i, speed;
-
- if (ibcs2_trace & IBCS2_TRACE_IOCTLCNV) {
- int i;
- printf("IBCS2: IBCS2 termio structure (input):\n");
- printf("i=%08x o=%08x c=%08x l=%08x speed=%d line=%d\n",
- ibcs2_termio->c_iflag, ibcs2_termio->c_oflag,
- ibcs2_termio->c_cflag, ibcs2_termio->c_lflag,
- ibcs2_to_bsd_speed(
- ibcs2_termio->c_cflag & IBCS2_CBAUD, sptab),
- ibcs2_termio->c_line);
- printf("c_cc ");
- for (i=0; i<IBCS2_NCC; i++)
- printf("%02x ", ibcs2_termio->c_cc[i]);
- printf("\n");
- }
-
- bsd_termios->c_iflag = ibcs2_termio->c_iflag &
- (IBCS2_IGNBRK|IBCS2_BRKINT|IBCS2_IGNPAR|IBCS2_PARMRK|IBCS2_INPCK
- |IBCS2_ISTRIP|IBCS2_INLCR|IBCS2_IGNCR|IBCS2_ICRNL|IBCS2_IXANY);
- if (ibcs2_termio->c_iflag & IBCS2_IXON)
- bsd_termios->c_iflag |= IXON;
- if (ibcs2_termio->c_iflag & IBCS2_IXOFF)
- bsd_termios->c_iflag |= IXOFF;
-
- bsd_termios->c_oflag = 0;
- if (ibcs2_termio->c_oflag & IBCS2_OPOST)
- bsd_termios->c_oflag |= OPOST;
- if (ibcs2_termio->c_oflag & IBCS2_ONLCR)
- bsd_termios->c_oflag |= ONLCR;
- if (ibcs2_termio->c_oflag & (IBCS2_TAB1|IBCS2_TAB2))
- bsd_termios->c_oflag |= OXTABS;
-
- speed = ibcs2_to_bsd_speed(ibcs2_termio->c_cflag & IBCS2_CBAUD, sptab);
- bsd_termios->c_ospeed = bsd_termios->c_ispeed = speed >= 0 ? speed : 0;
-
- bsd_termios->c_cflag = (ibcs2_termio->c_cflag & IBCS2_CSIZE) << 4;
- if (ibcs2_termio->c_cflag & IBCS2_CSTOPB)
- bsd_termios->c_cflag |= CSTOPB;
- if (ibcs2_termio->c_cflag & IBCS2_PARENB)
- bsd_termios->c_cflag |= PARENB;
- if (ibcs2_termio->c_cflag & IBCS2_PARODD)
- bsd_termios->c_cflag |= PARODD;
- if (ibcs2_termio->c_cflag & IBCS2_HUPCL)
- bsd_termios->c_cflag |= HUPCL;
- if (ibcs2_termio->c_cflag & IBCS2_CLOCAL)
- bsd_termios->c_cflag |= CLOCAL;
-
- bsd_termios->c_lflag = 0;
- if (ibcs2_termio->c_lflag & IBCS2_ISIG)
- bsd_termios->c_lflag |= ISIG;
- if (ibcs2_termio->c_lflag & IBCS2_ICANON)
- bsd_termios->c_lflag |= ICANON;
- if (ibcs2_termio->c_lflag & IBCS2_ECHO)
- bsd_termios->c_lflag |= ECHO;
- if (ibcs2_termio->c_lflag & IBCS2_ECHOE)
- bsd_termios->c_lflag |= ECHOE;
- if (ibcs2_termio->c_lflag & IBCS2_ECHOK)
- bsd_termios->c_lflag |= ECHOK;
- if (ibcs2_termio->c_lflag & IBCS2_ECHONL)
- bsd_termios->c_lflag |= ECHONL;
- if (ibcs2_termio->c_lflag & IBCS2_NOFLSH)
- bsd_termios->c_lflag |= NOFLSH;
- if (ibcs2_termio->c_lflag & 0x0200) /* XXX */
- bsd_termios->c_lflag |= ECHOCTL;
- if (ibcs2_termio->c_lflag & 0x0400) /* XXX */
- bsd_termios->c_lflag |= ECHOPRT;
- if (ibcs2_termio->c_lflag & 0x0800) /* XXX */
- bsd_termios->c_lflag |= ECHOKE;
- if (ibcs2_termio->c_lflag & 0x8000) /* XXX */
- bsd_termios->c_lflag |= IEXTEN;
-
- for (i=0; i<NCCS; bsd_termios->c_cc[i++] = 0) ;
- bsd_termios->c_cc[VINTR] = ibcs2_termio->c_cc[IBCS2_VINTR];
- bsd_termios->c_cc[VQUIT] = ibcs2_termio->c_cc[IBCS2_VQUIT];
- bsd_termios->c_cc[VERASE] = ibcs2_termio->c_cc[IBCS2_VERASE];
- bsd_termios->c_cc[VKILL] = ibcs2_termio->c_cc[IBCS2_VKILL];
- if (ibcs2_termio->c_lflag & IBCS2_ICANON) {
- bsd_termios->c_cc[VEOF] = ibcs2_termio->c_cc[IBCS2_VEOF];
- bsd_termios->c_cc[VEOL] = ibcs2_termio->c_cc[IBCS2_VEOL];
- } else {
- bsd_termios->c_cc[VMIN] = ibcs2_termio->c_cc[IBCS2_VMIN];
- bsd_termios->c_cc[VTIME] = ibcs2_termio->c_cc[IBCS2_VTIME];
- }
- bsd_termios->c_cc[VEOL2] = ibcs2_termio->c_cc[IBCS2_VEOL2];
-
- if (ibcs2_trace & IBCS2_TRACE_IOCTLCNV) {
- int i;
- printf("IBCS2: BSD termios structure (output):\n");
- printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n",
- bsd_termios->c_iflag, bsd_termios->c_oflag,
- bsd_termios->c_cflag, bsd_termios->c_lflag,
- bsd_termios->c_ispeed, bsd_termios->c_ospeed);
- printf("c_cc ");
- for (i=0; i<NCCS; i++)
- printf("%02x ", bsd_termios->c_cc[i]);
- printf("\n");
+ 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;
+ 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;
+ 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
-bsd_to_ibcs2_termios(struct termios *bsd_termios,
- struct ibcs2_termios *ibcs2_termios)
+stios2stio(ts, t)
+ struct ibcs2_termios *ts;
+ struct ibcs2_termio *t;
{
- int speed;
-
- if (ibcs2_trace & IBCS2_TRACE_IOCTLCNV) {
- int i;
- printf("IBCS2: BSD termios structure (input):\n");
- printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n",
- bsd_termios->c_iflag, bsd_termios->c_oflag,
- bsd_termios->c_cflag, bsd_termios->c_lflag,
- bsd_termios->c_ispeed, bsd_termios->c_ospeed);
- printf("c_cc ");
- for (i=0; i<NCCS; i++)
- printf("%02x ", bsd_termios->c_cc[i]);
- printf("\n");
- }
-
- ibcs2_termios->c_iflag = bsd_termios->c_iflag &
- (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK
- |ISTRIP|INLCR|IGNCR|ICRNL|IXANY);
- if (bsd_termios->c_iflag & IXON)
- ibcs2_termios->c_iflag |= IBCS2_IXON;
- if (bsd_termios->c_iflag & IXOFF)
- ibcs2_termios->c_iflag |= IBCS2_IXOFF;
-
- ibcs2_termios->c_oflag = 0;
- if (bsd_termios->c_oflag & OPOST)
- ibcs2_termios->c_oflag |= IBCS2_OPOST;
- if (bsd_termios->c_oflag & ONLCR)
- ibcs2_termios->c_oflag |= IBCS2_ONLCR;
- if (bsd_termios->c_oflag & OXTABS)
- ibcs2_termios->c_oflag |= (IBCS2_TAB1|IBCS2_TAB2);
-
- ibcs2_termios->c_cflag = (bsd_termios->c_cflag & CSIZE) >> 4; /* XXX */
- if (bsd_termios->c_cflag & CSTOPB)
- ibcs2_termios->c_cflag |= IBCS2_CSTOPB;
- if (bsd_termios->c_cflag & PARENB)
- ibcs2_termios->c_cflag |= IBCS2_PARENB;
- if (bsd_termios->c_cflag & PARODD)
- ibcs2_termios->c_cflag |= IBCS2_PARODD;
- if (bsd_termios->c_cflag & HUPCL)
- ibcs2_termios->c_cflag |= IBCS2_HUPCL;
- if (bsd_termios->c_cflag & CLOCAL)
- ibcs2_termios->c_cflag |= IBCS2_CLOCAL;
- if (bsd_termios->c_cflag & CRTSCTS)
- ibcs2_termios->c_cflag |= 0x8000; /* XXX */
-
- ibcs2_termios->c_lflag = 0;
- if (bsd_termios->c_lflag & ISIG)
- ibcs2_termios->c_lflag |= IBCS2_ISIG;
- if (bsd_termios->c_lflag & ICANON)
- ibcs2_termios->c_lflag |= IBCS2_ICANON;
- if (bsd_termios->c_lflag & ECHO)
- ibcs2_termios->c_lflag |= IBCS2_ECHO;
- if (bsd_termios->c_lflag & ECHOE)
- ibcs2_termios->c_lflag |= IBCS2_ECHOE;
- if (bsd_termios->c_lflag & ECHOK)
- ibcs2_termios->c_lflag |= IBCS2_ECHOK;
- if (bsd_termios->c_lflag & ECHONL)
- ibcs2_termios->c_lflag |= IBCS2_ECHONL;
- if (bsd_termios->c_lflag & NOFLSH)
- ibcs2_termios->c_lflag |= IBCS2_NOFLSH;
- if (bsd_termios->c_lflag & ECHOCTL)
- ibcs2_termios->c_lflag |= 0x0200; /* XXX */
- if (bsd_termios->c_lflag & ECHOPRT)
- ibcs2_termios->c_lflag |= 0x0400; /* XXX */
- if (bsd_termios->c_lflag & ECHOKE)
- ibcs2_termios->c_lflag |= 0x0800; /* XXX */
- if (bsd_termios->c_lflag & IEXTEN)
- ibcs2_termios->c_lflag |= 0x8000; /* XXX */
-
- ibcs2_termios->c_cc[IBCS2_VINTR] = bsd_termios->c_cc[VINTR];
- ibcs2_termios->c_cc[IBCS2_VQUIT] = bsd_termios->c_cc[VQUIT];
- ibcs2_termios->c_cc[IBCS2_VERASE] = bsd_termios->c_cc[VERASE];
- ibcs2_termios->c_cc[IBCS2_VKILL] = bsd_termios->c_cc[VKILL];
- if (bsd_termios->c_lflag & ICANON) {
- ibcs2_termios->c_cc[IBCS2_VEOF] = bsd_termios->c_cc[VEOF];
- ibcs2_termios->c_cc[IBCS2_VEOL] = bsd_termios->c_cc[VEOL];
- } else {
- ibcs2_termios->c_cc[IBCS2_VMIN] = bsd_termios->c_cc[VMIN];
- ibcs2_termios->c_cc[IBCS2_VTIME] = bsd_termios->c_cc[VTIME];
- }
- ibcs2_termios->c_cc[IBCS2_VEOL2] = bsd_termios->c_cc[VEOL2];
- ibcs2_termios->c_cc[IBCS2_VSWTCH] = 0xff;
- ibcs2_termios->c_cc[IBCS2_VSUSP] = bsd_termios->c_cc[VSUSP];
- ibcs2_termios->c_cc[IBCS2_VSTART] = bsd_termios->c_cc[VSTART];
- ibcs2_termios->c_cc[IBCS2_VSTOP] = bsd_termios->c_cc[VSTOP];
-
- ibcs2_termios->c_ispeed =
- bsd_to_ibcs2_speed(bsd_termios->c_ispeed, sptab);
- ibcs2_termios->c_ospeed =
- bsd_to_ibcs2_speed(bsd_termios->c_ospeed, sptab);
- ibcs2_termios->c_line = 0;
-
- if (ibcs2_trace & IBCS2_TRACE_IOCTLCNV) {
- int i;
- printf("IBCS2: IBCS2 termios structure (output):\n");
- printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d "
- "line=%d\n",
- ibcs2_termios->c_iflag, ibcs2_termios->c_oflag,
- ibcs2_termios->c_cflag, ibcs2_termios->c_lflag,
- ibcs2_to_bsd_speed(ibcs2_termios->c_ispeed, sptab),
- ibcs2_to_bsd_speed(ibcs2_termios->c_ospeed, sptab),
- ibcs2_termios->c_line);
- printf("c_cc ");
- for (i=0; i<IBCS2_NCCS; i++)
- printf("%02x ", ibcs2_termios->c_cc[i]);
- printf("\n");
- }
+ 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
-ibcs2_to_bsd_termios(struct ibcs2_termios *ibcs2_termios,
- struct termios *bsd_termios)
+stio2stios(t, ts)
+ struct ibcs2_termio *t;
+ struct ibcs2_termios *ts;
{
- int i, speed;
-
- if (ibcs2_trace & IBCS2_TRACE_IOCTLCNV) {
- int i;
- printf("IBCS2: IBCS2 termios structure (input):\n");
- printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d "
- "line=%d\n",
- ibcs2_termios->c_iflag, ibcs2_termios->c_oflag,
- ibcs2_termios->c_cflag, ibcs2_termios->c_lflag,
- ibcs2_to_bsd_speed(ibcs2_termios->c_ispeed, sptab),
- ibcs2_to_bsd_speed(ibcs2_termios->c_ospeed, sptab),
- ibcs2_termios->c_line);
- printf("c_cc ");
- for (i=0; i<IBCS2_NCCS; i++)
- printf("%02x ", ibcs2_termios->c_cc[i]);
- printf("\n");
- }
-
- bsd_termios->c_iflag = ibcs2_termios->c_iflag &
- (IBCS2_IGNBRK|IBCS2_BRKINT|IBCS2_IGNPAR|IBCS2_PARMRK|IBCS2_INPCK
- |IBCS2_ISTRIP|IBCS2_INLCR|IBCS2_IGNCR|IBCS2_ICRNL|IBCS2_IXANY);
- if (ibcs2_termios->c_iflag & IBCS2_IXON)
- bsd_termios->c_iflag |= IXON;
- if (ibcs2_termios->c_iflag & IBCS2_IXOFF)
- bsd_termios->c_iflag |= IXOFF;
-
- bsd_termios->c_oflag = 0;
- if (ibcs2_termios->c_oflag & IBCS2_OPOST)
- bsd_termios->c_oflag |= OPOST;
- if (ibcs2_termios->c_oflag & IBCS2_ONLCR)
- bsd_termios->c_oflag |= ONLCR;
- if (ibcs2_termios->c_oflag & (IBCS2_TAB1|IBCS2_TAB2))
- bsd_termios->c_oflag |= OXTABS;
-
- bsd_termios->c_cflag = (ibcs2_termios->c_cflag & IBCS2_CSIZE) << 4;
- if (ibcs2_termios->c_cflag & IBCS2_CSTOPB)
- bsd_termios->c_cflag |= CSTOPB;
- if (ibcs2_termios->c_cflag & IBCS2_PARENB)
- bsd_termios->c_cflag |= PARENB;
- if (ibcs2_termios->c_cflag & IBCS2_PARODD)
- bsd_termios->c_cflag |= PARODD;
- if (ibcs2_termios->c_cflag & IBCS2_HUPCL)
- bsd_termios->c_cflag |= HUPCL;
- if (ibcs2_termios->c_cflag & IBCS2_CLOCAL)
- bsd_termios->c_cflag |= CLOCAL;
- if (ibcs2_termios->c_cflag & 0x8000)
- bsd_termios->c_cflag |= CRTSCTS; /* XXX */
-
- bsd_termios->c_lflag = 0;
- if (ibcs2_termios->c_lflag & IBCS2_ISIG)
- bsd_termios->c_lflag |= ISIG;
- if (ibcs2_termios->c_lflag & IBCS2_ICANON)
- bsd_termios->c_lflag |= ICANON;
- if (ibcs2_termios->c_lflag & IBCS2_ECHO)
- bsd_termios->c_lflag |= ECHO;
- if (ibcs2_termios->c_lflag & IBCS2_ECHOE)
- bsd_termios->c_lflag |= ECHOE;
- if (ibcs2_termios->c_lflag & IBCS2_ECHOK)
- bsd_termios->c_lflag |= ECHOK;
- if (ibcs2_termios->c_lflag & IBCS2_ECHONL)
- bsd_termios->c_lflag |= ECHONL;
- if (ibcs2_termios->c_lflag & IBCS2_NOFLSH)
- bsd_termios->c_lflag |= NOFLSH;
- if (ibcs2_termios->c_lflag & 0x0200) /* XXX */
- bsd_termios->c_lflag |= ECHOCTL;
- if (ibcs2_termios->c_lflag & 0x0400) /* XXX */
- bsd_termios->c_lflag |= ECHOPRT;
- if (ibcs2_termios->c_lflag & 0x0800) /* XXX */
- bsd_termios->c_lflag |= ECHOKE;
- if (ibcs2_termios->c_lflag & 0x8000) /* XXX */
- bsd_termios->c_lflag |= IEXTEN;
-
- for (i=0; i<NCCS; bsd_termios->c_cc[i++] = 0) ;
- bsd_termios->c_cc[VINTR] = ibcs2_termios->c_cc[IBCS2_VINTR];
- bsd_termios->c_cc[VQUIT] = ibcs2_termios->c_cc[IBCS2_VQUIT];
- bsd_termios->c_cc[VERASE] = ibcs2_termios->c_cc[IBCS2_VERASE];
- bsd_termios->c_cc[VKILL] = ibcs2_termios->c_cc[IBCS2_VKILL];
- if (ibcs2_termios->c_lflag & IBCS2_ICANON) {
- bsd_termios->c_cc[VEOF] = ibcs2_termios->c_cc[IBCS2_VEOF];
- bsd_termios->c_cc[VEOL] = ibcs2_termios->c_cc[IBCS2_VEOL];
- } else {
- bsd_termios->c_cc[VMIN] = ibcs2_termios->c_cc[IBCS2_VMIN];
- bsd_termios->c_cc[VTIME] = ibcs2_termios->c_cc[IBCS2_VTIME];
- }
- bsd_termios->c_cc[VEOL2] = ibcs2_termios->c_cc[IBCS2_VEOL2];
- bsd_termios->c_cc[VSUSP] = ibcs2_termios->c_cc[IBCS2_VSUSP];
- bsd_termios->c_cc[VSTART] = ibcs2_termios->c_cc[IBCS2_VSTART];
- bsd_termios->c_cc[VSTOP] = ibcs2_termios->c_cc[IBCS2_VSTOP];
-
- bsd_termios->c_ispeed =
- ibcs2_to_bsd_speed(ibcs2_termios->c_ispeed, sptab);
- bsd_termios->c_ospeed =
- ibcs2_to_bsd_speed(ibcs2_termios->c_ospeed, sptab);
-
- if (ibcs2_trace & IBCS2_TRACE_IOCTLCNV) {
- int i;
- printf("IBCS2: BSD termios structure (output):\n");
- printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n",
- bsd_termios->c_iflag, bsd_termios->c_oflag,
- bsd_termios->c_cflag, bsd_termios->c_lflag,
- bsd_termios->c_ispeed, bsd_termios->c_ospeed);
- printf("c_cc ");
- for (i=0; i<NCCS; i++)
- printf("%02x ", bsd_termios->c_cc[i]);
- printf("\n");
- }
+ 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);
}
-
-struct ibcs2_ioctl_args {
- int fd;
- int cmd;
- int arg;
-};
-
int
-ibcs2_ioctl(struct proc *p, struct ibcs2_ioctl_args *args, int *retval)
+ibcs2_ioctl(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_ioctl_args *uap;
+ int *retval;
{
- struct termios bsd_termios;
- struct winsize bsd_winsize;
- struct ibcs2_termio ibcs2_termio;
- struct ibcs2_termios ibcs2_termios;
- struct ibcs2_winsize ibcs2_winsize;
struct filedesc *fdp = p->p_fd;
struct file *fp;
- int (*func)();
- int type = (args->cmd&0xffff00)>>8;
- int num = args->cmd&0xff;
+ int (*ctl)();
int error;
- if (ibcs2_trace & IBCS2_TRACE_IOCTL)
- printf("IBCS2: 'ioctl' fd=%d, typ=%d(%c), num=%d\n",
- args->fd, type, type, num);
-
- if ((unsigned)args->fd >= fdp->fd_nfiles
- || (fp = fdp->fd_ofiles[args->fd]) == 0)
+ 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 || (fp->f_flag & (FREAD | FWRITE)) == 0) {
+ if ((fp->f_flag & (FREAD|FWRITE)) == 0) {
+ DPRINTF(("ibcs2_ioctl(%d): bad fp flag ", p->p_pid));
return EBADF;
}
- func = fp->f_ops->fo_ioctl;
-
- switch (type) {
- case 'f':
- switch (num) {
- case 1:
- args->cmd = FIOCLEX;
- return ioctl(p, args, retval);
- case 2:
- args->cmd = FIONCLEX;
- return ioctl(p, args, retval);
- case 3:
- args->cmd = FIONREAD;
- return ioctl(p, args, retval);
- }
- break;
-#if 0
- case 'j':
- switch (num) {
- case 5: /* jerq winsize ?? */
- ibcs2_winsize.bytex = 80;
- /* p->p_session->s_ttyp->t_winsize.ws_col; XXX */
- ibcs2_winsize.bytey = 25;
- /* p->p_session->s_ttyp->t_winsize.ws_row; XXX */
- ibcs2_winsize.bitx =
- p->p_session->s_ttyp->t_winsize.ws_xpixel;
- ibcs2_winsize.bity =
- p->p_session->s_ttyp->t_winsize.ws_ypixel;
- return copyout((caddr_t)&ibcs2_winsize,
- (caddr_t)args->arg,
- sizeof(ibcs2_winsize));
- }
-#endif
- case 't':
- switch (num) {
- case 0:
- args->cmd = TIOCGETD;
- return ioctl(p, args, retval);
- case 1:
- args->cmd = TIOCSETD;
- return ioctl(p, args, retval);
- case 2:
- args->cmd = TIOCHPCL;
- return ioctl(p, args, retval);
- case 8:
- args->cmd = TIOCGETP;
- return ioctl(p, args, retval);
- case 9:
- args->cmd = TIOCSETP;
- return ioctl(p, args, retval);
- case 10:
- args->cmd = TIOCSETN;
- return ioctl(p, args, retval);
- case 13:
- args->cmd = TIOCEXCL;
- return ioctl(p, args, retval);
- case 14:
- args->cmd = TIOCNXCL;
- return ioctl(p, args, retval);
- case 16:
- args->cmd = TIOCFLUSH;
- return ioctl(p, args, retval);
- case 17:
- args->cmd = TIOCSETC;
- return ioctl(p, args, retval);
- case 18:
- args->cmd = TIOCGETC;
- return ioctl(p, args, retval);
- }
- break;
-
- case 'T':
- switch (num) {
- case 1: /* TCGETA */
- if ((error = (*func)(fp, TIOCGETA,
- (caddr_t)&bsd_termios, p)) != 0)
- return error;
- bsd_termios_to_ibcs2_termio(&bsd_termios,&ibcs2_termio);
- return copyout((caddr_t)&ibcs2_termio,
- (caddr_t)args->arg,
- sizeof(ibcs2_termio));
-
- case 2: /* TCSETA */
- ibcs2_termio_to_bsd_termios(
- (struct ibcs2_termio *)args->arg, &bsd_termios);
- return (*func)(fp, TIOCSETA, (caddr_t)&bsd_termios, p);
-
- case 3: /* TCSETAW */
- ibcs2_termio_to_bsd_termios(
- (struct ibcs2_termio *)args->arg, &bsd_termios);
- return (*func)(fp, TIOCSETAW, (caddr_t)&bsd_termios, p);
-
- case 4: /* TCSETAF */
- ibcs2_termio_to_bsd_termios(
- (struct ibcs2_termio *)args->arg, &bsd_termios);
- return (*func)(fp, TIOCSETAF, (caddr_t)&bsd_termios, p);
-
- case 5: /* TCSBRK */
- args->cmd = TIOCDRAIN;
- if (error = ioctl(p, args, retval))
- return error;
- args->cmd = TIOCSBRK;
- ioctl(p, args, retval);
- args->cmd = TIOCCBRK;
- error = ioctl(p, args, retval);
+ 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;
-
- case 6: /* TCONC */
- if (args->arg == 0) args->cmd = TIOCSTOP;
- else args->cmd = TIOCSTART;
- return ioctl(p, args, retval);
-
- case 7: /* TCFLSH */
- args->cmd = TIOCFLUSH;
- if ((int)args->arg == 0) (int)args->arg = FREAD;
- if ((int)args->arg == 1) (int)args->arg = FWRITE;
- if ((int)args->arg == 2) (int)args->arg = FREAD|FWRITE;
- return ioctl(p, args, retval);
-
- case 103: /* TIOCSWINSZ */
- bsd_winsize.ws_row =
- ((struct ibcs2_winsize *)(args->arg))->bytex;
- bsd_winsize.ws_col =
- ((struct ibcs2_winsize *)(args->arg))->bytey;
- bsd_winsize.ws_xpixel =
- ((struct ibcs2_winsize *)(args->arg))->bitx;
- bsd_winsize.ws_ypixel =
- ((struct ibcs2_winsize *)(args->arg))->bity;
- return (*func)(fp, TIOCSWINSZ,
- (caddr_t)&bsd_winsize, p);
-
- case 104: /* TIOCGWINSZ */
- if ((error = (*func)(fp, TIOCGWINSZ,
- (caddr_t)&bsd_winsize, p)) != 0)
- return error;
- ibcs2_winsize.bytex = bsd_winsize.ws_col;
- ibcs2_winsize.bytey = bsd_winsize.ws_row;
- ibcs2_winsize.bitx = bsd_winsize.ws_xpixel;
- ibcs2_winsize.bity = bsd_winsize.ws_ypixel;
- return copyout((caddr_t)&ibcs2_winsize,
- (caddr_t)args->arg,
- sizeof(ibcs2_winsize));
-
- case 20: /* TCSETPGRP */
- case 118: /* TIOCSPGRP */
- args->cmd = TIOCSPGRP;
- return ioctl(p, args, retval);
-
- case 21: /* TCGETPGRP */
- case 119: /* TIOCGPGRP */
- args->cmd = TIOCGPGRP;
- return ioctl(p, args, retval);
- }
- break;
-
- case ('x'):
- switch (num) {
- case 1:
- if ((error = (*func)(fp, TIOCGETA,
- (caddr_t)&bsd_termios, p)) != 0)
- return error;
- bsd_to_ibcs2_termios(&bsd_termios, &ibcs2_termios);
- return copyout((caddr_t)&ibcs2_termios,
- (caddr_t)args->arg,
- sizeof(ibcs2_termios));
- case 2:
- ibcs2_to_bsd_termios((struct ibcs2_termios *)args->arg,
- &bsd_termios);
- return (*func)(fp, TIOCSETA, (caddr_t)&bsd_termios, p);
- case 3:
- ibcs2_to_bsd_termios((struct ibcs2_termios *)args->arg,
- &bsd_termios);
- return (*func)(fp, TIOCSETAW, (caddr_t)&bsd_termios, p);
- case 4:
- ibcs2_to_bsd_termios((struct ibcs2_termios *)args->arg,
- &bsd_termios);
- return (*func)(fp, TIOCSETAF, (caddr_t)&bsd_termios, p);
-
- }
- break;
-
- /* below is console ioctl's, we have syscons so no problem here */
- case 'c':
- switch (num) {
- case 4:
- args->cmd = CONS_BLANKTIME;
- return ioctl(p, args, retval);
- case 64:
- args->cmd = PIO_FONT8x8;
- return ioctl(p, args, retval);
- case 65:
- args->cmd = GIO_FONT8x8;
- return ioctl(p, args, retval);
- case 66:
- args->cmd = PIO_FONT8x14;
- return ioctl(p, args, retval);
- case 67:
- args->cmd = GIO_FONT8x14;
- return ioctl(p, args, retval);
- case 68:
- args->cmd = PIO_FONT8x16;
- return ioctl(p, args, retval);
- case 69:
- args->cmd = GIO_FONT8x16;
- return ioctl(p, args, retval);
- case 73:
- args->cmd = CONS_GETINFO;
- return ioctl(p, args, retval);
}
- break;
-
- case 'k':
- switch (num) {
- case 0:
- args->cmd = GETFKEY;
- return ioctl(p, args, retval);
- case 1:
- args->cmd = SETFKEY;
- return ioctl(p, args, retval);
- case 2:
- args->cmd = GIO_SCRNMAP;
- return ioctl(p, args, retval);
- case 3:
- args->cmd = PIO_SCRNMAP;
- return ioctl(p, args, retval);
- case 6:
- args->cmd = GIO_KEYMAP;
- return ioctl(p, args, retval);
- case 7:
- args->cmd = PIO_KEYMAP;
- return ioctl(p, args, retval);
+
+ /* 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;
}
- break;
-
- case 'K':
- switch (num) {
- case 6:
- args->cmd = KDGKBMODE;
- return ioctl(p, args, retval);
- case 7:
- args->cmd = KDSKBMODE;
- return ioctl(p, args, retval);
- case 8:
- args->cmd = KDMKTONE;
- return ioctl(p, args, retval);
- case 9:
- args->cmd = KDGETMODE;
- return ioctl(p, args, retval);
- case 10:
- args->cmd = KDSETMODE;
- return ioctl(p, args, retval);
- case 13:
- args->cmd = KDSBORDER;
- return ioctl(p, args, retval);
- case 19:
- args->cmd = KDGKBSTATE;
- return ioctl(p, args, retval);
- case 20:
- args->cmd = KDSETRAD;
- return ioctl(p, args, retval);
- case 60:
- args->cmd = KDENABIO;
- return ioctl(p, args, retval);
- case 61:
- args->cmd = KDDISABIO;
- return ioctl(p, args, retval);
- case 63:
- args->cmd = KIOCSOUND;
- return ioctl(p, args, retval);
- case 64:
- args->cmd = KDGKBTYPE;
- return ioctl(p, args, retval);
- case 65:
- args->cmd = KDGETLED;
- return ioctl(p, args, retval);
- case 66:
- args->cmd = KDSETLED;
- return ioctl(p, args, retval);
+
+ /*
+ * 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;
}
- break;
-
- case 'S':
- args->cmd = _IO('S', num);
- return ioctl(p, args, retval);
-
- case 'v':
- switch (num) {
- case 1:
- args->cmd = VT_OPENQRY;
- return ioctl(p, args, retval);
- case 2:
- args->cmd = VT_SETMODE;
- return ioctl(p, args, retval);
- case 3:
- args->cmd = VT_GETMODE;
- return ioctl(p, args, retval);
- case 4:
- args->cmd = VT_RELDISP;
- return ioctl(p, args, retval);
- case 5:
- args->cmd = VT_ACTIVATE;
- return ioctl(p, args, retval);
- case 6:
- args->cmd = VT_WAITACTIVE;
- return ioctl(p, args, retval);
+ 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;
}
- break;
- }
- uprintf("IBCS2: 'ioctl' fd=%d, typ=%d(%c), num=%d not implemented\n",
- args->fd, type, type, num);
- return EINVAL;
-}
+ 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 ioctl(p, uap, retval);
+
+ case IBCS2_TIOCSWINSZ:
+ SCARG(uap, cmd) = TIOCSWINSZ;
+ return 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 setpgid_args sa;
+
+ SCARG(&sa, pid) = 0;
+ SCARG(&sa, pgid) = (int)SCARG(uap, data);
+ if (error = setpgid(p, &sa, retval))
+ return error;
+ return 0;
+ }
-struct ibcs2_sgtty_args {
- int fd;
- struct sgttyb *buf;
-};
+ case IBCS2_TCGETSC: /* SCO console - get scancode flags */
+ return ENOSYS;
-struct ioctl_args {
- int fd;
- int cmd;
- caddr_t arg;
-};
+ case IBCS2_TCSETSC: /* SCO console - set scancode flags */
+ return ENOSYS;
-int
-ibcs2_gtty(struct proc *p, struct ibcs2_sgtty_args *args, int *retval)
-{
- struct ioctl_args ioctl_arg;
-
- if (ibcs2_trace & IBCS2_TRACE_IOCTL)
- printf("IBCS2: 'gtty' fd=%d\n", args->fd);
- ioctl_arg.fd = args->fd;
- ioctl_arg.cmd = TIOCGETC;
- ioctl_arg.arg = (caddr_t)args->buf;
-
- return ioctl(p, &ioctl_arg, retval);
-}
+ case IBCS2_SIOCSOCKSYS:
+ return ibcs2_socksys(p, uap, retval);
-int
-ibcs2_stty(struct proc *p, struct ibcs2_sgtty_args *args, int *retval)
-{
- struct ioctl_args ioctl_arg;
-
- if (ibcs2_trace & IBCS2_TRACE_IOCTL)
- printf("IBCS2: 'stty' fd=%d\n", args->fd);
- ioctl_arg.fd = args->fd;
- ioctl_arg.cmd = TIOCSETC;
- ioctl_arg.arg = (caddr_t)args->buf;
- return ioctl(p, &ioctl_arg, retval);
+ case IBCS2_I_NREAD: /* STREAMS */
+ SCARG(uap, cmd) = FIONREAD;
+ return 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/i386/ibcs2/ibcs2_ipc.c b/sys/i386/ibcs2/ibcs2_ipc.c
index f760e2e..6dc1714 100644
--- a/sys/i386/ibcs2/ibcs2_ipc.c
+++ b/sys/i386/ibcs2/ibcs2_ipc.c
@@ -1,18 +1,14 @@
-/*-
- * Copyright (c) 1994 Søren Schmidt
+/*
+ * 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
- * in this position and unchanged.
- * 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 withough specific prior written permission
+ * 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
@@ -24,52 +20,395 @@
* 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.
- *
- * $Id: ibcs2_ipc.c,v 1.3 1994/10/12 19:38:03 sos Exp $
*/
-
-#include <i386/ibcs2/ibcs2.h>
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/errno.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_msgsys(struct proc *p, void *args, int *retval)
+ibcs2_msgsys(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_msgsys_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'msgsys'\n");
-#ifdef SYSVMSG
- return msgsys(p, args, retval);
-#else
- printf("IBCS2: 'msgsys' not implemented yet\n");
- return EINVAL;
-#endif
+ switch (SCARG(uap, which)) {
+ case 0: /* msgget */
+ SCARG(uap, which) = 1;
+ return compat_10_msgsys(p, uap, retval);
+ case 1: { /* msgctl */
+ int error;
+ struct compat_10_msgsys_args margs;
+ caddr_t sg = stackgap_init();
+
+ 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_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_msgsys(p, &margs, retval);
+ case IBCS2_IPC_RMID:
+ return compat_10_msgsys(p, &margs, retval);
+ }
+ return EINVAL;
+ }
+ case 2: /* msgrcv */
+ SCARG(uap, which) = 3;
+ return compat_10_msgsys(p, uap, retval);
+ case 3: /* msgsnd */
+ SCARG(uap, which) = 2;
+ return compat_10_msgsys(p, uap, retval);
+ 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_semsys(struct proc *p, void *args, int *retval)
+ibcs2_semsys(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_semsys_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'semsys'\n");
-#ifdef SYSVSEM
- return semsys(p, args, retval);
-#else
- printf("IBCS2: 'semsys' not implemented yet\n");
+ int error;
+
+ 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();
+
+ isp = (struct ibcs2_semid_ds *)SCARG(uap, a5);
+ sp = stackgap_alloc(&sg, sizeof(struct semid_ds));
+ SCARG(uap, a5) = (int)sp;
+ error = compat_10_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();
+
+ 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_semsys(p, uap, retval);
+ }
+ }
+ return compat_10_semsys(p, uap, retval);
+
+ case 1: /* semget */
+ return compat_10_semsys(p, uap, retval);
+
+ case 2: /* semop */
+ return compat_10_semsys(p, uap, retval);
+ }
return EINVAL;
-#endif
+}
+
+
+/*
+ * 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_shmsys(struct proc *p, void *args, int *retval)
+ibcs2_shmsys(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_shmsys_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'shmsys'\n");
-#ifdef SYSVSHM
- return shmsys(p, args, retval);
-#else
- printf("IBCS2: 'shmsys' not implemented yet\n");
+ int error;
+
+ switch (SCARG(uap, which)) {
+ case 0: /* shmat */
+ return compat_10_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();
+
+ isp = (struct ibcs2_shmid_ds *)SCARG(uap, a4);
+ sp = stackgap_alloc(&sg, sizeof(*sp));
+ SCARG(uap, a4) = (int)sp;
+ error = compat_10_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();
+
+ 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_shmsys(p, uap, retval);
+ }
+ }
+ return compat_10_shmsys(p, uap, retval);
+
+ case 2: /* shmdt */
+ return compat_10_shmsys(p, uap, retval);
+
+ case 3: /* shmget */
+ return compat_10_shmsys(p, uap, retval);
+ }
return EINVAL;
-#endif
}
-
diff --git a/sys/i386/ibcs2/ibcs2_misc.c b/sys/i386/ibcs2/ibcs2_misc.c
index c4dfe6c..cc1da26 100644
--- a/sys/i386/ibcs2/ibcs2_misc.c
+++ b/sys/i386/ibcs2/ibcs2_misc.c
@@ -1,17 +1,24 @@
-/*-
- * Copyright (c) 1994 Søren Schmidt
- * Copyright (c) 1994 Sean Eric Fagan
- * All rights reserved.
+/* $NetBSD: ibcs2_misc.c,v 1.6 1995/05/01 19:33:17 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.
*
- * Copyright (c) 1982, 1986, 1989, 1991 Regents of the University of California.
- * All rights reserved.
+ * 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
- * in this position and unchanged.
+ * 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.
@@ -35,934 +42,1159 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ibcs2_misc.c,v 1.16 1994/10/13 23:10:58 sos Exp $
+ * 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 <i386/ibcs2/ibcs2.h>
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/namei.h>
#include <sys/proc.h>
-#include <sys/exec.h>
-#include <sys/sysent.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/unistd.h>
+#include <sys/vnode.h>
+#include <sys/uio.h>
#include <sys/wait.h>
-#include <vm/vm.h>
-#include <machine/cpu.h>
-#include <machine/psl.h>
-#include <machine/reg.h>
+#include <sys/utsname.h>
+#include <sys/unistd.h>
-int ibcs2_trace = 0;
+#include <ufs/ufs/dir.h>
-struct ibcs2_traceemu_args {
- int options;
-};
+#include <netinet/in.h>
+#include <sys/syscallargs.h>
-int
-ibcs2_traceemu(struct proc *p, struct ibcs2_traceemu_args *args, int *retval)
-{
- *retval = ibcs2_trace;
- ibcs2_trace = args->options;
- return 0;
-}
+#include <miscfs/specfs/specdev.h>
-int
-ibcs2_access(struct proc *p, void *args, int *retval)
-{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'access'\n");
- return access(p, args, retval);
-}
+#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>
-struct ibcs2_alarm_args {
- unsigned int secs;
-};
int
-ibcs2_alarm(struct proc *p, struct ibcs2_alarm_args *args, int *retval)
+ibcs2_ulimit(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_ulimit_args *uap;
+ int *retval;
{
- extern struct timeval time;
- struct itimerval it, oit;
- int s;
-
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'alarm' secs=%d\n", args->secs);
- it.it_value.tv_sec = (long)args->secs;
- it.it_value.tv_usec = 0;
- it.it_interval.tv_sec = 0;
- it.it_interval.tv_usec = 0;
- s = splclock();
- oit = p->p_realtimer;
- if (timerisset(&oit.it_value))
- if (timercmp(&oit.it_value, &time, <))
- timerclear(&oit.it_value);
+ int error;
+ struct rlimit rl;
+ struct setrlimit_args {
+ int resource;
+ struct rlimit *rlp;
+ } 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.resource = RLIMIT_FSIZE;
+ sra.rlp = &rl;
+ error = setrlimit(p, &sra, retval);
+ if (!error)
+ *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur;
else
- timevalsub(&oit.it_value, &time);
- splx(s);
- if (itimerfix(&it.it_value) || itimerfix(&it.it_interval))
- return EINVAL;
- s = splclock();
- untimeout(realitexpire, (caddr_t)p);
- if (timerisset(&it.it_value)) {
- timevaladd(&it.it_value, &time);
- timeout(realitexpire, (caddr_t)p, hzto(&it.it_value));
+ 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_sysconf(p, uap, retval);
+ default:
+ return ENOSYS;
}
- p->p_realtimer = it;
- splx(s);
- if (oit.it_value.tv_usec)
- oit.it_value.tv_sec++;
- *retval = oit.it_value.tv_sec;
- return 0;
}
-struct ibcs2_break_args {
- char *dsend;
-};
-
int
-ibcs2_break(struct proc *p, struct ibcs2_break_args *args, int *retval)
+ibcs2_waitsys(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_waitsys_args *uap;
+ int *retval;
{
- struct vmspace *vm = p->p_vmspace;
- vm_offset_t new, old;
- int rv, diff;
- extern int swap_pager_full;
-
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'break' dsend=%x\n",
- (unsigned int)args->dsend);
-
- if ((vm_offset_t)args->dsend < (vm_offset_t)vm->vm_daddr)
- return EINVAL;
- if (((caddr_t)args->dsend - (caddr_t)vm->vm_daddr)
- > p->p_rlimit[RLIMIT_DATA].rlim_cur)
- return ENOMEM;
-
- old = round_page((vm_offset_t)vm->vm_daddr) + ctob(vm->vm_dsize);
- new = round_page((vm_offset_t)args->dsend);
-
- diff = new - old;
- if (diff > 0) {
- if (swap_pager_full) {
- return ENOMEM;
- }
- rv = vm_allocate(&vm->vm_map, &old, diff, FALSE);
- if (rv != KERN_SUCCESS) {
- 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)
- return ENOMEM;
- vm->vm_dsize -= btoc(diff);
+ int error, status;
+ struct 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 = 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_chdir(struct proc *p, void *args, int *retval)
+ibcs2_execv(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_execv_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'chdir'\n");
- return chdir(p, args, retval);
+ struct execve_args ea;
+ caddr_t sg = stackgap_init();
+
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ SCARG(&ea, path) = SCARG(uap, path);
+ SCARG(&ea, argp) = SCARG(uap, argp);
+ SCARG(&ea, envp) = NULL;
+ return execve(p, &ea, retval);
}
int
-ibcs2_chmod(struct proc *p, void *args, int *retval)
+ibcs2_execve(p, uap, retval)
+ struct proc *p;
+ struct execve_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'chmod'\n");
- return chmod(p, args, retval);
-}
+ caddr_t sg = stackgap_init();
-int
-ibcs2_chown(struct proc *p, void *args, int *retval)
-{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'chown'\n");
- return chown(p, args, retval);
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ return execve(p, uap, retval);
}
int
-ibcs2_chroot(struct proc *p, void *args, int *retval)
+ibcs2_umount(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_umount_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'chroot'\n");
- return chroot(p, args, retval);
-}
-
-struct ibcs2_close_args {
- int fd;
-};
+ struct unmount_args um;
-int
-ibcs2_close(struct proc *p, struct ibcs2_close_args *args, int *retval)
-{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'close' fd=%d\n", args->fd);
- return close(p, args, retval);
+ SCARG(&um, path) = SCARG(uap, name);
+ SCARG(&um, flags) = 0;
+ return unmount(p, &um, retval);
}
-struct exec_args {
- char *name;
- char **argv;
-};
-
int
-ibcs2_exec(struct proc *p, struct exec_args *args, int *retval)
+ibcs2_mount(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_mount_args *uap;
+ int *retval;
{
- struct execve_args {
- char *name;
- char **argv;
- char **envp;
- } execve_args;
-
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'exec' name=%s\n", args->name);
- execve_args.name = args->name;
- execve_args.argv = args->argv;
- execve_args.envp = 0;
- return execve(p, &execve_args, retval);
+#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 (strcmp(fsname, "4.2") == 0) {
+ SCARG(uap, type) = (caddr_t)STACK_ALLOC();
+ if (error = copyout("ufs", SCARG(uap, type), sizeof("ufs")))
+ return (error);
+ } else if (strcmp(fsname, "nfs") == 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 (mount(p, uap, retval));
+#else
+ return EINVAL;
+#endif
}
-struct ibcs2_exece_args {
- char *name;
- char **argv;
- char **envp;
-};
+/*
+ * 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_exece(struct proc *p, struct ibcs2_exece_args *args, int *retval)
+ibcs2_getdents(p, uap, retval)
+ struct proc *p;
+ register struct ibcs2_getdents_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'exece' name=%s\n", args->name);
- return execve(p, args, retval);
+ 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_dirent idb;
+ off_t off; /* true file offset */
+ int buflen, error, eofflag;
+#define BSD_DIRENT(cp) ((struct direct *)(cp))
+#define IBCS2_RECLEN(reclen) (reclen + sizeof(u_short))
+
+ 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);
+ 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, (u_long *)0,
+ 0))
+ goto out;
+ inp = buf;
+ outp = SCARG(uap, buf);
+ resid = SCARG(uap, nbytes);
+ if ((len = buflen - auio.uio_resid) == 0)
+ goto eof;
+ for (; len > 0; len -= reclen) {
+ reclen = BSD_DIRENT(inp)->d_reclen;
+ if (reclen & 3)
+ panic("ibcs2_getdents");
+ off += reclen; /* each entry points to next */
+ if (BSD_DIRENT(inp)->d_ino == 0) {
+ inp += reclen; /* it is a hole; squish it out */
+ continue;
+ }
+ if (reclen > len || resid < IBCS2_RECLEN(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)BSD_DIRENT(inp)->d_ino;
+ idb.d_off = (ibcs2_off_t)off;
+ idb.d_reclen = (u_short)IBCS2_RECLEN(reclen);
+ if ((error = copyout((caddr_t)&idb, outp, 10)) != 0 ||
+ (error = copyout(BSD_DIRENT(inp)->d_name, outp + 10,
+ BSD_DIRENT(inp)->d_namlen + 1)) != 0)
+ goto out;
+ /* advance past this real entry */
+ inp += reclen;
+ /* advance output past iBCS2-shaped entry */
+ outp += IBCS2_RECLEN(reclen);
+ resid -= IBCS2_RECLEN(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(buf, M_TEMP);
+ return (error);
}
int
-ibcs2_exit(struct proc *p, void *args, int *retval)
+ibcs2_read(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_read_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'exit'\n");
- return exit(p, args, retval);
+ 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;
+
+ if (error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) {
+ if (error == EINVAL)
+ return 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 read(p, uap, retval);
+ DPRINTF(("ibcs2_read: read directory\n"));
+ buflen = max(MAXBSIZE, SCARG(uap, nbytes));
+ buf = malloc(buflen, 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 & ~(DIRBLKSIZ - 1);
+ /*
+ * 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,
+ (u_long *)0, 0)) {
+ DPRINTF(("VOP_READDIR failed: %d\n", error));
+ goto out;
+ }
+ inp = buf + (off & (DIRBLKSIZ - 1));
+ buflen -= off & (DIRBLKSIZ - 1);
+ outp = SCARG(uap, buf);
+ resid = SCARG(uap, nbytes);
+ if ((len = buflen - auio.uio_resid) == 0)
+ goto eof;
+ for (; len > 0 && resid > 0; len -= reclen) {
+ reclen = BSD_DIRENT(inp)->d_reclen;
+ if (reclen & 3)
+ panic("ibcs2_read");
+ if (BSD_DIRENT(inp)->d_ino == 0) {
+ inp += reclen; /* it is a hole; squish it out */
+ off += reclen;
+ 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 = (BSD_DIRENT(inp)->d_ino > 0xfffe) ? 0xfffe :
+ BSD_DIRENT(inp)->d_ino;
+ (void)copystr(BSD_DIRENT(inp)->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 += reclen;
+ 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_fork(struct proc *p, void *args, int *retval)
+ibcs2_mknod(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_mknod_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'fork'\n");
- return fork(p, args, retval);
+ caddr_t sg = stackgap_init();
+
+ CHECKALTCREAT(p, &sg, SCARG(uap, path));
+ if (S_ISFIFO(SCARG(uap, mode))) {
+ struct mkfifo_args ap;
+ SCARG(&ap, path) = SCARG(uap, path);
+ SCARG(&ap, mode) = SCARG(uap, mode);
+ return mkfifo(p, uap, retval);
+ } else {
+ struct mknod_args ap;
+ SCARG(&ap, path) = SCARG(uap, path);
+ SCARG(&ap, mode) = SCARG(uap, mode);
+ SCARG(&ap, dev) = SCARG(uap, dev);
+ return mknod(p, &ap, retval);
+ }
}
int
-ibcs2_fsync(struct proc *p, void *args, int *retval)
+ibcs2_getgroups(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_getgroups_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'fsync'\n");
- return fsync(p, args, retval);
+ int error, i;
+ ibcs2_gid_t igid, *iset;
+ struct getgroups_args sa;
+ gid_t *gp;
+ caddr_t sg = stackgap_init();
+
+ 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 = 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_getgid(struct proc *p, void *args, int *retval)
+ibcs2_setgroups(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_setgroups_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'getgid'\n");
- return getgid(p, args, retval);
+ int error, i;
+ ibcs2_gid_t igid, *iset;
+ struct setgroups_args sa;
+ gid_t *gp;
+ caddr_t sg = stackgap_init();
+
+ 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 setgroups(p, &sa, retval);
}
-struct ibcs2_getgroups_args {
- int gidsetsize;
- ibcs2_gid_t *gidset;
-};
-
int
-ibcs2_getgroups(struct proc *p, struct ibcs2_getgroups_args *args, int *retval)
+ibcs2_setuid(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_setuid_args *uap;
+ int *retval;
{
- struct getgroups_args {
- u_int gidsetsize;
- gid_t *gidset;
- } tmp;
- ibcs2_gid_t *ibcs2_gidset;
- int i, error;
-
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'getgroups'\n");
+ struct setuid_args sa;
- tmp.gidsetsize = args->gidsetsize;
- tmp.gidset = (gid_t *)UA_ALLOC();
- ibcs2_gidset = (ibcs2_gid_t *)&tmp.gidset[NGROUPS_MAX];
- if (error = getgroups(p, &tmp, retval))
- return error;
- for (i = 0; i < retval[0]; i++)
- ibcs2_gidset[i] = (ibcs2_gid_t)tmp.gidset[i];
- return copyout((caddr_t)ibcs2_gidset, (caddr_t)args->gidset,
- sizeof(ibcs2_gid_t) * retval[0]);
+ SCARG(&sa, uid) = (uid_t)SCARG(uap, uid);
+ return setuid(p, &sa, retval);
}
int
-ibcs2_getpid(struct proc *p, void *args, int *retval)
+ibcs2_setgid(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_setgid_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'getpid'\n");
- return getpid(p, args, retval);
+ struct setgid_args sa;
+
+ SCARG(&sa, gid) = (gid_t)SCARG(uap, gid);
+ return setgid(p, &sa, retval);
}
int
-ibcs2_getuid(struct proc *p, void *args, int *retval)
+xenix_ftime(p, uap, retval)
+ struct proc *p;
+ struct xenix_ftime_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'getuid'\n");
- return getuid(p, args, retval);
-}
+ struct timeval tv;
+ extern struct timezone tz;
+ struct xenix_timeb itb;
-struct gtime_args {
- long *timeptr;
-};
+ 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_gtime(struct proc *p, struct gtime_args *args, int *retval)
+ibcs2_time(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_time_args *uap;
+ int *retval;
{
- int error = 0;
struct timeval tv;
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'gtime'\n");
microtime(&tv);
*retval = tv.tv_sec;
- if (args)
- (long)args->timeptr = tv.tv_sec;
- return error;
+ 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_link(struct proc *p, void *args, int *retval)
+ibcs2_pathconf(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_pathconf_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'link'\n");
- return link(p, args, retval);
+ SCARG(uap, name)++; /* iBCS2 _PC_* defines are offset by one */
+ return pathconf(p, uap, retval);
}
int
-ibcs2_mkdir(struct proc *p, void *args, int *retval)
+ibcs2_fpathconf(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_fpathconf_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'mkdir'\n");
- return mkdir(p, args, retval);
+ SCARG(uap, name)++; /* iBCS2 _PC_* defines are offset by one */
+ return fpathconf(p, uap, retval);
}
-struct ibcs2_mknod_args {
- char *fname;
- int fmode;
- ibcs2_dev_t dev;
-};
-
int
-ibcs2_mknod(struct proc *p, struct ibcs2_mknod_args *args, int *retval)
+ibcs2_sysconf(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_sysconf_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'mknod'\n");
- if (S_ISFIFO(args->fmode))
- return mkfifo(p, args, retval);
- return mknod(p, args, retval);
-}
+ int mib[2], value, len, error;
+ struct __sysctl_args sa;
+ struct 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();
+
+ SCARG(&ga, which) = RLIMIT_NPROC;
+ SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit *));
+ if (error = getrlimit(p, &ga, retval))
+ return error;
+ *retval = SCARG(&ga, rlp)->rlim_cur;
+ return 0;
+ }
-struct ibcs2_nice_args {
- int niceval;
-};
+ case IBCS2_SC_CLK_TCK:
+ *retval = hz;
+ return 0;
-int
-ibcs2_nice(struct proc *p, struct ibcs2_nice_args *args, int *retval)
-{
- int error;
+ case IBCS2_SC_NGROUPS_MAX:
+ mib[1] = KERN_NGROUPS;
+ break;
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'nice'\n");
- error = donice(p, p, args->niceval);
- *retval = p->p_nice;
- return error;
-}
+ case IBCS2_SC_OPEN_MAX:
+ {
+ caddr_t sg = stackgap_init();
-struct ibcs2_pathconf_args {
- long unused;
- int cmd;
-};
-int
-ibcs2_pathconf(struct proc *p, struct ibcs2_pathconf_args *args, int *retval)
-{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: '(f)pathconf'\n");
- switch (args->cmd) {
- case 0: /* _PC_LINK_MAX */
- *retval = (LINK_MAX);
- break;
- case 1: /* _PC_MAX_CANON */
- *retval = (MAX_CANON);
- break;
- case 2: /* _PC_MAX_INPUT */
- *retval = (MAX_INPUT);
- break;
- case 5: /* _PC_PATH_MAX */
- *retval = (PATH_MAX);
- break;
- case 8: /* _PC_VDISABLE */
- *retval = (_POSIX_VDISABLE);
- break;
- case 3: /* _PC_NAME_MAX */
- *retval = (NAME_MAX);
- break;
- case 4: /* _PC_PATH_MAX */
- *retval = (PATH_MAX);
- break;
- case 6: /* _PC_CHOWN_RESTRICTED */
-#ifdef _POSIX_CHOWN_RESTRICTED
- *retval = _POSIX_CHOWN_RESTRICTED;
-#else
- *retval = (0);
-#endif
- break;
- case 7: /* _PC_NO_TRUNC */
-#ifdef _POSIX_NO_TRUNC
- *retval = _POSIX_NO_TRUNC;
-#else
- *retval = (1);
-#endif
- break;
- default:
- *retval = -1;
- return EINVAL;
- }
- return 0;
-}
+ SCARG(&ga, which) = RLIMIT_NOFILE;
+ SCARG(&ga, rlp) = stackgap_alloc(&sg, sizeof(struct rlimit *));
+ if (error = 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;
-int
-ibcs2_pause(struct proc *p, void *args, int *retval)
-{
- int mask = 0;
+ case IBCS2_SC_XOPEN_VERSION:
+ *retval = 2; /* XXX: What should that be? */
+ return 0;
+
+ default:
+ return EINVAL;
+ }
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'pause'\n");
- return sigsuspend(p, &mask, retval);
+ 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 = __sysctl(p, &sa, retval))
+ return error;
+ *retval = value;
+ return 0;
}
int
-ibcs2_pipe(struct proc *p, void *args, int *retval)
+ibcs2_alarm(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_alarm_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'pipe'\n");
- return pipe(p, args, retval);
+ int error;
+ struct itimerval *itp, *oitp;
+ struct setitimer_args sa;
+ caddr_t sg = stackgap_init();
+
+ 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 = 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;
}
-struct ibcs2_poll {
- int fd;
- short events;
- short revents;
-};
-
-struct ibcs2_poll_args {
- struct ibcs2_poll *fds;
- unsigned long nfds;
- int timeout;
-};
-
int
-ibcs2_poll(struct proc *p, struct ibcs2_poll_args *args, int *retval)
+ibcs2_getmsg(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_getmsg_args *uap;
+ int *retval;
{
- struct ibcs2_poll conv;
- fd_set *readfds, *writefds, *exceptfds;
- struct timeval *timeout;
- struct select_args {
- u_int nd;
- fd_set *in, *ou, *ex;
- struct timeval *tv;
- } tmp_select;
- int i, error;
-
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'poll'\n");
- if (args->nfds > FD_SETSIZE)
- return EINVAL;
- readfds = (fd_set *)UA_ALLOC();
- FD_ZERO(readfds);
- writefds = (fd_set *)UA_ALLOC() + sizeof(fd_set *);
- FD_ZERO(writefds);
- exceptfds = (fd_set *)UA_ALLOC() + 2*sizeof(fd_set *);
- FD_ZERO(exceptfds);
- timeout = (struct timeval *)UA_ALLOC() + 3*sizeof(fd_set *);
- if (args->timeout == -1)
- timeout = NULL;
- else {
- timeout->tv_usec = (args->timeout % 1000)*1000;
- timeout->tv_sec = args->timeout / 1000;
- }
- tmp_select.nd = 0;
- tmp_select.in = readfds;
- tmp_select.ou = writefds;
- tmp_select.ex = exceptfds;
- tmp_select.tv = timeout;
- for (i = 0; i < args->nfds; i++) {
- if (error = copyin(args->fds + i*sizeof(struct ibcs2_poll),
- &conv, sizeof(conv)))
- return error;
- conv.revents = 0;
- if (conv.fd < 0 || conv.fd > FD_SETSIZE)
- continue;
- if (conv.fd >= tmp_select.nd)
- tmp_select.nd = conv.fd + 1;
- if (conv.events & IBCS2_READPOLL)
- FD_SET(conv.fd, readfds);
- if (conv.events & IBCS2_WRITEPOLL)
- FD_SET(conv.fd, writefds);
- FD_SET(conv.fd, exceptfds);
- }
- if (error = select(p, &tmp_select, retval))
- return error;
- if (*retval == 0)
- return 0;
- *retval = 0;
- for (*retval = 0, i = 0; i < args->nfds; i++) {
- copyin(args->fds + i*sizeof(struct ibcs2_poll),
- &conv, sizeof(conv));
- conv.revents = 0;
- if (conv.fd < 0 || conv.fd > FD_SETSIZE)
- /* should check for open as well */
- conv.revents |= IBCS2_POLLNVAL;
- else {
- if (FD_ISSET(conv.fd, readfds))
- conv.revents |= IBCS2_POLLIN;
- if (FD_ISSET(conv.fd, writefds))
- conv.revents |= IBCS2_POLLOUT;
- if (FD_ISSET(conv.fd, exceptfds))
- conv.revents |= IBCS2_POLLERR;
- if (conv.revents)
- ++*retval;
- }
- if (error = copyout(&conv,
- args->fds + i*sizeof(struct ibcs2_poll),
- sizeof(conv)))
- return error;
- }
return 0;
}
-struct ibcs2_procids_args {
- int req;
- int eax;
-};
-
int
-ibcs2_procids(struct proc *p, struct ibcs2_procids_args *args, int *retval)
+ibcs2_putmsg(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_putmsg_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'procids' request=%d, eax=%x\n",
- args->req, args->eax);
- switch (args->req) {
- case 0: /* getpgrp */
- return getpgrp(p, args, retval);
- case 1: /* setpgrp */
- {
- struct setpgid_args {
- int pid;
- int pgid;
- } tmp;
- tmp.pid = tmp.pgid = 0;
- return setpgid(p, &tmp, retval);
- }
- case 2: /* setpgid */
- return setpgid(p, args, retval);
- case 3: /* setsid */
- return setsid(p, args, retval);
- default:
- return EINVAL;
- }
+ return 0;
}
int
-ibcs2_profil(struct proc *p, void *args, int *retval)
+ibcs2_times(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_times_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'profil'\n");
- return profil(p, args, retval);
-}
+ int error;
+ struct getrusage_args ga;
+ struct tms tms;
+ struct timeval t;
+ caddr_t sg = stackgap_init();
+ 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 = 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 = getrusage(p, &ga, retval);
+ if (error)
+ return error;
+ tms.tms_cutime = CONVTCK(ru->ru_utime);
+ tms.tms_cstime = CONVTCK(ru->ru_stime);
-int
-ibcs2_ptrace(struct proc *p, void *args, int *retval)
-{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'ptrace'\n");
- return ptrace(p, args, retval);
+ microtime(&t);
+ *retval = CONVTCK(t);
+
+ return copyout((caddr_t)&tms, (caddr_t)SCARG(uap, tp),
+ sizeof(struct tms));
}
int
-ibcs2_readlink(struct proc *p, void *args, int *retval)
+ibcs2_stime(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_stime_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'readlink'\n");
- return readlink(p, args, retval);
+ int error;
+ struct settimeofday_args sa;
+ caddr_t sg = stackgap_init();
+
+ 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 = settimeofday(p, &sa, retval))
+ return EPERM;
+ return 0;
}
int
-ibcs2_rename(struct proc *p, void *args, int *retval)
+ibcs2_utime(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_utime_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'rename'\n");
- return rename(p, args, retval);
+ int error;
+ struct utimes_args sa;
+ struct timeval *tp;
+ caddr_t sg = stackgap_init();
+
+ CHECKALTEXIST(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 utimes(p, &sa, retval);
}
int
-ibcs2_rmdir(struct proc *p, void *args, int *retval)
+ibcs2_nice(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_nice_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'rmdir'\n");
- return rmdir(p, args, retval);
+ int error, cur_nice = p->p_nice;
+ struct setpriority_args sa;
+
+ SCARG(&sa, which) = PRIO_PROCESS;
+ SCARG(&sa, who) = 0;
+ SCARG(&sa, prio) = p->p_nice + SCARG(uap, incr);
+ if (error = setpriority(p, &sa, retval))
+ return EPERM;
+ *retval = p->p_nice;
+ return 0;
}
-struct ibcs2_secure_args {
- int cmd;
- int arg1;
- int arg2;
- int arg3;
- int arg4;
- int arg5;
-};
+/*
+ * iBCS2 getpgrp, setpgrp, setsid, and setpgid
+ */
int
-ibcs2_secure(struct proc *p, struct ibcs2_secure_args *args, int *retval)
+ibcs2_pgrpsys(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_pgrpsys_args *uap;
+ int *retval;
{
- struct trapframe *tf = (struct trapframe *)p->p_md.md_regs;
+ switch (SCARG(uap, type)) {
+ case 0: /* getpgrp */
+ *retval = p->p_pgrp->pg_id;
+ return 0;
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'secure'\n");
+ case 1: /* setpgrp */
+ {
+ struct setpgid_args sa;
- switch (args->cmd) {
+ SCARG(&sa, pid) = 0;
+ SCARG(&sa, pgid) = 0;
+ setpgid(p, &sa, retval);
+ *retval = p->p_pgrp->pg_id;
+ return 0;
+ }
- case 1: /* get login uid */
- *retval = p->p_ucred->cr_uid;
- return EPERM;
+ case 2: /* setpgid */
+ {
+ struct setpgid_args sa;
- case 2: /* set login uid */
+ SCARG(&sa, pid) = SCARG(uap, pid);
+ SCARG(&sa, pgid) = SCARG(uap, pgid);
+ return setpgid(p, &sa, retval);
+ }
+
+ case 3: /* setsid */
+ return setsid(p, NULL, retval);
default:
- printf("IBCS2: 'secure' cmd=%d not implemented\n",args->cmd);
+ return EINVAL;
}
- return EINVAL;
}
-struct ibcs2_setgid_args {
- ibcs2_gid_t gid;
-};
+/*
+ * XXX - need to check for nested calls
+ */
int
-ibcs2_setgid(struct proc *p, struct ibcs2_setgid_args *args, int *retval)
+ibcs2_plock(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_plock_args *uap;
+ int *retval;
{
- struct setgid_args {
- gid_t gid;
- } tmp;
+ int error;
+#define IBCS2_UNLOCK 0
+#define IBCS2_PROCLOCK 1
+#define IBCS2_TEXTLOCK 2
+#define IBCS2_DATALOCK 4
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'setgid'\n");
- tmp.gid = (gid_t) args->gid;
- return setgid(p, &tmp, retval);
+
+ 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;
}
-struct ibcs2_setgroups_args {
- int gidsetsize;
- ibcs2_gid_t *gidset;
-};
-
int
-ibcs2_setgroups(struct proc *p, struct ibcs2_setgroups_args *args, int *retval)
+ibcs2_uadmin(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_uadmin_args *uap;
+ int *retval;
{
- struct setgroups_args {
- u_int gidsetsize;
- gid_t *gidset;
- } tmp;
- ibcs2_gid_t *ibcs2_gidset;
- int i, error;
-
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'setgroups'\n");
- tmp.gidsetsize = args->gidsetsize;
- tmp.gidset = (gid_t *)UA_ALLOC();
- ibcs2_gidset = (ibcs2_gid_t *)&tmp.gidset[NGROUPS_MAX];
- if (error = copyin((caddr_t)args->gidset, (caddr_t)ibcs2_gidset,
- sizeof(ibcs2_gid_t) * tmp.gidsetsize))
- return error;
- for (i = 0; i < tmp.gidsetsize; i++)
- tmp.gidset[i] = (gid_t)ibcs2_gidset[i];
- return setgroups(p, &tmp, retval);
+#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
+
+ 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:
+ reboot(RB_HALT);
+ case SCO_AD_BOOT:
+ case SCO_AD_IBOOT:
+ reboot(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;
}
-struct ibcs2_setuid_args {
- ibcs2_uid_t uid;
-};
-
int
-ibcs2_setuid(struct proc *p, struct ibcs2_setuid_args *args, int *retval)
+ibcs2_sysfs(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_sysfs_args *uap;
+ int *retval;
{
- struct setuid_args {
- uid_t uid;
- } tmp;
-
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'setuid'\n");
- tmp.uid = (uid_t) args->uid;
- return setuid(p, &tmp, retval);
+#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_smount(struct proc *p, void *args, int *retval)
+ibcs2_poll(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_poll_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'smount'\n");
- return mount(p, args, retval);
+ return EINVAL; /* XXX - TODO */
}
-struct ibcs2_stime_args {
- long *timeptr;
-};
-
int
-ibcs2_stime(struct proc *p, struct ibcs2_stime_args *args, int *retval)
+xenix_rdchk(p, uap, retval)
+ struct proc *p;
+ struct xenix_rdchk_args *uap;
+ int *retval;
{
int error;
-
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'stime'\n");
- if (error = suser(p->p_ucred, &p->p_acflag))
+ struct ioctl_args sa;
+ caddr_t sg = stackgap_init();
+
+ SCARG(&sa, fd) = SCARG(uap, fd);
+ SCARG(&sa, com) = FIONREAD;
+ SCARG(&sa, data) = stackgap_alloc(&sg, sizeof(int));
+ if (error = ioctl(p, &sa, retval))
return error;
- if (args->timeptr) {
-#if 0
- /* WHAT DO WE DO ABOUT PENDING REAL-TIME TIMEOUTS??? */
- boottime.tv_sec += (long)args->timeptr - time.tv_sec;
- s = splhigh();
- time.tv_sec = (long)args->timeptr;
- time.tv_usec = 0;
- splx(s);
- resettodr();
-#else
- printf("IBCS2: trying to set system time %d\n",
- (long)args->timeptr);
-#endif
- }
+ *retval = (*((int*)SCARG(&sa, data))) ? 1 : 0;
return 0;
}
int
-ibcs2_sumount(struct proc *p, void *args, int *retval)
+xenix_chsize(p, uap, retval)
+ struct proc *p;
+ struct xenix_chsize_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'sumount'\n");
- return unmount(p, args, retval);
+ struct ftruncate_args sa;
+
+ SCARG(&sa, fd) = SCARG(uap, fd);
+ SCARG(&sa, pad) = 0;
+ SCARG(&sa, length) = SCARG(uap, size);
+ return ftruncate(p, &sa, retval);
}
int
-ibcs2_symlink(struct proc *p, void *args, int *retval)
+xenix_nap(p, uap, retval)
+ struct proc *p;
+ struct xenix_nap_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'symlink'\n");
- return symlink(p, args, retval);
+ return ENOSYS;
}
int
-ibcs2_sync(struct proc *p, void *args, int *retval)
+ibcs2_unlink(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_unlink_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'sync'\n");
- return sync(p, args, retval);
+ caddr_t sg = stackgap_init();
+
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ return unlink(p, uap, retval);
}
int
-ibcs2_sysacct(struct proc *p, void *args, int *retval)
+ibcs2_chdir(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_chdir_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'sysacct'\n");
- return acct(p, args, retval);
-}
+ caddr_t sg = stackgap_init();
-struct ibcs2_tms {
- long tms_utime;
- long tms_stime;
- long tms_cutime;
- long tms_cstime;
-};
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ return chdir(p, uap, retval);
+}
int
-ibcs2_times(struct proc *p, struct ibcs2_tms *args, int *retval)
+ibcs2_chmod(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_chmod_args *uap;
+ int *retval;
{
- extern int hz;
- struct timeval tv;
- struct ibcs2_tms tms;
-
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'times'\n");
- tms.tms_utime = p->p_uticks;
- tms.tms_stime = p->p_sticks;
- tms.tms_cutime = p->p_stats->p_cru.ru_utime.tv_sec * hz +
- ((p->p_stats->p_cru.ru_utime.tv_usec * hz)/1000000);
- tms.tms_cstime = p->p_stats->p_cru.ru_stime.tv_sec * hz +
- ((p->p_stats->p_cru.ru_stime.tv_usec * hz)/1000000);
- microtime(&tv);
- *retval = tv.tv_sec * hz + (tv.tv_usec * hz)/1000000;
- return (copyout((caddr_t)&tms,
- (caddr_t)args->tms_utime,
- sizeof(struct ibcs2_tms)));
-}
+ caddr_t sg = stackgap_init();
-struct ibcs2_ulimit_args {
- int cmd;
- long limit;
-};
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ return chmod(p, uap, retval);
+}
int
-ibcs2_ulimit(struct proc *p, struct ibcs2_ulimit_args *args, int *retval)
+ibcs2_chown(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_chown_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'ulimit'\n");
- switch (args->cmd) {
- case IBCS2_GETFSIZE:
- *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur;
- return 0;
-
- case IBCS2_SETFSIZE:
- return EINVAL;
+ caddr_t sg = stackgap_init();
- case IBCS2_GETPSIZE:
- *retval = p->p_rlimit[RLIMIT_RSS].rlim_cur;
- return 0;
- case IBCS2_GETMOPEN:
- *retval = p->p_rlimit[RLIMIT_NOFILE].rlim_cur;
- return 0;
- }
- return EINVAL;
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ return chown(p, uap, retval);
}
int
-ibcs2_umask(struct proc *p, void *args, int *retval)
+ibcs2_rmdir(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_rmdir_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'umask'\n");
- return umask(p, args, retval);
+ caddr_t sg = stackgap_init();
+
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ return rmdir(p, uap, retval);
}
int
-ibcs2_unlink(struct proc *p, void *args, int *retval)
+ibcs2_mkdir(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_mkdir_args *uap;
+ int *retval;
{
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'unlink'\n");
- return unlink(p, args, retval);
-}
+ caddr_t sg = stackgap_init();
-struct ibcs2_utime_args {
- char *fname;
- ibcs2_time_t *timeptr;
-};
+ CHECKALTCREAT(p, &sg, SCARG(uap, path));
+ return mkdir(p, uap, retval);
+}
int
-ibcs2_utime(struct proc *p, struct ibcs2_utime_args *args, int *retval)
+ibcs2_symlink(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_symlink_args *uap;
+ int *retval;
{
- struct bsd_utimes_args {
- char *fname;
- struct timeval *tptr;
- } bsdutimes;
- struct timeval tv;
+ caddr_t sg = stackgap_init();
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'utime'\n");
- tv.tv_sec = (long)args->timeptr;
- tv.tv_usec = 0;
- bsdutimes.tptr = &tv;
- bsdutimes.fname = args->fname;
- return utimes(p, &bsdutimes, retval);
-}
-
-struct ibcs2_utssys_args {
- char *buf;
- int mv;
- int cmd;
-};
-
-int
-ibcs2_utssys(struct proc *p, struct ibcs2_utssys_args *args, int *retval)
-{
- struct ibcs2_utsname {
- char sysname[9];
- char nodename[9];
- char release[9];
- char version[9];
- char machine[9];
- } ibcs2_uname;
- extern char ostype[], hostname[], osrelease[], machine[];
-
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'utssys' cmd=%d\n", args->cmd);
- switch(args->cmd) {
- case 0: /* uname */
- bzero(&ibcs2_uname, sizeof(struct ibcs2_utsname));
- strncpy(ibcs2_uname.sysname, ostype, 8);
- strncpy(ibcs2_uname.nodename, hostname, 8);
- strncpy(ibcs2_uname.release, osrelease, 8);
- strncpy(ibcs2_uname.version, version, 8);
- strncpy(ibcs2_uname.machine, machine, 8);
- return (copyout((caddr_t)&ibcs2_uname,
- (caddr_t)args->buf,
- sizeof(struct ibcs2_utsname)));
-
- case 2: /* ustat */
- printf("IBCS2: utssys(ustat) not implemented yet\n");
- return EINVAL;
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ CHECKALTCREAT(p, &sg, SCARG(uap, link));
+ return symlink(p, uap, retval);
+}
- case 1: /* umask, obsolete */
- default:
- printf("IBCS2: 'utssys cmd (%d) not implemented yet'\n",
- args->cmd);
- return EINVAL;
- }
+int
+ibcs2_rename(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_rename_args *uap;
+ int *retval;
+{
+ caddr_t sg = stackgap_init();
+
+ CHECKALTEXIST(p, &sg, SCARG(uap, from));
+ CHECKALTCREAT(p, &sg, SCARG(uap, to));
+ return rename(p, uap, retval);
}
int
-ibcs2_wait(struct proc *p, void *args, int *retval)
-{
- struct trapframe *tf = (struct trapframe *)p->p_md.md_regs;
- struct ibcs2_waitpid_args {
- int pid;
- int *status;
- int options;
- } *t = args;
- struct wait4_args {
- int pid;
- int *status;
- int options;
- struct rusage *rusage;
- int compat;
- } tmp;
-
- tmp.compat = 1;
- tmp.rusage = 0;
- if (ibcs2_trace & IBCS2_TRACE_MISC)
- printf("IBCS2: 'wait'\n");
-
- if ((tf->tf_eflags & (PSL_Z|PSL_PF|PSL_N|PSL_V))
- == (PSL_Z|PSL_PF|PSL_N|PSL_V)) {
- tmp.pid = t->pid;
- tmp.status = t->status;
- tmp.options = 0;
- if (t->options & 02)
- tmp.options |= WUNTRACED;
- if (t->options & 01)
- tmp.options |= WNOHANG;
- tmp.options = t->options;
- } else {
- tmp.pid = WAIT_ANY;
- tmp.status = (int*)t->pid;
- tmp.options = 0;
- }
- return wait1(p, &tmp, retval);
+ibcs2_readlink(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_readlink_args *uap;
+ int *retval;
+{
+ caddr_t sg = stackgap_init();
+
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ return readlink(p, uap, retval);
}
diff --git a/sys/i386/ibcs2/ibcs2_mount.h b/sys/i386/ibcs2/ibcs2_mount.h
new file mode 100644
index 0000000..d1b9aaa
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_signal.c b/sys/i386/ibcs2/ibcs2_signal.c
index 7824a0b..ba768b0 100644
--- a/sys/i386/ibcs2/ibcs2_signal.c
+++ b/sys/i386/ibcs2/ibcs2_signal.c
@@ -1,462 +1,492 @@
-/*-
- * Copyright (c) 1994 Sean Eric Fagan
- * Copyright (c) 1994 Søren Schmidt
- * All rights reserved.
- *
- * Copyright (c) 1982, 1986, 1989, 1991 Regents of the University of California.
+/* $NetBSD: ibcs2_signal.c,v 1.6 1995/09/19 22:19:07 thorpej 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
- * in this position and unchanged.
+ * 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.
+ * 3. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
*
- * $Id: ibcs2_signal.c,v 1.9 1994/10/12 19:38:03 sos Exp $
+ * 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 <i386/ibcs2/ibcs2.h>
-#include <sys/ioctl.h>
-#include <sys/ioctl_compat.h>
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/fcntl.h>
-#include <sys/file.h>
-#include <sys/filedesc.h>
#include <sys/namei.h>
-#include <sys/mount.h>
#include <sys/proc.h>
-#include <sys/resource.h>
-#include <sys/resourcevar.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/stat.h>
-#include <sys/tty.h>
-#include <sys/termios.h>
-#include <sys/time.h>
-#include <sys/times.h>
-#include <sys/vnode.h>
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/vm_map.h>
-#include <vm/vm_kern.h>
-
-
-#define DONTMASK (sigmask(SIGKILL)|sigmask(SIGSTOP)|sigmask(SIGCHLD))
-
-int bsd_to_ibcs2_signal[NSIG] = {
- 0, IBCS2_SIGHUP, IBCS2_SIGINT, IBCS2_SIGQUIT,
- IBCS2_SIGILL, IBCS2_SIGTRAP, IBCS2_SIGABRT, IBCS2_SIGEMT,
- IBCS2_SIGFPE, IBCS2_SIGKILL, IBCS2_SIGBUS, IBCS2_SIGSEGV,
- IBCS2_SIGSYS, IBCS2_SIGPIPE, IBCS2_SIGALRM, IBCS2_SIGTERM,
- IBCS2_SIGURG, IBCS2_SIGSTOP, IBCS2_SIGTSTP, IBCS2_SIGCONT,
- IBCS2_SIGCHLD, IBCS2_SIGTTIN, IBCS2_SIGTTOU, IBCS2_SIGIO,
- IBCS2_SIGGXCPU, IBCS2_SIGGXFSZ, IBCS2_SIGVTALRM, IBCS2_SIGPROF,
- IBCS2_SIGWINCH, 0, IBCS2_SIGUSR1, IBCS2_SIGUSR2
+#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_signal[IBCS2_NSIG] = {
- 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
+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 */
};
-static char ibcs2_sig_name[IBCS2_NSIG][10] = {
- "UNKNOWN", "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP",
- "SIGABRT", "SIGEMT", "SIGFPE", "SIGKILL", "SIGBUS", "SIGSEGV",
- "SIGSYS", "SIGPIPE", "SIGALRM", "SIGTERM", "SIGUSR1", "SIGUSR2",
- "SIGCHLD", "SIGPWR", "SIGWINCH", "SIGURG", "SIGIO", "SIGSTOP",
- "SIGTSTP", "SIGCONT", "SIGTTIN", "SIGTTOU", "SIGVTALRM",
- "SIGPROF", "SIGXCPU", "SIGXFSZ"
-};
-
-/*#define LEGAL_SIG(x) \
- (((x & IBCS2_SIGMASK) < IBCS2_NSIG) ? (x & IBCS2_SIGMASK) : (0))*/
-int
-LEGAL_SIG(int sig)
+void
+ibcs2_to_bsd_sigset(iss, bss)
+ const ibcs2_sigset_t *iss;
+ sigset_t *bss;
{
- if ((sig & IBCS2_SIGMASK) > IBCS2_NSIG) {
- printf("IBCS2: illegal ibcs2 signal %d(%08x)\n",
- sig & IBCS2_SIGMASK, sig);
- return 0;
+ 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);
+ }
}
- else
- return (sig & IBCS2_SIGMASK);
}
-char *
-ibcs2_sig_to_str(int sig)
+void
+bsd_to_ibcs2_sigset(bss, iss)
+ const sigset_t *bss;
+ ibcs2_sigset_t *iss;
{
- if (sig > IBCS2_NSIG) {
- printf("IBCS2: ibcs2 signal out of range (%d)\n", sig);
- return ibcs2_sig_name[0];
- }
- else
- return ibcs2_sig_name[sig];
-}
-
-static sig_t
-ibcs2_to_bsd_sigfunc(ibcs2_sig_t func) {
- switch ((int)func) {
- case IBCS2_SIG_DFL:
- return SIG_DFL;
- case IBCS2_SIG_IGN:
- return SIG_IGN;
- case IBCS2_SIG_HOLD:
- return SIG_HOLD;
- default:
- return func;
- }
-}
-
-static ibcs2_sig_t
-bsd_to_ibcs2_sigfunc(sig_t func) {
- switch ((int)func) {
- case SIG_DFL:
- return IBCS2_SIG_DFL;
- case SIG_IGN:
- return IBCS2_SIG_IGN;
- case SIG_CATCH:
- printf("IBCS2: Oops - SIG_CATCH does not translate :-(\n");
- return IBCS2_SIG_DFL;
- case SIG_HOLD:
- return IBCS2_SIG_HOLD;
- default:
- return func;
+ 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);
+ }
}
}
-static sigset_t
-ibcs2_to_bsd_sigmask(ibcs2_sigset_t mask) {
- int i;
- sigset_t new = 0;
+void
+ibcs2_to_bsd_sigaction(isa, bsa)
+ struct ibcs2_sigaction *isa;
+ struct sigaction *bsa;
+{
- for (i = 1; i < NSIG; i++)
- if (mask & (1 << i-1))
- new |= (1 << (ibcs2_to_bsd_signal[i]-1));
- return new;
+ 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;
}
-static ibcs2_sigset_t
-bsd_to_ibcs2_sigmask(sigset_t mask) {
- int i;
- sigset_t new = 0;
+void
+bsd_to_ibcs2_sigaction(bsa, isa)
+ struct sigaction *bsa;
+ struct ibcs2_sigaction *isa;
+{
- for (i = 1; i < IBCS2_NSIG; i++)
- if (mask & (1 << i-1))
- new |= (1 << (bsd_to_ibcs2_signal[i]-1));
- return new;
+ 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;
}
-struct ibcs2_signal_args {
- int signo;
- ibcs2_sig_t func;
-};
-
-static int
-ibcs2_sigset(struct proc *p, struct ibcs2_signal_args *args, int *retval)
+int
+ibcs2_sigaction(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
{
- struct sigaction tmp;
- int sig_bsd = ibcs2_to_bsd_signal[LEGAL_SIG(args->signo)];
-
- *retval = (int)bsd_to_ibcs2_sigfunc(p->p_sigacts->ps_sigact[sig_bsd]);
- if (args->func == IBCS2_SIG_HOLD) {
- (void) splhigh();
- p->p_sigmask |= (sigmask(sig_bsd) &~ DONTMASK);
- (void) spl0();
- }
- else {
- tmp.sa_mask = sigmask(sig_bsd);
- tmp.sa_handler = ibcs2_to_bsd_sigfunc(args->func);
- tmp.sa_flags = 0;
- setsigvec(p, sig_bsd, &tmp);
- }
- return 0;
-}
+ struct ibcs2_sigaction_args /* {
+ syscallarg(int) sig;
+ syscallarg(struct ibcs2_sigaction *) act;
+ syscallarg(struct ibcs2_sigaction *) oact;
+ } */ *uap = v;
+ struct ibcs2_sigaction *nisa, *oisa, tmpisa;
+ struct sigaction *nbsa, *obsa, tmpbsa;
+ struct sigaction_args sa;
+ caddr_t sg;
+ int error;
-static int
-ibcs2_sighold(struct proc *p, struct ibcs2_signal_args *args, int *retval)
-{
- int sig_bsd = ibcs2_to_bsd_signal[LEGAL_SIG(args->signo)];
+ sg = stackgap_init(p->p_emul);
+ nisa = SCARG(uap, act);
+ oisa = SCARG(uap, oact);
- (void) splhigh();
- *retval = p->p_sigmask;
- p->p_sigmask |= (sigmask(sig_bsd) & ~DONTMASK);
- (void) spl0();
- return 0;
-}
-
-static int
-ibcs2_sigrelse(struct proc *p, struct ibcs2_signal_args *args, int *retval)
-{
- int sig_bsd = ibcs2_to_bsd_signal[LEGAL_SIG(args->signo)];
+ if (oisa != NULL)
+ obsa = stackgap_alloc(&sg, sizeof(struct sigaction));
+ else
+ obsa = NULL;
- (void) splhigh();
- *retval = p->p_sigmask;
- p->p_sigmask &= ~sigmask(sig_bsd);
- (void) spl0();
- return 0;
-}
+ 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;
-static int
-ibcs2_sigignore(struct proc *p, struct ibcs2_signal_args *args, int *retval)
-{
- struct sigaction tmp;
- int sig_bsd = ibcs2_to_bsd_signal[LEGAL_SIG(args->signo)];
-
- tmp.sa_mask = sigmask(sig_bsd);
- tmp.sa_handler = SIG_IGN;
- tmp.sa_flags = 0;
- *retval = (int)bsd_to_ibcs2_sigfunc(p->p_sigacts->ps_sigact[sig_bsd]);
- setsigvec(p, sig_bsd, &tmp);
- return 0;
-}
+ SCARG(&sa, signum) = ibcs2_to_bsd_sig[SCARG(uap, sig)];
+ SCARG(&sa, nsa) = nbsa;
+ SCARG(&sa, osa) = obsa;
-static int
-ibcs2_sigpause(struct proc *p, struct ibcs2_signal_args *args, int *retval)
-{
- struct sigacts *ps = p->p_sigacts;
- int sig_bsd = ibcs2_to_bsd_signal[LEGAL_SIG(args->signo)];
-
- ps->ps_oldmask = p->p_sigmask;
- ps->ps_flags |= SAS_OLDMASK;
- p->p_sigmask = sigmask(sig_bsd) &~ DONTMASK;
- (void) tsleep((caddr_t) ps, PPAUSE|PCATCH, "i-pause", 0);
- *retval = -1;
- return EINTR;
-}
-
-static int
-ibcs2_signal(struct proc *p, struct ibcs2_signal_args *args, int *retval)
-{
- struct sigaction tmp;
- int sig_bsd = ibcs2_to_bsd_signal[LEGAL_SIG(args->signo)];
-
- tmp.sa_mask = sigmask(sig_bsd);
- tmp.sa_handler = ibcs2_to_bsd_sigfunc(args->func);
- tmp.sa_flags = 0;
- *retval = (int)bsd_to_ibcs2_sigfunc(p->p_sigacts->ps_sigact[sig_bsd]);
- setsigvec(p, sig_bsd, &tmp);
- return 0;
-}
+ if ((error = sigaction(p, &sa, retval)) != 0)
+ return error;
-int
-ibcs2_sigsys(struct proc *p, struct ibcs2_signal_args *args, int *retval)
-{
- if (ibcs2_trace & IBCS2_TRACE_SIGNAL)
- printf("IBCS2: 'sigsys' signo=%d(%s) ",
- args->signo & IBCS2_SIGMASK,
- ibcs2_sig_to_str(args->signo & IBCS2_SIGMASK));
-
- switch (args->signo & ~IBCS2_SIGMASK ) {
- case 0x0000:
- if (ibcs2_trace & IBCS2_TRACE_SIGNAL)
- printf("signal() func=%x\n", args->func);
- return ibcs2_signal(p, args, retval);
- case 0x0100:
- if (ibcs2_trace & IBCS2_TRACE_SIGNAL)
- printf("sigset() func=%x\n", args->func);
- return ibcs2_sigset(p, args, retval);
- case 0x0200:
- if (ibcs2_trace & IBCS2_TRACE_SIGNAL)
- printf("sighold()\n");
- return ibcs2_sighold(p, args, retval);
- case 0x0400:
- if (ibcs2_trace & IBCS2_TRACE_SIGNAL)
- printf("sigrelse()\n");
- return ibcs2_sigrelse(p, args, retval);
- case 0x0800:
- if (ibcs2_trace & IBCS2_TRACE_SIGNAL)
- printf("sigignore()\n");
- return ibcs2_sigignore(p, args, retval);
- case 0x1000:
- if (ibcs2_trace & IBCS2_TRACE_SIGNAL)
- printf("sigpause()\n");
- return ibcs2_sigpause(p, args, retval);
- default:
- printf("IBCS2: unknown signal action\n"); break;
+ 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;
}
- *retval = -1;
- return EINVAL;
-}
-struct ibcs2_sigaction_args {
- int signo;
- struct sigaction *osa, *nsa;
-};
+ return 0;
+}
int
-ibcs2_sigaction(struct proc *p, struct ibcs2_sigaction_args *args, int *retval)
+ibcs2_sigsys(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
{
- struct sigaction vec;
- register struct sigaction *sa;
- register struct sigacts *ps = p->p_sigacts;
- register int sig;
- int bit, error;
-
- if (ibcs2_trace & IBCS2_TRACE_SIGNAL)
- printf("IBCS2: 'sigaction' signo=%d(%s)\n",
- args->signo, ibcs2_sig_to_str(args->signo));
- sig = ibcs2_to_bsd_signal[LEGAL_SIG(args->signo)];
- if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP) {
- *retval = -1;
+ struct ibcs2_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;
}
- sa = &vec;
- if (args->osa) {
- sa->sa_handler = ps->ps_sigact[sig];
- sa->sa_mask = ps->ps_catchmask[sig];
- bit = sigmask(sig);
- sa->sa_flags = 0;
- if (p->p_flag & SA_NOCLDSTOP)
- sa->sa_flags = IBCS2_SA_NOCLDSTOP;
- if (error = copyout((caddr_t)sa, (caddr_t)args->osa,
- sizeof(vec))) {
- *retval = -1;
- return error;
- }
- }
- if (args->nsa) {
- if (error = copyin((caddr_t)args->nsa, (caddr_t)sa,
- sizeof(vec))) {
- *retval = -1;
- return error;
- }
+
+ switch (IBCS2_SIGCALL(SCARG(uap, sig))) {
+ /*
+ * sigset is identical to signal() except that SIG_HOLD is allowed as
+ * an action.
+ */
+ case IBCS2_SIGSET_MASK:
/*
- * iBCS2 only defines one SA_ flag right now
+ * sigset is identical to signal() except
+ * that SIG_HOLD is allowed as
+ * an action.
*/
- if (vec.sa_flags & IBCS2_SA_NOCLDSTOP)
- vec.sa_flags = SA_NOCLDSTOP;
- setsigvec(p, sig, sa);
+ if (SCARG(uap, fp) == IBCS2_SIG_HOLD) {
+ struct sigprocmask_args sa;
+
+ SCARG(&sa, how) = SIG_BLOCK;
+ SCARG(&sa, mask) = sigmask(signum);
+ return sigprocmask(p, &sa, retval);
+ }
+ /* FALLTHROUGH */
+
+ case IBCS2_SIGNAL_MASK:
+ {
+ struct 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 = 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 sigprocmask_args sa;
+
+ SCARG(&sa, how) = SIG_BLOCK;
+ SCARG(&sa, mask) = sigmask(signum);
+ return sigprocmask(p, &sa, retval);
+ }
+
+ case IBCS2_SIGRELSE_MASK:
+ {
+ struct sigprocmask_args sa;
+
+ SCARG(&sa, how) = SIG_UNBLOCK;
+ SCARG(&sa, mask) = sigmask(signum);
+ return sigprocmask(p, &sa, retval);
+ }
+
+ case IBCS2_SIGIGNORE_MASK:
+ {
+ struct 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 = sigaction(p, &sa_args, retval)) != 0) {
+ DPRINTF(("sigignore: sigaction failed\n"));
+ return error;
+ }
+ return 0;
+ }
+
+ case IBCS2_SIGPAUSE_MASK:
+ {
+ struct sigsuspend_args sa;
+
+ SCARG(&sa, mask) = p->p_sigmask &~ sigmask(signum);
+ return sigsuspend(p, &sa, retval);
+ }
+
+ default:
+ return ENOSYS;
}
- *retval = 0;
- return 0;
}
-struct ibcs2_sigprocmask_args {
- int how;
- unsigned long *mask;
- unsigned long *omask;
-};
-
int
-ibcs2_sigprocmask(struct proc *p, struct ibcs2_sigprocmask_args *args, int *retval)
+ibcs2_sigprocmask(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
{
- int error;
- sigset_t umask;
- sigset_t omask = bsd_to_ibcs2_sigmask(p->p_sigmask);
-
- if (ibcs2_trace & IBCS2_TRACE_SIGNAL)
- printf("IBCS2: 'sigprocmask' how=%d\n", args->how);
- if (error = copyin(args->mask, &umask, sizeof(args->mask))) {
- *retval = -1;
- return error;
+ struct ibcs2_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;
}
- umask = ibcs2_to_bsd_sigmask(umask);
- if (args->omask)
- if (error = copyout(&omask, args->omask, sizeof(args->omask))) {
- *retval = -1;
- 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 (args->how) {
- case 0: /* SIG_SETMASK */
- p->p_sigmask = umask &~ DONTMASK;
+
+ switch (SCARG(uap, how)) {
+ case IBCS2_SIG_BLOCK:
+ p->p_sigmask |= bss & ~sigcantmask;
break;
-
- case 1: /* SIG_BLOCK */
- p->p_sigmask |= (umask &~ DONTMASK);
+
+ case IBCS2_SIG_UNBLOCK:
+ p->p_sigmask &= ~bss;
break;
- case 2: /* SIG_UNBLOCK */
- p->p_sigmask &= ~umask;
+ case IBCS2_SIG_SETMASK:
+ p->p_sigmask = bss & ~sigcantmask;
break;
default:
error = EINVAL;
break;
}
+
(void) spl0();
- if (error)
- *retval = -1;
- else
- *retval = 0;
- return error;
-}
-struct ibcs2_sigpending_args {
- unsigned long *sigs;
-};
+ return error;
+}
int
-ibcs2_sigpending(struct proc *p, struct ibcs2_sigpending_args *args, int *retval)
+ibcs2_sigpending(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
{
- int error;
- sigset_t mask = bsd_to_ibcs2_sigmask(p->p_siglist);
-
- if (ibcs2_trace & IBCS2_TRACE_SIGNAL)
- printf("IBCS2: 'sigpending' which=%x\n", args->sigs);
- if (error = copyout(&mask, args->sigs, sizeof(unsigned long)))
- *retval = -1;
- else
- *retval = 0;
- return error;
-}
+ struct ibcs2_sigpending_args /* {
+ syscallarg(ibcs2_sigset_t *) mask;
+ } */ *uap = v;
+ sigset_t bss;
+ ibcs2_sigset_t iss;
-struct ibcs2_sigsuspend_args {
- sigset_t *mask;
-};
+ bss = p->p_siglist & p->p_sigmask;
+ bsd_to_ibcs2_sigset(&bss, &iss);
+
+ return copyout(&iss, SCARG(uap, mask), sizeof(iss));
+}
int
-ibcs2_sigsuspend(struct proc *p, struct ibcs2_sigsuspend_args *args, int *retval)
+ibcs2_sigsuspend(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
{
- sigset_t mask = ibcs2_to_bsd_sigmask((sigset_t)args->mask);
+ struct ibcs2_sigsuspend_args /* {
+ syscallarg(ibcs2_sigset_t *) mask;
+ } */ *uap = v;
+ ibcs2_sigset_t sss;
+ sigset_t bss;
+ struct sigsuspend_args sa;
+ int error;
- if (ibcs2_trace & IBCS2_TRACE_SIGNAL)
- printf("IBCS2: 'sigsuspend'\n");
- return sigsuspend(p, &mask, retval);
-}
+ if ((error = copyin(SCARG(uap, mask), &sss, sizeof(sss))) != 0)
+ return error;
-struct kill_args {
- int pid;
- int signo;
-};
+ ibcs2_to_bsd_sigset(&sss, &bss);
+
+ SCARG(&sa, mask) = bss;
+ return sigsuspend(p, &sa, retval);
+}
int
-ibcs2_kill(struct proc *p, struct kill_args *args, int *retval)
+ibcs2_pause(p, uap, retval)
+ register struct proc *p;
+ void *uap;
+ register_t *retval;
{
- struct kill_args tmp;
-
- if (ibcs2_trace & IBCS2_TRACE_SIGNAL)
- printf("IBCS2: 'kill' pid=%d, sig=%d(%s)\n", args->pid,
- args->signo, ibcs2_sig_to_str(args->signo));
- tmp.pid = args->pid;
- tmp.signo = (args->signo < IBCS2_NSIG) ?
- ibcs2_to_bsd_signal[args->signo] : IBCS2_NSIG;
- return kill(p, &tmp, retval);
+ struct sigsuspend_args bsa;
+
+ SCARG(&bsa, mask) = p->p_sigmask;
+ return sigsuspend(p, &bsa, retval);
}
+int
+ibcs2_kill(p, v, retval)
+ register struct proc *p;
+ void *v;
+ register_t *retval;
+{
+ struct ibcs2_kill_args /* {
+ syscallarg(int) pid;
+ syscallarg(int) signo;
+ } */ *uap = v;
+ struct kill_args ka;
+
+ SCARG(&ka, pid) = SCARG(uap, pid);
+ SCARG(&ka, signum) = ibcs2_to_bsd_sig[SCARG(uap, signo)];
+ return kill(p, &ka, retval);
+}
diff --git a/sys/i386/ibcs2/ibcs2_signal.h b/sys/i386/ibcs2/ibcs2_signal.h
new file mode 100644
index 0000000..2858688
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_socksys.c b/sys/i386/ibcs2/ibcs2_socksys.c
index a5076da..6cf0a8f 100644
--- a/sys/i386/ibcs2/ibcs2_socksys.c
+++ b/sys/i386/ibcs2/ibcs2_socksys.c
@@ -1,21 +1,15 @@
-/*-
- * Copyright (c) 1994 Mostyn Lewis
+/*
+ * Copyright (c) 1994, 1995 Scott Bartram
+ * Copyright (c) 1994 Arne H Juul
* All rights reserved.
*
- * This software is based on code which is:
- * Copyright (c) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
- *
* 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
- * in this position and unchanged.
- * 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 withough specific prior written permission
+ * 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
@@ -27,1424 +21,111 @@
* 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.
- *
- * $Id: ibcs2_socksys.c,v 1.2 1994/10/13 23:10:58 sos Exp $
*/
#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/filedesc.h>
+#include <sys/proc.h>
#include <sys/file.h>
-#include <sys/kernel.h>
-#include <sys/mbuf.h>
-#include <sys/protosw.h>
+#include <sys/filedesc.h>
+#include <sys/ioctl.h>
+#include <sys/termios.h>
+#include <sys/tty.h>
#include <sys/socket.h>
-#include <sys/socketvar.h>
#include <sys/ioctl.h>
-#include <sys/sockio.h>
-#include <sys/proc.h>
-#include <sys/exec.h>
-#include <sys/stat.h>
-#include <sys/syscall.h>
-#include <sys/sysent.h>
-#include <sys/malloc.h>
-#include <sys/un.h>
#include <net/if.h>
-#include <net/if_arp.h>
-#include <net/route.h>
-#include <netinet/in.h>
-#include <vm/vm.h>
-#include <i386/ibcs2/ibcs2.h>
-#include <i386/ibcs2/ibcs2_socksys.h>
-
-/* Socksys pseudo driver entry points */
-
-int sockopen (dev_t dev, int mode, int devtype, struct proc *p);
-int sockioctl(dev_t dev, int cmd, caddr_t arg, int fflag, struct proc *p);
-int sockclose(dev_t dev, int flag, int mode, struct proc *p);
-
-/* Socksys internal functions */
-static void put_socket_fops(struct proc *p, int fd);
-static int ss_fop_close(struct file *fp, struct proc *p);
-static int ss_fop_ioctl(struct file*fp, int cmd, caddr_t arg, struct proc *p);
-static int ss_syscall(caddr_t arg, struct proc *p);
+#include <compat/ibcs2/ibcs2_socksys.h>
+#include <compat/ibcs2/ibcs2_util.h>
/*
- * This structure is setup on first usage. Its address is planted
- * into a socket's file structure fileops pointer after a successful
- * socket creation or accept.
+ * iBCS2 socksys calls.
*/
-static struct fileops ss_socket_fops = {
- NULL, /* normal socket read */
- NULL, /* normal socket write */
- NULL, /* socksys ioctl */
- NULL, /* normal socket select */
- NULL, /* socksys close */
-};
-
-static int (*close_s)__P((struct file *fp, struct proc *p));
-static int (*ioctl_s)__P((struct file *fp, int cmd, caddr_t data, struct proc *p));
-
-int ss_debug = 1;
-
-static int
-ss_syscall(arg, p)
- caddr_t arg;
- struct proc *p;
-{
- int cmd;
- int error;
- int retval[2];
-
- retval[0] = retval[1] = 0;
- cmd = ((struct ss_call *)arg)->arg[0];
-
-#ifdef SS_DEBUG
- if(ss_debug) {
- static char *ss_syscall_strings[] = {
- "0?", "accept", "bind", "connect", "getpeername",
- "getsockname", "getsockopt", "listen", "recv(from)",
- "recvfrom", "send(to)", "sendto", "setsockopt", "shutdown",
- "socket", "select", "getipdomain", "setipdomain",
- "adjtime", "setreuid", "setregid", "gettimeofday",
- "settimeofday", "getitimer", "setitimer",
- };
-
- printf("ss_syscall: [%d] ",p->p_pid);
- if(cmd < 0 || (cmd > CMD_SO_SETITIMER && cmd != CMD_SO_SS_DEBUG) )
- printf("? ");
- else {
- if(cmd == CMD_SO_SS_DEBUG)
- printf("%s ","ss_debug");
- else
- printf("%s ",ss_syscall_strings[cmd]);
- }
- printf("(%d) <0x%x,0x%x,0x%x,0x%x,0x%x,0x%x>\n",
- cmd,
- ((struct ss_call *)arg)->arg[1],
- ((struct ss_call *)arg)->arg[2],
- ((struct ss_call *)arg)->arg[3],
- ((struct ss_call *)arg)->arg[4],
- ((struct ss_call *)arg)->arg[5],
- ((struct ss_call *)arg)->arg[6]);
- }
-#endif /* SS_DEBUG */
-
- error = 0;
-
- switch (cmd) {
-
- case CMD_SO_SS_DEBUG:
-
- ss_debug = ((struct ss_call *)arg)->arg[1];
- break;
-
- case CMD_SO_SOCKET: { /* NO CONV */
-
-#ifdef SS_DEBUG
- if(ss_debug > 1)
- printf("SO_SOCKET af in %d\n",
- ((struct ss_call *)arg)->arg[1]);
-#endif /* SS_DEBUG */
- ((struct ss_call *)arg)->arg[1] = ss_convert(
- af_whatevers,
- &(((struct ss_call *)arg)->arg[1]),
- 0);
-#ifdef SS_DEBUG
- if(ss_debug > 1) {
- printf("SO_SOCKET af out %d\n",
- ((struct ss_call *)arg)->arg[1]);
-
- printf("SO_SOCKET type in %d\n",
- ((struct ss_call *)arg)->arg[2]);
- }
-#endif /* SS_DEBUG */
- ((struct ss_call *)arg)->arg[2] = ss_convert(
- type_whatevers,
- &(((struct ss_call *)arg)->arg[2]),
- 0);
-#ifdef SS_DEBUG
- if(ss_debug > 1)
- printf("SO_SOCKET type out %d\n",
- ((struct ss_call *)arg)->arg[2]);
-#endif /* SS_DEBUG */
-
- SYSCALL(SYS_socket, 0, 0);
-
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("ss_syscall: [%d] socket fd=%d\n",
- p->p_pid, retval[0]);
-#endif /* SS_DEBUG */
- put_socket_fops(p,retval[0]);
-
- break;
- }
-
- case CMD_SO_ACCEPT: { /* CONVERSION in arg 2 */
-
- SYSCALL(SYS_accept, 2, SS_STRUCT_SOCKADDR);
-
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("ss_syscall: [%d] accept fd=%d\n",
- p->p_pid, retval[0]);
-#endif /* SS_DEBUG */
- put_socket_fops(p,retval[0]);
-
- break;
- }
-
- case CMD_SO_BIND:
- SYSCALL(SYS_bind, 2, SS_STRUCT_SOCKADDR);
- break;
-
- case CMD_SO_CONNECT: {
- struct alien_sockaddr *sa;
- unsigned short family;
-
- /* Remap any INADDR_ANY (0.0.0.0) to localhost */
-
- sa = (struct alien_sockaddr *)((struct ss_call *)arg)->arg[1];
- if(error = copyin((caddr_t)&sa->sa_family,
- (caddr_t)&family, sizeof(short)))
- return(error);
- if (family == AF_INET) {
- unsigned long *addr;
- unsigned long saddr;
-
- addr = &(((struct alien_sockaddr_in *)sa)->sin_addr.s_addr);
- if(error = copyin((caddr_t)addr, (caddr_t)&saddr, sizeof(long)))
- return(error);
- if (saddr == INADDR_ANY) {
- /* 0x0100007f is 127.0.0.1 reversed */
- saddr = 0x0100007f;
- if(error = copyout((caddr_t)&saddr,
- (caddr_t)addr, sizeof(long)))
- return(error);
-#ifdef SS_DEBUG
- if (ss_debug)
- printf("ss_syscall: remapped INADDR_ANY to localhost\n");
-#endif /* SS_DEBUG */
- }
- }
- SYSCALL(SYS_connect, 2, SS_STRUCT_SOCKADDR);
- break;
- }
-
- case CMD_SO_GETPEERNAME:
- SYSCALL(SYS_getpeername, 2, SS_STRUCT_SOCKADDR);
- break;
-
- case CMD_SO_GETSOCKNAME:
- SYSCALL(SYS_getsockname, 2, SS_STRUCT_SOCKADDR);
- break;
-
- case CMD_SO_GETSOCKOPT:
- if(error = ss_getsockopt((caddr_t)(((int *)arg) + 1),retval,p))
- return(error);
- break;
-
- case CMD_SO_LISTEN:
- SYSCALL(SYS_listen, 0, 0);
- break;
-
- case CMD_SO_RECV:
- ((struct ss_call *)arg)->arg[5] = (int)((struct sockaddr *)NULL);
- ((struct ss_call *)arg)->arg[6] = 0;
- SYSCALL(SYS_recvfrom, 0, 0);
- break;
-
- case CMD_SO_RECVFROM:
- SYSCALL(SYS_recvfrom, 5, SS_STRUCT_SOCKADDR);
- break;
-
- case CMD_SO_SEND:
- ((struct ss_call *)arg)->arg[5] = (int)((struct sockaddr *)NULL);
- ((struct ss_call *)arg)->arg[6] = 0;
- SYSCALL(SYS_sendto, 0, 0);
- break;
-
- case CMD_SO_SENDTO:
- SYSCALL(SYS_sendto, 5, SS_STRUCT_SOCKADDR);
- break;
-
- case CMD_SO_SETSOCKOPT:
- if(error = ss_setsockopt((caddr_t)(((int *)arg) + 1),retval,p))
- return(error);
-
- case CMD_SO_SHUTDOWN:
- SYSCALL(SYS_shutdown, 0, 0);
- break;
-
- case CMD_SO_GETIPDOMAIN:
- SYSCALL(SYS_getdomainname, 0, 0);
- break;
-
- case CMD_SO_SETIPDOMAIN: /* Note check on BSD utsname no change? */
- SYSCALL(SYS_setdomainname, 0, 0);
- break;
-
- case CMD_SO_SETREUID:
- SYSCALL(126/*SYS_setreuid*/, 0, 0);
- break;
-
- case CMD_SO_SETREGID:
- SYSCALL(127/*SYS_setregid*/, 0, 0);
- break;
-
- case CMD_SO_GETTIME:
- SYSCALL(SYS_gettimeofday, 0, 0);
- break;
-
- case CMD_SO_SETTIME:
- SYSCALL(SYS_settimeofday, 0, 0);
- break;
-
- case CMD_SO_GETITIMER:
- SYSCALL(SYS_getitimer, 0, 0);
- break;
-
- case CMD_SO_SETITIMER:
- SYSCALL(SYS_setitimer, 0, 0);
- break;
-
- case CMD_SO_SELECT:
- SYSCALL(SYS_select, 0, 0);
- break;
-
- case CMD_SO_ADJTIME:
- SYSCALL(SYS_adjtime, 0, 0);
- break;
-
- default:
- printf("ss_syscall: default 0x%x\n",cmd);
- return (EINVAL);
- }
- IBCS2_MAGIC_RETURN;
-}
-
-
-static int
-ss_fop_ioctl(fp, cmd, arg, p)
- struct file *fp;
- int cmd;
- caddr_t arg;
- struct proc *p;
-{
- int error;
- int retval[2];
-
-#ifdef SS_DEBUG
- if(ss_debug) {
- static char **ioctl_strings;
- int fd;
- struct filedesc *fdp;
- unsigned int ioctl_type;
- unsigned int ioctl_len;
- char cmd_type;
- int cmd_ordinal;
-
- static char *ioctl_type_strings[] = {
- "0?", "SS_IO", "SS_IOR", "3?", "SS_IOW", "5?", "SS_IOWR"
- };
- static char *ioctl_S_strings[] = {
- "0?", "SIOCSHIWAT", "SIOCGHIWAT", "SIOCSLOWAT", "SIOCGLOWAT",
- "SIOCATMARK", "SIOCSPGRP", "SIOCGPGRP", "FIONREAD",
- "FIONBIO", "FIOASYNC", "SIOCPROTO", "SIOCGETNAME",
- "SIOCGETPEER", "IF_UNITSEL", "SIOCXPROTO"
- };
- static char *ioctl_R_strings[] = {
- "0?", "1?", "2?", "3?", "4?", "5?", "6?", "7?", "8?",
- "SIOCADDRT", "SIOCDELRT"
- };
- static char *ioctl_I_strings[] = {
- "0?", "1?", "2?", "3?", "4?", "5?", "6?", "7?", "8?",
- "9?", "10?", "SIOCSIFADDR", "SIOCGIFADDR", "SIOCSIFDSTADDR",
- "SIOCGIFDSTADDR", "SIOCSIFFLAGS", "SIOCGIFFLAGS",
- "SIOCGIFCONF", "18?", "19?", "20?", "SIOCSIFMTU",
- "SIOCGIFMTU", "23?", "24?", "25?", "SIOCIFDETACH",
- "SIOCGENPSTATS", "28?", "SIOCX25XMT", "SS_SIOCX25RCV",
- "SS_SIOCX25TBL", "SIOCGIFBRDADDR" ,"SIOCSIFBRDADDR",
- "SIOCGIFNETMASK", "SIOCSIFNETMASK", "SIOCGIFMETRIC",
- "SIOCSIFMETRIC", "SIOCSARP", "SIOCGARP", "SIOCDARP",
- "SIOCSIFNAME", "SIOCGIFONEP", "SIOCSIFONEP ",
- "44?", "45?", "46?", "47?", "48?", "49?", "50?", "51?",
- "52?", "53?", "54?", "55?", "56?", "57?", "58?", "59?",
- "60?", "61?", "62?", "63?", "64?", "SIOCGENADDR",
- "SIOCSOCKSYS"
- };
-
- cmd_type = (cmd >> 8) & 0xff;
- cmd_ordinal = cmd & 0xff;
-
- switch (cmd_type) {
-
- case 'S':
- ioctl_strings = ioctl_S_strings;
- if (cmd_ordinal > 15)
- cmd_ordinal = -1;
- break;
-
- case 'R':
- ioctl_strings = ioctl_R_strings;
- if (cmd_ordinal > 10)
- cmd_ordinal = -1;
- break;
-
- case 'I':
- ioctl_strings = ioctl_I_strings;
- if (cmd_ordinal > 66)
- cmd_ordinal = -1;
- break;
-
- default:
- cmd_type = '?';
- break;
- }
- fdp = p->p_fd;
- fd = -1;
- while(++fd < NOFILE)
- if ( fp == fdp->fd_ofiles[fd] )
- break;
- ioctl_type = (0xe0000000 & cmd) >> 29;
- ioctl_len = (cmd >> 16) & SS_IOCPARM_MASK;
-
- printf("ss_fop_ioctl: [%d] fd=%d ",p->p_pid, fd);
- if(cmd_type != '?'){
- if(cmd_ordinal != -1)
- printf("%s %s('%c',%d,l=%d) ",ioctl_strings[cmd_ordinal],
- ioctl_type_strings[ioctl_type],
- cmd_type,
- cmd_ordinal,
- ioctl_len);
- else {
- cmd_ordinal = cmd & 0xff;
- printf("[unknown ordinal %d] %s('%c',%d,l=%d) ",cmd_ordinal,
- ioctl_type_strings[ioctl_type],
- cmd_type,
- cmd_ordinal,
- ioctl_len);
- }
- }
- else {
- printf("? %s('%c',%d,l=%d) ",
- ioctl_type_strings[ioctl_type],
- cmd_type,
- cmd_ordinal,
- ioctl_len);
- }
-
- printf("0x%x (0x%x) <0x%x>\n",
- fp, cmd, arg);
- }
-#endif /* SS_DEBUG */
-
- /* No dogs allowed */
-
- if(*(((int *)arg) - 3) != IBCS2_MAGIC_IN){
- printf("ss_fop_ioctl: bad magic (sys_generic.c has no socksys mods?)\n");
- return(EINVAL);
- }
-
- if(fp->f_type != DTYPE_SOCKET)
- return (ENOTSOCK);
-
- retval[0] = retval[1] = 0;
-
-
- error = 0;
-
- switch (cmd) {
- case SS_SIOCSHIWAT: /* set high watermark */
- case SS_SIOCSLOWAT: /* set low watermark */
- break; /* return value of 0 and no error */
-
- case SS_SIOCGHIWAT: /* get high watermark */
- case SS_SIOCGLOWAT: /* get low watermark */
- break; /* return value of 0 and no error */
-
- case SS_SIOCATMARK: /* at oob mark */
- IOCTL(SIOCATMARK);
- break;
-
- case SS_SIOCSPGRP: /* set process group */
- IOCTL(SIOCSPGRP);
- break;
- case SS_SIOCGPGRP: /* get process group */
- IOCTL(SIOCGPGRP);
- break;
-
- case FIONREAD:
- case SS_FIONREAD: /* get # bytes to read */
- IOCTL(FIONREAD);
- break;
-
- case SS_FIONBIO: /* set/clear non-blocking i/o */
- IOCTL(FIONBIO);
- break;
-
- case SS_FIOASYNC: /* set/clear async i/o */
- IOCTL(FIOASYNC);
- break;
-
- case SS_SIOCADDRT: /* add route - uses struct ortentry */
- IOCTL(SIOCADDRT);
- break;
-
- case SS_SIOCDELRT: /* delete route - uses struct ortentry */
- IOCTL(SIOCDELRT);
- break;
-
- case SS_SIOCSIFADDR: /* set ifnet address */
- IOCTL(SIOCSIFADDR);
- break;
-
- case SS_SIOCGIFADDR: /* get ifnet address */
- IOCTL(SIOCGIFADDR);
- break;
-
- case SS_SIOCSIFDSTADDR: /* set p-p address */
- IOCTL(SIOCSIFDSTADDR);
- break;
-
- case SS_SIOCGIFDSTADDR: /* get p-p address */
- IOCTL(SIOCGIFDSTADDR);
- break;
-
- case SS_SIOCSIFFLAGS: /* set ifnet flags */
- IOCTL(SIOCSIFFLAGS);
- break;
-
- case SS_SIOCGIFFLAGS: /* get ifnet flags */
- IOCTL(SIOCGIFFLAGS);
- break;
-
- case SS_SIOCGIFCONF: /* get ifnet ltst */
- IOCTL(SIOCGIFCONF);
- break;
-
- case SS_SIOCGIFBRDADDR: /* get broadcast addr */
- IOCTL(SIOCGIFBRDADDR);
- break;
-
- case SS_SIOCSIFBRDADDR: /* set broadcast addr */
- IOCTL(SIOCSIFBRDADDR);
- break;
-
- case SS_SIOCGIFNETMASK: /* get net addr mask */
- IOCTL(SIOCGIFNETMASK);
- break;
-
- case SS_SIOCSIFNETMASK: /* set net addr mask */
- IOCTL(SIOCSIFNETMASK);
- break;
-
- case SS_SIOCGIFMETRIC: /* get IF metric */
- IOCTL(SIOCGIFMETRIC);
- break;
-
- case SS_SIOCSIFMETRIC: /* set IF metric */
- IOCTL(SIOCSIFMETRIC);
- break;
-
-/* FreeBSD 2.0 does not have socket ARPs */
-
-#ifdef SIOCSARP
-
- case SS_SIOCSARP: /* set arp entry */
- IOCTL(SIOCSARP);
- break;
-
- case SS_SIOCGARP: /* get arp entry */
- IOCTL(SIOCGARP);
- break;
-
- case SS_SIOCDARP: /* delete arp entry */
- IOCTL(SIOCDARP);
- break;
-
-#else /* SIOCSARP */
-
- case SS_SIOCSARP: /* set arp entry */
- return(EINVAL);
-
- case SS_SIOCGARP: /* get arp entry */
- return(EINVAL);
-
- case SS_SIOCDARP: /* delete arp entry */
- return(EINVAL);
-
-#endif /* SIOCSARP */
-
- case SS_SIOCGENADDR: /* Get ethernet addr XXX */
- return (EINVAL);
-/* return (error = ioctl_s(fp, SIOCGIFHWADDR, arg, p)); */
-
- case SS_SIOCSIFMTU: /* get if_mtu */
- IOCTL(SIOCSIFMTU);
- break;
-
- case SS_SIOCGIFMTU: /* set if_mtu */
- IOCTL(SIOCGIFMTU);
- break;
-
- case SS_SIOCGETNAME: /* getsockname XXX */
- return (EINVAL);
-/* return (ioctl_s(fp, SIOCGIFNAME, arg, p)); MMM */
-
- case SS_SIOCGETPEER: { /* getpeername */
- struct moose {
- int fd;
- caddr_t asa;
- int *alen;
- int compat_43;
- } args;
-
- struct alien_sockaddr uaddr;
- struct sockaddr nuaddr;
- int nuaddr_len = sizeof(struct sockaddr);
- struct filedesc *fdp;
-
- if(fp->f_type != DTYPE_SOCKET)
- return (ENOTSOCK);
-
- bzero((caddr_t)&nuaddr, sizeof(struct sockaddr));
- fdp = p->p_fd;
- args.fd = -1;
- while(++args.fd < NOFILE)
- if ( fp == fdp->fd_ofiles[args.fd] )
- break;
- if(args.fd == NOFILE){
- printf("ss_fop_ioctl: [%d] SS_SIOCGETPEER args.fd > NOFILE\n", p->p_pid);
- return(EBADF);
- }
- args.asa = (caddr_t)&nuaddr;
- args.alen = &nuaddr_len;
- args.compat_43 = 0;
- error = SYSCALLX(SYS_getpeername, &args);
- if(error)
- return(error);
-
- bzero((caddr_t)&uaddr, sizeof(struct alien_sockaddr));
- uaddr.sa_family = (unsigned short)nuaddr.sa_family;
- bcopy(&nuaddr.sa_data, &uaddr.sa_data, __ALIEN_SOCK_SIZE__ - sizeof(unsigned short));
-
- error = copyout((caddr_t)&uaddr, (caddr_t)arg, sizeof(struct alien_sockaddr));
- return error;
- }
-
- default:
- printf("ss_fop_ioctl: [%d] %lx unknown ioctl 0x%x, 0x%lx\n",
- p->p_pid, (unsigned long)fp,
- cmd, (unsigned long)arg);
- return (EINVAL);
- }
- IBCS2_MAGIC_RETURN;
-}
+struct ibcs2_socksys_args {
+ int fd;
+ int magic;
+ caddr_t argsp;
+};
int
-sockioctl(dev, cmd, arg, fflag, p)
- dev_t dev;
- int cmd;
- caddr_t arg;
- int fflag;
- struct proc *p;
+ibcs2_socksys(p, uap, retval)
+ register struct proc *p;
+ register struct ibcs2_socksys_args *uap;
+ int *retval;
{
+ register struct filedesc *fdp = p->p_fd;
+ register struct file *fp;
int error;
- int retval[2];
-
-#ifdef SS_DEBUG
- if(ss_debug) {
- char cmd_type;
- int cmd_ordinal;
- static char **ioctl_strings;
- unsigned int ioctl_type;
- unsigned int ioctl_len;
-
- static char *ioctl_type_strings[] = {
- "NIOCxx", "SS_IO", "SS_IOR", "3?", "SS_IOW", "5?", "SS_IOWR"
- };
- static char *ioctl_S_strings[] = {
- "0?", "SIOCSHIWAT", "SIOCGHIWAT", "SIOCSLOWAT", "SIOCGLOWAT",
- "SIOCATMARK", "SIOCSPGRP", "SIOCGPGRP", "FIONREAD",
- "FIONBIO", "FIOASYNC", "SIOCPROTO", "SIOCGETNAME",
- "SIOCGETPEER", "IF_UNITSEL", "SIOCXPROTO"
- };
- static char *ioctl_R_strings[] = {
- "0?", "1?", "2?", "3?", "4?", "5?", "6?", "7?", "8?",
- "SIOCADDRT", "SIOCDELRT"
- };
- static char *ioctl_I_strings[] = {
- "0?", "1?", "2?", "3?", "4?", "5?", "6?", "7?", "8?",
- "9?", "10?", "SIOCSIFADDR", "SIOCGIFADDR", "SIOCSIFDSTADDR",
- "SIOCGIFDSTADDR", "SIOCSIFFLAGS", "SIOCGIFFLAGS",
- "SIOCGIFCONF", "18?", "19?", "20?", "SIOCSIFMTU",
- "SIOCGIFMTU", "23?", "24?", "25?", "SIOCIFDETACH",
- "SIOCGENPSTATS", "28?", "SIOCX25XMT", "SS_SIOCX25RCV",
- "SS_SIOCX25TBL", "SIOCGIFBRDADDR" ,"SIOCSIFBRDADDR",
- "SIOCGIFNETMASK", "SIOCSIFNETMASK", "SIOCGIFMETRIC",
- "SIOCSIFMETRIC", "SIOCSARP", "SIOCGARP", "SIOCDARP",
- "SIOCSIFNAME", "SIOCGIFONEP", "SIOCSIFONEP ",
- "44?", "45?", "46?", "47?", "48?", "49?", "50?", "51?",
- "52?", "53?", "54?", "55?", "56?", "57?", "58?", "59?",
- "60?", "61?", "62?", "63?", "64?", "SIOCGENADDR",
- "SIOCSOCKSYS"
- };
- static char *ioctl_NIOC_strings[] = {
- "0?", "NIOCNFSD", "NIOCOLDGETFH", "NIOCASYNCD",
- "NIOCSETDOMNAM", "NIOCGETDOMNAM", "NIOCCLNTHAND",
- "NIOCEXPORTFS", "NIOCGETFH", "NIOCLSTAT"
- };
-
- cmd_ordinal = cmd & 0xff;
- cmd_type = (cmd >> 8) & 0xff;
- switch (cmd_type) {
-
- case 0:
- ioctl_strings = ioctl_NIOC_strings;
- cmd_type = ' ';
- if (cmd_ordinal > 9)
- cmd_ordinal = -1;
- break;
-
- case 'S':
- ioctl_strings = ioctl_S_strings;
- if (cmd_ordinal > 15)
- cmd_ordinal = -1;
- break;
-
- case 'R':
- ioctl_strings = ioctl_R_strings;
- if (cmd_ordinal > 10)
- cmd_ordinal = -1;
- break;
-
- case 'I':
- ioctl_strings = ioctl_I_strings;
- if (cmd_ordinal > 66)
- cmd_ordinal = -1;
- break;
-
- default:
- cmd_type = '?';
- break;
-
- }
- ioctl_type = (0xe0000000 & cmd) >> 29;
- ioctl_len = (cmd >> 16) & SS_IOCPARM_MASK;
-
- printf("sockioctl: [%d] ",p->p_pid);
- if(cmd_type != '?'){
- if(cmd_ordinal != -1)
- printf("%s %s('%c',%d,l=%d) ",ioctl_strings[cmd_ordinal],
- ioctl_type_strings[ioctl_type],
- cmd_type,
- cmd_ordinal,
- ioctl_len);
- else {
- cmd_ordinal = cmd & 0xff;
- printf("[unknown ordinal %d] %s('%c',%d,l=%d) ",cmd_ordinal,
- ioctl_type_strings[ioctl_type],
- cmd_type,
- cmd_ordinal,
- ioctl_len);
- }
- }
- else {
- printf("? %s('%c',%d,l=%d) ",
- ioctl_type_strings[ioctl_type],
- cmd_type,
- cmd_ordinal,
- ioctl_len);
- }
-
- printf("0x%x (0x%x) <0x%x>\n",
- dev, cmd, arg);
- }
-#endif /* SS_DEBUG */
-
- if(*(((int *)arg) - 3) != IBCS2_MAGIC_IN){
- printf("sockioctl: bad magic (sys_generic.c has no socksys mods?)\n");
- return(EINVAL);
- }
-
- switch (cmd) {
-
- case SS_SIOCSOCKSYS: /* ss syscall */
- return ss_syscall(arg, p);
-
- /* NIOCxx: These ioctls are really just integers
- * (no other information to go on).
+ 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.
*/
- case NIOCSETDOMNAM: {
- struct sgdomarg domargs;
-
- if(error = copyin((caddr_t)*((caddr_t *)arg), (caddr_t)&domargs, sizeof(struct sgdomarg)))
- return(error);
-
- arg = (caddr_t)&domargs;
- SYSCALL_N(SYS_setdomainname, 0, 0);
- break;
- }
-
- case NIOCGETDOMNAM: {
- struct sgdomarg domargs;
-
- if(error = copyin((caddr_t)*((caddr_t *)arg), (caddr_t)&domargs, sizeof(struct sgdomarg)))
- return(error);
-
- arg = (caddr_t)&domargs;
- SYSCALL_N(SYS_getdomainname, 0, 0);
- break;
- }
-
- case NIOCLSTAT: {
- struct lstatarg st;
-
- if(error = copyin((caddr_t)*((caddr_t *)arg), (caddr_t)&st, sizeof(struct lstatarg)))
- return(error);
-
- /* DO WE HAVE A FOREIGN LSTAT */
-/* return mumbo_lstat(st.fname, st.statb); */
- return (EINVAL);
- }
-
- case NIOCNFSD:
- case NIOCOLDGETFH:
- case NIOCASYNCD:
- case NIOCCLNTHAND:
- case NIOCEXPORTFS:
- case NIOCGETFH:
- return (EINVAL);
-
-
- case SS_IF_UNITSEL: /* set unit number */
- case SS_SIOCXPROTO: /* empty proto table */
-
- case SS_SIOCIFDETACH: /* detach interface */
- case SS_SIOCGENPSTATS: /* get ENP stats */
-
- case SS_SIOCSIFNAME: /* set interface name */
- case SS_SIOCGIFONEP: /* get one-packet params */
- case SS_SIOCSIFONEP: /* set one-packet params */
-
- case SS_SIOCPROTO: /* link proto */
- case SS_SIOCX25XMT:
- case SS_SIOCX25RCV:
- case SS_SIOCX25TBL:
-
- printf("sockioctl: [%d] unsupported ioctl 0x%x , 0x%lx\n",
- p->p_pid,
- cmd, (unsigned long)arg);
- return (EINVAL);
-
- default:
- printf("sockioctl: [%d] unknown ioctl 0x%x , 0x%lx\n",
- p->p_pid,
- cmd, (unsigned long)arg);
- return (EINVAL);
- }
- IBCS2_MAGIC_RETURN;
-}
-
-
-int sockopen(dev, mode, devtype, p)
- dev_t dev;
- int mode;
- int devtype;
- struct proc *p;
-{
-
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("sockopen: [%d] 0x%x\n", p->p_pid, dev);
-#endif /* SS_DEBUG */
-
- /* minor = 0 is the socksys device itself. No special handling
- * will be needed as it is controlled by the application
- * via ioctls.
- */
- if (minor(dev) == 0)
- return 0;
-
- /* minor = 1 is the spx device. This is the client side of a
- * streams pipe to the X server. Under SCO and friends
- * the library code messes around setting the connection
- * up itself. We do it ourselves - this means we don't
- * need to worry about the implementation of the server
- * side (/dev/X0R - which must exist but can be a link
- * to /dev/null) nor do we need to actually implement
- * getmsg/putmsg.
- */
-{ /* SPX */
- int fd, error, args[3];
- int retval[2];
-#define SUN_LEN(su) \
- (sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path)) + 1
- struct sockaddr_un *Xaddr = (struct sockaddr_un *)UA_ALLOC();
- retval[0] = retval[1] = 0;
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("sockopen: SPX: [%d] opening\n", p->p_pid);
-#endif /* SS_DEBUG */
-
- /* Grab a socket. */
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("sockopen: SPX: [%d] get a unix domain socket\n",
- p->p_pid);
-#endif /* SS_DEBUG */
- args[0] = AF_UNIX;
- args[1] = SOCK_STREAM;
- args[2] = 0;
- error = SYSCALLX(SYS_socket, args);
- if (error)
- return error;
- fd = retval[0];
- if(fd < 1) {
- printf("sockopen: SPX: [%d] unexpected fd of %d\n",
- p->p_pid, fd);
- return(EOPNOTSUPP); /* MRL whatever */
- }
-
- /* Connect the socket to X. */
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("sockopen: SPX: [%d] connect to /tmp/X11-unix/X0\n",
- p->p_pid);
-#endif /* SS_DEBUG */
- args[0] = fd;
- Xaddr->sun_family = AF_UNIX;
- copyout("/tmp/.X11-unix/X0", Xaddr->sun_path, 18);
- Xaddr->sun_len = SUN_LEN(Xaddr);
- args[1] = (int)Xaddr;
- args[2] = sizeof(struct sockaddr_un);
- error = SYSCALLX(SYS_connect, args);
- if (error) {
- (void)SYSCALLX(SYS_close, &fd);
+ if (error = copyin(uap->argsp, (caddr_t)realargs, sizeof(realargs)))
return error;
- }
-
- put_socket_fops(p,fd);
-
- return 0;
-} /* SPX */
-}
-
-
-int sockclose(dev, flag, mode, p)
- dev_t dev;
- int flag;
- int mode;
- struct proc *p;
-{
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("sockclose: [%d] 0x%x\n", p->p_pid, dev);
-#endif /* SS_DEBUG */
- return(0);
-}
-
-static
-int ss_fop_close(struct file *fp, struct proc *p)
-{
-
-#ifdef SS_DEBUG
-int fd;
-struct filedesc *fdp;
-
- if(ss_debug){
- fdp = p->p_fd;
- fd = -1;
- while(++fd < NOFILE)
- if ( fp == fdp->fd_ofiles[fd] )
- break;
- printf("ss_fop_close: [%d] fd=%d ", p->p_pid, fd);
- }
-#endif /* SS_DEBUG */
-
- if(fp->f_type == DTYPE_SOCKET) {
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("is a socket\n");
-#endif /* SS_DEBUG */
- return(close_s(fp, p));
- }
- else {
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("is not a socket\n");
-#endif /* SS_DEBUG */
- return(ENOTSOCK);
- }
-}
-
-void put_socket_fops(struct proc *p, int fd)
-{
-struct filedesc *fdp;
-struct file *fp;
-
- fdp = p->p_fd;
- fp = fdp->fd_ofiles[fd];
- if (ss_socket_fops.fo_ioctl != fp->f_ops->fo_ioctl) {
- bcopy(fp->f_ops, &ss_socket_fops, sizeof(struct fileops));
- ioctl_s = ss_socket_fops.fo_ioctl; /* save standard ioctl */
- close_s = ss_socket_fops.fo_close; /* save standard close */
- ss_socket_fops.fo_ioctl = ss_fop_ioctl;
- ss_socket_fops.fo_close = ss_fop_close;
- }
- fp->f_ops = &ss_socket_fops;
-
- return;
-}
-
-int ss_SYSCALL(n,convert_arg,indicator,arg,p,retval)
- int n; /* syscall ordinal */
- int convert_arg; /* if not 0, argument to convert */
- int indicator; /* type of argument to convert */
- int *arg; /* address of alien arg */
- struct proc *p;
- int *retval;
-{
-int error;
-int rc;
-
- if(convert_arg){
- if(rc = ss_convert_struct( (caddr_t)*(arg + convert_arg),
- indicator,
- SS_ALIEN_TO_NATIVE))
- return(rc);
-
- error = (*sysent[n].sy_call)(p, arg + 1, retval);
- rc = ss_convert_struct( (caddr_t)*(arg + convert_arg),
- indicator,
- SS_NATIVE_TO_ALIEN);
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("ss_SYSCALL: [%d] error=%d, rc=%d\n",
- p->p_pid, error, rc);
-#endif /* SS_DEBUG */
- }
- else {
- rc = 0;
- error = (*sysent[n].sy_call)(p, arg + 1, retval);
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("ss_SYSCALL: [%d] error=%d\n",p->p_pid, error);
-#endif /* SS_DEBUG */
- }
-
- return(error ? error : rc);
-}
-
-int ss_IOCTL(fp, cmd, arg, p)
- struct file *fp;
- int cmd;
- int *arg; /* address of alien arg */
- struct proc *p;
-{
-int error, rc;
-int these[2];
-char cmd_type;
-int cmd_ordinal;
-int indicator;
-
- cmd_type = (cmd >> 8) & 0xff;
- cmd_ordinal = cmd & 0xff;
- these[0] = cmd_type;
- these[1] = cmd_ordinal;
-#ifdef SS_DEBUG
- if(ss_debug > 1)
- printf("ss_IOCTL: calling ss_convert with %d(%c) %d\n",
- these[0],these[0],these[1]);
-#endif /* SS_DEBUG */
- indicator = ss_convert( struct_whatevers, these, 0);
-#ifdef SS_DEBUG
- if(ss_debug > 1)
- printf("ss_IOCTL: ss_convert returns indicator %d\n",indicator);
-#endif /* SS_DEBUG */
- if(indicator){
- error = ss_convert_struct((caddr_t)*(arg + 2),
- indicator,
- SS_ALIEN_TO_NATIVE);
-#ifdef SS_DEBUG
- if(ss_debug > 1)
- printf("ss_IOCTL: ss_convert_struct returns %d\n",error);
-#endif /* SS_DEBUG */
- if(error)
- return(error);
- /* change len in ioctl now - in the general case */
- error = ioctl_s(fp, cmd, (caddr_t)arg, p);
- rc = ss_convert_struct( (caddr_t)*(arg + 2),
- indicator,
- SS_NATIVE_TO_ALIEN);
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("ss_IOCTL: [%d] error=%d, rc=%d\n",p->p_pid,
- error, rc);
-#endif /* SS_DEBUG */
- }
- else {
- rc = 0;
- error = ioctl_s(fp, cmd, (caddr_t)arg, p);
-#ifdef SS_DEBUG
- if(ss_debug)
- printf("ss_IOCTL: [%d] error=%d\n",p->p_pid, error);
-#endif /* SS_DEBUG */
- }
-
- return(error ? error : rc);
-}
-
-
-struct ss_socketopt_args {
- int s;
- int level;
- int name;
- caddr_t val;
- int valsize;
-};
-
-int
-ss_setsockopt(arg, ret, p)
- struct ss_socketopt_args *arg;
- int *ret;
- struct proc *p;
-{
- int error, optname;
- int retval[2];
-
- if (arg->level != 0xffff) /* FreeBSD, SCO and ? */
- return (ENOPROTOOPT);
-
- optname = ss_convert(sopt_whatevers, &arg->name, 0);
-
- switch (optname) {
-
- case SO_ACCEPTCONN:
- case SO_BROADCAST:
- case SO_DEBUG:
- case SO_DONTROUTE:
- case SO_LINGER:
- case SO_KEEPALIVE:
- case SO_OOBINLINE:
- case SO_RCVBUF:
- case SO_RCVLOWAT:
- case SO_RCVTIMEO:
- case SO_REUSEADDR:
- case SO_SNDBUF:
- case SO_SNDLOWAT:
- case SO_SNDTIMEO:
- case SO_USELOOPBACK:
- error = SYSCALLX(SYS_setsockopt, arg);
- *ret = retval[0];
- *(ret + 1) = retval[1];
- return(error);
-
- case SO_ERROR:
- case SO_IMASOCKET:
- case SO_NO_CHECK:
- case SO_ORDREL:
- case SO_PRIORITY:
- case SO_PROTOTYPE:
- case SO_TYPE:
- return (ENOPROTOOPT);
-
- }
-
- return (ENOPROTOOPT);
-}
-
-
-int
-ss_getsockopt(arg, ret, p)
- struct ss_socketopt_args *arg;
- int *ret;
- struct proc *p;
-{
- int error, optname;
- int retval[2];
-
- if (arg->level != 0xffff) /* FreeBSD, SCO and ? */
- return (ENOPROTOOPT);
-
- optname = ss_convert(sopt_whatevers, &arg->name, 0);
-
- switch (optname) {
-
- case SO_ACCEPTCONN:
- case SO_BROADCAST:
- case SO_DEBUG:
- case SO_DONTROUTE:
- case SO_ERROR:
- case SO_KEEPALIVE:
- case SO_LINGER:
- case SO_OOBINLINE:
- case SO_RCVBUF:
- case SO_RCVLOWAT:
- case SO_RCVTIMEO:
- case SO_REUSEADDR:
- case SO_SNDBUF:
- case SO_SNDLOWAT:
- case SO_SNDTIMEO:
- case SO_TYPE:
- case SO_USELOOPBACK:
- error = SYSCALLX(SYS_getsockopt, arg);
- *ret = retval[0];
- *(ret + 1) = retval[1];
- return(error);
-
-
- case SO_PROTOTYPE: {
- int value = 0;
-
- error = copyout((caddr_t)&value, (caddr_t)arg->s, sizeof(int));
- return(error);
- }
-
-
- case SO_IMASOCKET: {
- int value = 1;
-
- error = copyout((caddr_t)&value, (caddr_t)arg->s, sizeof(int));
- return(error);
- }
-
- case SO_NO_CHECK:
- case SO_ORDREL:
- case SO_PRIORITY:
- return (ENOPROTOOPT);
- }
-
- return (ENOPROTOOPT);
-}
-
-#define SS_CONVERT
-int system_type = SS_FREEBSD; /* FreeBSD */
-
-int
-ss_convert(what, this, otherwise)
- struct whatever **what;
- int *this;
- int otherwise;
-{
- struct whatever *specific;
-
- if(!(specific = what[system_type]))
- return *this;
-
- for (; specific->from != -1; specific++)
- if(specific->from <= *this && *this <= specific->to)
- if(specific->from == specific->to){
- if(specific->more){
- specific = specific->more;
- this++;
- continue;
- }
- else {
- return((int)specific->conversion);
- }
- }
- else {
- return(specific->conversion ? (
- specific->all_the_same ? (int)specific->conversion : specific->conversion[*this - specific->from] ) : *this);
- }
-
- return otherwise;
-}
-
-/* Returns 0 - no conversion, no pointer modification
- 1 - converted, relevant pointer modification
- -1 - error
- */
-int
-ss_convert_struct(alien, indicator, direction)
- char *alien;
- int indicator;
- int direction;
-{
-int error, len;
-
- switch (system_type) {
-
- case SS_FREEBSD:
- return(0);
- case SS_SYSVR4:
- case SS_SYSVR3:
- case SS_SCO_32:
- case SS_WYSE_321:
- case SS_ISC:
- case SS_LINUX:
-
- switch(direction){
-
- case SS_ALIEN_TO_NATIVE:
-
- error = ss_atn(alien, indicator);
-#ifdef SS_DEBUG
- if(ss_debug > 1)
- printf("ss_convert: ATN ss_atn error %d\n",error);
-#endif /* SS_DEBUG */
- return(error);
-
- case SS_NATIVE_TO_ALIEN:
-
- error = ss_nta(alien, indicator);
-#ifdef SS_DEBUG
- if(ss_debug > 1)
- printf("ss_convert: NTA ss_nta error %d\n",error);
-#endif /* SS_DEBUG */
- return(error);
-
- }
-
- default:
-
- printf("ss_convert_struct: not expecting system_type %d\n", system_type);
- break;
-
- }
- return(EINVAL);
-}
-
-/* note sockaddr_un linux unsigned short fam, 108 path
- BSD uchar , uchar 104 */
-int
-ss_atn(alien, indicator)
- char *alien;
- int indicator;
-{
-int error;
-
- switch (indicator) {
-
- case SS_STRUCT_ARPREQ:
- /* compatible */
- return(0);
-
- case SS_STRUCT_IFCONF:
- /* compatible */
- return(0);
-
- case SS_STRUCT_IFREQ:
- /* length OK - more unions - function dependent */
- return(0);
-
- case SS_STRUCT_ORTENTRY:
- /* compatible */
- return(0);
-
- case SS_STRUCT_SOCKADDR:{
- struct native_hdr {
- u_char len;
- u_char family;
- };
- union hdr_part {
- struct native_hdr native;
- u_short alien_family;
- } hdr;
-
- if(error = copyin((caddr_t)alien,(caddr_t)&hdr,sizeof(hdr)))
- return(error);
-#ifdef SS_DEBUG
- if(ss_debug > 1)
- printf("ss_atn:copyin 0x%x\n",hdr.alien_family);
-#endif /* SS_DEBUG */
-
- if( hdr.alien_family < AF_MAX){
- hdr.native.family = hdr.alien_family >> 8; /* 386 endianess */
- /* OR LEN FOM A PARAM ? */
- hdr.native.len = sizeof(struct sockaddr);
-#ifdef SS_DEBUG
- if(ss_debug > 1)
- printf("ss_atn:copyout 0x%x\n",hdr.alien_family);
-#endif /* SS_DEBUG */
- error = copyout((caddr_t)&hdr,(caddr_t)alien,sizeof(hdr));
- return(error);
- }
- else {
- printf("ss_atn: sa_family = %d\n", hdr.alien_family);
- return(EINVAL);
- }
-
- }
-
- case SS_STRUCT_SOCKNEWPROTO:
- /* don't have */
- printf("ss_atn: not expecting SS_STRUCT_SOCKNEWPROTO\n");
- return(EINVAL);
-
- default:
- printf("ss_atn: not expecting case %d\n",indicator);
- return(EINVAL);
-
- }
-}
-
-/* note sockaddr_un linux unsigned short fam, 108 path
- BSD uchar , uchar 104 */
-int
-ss_nta(alien, indicator)
- char *alien;
- int indicator;
-{
-int error;
-
- switch (indicator) {
-
- case SS_STRUCT_ARPREQ:
- /* compatible */
- return(0);
-
- case SS_STRUCT_IFCONF:
- /* compatible */
- return(0);
-
- case SS_STRUCT_IFREQ:
- /* length OK - more unions - function dependent */
- return(0);
-
- case SS_STRUCT_ORTENTRY:
- /* compatible */
- return(0);
-
- case SS_STRUCT_SOCKADDR:{
- struct native_hdr {
- u_char len;
- u_char family;
- };
- union hdr_part {
- struct native_hdr native;
- u_short alien_family;
- } hdr;
-
- if(error = copyin((caddr_t)alien,(caddr_t)&hdr,sizeof(hdr)))
- return(error);
-#ifdef SS_DEBUG
- if(ss_debug > 1)
- printf("ss_nta:copyin 0x%x\n",hdr.alien_family);
-#endif /* SS_DEBUG */
- hdr.alien_family = hdr.native.family;
-#ifdef SS_DEBUG
- if(ss_debug > 1)
- printf("ss_nta:copyout 0x%x\n",hdr.alien_family);
-#endif /* SS_DEBUG */
- error = copyout((caddr_t)&hdr,(caddr_t)alien,sizeof(hdr));
- return(error);
- }
-
- case SS_STRUCT_SOCKNEWPROTO:
- /* don't have */
- printf("ss_nta: not expecting SS_STRUCT_SOCKNEWPROTO\n");
- return(EINVAL);
+ 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 accept(p, realargs+1, retval);
+ case SOCKSYS_BIND:
+ return bind(p, realargs+1, retval);
+ case SOCKSYS_CONNECT:
+ return connect(p, realargs+1, retval);
+ case SOCKSYS_GETPEERNAME:
+ return getpeername(p, realargs+1, retval);
+ case SOCKSYS_GETSOCKNAME:
+ return getsockname(p, realargs+1, retval);
+ case SOCKSYS_GETSOCKOPT:
+ return getsockopt(p, realargs+1, retval);
+ case SOCKSYS_LISTEN:
+ return listen(p, realargs+1, retval);
+ case SOCKSYS_RECV:
+ realargs[5] = realargs[6] = 0;
+ /* FALLTHROUGH */
+ case SOCKSYS_RECVFROM:
+ return recvfrom(p, realargs+1, retval);
+ case SOCKSYS_SEND:
+ realargs[5] = realargs[6] = 0;
+ /* FALLTHROUGH */
+ case SOCKSYS_SENDTO:
+ return sendto(p, realargs+1, retval);
+ case SOCKSYS_SETSOCKOPT:
+ return setsockopt(p, realargs+1, retval);
+ case SOCKSYS_SHUTDOWN:
+ return shutdown(p, realargs+1, retval);
+ case SOCKSYS_SOCKET:
+ return socket(p, realargs+1, retval);
+ case SOCKSYS_SELECT:
+ return select(p, realargs+1, retval);
+ case SOCKSYS_GETIPDOMAIN:
+ return compat_09_getdomainname(p, realargs + 1, retval);
+ case SOCKSYS_SETIPDOMAIN:
+ return compat_09_setdomainname(p, realargs + 1, retval);
+ case SOCKSYS_ADJTIME:
+ return adjtime(p, realargs + 1, retval);
+ case SOCKSYS_SETREUID:
+ return compat_43_setreuid(p, realargs + 1, retval);
+ case SOCKSYS_SETREGID:
+ return compat_43_setregid(p, realargs + 1, retval);
+ case SOCKSYS_GETTIME:
+ return gettimeofday(p, realargs + 1, retval);
+ case SOCKSYS_SETTIME:
+ return settimeofday(p, realargs + 1, retval);
+ case SOCKSYS_GETITIMER:
+ return getitimer(p, realargs + 1, retval);
+ case SOCKSYS_SETITIMER:
+ return setitimer(p, realargs + 1, retval);
default:
- printf("ss_nta: not expecting case %d\n",indicator);
- return(EINVAL);
-
+ 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/i386/ibcs2/ibcs2_socksys.h b/sys/i386/ibcs2/ibcs2_socksys.h
index 11a1b20..bc89180 100644
--- a/sys/i386/ibcs2/ibcs2_socksys.h
+++ b/sys/i386/ibcs2/ibcs2_socksys.h
@@ -1,21 +1,15 @@
-/*-
- * Copyright (c) 1994 Mostyn Lewis
+/*
+ * Copyright (c) 1994, 1995 Scott Bartram
+ * Copyright (c) 1994 Arne H Juul
* All rights reserved.
*
- * This software is based on code which is:
- * Copyright (c) 1994 Mike Jagdis (jaggy@purplet.demon.co.uk)
- *
* 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
- * in this position and unchanged.
- * 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 withough specific prior written permission
+ * 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
@@ -27,372 +21,98 @@
* 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.
- *
- * $Id: ibcs2_socksys.h,v 1.2 1994/10/13 23:10:58 sos Exp $
*/
-#define SS_DEBUG
-
-struct ss_call {
- int arg[7];
-};
-
-/* Alien socket */
-struct alien_sockaddr {
- unsigned short sa_family; /* address family, AF_xxx */
- char sa_data[14]; /* 14 bytes of protocol address */
-};
-
-struct alien_in_addr {
- unsigned long int s_addr;
-};
-#define __ALIEN_SOCK_SIZE__ 16 /* sizeof(struct alien_sockaddr)*/
-struct alien_sockaddr_in {
- short int sin_family; /* Address family */
- unsigned short int sin_port; /* Port number */
- struct alien_in_addr sin_addr; /* Internet address */
- unsigned char __filling[__ALIEN_SOCK_SIZE__ - sizeof(short int) -
- sizeof(unsigned short int) - sizeof(struct alien_in_addr)];
-};
-
-struct sgdomarg {
- char *name;
- int namelen;
-};
-
-struct lstatarg {
- char *fname;
- void *statb;
+#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; /* address family (AF_INET, etc.) */
- int type; /* protocol type (SOCK_STREAM, etc.) */
- int proto; /* per family proto number */
- dev_t dev; /* major/minor to use (must be a clone) */
- int flags; /* protosw flags */
-};
-
-/* System type ordinals */
-#define SS_FREEBSD 0
-#define SS_SYSVR4 1
-#define SS_SYSVR3 2
-#define SS_SCO_32 3
-#define SS_WYSE_321 4
-#define SS_ISC 5
-#define SS_LINUX 6
-
-
-/* Socksys macros */
-#define IOCTL(cmd) \
- if(error = ss_IOCTL(fp, cmd, arg, p))\
- return(error);
-#define SYSCALL(number,conv_arg,indicator) \
- if(error = ss_SYSCALL(number,conv_arg,indicator,arg,p,retval))\
- return(error);
-#define SYSCALL_N(number,conv_arg,indicator) \
- arg = (caddr_t)(((int *)arg) - 1);\
- if(error = ss_SYSCALL(number,conv_arg,indicator,arg,p,retval))\
- return(error);
-#define SYSCALLX(number,arg) (*sysent[number].sy_call)(p, (caddr_t)arg, retval)
-#define SYSCALL_RETURN(number) SYSCALL(number) ; IBCS2_MAGIC_RETURN
-
-/* Socksys commands */
-#define CMD_SO_ACCEPT 1
-#define CMD_SO_BIND 2
-#define CMD_SO_CONNECT 3
-#define CMD_SO_GETPEERNAME 4
-#define CMD_SO_GETSOCKNAME 5
-#define CMD_SO_GETSOCKOPT 6
-#define CMD_SO_LISTEN 7
-#define CMD_SO_RECV 8
-#define CMD_SO_RECVFROM 9
-#define CMD_SO_SEND 10
-#define CMD_SO_SENDTO 11
-#define CMD_SO_SETSOCKOPT 12
-#define CMD_SO_SHUTDOWN 13
-#define CMD_SO_SOCKET 14
-#define CMD_SO_SELECT 15
-#define CMD_SO_GETIPDOMAIN 16
-#define CMD_SO_SETIPDOMAIN 17
-#define CMD_SO_ADJTIME 18
-#define CMD_SO_SETREUID 19
-#define CMD_SO_SETREGID 20
-#define CMD_SO_GETTIME 21
-#define CMD_SO_SETTIME 22
-#define CMD_SO_GETITIMER 23
-#define CMD_SO_SETITIMER 24
-
-#define CMD_SO_SS_DEBUG 255
-
-/* socksys ioctls */
-#define SS_IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
-#define SS_IOC_VOID 0x20000000 /* no parameters */
-#define SS_IOC_OUT 0x40000000 /* copy out parameters */
-#define SS_IOC_IN 0x80000000 /* copy in parameters */
-#define SS_IOC_INOUT (SS_IOC_IN|SS_IOC_OUT)
-
-#define SS_IO(x,y) (SS_IOC_VOID|(x<<8)|y)
-#define SS_IOR(x,y,t) (SS_IOC_OUT|((sizeof(t)&SS_IOCPARM_MASK)<<16)|(x<<8)|y)
-#define SS_IOW(x,y,t) (SS_IOC_IN|((sizeof(t)&SS_IOCPARM_MASK)<<16)|(x<<8)|y)
-#define SS_IOWR(x,y,t) (SS_IOC_INOUT|((sizeof(t)&SS_IOCPARM_MASK)<<16)|(x<<8)|y)
-
-#define SS_SIOCSHIWAT SS_IOW ('S', 1, int) /* set high watermark */
-#define SS_SIOCGHIWAT SS_IOR ('S', 2, int) /* get high watermark */
-#define SS_SIOCSLOWAT SS_IOW ('S', 3, int) /* set low watermark */
-#define SS_SIOCGLOWAT SS_IOR ('S', 4, int) /* get low watermark */
-#define SS_SIOCATMARK SS_IOR ('S', 5, int) /* at oob mark? */
-#define SS_SIOCSPGRP SS_IOW ('S', 6, int) /* set process group */
-#define SS_SIOCGPGRP SS_IOR ('S', 7, int) /* get process group */
-#define SS_FIONREAD SS_IOR ('S', 8, int)
-#define SS_FIONBIO SS_IOW ('S', 9, int)
-#define SS_FIOASYNC SS_IOW ('S', 10, int)
-#define SS_SIOCPROTO SS_IOW ('S', 11, struct socknewproto) /* link proto */
-#define SS_SIOCGETNAME SS_IOR ('S', 12, struct sockaddr) /* getsockname */
-#define SS_SIOCGETPEER SS_IOR ('S', 13,struct sockaddr) /* getpeername */
-#define SS_IF_UNITSEL SS_IOW ('S', 14, int)/* set unit number */
-#define SS_SIOCXPROTO SS_IO ('S', 15) /* empty proto table */
-
-#define SS_SIOCADDRT SS_IOW ('R', 9, struct ortentry) /* add route */
-#define SS_SIOCDELRT SS_IOW ('R', 10, struct ortentry)/* delete route */
-
-#define SS_SIOCSIFADDR SS_IOW ('I', 11, struct ifreq)/* set ifnet address */
-#define SS_SIOCGIFADDR SS_IOWR('I', 12, struct ifreq)/* get ifnet address */
-#define SS_SIOCSIFDSTADDR SS_IOW ('I', 13, struct ifreq)/* set p-p address */
-#define SS_SIOCGIFDSTADDR SS_IOWR('I', 14,struct ifreq) /* get p-p address */
-#define SS_SIOCSIFFLAGS SS_IOW ('I', 15, struct ifreq)/* set ifnet flags */
-#define SS_SIOCGIFFLAGS SS_IOWR('I', 16, struct ifreq)/* get ifnet flags */
-#define SS_SIOCGIFCONF SS_IOWR('I', 17, struct ifconf)/* get ifnet list */
-
-#define SS_SIOCSIFMTU SS_IOW ('I', 21, struct ifreq)/* get if_mtu */
-#define SS_SIOCGIFMTU SS_IOWR('I', 22, struct ifreq)/* set if_mtu */
-
-#define SS_SIOCIFDETACH SS_IOW ('I', 26, struct ifreq)/* detach interface */
-#define SS_SIOCGENPSTATS SS_IOWR('I', 27, struct ifreq)/* get ENP stats */
-
-#define SS_SIOCX25XMT SS_IOWR('I', 29, struct ifreq)/* start a slp proc in x25if */
-#define SS_SIOCX25RCV SS_IOWR('I', 30, struct ifreq)/* start a slp proc in x25if */
-#define SS_SIOCX25TBL SS_IOWR('I', 31, struct ifreq)/* xfer lun table to kernel */
-
-#define SS_SIOCGIFBRDADDR SS_IOWR('I', 32, struct ifreq)/* get broadcast addr */
-#define SS_SIOCSIFBRDADDR SS_IOW ('I', 33, struct ifreq)/* set broadcast addr */
-#define SS_SIOCGIFNETMASK SS_IOWR('I', 34, struct ifreq)/* get net addr mask */
-#define SS_SIOCSIFNETMASK SS_IOW ('I', 35, struct ifreq)/* set net addr mask */
-#define SS_SIOCGIFMETRIC SS_IOWR('I', 36, struct ifreq)/* get IF metric */
-#define SS_SIOCSIFMETRIC SS_IOW ('I', 37, struct ifreq)/* set IF metric */
-
-#define SS_SIOCSARP SS_IOW ('I', 38, struct arpreq)/* set arp entry */
-#define SS_SIOCGARP SS_IOWR('I', 39, struct arpreq)/* get arp entry */
-#define SS_SIOCDARP SS_IOW ('I', 40, struct arpreq)/* delete arp entry */
-
-#define SS_SIOCSIFNAME SS_IOW ('I', 41, struct ifreq)/* set interface name */
-#define SS_SIOCGIFONEP SS_IOWR('I', 42, struct ifreq)/* get 1-packet parms */
-#define SS_SIOCSIFONEP SS_IOW ('I', 43, struct ifreq)/* set 1-packet parms */
-
-#define SS_SIOCGENADDR SS_IOWR('I', 65, struct ifreq)/* Get ethernet addr */
-
-#define SS_SIOCSOCKSYS SS_IOW ('I', 66, struct ss_call)/* ss syscall */
-
-
-/*
- * NFS/NIS has a pseudo device called /dev/nfsd which may accept ioctl
- * calls. /dev/nfsd is linked to /dev/socksys.
- */
-
-#define NIOCNFSD 1
-#define NIOCOLDGETFH 2
-#define NIOCASYNCD 3
-#define NIOCSETDOMNAM 4
-#define NIOCGETDOMNAM 5
-#define NIOCCLNTHAND 6
-#define NIOCEXPORTFS 7
-#define NIOCGETFH 8
-#define NIOCLSTAT 9
-
-
-/*
- * noso
- */
-
-#define SO_ORDREL 0xff02
-#define SO_IMASOCKET 0xff03
-#define SO_PROTOTYPE 0xff04
-/* Check below */
-#define SO_NO_CHECK 11
-#define SO_PRIORITY 12
-
-/*
- * convert
- */
-
-/* Structure conversion indicators */
-
-#define SS_STRUCT_ARPREQ 1
-#define SS_STRUCT_IFCONF 2
-#define SS_STRUCT_IFREQ 3
-#define SS_STRUCT_ORTENTRY 4
-#define SS_STRUCT_SOCKADDR 5
-#define SS_STRUCT_SOCKNEWPROTO 6
-
-#define SS_ALIEN_TO_NATIVE 1
-#define SS_NATIVE_TO_ALIEN 2
-
-struct whatever {
- int from, to;
- unsigned char *conversion;
- unsigned char all_the_same;
- struct whatever *more;
-};
-
-
-extern struct whatever *af_whatevers[];
-extern struct whatever *type_whatevers[];
-extern struct whatever *sopt_whatevers[];
-extern struct whatever *struct_whatevers[];
-
-extern int ss_convert(struct whatever **what, int *this, int otherwise);
-extern int ss_convert_struct(char *alien, int indicator, int direction);
-
-/*
- * convert af
- */
-
-
-static struct whatever af_whatevers_all[] = {
- { 0, 2, NULL, 0, 0 },
- { -1 }
-};
-
-
-struct whatever *af_whatevers[] = {
- NULL, /* FreeBSD */
- af_whatevers_all, /* SysVR4 */
- af_whatevers_all, /* SysVR3 */
- af_whatevers_all, /* SCO 3.2.[24] */
- af_whatevers_all, /* Wyse Unix V/386 3.2.1 */
- af_whatevers_all, /* ISC */
- af_whatevers_all /* Linux */
-};
-
-/*
- * convert sopt
- */
-
-static struct whatever sopt_whatevers_all[] = {
- { 0x0001, 0x0001, (char *)SO_DEBUG, 0, 0 },
- { 0x0002, 0x0002, (char *)SO_ACCEPTCONN, 0, 0 },
- { 0x0004, 0x0004, (char *)SO_REUSEADDR, 0, 0 },
- { 0x0008, 0x0008, (char *)SO_KEEPALIVE, 0, 0 },
- { 0x0010, 0x0010, (char *)SO_DONTROUTE, 0, 0 },
- { 0x0020, 0x0020, (char *)SO_BROADCAST, 0, 0 },
- { 0x0040, 0x0040, (char *)SO_USELOOPBACK, 0, 0 },
- { 0x0080, 0x0080, (char *)SO_LINGER, 0, 0 },
- { 0x0100, 0x0100, (char *)SO_OOBINLINE, 0, 0 },
- { 0x0200, 0x0200, (char *)SO_ORDREL, 0, 0 },
- { 0x0400, 0x0400, (char *)SO_IMASOCKET, 0, 0 },
- { 0x1001, 0x1001, (char *)SO_SNDBUF, 0, 0 },
- { 0x1002, 0x1001, (char *)SO_RCVBUF, 0, 0 },
- { 0x1003, 0x1001, (char *)SO_SNDLOWAT, 0, 0 },
- { 0x1004, 0x1001, (char *)SO_RCVLOWAT, 0, 0 },
- { 0x1005, 0x1001, (char *)SO_SNDTIMEO, 0, 0 },
- { 0x1006, 0x1001, (char *)SO_RCVTIMEO, 0, 0 },
- { 0x1007, 0x1001, (char *)SO_ERROR, 0, 0 },
- { 0x1008, 0x1001, (char *)SO_TYPE, 0, 0 },
- { 0x1009, 0x1001, (char *)SO_PROTOTYPE, 0, 0 },
- { -1 }
-};
-
-
-struct whatever *sopt_whatevers[] = {
- NULL, /* FreeBSD */
- sopt_whatevers_all, /* SysVR4 */
- sopt_whatevers_all, /* SysVR3 */
- sopt_whatevers_all, /* SCO 3.2.[24] */
- sopt_whatevers_all, /* Wyse Unix V/386 3.2.1 */
- sopt_whatevers_all, /* ISC */
- sopt_whatevers_all /* Linux */
+ int family;
+ int type;
+ int proto;
+ ibcs2_dev_t dev;
+ int flags;
};
-/*
- * convert struct
- */
-
-static struct whatever struct_whatever_typeI_ranges[] = {
- { 11, 16, (char *)SS_STRUCT_IFREQ , 1, 0 }, /* OK */
- { 17, 17, (char *)SS_STRUCT_IFCONF , 1, 0 }, /* OK */
- { 21, 22, (char *)SS_STRUCT_IFREQ , 1, 0 }, /* SIZE OK */
- { 26, 27, (char *)SS_STRUCT_IFREQ , 1, 0 }, /* SIZE OK */
- { 29, 37, (char *)SS_STRUCT_IFREQ , 1, 0 }, /* SIZE OK */
- { 38, 40, (char *)SS_STRUCT_ARPREQ , 1, 0 }, /* OK */
- { 41, 43, (char *)SS_STRUCT_IFREQ , 1, 0 }, /* SIZE OK */
- { 65, 65, (char *)SS_STRUCT_IFREQ , 1, 0 }, /* SIZE OK */
- { -1 }
-};
-
-static struct whatever struct_whatever_typeR_ranges[] = {
- { 9, 10, (char *)SS_STRUCT_ORTENTRY , 1, 0 }, /* SIZE OK */
- { -1 }
-};
-
-static struct whatever struct_whatever_typeS_ranges[] = {
- { 1, 10, 0 , 1, 0 },
- { 11, 11, (char *)SS_STRUCT_SOCKNEWPROTO, 1, 0 }, /* NO SUPPORT */
- { 12, 13, (char *)SS_STRUCT_SOCKADDR , 1, 0 }, /* len and family */
- { 14, 15, 0 , 1, 0 },
- { -1 }
-};
-
-static struct whatever struct_whatevers_all[] = {
- { 'I', 'I', 0, 0, struct_whatever_typeI_ranges },
- { 'R', 'R', 0, 0, struct_whatever_typeR_ranges },
- { 'S', 'S', 0, 0, struct_whatever_typeS_ranges },
- { -1 }
-};
-
-struct whatever *struct_whatevers[] = {
- struct_whatevers_all, /* FreeBSD */
- struct_whatevers_all, /* SysVR4 */
- struct_whatevers_all, /* SysVR3 */
- struct_whatevers_all, /* SCO 3.2.[24] */
- struct_whatevers_all, /* Wyse Unix V/386 3.2.1 */
- struct_whatevers_all, /* ISC */
- struct_whatevers_all /* Linux */
-};
-
-int ss_struct_native_sizes[] = {
- sizeof(struct arpreq),
- sizeof(struct ifconf),
- sizeof(struct ifreq),
- sizeof(struct rtentry),
- sizeof(struct sockaddr),
- sizeof(struct socknewproto)
-};
-
-/*
- * convert type
- */
-
-static char type_conversion_SysVr4_range1[] = {
- SOCK_DGRAM,
- SOCK_STREAM,
- 0,
- SOCK_RAW,
- SOCK_RDM,
- SOCK_SEQPACKET
-};
-
-static struct whatever type_whatevers_SysVr4[] = {
- { 1, 6, type_conversion_SysVr4_range1, 0 },
- { -1 }
-};
-
-struct whatever *type_whatevers[] = {
- NULL, /* FreeBSD */
- type_whatevers_SysVr4, /* SysVR4 */
- NULL, /* SysVR3 */
- NULL, /* SCO 3.2.[24] */
- NULL, /* Wyse Unix V/386 3.2.1 */
- NULL, /* ISC */
- NULL /* Linux */
-};
+#endif /* _IBCS2_SOCKSYS_H */
diff --git a/sys/i386/ibcs2/ibcs2_stat.c b/sys/i386/ibcs2/ibcs2_stat.c
new file mode 100644
index 0000000..a9d5c4b
--- /dev/null
+++ b/sys/i386/ibcs2/ibcs2_stat.c
@@ -0,0 +1,244 @@
+/*
+ * 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_statfs(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_statfs_args *uap;
+ int *retval;
+{
+ register struct mount *mp;
+ register struct statfs *sp;
+ int error;
+ struct nameidata nd;
+ caddr_t sg = stackgap_init();
+
+ CHECKALTEXIST(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_fstatfs(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_fstatfs_args *uap;
+ int *retval;
+{
+ 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_stat(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_stat_args *uap;
+ int *retval;
+{
+ struct ostat st;
+ struct ibcs2_stat ibcs2_st;
+ struct compat_43_stat_args cup;
+ int error;
+ caddr_t sg = stackgap_init();
+
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(st));
+ if (error = compat_43_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_lstat(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_lstat_args *uap;
+ int *retval;
+{
+ struct ostat st;
+ struct ibcs2_stat ibcs2_st;
+ struct compat_43_lstat_args cup;
+ int error;
+ caddr_t sg = stackgap_init();
+
+ CHECKALTEXIST(p, &sg, SCARG(uap, path));
+ SCARG(&cup, path) = SCARG(uap, path);
+ SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(st));
+ if (error = compat_43_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_fstat(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_fstat_args *uap;
+ int *retval;
+{
+ struct ostat st;
+ struct ibcs2_stat ibcs2_st;
+ struct compat_43_fstat_args cup;
+ int error;
+ caddr_t sg = stackgap_init();
+
+ SCARG(&cup, fd) = SCARG(uap, fd);
+ SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(st));
+ if (error = compat_43_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_utssys(p, uap, retval)
+ struct proc *p;
+ struct ibcs2_utssys_args *uap;
+ int *retval;
+{
+ 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/i386/ibcs2/ibcs2_stat.h b/sys/i386/ibcs2/ibcs2_stat.h
new file mode 100644
index 0000000..2eb0102
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_statfs.h b/sys/i386/ibcs2/ibcs2_statfs.h
new file mode 100644
index 0000000..d6e0100
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_stropts.h b/sys/i386/ibcs2/ibcs2_stropts.h
new file mode 100644
index 0000000..4d26e73
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_syscall.h b/sys/i386/ibcs2/ibcs2_syscall.h
new file mode 100644
index 0000000..f02ad42
--- /dev/null
+++ b/sys/i386/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.4 1995/03/14 15:12:52 scottb Exp
+ */
+
+#define IBCS2_SYS_syscall 0
+#define IBCS2_SYS_exit 1
+#define IBCS2_SYS_fork 2
+#define IBCS2_SYS_ibcs2_read 3
+#define IBCS2_SYS_write 4
+#define IBCS2_SYS_ibcs2_open 5
+#define IBCS2_SYS_close 6
+#define IBCS2_SYS_ibcs2_waitsys 7
+#define IBCS2_SYS_ibcs2_creat 8
+#define IBCS2_SYS_link 9
+#define IBCS2_SYS_ibcs2_unlink 10
+#define IBCS2_SYS_ibcs2_execv 11
+#define IBCS2_SYS_ibcs2_chdir 12
+#define IBCS2_SYS_ibcs2_time 13
+#define IBCS2_SYS_ibcs2_mknod 14
+#define IBCS2_SYS_ibcs2_chmod 15
+#define IBCS2_SYS_ibcs2_chown 16
+#define IBCS2_SYS_obreak 17
+#define IBCS2_SYS_ibcs2_stat 18
+#define IBCS2_SYS_compat_43_lseek 19
+#define IBCS2_SYS_getpid 20
+#define IBCS2_SYS_ibcs2_mount 21
+#define IBCS2_SYS_ibcs2_umount 22
+#define IBCS2_SYS_ibcs2_setuid 23
+#define IBCS2_SYS_getuid 24
+#define IBCS2_SYS_ibcs2_stime 25
+#define IBCS2_SYS_ibcs2_alarm 27
+#define IBCS2_SYS_ibcs2_fstat 28
+#define IBCS2_SYS_ibcs2_pause 29
+#define IBCS2_SYS_ibcs2_utime 30
+#define IBCS2_SYS_ibcs2_access 33
+#define IBCS2_SYS_ibcs2_nice 34
+#define IBCS2_SYS_ibcs2_statfs 35
+#define IBCS2_SYS_sync 36
+#define IBCS2_SYS_ibcs2_kill 37
+#define IBCS2_SYS_ibcs2_fstatfs 38
+#define IBCS2_SYS_ibcs2_pgrpsys 39
+#define IBCS2_SYS_dup 41
+#define IBCS2_SYS_pipe 42
+#define IBCS2_SYS_ibcs2_times 43
+#define IBCS2_SYS_ibcs2_plock 45
+#define IBCS2_SYS_ibcs2_setgid 46
+#define IBCS2_SYS_getgid 47
+#define IBCS2_SYS_ibcs2_sigsys 48
+#define IBCS2_SYS_ibcs2_msgsys 49
+#define IBCS2_SYS_ibcs2_shmsys 52
+#define IBCS2_SYS_ibcs2_semsys 53
+#define IBCS2_SYS_ibcs2_ioctl 54
+#define IBCS2_SYS_ibcs2_uadmin 55
+#define IBCS2_SYS_ibcs2_utssys 57
+#define IBCS2_SYS_ibcs2_execve 59
+#define IBCS2_SYS_umask 60
+#define IBCS2_SYS_chroot 61
+#define IBCS2_SYS_ibcs2_fcntl 62
+#define IBCS2_SYS_ibcs2_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_ibcs2_rmdir 79
+#define IBCS2_SYS_ibcs2_mkdir 80
+#define IBCS2_SYS_ibcs2_getdents 81
+#define IBCS2_SYS_ibcs2_sysfs 84
+#define IBCS2_SYS_ibcs2_getmsg 85
+#define IBCS2_SYS_ibcs2_putmsg 86
+#define IBCS2_SYS_ibcs2_poll 87
+#define IBCS2_SYS_ibcs2_symlink 90
+#define IBCS2_SYS_ibcs2_lstat 91
+#define IBCS2_SYS_ibcs2_readlink 92
+#define IBCS2_SYS_sigreturn 103
+#define IBCS2_SYS_xenix_rdchk 135
+#define IBCS2_SYS_xenix_chsize 138
+#define IBCS2_SYS_xenix_ftime 139
+#define IBCS2_SYS_xenix_nap 140
+#define IBCS2_SYS_select 164
+#define IBCS2_SYS_ibcs2_sigaction 167
+#define IBCS2_SYS_ibcs2_sigprocmask 168
+#define IBCS2_SYS_ibcs2_sigpending 169
+#define IBCS2_SYS_ibcs2_sigsuspend 170
+#define IBCS2_SYS_ibcs2_getgroups 171
+#define IBCS2_SYS_ibcs2_setgroups 172
+#define IBCS2_SYS_ibcs2_sysconf 173
+#define IBCS2_SYS_ibcs2_pathconf 174
+#define IBCS2_SYS_ibcs2_fpathconf 175
+#define IBCS2_SYS_ibcs2_rename 176
+#define IBCS2_SYS_MAXSYSCALL 177
diff --git a/sys/i386/ibcs2/ibcs2_sysent.c b/sys/i386/ibcs2/ibcs2_sysent.c
index 1f1422d..c7e9fb3 100644
--- a/sys/i386/ibcs2/ibcs2_sysent.c
+++ b/sys/i386/ibcs2/ibcs2_sysent.c
@@ -1,500 +1,534 @@
-/*-
- * Copyright (c) 1994 Søren Schmidt
- * Copyright (c) 1994 Sean Eric Fagan
- * All rights reserved.
+/*
+ * System call switch table.
*
- * 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
- * in this position and unchanged.
- * 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 withough 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.
- *
- * $Id: ibcs2_sysent.c,v 1.14 1994/10/13 23:10:58 sos Exp $
+ * DO NOT EDIT-- this file is automatically generated.
+ * created from NetBSD: syscalls.master,v 1.4 1995/03/14 15:12:52 scottb Exp
*/
-#include <i386/ibcs2/ibcs2.h>
#include <sys/param.h>
+#include <compat/ibcs2/ibcs2_types.h>
+#include <compat/ibcs2/ibcs2_signal.h>
+#include <compat/ibcs2/ibcs2_statfs.h>
#include <sys/systm.h>
#include <sys/signal.h>
-#include <sys/sysent.h>
-
-#define NERR 80 /* XXX must match sys/errno.h */
-
-/* errno conversion tables */
-int bsd_to_svr3_errno[NERR] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
- 10, 45, 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
- 30, 31, 32, 33, 34, 11, 91, 92, 93, 94,
- 95, 96,118, 97, 98, 99,100,101,102,103,
- 104,105,106,107,108, 63,110,111,112,113,
- 114,115, 31, 78,116,117,145, 11, 11, 11,
- 0, 66, 0, 0, 0, 0, 0, 46, 89, 0,
-};
-
-/* function defines */
-int ibcs2_access();
-int ibcs2_advfs();
-int ibcs2_alarm();
-int ibcs2_break();
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <compat/ibcs2/ibcs2_syscallargs.h>
+int nosys();
+int exit();
+int fork();
+int ibcs2_read();
+int write();
+int ibcs2_open();
+int close();
+int ibcs2_waitsys();
+int ibcs2_creat();
+int link();
+int ibcs2_unlink();
+int ibcs2_execv();
int ibcs2_chdir();
+int ibcs2_time();
+int ibcs2_mknod();
int ibcs2_chmod();
int ibcs2_chown();
-int ibcs2_chroot();
-int ibcs2_cisc();
-int ibcs2_clocal();
-int ibcs2_close();
-int ibcs2_creat();
-int ibcs2_cxenix();
-int ibcs2_dup();
-int ibcs2_exec();
-int ibcs2_exece();
-int ibcs2_exit();
-int ibcs2_fcntl();
-int ibcs2_fork();
+int obreak();
+int ibcs2_stat();
+int compat_43_lseek();
+int getpid();
+int ibcs2_mount();
+int ibcs2_umount();
+int ibcs2_setuid();
+int getuid();
+int ibcs2_stime();
+int ibcs2_alarm();
int ibcs2_fstat();
-int ibcs2_fstatfs();
-int ibcs2_fsync();
-int ibcs2_getdents();
-int ibcs2_getgid();
-int ibcs2_getmsg();
-int ibcs2_getpid();
-int ibcs2_getuid();
-int ibcs2_gtime();
-int ibcs2_gtty();
-int ibcs2_ioctl();
-int ibcs2_kill();
-int ibcs2_libattach();
-int ibcs2_libdetach();
-int ibcs2_link();
-int ibcs2_lstat();
-int ibcs2_mkdir();
-int ibcs2_mknod();
-int ibcs2_msgsys();
-int ibcs2_nice();
-int ibcs2_nosys();
-int ibcs2_open();
int ibcs2_pause();
-int ibcs2_pipe();
+int ibcs2_utime();
+int ibcs2_access();
+int ibcs2_nice();
+int ibcs2_statfs();
+int sync();
+int ibcs2_kill();
+int ibcs2_fstatfs();
+int ibcs2_pgrpsys();
+int dup();
+int pipe();
+int ibcs2_times();
int ibcs2_plock();
-int ibcs2_poll();
-int ibcs2_procids();
-int ibcs2_profil();
-int ibcs2_ptrace();
-int ibcs2_putmsg();
-int ibcs2_read();
-int ibcs2_readlink();
-int ibcs2_rfdebug();
-int ibcs2_rfstart();
-int ibcs2_rfstop();
-int ibcs2_rfsys();
-int ibcs2_rmdir();
-int ibcs2_rmount();
-int ibcs2_rumount();
-int ibcs2_secure();
-int ibcs2_seek();
-int ibcs2_semsys();
int ibcs2_setgid();
-int ibcs2_setuid();
-int ibcs2_shmsys();
+int getgid();
int ibcs2_sigsys();
-int ibcs2_smount();
-int ibcs2_stat();
-int ibcs2_statfs();
-int ibcs2_stime();
-int ibcs2_stty();
-int ibcs2_sumount();
-int ibcs2_symlink();
-int ibcs2_sync();
-int ibcs2_sysacct();
-int ibcs2_sysfs();
-int ibcs2_sysi86();
-int ibcs2_times();
+#ifdef SYSVMSG
+int ibcs2_msgsys();
+#else
+#endif
+#ifdef SYSVSHM
+int ibcs2_shmsys();
+#else
+#endif
+#ifdef SYSVSEM
+int ibcs2_semsys();
+#else
+#endif
+int ibcs2_ioctl();
int ibcs2_uadmin();
-int ibcs2_ulimit();
-int ibcs2_umask();
-int ibcs2_unadvfs();
-int ibcs2_unlink();
-int ibcs2_utime();
int ibcs2_utssys();
-int ibcs2_wait();
-int ibcs2_write();
-int ibcs2_traceemu(); /* XXX */
-int sigreturn(); /* XXX */
+int ibcs2_execve();
+int umask();
+int chroot();
+int ibcs2_fcntl();
+int ibcs2_ulimit();
+int ibcs2_rmdir();
+int ibcs2_mkdir();
+int ibcs2_getdents();
+int ibcs2_sysfs();
+int ibcs2_getmsg();
+int ibcs2_putmsg();
+int ibcs2_poll();
+int ibcs2_symlink();
+int ibcs2_lstat();
+int ibcs2_readlink();
+int sigreturn();
+int xenix_rdchk();
+int xenix_chsize();
+int xenix_ftime();
+int xenix_nap();
+int select();
+int ibcs2_sigaction();
+int ibcs2_sigprocmask();
+int ibcs2_sigpending();
+int ibcs2_sigsuspend();
+int ibcs2_getgroups();
+int ibcs2_setgroups();
+int ibcs2_sysconf();
+int ibcs2_pathconf();
+int ibcs2_fpathconf();
+int ibcs2_rename();
-/* ibcs2 svr3 sysent table */
-struct sysent svr3_sysent[] =
-{
- 0, ibcs2_nosys, /* 0 = indir */
- 1, ibcs2_exit, /* 1 = exit */
- 0, ibcs2_fork, /* 2 = fork */
- 3, ibcs2_read, /* 3 = read */
- 3, ibcs2_write, /* 4 = write */
- 3, ibcs2_open, /* 5 = open */
- 1, ibcs2_close, /* 6 = close */
- 3, ibcs2_wait, /* 7 = wait */
- 2, ibcs2_creat, /* 8 = creat */
- 2, ibcs2_link, /* 9 = link */
- 1, ibcs2_unlink, /* 10 = unlink */
- 2, ibcs2_exec, /* 11 = exec */
- 1, ibcs2_chdir, /* 12 = chdir */
- 0, ibcs2_gtime, /* 13 = time */
- 3, ibcs2_mknod, /* 14 = mknod */
- 2, ibcs2_chmod, /* 15 = chmod */
- 3, ibcs2_chown, /* 16 = chown */
- 1, ibcs2_break, /* 17 = break */
- 2, ibcs2_stat, /* 18 = stat */
- 3, ibcs2_seek, /* 19 = seek */
- 0, ibcs2_getpid, /* 20 = getpid */
- 6, ibcs2_smount, /* 21 = mount */
- 1, ibcs2_sumount, /* 22 = umount */
- 1, ibcs2_setuid, /* 23 = setuid */
- 0, ibcs2_getuid, /* 24 = getuid */
- 1, ibcs2_stime, /* 25 = stime */
- 4, ibcs2_ptrace, /* 26 = ptrace */
- 1, ibcs2_alarm, /* 27 = alarm */
- 2, ibcs2_fstat, /* 28 = fstat */
- 0, ibcs2_pause, /* 29 = pause */
- 2, ibcs2_utime, /* 30 = utime */
- 2, ibcs2_stty, /* 31 = stty */
- 2, ibcs2_gtty, /* 32 = gtty */
- 2, ibcs2_access, /* 33 = access */
- 1, ibcs2_nice, /* 34 = nice */
- 4, ibcs2_statfs, /* 35 = statfs */
- 0, ibcs2_sync, /* 36 = sync */
- 2, ibcs2_kill, /* 37 = kill */
- 4, ibcs2_fstatfs, /* 38 = fstatfs */
- 1, ibcs2_procids, /* 39 = procids */
- 5, ibcs2_cxenix, /* 40 = XENIX special system call */
- 1, ibcs2_dup, /* 41 = dup */
- 1, ibcs2_pipe, /* 42 = pipe */
- 1, ibcs2_times, /* 43 = times */
- 4, ibcs2_profil, /* 44 = prof */
- 1, ibcs2_plock, /* 45 = proc lock */
- 1, ibcs2_setgid, /* 46 = setgid */
- 0, ibcs2_getgid, /* 47 = getgid */
- 2, ibcs2_sigsys, /* 48 = signal */
- 6, ibcs2_msgsys, /* 49 = IPC message */
- 4, ibcs2_sysi86, /* 50 = i386-specific system call */
- 1, ibcs2_sysacct, /* 51 = turn acct off/on */
- 4, ibcs2_shmsys, /* 52 = shared memory */
- 5, ibcs2_semsys, /* 53 = IPC semaphores */
- 3, ibcs2_ioctl, /* 54 = ioctl */
- 3, ibcs2_uadmin, /* 55 = uadmin */
- 0, ibcs2_nosys, /* 56 = reserved for exch */
- 3, ibcs2_utssys, /* 57 = utssys */
- 1, ibcs2_fsync, /* 58 = fsync */
- 3, ibcs2_exece, /* 59 = exece */
- 1, ibcs2_umask, /* 60 = umask */
- 1, ibcs2_chroot, /* 61 = chroot */
- 3, ibcs2_fcntl, /* 62 = fcntl */
- 2, ibcs2_ulimit, /* 63 = ulimit */
- 0, ibcs2_nosys, /* 64 = nosys */
- 0, ibcs2_nosys, /* 65 = nosys */
- 0, ibcs2_nosys, /* 66 = nosys */
- 0, ibcs2_nosys, /* 67 = file locking call */
- 0, ibcs2_nosys, /* 68 = local system calls */
- 0, ibcs2_nosys, /* 69 = inode open */
- 4, ibcs2_advfs, /* 70 = advfs */
- 1, ibcs2_unadvfs, /* 71 = unadvfs */
- 4, ibcs2_rmount, /* 72 = rmount */
- 1, ibcs2_rumount, /* 73 = rumount */
- 5, ibcs2_rfstart, /* 74 = rfstart */
- 0, ibcs2_nosys, /* 75 = not used */
- 1, ibcs2_rfdebug, /* 76 = rfdebug */
- 0, ibcs2_rfstop, /* 77 = rfstop */
- 6, ibcs2_rfsys, /* 78 = rfsys */
- 1, ibcs2_rmdir, /* 79 = rmdir */
- 2, ibcs2_mkdir, /* 80 = mkdir */
- 4, ibcs2_getdents, /* 81 = getdents */
- 3, ibcs2_libattach, /* 82 = libattach */
- 1, ibcs2_libdetach, /* 83 = libdetach */
- 3, ibcs2_sysfs, /* 84 = sysfs */
- 4, ibcs2_getmsg, /* 85 = getmsg */
- 4, ibcs2_putmsg, /* 86 = putmsg */
- 3, ibcs2_poll, /* 87 = poll */
- 0, ibcs2_nosys, /* 88 = not used */
- 6, ibcs2_secure, /* 89 = secureware */
- 2, ibcs2_symlink, /* 90 = symlink */
- 2, ibcs2_lstat, /* 91 = lstat */
- 3, ibcs2_readlink, /* 92 = readlink */
- 0, ibcs2_nosys, /* 93 = not used */
- 0, ibcs2_nosys, /* 94 = not used */
- 0, ibcs2_nosys, /* 95 = not used */
- 0, ibcs2_nosys, /* 96 = not used */
- 0, ibcs2_nosys, /* 97 = not used */
- 0, ibcs2_nosys, /* 98 = not used */
- 0, ibcs2_nosys, /* 99 = not used */
- 0, ibcs2_nosys, /* 100 = not used */
- 0, ibcs2_nosys, /* 101 = not used */
- 0, ibcs2_nosys, /* 102 = not used */
- 1, sigreturn, /* 103 = BSD sigreturn XXX */
- 0, ibcs2_nosys, /* 104 = not used */
- 5, ibcs2_cisc, /* 105 = ISC special */
- 0, ibcs2_nosys, /* 106 = not used */
- 0, ibcs2_nosys, /* 107 = not used */
- 0, ibcs2_nosys, /* 108 = not used */
- 0, ibcs2_nosys, /* 109 = not used */
- 0, ibcs2_nosys, /* 110 = not used */
- 0, ibcs2_nosys, /* 111 = not used */
- 0, ibcs2_nosys, /* 112 = not used */
- 0, ibcs2_nosys, /* 113 = not used */
- 0, ibcs2_nosys, /* 114 = not used */
- 0, ibcs2_nosys, /* 115 = not used */
- 0, ibcs2_nosys, /* 116 = not used */
- 0, ibcs2_nosys, /* 117 = not used */
- 0, ibcs2_nosys, /* 118 = not used */
- 0, ibcs2_nosys, /* 119 = not used */
- 0, ibcs2_nosys, /* 120 = not used */
- 0, ibcs2_nosys, /* 121 = not used */
- 0, ibcs2_nosys, /* 122 = not used */
- 0, ibcs2_nosys, /* 123 = not used */
- 0, ibcs2_nosys, /* 124 = not used */
- 0, ibcs2_nosys, /* 125 = not used */
- 1, ibcs2_traceemu, /* 126 = ibcs2 emulator trace cntl */
- 5, ibcs2_clocal, /* 127 = local system calls */
-};
+#ifdef COMPAT_43
+#define compat_43(func) __CONCAT(compat_43_,func)
-struct sysentvec ibcs2_svr3_sysvec = {
- sizeof (svr3_sysent) / sizeof (svr3_sysent[0]),
- svr3_sysent,
- 0x7F,
- NSIG,
- bsd_to_ibcs2_signal,
- NERR,
- bsd_to_svr3_errno
-};
+#ifdef SYSVMSG
+#else
+#endif
+#ifdef SYSVSHM
+#else
+#endif
+#ifdef SYSVSEM
+#else
+#endif
-#if 0
+#else /* COMPAT_43 */
+#define compat_43(func) nosys
+#endif /* COMPAT_43 */
-int ibcs2_acancel();
-int ibcs2_adjtime();
-int ibcs2_context();
-int ibcs2_evsys();
-int ibcs2_evtrapret();
-int ibcs2_fchdir();
-int ibcs2_fchmod();
-int ibcs2_fchown();
-int ibcs2_fstatvfs();
-int ibcs2_fxstat();
-int ibcs2_getgroups();
-int ibcs2_getpmsg();
-int ibcs2_getrlimit();
-int ibcs2_hrtsys();
-int ibcs2_lchown();
-int ibcs2_lxstat();
-int ibcs2_memcntl();
-int ibcs2_mincore();
-int ibcs2_mmap();
-int ibcs2_mprotect();
-int ibcs2_munmap();
-int ibcs2_pathconf();
-int ibcs2_priocntlsys();
-int ibcs2_putgmsg();
-int ibcs2_readv();
-int ibcs2_rename();
-int ibcs2_setegid();
-int ibcs2_seteuid();
-int ibcs2_setgroups();
-int ibcs2_setrlimit();
-int ibcs2_sigaction();
-int ibcs2_sigaltstack();
-int ibcs2_sigpending();
-int ibcs2_sigprocmask();
-int ibcs2_sigsendsys();
-int ibcs2_sigsuspend();
-int ibcs2_statvfs();
-int ibcs2_sysconfig();
-int ibcs2_systeminfo();
-int ibcs2_vfork();
-int ibcs2_waitsys();
-int ibcs2_writev();
-int ibcs2_xmknod();
-int ibcs2_xstat();
-int bsd_to_svr4_errno[NERR] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
- 10, 45, 12, 13, 14, 15, 16, 17, 18, 19,
- 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
- 30, 31, 32, 33, 34, 11,150,149, 95, 96,
- 97, 98, 99,120,121,122,123,124,125,126,
- 127,128,129,130,131,132,133,134,143,144,
- 145,146, 90, 78,147,148, 93, 11, 94, 11,
- 0, 0, 0, 0, 0, 0, 0, 46, 89, 0,
-};
+#ifdef COMPAT_09
+#define compat_09(func) __CONCAT(compat_09_,func)
-/* ibcs2 svr4 sysent table */
-struct sysent svr4_sysent[] =
-{
- 0, ibcs2_nosys, /* 0 = indir */
- 1, ibcs2_exit, /* 1 = exit */
- 0, ibcs2_fork, /* 2 = fork */
- 3, ibcs2_read, /* 3 = read */
- 3, ibcs2_write, /* 4 = write */
- 3, ibcs2_open, /* 5 = open */
- 1, ibcs2_close, /* 6 = close */
- 3, ibcs2_wait, /* 7 = wait */
- 2, ibcs2_creat, /* 8 = creat */
- 2, ibcs2_link, /* 9 = link */
- 1, ibcs2_unlink, /* 10 = unlink */
- 2, ibcs2_exec, /* 11 = exec */
- 1, ibcs2_chdir, /* 12 = chdir */
- 0, ibcs2_gtime, /* 13 = time */
- 3, ibcs2_mknod, /* 14 = mknod */
- 2, ibcs2_chmod, /* 15 = chmod */
- 3, ibcs2_chown, /* 16 = chown */
- 1, ibcs2_break, /* 17 = break */
- 2, ibcs2_stat, /* 18 = stat */
- 3, ibcs2_seek, /* 19 = seek */
- 0, ibcs2_getpid, /* 20 = getpid */
- 6, ibcs2_smount, /* 21 = mount */
- 1, ibcs2_sumount, /* 22 = umount */
- 1, ibcs2_setuid, /* 23 = setuid */
- 0, ibcs2_getuid, /* 24 = getuid */
- 1, ibcs2_stime, /* 25 = stime */
- 4, ibcs2_ptrace, /* 26 = ptrace */
- 1, ibcs2_alarm, /* 27 = alarm */
- 2, ibcs2_fstat, /* 28 = fstat */
- 0, ibcs2_pause, /* 29 = pause */
- 2, ibcs2_utime, /* 30 = utime */
- 2, ibcs2_stty, /* 31 = stty */
- 2, ibcs2_gtty, /* 32 = gtty */
- 2, ibcs2_access, /* 33 = access */
- 1, ibcs2_nice, /* 34 = nice */
- 4, ibcs2_statfs, /* 35 = statfs */
- 0, ibcs2_sync, /* 36 = sync */
- 2, ibcs2_kill, /* 37 = kill */
- 4, ibcs2_fstatfs, /* 38 = fstatfs */
- 1, ibcs2_procids, /* 39 = procids */
- 5, ibcs2_cxenix, /* 40 = XENIX special system call */
- 1, ibcs2_dup, /* 41 = dup */
- 1, ibcs2_pipe, /* 42 = pipe */
- 1, ibcs2_times, /* 43 = times */
- 4, ibcs2_profil, /* 44 = prof */
- 1, ibcs2_plock, /* 45 = proc lock */
- 1, ibcs2_setgid, /* 46 = setgid */
- 0, ibcs2_getgid, /* 47 = getgid */
- 2, ibcs2_sigsys, /* 48 = signal */
- 6, ibcs2_msgsys, /* 49 = IPC message */
- 4, ibcs2_sysi86, /* 50 = i386-specific system call */
- 1, ibcs2_sysacct, /* 51 = turn acct off/on */
- 4, ibcs2_shmsys, /* 52 = shared memory */
- 5, ibcs2_semsys, /* 53 = IPC semaphores */
- 3, ibcs2_ioctl, /* 54 = ioctl */
- 3, ibcs2_uadmin, /* 55 = uadmin */
- 0, ibcs2_nosys, /* 56 = reserved for exch */
- 3, ibcs2_utssys, /* 57 = utssys */
- 1, ibcs2_fsync, /* 58 = fsync */
- 3, ibcs2_exece, /* 59 = exece */
- 1, ibcs2_umask, /* 60 = umask */
- 1, ibcs2_chroot, /* 61 = chroot */
- 3, ibcs2_fcntl, /* 62 = fcntl */
- 2, ibcs2_ulimit, /* 63 = ulimit */
- 0, ibcs2_nosys, /* 64 = nosys */
- 0, ibcs2_nosys, /* 65 = nosys */
- 0, ibcs2_nosys, /* 66 = nosys */
- 0, ibcs2_nosys, /* 67 = file locking call */
- 0, ibcs2_nosys, /* 68 = local system calls */
- 0, ibcs2_nosys, /* 69 = inode open */
- 4, ibcs2_advfs, /* 70 = advfs */
- 1, ibcs2_unadvfs, /* 71 = unadvfs */
- 4, ibcs2_rmount, /* 72 = rmount */
- 1, ibcs2_rumount, /* 73 = rumount */
- 5, ibcs2_rfstart, /* 74 = rfstart */
- 0, ibcs2_nosys, /* 75 = not used */
- 1, ibcs2_rfdebug, /* 76 = rfdebug */
- 0, ibcs2_rfstop, /* 77 = rfstop */
- 6, ibcs2_rfsys, /* 78 = rfsys */
- 1, ibcs2_rmdir, /* 79 = rmdir */
- 2, ibcs2_mkdir, /* 80 = mkdir */
- 4, ibcs2_getdents, /* 81 = getdents */
- 3, ibcs2_libattach, /* 82 = libattach */
- 1, ibcs2_libdetach, /* 83 = libdetach */
- 3, ibcs2_sysfs, /* 84 = sysfs */
- 4, ibcs2_getmsg, /* 85 = getmsg */
- 4, ibcs2_putmsg, /* 86 = putmsg */
- 3, ibcs2_poll, /* 87 = poll */
- 6, ibcs2_lstat, /* 88 = lstat */
- 2, ibcs2_symlink, /* 89 = symlink */
- 3, ibcs2_readlink, /* 90 = readlink */
- 2, ibcs2_setgroups, /* 91 = setgroups */
- 2, ibcs2_getgroups, /* 92 = getgroups */
- 2, ibcs2_fchmod, /* 93 = fchmod */
- 3, ibcs2_fchown, /* 94 = fchown */
- 3, ibcs2_sigprocmask, /* 95 = sigprocmask */
- 0, ibcs2_sigsuspend, /* 96 = sigsuspend */
- 2, ibcs2_sigaltstack, /* 97 = sigaltstack */
- 3, ibcs2_sigaction, /* 98 = sigaction */
- 1, ibcs2_sigpending, /* 99 = sigpending */
- 0, ibcs2_context, /* 100 = context */
- 0, ibcs2_evsys, /* 101 = evsys */
- 0, ibcs2_evtrapret, /* 102 = evtrapret */
- 0, ibcs2_statvfs, /* 103 = statvfs */
- 0, ibcs2_fstatvfs, /* 104 = fstatvfs */
- 5, ibcs2_cisc, /* 105 = ISC special */
- 0, ibcs2_nfssys, /* 106 = nfssys */
- 0, ibcs2_waitsys, /* 107 = waitsys */
- 0, ibcs2_sigsendsys, /* 108 = sigsendsys */
- 0, ibcs2_hrtsys, /* 109 = hrtsys */
- 0, ibcs2_acancel, /* 110 = acancel */
- 0, ibcs2_async, /* 111 = async */
- 0, ibcs2_priocntlsys, /* 112 = priocntlsys */
- 0, ibcs2_pathconf, /* 113 = pathconf */
- 0, ibcs2_mincore, /* 114 = mincore */
- 6, ibcs2_mmap, /* 115 = mmap */
- 3, ibcs2_mprotect, /* 116 = mprotect */
- 2, ibcs2_munmap, /* 117 = munmap */
- 0, ibcs2_pathconf, /* 118 = fpathconf */
- 0, ibcs2_vfork, /* 119 = vfork */
- 0, ibcs2_fchdir, /* 120 = fchdir */
- 0, ibcs2_readv, /* 121 = readv */
- 0, ibcs2_writev, /* 122 = writev */
- 3, ibcs2_xstat, /* 123 = xstat */
- 3, ibcs2_lxstat, /* 124 = lxstat */
- 3, ibcs2_fxstat, /* 125 = fxstat */
- 4, ibcs2_xmknod, /* 126 = xmknod */
- 5, ibcs2_clocal, /* 127 = local system calls */
- 0, ibcs2_setrlimit, /* 128 = setrlimit */
- 0, ibcs2_getrlimit, /* 129 = getrlimit */
- 0, ibcs2_lchown, /* 130 = lchown */
- 0, ibcs2_memcntl, /* 131 = memcntl */
- 0, ibcs2_getpmsg, /* 132 = getpmsg */
- 0, ibcs2_putgmsg, /* 133 = putgmsg */
- 2, ibcs2_rename, /* 134 = rename */
- 1, ibcs2_uname, /* 135 = uname */
- 0, ibcs2_setegid, /* 136 = setegid */
- 0, ibcs2_sysconfig, /* 137 = sysconfig */
- 0, ibcs2_adjtime, /* 138 = adjtime */
- 0, ibcs2_systeminfo, /* 139 = systeminfo */
- 0, ibcs2_nosys, /* 140 = not used */
- 0, ibcs2_seteuid, /* 141 = seteuid */
-};
+#ifdef SYSVMSG
+#else
+#endif
+#ifdef SYSVSHM
+#else
+#endif
+#ifdef SYSVSEM
+#else
+#endif
-struct sysentvec ibcs2_svr4_sysvec = {
- sizeof (svr4_sysent) / sizeof (svr4_sysent[0]),
- svr4_sysent,
- 0xFF,
- NSIG,
- bsd_to_ibcs2_signal,
- NERR,
- bsd_to_svr4_errno
-};
+#else /* COMPAT_09 */
+#define compat_09(func) nosys
+#endif /* COMPAT_09 */
+
+
+#ifdef COMPAT_10
+#define compat_10(func) __CONCAT(compat_10_,func)
+
+#ifdef SYSVMSG
+#else
+#endif
+#ifdef SYSVSHM
+#else
+#endif
+#ifdef SYSVSEM
+#else
+#endif
+
+#else /* COMPAT_10 */
+#define compat_10(func) nosys
+#endif /* COMPAT_10 */
+#define s(type) sizeof(type)
+
+struct sysent ibcs2_sysent[] = {
+ { 0, 0,
+ nosys }, /* 0 = syscall */
+ { 1, s(struct exit_args),
+ exit }, /* 1 = exit */
+ { 0, 0,
+ fork }, /* 2 = fork */
+ { 3, s(struct ibcs2_read_args),
+ ibcs2_read }, /* 3 = ibcs2_read */
+ { 3, s(struct write_args),
+ write }, /* 4 = write */
+ { 3, s(struct ibcs2_open_args),
+ ibcs2_open }, /* 5 = ibcs2_open */
+ { 1, s(struct close_args),
+ close }, /* 6 = close */
+ { 3, s(struct ibcs2_waitsys_args),
+ ibcs2_waitsys }, /* 7 = ibcs2_waitsys */
+ { 2, s(struct ibcs2_creat_args),
+ ibcs2_creat }, /* 8 = ibcs2_creat */
+ { 2, s(struct link_args),
+ link }, /* 9 = link */
+ { 1, s(struct ibcs2_unlink_args),
+ ibcs2_unlink }, /* 10 = ibcs2_unlink */
+ { 2, s(struct ibcs2_execv_args),
+ ibcs2_execv }, /* 11 = ibcs2_execv */
+ { 1, s(struct ibcs2_chdir_args),
+ ibcs2_chdir }, /* 12 = ibcs2_chdir */
+ { 1, s(struct ibcs2_time_args),
+ ibcs2_time }, /* 13 = ibcs2_time */
+ { 3, s(struct ibcs2_mknod_args),
+ ibcs2_mknod }, /* 14 = ibcs2_mknod */
+ { 2, s(struct ibcs2_chmod_args),
+ ibcs2_chmod }, /* 15 = ibcs2_chmod */
+ { 3, s(struct ibcs2_chown_args),
+ ibcs2_chown }, /* 16 = ibcs2_chown */
+ { 1, s(struct obreak_args),
+ obreak }, /* 17 = obreak */
+ { 2, s(struct ibcs2_stat_args),
+ ibcs2_stat }, /* 18 = ibcs2_stat */
+ { 3, s(struct compat_43_lseek_args),
+ compat_43_lseek }, /* 19 = compat_43_lseek */
+ { 0, 0,
+ getpid }, /* 20 = getpid */
+ { 6, s(struct ibcs2_mount_args),
+ ibcs2_mount }, /* 21 = ibcs2_mount */
+ { 1, s(struct ibcs2_umount_args),
+ ibcs2_umount }, /* 22 = ibcs2_umount */
+ { 1, s(struct ibcs2_setuid_args),
+ ibcs2_setuid }, /* 23 = ibcs2_setuid */
+ { 0, 0,
+ getuid }, /* 24 = getuid */
+ { 1, s(struct ibcs2_stime_args),
+ ibcs2_stime }, /* 25 = ibcs2_stime */
+ { 0, 0,
+ nosys }, /* 26 = unimplemented ibcs2_ptrace */
+ { 1, s(struct ibcs2_alarm_args),
+ ibcs2_alarm }, /* 27 = ibcs2_alarm */
+ { 2, s(struct ibcs2_fstat_args),
+ ibcs2_fstat }, /* 28 = ibcs2_fstat */
+ { 0, 0,
+ ibcs2_pause }, /* 29 = ibcs2_pause */
+ { 2, s(struct ibcs2_utime_args),
+ ibcs2_utime }, /* 30 = ibcs2_utime */
+ { 0, 0,
+ nosys }, /* 31 = unimplemented was stty */
+ { 0, 0,
+ nosys }, /* 32 = unimplemented was gtty */
+ { 2, s(struct ibcs2_access_args),
+ ibcs2_access }, /* 33 = ibcs2_access */
+ { 1, s(struct ibcs2_nice_args),
+ ibcs2_nice }, /* 34 = ibcs2_nice */
+ { 4, s(struct ibcs2_statfs_args),
+ ibcs2_statfs }, /* 35 = ibcs2_statfs */
+ { 0, 0,
+ sync }, /* 36 = sync */
+ { 2, s(struct ibcs2_kill_args),
+ ibcs2_kill }, /* 37 = ibcs2_kill */
+ { 4, s(struct ibcs2_fstatfs_args),
+ ibcs2_fstatfs }, /* 38 = ibcs2_fstatfs */
+ { 4, s(struct ibcs2_pgrpsys_args),
+ ibcs2_pgrpsys }, /* 39 = ibcs2_pgrpsys */
+ { 0, 0,
+ nosys }, /* 40 = unimplemented ibcs2_xenix */
+ { 1, s(struct dup_args),
+ dup }, /* 41 = dup */
+ { 0, 0,
+ pipe }, /* 42 = pipe */
+ { 1, s(struct ibcs2_times_args),
+ ibcs2_times }, /* 43 = ibcs2_times */
+ { 0, 0,
+ nosys }, /* 44 = unimplemented profil */
+ { 1, s(struct ibcs2_plock_args),
+ ibcs2_plock }, /* 45 = ibcs2_plock */
+ { 1, s(struct ibcs2_setgid_args),
+ ibcs2_setgid }, /* 46 = ibcs2_setgid */
+ { 0, 0,
+ getgid }, /* 47 = getgid */
+ { 2, s(struct ibcs2_sigsys_args),
+ ibcs2_sigsys }, /* 48 = ibcs2_sigsys */
+#ifdef SYSVMSG
+ { 6, s(struct ibcs2_msgsys_args),
+ ibcs2_msgsys }, /* 49 = ibcs2_msgsys */
+#else
+ { 0, 0,
+ nosys }, /* 49 = unimplemented nosys */
+#endif
+ { 0, 0,
+ nosys }, /* 50 = unimplemented ibcs2_sys3b */
+ { 0, 0,
+ nosys }, /* 51 = unimplemented ibcs2_acct */
+#ifdef SYSVSHM
+ { 4, s(struct ibcs2_shmsys_args),
+ ibcs2_shmsys }, /* 52 = ibcs2_shmsys */
+#else
+ { 0, 0,
+ nosys }, /* 52 = unimplemented nosys */
#endif
+#ifdef SYSVSEM
+ { 5, s(struct ibcs2_semsys_args),
+ ibcs2_semsys }, /* 53 = ibcs2_semsys */
+#else
+ { 0, 0,
+ nosys }, /* 53 = unimplemented nosys */
+#endif
+ { 3, s(struct ibcs2_ioctl_args),
+ ibcs2_ioctl }, /* 54 = ibcs2_ioctl */
+ { 3, s(struct ibcs2_uadmin_args),
+ ibcs2_uadmin }, /* 55 = ibcs2_uadmin */
+ { 0, 0,
+ nosys }, /* 56 = unimplemented nosys */
+ { 3, s(struct ibcs2_utssys_args),
+ ibcs2_utssys }, /* 57 = ibcs2_utssys */
+ { 0, 0,
+ nosys }, /* 58 = unimplemented nosys */
+ { 3, s(struct ibcs2_execve_args),
+ ibcs2_execve }, /* 59 = ibcs2_execve */
+ { 1, s(struct umask_args),
+ umask }, /* 60 = umask */
+ { 1, s(struct chroot_args),
+ chroot }, /* 61 = chroot */
+ { 3, s(struct ibcs2_fcntl_args),
+ ibcs2_fcntl }, /* 62 = ibcs2_fcntl */
+ { 2, s(struct ibcs2_ulimit_args),
+ ibcs2_ulimit }, /* 63 = ibcs2_ulimit */
+ { 0, 0,
+ nosys }, /* 64 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ nosys }, /* 65 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ nosys }, /* 66 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ nosys }, /* 67 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ nosys }, /* 68 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ nosys }, /* 69 = unimplemented reserved for unix/pc */
+ { 0, 0,
+ nosys }, /* 70 = obsolete rfs_advfs */
+ { 0, 0,
+ nosys }, /* 71 = obsolete rfs_unadvfs */
+ { 0, 0,
+ nosys }, /* 72 = obsolete rfs_rmount */
+ { 0, 0,
+ nosys }, /* 73 = obsolete rfs_rumount */
+ { 0, 0,
+ nosys }, /* 74 = obsolete rfs_rfstart */
+ { 0, 0,
+ nosys }, /* 75 = obsolete rfs_sigret */
+ { 0, 0,
+ nosys }, /* 76 = obsolete rfs_rdebug */
+ { 0, 0,
+ nosys }, /* 77 = obsolete rfs_rfstop */
+ { 0, 0,
+ nosys }, /* 78 = unimplemented rfs_rfsys */
+ { 1, s(struct ibcs2_rmdir_args),
+ ibcs2_rmdir }, /* 79 = ibcs2_rmdir */
+ { 2, s(struct ibcs2_mkdir_args),
+ ibcs2_mkdir }, /* 80 = ibcs2_mkdir */
+ { 3, s(struct ibcs2_getdents_args),
+ ibcs2_getdents }, /* 81 = ibcs2_getdents */
+ { 0, 0,
+ nosys }, /* 82 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 83 = unimplemented nosys */
+ { 3, s(struct ibcs2_sysfs_args),
+ ibcs2_sysfs }, /* 84 = ibcs2_sysfs */
+ { 4, s(struct ibcs2_getmsg_args),
+ ibcs2_getmsg }, /* 85 = ibcs2_getmsg */
+ { 4, s(struct ibcs2_putmsg_args),
+ ibcs2_putmsg }, /* 86 = ibcs2_putmsg */
+ { 3, s(struct ibcs2_poll_args),
+ ibcs2_poll }, /* 87 = ibcs2_poll */
+ { 0, 0,
+ nosys }, /* 88 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 89 = unimplemented nosys */
+ { 2, s(struct ibcs2_symlink_args),
+ ibcs2_symlink }, /* 90 = ibcs2_symlink */
+ { 2, s(struct ibcs2_lstat_args),
+ ibcs2_lstat }, /* 91 = ibcs2_lstat */
+ { 3, s(struct ibcs2_readlink_args),
+ ibcs2_readlink }, /* 92 = ibcs2_readlink */
+ { 0, 0,
+ nosys }, /* 93 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 94 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 95 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 96 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 97 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 98 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 99 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 100 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 101 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 102 = unimplemented nosys */
+ { 1, s(struct sigreturn_args),
+ sigreturn }, /* 103 = sigreturn */
+ { 0, 0,
+ nosys }, /* 104 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 105 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 106 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 107 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 108 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 109 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 110 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 111 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 112 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 113 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 114 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 115 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 116 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 117 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 118 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 119 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 120 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 121 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 122 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 123 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 124 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 125 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 126 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 127 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 128 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 129 = unimplemented xenix_xlocking */
+ { 0, 0,
+ nosys }, /* 130 = unimplemented xenix_creatsem */
+ { 0, 0,
+ nosys }, /* 131 = unimplemented xenix_opensem */
+ { 0, 0,
+ nosys }, /* 132 = unimplemented xenix_sigsem */
+ { 0, 0,
+ nosys }, /* 133 = unimplemented xenix_waitsem */
+ { 0, 0,
+ nosys }, /* 134 = unimplemented xenix_nbwaitsem */
+ { 1, s(struct xenix_rdchk_args),
+ xenix_rdchk }, /* 135 = xenix_rdchk */
+ { 0, 0,
+ nosys }, /* 136 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 137 = unimplemented nosys */
+ { 2, s(struct xenix_chsize_args),
+ xenix_chsize }, /* 138 = xenix_chsize */
+ { 1, s(struct xenix_ftime_args),
+ xenix_ftime }, /* 139 = xenix_ftime */
+ { 1, s(struct xenix_nap_args),
+ xenix_nap }, /* 140 = xenix_nap */
+ { 0, 0,
+ nosys }, /* 141 = unimplemented xenix_sdget */
+ { 0, 0,
+ nosys }, /* 142 = unimplemented xenix_sdfree */
+ { 0, 0,
+ nosys }, /* 143 = unimplemented xenix_sdenter */
+ { 0, 0,
+ nosys }, /* 144 = unimplemented xenix_sdleave */
+ { 0, 0,
+ nosys }, /* 145 = unimplemented xenix_sdgetv */
+ { 0, 0,
+ nosys }, /* 146 = unimplemented xenix_sdwaitv */
+ { 0, 0,
+ nosys }, /* 147 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 148 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 149 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 150 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 151 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 152 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 153 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 154 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 155 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 156 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 157 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 158 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 159 = unimplemented nosys */
+ { 0, 0,
+ nosys }, /* 160 = unimplemented xenix_proctl */
+ { 0, 0,
+ nosys }, /* 161 = unimplemented xenix_execseg */
+ { 0, 0,
+ nosys }, /* 162 = unimplemented xenix_unexecseg */
+ { 0, 0,
+ nosys }, /* 163 = unimplemented nosys */
+ { 5, s(struct select_args),
+ select }, /* 164 = select */
+ { 0, 0,
+ nosys }, /* 165 = unimplemented xenix_eaccess */
+ { 0, 0,
+ nosys }, /* 166 = unimplemented xenix_paccess */
+ { 3, s(struct ibcs2_sigaction_args),
+ ibcs2_sigaction }, /* 167 = ibcs2_sigaction */
+ { 3, s(struct ibcs2_sigprocmask_args),
+ ibcs2_sigprocmask }, /* 168 = ibcs2_sigprocmask */
+ { 1, s(struct ibcs2_sigpending_args),
+ ibcs2_sigpending }, /* 169 = ibcs2_sigpending */
+ { 1, s(struct ibcs2_sigsuspend_args),
+ ibcs2_sigsuspend }, /* 170 = ibcs2_sigsuspend */
+ { 2, s(struct ibcs2_getgroups_args),
+ ibcs2_getgroups }, /* 171 = ibcs2_getgroups */
+ { 2, s(struct ibcs2_setgroups_args),
+ ibcs2_setgroups }, /* 172 = ibcs2_setgroups */
+ { 1, s(struct ibcs2_sysconf_args),
+ ibcs2_sysconf }, /* 173 = ibcs2_sysconf */
+ { 2, s(struct ibcs2_pathconf_args),
+ ibcs2_pathconf }, /* 174 = ibcs2_pathconf */
+ { 2, s(struct ibcs2_fpathconf_args),
+ ibcs2_fpathconf }, /* 175 = ibcs2_fpathconf */
+ { 2, s(struct ibcs2_rename_args),
+ ibcs2_rename }, /* 176 = ibcs2_rename */
+};
+
diff --git a/sys/i386/ibcs2/ibcs2_termios.h b/sys/i386/ibcs2/ibcs2_termios.h
new file mode 100644
index 0000000..35602cf
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_time.h b/sys/i386/ibcs2/ibcs2_time.h
new file mode 100644
index 0000000..a3b669b
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_timeb.h b/sys/i386/ibcs2/ibcs2_timeb.h
new file mode 100644
index 0000000..d85202d
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_types.h b/sys/i386/ibcs2/ibcs2_types.h
new file mode 100644
index 0000000..305a1fc
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_unistd.h b/sys/i386/ibcs2/ibcs2_unistd.h
new file mode 100644
index 0000000..1a0dd66
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_ustat.h b/sys/i386/ibcs2/ibcs2_ustat.h
new file mode 100644
index 0000000..03c7146
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_util.c b/sys/i386/ibcs2/ibcs2_util.c
new file mode 100644
index 0000000..69937ac
--- /dev/null
+++ b/sys/i386/ibcs2/ibcs2_util.c
@@ -0,0 +1,178 @@
+/*
+ * 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.
+ *
+ * from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos 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/malloc.h>
+#include <sys/vnode.h>
+
+#include <compat/ibcs2/ibcs2_util.h>
+
+const char ibcs2_emul_path[] = "/emul/ibcs2";
+
+/*
+ * Search an alternate path before passing pathname arguments on
+ * to system calls. Useful for keeping a seperate '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
+ibcs2_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;
+ size_t sz, len;
+
+ buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
+ *pbuf = path;
+
+ for (ptr = buf; (*ptr = *prefix) != '\0'; ptr++, prefix++)
+ 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 ibcs2_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 *) ibcs2_emul_path, 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/i386/ibcs2/ibcs2_util.h b/sys/i386/ibcs2/ibcs2_util.h
new file mode 100644
index 0000000..6aa4e8c
--- /dev/null
+++ b/sys/i386/ibcs2/ibcs2_util.h
@@ -0,0 +1,82 @@
+
+/*
+ * 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.
+ *
+ * from: svr4_util.h,v 1.5 1994/11/18 02:54:31 christos Exp
+ * from: linux_util.h,v 1.2 1995/03/05 23:23:50 fvdl Exp
+ */
+
+/*
+ * This file is pretty much the same as Christos' svr4_util.h
+ * (for now).
+ */
+
+#ifndef _IBCS2_UTIL_H_
+#define _IBCS2_UTIL_H_
+
+#include <machine/vmparam.h>
+#include <sys/exec.h>
+#include <sys/cdefs.h>
+
+static __inline caddr_t
+stackgap_init()
+{
+ extern char sigcode[], esigcode[];
+#define szsigcode ((caddr_t)(esigcode - 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;
+}
+
+#ifdef DEBUG_IBCS2
+#define DPRINTF(a) printf a;
+#else
+#define DPRINTF(a)
+#endif
+
+extern const char ibcs2_emul_path[];
+
+int ibcs2_emul_find __P((struct proc *, caddr_t *, const char *, char *,
+ char **, int));
+
+#define CHECKALTEXIST(p, sgp, path) \
+ ibcs2_emul_find(p, sgp, ibcs2_emul_path, path, &(path), 0)
+
+#define CHECKALTCREAT(p, sgp, path) \
+ ibcs2_emul_find(p, sgp, ibcs2_emul_path, path, &(path), 1)
+
+#endif /* !_IBCS2_UTIL_H_ */
diff --git a/sys/i386/ibcs2/ibcs2_utime.h b/sys/i386/ibcs2/ibcs2_utime.h
new file mode 100644
index 0000000..02d8315
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/ibcs2_utsname.h b/sys/i386/ibcs2/ibcs2_utsname.h
new file mode 100644
index 0000000..4f2ee68
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/syscalls.conf b/sys/i386/ibcs2/syscalls.conf
new file mode 100644
index 0000000..7f46f44
--- /dev/null
+++ b/sys/i386/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/i386/ibcs2/syscalls.master b/sys/i386/ibcs2/syscalls.master
new file mode 100644
index 0000000..db907d7
--- /dev/null
+++ b/sys/i386/ibcs2/syscalls.master
@@ -0,0 +1,243 @@
+ $NetBSD: syscalls.master,v 1.4 1995/03/14 15:12:52 scottb Exp $
+
+; @(#)syscalls.master 8.1 (Berkeley) 7/19/93
+; System call name/number master file (or rather, slave, from IBCS2).
+; Processed to created ibcs2_sysent.c, ibcs2_syscalls.c and ibcs2_syscall.h.
+
+; Columns: number type nargs name altname/comments
+; number system call number, must be in order
+; type one of STD, OBSOL, UNIMPL, STD
+; nargs number of arguments
+; name name of syscall routine
+; altname name of system call if different
+; for UNIMPL/OBSOL, name continues with comments
+
+#include <sys/param.h>
+#include <compat/ibcs2/ibcs2_types.h>
+#include <compat/ibcs2/ibcs2_signal.h>
+#include <compat/ibcs2/ibcs2_statfs.h>
+#include <sys/systm.h>
+#include <sys/signal.h>
+#include <sys/mount.h>
+#include <sys/syscallargs.h>
+#include <compat/ibcs2/ibcs2_syscallargs.h>
+
+; types:
+; STD always included
+; STD included on COMPAT #ifdef
+; LIBSTD included on COMPAT #ifdef, and placed in syscall.h
+; OBSOL obsolete, not included in system, only specifies name
+; UNIMPL not implemented, placeholder only
+
+; #ifdef's, etc. may be included, and are copied to the output files.
+
+0 NOARGS { int nosys(void); } syscall
+1 NOARGS { int exit(int rval); }
+2 NOARGS { int fork(void); }
+3 STD { int ibcs2_read(int fd, char *buf, u_int nbytes); }
+4 NOARGS { int write(int fd, char *buf, u_int nbytes); }
+5 STD { int ibcs2_open(char *path, int flags, int mode); }
+6 NOARGS { int close(int fd); }
+7 STD { int ibcs2_waitsys(int a1, int a2, int a3); }
+8 STD { int ibcs2_creat(char *path, int mode); }
+9 NOARGS { int link(char *path, char *link); }
+10 STD { int ibcs2_unlink(char *path); }
+11 STD { int ibcs2_execv(char *path, char **argp); }
+12 STD { int ibcs2_chdir(char *path); }
+13 STD { int ibcs2_time(ibcs2_time_t *tp); }
+14 STD { int ibcs2_mknod(char* path, int mode, int dev); }
+15 STD { int ibcs2_chmod(char *path, int mode); }
+16 STD { int ibcs2_chown(char *path, int uid, int gid); }
+17 NOARGS { int obreak(caddr_t nsize); }
+18 STD { int ibcs2_stat(char* path, struct ibcs2_stat *st); }
+19 NOARGS { long compat_43_lseek(int fd, long offset, \
+ int whence); }
+20 NOARGS { pid_t getpid(void); }
+21 STD { int ibcs2_mount(char *special, char *dir, int flags, \
+ int fstype, char *data, int len); }
+22 STD { int ibcs2_umount(char *name); }
+23 STD { int ibcs2_setuid(int uid); }
+24 NOARGS { uid_t getuid(void); }
+25 STD { int ibcs2_stime(long *timep); }
+26 UNIMPL ibcs2_ptrace
+27 STD { int ibcs2_alarm(unsigned sec); }
+28 STD { int ibcs2_fstat(int fd, struct ibcs2_stat *st); }
+29 STD { int ibcs2_pause(void); }
+30 STD { int ibcs2_utime(char *path, \
+ struct ibcs2_utimbuf *buf); }
+31 UNIMPL was stty
+32 UNIMPL was gtty
+33 STD { int ibcs2_access(char *path, int flags); }
+34 STD { int ibcs2_nice(int incr); }
+35 STD { int ibcs2_statfs(char *path, \
+ struct ibcs2_statfs *buf, \
+ int len, int fstype); }
+36 NOARGS { int sync(void); }
+37 STD { int ibcs2_kill(int pid, int signo); }
+38 STD { int ibcs2_fstatfs(int fd, struct ibcs2_statfs *buf, \
+ int len, int fstype); }
+39 STD { int ibcs2_pgrpsys(int type, caddr_t dummy, int pid, \
+ int pgid); }
+40 UNIMPL ibcs2_xenix
+41 NOARGS { int dup(u_int fd); }
+42 NOARGS { int pipe(void); }
+43 STD { int ibcs2_times(struct tms *tp); }
+44 UNIMPL profil
+45 STD { int ibcs2_plock(int cmd); }
+46 STD { int ibcs2_setgid(int gid); }
+47 NOARGS { gid_t getgid(void); }
+48 STD { int ibcs2_sigsys(int sig, ibcs2_sig_t fp); }
+#ifdef SYSVMSG
+49 STD { int ibcs2_msgsys(int which, int a2, int a3, int a4, \
+ int a5, int a6); }
+#else
+49 UNIMPL nosys
+#endif
+50 UNIMPL ibcs2_sys3b
+51 UNIMPL ibcs2_acct
+#ifdef SYSVSHM
+52 STD { int ibcs2_shmsys(int which, int a2, int a3, int a4); }
+#else
+52 UNIMPL nosys
+#endif
+#ifdef SYSVSEM
+53 STD { int ibcs2_semsys(int which, int a2, int a3, int a4, \
+ int a5); }
+#else
+53 UNIMPL nosys
+#endif
+54 STD { int ibcs2_ioctl(int fd, int cmd, caddr_t data); }
+55 STD { int ibcs2_uadmin(int cmd, int func, caddr_t data); }
+56 UNIMPL nosys
+57 STD { int ibcs2_utssys(int a1, int a2, int flag); }
+58 UNIMPL nosys
+59 STD { int ibcs2_execve(char *path, char **argp, \
+ char **envp); }
+60 NOARGS { int umask(int newmask); }
+61 NOARGS { int chroot(char *path); }
+62 STD { int ibcs2_fcntl(int fd, int cmd, char *arg); }
+63 STD { long ibcs2_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_rmdir(char *path); }
+80 STD { int ibcs2_mkdir(char *path, int mode); }
+81 STD { int ibcs2_getdents(int fd, char *buf, int nbytes); }
+82 UNIMPL nosys
+83 UNIMPL nosys
+84 STD { int ibcs2_sysfs(int cmd, caddr_t d1, char *buf); }
+85 STD { int ibcs2_getmsg(int fd, struct ibcs2_stropts *ctl, \
+ struct ibcs2_stropts *dat, \
+ int *flags); }
+86 STD { int ibcs2_putmsg(int fd, struct ibcs2_stropts *ctl, \
+ struct ibcs2_stropts *dat, \
+ int flags); }
+87 STD { int ibcs2_poll(struct ibcs2_pollfd *fds, long nfds, \
+ int timeout); }
+88 UNIMPL nosys
+89 UNIMPL nosys
+90 STD { int ibcs2_symlink(char *path, char *link); }
+91 STD { int ibcs2_lstat(char *path, struct ibcs2_stat *st); }
+92 STD { int ibcs2_readlink(char *path, char *buf, int count); }
+93 UNIMPL nosys
+94 UNIMPL nosys
+95 UNIMPL nosys
+96 UNIMPL nosys
+97 UNIMPL nosys
+98 UNIMPL nosys
+99 UNIMPL nosys
+100 UNIMPL nosys
+101 UNIMPL nosys
+102 UNIMPL nosys
+103 NOARGS { int sigreturn(struct sigcontext *sigcntxp); }
+104 UNIMPL nosys
+105 UNIMPL nosys
+106 UNIMPL nosys
+107 UNIMPL nosys
+108 UNIMPL nosys
+109 UNIMPL nosys
+110 UNIMPL nosys
+111 UNIMPL nosys
+112 UNIMPL nosys
+113 UNIMPL nosys
+114 UNIMPL nosys
+115 UNIMPL nosys
+116 UNIMPL nosys
+117 UNIMPL nosys
+118 UNIMPL nosys
+119 UNIMPL nosys
+120 UNIMPL nosys
+121 UNIMPL nosys
+122 UNIMPL nosys
+123 UNIMPL nosys
+124 UNIMPL nosys
+125 UNIMPL nosys
+126 UNIMPL nosys
+127 UNIMPL nosys
+128 UNIMPL nosys
+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_rdchk(int fd); }
+136 UNIMPL nosys
+137 UNIMPL nosys
+138 STD { int xenix_chsize(int fd, long size); }
+139 STD { int xenix_ftime(struct xenix_timeb *tp); }
+140 STD { int xenix_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 nosys
+148 UNIMPL nosys
+149 UNIMPL nosys
+150 UNIMPL nosys
+151 UNIMPL nosys
+152 UNIMPL nosys
+153 UNIMPL nosys
+154 UNIMPL nosys
+155 UNIMPL nosys
+156 UNIMPL nosys
+157 UNIMPL nosys
+158 UNIMPL nosys
+159 UNIMPL nosys
+160 UNIMPL xenix_proctl
+161 UNIMPL xenix_execseg
+162 UNIMPL xenix_unexecseg
+163 UNIMPL nosys
+164 NOARGS { int 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_sigaction(int sig, \
+ struct ibcs2_sigaction *act, \
+ struct ibcs2_sigaction *oact); }
+168 STD { int ibcs2_sigprocmask(int how, ibcs2_sigset_t *set, \
+ ibcs2_sigset_t *oset); }
+169 STD { int ibcs2_sigpending(ibcs2_sigset_t *mask); }
+170 STD { int ibcs2_sigsuspend(ibcs2_sigset_t *mask); }
+171 STD { int ibcs2_getgroups(int gidsetsize, \
+ ibcs2_gid_t *gidset); }
+172 STD { int ibcs2_setgroups(int gidsetsize, \
+ ibcs2_gid_t *gidset); }
+173 STD { int ibcs2_sysconf(int name); }
+174 STD { int ibcs2_pathconf(char *path, int name); }
+175 STD { int ibcs2_fpathconf(int fd, int name); }
+176 STD { int ibcs2_rename(char *from, char *to); }
OpenPOWER on IntegriCloud