diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-18 08:53:40 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-18 08:53:40 +0000 |
commit | d6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch) | |
tree | ece253b876159b39c620e62b6c9b1174642e070e /sys/compat/svr4 |
initial import of NetBSD tree
Diffstat (limited to 'sys/compat/svr4')
49 files changed, 9084 insertions, 0 deletions
diff --git a/sys/compat/svr4/files.svr4 b/sys/compat/svr4/files.svr4 new file mode 100644 index 00000000000..fd59078d07e --- /dev/null +++ b/sys/compat/svr4/files.svr4 @@ -0,0 +1,23 @@ +# $NetBSD: files.svr4,v 1.4 1995/08/14 01:34:12 mycroft Exp $ +# +# Config.new file description for machine-independent SVR4 compat code. +# Included by ports that need it. + +# ports should define any machine-specific files they need in their +# own file lists. + +file compat/svr4/svr4_error.c compat_svr4 +file compat/svr4/svr4_exec.c compat_svr4 +file compat/svr4/svr4_fcntl.c compat_svr4 +file compat/svr4/svr4_filio.c compat_svr4 +file compat/svr4/svr4_ioctl.c compat_svr4 +file compat/svr4/svr4_misc.c compat_svr4 +file compat/svr4/svr4_net.c compat_svr4 +file compat/svr4/svr4_signal.c compat_svr4 +file compat/svr4/svr4_sockio.c compat_svr4 +file compat/svr4/svr4_stat.c compat_svr4 +file compat/svr4/svr4_stream.c compat_svr4 +file compat/svr4/svr4_syscalls.c compat_svr4 +file compat/svr4/svr4_sysent.c compat_svr4 +file compat/svr4/svr4_termios.c compat_svr4 +file compat/svr4/svr4_ttold.c compat_svr4 diff --git a/sys/compat/svr4/svr4_dirent.h b/sys/compat/svr4/svr4_dirent.h new file mode 100644 index 00000000000..4197afafc5f --- /dev/null +++ b/sys/compat/svr4/svr4_dirent.h @@ -0,0 +1,45 @@ +/* $NetBSD: svr4_dirent.h,v 1.4 1995/10/07 06:27:37 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_DIRENT_H_ +#define _SVR4_DIRENT_H_ + +#define SVR4_MAXNAMLEN 512 + +struct svr4_dirent { + svr4_ino_t d_ino; + svr4_off_t d_off; + u_short d_reclen; + char d_name[SVR4_MAXNAMLEN + 1]; +}; + +#define SVR4_NAMEOFF(dp) ((char *)&(dp)->d_name - (char *)dp) +#define SVR4_RECLEN(de,namlen) ALIGN((SVR4_NAMEOFF(de) + (namlen) + 1)) + +#endif /* !_SVR4_DIRENT_H_ */ diff --git a/sys/compat/svr4/svr4_errno.h b/sys/compat/svr4/svr4_errno.h new file mode 100644 index 00000000000..63fa48872d7 --- /dev/null +++ b/sys/compat/svr4/svr4_errno.h @@ -0,0 +1,171 @@ +/* $NetBSD: svr4_errno.h,v 1.2 1994/11/18 02:53:37 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_ERRNO_H_ +#define _SVR4_ERRNO_H_ + +#define SVR4_EPERM 1 +#define SVR4_ENOENT 2 +#define SVR4_ESRCH 3 +#define SVR4_EINTR 4 +#define SVR4_EIO 5 +#define SVR4_ENXIO 6 +#define SVR4_E2BIG 7 +#define SVR4_ENOEXEC 8 +#define SVR4_EBADF 9 +#define SVR4_ECHILD 10 +#define SVR4_EAGAIN 11 +#define SVR4_ENOMEM 12 +#define SVR4_EACCES 13 +#define SVR4_EFAULT 14 +#define SVR4_ENOTBLK 15 +#define SVR4_EBUSY 16 +#define SVR4_EEXIST 17 +#define SVR4_EXDEV 18 +#define SVR4_ENODEV 19 +#define SVR4_ENOTDIR 20 +#define SVR4_EISDIR 21 +#define SVR4_EINVAL 22 +#define SVR4_ENFILE 23 +#define SVR4_EMFILE 24 +#define SVR4_ENOTTY 25 +#define SVR4_ETXTBSY 26 +#define SVR4_EFBIG 27 +#define SVR4_ENOSPC 28 +#define SVR4_ESPIPE 29 +#define SVR4_EROFS 30 +#define SVR4_EMLINK 31 +#define SVR4_EPIPE 32 +#define SVR4_EDOM 33 +#define SVR4_ERANGE 34 +#define SVR4_ENOMSG 35 +#define SVR4_EIDRM 36 +#define SVR4_ECHRNG 37 +#define SVR4_EL2NSYNC 38 +#define SVR4_EL3HLT 39 +#define SVR4_EL3RST 40 +#define SVR4_ELNRNG 41 +#define SVR4_EUNATCH 42 +#define SVR4_ENOCSI 43 +#define SVR4_EL2HLT 44 +#define SVR4_EDEADLK 45 +#define SVR4_ENOLCK 46 +#define SVR4_EBADE 50 +#define SVR4_EBADR 51 +#define SVR4_EXFULL 52 +#define SVR4_ENOANO 53 +#define SVR4_EBADRQC 54 +#define SVR4_EBADSLT 55 +#define SVR4_EDEADLOCK 56 +#define SVR4_EBFONT 57 +#define SVR4_ENOSTR 60 +#define SVR4_ENODATA 61 +#define SVR4_ETIME 62 +#define SVR4_ENOSR 63 +#define SVR4_ENONET 64 +#define SVR4_ENOPKG 65 +#define SVR4_EREMOTE 66 +#define SVR4_ENOLINK 67 +#define SVR4_EADV 68 +#define SVR4_ESRMNT 69 +#define SVR4_ECOMM 70 +#define SVR4_EPROTO 71 +#define SVR4_EMULTIHOP 74 +#define SVR4_EBADMSG 77 +#define SVR4_ENAMETOOLONG 78 +#define SVR4_EOVERFLOW 79 +#define SVR4_ENOTUNIQ 80 +#define SVR4_EBADFD 81 +#define SVR4_EREMCHG 82 +#define SVR4_ELIBACC 83 +#define SVR4_ELIBBAD 84 +#define SVR4_ELIBSCN 85 +#define SVR4_ELIBMAX 86 +#define SVR4_ELIBEXEC 87 +#define SVR4_EILSEQ 88 +#define SVR4_ENOSYS 89 +#define SVR4_ELOOP 90 +#define SVR4_ERESTART 91 +#define SVR4_ESTRPIPE 92 +#define SVR4_ENOTEMPTY 93 +#define SVR4_EUSERS 94 +#define SVR4_ENOTSOCK 95 +#define SVR4_EDESTADDRREQ 96 +#define SVR4_EMSGSIZE 97 +#define SVR4_EPROTOTYPE 98 +#define SVR4_ENOPROTOOPT 99 +#define SVR4_EPROTONOSUPPORT 120 +#define SVR4_ESOCKTNOSUPPORT 121 +#define SVR4_EOPNOTSUPP 122 +#define SVR4_EPFNOSUPPORT 123 +#define SVR4_EAFNOSUPPORT 124 +#define SVR4_EADDRINUSE 125 +#define SVR4_EADDRNOTAVAIL 126 +#define SVR4_ENETDOWN 127 +#define SVR4_ENETUNREACH 128 +#define SVR4_ENETRESET 129 +#define SVR4_ECONNABORTED 130 +#define SVR4_ECONNRESET 131 +#define SVR4_ENOBUFS 132 +#define SVR4_EISCONN 133 +#define SVR4_ENOTCONN 134 +#define SVR4_EUCLEAN 135 +#define SVR4_ENOTNAM 137 +#define SVR4_ENAVAIL 138 +#define SVR4_EISNAM 139 +#define SVR4_EREMOTEIO 140 +#define SVR4_EINIT 141 +#define SVR4_EREMDEV 142 +#define SVR4_ESHUTDOWN 143 +#define SVR4_ETOOMANYREFS 144 +#define SVR4_ETIMEDOUT 145 +#define SVR4_ECONNREFUSED 146 +#define SVR4_EHOSTDOWN 147 +#define SVR4_EHOSTUNREACH 148 +#define SVR4_EWOULDBLOCK SVR4_EAGAIN +#define SVR4_EALREADY 149 +#define SVR4_EINPROGRESS 150 +#define SVR4_ESTALE 151 +#define SVR4_EIORESID 500 + +/* + * These ones are not translated... + */ +#define SVR4_EPROCLIM SVR4_ENOSYS +#define SVR4_EDQUOT SVR4_ENOSYS +#define SVR4_EBADRPC SVR4_ENOSYS +#define SVR4_ERPCMISMATCH SVR4_ENOSYS +#define SVR4_EPROGUNAVAIL SVR4_ENOSYS +#define SVR4_EPROGMISMATCH SVR4_ENOSYS +#define SVR4_EPROCUNAVAIL SVR4_ENOSYS +#define SVR4_EFTYPE SVR4_ENOSYS +#define SVR4_EAUTH SVR4_ENOSYS +#define SVR4_ENEEDAUTH SVR4_ENOSYS + +#endif /* !_SVR4_ERRNO_H_ */ diff --git a/sys/compat/svr4/svr4_error.c b/sys/compat/svr4/svr4_error.c new file mode 100644 index 00000000000..7f674e28284 --- /dev/null +++ b/sys/compat/svr4/svr4_error.c @@ -0,0 +1,120 @@ +/* $NetBSD: svr4_error.c,v 1.2 1994/11/18 02:53:41 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Translate error codes. + */ + +#include <compat/svr4/svr4_errno.h> + + +int svr4_error[] = { + 0, + SVR4_EPERM, + SVR4_ENOENT, + SVR4_ESRCH, + SVR4_EINTR, + SVR4_EIO, + SVR4_ENXIO, + SVR4_E2BIG, + SVR4_ENOEXEC, + SVR4_EBADF, + SVR4_ECHILD, + SVR4_EDEADLK, + SVR4_ENOMEM, + SVR4_EACCES, + SVR4_EFAULT, + SVR4_ENOTBLK, + SVR4_EBUSY, + SVR4_EEXIST, + SVR4_EXDEV, + SVR4_ENODEV, + SVR4_ENOTDIR, + SVR4_EISDIR, + SVR4_EINVAL, + SVR4_ENFILE, + SVR4_EMFILE, + SVR4_ENOTTY, + SVR4_ETXTBSY, + SVR4_EFBIG, + SVR4_ENOSPC, + SVR4_ESPIPE, + SVR4_EROFS, + SVR4_EMLINK, + SVR4_EPIPE, + SVR4_EDOM, + SVR4_ERANGE, + SVR4_EAGAIN, + SVR4_EINPROGRESS, + SVR4_EALREADY, + SVR4_ENOTSOCK, + SVR4_EDESTADDRREQ, + SVR4_EMSGSIZE, + SVR4_EPROTOTYPE, + SVR4_ENOPROTOOPT, + SVR4_EPROTONOSUPPORT, + SVR4_ESOCKTNOSUPPORT, + SVR4_EOPNOTSUPP, + SVR4_EPFNOSUPPORT, + SVR4_EAFNOSUPPORT, + SVR4_EADDRINUSE, + SVR4_EADDRNOTAVAIL, + SVR4_ENETDOWN, + SVR4_ENETUNREACH, + SVR4_ENETRESET, + SVR4_ECONNABORTED, + SVR4_ECONNRESET, + SVR4_ENOBUFS, + SVR4_EISCONN, + SVR4_ENOTCONN, + SVR4_ESHUTDOWN, + SVR4_ETOOMANYREFS, + SVR4_ETIMEDOUT, + SVR4_ECONNREFUSED, + SVR4_ELOOP, + SVR4_ENAMETOOLONG, + SVR4_EHOSTDOWN, + SVR4_EHOSTUNREACH, + SVR4_ENOTEMPTY, + SVR4_EPROCLIM, + SVR4_EUSERS, + SVR4_EDQUOT, + SVR4_ESTALE, + SVR4_EREMOTE, + SVR4_EBADRPC, + SVR4_ERPCMISMATCH, + SVR4_EPROGUNAVAIL, + SVR4_EPROGMISMATCH, + SVR4_EPROCUNAVAIL, + SVR4_ENOLCK, + SVR4_ENOSYS, + SVR4_EFTYPE, + SVR4_EAUTH, + SVR4_ENEEDAUTH, +}; diff --git a/sys/compat/svr4/svr4_exec.c b/sys/compat/svr4/svr4_exec.c new file mode 100644 index 00000000000..9393f63736a --- /dev/null +++ b/sys/compat/svr4/svr4_exec.c @@ -0,0 +1,132 @@ +/* $NetBSD: svr4_exec.c,v 1.15 1995/06/24 20:29:19 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/kernel.h> +#include <sys/proc.h> +#include <sys/malloc.h> +#include <sys/namei.h> +#include <sys/vnode.h> +#include <sys/exec_elf.h> + +#include <sys/mman.h> +#include <vm/vm.h> +#include <vm/vm_param.h> +#include <vm/vm_map.h> + +#include <machine/cpu.h> +#include <machine/reg.h> +#include <machine/exec.h> +#include <machine/svr4_machdep.h> + +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_syscall.h> +#include <compat/svr4/svr4_exec.h> + +static void *svr4_copyargs __P((struct exec_package *, struct ps_strings *, + void *, void *)); + +const char svr4_emul_path[] = "/emul/svr4"; +extern int svr4_error[]; +extern char svr4_sigcode[], svr4_esigcode[]; +extern struct sysent svr4_sysent[]; +extern char *svr4_syscallnames[]; + +struct emul emul_svr4 = { + "svr4", + svr4_error, + svr4_sendsig, + SVR4_SYS_syscall, + SVR4_SYS_MAXSYSCALL, + svr4_sysent, + svr4_syscallnames, + SVR4_AUX_ARGSIZ, + svr4_copyargs, + setregs, + svr4_sigcode, + svr4_esigcode, +}; + +static void * +svr4_copyargs(pack, arginfo, stack, argp) + struct exec_package *pack; + struct ps_strings *arginfo; + void *stack; + void *argp; +{ + AuxInfo *a; + struct elf_args *ap; + + if (!(a = (AuxInfo *) elf_copyargs(pack, arginfo, stack, argp))) + return NULL; +#ifdef SVR4_COMPAT_SOLARIS2 + if (pack->ep_emul_arg) { + a->au_id = AUX_sun_uid; + a->au_v = p->p_ucred->cr_uid; + a++; + + a->au_id = AUX_sun_ruid; + a->au_v = p->p_cred->ruid; + a++; + + a->au_id = AUX_sun_gid; + a->au_v = p->p_ucred->cr_gid; + a++; + + a->au_id = AUX_sun_rgid; + a->au_v = p->p_cred->rgid; + a++; + } +#endif + return a; +} + +int +svr4_elf_probe(p, epp, itp, pos) + struct proc *p; + struct exec_package *epp; + char *itp; + u_long *pos; +{ + char *bp; + int error; + size_t len; + + if (itp[0]) { + if ((error = emul_find(p, NULL, svr4_emul_path, itp, &bp, 0))) + return error; + if ((error = copystr(bp, itp, MAXPATHLEN, &len))) + return error; + free(bp, M_TEMP); + } + epp->ep_emul = &emul_svr4; + *pos = SVR4_INTERP_ADDR; + return 0; +} diff --git a/sys/compat/svr4/svr4_exec.h b/sys/compat/svr4/svr4_exec.h new file mode 100644 index 00000000000..747e7866b35 --- /dev/null +++ b/sys/compat/svr4/svr4_exec.h @@ -0,0 +1,67 @@ +/* $NetBSD: svr4_exec.h,v 1.7 1995/07/02 06:16:06 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_EXEC_H_ +#define _SVR4_EXEC_H_ + +#ifdef SVR4_COMPAT_SOLARIS2 +# define SVR4_AUX_ARGSIZ (sizeof(AuxInfo) * 12 / sizeof(char *)) +#else +# define SVR4_AUX_ARGSIZ (sizeof(AuxInfo) * 8 / sizeof(char *)) +#endif + +/* + * The following is horrible; there must be a better way. I need to + * play with brk(2) a bit more. + */ +#ifdef i386 +/* + * I cannot load the interpreter after the data segment because brk(2) + * breaks. I have to load it somewhere before. Programs start at + * 0x08000000 so I load the interpreter far before. + */ +#define SVR4_INTERP_ADDR 0x01000000 +#endif + +#ifdef sparc +/* + * Here programs load at 0x00010000, so I load the interpreter far after + * the end of the data segment. + */ +#define SVR4_INTERP_ADDR 0x10000000 +#endif + +#ifndef SVR4_INTERP_ADDR +# define SVR4_INTERP_ADDR 0 +#endif + +int svr4_elf_probe __P((struct proc *p, struct exec_package *, char *, + u_long *pos)); + +#endif /* !_SVR4_EXEC_H_ */ diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c new file mode 100644 index 00000000000..a2421d32fc7 --- /dev/null +++ b/sys/compat/svr4/svr4_fcntl.c @@ -0,0 +1,450 @@ +/* $NetBSD: svr4_fcntl.c,v 1.13 1995/10/09 23:56:17 thorpej Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/namei.h> +#include <sys/proc.h> +#include <sys/file.h> +#include <sys/stat.h> +#include <sys/filedesc.h> +#include <sys/ioctl.h> +#include <sys/kernel.h> +#include <sys/mount.h> +#include <sys/malloc.h> + +#include <sys/syscallargs.h> + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_fcntl.h> +#include <compat/svr4/svr4_poll.h> + +static u_long +svr4_to_bsd_cmd(cmd) + u_long cmd; +{ + + switch (cmd) { + case SVR4_F_DUPFD: + return F_DUPFD; + case SVR4_F_GETFD: + return F_GETFD; + case SVR4_F_SETFD: + return F_SETFD; + case SVR4_F_GETFL: + return F_GETFL; + case SVR4_F_SETFL: + return F_SETFL; + case SVR4_F_GETLK: + return F_GETLK; + case SVR4_F_SETLK: + return F_SETLK; + case SVR4_F_SETLKW: + return F_SETLKW; + default: + return -1; + } +} + + +static int +svr4_to_bsd_flags(l) + int l; +{ + int r = 0; + r |= (l & SVR4_O_RDONLY) ? O_RDONLY : 0; + r |= (l & SVR4_O_WRONLY) ? O_WRONLY : 0; + r |= (l & SVR4_O_RDWR) ? O_RDWR : 0; + r |= (l & SVR4_O_NDELAY) ? O_NONBLOCK : 0; + r |= (l & SVR4_O_APPEND) ? O_APPEND : 0; + r |= (l & SVR4_O_SYNC) ? O_FSYNC : 0; + r |= (l & SVR4_O_RAIOSIG) ? O_ASYNC : 0; + r |= (l & SVR4_O_NONBLOCK) ? O_NONBLOCK : 0; + r |= (l & SVR4_O_PRIV) ? O_EXLOCK : 0; + r |= (l & SVR4_O_CREAT) ? O_CREAT : 0; + r |= (l & SVR4_O_TRUNC) ? O_TRUNC : 0; + r |= (l & SVR4_O_EXCL) ? O_EXCL : 0; + r |= (l & SVR4_O_NOCTTY) ? O_NOCTTY : 0; + return r; +} + + +static int +bsd_to_svr4_flags(l) + int l; +{ + int r = 0; + r |= (l & O_RDONLY) ? SVR4_O_RDONLY : 0; + r |= (l & O_WRONLY) ? SVR4_O_WRONLY : 0; + r |= (l & O_RDWR) ? SVR4_O_RDWR : 0; + r |= (l & O_NDELAY) ? SVR4_O_NONBLOCK : 0; + r |= (l & O_APPEND) ? SVR4_O_APPEND : 0; + r |= (l & O_FSYNC) ? SVR4_O_SYNC : 0; + r |= (l & O_ASYNC) ? SVR4_O_RAIOSIG : 0; + r |= (l & O_NONBLOCK) ? SVR4_O_NONBLOCK : 0; + r |= (l & O_EXLOCK) ? SVR4_O_PRIV : 0; + r |= (l & O_CREAT) ? SVR4_O_CREAT : 0; + r |= (l & O_TRUNC) ? SVR4_O_TRUNC : 0; + r |= (l & O_EXCL) ? SVR4_O_EXCL : 0; + r |= (l & O_NOCTTY) ? SVR4_O_NOCTTY : 0; + return r; +} + +static void +bsd_to_svr4_flock(iflp, oflp) + struct flock *iflp; + struct svr4_flock *oflp; +{ + switch (iflp->l_type) { + case F_RDLCK: + oflp->l_type = SVR4_F_RDLCK; + break; + case F_WRLCK: + oflp->l_type = SVR4_F_WRLCK; + break; + case F_UNLCK: + oflp->l_type = SVR4_F_UNLCK; + break; + default: + oflp->l_type = -1; + break; + } + + oflp->l_whence = (short) iflp->l_whence; + oflp->l_start = (svr4_off_t) iflp->l_start; + oflp->l_len = (svr4_off_t) iflp->l_len; + oflp->l_sysid = 0; + oflp->l_pid = (svr4_pid_t) iflp->l_pid; +} + + +static void +svr4_to_bsd_flock(iflp, oflp) + struct svr4_flock *iflp; + struct flock *oflp; +{ + switch (iflp->l_type) { + case SVR4_F_RDLCK: + oflp->l_type = F_RDLCK; + break; + case SVR4_F_WRLCK: + oflp->l_type = F_WRLCK; + break; + case SVR4_F_UNLCK: + oflp->l_type = F_UNLCK; + break; + default: + oflp->l_type = -1; + break; + } + + oflp->l_whence = iflp->l_whence; + oflp->l_start = (off_t) iflp->l_start; + oflp->l_len = (off_t) iflp->l_len; + oflp->l_pid = (pid_t) iflp->l_pid; + +} + +int +svr4_sys_open(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_open_args *uap = v; + int error; + struct sys_open_args cup; + + caddr_t sg = stackgap_init(p->p_emul); + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&cup, path) = SCARG(uap, path); + SCARG(&cup, flags) = svr4_to_bsd_flags(SCARG(uap, flags)); + SCARG(&cup, mode) = SCARG(uap, mode); + error = sys_open(p, &cup, retval); + + if (error) + return error; + + if ((SCARG(&cup, flags) & O_NOCTTY) && SESS_LEADER(p) && + !(p->p_flag & P_CONTROLT)) { + struct filedesc *fdp = p->p_fd; + struct file *fp = fdp->fd_ofiles[*retval]; + + /* ignore any error, just give it a try */ + if (fp->f_type == DTYPE_VNODE) + (fp->f_ops->fo_ioctl) (fp, TIOCSCTTY, (caddr_t) 0, p); + } + return 0; +} + + +int +svr4_sys_creat(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_creat_args *uap = v; + struct sys_open_args cup; + + caddr_t sg = stackgap_init(p->p_emul); + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&cup, path) = SCARG(uap, path); + SCARG(&cup, mode) = SCARG(uap, mode); + SCARG(&cup, flags) = O_WRONLY | O_CREAT | O_TRUNC; + + return sys_open(p, &cup, retval); +} + + +int +svr4_sys_access(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_access_args *uap = v; + struct sys_access_args cup; + + caddr_t sg = stackgap_init(p->p_emul); + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&cup, path) = SCARG(uap, path); + SCARG(&cup, flags) = SCARG(uap, flags); + + return sys_access(p, &cup, retval); +} + + +int +svr4_sys_fcntl(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_fcntl_args *uap = v; + int error; + struct sys_fcntl_args fa; + + SCARG(&fa, fd) = SCARG(uap, fd); + SCARG(&fa, cmd) = svr4_to_bsd_cmd(SCARG(uap, cmd)); + + switch (SCARG(&fa, cmd)) { + case F_DUPFD: + case F_GETFD: + case F_SETFD: + SCARG(&fa, arg) = SCARG(uap, arg); + return sys_fcntl(p, &fa, retval); + + case F_GETFL: + SCARG(&fa, arg) = SCARG(uap, arg); + error = sys_fcntl(p, &fa, retval); + if (error) + return error; + *retval = bsd_to_svr4_flags(*retval); + return error; + + case F_SETFL: + SCARG(&fa, arg) = (void *) svr4_to_bsd_flags(SCARG(uap, arg)); + return sys_fcntl(p, &fa, retval); + + case F_GETLK: + case F_SETLK: + case F_SETLKW: + { + struct svr4_flock ifl; + struct flock *flp, fl; + caddr_t sg = stackgap_init(p->p_emul); + + flp = stackgap_alloc(&sg, sizeof(struct flock)); + SCARG(&fa, arg) = (void *) flp; + + error = copyin(SCARG(uap, arg), &ifl, sizeof ifl); + if (error) + return error; + + svr4_to_bsd_flock(&ifl, &fl); + + error = copyout(&fl, flp, sizeof fl); + if (error) + return error; + + error = sys_fcntl(p, &fa, retval); + if (error || SCARG(&fa, cmd) != F_GETLK) + return error; + + error = copyin(flp, &fl, sizeof fl); + if (error) + return error; + + bsd_to_svr4_flock(&fl, &ifl); + + return copyout(&ifl, SCARG(uap, arg), sizeof ifl); + } + default: + return ENOSYS; + } +} + + +static void +svr4_pollscan(p, pl, nfd, retval) + struct proc *p; + struct svr4_pollfd *pl; + int nfd; + register_t *retval; +{ + register struct filedesc *fdp = p->p_fd; + register int msk, i; + struct file *fp; + int n = 0; + static int flag[3] = { FREAD, FWRITE, 0 }; + static int pflag[3] = { SVR4_POLLIN|SVR4_POLLRDNORM, + SVR4_POLLOUT, SVR4_POLLERR }; + + /* + * XXX: We need to implement the rest of the flags. + */ + for (i = 0; i < nfd; i++) { + fp = fdp->fd_ofiles[pl[i].fd]; + if (fp == NULL) { + if (pl[i].events & SVR4_POLLNVAL) { + pl[i].revents |= SVR4_POLLNVAL; + n++; + } + continue; + } + for (msk = 0; msk < 3; msk++) { + if (pl[i].events & pflag[msk]) { + if ((*fp->f_ops->fo_select)(fp, flag[msk], p)) { + pl[i].revents |= + pflag[msk] & pl[i].events; + n++; + } + } + } + } + *retval = n; +} + + +/* + * We are using the same mechanism as select only we encode/decode args + * differently. + */ +int +svr4_sys_poll(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_poll_args *uap = v; + int i, s; + int error, error2; + size_t sz = sizeof(struct svr4_pollfd) * SCARG(uap, nfds); + struct svr4_pollfd *pl; + int msec = SCARG(uap, timeout); + struct timeval atv; + int timo; + u_int ni; + int ncoll; + extern int nselcoll, selwait; + + pl = (struct svr4_pollfd *) malloc(sz, M_TEMP, M_WAITOK); + + if (error = copyin(SCARG(uap, fds), pl, sz)) + goto bad; + + for (i = 0; i < SCARG(uap, nfds); i++) { + DPRINTF(("pollfd %d, %x\n", pl[i].fd, pl[i].events)); + pl[i].revents = 0; + } + + if (msec != -1) { + atv.tv_sec = msec / 1000; + atv.tv_usec = (msec - (atv.tv_sec * 1000)) * 1000; + + if (itimerfix(&atv)) { + error = EINVAL; + goto done; + } + s = splclock(); + timeradd(&atv, &time, &atv); + timo = hzto(&atv); + /* + * Avoid inadvertently sleeping forever. + */ + if (timo == 0) + timo = 1; + splx(s); + } else + timo = 0; + +retry: + ncoll = nselcoll; + p->p_flag |= P_SELECT; + svr4_pollscan(p, pl, SCARG(uap, nfds), retval); + if (*retval) + goto done; + s = splhigh(); + if (timo && timercmp(&time, &atv, >=)) { + splx(s); + goto done; + } + if ((p->p_flag & P_SELECT) == 0 || nselcoll != ncoll) { + splx(s); + goto retry; + } + p->p_flag &= ~P_SELECT; + error = tsleep((caddr_t)&selwait, PSOCK | PCATCH, "svr4_poll", timo); + splx(s); + if (error == 0) + goto retry; + +done: + p->p_flag &= ~P_SELECT; + /* poll is not restarted after signals... */ + if (error == ERESTART) + error = EINTR; + if (error == EWOULDBLOCK) + error = 0; + + if (error2 = copyout(pl, SCARG(uap, fds), sz)) + error = error2; + +bad: + free((char *) pl, M_TEMP); + + return (error); +} diff --git a/sys/compat/svr4/svr4_fcntl.h b/sys/compat/svr4/svr4_fcntl.h new file mode 100644 index 00000000000..3559b4a6dc3 --- /dev/null +++ b/sys/compat/svr4/svr4_fcntl.h @@ -0,0 +1,110 @@ +/* $NetBSD: svr4_fcntl.h,v 1.3 1994/10/29 00:43:19 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_FCNTL_H_ +#define _SVR4_FCNTL_H_ + +#include <compat/svr4/svr4_types.h> +#include <sys/fcntl.h> + +#define SVR4_O_RDONLY 0x0000 +#define SVR4_O_WRONLY 0x0001 +#define SVR4_O_RDWR 0x0002 +#define SVR4_O_ACCMODE 0x0003 +#define SVR4_O_NDELAY 0x0004 +#define SVR4_O_APPEND 0x0008 +#define SVR4_O_SYNC 0x0010 +#define SVR4_O_RAIOSIG 0x0020 +#define SVR4_O_NONBLOCK 0x0080 +#define SVR4_O_CREAT 0x0100 +#define SVR4_O_TRUNC 0x0200 +#define SVR4_O_EXCL 0x0400 +#define SVR4_O_NOCTTY 0x0800 +#define SVR4_O_PRIV 0x1000 + + +#define SVR4_FD_CLOEXEC 1 + +#define SVR4_F_DUPFD 0 +#define SVR4_F_GETFD 1 +#define SVR4_F_SETFD 2 +#define SVR4_F_GETFL 3 +#define SVR4_F_SETFL 4 +#define SVR4_F_GETLK_SVR3 5 +#define SVR4_F_SETLK 6 +#define SVR4_F_SETLKW 7 +#define SVR4_F_CHKFL 8 + +#define SVR4_F_ALLOCSP 10 +#define SVR4_F_FREESP 11 +#define SVR4_F_GETLK 14 + +#define SVR4_F_RSETLK 20 +#define SVR4_F_RGETLK 21 +#define SVR4_F_RSETLKW 22 + +#define SVR4_F_GETOWN 23 +#define SVR4_F_SETOWN 24 + +#define SVR4_F_CHSIZE_XENIX 0x6000 +#define SVR4_F_RDCHK_XENIX 0x6001 +#define SVR4_F_LK_UNLCK_XENIX 0x6300 +#define SVR4_F_LK_LOCK_XENIX 0x7200 +#define SVR4_F_LK_NBLCK_XENIX 0x6200 +#define SVR4_F_LK_RLCK_XENIX 0x7100 +#define SVR4_F_LK_NBRLCK_XENIX 0x6100 + +#define SVR4_LK_CMDTYPE(x) (((x) >> 12) & 0x7) +#define SVR4_LK_LCKTYPE(x) (((x) >> 8) & 0x7) + +#define SVR4_F_RDLCK 1 +#define SVR4_F_WRLCK 2 +#define SVR4_F_UNLCK 3 + +struct svr4_flock_svr3 { + short l_type; + short l_whence; + svr4_off_t l_start; + svr4_off_t l_len; + short l_sysid; + svr4_o_pid_t l_pid; +}; + + +struct svr4_flock { + short l_type; + short l_whence; + svr4_off_t l_start; + svr4_off_t l_len; + long l_sysid; + svr4_pid_t l_pid; + long pad[4]; +}; + +#endif /* !_SVR4_FCNTL_H_ */ diff --git a/sys/compat/svr4/svr4_filio.c b/sys/compat/svr4/svr4_filio.c new file mode 100644 index 00000000000..6f553986c67 --- /dev/null +++ b/sys/compat/svr4/svr4_filio.c @@ -0,0 +1,110 @@ +/* $NetBSD: svr4_filio.c,v 1.3 1995/10/07 06:27:40 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/proc.h> +#include <sys/systm.h> +#include <sys/file.h> +#include <sys/filedesc.h> +#include <sys/ioctl.h> +#include <sys/termios.h> +#include <sys/tty.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <sys/mount.h> +#include <net/if.h> +#include <sys/malloc.h> + +#include <sys/syscallargs.h> + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_stropts.h> +#include <compat/svr4/svr4_ioctl.h> +#include <compat/svr4/svr4_filio.h> + + +int +svr4_filioctl(fp, cmd, data, p, retval) + struct file *fp; + u_long cmd; + caddr_t data; + struct proc *p; + register_t *retval; +{ + struct filedesc *fdp = p->p_fd; + int error; + int fd; + int num; + int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) = + fp->f_ops->fo_ioctl; + + *retval = 0; + + switch (cmd) { + case SVR4_FIOCLEX: + fd = fp - fdp->fd_ofiles[0]; + fdp->fd_ofileflags[fd] |= UF_EXCLOSE; + return 0; + + case SVR4_FIONCLEX: + fd = fp - fdp->fd_ofiles[0]; + fdp->fd_ofileflags[fd] &= ~UF_EXCLOSE; + return 0; + + case SVR4_FIOGETOWN: + case SVR4_FIOSETOWN: + case SVR4_FIOASYNC: + case SVR4_FIONBIO: + case SVR4_FIONREAD: + if ((error = copyin(data, &num, sizeof(num))) != 0) + return error; + + switch (cmd) { + case SVR4_FIOGETOWN: cmd = FIOGETOWN; break; + case SVR4_FIOSETOWN: cmd = FIOSETOWN; break; + case SVR4_FIOASYNC: cmd = FIOASYNC; break; + case SVR4_FIONBIO: cmd = FIONBIO; break; + case SVR4_FIONREAD: cmd = FIONREAD; break; + } + + error = (*ctl)(fp, cmd, (caddr_t) &num, p); + + if (error) + return error; + + return copyout(&num, data, sizeof(num)); + + default: + DPRINTF(("Unknown svr4 filio %x\n", cmd)); + return 0; /* ENOSYS really */ + } +} diff --git a/sys/compat/svr4/svr4_filio.h b/sys/compat/svr4/svr4_filio.h new file mode 100644 index 00000000000..676f8d802de --- /dev/null +++ b/sys/compat/svr4/svr4_filio.h @@ -0,0 +1,44 @@ +/* $NetBSD: svr4_filio.h,v 1.2 1994/11/18 02:53:45 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_FILIO_H_ +#define _SVR4_FILIO_H_ + +#define SVR4_FIOC ('f' << 8) + +#define SVR4_FIOCLEX SVR4_IO('f', 1) +#define SVR4_FIONCLEX SVR4_IO('f', 2) + +#define SVR4_FIOGETOWN SVR4_IOR('f', 123, int) +#define SVR4_FIOSETOWN SVR4_IOW('f', 124, int) +#define SVR4_FIOASYNC SVR4_IOW('f', 125, int) +#define SVR4_FIONBIO SVR4_IOW('f', 126, int) +#define SVR4_FIONREAD SVR4_IOR('f', 127, int) + +#endif /* !_SVR4_FILIO_H_ */ diff --git a/sys/compat/svr4/svr4_fuser.h b/sys/compat/svr4/svr4_fuser.h new file mode 100644 index 00000000000..dd83b89c434 --- /dev/null +++ b/sys/compat/svr4/svr4_fuser.h @@ -0,0 +1,53 @@ +/* $NetBSD: svr4_fuser.h,v 1.3 1994/10/29 00:43:20 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_FUSER_H_ +#define _SVR4_FUSER_H_ + +#include <compat/svr4/svr4_types.h> + +struct svr4_f_user { + svr4_pid_t fu_pid; + int fu_flags; + uid_t fu_uid; +}; + + +#define SVR4_F_FILE_ONLY 1 +#define SVR4_F_CONTAINED 2 + +#define SVR4_F_CDIR 0x01 +#define SVR4_F_RDIR 0x02 +#define SVR4_F_TEXT 0x04 +#define SVR4_F_MAP 0x08 +#define SVR4_F_OPEN 0x10 +#define SVR4_F_TRACE 0x20 +#define SVR4_F_TTY 0x40 + +#endif /* !_SVR4_FUSER_H_ */ diff --git a/sys/compat/svr4/svr4_hrt.h b/sys/compat/svr4/svr4_hrt.h new file mode 100644 index 00000000000..ebbf9322518 --- /dev/null +++ b/sys/compat/svr4/svr4_hrt.h @@ -0,0 +1,86 @@ +/* $NetBSD: svr4_hrt.h,v 1.1 1994/11/18 02:56:09 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_HRT_H_ +#define _SVR4_HRT_H_ + +#define SVR4_HRT_CNTL 0 +#define SVR4_HRT_CNTL_RES 0 +#define SVR4_HRT_CNTL_TOFD 1 +#define SVR4_HRT_CNTL_START 2 +#define SVR4_HRT_CNTL_GET 3 + +#define SVR4_HRT_ALRM 1 +#define SVR4_HRT_ALRM_DO 4 +#define SVR4_HRT_ALRM_REP 5 +#define SVR4_HRT_ALRM_TOD 6 +#define SVR4_HRT_ALRM_FUTREP 7 +#define SVR4_HRT_ALRM_TODREP 8 +#define SVR4_HRT_ALRM_PEND 9 + +#define SVR4_HRT_SLP 2 +#define SVR4_HRT_SLP_INT 10 +#define SVR4_HRT_SLP_TOD 11 + +#define SVR4_HRT_BSD 12 +#define SVR4_HRT_BSD_PEND 13 +#define SVR4_HRT_BSD_REP1 14 +#define SVR4_HRT_BSD_REP2 15 +#define SVR4_HRT_BSD_CANCEL 16 + +#define SVR4_HRT_CAN 3 + +#define SVR4_HRT_SEC 1 +#define SVR4_HRT_MSEC 1000 +#define SVR4_HRT_USEC 1000000 +#define SVR4_HRT_NSEC 1000000000 + +#define SVR4_HRT_TRUNC 0 +#define SVR4_HRT_RND 1 + +typedef struct { + u_long i_word1; + u_long i_word2; + int i_clock; +} svr4_hrt_interval_t; + +typedef struct { + u_long h_sec; + long h_rem; + u_long h_res; +} svr4_hrt_time_t; + +#define SVR4_HRT_DONE 1 +#define SVR4_HRT_ERROR 2 + +#define SVR4_HRT_CLK_STD 1 +#define SVR4_HRT_CLK_USERVIRT 2 +#define SVR4_HRT_CLK_PROCVIRT 4 + +#endif /* !_SVR4_HRT_H_ */ diff --git a/sys/compat/svr4/svr4_ioctl.c b/sys/compat/svr4/svr4_ioctl.c new file mode 100644 index 00000000000..355e5135c87 --- /dev/null +++ b/sys/compat/svr4/svr4_ioctl.c @@ -0,0 +1,135 @@ +/* $NetBSD: svr4_ioctl.c,v 1.12 1995/10/07 06:27:41 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/proc.h> +#include <sys/systm.h> +#include <sys/file.h> +#include <sys/filedesc.h> +#include <sys/ioctl.h> +#include <sys/termios.h> +#include <sys/tty.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <sys/mount.h> +#include <net/if.h> +#include <sys/malloc.h> + +#include <sys/syscallargs.h> + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_stropts.h> +#include <compat/svr4/svr4_ioctl.h> +#include <compat/svr4/svr4_termios.h> +#include <compat/svr4/svr4_ttold.h> +#include <compat/svr4/svr4_filio.h> +#include <compat/svr4/svr4_sockio.h> + +#ifdef DEBUG_SVR4 +/* + * Decode an ioctl command symbolically + */ +void +svr4_decode_cmd(cmd, dir, c, num, argsiz) + u_long cmd; + char *dir, *c; + int *num, *argsiz; +{ + if (cmd & SVR4_IOC_VOID) + *dir++ = 'V'; + if (cmd & SVR4_IOC_IN) + *dir++ = 'R'; + if (cmd & SVR4_IOC_OUT) + *dir++ = 'W'; + *dir = '\0'; + if (cmd & SVR4_IOC_INOUT) + *argsiz = (cmd >> 16) & 0xff; + else + *argsiz = -1; + + *c = (cmd >> 8) & 0xff; + *num = cmd & 0xff; +} +#endif + +int +svr4_sys_ioctl(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_ioctl_args *uap = v; + struct file *fp; + struct filedesc *fdp; + u_long cmd; +#ifdef DEBUG_SVR4 + char dir[4]; + char c; + int num; + int argsiz; + + svr4_decode_cmd(SCARG(uap, com), dir, &c, &num, &argsiz); + + printf("svr4_ioctl(%d, _IO%s(%c, %d, %d), %x);\n", SCARG(uap, fd), + dir, c, num, argsiz, SCARG(uap, data)); +#endif + fdp = p->p_fd; + cmd = SCARG(uap, com); + + if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || + (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) + return EBADF; + + if ((fp->f_flag & (FREAD | FWRITE)) == 0) + return EBADF; + + switch (cmd & 0xff00) { + case SVR4_tIOC: + return svr4_ttoldioctl(fp, cmd, SCARG(uap, data), p, retval); + + case SVR4_TIOC: + return svr4_termioctl(fp, cmd, SCARG(uap, data), p, retval); + + case SVR4_STR: + return svr4_streamioctl(fp, cmd, SCARG(uap, data), p, retval); + + case SVR4_FIOC: + return svr4_filioctl(fp, cmd, SCARG(uap, data), p, retval); + + case SVR4_SIOC: + return svr4_sockioctl(fp, cmd, SCARG(uap, data), p, retval); + + default: + DPRINTF(("Unimplemented ioctl %x\n", cmd)); + return 0; /* XXX: really ENOSYS */ + } +} diff --git a/sys/compat/svr4/svr4_ioctl.h b/sys/compat/svr4/svr4_ioctl.h new file mode 100644 index 00000000000..ba35ae9701b --- /dev/null +++ b/sys/compat/svr4/svr4_ioctl.h @@ -0,0 +1,57 @@ +/* $NetBSD: svr4_ioctl.h,v 1.4 1995/10/07 06:27:42 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_IOCTL_H_ +#define _SVR4_IOCTL_H_ + +#define SVR4_IOC_VOID 0x20000000 +#define SVR4_IOC_OUT 0x40000000 +#define SVR4_IOC_IN 0x80000000 +#define SVR4_IOC_INOUT (SVR4_IOC_IN|SVR4_IOC_OUT) + +#define SVR4_IOC(inout,group,num,len) \ + (inout | ((len & 0xff) << 16) | ((group) << 8) | (num)) + +#define SVR4_IO(g,n) SVR4_IOC(SVR4_IOC_VOID, (g), (n), 0) +#define SVR4_IOR(g,n,t) SVR4_IOC(SVR4_IOC_OUT, (g), (n), sizeof(t)) +#define SVR4_IOW(g,n,t) SVR4_IOC(SVR4_IOC_IN, (g), (n), sizeof(t)) +#define SVR4_IOWR(g,n,t) SVR4_IOC(SVR4_IOC_INOUT,(g), (n), sizeof(t)) + +int svr4_streamioctl __P((struct file *fp, u_long cmd, caddr_t data, + struct proc *p, register_t *retval)); +int svr4_termioctl __P((struct file *fp, u_long cmd, caddr_t data, + struct proc *p, register_t *retval)); +int svr4_ttoldioctl __P((struct file *fp, u_long cmd, caddr_t data, + struct proc *p, register_t *retval)); +int svr4_filioctl __P((struct file *fp, u_long cmd, caddr_t data, + struct proc *p, register_t *retval)); +int svr4_sockioctl __P((struct file *fp, u_long cmd, caddr_t data, + struct proc *p, register_t *retval)); + +#endif /* !_SVR4_IOCTL_H_ */ diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c new file mode 100644 index 00000000000..bab1d019d8d --- /dev/null +++ b/sys/compat/svr4/svr4_misc.c @@ -0,0 +1,1199 @@ +/* $NetBSD: svr4_misc.c,v 1.28 1995/10/09 11:24:17 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * SVR4 compatibility module. + * + * SVR4 system calls that are implemented differently in BSD are + * handled here. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/namei.h> +#include <sys/dir.h> +#include <sys/proc.h> +#include <sys/file.h> +#include <sys/stat.h> +#include <sys/time.h> +#include <sys/filedesc.h> +#include <sys/ioctl.h> +#include <sys/kernel.h> +#include <sys/malloc.h> +#include <sys/mbuf.h> +#include <sys/mman.h> +#include <sys/mount.h> +#include <sys/resource.h> +#include <sys/resourcevar.h> +#include <sys/socket.h> +#include <sys/vnode.h> +#include <sys/uio.h> +#include <sys/wait.h> +#include <sys/utsname.h> +#include <sys/unistd.h> +#include <sys/times.h> +#include <sys/sem.h> +#include <sys/msg.h> + +#include <netinet/in.h> +#include <sys/syscallargs.h> + +#include <miscfs/specfs/specdev.h> + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_time.h> +#include <compat/svr4/svr4_dirent.h> +#include <compat/svr4/svr4_ulimit.h> +#include <compat/svr4/svr4_hrt.h> +#include <compat/svr4/svr4_wait.h> +#include <compat/svr4/svr4_statvfs.h> +#include <compat/svr4/svr4_sysconfig.h> + +#include <vm/vm.h> +/* XXX */ extern struct proc *pfind(); + +static __inline clock_t timeval_to_clock_t __P((struct timeval *)); +static int svr4_setinfo __P((struct proc *, int, svr4_siginfo_t *)); + +struct svr4_hrtcntl_args; +static int svr4_hrtcntl __P((struct proc *, struct svr4_hrtcntl_args *, + register_t *)); +static void bsd_statfs_to_svr4_statvfs __P((const struct statfs *, + struct svr4_statvfs *)); +static struct proc *svr4_pfind __P((pid_t pid)); + +int +svr4_sys_wait(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_wait_args *uap = v; + struct sys_wait4_args w4; + int error; + size_t sz = sizeof(*SCARG(&w4, status)); + + SCARG(&w4, rusage) = NULL; + SCARG(&w4, options) = 0; + + if (SCARG(uap, status) == NULL) { + caddr_t sg = stackgap_init(p->p_emul); + SCARG(&w4, status) = stackgap_alloc(&sg, sz); + } + else + SCARG(&w4, status) = SCARG(uap, status); + + SCARG(&w4, pid) = WAIT_ANY; + + if ((error = sys_wait4(p, &w4, retval)) != 0) + return error; + + /* + * It looks like wait(2) on svr4/solaris/2.4 returns + * the status in retval[1], and the pid on retval[0]. + * NB: this can break if register_t stops being an int. + */ + return copyin(SCARG(&w4, status), &retval[1], sz); +} + + +int +svr4_sys_execv(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_execv_args *uap = v; + struct sys_execve_args ex; + + caddr_t sg = stackgap_init(p->p_emul); + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&ex, path) = SCARG(uap, path); + SCARG(&ex, argp) = SCARG(uap, argp); + SCARG(&ex, envp) = NULL; + + return sys_execve(p, &ex, retval); +} + + +int +svr4_sys_execve(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct sys_execve_args *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + return sys_execve(p, uap, retval); +} + + +int +svr4_sys_time(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_time_args *uap = v; + int error = 0; + struct timeval tv; + + microtime(&tv); + if (SCARG(uap, t)) + error = copyout(&tv.tv_sec, SCARG(uap, t), + sizeof(*(SCARG(uap, t)))); + *retval = (int) tv.tv_sec; + + return error; +} + + +/* + * Read SVR4-style directory entries. We suck them into kernel space so + * that they can be massaged before being copied out to user code. Like + * SunOS, we squish out `empty' entries. + * + * This is quite ugly, but what do you expect from compatibility code? + */ +int +svr4_sys_getdents(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_getdents_args *uap = v; + register struct dirent *bdp; + struct vnode *vp; + caddr_t inp, buf; /* BSD-format */ + int len, reclen; /* BSD-format */ + caddr_t outp; /* SVR4-format */ + int resid, svr4_reclen; /* SVR4-format */ + struct file *fp; + struct uio auio; + struct iovec aiov; + struct svr4_dirent idb; + off_t off; /* true file offset */ + int buflen, error, eofflag; + u_long *cookiebuf, *cookie; + int ncookies; + + if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0) + return (error); + + if ((fp->f_flag & FREAD) == 0) + return (EBADF); + + vp = (struct vnode *)fp->f_data; + + if (vp->v_type != VDIR) /* XXX vnode readdir op should do this */ + return (EINVAL); + + buflen = min(MAXBSIZE, SCARG(uap, nbytes)); + buf = malloc(buflen, M_TEMP, M_WAITOK); + ncookies = buflen / 16; + cookiebuf = malloc(ncookies * sizeof(*cookiebuf), M_TEMP, M_WAITOK); + VOP_LOCK(vp); + off = fp->f_offset; +again: + aiov.iov_base = buf; + aiov.iov_len = buflen; + auio.uio_iov = &aiov; + auio.uio_iovcnt = 1; + auio.uio_rw = UIO_READ; + auio.uio_segflg = UIO_SYSSPACE; + auio.uio_procp = p; + auio.uio_resid = buflen; + auio.uio_offset = off; + /* + * First we read into the malloc'ed buffer, then + * we massage it into user space, one record at a time. + */ + error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, cookiebuf, + ncookies); + if (error) + goto out; + + inp = buf; + outp = SCARG(uap, buf); + resid = SCARG(uap, nbytes); + if ((len = buflen - auio.uio_resid) == 0) + goto eof; + + for (cookie = cookiebuf; len > 0; len -= reclen) { + bdp = (struct dirent *)inp; + reclen = bdp->d_reclen; + if (reclen & 3) + panic("svr4_getdents"); + off = *cookie++; /* each entry points to the next */ + if (bdp->d_fileno == 0) { + inp += reclen; /* it is a hole; squish it out */ + continue; + } + svr4_reclen = SVR4_RECLEN(&idb, bdp->d_namlen); + if (reclen > len || resid < svr4_reclen) { + /* entry too big for buffer, so just stop */ + outp++; + break; + } + /* + * Massage in place to make a SVR4-shaped dirent (otherwise + * we have to worry about touching user memory outside of + * the copyout() call). + */ + idb.d_ino = (svr4_ino_t)bdp->d_fileno; + idb.d_off = (svr4_off_t)off; + idb.d_reclen = (u_short)svr4_reclen; + strcpy(idb.d_name, bdp->d_name); + if ((error = copyout((caddr_t)&idb, outp, svr4_reclen))) + goto out; + /* advance past this real entry */ + inp += reclen; + /* advance output past SVR4-shaped entry */ + outp += svr4_reclen; + resid -= svr4_reclen; + } + + /* if we squished out the whole block, try again */ + if (outp == SCARG(uap, buf)) + goto again; + fp->f_offset = off; /* update the vnode offset */ + +eof: + *retval = SCARG(uap, nbytes) - resid; +out: + VOP_UNLOCK(vp); + free(cookiebuf, M_TEMP); + free(buf, M_TEMP); + return error; +} + +int +svr4_sys_mmap(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_mmap_args *uap = v; + struct filedesc *fdp; + struct file *fp; + struct vnode *vp; + struct sys_mmap_args mm; + caddr_t rp; +#define _MAP_NEW 0x80000000 + /* + * Verify the arguments. + */ + if (SCARG(uap, prot) & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) + return EINVAL; /* XXX still needed? */ + + SCARG(&mm, prot) = SCARG(uap, prot); + SCARG(&mm, len) = SCARG(uap, len); + SCARG(&mm, flags) = SCARG(uap, flags) & ~_MAP_NEW; + SCARG(&mm, fd) = SCARG(uap, fd); + SCARG(&mm, addr) = SCARG(uap, addr); + SCARG(&mm, pos) = SCARG(uap, pos); + + rp = (caddr_t) round_page(p->p_vmspace->vm_daddr + MAXDSIZ); + if ((SCARG(&mm, flags) & MAP_FIXED) == 0 && + SCARG(&mm, addr) != 0 && SCARG(&mm, addr) < rp) + SCARG(&mm, addr) = rp; + + return sys_mmap(p, &mm, retval); +} + +int +svr4_sys_fchroot(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_fchroot_args *uap = v; + struct filedesc *fdp = p->p_fd; + struct vnode *vp; + struct file *fp; + int error; + + if ((error = suser(p->p_ucred, &p->p_acflag)) != 0) + return error; + if ((error = getvnode(fdp, SCARG(uap, fd), &fp)) != 0) + return error; + vp = (struct vnode *) fp->f_data; + VOP_LOCK(vp); + if (vp->v_type != VDIR) + error = ENOTDIR; + else + error = VOP_ACCESS(vp, VEXEC, p->p_ucred, p); + VOP_UNLOCK(vp); + if (error) + return error; + VREF(vp); + if (fdp->fd_rdir != NULL) + vrele(fdp->fd_rdir); + fdp->fd_rdir = vp; + return 0; +} + + +int +svr4_sys_mknod(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_mknod_args *uap = v; + caddr_t sg = stackgap_init(p->p_emul); + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + if (S_ISFIFO(SCARG(uap, mode))) { + struct sys_mkfifo_args ap; + SCARG(&ap, path) = SCARG(uap, path); + SCARG(&ap, mode) = SCARG(uap, mode); + return sys_mkfifo(p, &ap, retval); + } else { + struct sys_mknod_args ap; + SCARG(&ap, path) = SCARG(uap, path); + SCARG(&ap, mode) = SCARG(uap, mode); + SCARG(&ap, dev) = SCARG(uap, dev); + return sys_mknod(p, &ap, retval); + } +} + +int +svr4_sys_vhangup(p, v, retval) + struct proc *p; + void *v; + register_t *retval; +{ + return 0; +} + + +int +svr4_sys_sysconfig(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_sysconfig_args *uap = v; + extern int maxfiles; + + switch (SCARG(uap, name)) { + case SVR4_CONFIG_UNUSED: + *retval = 0; + break; + case SVR4_CONFIG_NGROUPS: + *retval = NGROUPS_MAX; + break; + case SVR4_CONFIG_CHILD_MAX: + *retval = maxproc; + break; + case SVR4_CONFIG_OPEN_FILES: + *retval = maxfiles; + break; + case SVR4_CONFIG_POSIX_VER: + *retval = 198808; + break; + case SVR4_CONFIG_PAGESIZE: + *retval = NBPG; + break; + case SVR4_CONFIG_CLK_TCK: + *retval = 60; /* should this be `hz', ie. 100? */ + break; + case SVR4_CONFIG_XOPEN_VER: + *retval = 2; /* XXX: What should that be? */ + break; + case SVR4_CONFIG_PROF_TCK: + *retval = 60; /* XXX: What should that be? */ + break; + case SVR4_CONFIG_NPROC_CONF: + *retval = 1; /* Only one processor for now */ + break; + case SVR4_CONFIG_NPROC_ONLN: + *retval = 1; /* And it better be online */ + break; + case SVR4_CONFIG_AIO_LISTIO_MAX: + case SVR4_CONFIG_AIO_MAX: + case SVR4_CONFIG_AIO_PRIO_DELTA_MAX: + *retval = 0; /* No aio support */ + break; + case SVR4_CONFIG_DELAYTIMER_MAX: + *retval = 0; /* No delaytimer support */ + break; + case SVR4_CONFIG_MQ_OPEN_MAX: + *retval = msginfo.msgmni; + break; + case SVR4_CONFIG_MQ_PRIO_MAX: + *retval = 0; /* XXX: Don't know */ + break; + case SVR4_CONFIG_RTSIG_MAX: + *retval = 0; + break; + case SVR4_CONFIG_SEM_NSEMS_MAX: + *retval = seminfo.semmni; + break; + case SVR4_CONFIG_SEM_VALUE_MAX: + *retval = seminfo.semvmx; + break; + case SVR4_CONFIG_SIGQUEUE_MAX: + *retval = 0; /* XXX: Don't know */ + break; + case SVR4_CONFIG_SIGRT_MIN: + case SVR4_CONFIG_SIGRT_MAX: + *retval = 0; /* No real time signals */ + break; + case SVR4_CONFIG_TIMER_MAX: + *retval = 3; /* XXX: real, virtual, profiling */ + break; + case SVR4_CONFIG_PHYS_PAGES: + *retval = cnt.v_free_count; /* XXX: free instead of total */ + break; + case SVR4_CONFIG_AVPHYS_PAGES: + *retval = cnt.v_active_count; /* XXX: active instead of avg */ + break; + default: + return EINVAL; + } + return 0; +} + +#define SVR4_RLIMIT_NOFILE 5 /* Other RLIMIT_* are the same */ +#define SVR4_RLIMIT_VMEM 6 /* Other RLIMIT_* are the same */ +#define SVR4_RLIM_NLIMITS 7 + +int +svr4_sys_getrlimit(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_getrlimit_args *uap = v; + struct compat_43_sys_getrlimit_args ap; + + if (SCARG(uap, which) >= SVR4_RLIM_NLIMITS) + return EINVAL; + + if (SCARG(uap, which) == SVR4_RLIMIT_NOFILE) + SCARG(uap, which) = RLIMIT_NOFILE; + if (SCARG(uap, which) == SVR4_RLIMIT_VMEM) + SCARG(uap, which) = RLIMIT_RSS; + + SCARG(&ap, which) = SCARG(uap, which); + SCARG(&ap, rlp) = SCARG(uap, rlp); + + return compat_43_sys_getrlimit(p, &ap, retval); +} + +int +svr4_sys_setrlimit(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_setrlimit_args *uap = v; + struct compat_43_sys_setrlimit_args ap; + + if (SCARG(uap, which) >= SVR4_RLIM_NLIMITS) + return EINVAL; + + if (SCARG(uap, which) == SVR4_RLIMIT_NOFILE) + SCARG(uap, which) = RLIMIT_NOFILE; + if (SCARG(uap, which) == SVR4_RLIMIT_VMEM) + SCARG(uap, which) = RLIMIT_RSS; + + SCARG(&ap, which) = SCARG(uap, which); + SCARG(&ap, rlp) = SCARG(uap, rlp); + + return compat_43_sys_setrlimit(p, uap, retval); +} + + +/* ARGSUSED */ +int +svr4_sys_break(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_break_args *uap = v; + register struct vmspace *vm = p->p_vmspace; + vm_offset_t new, old; + int rv; + register int diff; + + old = (vm_offset_t) vm->vm_daddr; + new = round_page(SCARG(uap, nsize)); + diff = new - old; + + DPRINTF(("break(1): old %x new %x diff %x\n", old, new, diff)); + + if (diff > p->p_rlimit[RLIMIT_DATA].rlim_cur) + return ENOMEM; + + old = round_page(old + ctob(vm->vm_dsize)); + DPRINTF(("break(2): dsize = %x ctob %x\n", + vm->vm_dsize, ctob(vm->vm_dsize))); + + diff = new - old; + DPRINTF(("break(3): old %x new %x diff %x\n", old, new, diff)); + + if (diff > 0) { + rv = vm_allocate(&vm->vm_map, &old, diff, FALSE); + if (rv != KERN_SUCCESS) { + uprintf("sbrk: grow failed, return = %d\n", rv); + return ENOMEM; + } + vm->vm_dsize += btoc(diff); + } else if (diff < 0) { + diff = -diff; + rv = vm_deallocate(&vm->vm_map, new, diff); + if (rv != KERN_SUCCESS) { + uprintf("sbrk: shrink failed, return = %d\n", rv); + return ENOMEM; + } + vm->vm_dsize -= btoc(diff); + } + return 0; +} + +static __inline clock_t +timeval_to_clock_t(tv) + struct timeval *tv; +{ + return tv->tv_sec * hz + tv->tv_usec / (1000000 / hz); +} + +int +svr4_sys_times(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_times_args *uap = v; + int error; + struct tms tms; + struct timeval t; + struct rusage *ru; + struct rusage r; + struct sys_getrusage_args ga; + + caddr_t sg = stackgap_init(p->p_emul); + ru = stackgap_alloc(&sg, sizeof(struct rusage)); + + SCARG(&ga, who) = RUSAGE_SELF; + SCARG(&ga, rusage) = ru; + + error = sys_getrusage(p, &ga, retval); + if (error) + return error; + + if (error = copyin(ru, &r, sizeof r)) + return error; + + tms.tms_utime = timeval_to_clock_t(&r.ru_utime); + tms.tms_stime = timeval_to_clock_t(&r.ru_stime); + + SCARG(&ga, who) = RUSAGE_CHILDREN; + error = sys_getrusage(p, &ga, retval); + if (error) + return error; + + if (error = copyin(ru, &r, sizeof r)) + return error; + + tms.tms_cutime = timeval_to_clock_t(&r.ru_utime); + tms.tms_cstime = timeval_to_clock_t(&r.ru_stime); + + microtime(&t); + *retval = timeval_to_clock_t(&t); + + return copyout(&tms, SCARG(uap, tp), sizeof(tms)); +} + + +int +svr4_sys_ulimit(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_ulimit_args *uap = v; + + switch (SCARG(uap, cmd)) { + case SVR4_GFILLIM: + *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur / 512; + return 0; + + case SVR4_SFILLIM: + { + int error; + struct sys_setrlimit_args srl; + struct rlimit krl; + caddr_t sg = stackgap_init(p->p_emul); + struct rlimit *url = (struct rlimit *) + stackgap_alloc(&sg, sizeof *url); + + krl.rlim_cur = SCARG(uap, newlimit) * 512; + krl.rlim_max = p->p_rlimit[RLIMIT_FSIZE].rlim_max; + + error = copyout(&krl, url, sizeof(*url)); + if (error) + return error; + + srl.which = RLIMIT_FSIZE; + srl.rlp = url; + + error = sys_setrlimit(p, &srl, retval); + if (error) + return error; + + *retval = p->p_rlimit[RLIMIT_FSIZE].rlim_cur; + return 0; + } + + case SVR4_GMEMLIM: + { + struct vmspace *vm = p->p_vmspace; + *retval = (long) vm->vm_daddr + + p->p_rlimit[RLIMIT_DATA].rlim_cur; + return 0; + } + + case SVR4_GDESLIM: + *retval = p->p_rlimit[RLIMIT_NOFILE].rlim_cur; + return 0; + + default: + return ENOSYS; + } +} + + +static struct proc * +svr4_pfind(pid) + pid_t pid; +{ + struct proc *p; + + /* look in the live processes */ + if ((p = pfind(pid)) != NULL) + return p; + + /* look in the zombies */ + for (p = zombproc.lh_first; p != 0; p = p->p_list.le_next) + if (p->p_pid == pid) + return p; + + return NULL; +} + + +int +svr4_sys_pgrpsys(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_pgrpsys_args *uap = v; + int error; + + switch (SCARG(uap, cmd)) { + case 0: /* getpgrp() */ + *retval = p->p_pgrp->pg_id; + return 0; + + case 1: /* setpgrp() */ + { + struct sys_setpgid_args sa; + + SCARG(&sa, pid) = 0; + SCARG(&sa, pgid) = 0; + if ((error = sys_setpgid(p, &sa, retval)) != 0) + return error; + *retval = p->p_pgrp->pg_id; + return 0; + } + + case 2: /* getsid(pid) */ + if (SCARG(uap, pid) != 0 && + (p = svr4_pfind(SCARG(uap, pid))) == NULL) + return ESRCH; + /* + * we return the pid of the session leader for this + * process + */ + *retval = (register_t) p->p_session->s_leader->p_pid; + return 0; + + case 3: /* setsid() */ + return sys_setsid(p, NULL, retval); + + case 4: /* getpgid(pid) */ + + if (SCARG(uap, pid) != 0 && + (p = svr4_pfind(SCARG(uap, pid))) == NULL) + return ESRCH; + + *retval = (int) p->p_pgrp->pg_id; + return 0; + + case 5: /* setpgid(pid, pgid); */ + { + struct sys_setpgid_args sa; + + SCARG(&sa, pid) = SCARG(uap, pid); + SCARG(&sa, pgid) = SCARG(uap, pgid); + return sys_setpgid(p, &sa, retval); + } + + default: + return EINVAL; + } +} + +#define syscallarg(x) union { x datum; register_t pad; } + +struct svr4_hrtcntl_args { + syscallarg(int) cmd; + syscallarg(int) fun; + syscallarg(int) clk; + syscallarg(svr4_hrt_interval_t *) iv; + syscallarg(svr4_hrt_time_t *) ti; +}; + +static int +svr4_hrtcntl(p, uap, retval) + register struct proc *p; + register struct svr4_hrtcntl_args *uap; + register_t *retval; +{ + switch (SCARG(uap, fun)) { + case SVR4_HRT_CNTL_RES: + DPRINTF(("htrcntl(RES)\n")); + *retval = SVR4_HRT_USEC; + return 0; + + case SVR4_HRT_CNTL_TOFD: + DPRINTF(("htrcntl(TOFD)\n")); + { + struct timeval tv; + svr4_hrt_time_t t; + if (SCARG(uap, clk) != SVR4_HRT_CLK_STD) { + DPRINTF(("clk == %d\n", SCARG(uap, clk))); + return EINVAL; + } + if (SCARG(uap, ti) == NULL) { + DPRINTF(("ti NULL\n")); + return EINVAL; + } + microtime(&tv); + t.h_sec = tv.tv_sec; + t.h_rem = tv.tv_usec; + t.h_res = SVR4_HRT_USEC; + return copyout(&t, SCARG(uap, ti), sizeof(t)); + } + + case SVR4_HRT_CNTL_START: + DPRINTF(("htrcntl(START)\n")); + return ENOSYS; + + case SVR4_HRT_CNTL_GET: + DPRINTF(("htrcntl(GET)\n")); + return ENOSYS; + default: + DPRINTF(("Bad htrcntl command %d\n", SCARG(uap, fun))); + return ENOSYS; + } +} + +int +svr4_sys_hrtsys(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_hrtsys_args *uap = v; + int error; + struct timeval tv; + + switch (SCARG(uap, cmd)) { + case SVR4_HRT_CNTL: + return svr4_hrtcntl(p, (struct svr4_hrtcntl_args *) uap, + retval); + + case SVR4_HRT_ALRM: + DPRINTF(("hrtalarm\n")); + return ENOSYS; + + case SVR4_HRT_SLP: + DPRINTF(("hrtsleep\n")); + return ENOSYS; + + case SVR4_HRT_CAN: + DPRINTF(("hrtcancel\n")); + return ENOSYS; + + default: + DPRINTF(("Bad hrtsys command %d\n", SCARG(uap, cmd))); + return EINVAL; + } +} + +static int +svr4_setinfo(p, st, s) + struct proc *p; + int st; + svr4_siginfo_t *s; +{ + svr4_siginfo_t i; + + bzero(&i, sizeof(i)); + + i.si_signo = SVR4_SIGCHLD; + i.si_errno = 0; /* XXX? */ + + if (p) { + i.si_pid = p->p_pid; + i.si_stime = p->p_ru->ru_stime.tv_sec; + i.si_utime = p->p_ru->ru_utime.tv_sec; + } + + if (WIFEXITED(st)) { + i.si_status = WEXITSTATUS(st); + i.si_code = SVR4_CLD_EXITED; + } + else if (WIFSTOPPED(st)) { + i.si_status = bsd_to_svr4_sig[WSTOPSIG(st)]; + + if (i.si_status == SVR4_SIGCONT) + i.si_code = SVR4_CLD_CONTINUED; + else + i.si_code = SVR4_CLD_STOPPED; + } else { + i.si_status = bsd_to_svr4_sig[WTERMSIG(st)]; + + if (WCOREDUMP(st)) + i.si_code = SVR4_CLD_DUMPED; + else + i.si_code = SVR4_CLD_KILLED; + } + + DPRINTF(("siginfo [pid %d signo %d code %d errno %d status %d]\n", + i.si_pid, i.si_signo, i.si_code, i.si_errno, i.si_status)); + + return copyout(&i, s, sizeof(i)); +} + + +int +svr4_sys_waitsys(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_waitsys_args *uap = v; + int nfound; + int error; + struct proc *q, *t; + + + switch (SCARG(uap, grp)) { + case SVR4_P_PID: + break; + + case SVR4_P_PGID: + SCARG(uap, id) = -p->p_pgid; + break; + + case SVR4_P_ALL: + SCARG(uap, id) = WAIT_ANY; + break; + + default: + return EINVAL; + } + + DPRINTF(("waitsys(%d, %d, %x, %x)\n", + SCARG(uap, grp), SCARG(uap, id), SCARG(uap, info), + SCARG(uap, options))); + +loop: + nfound = 0; + for (q = p->p_children.lh_first; q != 0; q = q->p_sibling.le_next) { + if (SCARG(uap, id) != WAIT_ANY && + q->p_pid != SCARG(uap, id) && + q->p_pgid != -SCARG(uap, id)) { + DPRINTF(("pid %d pgid %d != %d\n", q->p_pid, + q->p_pgid, SCARG(uap, id))); + continue; + } + nfound++; + if (q->p_stat == SZOMB && + ((SCARG(uap, options) & (SVR4_WEXITED|SVR4_WTRAPPED)))) { + *retval = 0; + DPRINTF(("found %d\n", q->p_pid)); + if ((error = svr4_setinfo(q, q->p_xstat, + SCARG(uap, info))) != 0) + return error; + + + if ((SCARG(uap, options) & SVR4_WNOWAIT)) { + DPRINTF(("Don't wait\n")); + return 0; + } + + /* + * If we got the child via a ptrace 'attach', + * we need to give it back to the old parent. + */ + if (q->p_oppid && (t = pfind(q->p_oppid))) { + q->p_oppid = 0; + proc_reparent(q, t); + psignal(t, SIGCHLD); + wakeup((caddr_t)t); + return 0; + } + q->p_xstat = 0; + ruadd(&p->p_stats->p_cru, q->p_ru); + FREE(q->p_ru, M_ZOMBIE); + + /* + * Decrement the count of procs running with this uid. + */ + (void)chgproccnt(q->p_cred->p_ruid, -1); + + /* + * Free up credentials. + */ + if (--q->p_cred->p_refcnt == 0) { + crfree(q->p_cred->pc_ucred); + FREE(q->p_cred, M_SUBPROC); + } + + /* + * Release reference to text vnode + */ + if (q->p_textvp) + vrele(q->p_textvp); + + /* + * Finally finished with old proc entry. + * Unlink it from its process group and free it. + */ + leavepgrp(q); + LIST_REMOVE(q, p_list); /* off zombproc */ + LIST_REMOVE(q, p_sibling); + + /* + * Give machine-dependent layer a chance + * to free anything that cpu_exit couldn't + * release while still running in process context. + */ + cpu_wait(q); + FREE(q, M_PROC); + nprocs--; + return 0; + } + if (q->p_stat == SSTOP && (q->p_flag & P_WAITED) == 0 && + (q->p_flag & P_TRACED || + (SCARG(uap, options) & (SVR4_WSTOPPED|SVR4_WCONTINUED)))) { + DPRINTF(("jobcontrol %d\n", q->p_pid)); + if (((SCARG(uap, options) & SVR4_WNOWAIT)) == 0) + q->p_flag |= P_WAITED; + else + DPRINTF(("Don't wait\n")); + *retval = 0; + return svr4_setinfo(q, W_STOPCODE(q->p_xstat), + SCARG(uap, info)); + } + } + + if (nfound == 0) + return ECHILD; + + if (SCARG(uap, options) & SVR4_WNOHANG) { + *retval = 0; + if ((error = svr4_setinfo(NULL, 0, SCARG(uap, info))) != 0) + return error; + return 0; + } + + if (error = tsleep((caddr_t)p, PWAIT | PCATCH, "svr4_wait", 0)) + return error; + goto loop; +} + + +static void +bsd_statfs_to_svr4_statvfs(bfs, sfs) + const struct statfs *bfs; + struct svr4_statvfs *sfs; +{ + sfs->f_bsize = bfs->f_bsize; + sfs->f_frsize = bfs->f_bsize / 8; /* XXX */ + sfs->f_blocks = bfs->f_blocks; + sfs->f_bfree = bfs->f_bfree; + sfs->f_bavail = bfs->f_bavail; + sfs->f_files = bfs->f_files; + sfs->f_ffree = bfs->f_ffree; + sfs->f_favail = bfs->f_ffree; + sfs->f_fsid = bfs->f_fsid.val[0]; + bcopy(bfs->f_fstypename, sfs->f_basetype, sizeof(sfs->f_basetype)); + sfs->f_flag = 0; + if (bfs->f_flags & MNT_RDONLY) + sfs->f_flag |= SVR4_ST_RDONLY; + if (bfs->f_flags & MNT_NOSUID) + sfs->f_flag |= SVR4_ST_NOSUID; + sfs->f_namemax = MAXNAMLEN; + bcopy(bfs->f_fstypename, sfs->f_fstr, sizeof(sfs->f_fstr)); /* XXX */ + bzero(sfs->f_filler, sizeof(sfs->f_filler)); +} + + +int +svr4_sys_statvfs(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_statvfs_args *uap = v; + struct sys_statfs_args fs_args; + caddr_t sg = stackgap_init(p->p_emul); + struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs)); + struct statfs bfs; + struct svr4_statvfs sfs; + int error; + + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + SCARG(&fs_args, path) = SCARG(uap, path); + SCARG(&fs_args, buf) = fs; + + if ((error = sys_statfs(p, &fs_args, retval)) != 0) + return error; + + if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0) + return error; + + bsd_statfs_to_svr4_statvfs(&bfs, &sfs); + + return copyout(&sfs, SCARG(uap, fs), sizeof(sfs)); +} + + +int +svr4_sys_fstatvfs(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_fstatvfs_args *uap = v; + struct sys_fstatfs_args fs_args; + caddr_t sg = stackgap_init(p->p_emul); + struct statfs *fs = stackgap_alloc(&sg, sizeof(struct statfs)); + struct statfs bfs; + struct svr4_statvfs sfs; + int error; + + SCARG(&fs_args, fd) = SCARG(uap, fd); + SCARG(&fs_args, buf) = fs; + + if ((error = sys_fstatfs(p, &fs_args, retval)) != 0) + return error; + + if ((error = copyin(fs, &bfs, sizeof(bfs))) != 0) + return error; + + bsd_statfs_to_svr4_statvfs(&bfs, &sfs); + + return copyout(&sfs, SCARG(uap, fs), sizeof(sfs)); +} + +int +svr4_sys_alarm(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_alarm_args *uap = v; + int error; + struct itimerval *ntp, *otp, tp; + struct sys_setitimer_args sa; + caddr_t sg = stackgap_init(p->p_emul); + + ntp = stackgap_alloc(&sg, sizeof(struct itimerval)); + otp = stackgap_alloc(&sg, sizeof(struct itimerval)); + + timerclear(&tp.it_interval); + tp.it_value.tv_sec = SCARG(uap, sec); + tp.it_value.tv_usec = 0; + + if ((error = copyout(&tp, ntp, sizeof(tp))) != 0) + return error; + + SCARG(&sa, which) = ITIMER_REAL; + SCARG(&sa, itv) = ntp; + SCARG(&sa, oitv) = otp; + + if ((error = sys_setitimer(p, &sa, retval)) != 0) + return error; + + if ((error = copyin(otp, &tp, sizeof(tp))) != 0) + return error; + + if (tp.it_value.tv_usec) + tp.it_value.tv_sec++; + + *retval = (register_t) tp.it_value.tv_sec; + + return 0; +} + + +int +svr4_sys_gettimeofday(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_gettimeofday_args *uap = v; + + if (SCARG(uap, tp)) { + struct timeval atv; + + microtime(&atv); + return copyout(&atv, SCARG(uap, tp), sizeof (atv)); + } + + return 0; +} diff --git a/sys/compat/svr4/svr4_net.c b/sys/compat/svr4/svr4_net.c new file mode 100644 index 00000000000..42f50403f54 --- /dev/null +++ b/sys/compat/svr4/svr4_net.c @@ -0,0 +1,171 @@ +/* $NetBSD: svr4_net.c,v 1.4 1994/12/14 20:20:26 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution ast use in source ast binary forms, with or without + * modification, are permitted provided that the following costitions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of costitions ast the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of costitions ast the following disclaimer in the + * documentation ast/or other materials provided with the distribution. + * 3. The name of the author may not be used to estorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Emulate /dev/{udp,tcp,...} + */ + +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/systm.h> +#include <sys/buf.h> +#include <sys/malloc.h> +#include <sys/ioctl.h> +#include <sys/tty.h> +#include <sys/file.h> +#include <sys/filedesc.h> +#include <sys/select.h> +#include <sys/socket.h> +#include <sys/socketvar.h> +#include <net/if.h> +#include <netinet/in.h> +#include <sys/proc.h> +#include <sys/vnode.h> +#include <sys/device.h> + + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_ioctl.h> +#include <compat/svr4/svr4_stropts.h> + +/* + * Device minor numbers + */ +enum { + dev_arp = 26, + dev_icmp = 27, + dev_ip = 28, + dev_tcp = 35, + dev_udp = 36 +}; + +static int svr4_netclose __P((struct file *fp, struct proc *p)); + +static struct fileops svr4_netops = { + soo_read, soo_write, soo_ioctl, soo_select, svr4_netclose +}; + + +/* + * Used by new config, but we don't need it. + */ +int +svr4_netattach(n) + int n; +{ + return 0; +} + + +int +svr4_netopen(dev, flag, mode, p) + dev_t dev; + int flag; + int mode; + struct proc *p; +{ + int type, protocol; + int fd; + struct file *fp; + struct socket *so; + int error; + struct svr4_strm *st; + + DPRINTF(("netopen(")); + + if (p->p_dupfd >= 0) + return ENODEV; + + switch (minor(dev)) { + case dev_udp: + type = SOCK_DGRAM; + protocol = IPPROTO_UDP; + DPRINTF(("udp, ")); + break; + + case dev_tcp: + type = SOCK_STREAM; + protocol = IPPROTO_TCP; + DPRINTF(("tcp, ")); + break; + + case dev_ip: + type = SOCK_RAW; + protocol = IPPROTO_IP; + DPRINTF(("ip, ")); + break; + + case dev_icmp: + type = SOCK_RAW; + protocol = IPPROTO_ICMP; + DPRINTF(("icmp, ")); + break; + + default: + DPRINTF(("%d);\n", minor(dev))); + return EOPNOTSUPP; + } + + if ((error = falloc(p, &fp, &fd)) != 0) + return (error); + + if ((error = socreate(AF_INET, &so, type, protocol)) != 0) { + DPRINTF(("socreate error %d\n", error)); + p->p_fd->fd_ofiles[fd] = 0; + ffree(fp); + return error; + } + + fp->f_flag = FREAD|FWRITE; + fp->f_type = DTYPE_SOCKET; + fp->f_ops = &svr4_netops; + + st = malloc(sizeof(struct svr4_strm), M_NETADDR, M_WAITOK); + /* XXX: This is unused; ask for a field and make this legal */ + so->so_tpcb = (caddr_t) st; + st->s_cmd = ~0; + fp->f_data = (caddr_t)so; + DPRINTF(("ok);\n")); + + p->p_dupfd = fd; + return ENXIO; +} + +static int +svr4_netclose(fp, p) + struct file *fp; + struct proc *p; +{ + struct socket *so = (struct socket *) fp->f_data; + free((char *) so->so_tpcb, M_NETADDR); + return soo_close(fp, p); +} diff --git a/sys/compat/svr4/svr4_poll.h b/sys/compat/svr4/svr4_poll.h new file mode 100644 index 00000000000..c63e5f2e91f --- /dev/null +++ b/sys/compat/svr4/svr4_poll.h @@ -0,0 +1,50 @@ +/* $NetBSD: svr4_poll.h,v 1.2 1994/11/18 02:53:55 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_POLL_H_ +#define _SVR4_POLL_H_ + +struct svr4_pollfd { + int fd; + short events; + short revents; +}; + +#define SVR4_POLLIN 0x0001 +#define SVR4_POLLPRI 0x0002 +#define SVR4_POLLOUT 0x0004 +#define SVR4_POLLERR 0x0008 +#define SVR4_POLLHUP 0x0010 +#define SVR4_POLLNVAL 0x0020 +#define SVR4_POLLRDNORM 0x0040 +#define SVR4_POLLRDBAND 0x0080 +#define SVR4_POLLWRBAND 0x0100 + + +#endif /* !_SVR4_POLL_H_ */ diff --git a/sys/compat/svr4/svr4_siginfo.h b/sys/compat/svr4/svr4_siginfo.h new file mode 100644 index 00000000000..0175de9dcec --- /dev/null +++ b/sys/compat/svr4/svr4_siginfo.h @@ -0,0 +1,110 @@ +/* $NetBSD: svr4_siginfo.h,v 1.2 1995/07/04 19:47:05 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_SIGINFO_H_ +#define _SVR4_SIGINFO_H_ + +#define SVR4_ILL_ILLOPC 1 +#define SVR4_ILL_ILLOPN 2 +#define SVR4_ILL_ILLADR 3 +#define SVR4_ILL_ILLTRP 4 +#define SVR4_ILL_PRVOPC 5 +#define SVR4_ILL_PRVREG 6 +#define SVR4_ILL_COPROC 7 +#define SVR4_ILL_BADSTK 8 + +#define SVR4_FPE_INTDIV 1 +#define SVR4_FPE_INTOVF 2 +#define SVR4_FPE_FLTDIV 3 +#define SVR4_FPE_FLTOVF 4 +#define SVR4_FPE_FLTUND 5 +#define SVR4_FPE_FLTRES 6 +#define SVR4_FPE_FLTINV 7 +#define SVR4_FPE_FLTSUB 8 + +#define SVR4_SEGV_MAPERR 1 +#define SVR4_SEGV_ACCERR 2 + +#define SVR4_BUS_ADRALN 1 +#define SVR4_BUS_ADRERR 2 +#define SVR4_BUS_OBJERR 3 + +#define SVR4_TRAP_BRKPT 1 +#define SVR4_TRAP_TRACE 2 + +#define SVR4_POLL_IN 1 +#define SVR4_POLL_OUT 2 +#define SVR4_POLL_MSG 3 +#define SVR4_POLL_ERR 4 +#define SVR4_POLL_PRI 5 + +#define SVR4_CLD_EXITED 1 +#define SVR4_CLD_KILLED 2 +#define SVR4_CLD_DUMPED 3 +#define SVR4_CLD_TRAPPED 4 +#define SVR4_CLD_STOPPED 5 +#define SVR4_CLD_CONTINUED 6 + +#define SVR4_EMT_TAGOVF 1 + +typedef union svr4_siginfo { + char si_pad[128]; /* Total size; for future expansion */ + struct { + int _signo; + int _code; + int _errno; + union { + struct { + svr4_pid_t _pid; + svr4_clock_t _utime; + int _status; + svr4_clock_t _stime; + } _child; + + struct { + caddr_t _addr; + int _trap; + } _fault; + } _reason; + } _info; +} svr4_siginfo_t; + +#define si_signo _info._signo +#define si_code _info._code +#define si_errno _info._errno + +#define si_pid _info._reason._child._pid +#define si_stime _info._reason._child._stime +#define si_status _info._reason._child._status +#define si_utime _info._reason._child._utime + +#define si_addr _info._reason._fault._addr +#define si_trap _info._reason._fault._trap + +#endif /* !_SVR4_SIGINFO_H_ */ diff --git a/sys/compat/svr4/svr4_signal.c b/sys/compat/svr4/svr4_signal.c new file mode 100644 index 00000000000..21b65d2962e --- /dev/null +++ b/sys/compat/svr4/svr4_signal.c @@ -0,0 +1,645 @@ +/* $NetBSD: svr4_signal.c,v 1.19 1995/10/07 06:27:46 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/namei.h> +#include <sys/proc.h> +#include <sys/filedesc.h> +#include <sys/ioctl.h> +#include <sys/mount.h> +#include <sys/kernel.h> +#include <sys/signal.h> +#include <sys/signalvar.h> +#include <sys/malloc.h> + +#include <sys/syscallargs.h> + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_ucontext.h> + +#define sigemptyset(s) bzero((s), sizeof(*(s))) +#define sigismember(s, n) (*(s) & sigmask(n)) +#define sigaddset(s, n) (*(s) |= sigmask(n)) + +#define svr4_sigmask(n) (1 << (((n) - 1) & (32 - 1))) +#define svr4_sigword(n) (((n) - 1) >> 5) +#define svr4_sigemptyset(s) bzero((s), sizeof(*(s))) +#define svr4_sigismember(s, n) ((s)->bits[svr4_sigword(n)] & svr4_sigmask(n)) +#define svr4_sigaddset(s, n) ((s)->bits[svr4_sigword(n)] |= svr4_sigmask(n)) + +static inline int +svr4_sigfillset(s) + svr4_sigset_t *s; +{ + int i; + + svr4_sigemptyset(s); + for (i = 1; i < SVR4_NSIG; i++) + svr4_sigaddset(s, i); +} + +int bsd_to_svr4_sig[] = { + 0, + SVR4_SIGHUP, + SVR4_SIGINT, + SVR4_SIGQUIT, + SVR4_SIGILL, + SVR4_SIGTRAP, + SVR4_SIGABRT, + SVR4_SIGEMT, + SVR4_SIGFPE, + SVR4_SIGKILL, + SVR4_SIGBUS, + SVR4_SIGSEGV, + SVR4_SIGSYS, + SVR4_SIGPIPE, + SVR4_SIGALRM, + SVR4_SIGTERM, + SVR4_SIGURG, + SVR4_SIGSTOP, + SVR4_SIGTSTP, + SVR4_SIGCONT, + SVR4_SIGCHLD, + SVR4_SIGTTIN, + SVR4_SIGTTOU, + SVR4_SIGIO, + SVR4_SIGXCPU, + SVR4_SIGXFSZ, + SVR4_SIGVTALRM, + SVR4_SIGPROF, + SVR4_SIGWINCH, + 0, + SVR4_SIGUSR1, + SVR4_SIGUSR2, +}; + +int svr4_to_bsd_sig[] = { + 0, + SIGHUP, + SIGINT, + SIGQUIT, + SIGILL, + SIGTRAP, + SIGABRT, + SIGEMT, + SIGFPE, + SIGKILL, + SIGBUS, + SIGSEGV, + SIGSYS, + SIGPIPE, + SIGALRM, + SIGTERM, + SIGUSR1, + SIGUSR2, + SIGCHLD, + 0, + SIGWINCH, + SIGURG, + SIGIO, + SIGSTOP, + SIGTSTP, + SIGCONT, + SIGTTIN, + SIGTTOU, + SIGVTALRM, + SIGPROF, + SIGXCPU, + SIGXFSZ, +}; + +void +svr4_to_bsd_sigset(sss, bss) + const svr4_sigset_t *sss; + sigset_t *bss; +{ + int i, newsig; + + sigemptyset(bss); + for (i = 1; i < SVR4_NSIG; i++) { + if (svr4_sigismember(sss, i)) { + newsig = svr4_to_bsd_sig[i]; + if (newsig) + sigaddset(bss, newsig); + } + } +} + + +void +bsd_to_svr4_sigset(bss, sss) + const sigset_t *bss; + svr4_sigset_t *sss; +{ + int i, newsig; + + svr4_sigemptyset(sss); + for (i = 1; i < NSIG; i++) { + if (sigismember(bss, i)) { + newsig = bsd_to_svr4_sig[i]; + if (newsig) + svr4_sigaddset(sss, newsig); + } + } +} + +/* + * XXX: Only a subset of the flags is currently implemented. + */ +void +svr4_to_bsd_sigaction(ssa, bsa) + const struct svr4_sigaction *ssa; + struct sigaction *bsa; +{ + + bsa->sa_handler = ssa->sa_handler; + svr4_to_bsd_sigset(&ssa->sa_mask, &bsa->sa_mask); + bsa->sa_flags = 0; + if ((ssa->sa_flags & SVR4_SA_ONSTACK) != 0) + bsa->sa_flags |= SA_ONSTACK; + if ((ssa->sa_flags & SVR4_SA_RESTART) != 0) + bsa->sa_flags |= SA_RESTART; + if ((ssa->sa_flags & SVR4_SA_RESETHAND) != 0) + bsa->sa_flags |= SA_RESETHAND; + if ((ssa->sa_flags & SVR4_SA_NOCLDSTOP) != 0) + bsa->sa_flags |= SA_NOCLDSTOP; + if ((ssa->sa_flags & SVR4_SA_NODEFER) != 0) + bsa->sa_flags |= SA_NODEFER; +} + +void +bsd_to_svr4_sigaction(bsa, ssa) + const struct sigaction *bsa; + struct svr4_sigaction *ssa; +{ + + ssa->sa_handler = bsa->sa_handler; + bsd_to_svr4_sigset(&bsa->sa_mask, &ssa->sa_mask); + ssa->sa_flags = 0; + if ((bsa->sa_flags & SA_ONSTACK) != 0) + ssa->sa_flags |= SA_ONSTACK; + if ((bsa->sa_flags & SA_RESETHAND) != 0) + ssa->sa_flags |= SA_RESETHAND; + if ((bsa->sa_flags & SA_RESTART) != 0) + ssa->sa_flags |= SA_RESTART; + if ((bsa->sa_flags & SA_NODEFER) != 0) + ssa->sa_flags |= SA_NODEFER; + if ((bsa->sa_flags & SA_NOCLDSTOP) != 0) + ssa->sa_flags |= SA_NOCLDSTOP; +} + +void +svr4_to_bsd_sigaltstack(sss, bss) + const struct svr4_sigaltstack *sss; + struct sigaltstack *bss; +{ + + bss->ss_base = sss->ss_sp; + bss->ss_size = sss->ss_size; + bss->ss_flags = 0; + + if ((sss->ss_flags & SVR4_SS_DISABLE) != 0) + bss->ss_flags |= SS_DISABLE; + if ((sss->ss_flags & SVR4_SS_ONSTACK) != 0) + bss->ss_flags |= SS_ONSTACK; +} + +void +bsd_to_svr4_sigaltstack(bss, sss) + const struct sigaltstack *bss; + struct svr4_sigaltstack *sss; +{ + + sss->ss_sp = bss->ss_base; + sss->ss_size = bss->ss_size; + sss->ss_flags = 0; + + if ((bss->ss_flags & SS_DISABLE) != 0) + sss->ss_flags |= SVR4_SS_DISABLE; + if ((bss->ss_flags & SS_ONSTACK) != 0) + sss->ss_flags |= SVR4_SS_ONSTACK; +} + +int +svr4_sys_sigaction(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_sigaction_args /* { + syscallarg(int) signum; + syscallarg(struct svr4_sigaction *) nsa; + syscallarg(struct svr4_sigaction *) osa; + } */ *uap = v; + struct svr4_sigaction *nssa, *ossa, tmpssa; + struct sigaction *nbsa, *obsa, tmpbsa; + struct sys_sigaction_args sa; + caddr_t sg; + int error; + + sg = stackgap_init(p->p_emul); + nssa = SCARG(uap, nsa); + ossa = SCARG(uap, osa); + + if (ossa != NULL) + obsa = stackgap_alloc(&sg, sizeof(struct sigaction)); + else + obsa = NULL; + + if (nssa != NULL) { + nbsa = stackgap_alloc(&sg, sizeof(struct sigaction)); + if ((error = copyin(nssa, &tmpssa, sizeof(tmpssa))) != 0) + return error; + svr4_to_bsd_sigaction(&tmpssa, &tmpbsa); + if ((error = copyout(&tmpbsa, nbsa, sizeof(tmpbsa))) != 0) + return error; + } else + nbsa = NULL; + + SCARG(&sa, signum) = svr4_to_bsd_sig[SCARG(uap, signum)]; + SCARG(&sa, nsa) = nbsa; + SCARG(&sa, osa) = obsa; + + if ((error = sys_sigaction(p, &sa, retval)) != 0) + return error; + + if (ossa != NULL) { + if ((error = copyin(obsa, &tmpbsa, sizeof(tmpbsa))) != 0) + return error; + bsd_to_svr4_sigaction(&tmpbsa, &tmpssa); + if ((error = copyout(&tmpssa, ossa, sizeof(tmpssa))) != 0) + return error; + } + + return 0; +} + +int +svr4_sys_sigaltstack(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_sigaltstack_args /* { + syscallarg(struct svr4_sigaltstack *) nss; + syscallarg(struct svr4_sigaltstack *) oss; + } */ *uap = v; + struct svr4_sigaltstack *nsss, *osss, tmpsss; + struct sigaltstack *nbss, *obss, tmpbss; + struct sys_sigaltstack_args sa; + caddr_t sg; + int error; + + sg = stackgap_init(p->p_emul); + nsss = SCARG(uap, nss); + osss = SCARG(uap, oss); + + if (osss != NULL) + obss = stackgap_alloc(&sg, sizeof(struct sigaltstack)); + else + obss = NULL; + + if (nsss != NULL) { + nbss = stackgap_alloc(&sg, sizeof(struct sigaltstack)); + if ((error = copyin(nsss, &tmpsss, sizeof(tmpsss))) != 0) + return error; + svr4_to_bsd_sigaltstack(&tmpsss, &tmpbss); + if ((error = copyout(&tmpbss, nbss, sizeof(tmpbss))) != 0) + return error; + } else + nbss = NULL; + + SCARG(&sa, nss) = nbss; + SCARG(&sa, oss) = obss; + + if ((error = sys_sigaltstack(p, &sa, retval)) != 0) + return error; + + if (obss != NULL) { + if ((error = copyin(obss, &tmpbss, sizeof(tmpbss))) != 0) + return error; + bsd_to_svr4_sigaltstack(&tmpbss, &tmpsss); + if ((error = copyout(&tmpsss, osss, sizeof(tmpsss))) != 0) + return error; + } + + return 0; +} + +/* + * Stolen from the ibcs2 one + */ +int +svr4_sys_signal(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_signal_args /* { + syscallarg(int) signum; + syscallarg(svr4_sig_t) handler; + } */ *uap = v; + int signum = svr4_to_bsd_sig[SVR4_SIGNO(SCARG(uap, signum))]; + int error; + caddr_t sg = stackgap_init(p->p_emul); + + if (signum <= 0 || signum >= SVR4_NSIG) { + if (SVR4_SIGCALL(SCARG(uap, signum)) == SVR4_SIGNAL_MASK || + SVR4_SIGCALL(SCARG(uap, signum)) == SVR4_SIGDEFER_MASK) + *retval = (int)SVR4_SIG_ERR; + return EINVAL; + } + + switch (SVR4_SIGCALL(SCARG(uap, signum))) { + case SVR4_SIGDEFER_MASK: + /* + * sigset is identical to signal() except + * that SIG_HOLD is allowed as + * an action. + */ + if (SCARG(uap, handler) == SVR4_SIG_HOLD) { + struct sys_sigprocmask_args sa; + + SCARG(&sa, how) = SIG_BLOCK; + SCARG(&sa, mask) = sigmask(signum); + return sys_sigprocmask(p, &sa, retval); + } + /* FALLTHROUGH */ + + case SVR4_SIGNAL_MASK: + { + struct sys_sigaction_args sa_args; + struct sigaction *nbsa, *obsa, sa; + + nbsa = stackgap_alloc(&sg, sizeof(struct sigaction)); + obsa = stackgap_alloc(&sg, sizeof(struct sigaction)); + SCARG(&sa_args, signum) = signum; + SCARG(&sa_args, nsa) = nbsa; + SCARG(&sa_args, osa) = obsa; + + sa.sa_handler = SCARG(uap, handler); + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; +#if 0 + if (signum != SIGALRM) + sa.sa_flags = SA_RESTART; +#endif + if ((error = copyout(&sa, nbsa, sizeof(sa))) != 0) + return error; + if ((error = sys_sigaction(p, &sa_args, retval)) != 0) { + DPRINTF(("signal: sigaction failed: %d\n", + error)); + *retval = (int)SVR4_SIG_ERR; + return error; + } + if ((error = copyin(obsa, &sa, sizeof(sa))) != 0) + return error; + *retval = (int)sa.sa_handler; + return 0; + } + + case SVR4_SIGHOLD_MASK: + { + struct sys_sigprocmask_args sa; + + SCARG(&sa, how) = SIG_BLOCK; + SCARG(&sa, mask) = sigmask(signum); + return sys_sigprocmask(p, &sa, retval); + } + + case SVR4_SIGRELSE_MASK: + { + struct sys_sigprocmask_args sa; + + SCARG(&sa, how) = SIG_UNBLOCK; + SCARG(&sa, mask) = sigmask(signum); + return sys_sigprocmask(p, &sa, retval); + } + + case SVR4_SIGIGNORE_MASK: + { + struct sys_sigaction_args sa_args; + struct sigaction *bsa, sa; + + bsa = stackgap_alloc(&sg, sizeof(struct sigaction)); + SCARG(&sa_args, signum) = signum; + SCARG(&sa_args, nsa) = bsa; + SCARG(&sa_args, osa) = NULL; + + sa.sa_handler = SIG_IGN; + sigemptyset(&sa.sa_mask); + sa.sa_flags = 0; + if ((error = copyout(&sa, bsa, sizeof(sa))) != 0) + return error; + if ((error = sys_sigaction(p, &sa_args, retval)) != 0) { + DPRINTF(("sigignore: sigaction failed\n")); + return error; + } + return 0; + } + + case SVR4_SIGPAUSE_MASK: + { + struct sys_sigsuspend_args sa; + + SCARG(&sa, mask) = p->p_sigmask & ~sigmask(signum); + return sys_sigsuspend(p, &sa, retval); + } + + default: + return ENOSYS; + } +} + +int +svr4_sys_sigprocmask(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_sigprocmask_args /* { + syscallarg(int) how; + syscallarg(svr4_sigset_t *) set; + syscallarg(svr4_sigset_t *) oset; + } */ *uap = v; + svr4_sigset_t sss; + sigset_t bss; + int error = 0; + + if (SCARG(uap, oset) != NULL) { + /* Fix the return value first if needed */ + bsd_to_svr4_sigset(&p->p_sigmask, &sss); + if ((error = copyout(&sss, SCARG(uap, oset), sizeof(sss))) != 0) + return error; + } + + if (SCARG(uap, set) == NULL) + /* Just examine */ + return 0; + + if ((error = copyin(SCARG(uap, set), &sss, sizeof(sss))) != 0) + return error; + + svr4_to_bsd_sigset(&sss, &bss); + + (void) splhigh(); + + switch (SCARG(uap, how)) { + case SVR4_SIG_BLOCK: + p->p_sigmask |= bss & ~sigcantmask; + break; + + case SVR4_SIG_UNBLOCK: + p->p_sigmask &= ~bss; + break; + + case SVR4_SIG_SETMASK: + p->p_sigmask = bss & ~sigcantmask; + break; + + default: + error = EINVAL; + break; + } + + (void) spl0(); + + return error; +} + +int +svr4_sys_sigpending(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_sigpending_args /* { + syscallarg(int) what; + syscallarg(svr4_sigset_t *) mask; + } */ *uap = v; + sigset_t bss; + svr4_sigset_t sss; + + switch (SCARG(uap, what)) { + case 1: /* sigpending */ + if (SCARG(uap, mask) == NULL) + return 0; + bss = p->p_siglist & p->p_sigmask; + bsd_to_svr4_sigset(&bss, &sss); + break; + + case 2: /* sigfillset */ + svr4_sigfillset(&sss); + break; + + default: + return EINVAL; + } + + return copyout(&sss, SCARG(uap, mask), sizeof(sss)); +} + +int +svr4_sys_sigsuspend(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_sigsuspend_args /* { + syscallarg(svr4_sigset_t *) ss; + } */ *uap = v; + svr4_sigset_t sss; + sigset_t bss; + struct sys_sigsuspend_args sa; + int error; + + if ((error = copyin(SCARG(uap, ss), &sss, sizeof(sss))) != 0) + return error; + + svr4_to_bsd_sigset(&sss, &bss); + + SCARG(&sa, mask) = bss; + return sys_sigsuspend(p, &sa, retval); +} + +int +svr4_sys_kill(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_kill_args /* { + syscallarg(int) pid; + syscallarg(int) signum; + } */ *uap = v; + struct sys_kill_args ka; + + SCARG(&ka, pid) = SCARG(uap, pid); + SCARG(&ka, signum) = svr4_to_bsd_sig[SCARG(uap, signum)]; + return sys_kill(p, &ka, retval); +} + +int +svr4_sys_context(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_context_args /* { + syscallarg(int) func; + syscallarg(struct svr4_ucontext *) uc; + } */ *uap = v; + struct svr4_ucontext uc; + int error; + *retval = 0; + + switch (SCARG(uap, func)) { + case 0: + DPRINTF(("getcontext(%x)\n", SCARG(uap, uc))); + svr4_getcontext(p, &uc, p->p_sigmask, + p->p_sigacts->ps_sigstk.ss_flags & SS_ONSTACK); + return copyout(&uc, SCARG(uap, uc), sizeof(uc)); + + case 1: + DPRINTF(("setcontext(%x)\n", SCARG(uap, uc))); + if ((error = copyin(SCARG(uap, uc), &uc, sizeof(uc))) != 0) + return error; + return svr4_setcontext(p, &uc); + + default: + DPRINTF(("context(%d, %x)\n", SCARG(uap, func), + SCARG(uap, uc))); + return ENOSYS; + } + return 0; +} diff --git a/sys/compat/svr4/svr4_signal.h b/sys/compat/svr4/svr4_signal.h new file mode 100644 index 00000000000..8dfeee42749 --- /dev/null +++ b/sys/compat/svr4/svr4_signal.h @@ -0,0 +1,128 @@ +/* $NetBSD: svr4_signal.h,v 1.13 1995/08/14 02:22:20 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_SIGNAL_H_ +#define _SVR4_SIGNAL_H_ + +#include <compat/svr4/svr4_siginfo.h> + +#define SVR4_SIGHUP 1 +#define SVR4_SIGINT 2 +#define SVR4_SIGQUIT 3 +#define SVR4_SIGILL 4 +#define SVR4_SIGTRAP 5 +#define SVR4_SIGIOT 6 +#define SVR4_SIGABRT 6 +#define SVR4_SIGEMT 7 +#define SVR4_SIGFPE 8 +#define SVR4_SIGKILL 9 +#define SVR4_SIGBUS 10 +#define SVR4_SIGSEGV 11 +#define SVR4_SIGSYS 12 +#define SVR4_SIGPIPE 13 +#define SVR4_SIGALRM 14 +#define SVR4_SIGTERM 15 +#define SVR4_SIGUSR1 16 +#define SVR4_SIGUSR2 17 +#define SVR4_SIGCLD 18 +#define SVR4_SIGCHLD 18 +#define SVR4_SIGPWR 19 +#define SVR4_SIGWINCH 20 +#define SVR4_SIGURG 21 +#define SVR4_SIGPOLL 22 +#define SVR4_SIGIO 22 +#define SVR4_SIGSTOP 23 +#define SVR4_SIGTSTP 24 +#define SVR4_SIGCONT 25 +#define SVR4_SIGTTIN 26 +#define SVR4_SIGTTOU 27 +#define SVR4_SIGVTALRM 28 +#define SVR4_SIGPROF 29 +#define SVR4_SIGXCPU 30 +#define SVR4_SIGXFSZ 31 +#define SVR4_NSIG 32 + +#define SVR4_SIGNO_MASK 0x00FF +#define SVR4_SIGNAL_MASK 0x0000 +#define SVR4_SIGDEFER_MASK 0x0100 +#define SVR4_SIGHOLD_MASK 0x0200 +#define SVR4_SIGRELSE_MASK 0x0400 +#define SVR4_SIGIGNORE_MASK 0x0800 +#define SVR4_SIGPAUSE_MASK 0x1000 + +#define SVR4_SIGNO(x) ((x) & SVR4_SIGNO_MASK) +#define SVR4_SIGCALL(x) ((x) & ~SVR4_SIGNO_MASK) + +#define SVR4_SIG_DFL (void(*)())0 +#define SVR4_SIG_ERR (void(*)())-1 +#define SVR4_SIG_IGN (void(*)())1 +#define SVR4_SIG_HOLD (void(*)())2 + +#define SVR4_SIG_BLOCK 1 +#define SVR4_SIG_UNBLOCK 2 +#define SVR4_SIG_SETMASK 3 + +typedef struct { + u_long bits[4]; +} svr4_sigset_t; +typedef void (*svr4_sig_t) __P((int)); + +struct svr4_sigaction { + int sa_flags; + svr4_sig_t sa_handler; + svr4_sigset_t sa_mask; + int sa_reserved[2]; +}; + +struct svr4_sigaltstack { + char *ss_sp; + int ss_size; + int ss_flags; +}; + +/* sa_flags */ +#define SVR4_SA_ONSTACK 0x00000001 +#define SVR4_SA_RESETHAND 0x00000002 +#define SVR4_SA_RESTART 0x00000004 +#define SVR4_SA_SIGINFO 0x00000008 +#define SVR4_SA_NODEFER 0x00000010 +#define SVR4_SA_NOCLDWAIT 0x00010000 /* No zombies */ +#define SVR4_SA_NOCLDSTOP 0x00020000 /* No jcl */ + +/* ss_flags */ +#define SVR4_SS_ONSTACK 0x00000001 +#define SVR4_SS_DISABLE 0x00000002 + +extern int bsd_to_svr4_sig[]; +void bsd_to_svr4_sigaltstack __P((const struct sigaltstack *, struct svr4_sigaltstack *)); +void bsd_to_svr4_sigset __P((const sigset_t *, svr4_sigset_t *)); +void svr4_to_bsd_sigaltstack __P((const struct svr4_sigaltstack *, struct sigaltstack *)); +void svr4_to_bsd_sigset __P((const svr4_sigset_t *, sigset_t *)); + +#endif /* !_SVR4_SIGNAL_H_ */ diff --git a/sys/compat/svr4/svr4_sockio.c b/sys/compat/svr4/svr4_sockio.c new file mode 100644 index 00000000000..5251ac761f9 --- /dev/null +++ b/sys/compat/svr4/svr4_sockio.c @@ -0,0 +1,144 @@ +/* $NetBSD: svr4_sockio.c,v 1.5 1995/10/07 06:27:48 mycroft Exp $ */ + +/* + * Copyright (c) 1995 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/proc.h> +#include <sys/systm.h> +#include <sys/file.h> +#include <sys/filedesc.h> +#include <sys/ioctl.h> +#include <sys/termios.h> +#include <sys/tty.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <sys/mount.h> +#include <net/if.h> +#include <sys/malloc.h> + +#include <sys/syscallargs.h> + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_stropts.h> +#include <compat/svr4/svr4_ioctl.h> +#include <compat/svr4/svr4_sockio.h> + +static int bsd_to_svr4_flags __P((int)); + +#define bsd_to_svr4_flag(a) \ + if (bf & __CONCAT(I,a)) sf |= __CONCAT(SVR4_I,a) + +static int +bsd_to_svr4_flags(bf) + int bf; +{ + int sf = 0; + bsd_to_svr4_flag(FF_UP); + bsd_to_svr4_flag(FF_BROADCAST); + bsd_to_svr4_flag(FF_DEBUG); + bsd_to_svr4_flag(FF_LOOPBACK); + bsd_to_svr4_flag(FF_POINTOPOINT); + bsd_to_svr4_flag(FF_NOTRAILERS); + bsd_to_svr4_flag(FF_RUNNING); + bsd_to_svr4_flag(FF_NOARP); + bsd_to_svr4_flag(FF_PROMISC); + bsd_to_svr4_flag(FF_ALLMULTI); + bsd_to_svr4_flag(FF_MULTICAST); + return sf; +} + +int +svr4_sockioctl(fp, cmd, data, p, retval) + struct file *fp; + u_long cmd; + caddr_t data; + struct proc *p; + register_t *retval; +{ + struct filedesc *fdp = p->p_fd; + caddr_t sg = stackgap_init(p->p_emul); + int error; + int fd; + int num; + int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) = + fp->f_ops->fo_ioctl; + + *retval = 0; + + switch (cmd) { + case SVR4_SIOCGIFNUM: + { + extern int if_index; + + DPRINTF(("SIOCGIFNUM %d\n", if_index)); + return copyout(&if_index, data, sizeof(if_index)); + } + + case SVR4_SIOCGIFFLAGS: + { + struct ifreq br; + struct svr4_ifreq sr; + + if ((error = copyin(data, &sr, sizeof(sr))) != 0) + return error; + + (void) strcpy(br.ifr_name, sr.svr4_ifr_name); + if ((error = (*ctl)(fp, SIOCGIFFLAGS, + (caddr_t) &br, p)) != 0) + return error; + + sr.svr4_ifr_flags = bsd_to_svr4_flags(br.ifr_flags); + DPRINTF(("SIOCGIFFLAGS %s = %d\n", + sr.svr4_ifr_name, sr.svr4_ifr_flags)); + return 0; + } + + case SVR4_SIOCGIFCONF: + { + struct svr4_ifconf sc; + + if ((error = copyin(data, &sc, sizeof(sc))) != 0) + return error; + + if ((error = (*ctl)(fp, OSIOCGIFCONF, + (caddr_t) &sc, p)) != 0) + return error; + + DPRINTF(("SIOCGIFCONF\n")); + return 0; + } + + + default: + DPRINTF(("Unknown svr4 sockio %x\n", cmd)); + return 0; /* ENOSYS really */ + } +} diff --git a/sys/compat/svr4/svr4_sockio.h b/sys/compat/svr4/svr4_sockio.h new file mode 100644 index 00000000000..efa9db8f3ca --- /dev/null +++ b/sys/compat/svr4/svr4_sockio.h @@ -0,0 +1,92 @@ +/* $NetBSD: svr4_sockio.h,v 1.2 1995/07/04 23:00:13 christos Exp $ */ + +/* + * Copyright (c) 1995 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_SOCKIO_H_ +#define _SVR4_SOCKIO_H_ + +#define SVR4_IFF_UP 0x0001 +#define SVR4_IFF_BROADCAST 0x0002 +#define SVR4_IFF_DEBUG 0x0004 +#define SVR4_IFF_LOOPBACK 0x0008 +#define SVR4_IFF_POINTOPOINT 0x0010 +#define SVR4_IFF_NOTRAILERS 0x0020 +#define SVR4_IFF_RUNNING 0x0040 +#define SVR4_IFF_NOARP 0x0080 +#define SVR4_IFF_PROMISC 0x0100 +#define SVR4_IFF_ALLMULTI 0x0200 +#define SVR4_IFF_INTELLIGENT 0x0400 +#define SVR4_IFF_MULTICAST 0x0800 +#define SVR4_IFF_MULTI_BCAST 0x1000 +#define SVR4_IFF_UNNUMBERED 0x2000 +#define SVR4_IFF_PRIVATE 0x8000 + +struct svr4_ifreq { +#define SVR4_IFNAMSIZ 16 + char svr4_ifr_name[SVR4_IFNAMSIZ]; + union { + struct osockaddr ifru_addr; + struct osockaddr ifru_dstaddr; + struct osockaddr ifru_broadaddr; + short ifru_flags; + int ifru_metric; + char ifru_data; + char ifru_enaddr[6]; + int if_muxid[2]; + + } ifr_ifru; + +#define svr4_ifr_addr ifr_ifru.ifru_addr +#define svr4_ifr_dstaddr ifr_ifru.ifru_dstaddr +#define svr4_ifr_broadaddr ifr_ifru.ifru_broadaddr +#define svr4_ifr_flags ifr_ifru.ifru_flags +#define svr4_ifr_metric ifr_ifru.ifru_metric +#define svr4_ifr_data ifr_ifru.ifru_data +#define svr4_ifr_enaddr ifr_ifru.ifru_enaddr +#define svr4_ifr_muxid ifr_ifru.ifru_muxid + +}; + +struct svr4_ifconf { + int svr4_ifc_len; + union { + caddr_t ifcu_buf; + struct svr4_ifreq *ifcu_req; + } ifc_ifcu; + +#define svr4_ifc_buf ifc_ifcu.ifcu_buf +#define svr4_ifc_req ifc_ifcu.ifcu_req +}; + +#define SVR4_SIOC ('i' << 8) + +#define SVR4_SIOCGIFFLAGS SVR4_IOWR('i', 17, struct svr4_ifreq) +#define SVR4_SIOCGIFCONF SVR4_IOWR('i', 20, struct svr4_ifconf) +#define SVR4_SIOCGIFNUM SVR4_IOR('i', 87, int) + +#endif /* !_SVR4_SOCKIO_H_ */ diff --git a/sys/compat/svr4/svr4_sockmod.h b/sys/compat/svr4/svr4_sockmod.h new file mode 100644 index 00000000000..89983b4cd63 --- /dev/null +++ b/sys/compat/svr4/svr4_sockmod.h @@ -0,0 +1,78 @@ +/* $NetBSD: svr4_sockmod.h,v 1.3 1995/03/31 03:06:32 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_SOCKMOD_H_ +#define _SVR4_SOCKMOD_H_ + +#define SVR4_SIMOD ('I' << 8) + +#define SVR4_SI_OGETUDATA (SVR4_SIMOD|101) +#define SVR4_SI_SHUTDOWN (SVR4_SIMOD|102) +#define SVR4_SI_LISTEN (SVR4_SIMOD|103) +#define SVR4_SI_SETMYNAME (SVR4_SIMOD|104) +#define SVR4_SI_SETPEERNAME (SVR4_SIMOD|105) +#define SVR4_SI_GETINTRANSIT (SVR4_SIMOD|106) +#define SVR4_SI_TCL_LINK (SVR4_SIMOD|107) +#define SVR4_SI_TCL_UNLINK (SVR4_SIMOD|108) +#define SVR4_SI_SOCKPARAMS (SVR4_SIMOD|109) +#define SVR4_SI_GETUDATA (SVR4_SIMOD|110) + + +#define SVR4_SOCK_RAW 1 +#define SVR4_SOCK_STREAM 2 +#define SVR4_SOCK_DGRAM 3 + +struct svr4_si_sockparms { + int family; + int type; + int protocol; +}; + +struct svr4_si_oudata { + int tidusize; + int addrsize; + int optsize; + int etsdusize; + int servtype; + int so_state; + int so_options; +}; + +struct svr4_si_udata { + int tidusize; + int addrsize; + int optsize; + int etsdusize; + int servtype; + int so_state; + int so_options; + int tsdusize; + struct svr4_si_sockparms sockparms; +}; +#endif /* !_SVR4_SOCKMOD_H_ */ diff --git a/sys/compat/svr4/svr4_stat.c b/sys/compat/svr4/svr4_stat.c new file mode 100644 index 00000000000..b49e517b4fa --- /dev/null +++ b/sys/compat/svr4/svr4_stat.c @@ -0,0 +1,503 @@ +/* $NetBSD: svr4_stat.c,v 1.13 1995/10/07 06:27:49 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/namei.h> +#include <sys/proc.h> +#include <sys/file.h> +#include <sys/stat.h> +#include <sys/filedesc.h> +#include <sys/ioctl.h> +#include <sys/kernel.h> +#include <sys/mount.h> +#include <sys/malloc.h> + +#include <sys/time.h> +#include <sys/ucred.h> +#include <vm/vm.h> +#include <sys/sysctl.h> + +#include <sys/syscallargs.h> + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_stat.h> +#include <compat/svr4/svr4_ustat.h> +#include <compat/svr4/svr4_fuser.h> +#include <compat/svr4/svr4_utsname.h> +#include <compat/svr4/svr4_systeminfo.h> + +#define syscallarg(x) union { x datum; register_t pad; } + +#ifdef sparc +/* + * Solaris-2.4 on the sparc has the old stat call using the new + * stat data structure... + */ +# define SVR4_NO_OSTAT +#endif + +static void +bsd_to_svr4_stat(st, st4) + struct stat *st; + struct svr4_stat *st4; +{ + bzero(st4, sizeof(*st4)); + st4->st_dev = st->st_dev; + st4->st_ino = st->st_ino; + st4->st_mode = st->st_mode; + st4->st_nlink = st->st_nlink; + st4->st_uid = st->st_uid; + st4->st_gid = st->st_gid; + st4->st_rdev = st->st_rdev; + st4->st_size = st->st_size; + st4->st_atim = st->st_atimespec.ts_sec; + st4->st_mtim = st->st_mtimespec.ts_sec; + st4->st_ctim = st->st_ctimespec.ts_sec; +} + + +static void +bsd_to_svr4_xstat(st, st4) + struct stat *st; + struct svr4_xstat *st4; +{ + bzero(st4, sizeof(*st4)); + st4->st_dev = st->st_dev; + st4->st_ino = st->st_ino; + st4->st_mode = st->st_mode; + st4->st_nlink = st->st_nlink; + st4->st_uid = st->st_uid; + st4->st_gid = st->st_gid; + st4->st_rdev = st->st_rdev; + st4->st_size = st->st_size; + st4->st_atim = st->st_atimespec; + st4->st_mtim = st->st_mtimespec; + st4->st_ctim = st->st_ctimespec; + st4->st_blksize = st->st_blksize; + st4->st_blocks = st->st_blocks; + strcpy(st4->st_fstype, "unknown"); +} + + +int +svr4_sys_stat(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_stat_args *uap = v; +#ifdef SVR4_NO_OSTAT + struct svr4_sys_xstat_args cup; + + SCARG(&cup, two) = 2; + SCARG(&cup, path) = SCARG(uap, path); + SCARG(&cup, ub) = (struct svr4_xstat *) SCARG(uap, ub); + return svr4_sys_xstat(p, &cup, retval); +#else + struct stat st; + struct svr4_stat svr4_st; + struct sys_stat_args cup; + int error; + + caddr_t sg = stackgap_init(p->p_emul); + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&cup, path) = SCARG(uap, path); + SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); + + + if ((error = sys_stat(p, &cup, retval)) != 0) + return error; + + if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) + return error; + + bsd_to_svr4_stat(&st, &svr4_st); + + if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0) + return error; + + return 0; +#endif +} + +int +svr4_sys_lstat(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_lstat_args *uap = v; +#ifdef SVR4_NO_OSTAT + struct svr4_sys_lxstat_args cup; + + SCARG(&cup, two) = 2; + SCARG(&cup, path) = SCARG(uap, path); + SCARG(&cup, ub) = (struct svr4_xstat *) SCARG(uap, ub); + return svr4_sys_lxstat(p, &cup, retval); +#else + struct stat st; + struct svr4_stat svr4_st; + struct sys_lstat_args cup; + int error; + + caddr_t sg = stackgap_init(p->p_emul); + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&cup, path) = SCARG(uap, path); + SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); + + if ((error = sys_lstat(p, &cup, retval)) != 0) + return error; + + if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) + return error; + + bsd_to_svr4_stat(&st, &svr4_st); + + if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0) + return error; + + return 0; +#endif +} + +int +svr4_sys_fstat(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_fstat_args *uap = v; +#ifdef SVR4_NO_OSTAT + struct svr4_sys_fxstat_args cup; + + SCARG(&cup, two) = 2; + SCARG(&cup, fd) = SCARG(uap, fd); + SCARG(&cup, sb) = (struct svr4_xstat *) SCARG(uap, sb); + return svr4_sys_fxstat(p, &cup, retval); +#else + struct stat st; + struct svr4_stat svr4_st; + struct sys_fstat_args cup; + int error; + + caddr_t sg = stackgap_init(p->p_emul); + + SCARG(&cup, fd) = SCARG(uap, fd); + SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); + + if ((error = sys_fstat(p, &cup, retval)) != 0) + return error; + + if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) + return error; + + bsd_to_svr4_stat(&st, &svr4_st); + + if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0) + return error; + + return 0; +#endif +} + + +int +svr4_sys_xstat(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_xstat_args *uap = v; + struct stat st; + struct svr4_xstat svr4_st; + struct sys_stat_args cup; + int error; + + caddr_t sg = stackgap_init(p->p_emul); + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&cup, path) = SCARG(uap, path); + SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); + + if ((error = sys_stat(p, &cup, retval)) != 0) + return error; + + if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) + return error; + + bsd_to_svr4_xstat(&st, &svr4_st); + + if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0) + return error; + + return 0; +} + +int +svr4_sys_lxstat(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_lxstat_args *uap = v; + struct stat st; + struct svr4_xstat svr4_st; + struct sys_lstat_args cup; + int error; + + caddr_t sg = stackgap_init(p->p_emul); + SVR4_CHECK_ALT_EXIST(p, &sg, SCARG(uap, path)); + + SCARG(&cup, path) = SCARG(uap, path); + SCARG(&cup, ub) = stackgap_alloc(&sg, sizeof(struct stat)); + + if ((error = sys_lstat(p, &cup, retval)) != 0) + return error; + + if ((error = copyin(SCARG(&cup, ub), &st, sizeof st)) != 0) + return error; + + bsd_to_svr4_xstat(&st, &svr4_st); + + if ((error = copyout(&svr4_st, SCARG(uap, ub), sizeof svr4_st)) != 0) + return error; + + return 0; +} + +int +svr4_sys_fxstat(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_fxstat_args *uap = v; + struct stat st; + struct svr4_xstat svr4_st; + struct sys_fstat_args cup; + int error; + + caddr_t sg = stackgap_init(p->p_emul); + + SCARG(&cup, fd) = SCARG(uap, fd); + SCARG(&cup, sb) = stackgap_alloc(&sg, sizeof(struct stat)); + + if ((error = sys_fstat(p, &cup, retval)) != 0) + return error; + + if ((error = copyin(SCARG(&cup, sb), &st, sizeof st)) != 0) + return error; + + bsd_to_svr4_xstat(&st, &svr4_st); + + if ((error = copyout(&svr4_st, SCARG(uap, sb), sizeof svr4_st)) != 0) + return error; + + return 0; +} + +struct svr4_ustat_args { + syscallarg(svr4_dev_t) dev; + syscallarg(struct svr4_ustat *) name; +}; + +int +svr4_ustat(p, uap, retval) + register struct proc *p; + struct svr4_ustat_args /* { + syscallarg(svr4_dev_t) dev; + syscallarg(struct svr4_ustat *) name; + } */ *uap; + register_t *retval; +{ + struct svr4_ustat us; + int error; + + bzero(&us, sizeof us); + + /* + * XXX: should set f_tfree and f_tinode at least + * How do we translate dev -> fstat? (and then to svr4_ustat) + */ + if (error = copyout(&us, SCARG(uap, name), sizeof us)) + return (error); + + return 0; +} + + + +int +svr4_sys_uname(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_uname_args *uap = v; + struct svr4_utsname sut; + extern char ostype[], hostname[], osrelease[], version[], machine[]; + + + bzero(&sut, sizeof(sut)); + + strncpy(sut.sysname, ostype, sizeof(sut.sysname)); + sut.sysname[sizeof(sut.sysname) - 1] = '\0'; + + strncpy(sut.nodename, hostname, sizeof(sut.nodename)); + sut.nodename[sizeof(sut.nodename) - 1] = '\0'; + + strncpy(sut.release, osrelease, sizeof(sut.release)); + sut.release[sizeof(sut.release) - 1] = '\0'; + + strncpy(sut.version, version, sizeof(sut.version)); + sut.version[sizeof(sut.version) - 1] = '\0'; + + strncpy(sut.machine, machine, sizeof(sut.machine)); + sut.machine[sizeof(sut.machine) - 1] = '\0'; + + return copyout((caddr_t) &sut, (caddr_t) SCARG(uap, name), + sizeof(struct svr4_utsname)); +} + +int +svr4_sys_systeminfo(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_systeminfo_args *uap = v; + char *str; + int name; + int error; + long len; + extern char ostype[], hostname[], osrelease[], + version[], machine[], domainname[]; + + u_int rlen = SCARG(uap, len); + + switch (SCARG(uap, what)) { + case SVR4_SI_SYSNAME: + str = ostype; + break; + + case SVR4_SI_HOSTNAME: + str = hostname; + break; + + case SVR4_SI_RELEASE: + str = osrelease; + break; + + case SVR4_SI_VERSION: + str = version; + break; + + case SVR4_SI_MACHINE: + str = machine; + break; + + case SVR4_SI_ARCHITECTURE: + str = machine; + break; + + case SVR4_SI_HW_SERIAL: + str = "0"; + break; + + case SVR4_SI_HW_PROVIDER: + str = ostype; + break; + + case SVR4_SI_SRPC_DOMAIN: + str = domainname; + break; + + case SVR4_SI_SET_HOSTNAME: + if (error = suser(p->p_ucred, &p->p_acflag)) + return error; + name = KERN_HOSTNAME; + return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen); + + case SVR4_SI_SET_SRPC_DOMAIN: + if (error = suser(p->p_ucred, &p->p_acflag)) + return error; + name = KERN_DOMAINNAME; + return kern_sysctl(&name, 1, 0, 0, SCARG(uap, buf), rlen); + + default: + DPRINTF(("Bad systeminfo command %d\n", SCARG(uap, what))); + return ENOSYS; + } + + len = strlen(str) + 1; + if (len > rlen) + len = rlen; + + return copyout(str, SCARG(uap, buf), len); +} + + +int +svr4_sys_utssys(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_utssys_args *uap = v; + + switch (SCARG(uap, sel)) { + case 0: /* uname(2) */ + { + struct svr4_sys_uname_args ua; + SCARG(&ua, name) = SCARG(uap, a1); + return svr4_sys_uname(p, &ua, retval); + } + + case 2: /* ustat(2) */ + { + struct svr4_ustat_args ua; + SCARG(&ua, dev) = (svr4_dev_t) SCARG(uap, a2); + SCARG(&ua, name) = SCARG(uap, a1); + return svr4_ustat(p, &ua, retval); + } + + case 3: /* fusers(2) */ + return ENOSYS; + + default: + return ENOSYS; + } + return ENOSYS; +} diff --git a/sys/compat/svr4/svr4_stat.h b/sys/compat/svr4/svr4_stat.h new file mode 100644 index 00000000000..7af8232bf4c --- /dev/null +++ b/sys/compat/svr4/svr4_stat.h @@ -0,0 +1,71 @@ +/* $NetBSD: svr4_stat.h,v 1.3 1994/10/29 00:43:27 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_STAT_H_ +#define _SVR4_STAT_H_ + +#include <compat/svr4/svr4_types.h> +#include <sys/stat.h> + +struct svr4_stat { + svr4_o_dev_t st_dev; + svr4_o_ino_t st_ino; + svr4_o_mode_t st_mode; + svr4_o_nlink_t st_nlink; + svr4_o_uid_t st_uid; + svr4_o_gid_t st_gid; + svr4_o_dev_t st_rdev; + svr4_off_t st_size; + svr4_time_t st_atim; + svr4_time_t st_mtim; + svr4_time_t st_ctim; +}; + +struct svr4_xstat { + svr4_dev_t st_dev; + long st_pad1[3]; + svr4_ino_t st_ino; + svr4_mode_t st_mode; + svr4_nlink_t st_nlink; + svr4_uid_t st_uid; + svr4_gid_t st_gid; + svr4_dev_t st_rdev; + long st_pad2[2]; + svr4_off_t st_size; + long st_pad3; + svr4_timestruc_t st_atim; + svr4_timestruc_t st_mtim; + svr4_timestruc_t st_ctim; + long st_blksize; + long st_blocks; + char st_fstype[16]; + long st_pad4[8]; +}; + +#endif /* !_SVR4_STAT_H_ */ diff --git a/sys/compat/svr4/svr4_statvfs.h b/sys/compat/svr4/svr4_statvfs.h new file mode 100644 index 00000000000..d5f592018ff --- /dev/null +++ b/sys/compat/svr4/svr4_statvfs.h @@ -0,0 +1,54 @@ +/* $NetBSD: svr4_statvfs.h,v 1.1 1995/01/08 21:31:39 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_STATVFS_H_ +#define _SVR4_STATVFS_H_ + +typedef struct svr4_statvfs { + u_long f_bsize; + u_long f_frsize; + u_long f_blocks; + u_long f_bfree; + u_long f_bavail; + u_long f_files; + u_long f_ffree; + u_long f_favail; + u_long f_fsid; + char f_basetype[16]; + u_long f_flag; + u_long f_namemax; + char f_fstr[32]; + u_long f_filler[16]; +} svr4_statvfs_t; + +#define SVR4_ST_RDONLY 0x01 +#define SVR4_ST_NOSUID 0x02 +#define SVR4_ST_NOTRUNC 0x04 + +#endif /* !_SVR4_STATVFS_H_ */ diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c new file mode 100644 index 00000000000..f052f7fbc6f --- /dev/null +++ b/sys/compat/svr4/svr4_stream.c @@ -0,0 +1,971 @@ +/* $NetBSD: svr4_stream.c,v 1.9 1995/10/07 06:27:52 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Pretend that we have streams... + */ + +#include <sys/param.h> +#include <sys/kernel.h> +#include <sys/systm.h> +#include <sys/buf.h> +#include <sys/malloc.h> +#include <sys/ioctl.h> +#include <sys/tty.h> +#include <sys/file.h> +#include <sys/filedesc.h> +#include <sys/select.h> +#include <sys/socket.h> +#include <sys/socketvar.h> +#include <net/if.h> +#include <netinet/in.h> +#include <sys/mount.h> +#include <sys/proc.h> +#include <sys/vnode.h> +#include <sys/device.h> + +#include <sys/syscallargs.h> + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_stropts.h> +#include <compat/svr4/svr4_timod.h> +#include <compat/svr4/svr4_sockmod.h> +#include <compat/svr4/svr4_ioctl.h> + +static void svr4_getparm __P((struct socket *, struct svr4_si_sockparms *)); +static int svr4_sockmod __P((struct file *, struct svr4_strioctl *, + struct proc *)); +static int svr4_timod __P((struct file *, struct svr4_strioctl *, + struct proc *)); +#ifdef DEBUG_SVR4 +static int svr4_showioc __P((const char *, struct svr4_strioctl *)); +static int svr4_getstrbuf __P((struct svr4_strbuf *)); +static void svr4_showmsg __P((const char *, int, struct svr4_strbuf *, + struct svr4_strbuf *, int)); +#endif /* DEBUG_SVR4 */ + + +static void +svr4_getparm(so, pa) + struct socket *so; + struct svr4_si_sockparms *pa; +{ + pa->family = AF_INET; + + switch (so->so_type) { + case SOCK_DGRAM: + pa->type = SVR4_SOCK_DGRAM; + pa->protocol = IPPROTO_UDP; + return; + + case SOCK_STREAM: + pa->type = SVR4_SOCK_STREAM; + pa->protocol = IPPROTO_TCP; + return; + + case SOCK_RAW: + pa->type = SVR4_SOCK_RAW; + pa->protocol = IPPROTO_RAW; + return; + + default: + pa->type = 0; + pa->protocol = 0; + return; + } +} + + +static int +svr4_sockmod(fp, ioc, p) + struct file *fp; + struct svr4_strioctl *ioc; + struct proc *p; +{ + int error; + + switch (ioc->cmd) { + case SVR4_SI_OGETUDATA: + DPRINTF(("SI_OGETUDATA\n")); + { + struct svr4_si_oudata ud; + struct svr4_si_sockparms pa; + struct socket *so = (struct socket *) fp->f_data; + + if (sizeof(ud) != ioc->len) { + DPRINTF(("Wrong size %d != %d\n", + sizeof(ud), ioc->len)); + return EINVAL; + } + + if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0) + return error; + + /* I have no idea what these should be! */ + ud.tidusize = 16384; + ud.addrsize = sizeof(struct sockaddr_in); + ud.optsize = 128; + + svr4_getparm(so, &pa); + + if (pa.type == SVR4_SOCK_STREAM) + ud.etsdusize = 1; + else + ud.etsdusize = 0; + + ud.servtype = pa.type; + + /* XXX: Fixme */ + ud.so_state = 0; + ud.so_options = 0; + return copyout(&ud, ioc->buf, sizeof(ud)); + } + + case SVR4_SI_SHUTDOWN: + DPRINTF(("SI_SHUTDOWN\n")); + return 0; + + case SVR4_SI_LISTEN: + DPRINTF(("SI_LISTEN\n")); + return 0; + + case SVR4_SI_SETMYNAME: + DPRINTF(("SI_SETMYNAME\n")); + return 0; + + case SVR4_SI_SETPEERNAME: + DPRINTF(("SI_SETPEERNAME\n")); + return 0; + + case SVR4_SI_GETINTRANSIT: + DPRINTF(("SI_GETINTRANSIT\n")); + return 0; + + case SVR4_SI_TCL_LINK: + DPRINTF(("SI_TCL_LINK\n")); + return 0; + + case SVR4_SI_TCL_UNLINK: + DPRINTF(("SI_TCL_UNLINK\n")); + return 0; + + case SVR4_SI_SOCKPARAMS: + DPRINTF(("SI_SOCKPARAMS\n")); + { + struct socket *so = (struct socket *) fp->f_data; + struct svr4_si_sockparms pa; + + svr4_getparm(so, &pa); + return copyout(&pa, ioc->buf, sizeof(pa)); + } + return 0; + + case SVR4_SI_GETUDATA: + DPRINTF(("SI_GETUDATA\n")); + { + struct svr4_si_udata ud; + struct socket *so = (struct socket *) fp->f_data; + + if (sizeof(ud) != ioc->len) { + DPRINTF(("Wrong size %d != %d\n", + sizeof(ud), ioc->len)); + return EINVAL; + } + + if ((error = copyin(ioc->buf, &ud, sizeof(ud))) != 0) + return error; + + /* I have no idea what these should be! */ + ud.tidusize = 16384; + ud.addrsize = sizeof(struct sockaddr_in); + ud.optsize = 128; + ud.tsdusize = 16384; + + svr4_getparm(so, &ud.sockparms); + + if (ud.sockparms.type == SVR4_SOCK_STREAM) + ud.etsdusize = 1; + else + ud.etsdusize = 0; + + ud.servtype = ud.sockparms.type; + + /* XXX: Fixme */ + ud.so_state = 0; + ud.so_options = 0; + return copyout(&ud, ioc->buf, sizeof(ud)); + } + return 0; + + default: + DPRINTF(("Unknown sockmod ioctl %x\n", ioc->cmd)); + return 0; + + } +} + +static int +svr4_timod(fp, ioc, p) + struct file *fp; + struct svr4_strioctl *ioc; + struct proc *p; +{ + int error; + + switch (ioc->cmd) { + case SVR4_TI_GETINFO: + DPRINTF(("TI_GETINFO\n")); + { + struct svr4_infocmd info; + + bzero(&info, sizeof(info)); + + if ((error = copyin(ioc->buf, &info, ioc->len)) != 0) + return error; + + if (info.cmd != SVR4_TI_INFO_REQUEST) + return EINVAL; + + info.cmd = SVR4_TI_INFO_REPLY; + info.tsdu = 0; + info.etsdu = 1; + info.cdata = -2; + info.ddata = -2; + info.addr = 16; + info.opt = -1; + info.tidu = 16384; + info.serv = 2; + info.current = 0; + info.provider = 2; + + ioc->len = sizeof(info); + if ((error = copyout(&info, ioc->buf, ioc->len)) != 0) + return error; + } + return 0; + + case SVR4_TI_OPTMGMT: + DPRINTF(("TI_OPTMGMT\n")); + return 0; + + case SVR4_TI_BIND: + DPRINTF(("TI_BIND\n")); + { + struct svr4_strmcmd bnd; + bzero(&bnd, sizeof(bnd)); + + if ((error = copyin(ioc->buf, &bnd, ioc->len)) != 0) + return error; + + if (bnd.cmd != SVR4_TI_BIND_REQUEST) + return EINVAL; + + ioc->len = 32; + + bzero(&bnd, sizeof(bnd)); + + bnd.cmd = SVR4_TI_BIND_REPLY; + bnd.len = sizeof(struct sockaddr_in); + bnd.offs = 0x10; + + if ((error = copyout(&bnd, ioc->buf, ioc->len)) != 0) + return error; + } + return 0; + + case SVR4_TI_UNBIND: + DPRINTF(("TI_UNBIND\n")); + return 0; + + case SVR4_TI_GETMYNAME: + DPRINTF(("TI_GETMYNAME\n")); + return 0; + + case SVR4_TI_GETPEERNAME: + DPRINTF(("TI_GETPEERNAME\n")); + return 0; + + case SVR4_TI_SETMYNAME: + DPRINTF(("TI_SETMYNAME\n")); + return 0; + + case SVR4_TI_SETPEERNAME: + DPRINTF(("TI_SETPEERNAME\n")); + return 0; + + default: + DPRINTF(("Unknown timod ioctl %x\n", ioc->cmd)); + return 0; + } +} + + +#ifdef DEBUG_SVR4 +static int +svr4_showioc(str, ioc) + const char *str; + struct svr4_strioctl *ioc; +{ + char *ptr = (char *) malloc(ioc->len, M_TEMP, M_WAITOK); + int error; + int i; + + printf("%s cmd = %d, timeout = %d, len = %d, buf = %x { ", + str, ioc->cmd, ioc->timeout, ioc->len, ioc->buf); + + if ((error = copyin(ioc->buf, ptr, ioc->len)) != 0) { + free((char *) ptr, M_TEMP); + return error; + } + + for (i = 0; i < ioc->len; i++) + printf("%x ", (unsigned char) ptr[i]); + + printf("}\n"); + + free((char *) ptr, M_TEMP); + return 0; +} +#endif /* DEBUG_SVR4 */ + + +int +svr4_streamioctl(fp, cmd, dat, p, retval) + struct file *fp; + u_long cmd; + caddr_t dat; + struct proc *p; + register_t *retval; +{ + struct svr4_strioctl ioc; + int error; + + *retval = 0; + + /* + * All the following stuff assumes "sockmod" is pushed... + */ + switch (cmd) { + case SVR4_I_NREAD: + DPRINTF(("I_NREAD\n")); + { + int nread = 0; /* XXX: is that FIONREAD? */ + if ((error = copyout(&nread, dat, sizeof(nread))) != 0) + return error; + } + return 0; + + case SVR4_I_PUSH: + DPRINTF(("I_PUSH\n")); + return 0; + + case SVR4_I_POP: + DPRINTF(("I_POP\n")); + return 0; + + case SVR4_I_LOOK: + DPRINTF(("I_LOOK\n")); + return 0; + + case SVR4_I_FLUSH: + DPRINTF(("I_FLUSH\n")); + return 0; + + case SVR4_I_SRDOPT: + DPRINTF(("I_SRDOPT\n")); + return 0; + + case SVR4_I_GRDOPT: + DPRINTF(("I_GRDOPT\n")); + return 0; + + case SVR4_I_STR: + DPRINTF(("I_STR\n")); + if ((error = copyin(dat, &ioc, sizeof(ioc))) != 0) + return error; + +#ifdef DEBUG_SVR4 + if ((error = svr4_showioc(">", &ioc)) != 0) + return error; +#endif /* DEBUG_SVR4 */ + switch (ioc.cmd & 0xff00) { + case SVR4_SIMOD: + if ((error = svr4_sockmod(fp, &ioc, p)) != 0) + return error; + break; + + case SVR4_TIMOD: + if ((error = svr4_timod(fp, &ioc, p)) != 0) + return error; + break; + + default: + DPRINTF(("Unimplemented module %c %d\n", + (char) (cmd >> 8), cmd & 0xff)); + return 0; + } + +#ifdef DEBUG_SVR4 + if ((error = svr4_showioc("<", &ioc)) != 0) + return error; +#endif /* DEBUG_SVR4 */ + return copyout(&ioc, dat, sizeof(ioc)); + + case SVR4_I_SETSIG: + DPRINTF(("I_SETSIG\n")); + return 0; + + case SVR4_I_GETSIG: + DPRINTF(("I_GETSIG\n")); + return EINVAL; + + case SVR4_I_FIND: + DPRINTF(("I_FIND\n")); + /* + * Here we are not pushing modules really, we just + * pretend all are present + */ + *retval = 1; + return 0; + + case SVR4_I_LINK: + DPRINTF(("I_LINK\n")); + return 0; + + case SVR4_I_UNLINK: + DPRINTF(("I_UNLINK\n")); + return 0; + + case SVR4_I_ERECVFD: + DPRINTF(("I_ERECVFD\n")); + return 0; + + case SVR4_I_PEEK: + DPRINTF(("I_PEEK\n")); + return 0; + + case SVR4_I_FDINSERT: + DPRINTF(("I_FDINSERT\n")); + return 0; + + case SVR4_I_SENDFD: + DPRINTF(("I_SENDFD\n")); + return 0; + + case SVR4_I_RECVFD: + DPRINTF(("I_RECVFD\n")); + return 0; + + case SVR4_I_SWROPT: + DPRINTF(("I_SWROPT\n")); + return 0; + + case SVR4_I_GWROPT: + DPRINTF(("I_GWROPT\n")); + return 0; + + case SVR4_I_LIST: + DPRINTF(("I_LIST\n")); + return 0; + + case SVR4_I_PLINK: + DPRINTF(("I_PLINK\n")); + return 0; + + case SVR4_I_PUNLINK: + DPRINTF(("I_PUNLINK\n")); + return 0; + + case SVR4_I_SETEV: + DPRINTF(("I_SETEV\n")); + return 0; + + case SVR4_I_GETEV: + DPRINTF(("I_GETEV\n")); + return 0; + + case SVR4_I_STREV: + DPRINTF(("I_STREV\n")); + return 0; + + case SVR4_I_UNSTREV: + DPRINTF(("I_UNSTREV\n")); + return 0; + + case SVR4_I_FLUSHBAND: + DPRINTF(("I_FLUSHBAND\n")); + return 0; + + case SVR4_I_CKBAND: + DPRINTF(("I_CKBAND\n")); + return 0; + + case SVR4_I_GETBAND: + DPRINTF(("I_GETBANK\n")); + return 0; + + case SVR4_I_ATMARK: + DPRINTF(("I_ATMARK\n")); + return 0; + + case SVR4_I_SETCLTIME: + DPRINTF(("I_SETCLTIME\n")); + return 0; + + case SVR4_I_GETCLTIME: + DPRINTF(("I_GETCLTIME\n")); + return 0; + + case SVR4_I_CANPUT: + DPRINTF(("I_CANPUT\n")); + return 0; + + default: + DPRINTF(("unimpl cmd = %x\n", cmd)); + break; + } + + return 0; +} + + +#ifdef DEBUG_SVR4 +static int +svr4_getstrbuf(str) + struct svr4_strbuf *str; +{ + int error; + int i; + char *ptr = NULL; + int maxlen = str->maxlen; + int len = str->len; + + if (maxlen < 0) + maxlen = 0; + + if (len >= maxlen || len <= 0) + len = maxlen; + + if (len != 0) { + ptr = malloc(len, M_TEMP, M_WAITOK); + + if ((error = copyin(str->buf, ptr, len)) != 0) { + free((char *) ptr, M_TEMP); + return error; + } + } + + printf(", { %d, %d, %x=[ ", str->maxlen, str->len, str->buf); + for (i = 0; i < len; i++) { + printf("%x ", (unsigned char) ptr[i]); + if (i > 20) { + printf("..."); + break; + } + } + printf("]}"); + + if (ptr) + free((char *) ptr, M_TEMP); + + return 0; +} + + +static void +svr4_showmsg(str, fd, ctl, dat, flags) + const char *str; + int fd; + struct svr4_strbuf *ctl; + struct svr4_strbuf *dat; + int flags; +{ + struct svr4_strbuf buf; + int error; + + printf("%s(%d", str, fd); + if (ctl != NULL) { + if ((error = copyin(ctl, &buf, sizeof(buf))) != 0) + return; + svr4_getstrbuf(&buf); + } + else + printf(", NULL"); + + if (dat != NULL) { + if ((error = copyin(dat, &buf, sizeof(buf))) != 0) + return; + svr4_getstrbuf(&buf); + } + else + printf(", NULL"); + + printf(", %x);\n", flags); +} +#endif /* DEBUG_SVR4 */ + + +int +svr4_sys_putmsg(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_putmsg_args *uap = v; + struct filedesc *fdp = p->p_fd; + struct file *fp; + struct svr4_strbuf dat, ctl; + struct svr4_strmcmd sc; + struct svr4_netaddr *na; + struct socket *so; + struct svr4_strm *st; + int error; + struct sockaddr_in sa, *sap; + caddr_t sg; + + if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || + (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) + return EBADF; + +#ifdef DEBUG_SVR4 + svr4_showmsg(">putmsg", SCARG(uap, fd), SCARG(uap, ctl), + SCARG(uap, dat), SCARG(uap, flags)); +#endif /* DEBUG_SVR4 */ + + if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || + (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) + return EBADF; + + if (SCARG(uap, ctl) != NULL) { + if ((error = copyin(SCARG(uap, ctl), &ctl, sizeof(ctl))) != 0) + return error; + } + else + ctl.len = -1; + + if (SCARG(uap, dat) != NULL) { + if ((error = copyin(SCARG(uap, dat), &dat, sizeof(dat))) != 0) + return error; + } + else + dat.len = -1; + + /* + * Only for sockets for now. + */ + if (fp == NULL || fp->f_type != DTYPE_SOCKET) { + DPRINTF(("putmsg: bad file type\n")); + return EINVAL; + } + + so = (struct socket *) fp->f_data; + st = (struct svr4_strm *) so->so_tpcb; + + + if (ctl.len > sizeof(sc)) { + DPRINTF(("putmsg: Bad control size %d != %d\n", ctl.len, + sizeof(struct svr4_strmcmd))); + return EINVAL; + } + + if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0) + return error; + + if (sc.len != sizeof(sa)) { + DPRINTF(("putmsg: Cannot handle variable address lengths\n")); + return ENOSYS; + } + + na = SVR4_ADDROF(&sc); + bzero(&sa, sizeof(sa)); + sa.sin_family = na->family; + sa.sin_port = na->port; + sa.sin_addr.s_addr = na->addr; + + sg = stackgap_init(p->p_emul); + sap = (struct sockaddr_in *) stackgap_alloc(&sg, + sizeof(struct sockaddr_in)); + + if ((error = copyout(&sa, sap, sizeof(sa))) != 0) + return error; + + switch (st->s_cmd = sc.cmd) { + case SVR4_TI_CONNECT_REQUEST: /* connect */ + { + struct sys_connect_args co; + + co.s = SCARG(uap, fd); + co.name = (caddr_t) sap; + co.namelen = (int) sizeof(sa); + return sys_connect(p, &co, retval); + } + + case SVR4_TI_SENDTO_REQUEST: /* sendto */ + { + struct msghdr msg; + struct iovec aiov; + msg.msg_name = (caddr_t) sap; + msg.msg_namelen = sizeof(sa); + msg.msg_iov = &aiov; + msg.msg_iovlen = 1; + msg.msg_control = 0; +#ifdef COMPAT_OLDSOCK + msg.msg_flags = 0; +#endif /* COMPAT_OLDSOCK */ + aiov.iov_base = dat.buf; + aiov.iov_len = dat.len; + error = sendit(p, SCARG(uap, fd), &msg, + SCARG(uap, flags), retval); + + *retval = 0; + return error; + } + default: + DPRINTF(("putmsg: Unimplemented command %x\n", sc.cmd)); + return ENOSYS; + } +} + + +int +svr4_sys_getmsg(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_getmsg_args *uap = v; + struct filedesc *fdp = p->p_fd; + struct file *fp; + struct sys_getpeername_args ga; + struct svr4_strbuf dat, ctl; + struct svr4_strmcmd sc; + struct svr4_netaddr *na; + int error; + struct msghdr msg; + struct iovec aiov; + struct sockaddr_in sa, *sap; + struct socket *so; + struct svr4_strm *st; + int *flen; + int fl; + caddr_t sg; + + if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || + (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) + return EBADF; + + bzero(&sc, sizeof(sc)); + +#ifdef DEBUG_SVR4 + svr4_showmsg(">getmsg", SCARG(uap, fd), SCARG(uap, ctl), + SCARG(uap, dat), 0); +#endif /* DEBUG_SVR4 */ + + if ((u_int)SCARG(uap, fd) >= fdp->fd_nfiles || + (fp = fdp->fd_ofiles[SCARG(uap, fd)]) == NULL) + return EBADF; + + if (SCARG(uap, ctl) != NULL) { + if ((error = copyin(SCARG(uap, ctl), &ctl, sizeof(ctl))) != 0) + return error; + } + else { + ctl.len = -1; + ctl.maxlen = 0; + } + + if (SCARG(uap, dat) != NULL) { + if ((error = copyin(SCARG(uap, dat), &dat, sizeof(dat))) != 0) + return error; + } + else { + dat.len = -1; + dat.maxlen = 0; + } + + /* + * Only for sockets for now. + */ + if (fp == NULL || fp->f_type != DTYPE_SOCKET) { + DPRINTF(("getmsg: bad file type\n")); + return EINVAL; + } + + so = (struct socket *) fp->f_data; + st = (struct svr4_strm *) so->so_tpcb; + + if (ctl.maxlen == -1 || dat.maxlen == -1) { + DPRINTF(("getmsg: Cannot handle -1 maxlen (yet)\n")); + return ENOSYS; + } + + sg = stackgap_init(p->p_emul); + sap = (struct sockaddr_in *) stackgap_alloc(&sg, + sizeof(struct sockaddr_in)); + flen = (int *) stackgap_alloc(&sg, sizeof(*flen)); + + fl = sizeof(sa); + if ((error = copyout(&fl, flen, sizeof(fl))) != 0) + return error; + + + switch (st->s_cmd) { + case SVR4_TI_CONNECT_REQUEST: + /* + * We do the connect in one step, so the putmsg should + * have gotten the error. + */ + sc.cmd = SVR4_TI_OK_REPLY; + sc.len = 0; + + ctl.len = 8; + dat.len = -1; + fl = 1; + break; + + case SVR4_TI_OK_REPLY: + /* + * We are immediately after a connect reply, so we send + * an connect verification. + */ + SCARG(&ga, fdes) = SCARG(uap, fd); + SCARG(&ga, asa) = (caddr_t) sap; + SCARG(&ga, alen) = flen; + + if ((error = sys_getpeername(p, &ga, retval)) != 0) { + DPRINTF(("getmsg: getpeername failed %d\n", error)); + return error; + } + + if ((error = copyin(sap, &sa, sizeof(sa))) != 0) + return error; + + sc.cmd = SVR4_TI_CONNECT_REPLY; + sc.len = sizeof(struct sockaddr_in); + sc.offs = 0x18; + sc.pad[0] = 0x4; + sc.pad[1] = 0x14; + sc.pad[2] = 0x04000402; + na = SVR4_ADDROF(&sc); + + na->family = sa.sin_family; + na->port = sa.sin_port; + na->addr = sa.sin_addr.s_addr; + + ctl.len = 40; + dat.len = -1; + fl = 0; + break; + + case SVR4_TI_SENDTO_REQUEST: + if (ctl.maxlen > 36 && ctl.len < 36) + ctl.len = 36; + + if ((error = copyin(ctl.buf, &sc, ctl.len)) != 0) + return error; + + + na = SVR4_ADDROF(&sc); + + bzero(&sa, sizeof(sa)); + sa.sin_family = na->family; + sa.sin_port = na->port; + sa.sin_addr.s_addr = na->addr; + + if ((error = copyout(&sa, sap, sizeof(sa))) != 0) + return error; + + msg.msg_name = (caddr_t) sap; + msg.msg_namelen = sizeof(sa); + msg.msg_iov = &aiov; + msg.msg_iovlen = 1; + msg.msg_control = 0; + aiov.iov_base = dat.buf; + aiov.iov_len = dat.maxlen; + msg.msg_flags = 0; + + error = recvit(p, SCARG(uap, fd), &msg, flen, retval); + + if (error) { + DPRINTF(("getmsg: recvit failed %d\n", error)) + return error; + } + + + if ((error = copyin(msg.msg_name, &sa, sizeof(sa))) != 0) + return error; + + sc.cmd = SVR4_TI_RECVFROM_REPLY; + sc.len = sizeof(sa); + + na->family = sa.sin_family; + na->port = sa.sin_port; + na->addr = sa.sin_addr.s_addr; + + dat.len = *retval; + fl = 0; + break; + + default: + DPRINTF(("getmsg: Unknown state %x\n", st->s_cmd)); + return EINVAL; + } + + + st->s_cmd = sc.cmd; + if (SCARG(uap, ctl)) { + if (ctl.len != -1) + if ((error = copyout(&sc, ctl.buf, ctl.len)) != 0) + return error; + + if ((error = copyout(&ctl, SCARG(uap, ctl), sizeof(ctl))) != 0) + return error; + } + + if (SCARG(uap, dat)) { + if ((error = copyout(&dat, SCARG(uap, dat), sizeof(dat))) != 0) + return error; + } + + if (SCARG(uap, flags)) { /* XXX: Need translation */ + if ((error = copyout(&fl, SCARG(uap, flags), sizeof(fl))) != 0) + return error; + } + + *retval = 0; + +#ifdef DEBUG_SVR4 + svr4_showmsg("<getmsg", SCARG(uap, fd), SCARG(uap, ctl), + SCARG(uap, dat), fl); +#endif /* DEBUG_SVR4 */ + return error; +} diff --git a/sys/compat/svr4/svr4_stropts.h b/sys/compat/svr4/svr4_stropts.h new file mode 100644 index 00000000000..ff83734a1cf --- /dev/null +++ b/sys/compat/svr4/svr4_stropts.h @@ -0,0 +1,126 @@ +/* $NetBSD: svr4_stropts.h,v 1.5 1995/10/07 06:27:53 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_STROPTS_H_ +#define _SVR4_STROPTS_H_ + + +struct svr4_strbuf { + int maxlen; + int len; + char *buf; +}; + +#define SVR4_STR ('S' << 8) +#define SVR4_I_NREAD (SVR4_STR| 1) +#define SVR4_I_PUSH (SVR4_STR| 2) +#define SVR4_I_POP (SVR4_STR| 3) +#define SVR4_I_LOOK (SVR4_STR| 4) +#define SVR4_I_FLUSH (SVR4_STR| 5) +#define SVR4_I_SRDOPT (SVR4_STR| 6) +#define SVR4_I_GRDOPT (SVR4_STR| 7) +#define SVR4_I_STR (SVR4_STR| 8) +#define SVR4_I_SETSIG (SVR4_STR| 9) +#define SVR4_I_GETSIG (SVR4_STR|10) +#define SVR4_I_FIND (SVR4_STR|11) +#define SVR4_I_LINK (SVR4_STR|12) +#define SVR4_I_UNLINK (SVR4_STR|13) +#define SVR4_I_ERECVFD (SVR4_STR|14) +#define SVR4_I_PEEK (SVR4_STR|15) +#define SVR4_I_FDINSERT (SVR4_STR|16) +#define SVR4_I_SENDFD (SVR4_STR|17) +#define SVR4_I_RECVFD (SVR4_STR|18) +#define SVR4_I_SWROPT (SVR4_STR|19) +#define SVR4_I_GWROPT (SVR4_STR|20) +#define SVR4_I_LIST (SVR4_STR|21) +#define SVR4_I_PLINK (SVR4_STR|22) +#define SVR4_I_PUNLINK (SVR4_STR|23) +#define SVR4_I_SETEV (SVR4_STR|24) +#define SVR4_I_GETEV (SVR4_STR|25) +#define SVR4_I_STREV (SVR4_STR|26) +#define SVR4_I_UNSTREV (SVR4_STR|27) +#define SVR4_I_FLUSHBAND (SVR4_STR|28) +#define SVR4_I_CKBAND (SVR4_STR|29) +#define SVR4_I_GETBAND (SVR4_STR|30) +#define SVR4_I_ATMARK (SVR4_STR|31) +#define SVR4_I_SETCLTIME (SVR4_STR|32) +#define SVR4_I_GETCLTIME (SVR4_STR|33) +#define SVR4_I_CANPUT (SVR4_STR|34) + +/* Struct passed for SVR4_I_STR */ +struct svr4_strioctl { + u_long cmd; + int timeout; + int len; + char *buf; +}; + + +/* + * Our internal state for the stream + * For now we keep almost nothing... In the future we can keep more + * streams state. + */ +struct svr4_strm { + int s_cmd; /* last getmsg reply or putmsg request */ +}; + +/* + * The following structures are determined empirically. + */ +struct svr4_strmcmd { + long cmd; /* command ? */ + long len; /* Address len */ + long offs; /* Address offset */ + long pad[61]; +}; + +struct svr4_infocmd { + long cmd; + long tsdu; + long etsdu; + long cdata; + long ddata; + long addr; + long opt; + long tidu; + long serv; + long current; + long provider; +}; + +struct svr4_netaddr { + u_short family; + u_short port; + u_long addr; +}; + +#define SVR4_ADDROF(sc) (struct svr4_netaddr *) (((char *) (sc)) + (sc)->offs) + +#endif /* !_SVR4_STROPTS */ diff --git a/sys/compat/svr4/svr4_syscall.h b/sys/compat/svr4/svr4_syscall.h new file mode 100644 index 00000000000..2a3076df8e8 --- /dev/null +++ b/sys/compat/svr4/svr4_syscall.h @@ -0,0 +1,110 @@ +/* + * System call numbers. + * + * DO NOT EDIT-- this file is automatically generated. + * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp + */ + +#define SVR4_SYS_syscall 0 +#define SVR4_SYS_exit 1 +#define SVR4_SYS_fork 2 +#define SVR4_SYS_read 3 +#define SVR4_SYS_write 4 +#define SVR4_SYS_open 5 +#define SVR4_SYS_close 6 +#define SVR4_SYS_wait 7 +#define SVR4_SYS_creat 8 +#define SVR4_SYS_link 9 +#define SVR4_SYS_unlink 10 +#define SVR4_SYS_execv 11 +#define SVR4_SYS_chdir 12 +#define SVR4_SYS_time 13 +#define SVR4_SYS_mknod 14 +#define SVR4_SYS_chmod 15 +#define SVR4_SYS_chown 16 +#define SVR4_SYS_break 17 +#define SVR4_SYS_stat 18 +#define SVR4_SYS_lseek 19 +#define SVR4_SYS_getpid 20 +#define SVR4_SYS_setuid 23 +#define SVR4_SYS_getuid 24 +#define SVR4_SYS_alarm 27 +#define SVR4_SYS_fstat 28 +#define SVR4_SYS_access 33 +#define SVR4_SYS_sync 36 +#define SVR4_SYS_kill 37 +#define SVR4_SYS_pgrpsys 39 +#define SVR4_SYS_dup 41 +#define SVR4_SYS_pipe 42 +#define SVR4_SYS_times 43 +#define SVR4_SYS_setgid 46 +#define SVR4_SYS_getgid 47 +#define SVR4_SYS_signal 48 +#define SVR4_SYS_sysarch 50 +#define SVR4_SYS_ioctl 54 +#define SVR4_SYS_utssys 57 +#define SVR4_SYS_fsync 58 +#define SVR4_SYS_execve 59 +#define SVR4_SYS_umask 60 +#define SVR4_SYS_chroot 61 +#define SVR4_SYS_fcntl 62 +#define SVR4_SYS_ulimit 63 + /* 70 is obsolete advfs */ + /* 71 is obsolete unadvfs */ + /* 72 is obsolete rmount */ + /* 73 is obsolete rumount */ + /* 74 is obsolete rfstart */ + /* 75 is obsolete sigret */ + /* 76 is obsolete rdebug */ + /* 77 is obsolete rfstop */ +#define SVR4_SYS_rmdir 79 +#define SVR4_SYS_mkdir 80 +#define SVR4_SYS_getdents 81 + /* 82 is obsolete libattach */ + /* 83 is obsolete libdetach */ +#define SVR4_SYS_getmsg 85 +#define SVR4_SYS_putmsg 86 +#define SVR4_SYS_poll 87 +#define SVR4_SYS_lstat 88 +#define SVR4_SYS_symlink 89 +#define SVR4_SYS_readlink 90 +#define SVR4_SYS_getgroups 91 +#define SVR4_SYS_setgroups 92 +#define SVR4_SYS_fchmod 93 +#define SVR4_SYS_fchown 94 +#define SVR4_SYS_sigprocmask 95 +#define SVR4_SYS_sigsuspend 96 +#define SVR4_SYS_sigaltstack 97 +#define SVR4_SYS_sigaction 98 +#define SVR4_SYS_sigpending 99 +#define SVR4_SYS_context 100 +#define SVR4_SYS_statvfs 103 +#define SVR4_SYS_fstatvfs 104 +#define SVR4_SYS_waitsys 107 +#define SVR4_SYS_hrtsys 109 +#define SVR4_SYS_mmap 115 +#define SVR4_SYS_mprotect 116 +#define SVR4_SYS_munmap 117 +#define SVR4_SYS_fpathconf 118 +#define SVR4_SYS_vfork 119 +#define SVR4_SYS_fchdir 120 +#define SVR4_SYS_readv 121 +#define SVR4_SYS_writev 122 +#define SVR4_SYS_xstat 123 +#define SVR4_SYS_lxstat 124 +#define SVR4_SYS_fxstat 125 +#define SVR4_SYS_setrlimit 128 +#define SVR4_SYS_getrlimit 129 +#define SVR4_SYS_rename 134 +#define SVR4_SYS_uname 135 +#define SVR4_SYS_setegid 136 +#define SVR4_SYS_sysconfig 137 +#define SVR4_SYS_adjtime 138 +#define SVR4_SYS_systeminfo 139 +#define SVR4_SYS_seteuid 141 +#define SVR4_SYS_fchroot 153 +#define SVR4_SYS_vhangup 155 +#define SVR4_SYS_gettimeofday 156 +#define SVR4_SYS_getitimer 157 +#define SVR4_SYS_setitimer 158 +#define SVR4_SYS_MAXSYSCALL 187 diff --git a/sys/compat/svr4/svr4_syscallargs.h b/sys/compat/svr4/svr4_syscallargs.h new file mode 100644 index 00000000000..79b22a29872 --- /dev/null +++ b/sys/compat/svr4/svr4_syscallargs.h @@ -0,0 +1,369 @@ +/* + * System call argument lists. + * + * DO NOT EDIT-- this file is automatically generated. + * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp + */ + +#define syscallarg(x) union { x datum; register_t pad; } + +struct svr4_sys_open_args { + syscallarg(char *) path; + syscallarg(int) flags; + syscallarg(int) mode; +}; + +struct svr4_sys_wait_args { + syscallarg(int *) status; +}; + +struct svr4_sys_creat_args { + syscallarg(char *) path; + syscallarg(int) mode; +}; + +struct svr4_sys_execv_args { + syscallarg(char *) path; + syscallarg(char **) argp; +}; + +struct svr4_sys_time_args { + syscallarg(svr4_time_t *) t; +}; + +struct svr4_sys_mknod_args { + syscallarg(char *) path; + syscallarg(int) mode; + syscallarg(int) dev; +}; + +struct svr4_sys_break_args { + syscallarg(caddr_t) nsize; +}; + +struct svr4_sys_stat_args { + syscallarg(char *) path; + syscallarg(struct svr4_stat *) ub; +}; + +struct svr4_sys_alarm_args { + syscallarg(unsigned) sec; +}; + +struct svr4_sys_fstat_args { + syscallarg(int) fd; + syscallarg(struct svr4_stat *) sb; +}; + +struct svr4_sys_access_args { + syscallarg(char *) path; + syscallarg(int) flags; +}; + +struct svr4_sys_kill_args { + syscallarg(int) pid; + syscallarg(int) signum; +}; + +struct svr4_sys_pgrpsys_args { + syscallarg(int) cmd; + syscallarg(int) pid; + syscallarg(int) pgid; +}; + +struct svr4_sys_times_args { + syscallarg(struct tms *) tp; +}; + +struct svr4_sys_signal_args { + syscallarg(int) signum; + syscallarg(svr4_sig_t) handler; +}; + +struct svr4_sys_sysarch_args { + syscallarg(int) op; + syscallarg(void *) a1; +}; + +struct svr4_sys_ioctl_args { + syscallarg(int) fd; + syscallarg(u_long) com; + syscallarg(caddr_t) data; +}; + +struct svr4_sys_utssys_args { + syscallarg(void *) a1; + syscallarg(void *) a2; + syscallarg(int) sel; + syscallarg(void *) a3; +}; + +struct svr4_sys_execve_args { + syscallarg(char *) path; + syscallarg(char **) argp; + syscallarg(char **) envp; +}; + +struct svr4_sys_fcntl_args { + syscallarg(int) fd; + syscallarg(int) cmd; + syscallarg(char *) arg; +}; + +struct svr4_sys_ulimit_args { + syscallarg(int) cmd; + syscallarg(long) newlimit; +}; + +struct svr4_sys_getdents_args { + syscallarg(int) fd; + syscallarg(char *) buf; + syscallarg(int) nbytes; +}; + +struct svr4_sys_getmsg_args { + syscallarg(int) fd; + syscallarg(struct svr4_strbuf *) ctl; + syscallarg(struct svr4_strbuf *) dat; + syscallarg(int *) flags; +}; + +struct svr4_sys_putmsg_args { + syscallarg(int) fd; + syscallarg(struct svr4_strbuf *) ctl; + syscallarg(struct svr4_strbuf *) dat; + syscallarg(int) flags; +}; + +struct svr4_sys_poll_args { + syscallarg(struct svr4_pollfd *) fds; + syscallarg(long) nfds; + syscallarg(int) timeout; +}; + +struct svr4_sys_lstat_args { + syscallarg(char *) path; + syscallarg(struct svr4_stat *) ub; +}; + +struct svr4_sys_sigprocmask_args { + syscallarg(int) how; + syscallarg(svr4_sigset_t *) set; + syscallarg(svr4_sigset_t *) oset; +}; + +struct svr4_sys_sigsuspend_args { + syscallarg(svr4_sigset_t *) ss; +}; + +struct svr4_sys_sigaltstack_args { + syscallarg(struct svr4_sigaltstack *) nss; + syscallarg(struct svr4_sigaltstack *) oss; +}; + +struct svr4_sys_sigaction_args { + syscallarg(int) signum; + syscallarg(struct svr4_sigaction *) nsa; + syscallarg(struct svr4_sigaction *) osa; +}; + +struct svr4_sys_sigpending_args { + syscallarg(int) what; + syscallarg(svr4_sigset_t *) mask; +}; + +struct svr4_sys_context_args { + syscallarg(int) func; + syscallarg(struct svr4_ucontext *) uc; +}; + +struct svr4_sys_statvfs_args { + syscallarg(char *) path; + syscallarg(struct svr4_statvfs *) fs; +}; + +struct svr4_sys_fstatvfs_args { + syscallarg(int) fd; + syscallarg(struct svr4_statvfs *) fs; +}; + +struct svr4_sys_waitsys_args { + syscallarg(int) grp; + syscallarg(int) id; + syscallarg(union svr4_siginfo *) info; + syscallarg(int) options; +}; + +struct svr4_sys_hrtsys_args { + syscallarg(int) cmd; + syscallarg(int) fun; + syscallarg(int) sub; + syscallarg(void *) rv1; + syscallarg(void *) rv2; +}; + +struct svr4_sys_mmap_args { + syscallarg(svr4_caddr_t) addr; + syscallarg(svr4_size_t) len; + syscallarg(int) prot; + syscallarg(int) flags; + syscallarg(int) fd; + syscallarg(svr4_off_t) pos; +}; + +struct svr4_sys_xstat_args { + syscallarg(int) two; + syscallarg(char *) path; + syscallarg(struct svr4_xstat *) ub; +}; + +struct svr4_sys_lxstat_args { + syscallarg(int) two; + syscallarg(char *) path; + syscallarg(struct svr4_xstat *) ub; +}; + +struct svr4_sys_fxstat_args { + syscallarg(int) two; + syscallarg(int) fd; + syscallarg(struct svr4_xstat *) sb; +}; + +struct svr4_sys_setrlimit_args { + syscallarg(int) which; + syscallarg(struct ogetrlimit *) rlp; +}; + +struct svr4_sys_getrlimit_args { + syscallarg(int) which; + syscallarg(struct ogetrlimit *) rlp; +}; + +struct svr4_sys_uname_args { + syscallarg(struct svr4_utsname *) name; + syscallarg(int) dummy; +}; + +struct svr4_sys_sysconfig_args { + syscallarg(int) name; +}; + +struct svr4_sys_systeminfo_args { + syscallarg(int) what; + syscallarg(char *) buf; + syscallarg(long) len; +}; + +struct svr4_sys_fchroot_args { + syscallarg(int) fd; +}; + +struct svr4_sys_gettimeofday_args { + syscallarg(struct timeval *) tp; +}; + +/* + * System call prototypes. + */ + +int sys_nosys __P((struct proc *, void *, register_t *)); +int sys_exit __P((struct proc *, void *, register_t *)); +int sys_fork __P((struct proc *, void *, register_t *)); +int sys_read __P((struct proc *, void *, register_t *)); +int sys_write __P((struct proc *, void *, register_t *)); +int svr4_sys_open __P((struct proc *, void *, register_t *)); +int sys_close __P((struct proc *, void *, register_t *)); +int svr4_sys_wait __P((struct proc *, void *, register_t *)); +int svr4_sys_creat __P((struct proc *, void *, register_t *)); +int sys_link __P((struct proc *, void *, register_t *)); +int sys_unlink __P((struct proc *, void *, register_t *)); +int svr4_sys_execv __P((struct proc *, void *, register_t *)); +int sys_chdir __P((struct proc *, void *, register_t *)); +int svr4_sys_time __P((struct proc *, void *, register_t *)); +int svr4_sys_mknod __P((struct proc *, void *, register_t *)); +int sys_chmod __P((struct proc *, void *, register_t *)); +int sys_chown __P((struct proc *, void *, register_t *)); +int svr4_sys_break __P((struct proc *, void *, register_t *)); +int svr4_sys_stat __P((struct proc *, void *, register_t *)); +int compat_43_sys_lseek __P((struct proc *, void *, register_t *)); +int sys_getpid __P((struct proc *, void *, register_t *)); +int sys_setuid __P((struct proc *, void *, register_t *)); +int sys_getuid __P((struct proc *, void *, register_t *)); +int svr4_sys_alarm __P((struct proc *, void *, register_t *)); +int svr4_sys_fstat __P((struct proc *, void *, register_t *)); +int svr4_sys_access __P((struct proc *, void *, register_t *)); +int sys_sync __P((struct proc *, void *, register_t *)); +int svr4_sys_kill __P((struct proc *, void *, register_t *)); +int svr4_sys_pgrpsys __P((struct proc *, void *, register_t *)); +int sys_dup __P((struct proc *, void *, register_t *)); +int sys_pipe __P((struct proc *, void *, register_t *)); +int svr4_sys_times __P((struct proc *, void *, register_t *)); +int sys_setgid __P((struct proc *, void *, register_t *)); +int sys_getgid __P((struct proc *, void *, register_t *)); +int svr4_sys_signal __P((struct proc *, void *, register_t *)); +#ifdef SYSVMSG +#else +#endif +int svr4_sys_sysarch __P((struct proc *, void *, register_t *)); +#ifdef SYSVSHM +#else +#endif +#ifdef SYSVSEM +#else +#endif +int svr4_sys_ioctl __P((struct proc *, void *, register_t *)); +int svr4_sys_utssys __P((struct proc *, void *, register_t *)); +int sys_fsync __P((struct proc *, void *, register_t *)); +int svr4_sys_execve __P((struct proc *, void *, register_t *)); +int sys_umask __P((struct proc *, void *, register_t *)); +int sys_chroot __P((struct proc *, void *, register_t *)); +int svr4_sys_fcntl __P((struct proc *, void *, register_t *)); +int svr4_sys_ulimit __P((struct proc *, void *, register_t *)); +int sys_rmdir __P((struct proc *, void *, register_t *)); +int sys_mkdir __P((struct proc *, void *, register_t *)); +int svr4_sys_getdents __P((struct proc *, void *, register_t *)); +int svr4_sys_getmsg __P((struct proc *, void *, register_t *)); +int svr4_sys_putmsg __P((struct proc *, void *, register_t *)); +int svr4_sys_poll __P((struct proc *, void *, register_t *)); +int svr4_sys_lstat __P((struct proc *, void *, register_t *)); +int sys_symlink __P((struct proc *, void *, register_t *)); +int sys_readlink __P((struct proc *, void *, register_t *)); +int sys_getgroups __P((struct proc *, void *, register_t *)); +int sys_setgroups __P((struct proc *, void *, register_t *)); +int sys_fchmod __P((struct proc *, void *, register_t *)); +int sys_fchown __P((struct proc *, void *, register_t *)); +int svr4_sys_sigprocmask __P((struct proc *, void *, register_t *)); +int svr4_sys_sigsuspend __P((struct proc *, void *, register_t *)); +int svr4_sys_sigaltstack __P((struct proc *, void *, register_t *)); +int svr4_sys_sigaction __P((struct proc *, void *, register_t *)); +int svr4_sys_sigpending __P((struct proc *, void *, register_t *)); +int svr4_sys_context __P((struct proc *, void *, register_t *)); +int svr4_sys_statvfs __P((struct proc *, void *, register_t *)); +int svr4_sys_fstatvfs __P((struct proc *, void *, register_t *)); +int svr4_sys_waitsys __P((struct proc *, void *, register_t *)); +int svr4_sys_hrtsys __P((struct proc *, void *, register_t *)); +int svr4_sys_mmap __P((struct proc *, void *, register_t *)); +int sys_mprotect __P((struct proc *, void *, register_t *)); +int sys_munmap __P((struct proc *, void *, register_t *)); +int sys_fpathconf __P((struct proc *, void *, register_t *)); +int sys_vfork __P((struct proc *, void *, register_t *)); +int sys_fchdir __P((struct proc *, void *, register_t *)); +int sys_readv __P((struct proc *, void *, register_t *)); +int sys_writev __P((struct proc *, void *, register_t *)); +int svr4_sys_xstat __P((struct proc *, void *, register_t *)); +int svr4_sys_lxstat __P((struct proc *, void *, register_t *)); +int svr4_sys_fxstat __P((struct proc *, void *, register_t *)); +int svr4_sys_setrlimit __P((struct proc *, void *, register_t *)); +int svr4_sys_getrlimit __P((struct proc *, void *, register_t *)); +int sys_rename __P((struct proc *, void *, register_t *)); +int svr4_sys_uname __P((struct proc *, void *, register_t *)); +int sys_setegid __P((struct proc *, void *, register_t *)); +int svr4_sys_sysconfig __P((struct proc *, void *, register_t *)); +int sys_adjtime __P((struct proc *, void *, register_t *)); +int svr4_sys_systeminfo __P((struct proc *, void *, register_t *)); +int sys_seteuid __P((struct proc *, void *, register_t *)); +int svr4_sys_fchroot __P((struct proc *, void *, register_t *)); +int svr4_sys_vhangup __P((struct proc *, void *, register_t *)); +int svr4_sys_gettimeofday __P((struct proc *, void *, register_t *)); +int sys_getitimer __P((struct proc *, void *, register_t *)); +int sys_setitimer __P((struct proc *, void *, register_t *)); diff --git a/sys/compat/svr4/svr4_syscalls.c b/sys/compat/svr4/svr4_syscalls.c new file mode 100644 index 00000000000..8019c68e7e8 --- /dev/null +++ b/sys/compat/svr4/svr4_syscalls.c @@ -0,0 +1,208 @@ +/* + * System call names. + * + * DO NOT EDIT-- this file is automatically generated. + * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp + */ + +char *svr4_syscallnames[] = { + "syscall", /* 0 = syscall */ + "exit", /* 1 = exit */ + "fork", /* 2 = fork */ + "read", /* 3 = read */ + "write", /* 4 = write */ + "open", /* 5 = open */ + "close", /* 6 = close */ + "wait", /* 7 = wait */ + "creat", /* 8 = creat */ + "link", /* 9 = link */ + "unlink", /* 10 = unlink */ + "execv", /* 11 = execv */ + "chdir", /* 12 = chdir */ + "time", /* 13 = time */ + "mknod", /* 14 = mknod */ + "chmod", /* 15 = chmod */ + "chown", /* 16 = chown */ + "break", /* 17 = break */ + "stat", /* 18 = stat */ + "lseek", /* 19 = lseek */ + "getpid", /* 20 = getpid */ + "#21 (unimplemented old_mount)", /* 21 = unimplemented old_mount */ + "#22 (unimplemented System V umount)", /* 22 = unimplemented System V umount */ + "setuid", /* 23 = setuid */ + "getuid", /* 24 = getuid */ + "#25 (unimplemented stime)", /* 25 = unimplemented stime */ + "#26 (unimplemented ptrace)", /* 26 = unimplemented ptrace */ + "alarm", /* 27 = alarm */ + "fstat", /* 28 = fstat */ + "#29 (unimplemented pause)", /* 29 = unimplemented pause */ + "#30 (unimplemented utime)", /* 30 = unimplemented utime */ + "#31 (unimplemented was stty)", /* 31 = unimplemented was stty */ + "#32 (unimplemented was gtty)", /* 32 = unimplemented was gtty */ + "access", /* 33 = access */ + "#34 (unimplemented nice)", /* 34 = unimplemented nice */ + "#35 (unimplemented statfs)", /* 35 = unimplemented statfs */ + "sync", /* 36 = sync */ + "kill", /* 37 = kill */ + "#38 (unimplemented fstatfs)", /* 38 = unimplemented fstatfs */ + "pgrpsys", /* 39 = pgrpsys */ + "#40 (unimplemented xenix)", /* 40 = unimplemented xenix */ + "dup", /* 41 = dup */ + "pipe", /* 42 = pipe */ + "times", /* 43 = times */ + "#44 (unimplemented profil)", /* 44 = unimplemented profil */ + "#45 (unimplemented plock)", /* 45 = unimplemented plock */ + "setgid", /* 46 = setgid */ + "getgid", /* 47 = getgid */ + "signal", /* 48 = signal */ +#ifdef SYSVMSG + "#49 (unimplemented { int sys_msgsys ( int which , int a2 , int a3 , int a4 , int a5 , int a6 ) ; })", /* 49 = unimplemented { int sys_msgsys ( int which , int a2 , int a3 , int a4 , int a5 , int a6 ) ; } */ +#else + "#49 (unimplemented msgsys)", /* 49 = unimplemented msgsys */ +#endif + "sysarch", /* 50 = sysarch */ + "#51 (unimplemented acct)", /* 51 = unimplemented acct */ +#ifdef SYSVSHM + "#52 (unimplemented { int sys_shmsys ( int which , int a2 , int a3 , int a4 ) ; })", /* 52 = unimplemented { int sys_shmsys ( int which , int a2 , int a3 , int a4 ) ; } */ +#else + "#52 (unimplemented shmsys)", /* 52 = unimplemented shmsys */ +#endif +#ifdef SYSVSEM + "#53 (unimplemented { int sys_semsys ( int which , int a2 , int a3 , int a4 , int a5 ) ; })", /* 53 = unimplemented { int sys_semsys ( int which , int a2 , int a3 , int a4 , int a5 ) ; } */ +#else + "#53 (unimplemented semsys)", /* 53 = unimplemented semsys */ +#endif + "ioctl", /* 54 = ioctl */ + "#55 (unimplemented uadmin)", /* 55 = unimplemented uadmin */ + "#56 (unimplemented exch)", /* 56 = unimplemented exch */ + "utssys", /* 57 = utssys */ + "fsync", /* 58 = fsync */ + "execve", /* 59 = execve */ + "umask", /* 60 = umask */ + "chroot", /* 61 = chroot */ + "fcntl", /* 62 = fcntl */ + "ulimit", /* 63 = ulimit */ + "#64 (unimplemented reserved for unix/pc)", /* 64 = unimplemented reserved for unix/pc */ + "#65 (unimplemented reserved for unix/pc)", /* 65 = unimplemented reserved for unix/pc */ + "#66 (unimplemented reserved for unix/pc)", /* 66 = unimplemented reserved for unix/pc */ + "#67 (unimplemented reserved for unix/pc)", /* 67 = unimplemented reserved for unix/pc */ + "#68 (unimplemented reserved for unix/pc)", /* 68 = unimplemented reserved for unix/pc */ + "#69 (unimplemented reserved for unix/pc)", /* 69 = unimplemented reserved for unix/pc */ + "#70 (obsolete advfs)", /* 70 = obsolete advfs */ + "#71 (obsolete unadvfs)", /* 71 = obsolete unadvfs */ + "#72 (obsolete rmount)", /* 72 = obsolete rmount */ + "#73 (obsolete rumount)", /* 73 = obsolete rumount */ + "#74 (obsolete rfstart)", /* 74 = obsolete rfstart */ + "#75 (obsolete sigret)", /* 75 = obsolete sigret */ + "#76 (obsolete rdebug)", /* 76 = obsolete rdebug */ + "#77 (obsolete rfstop)", /* 77 = obsolete rfstop */ + "#78 (unimplemented rfsys)", /* 78 = unimplemented rfsys */ + "rmdir", /* 79 = rmdir */ + "mkdir", /* 80 = mkdir */ + "getdents", /* 81 = getdents */ + "#82 (obsolete libattach)", /* 82 = obsolete libattach */ + "#83 (obsolete libdetach)", /* 83 = obsolete libdetach */ + "#84 (unimplemented sysfs)", /* 84 = unimplemented sysfs */ + "getmsg", /* 85 = getmsg */ + "putmsg", /* 86 = putmsg */ + "poll", /* 87 = poll */ + "lstat", /* 88 = lstat */ + "symlink", /* 89 = symlink */ + "readlink", /* 90 = readlink */ + "getgroups", /* 91 = getgroups */ + "setgroups", /* 92 = setgroups */ + "fchmod", /* 93 = fchmod */ + "fchown", /* 94 = fchown */ + "sigprocmask", /* 95 = sigprocmask */ + "sigsuspend", /* 96 = sigsuspend */ + "sigaltstack", /* 97 = sigaltstack */ + "sigaction", /* 98 = sigaction */ + "sigpending", /* 99 = sigpending */ + "context", /* 100 = context */ + "#101 (unimplemented evsys)", /* 101 = unimplemented evsys */ + "#102 (unimplemented evtrapret)", /* 102 = unimplemented evtrapret */ + "statvfs", /* 103 = statvfs */ + "fstatvfs", /* 104 = fstatvfs */ + "#105 (unimplemented)", /* 105 = unimplemented */ + "#106 (unimplemented nfssvc)", /* 106 = unimplemented nfssvc */ + "waitsys", /* 107 = waitsys */ + "#108 (unimplemented sigsendsys)", /* 108 = unimplemented sigsendsys */ + "hrtsys", /* 109 = hrtsys */ + "#110 (unimplemented acancel)", /* 110 = unimplemented acancel */ + "#111 (unimplemented async)", /* 111 = unimplemented async */ + "#112 (unimplemented priocntlsys)", /* 112 = unimplemented priocntlsys */ + "#113 (unimplemented pathconf)", /* 113 = unimplemented pathconf */ + "#114 (unimplemented mincore)", /* 114 = unimplemented mincore */ + "mmap", /* 115 = mmap */ + "mprotect", /* 116 = mprotect */ + "munmap", /* 117 = munmap */ + "fpathconf", /* 118 = fpathconf */ + "vfork", /* 119 = vfork */ + "fchdir", /* 120 = fchdir */ + "readv", /* 121 = readv */ + "writev", /* 122 = writev */ + "xstat", /* 123 = xstat */ + "lxstat", /* 124 = lxstat */ + "fxstat", /* 125 = fxstat */ + "#126 (unimplemented xmknod)", /* 126 = unimplemented xmknod */ + "#127 (unimplemented clocal)", /* 127 = unimplemented clocal */ + "setrlimit", /* 128 = setrlimit */ + "getrlimit", /* 129 = getrlimit */ + "#130 (unimplemented lchown)", /* 130 = unimplemented lchown */ + "#131 (unimplemented memcntl)", /* 131 = unimplemented memcntl */ + "#132 (unimplemented getpmsg)", /* 132 = unimplemented getpmsg */ + "#133 (unimplemented putpmsg)", /* 133 = unimplemented putpmsg */ + "rename", /* 134 = rename */ + "uname", /* 135 = uname */ + "setegid", /* 136 = setegid */ + "sysconfig", /* 137 = sysconfig */ + "adjtime", /* 138 = adjtime */ + "systeminfo", /* 139 = systeminfo */ + "#140 (unimplemented)", /* 140 = unimplemented */ + "seteuid", /* 141 = seteuid */ + "#142 (unimplemented vtrace)", /* 142 = unimplemented vtrace */ + "#143 (unimplemented fork1)", /* 143 = unimplemented fork1 */ + "#144 (unimplemented sigwait)", /* 144 = unimplemented sigwait */ + "#145 (unimplemented lwp_info)", /* 145 = unimplemented lwp_info */ + "#146 (unimplemented yield)", /* 146 = unimplemented yield */ + "#147 (unimplemented lwp_sema_p)", /* 147 = unimplemented lwp_sema_p */ + "#148 (unimplemented lwp_sema_v)", /* 148 = unimplemented lwp_sema_v */ + "#149 (unimplemented)", /* 149 = unimplemented */ + "#150 (unimplemented)", /* 150 = unimplemented */ + "#151 (unimplemented)", /* 151 = unimplemented */ + "#152 (unimplemented modctl)", /* 152 = unimplemented modctl */ + "fchroot", /* 153 = fchroot */ + "#154 (unimplemented utimes)", /* 154 = unimplemented utimes */ + "vhangup", /* 155 = vhangup */ + "gettimeofday", /* 156 = gettimeofday */ + "getitimer", /* 157 = getitimer */ + "setitimer", /* 158 = setitimer */ + "#159 (unimplemented lwp_create)", /* 159 = unimplemented lwp_create */ + "#160 (unimplemented lwp_exit)", /* 160 = unimplemented lwp_exit */ + "#161 (unimplemented lwp_suspend)", /* 161 = unimplemented lwp_suspend */ + "#162 (unimplemented lwp_continue)", /* 162 = unimplemented lwp_continue */ + "#163 (unimplemented lwp_kill)", /* 163 = unimplemented lwp_kill */ + "#164 (unimplemented lwp_self)", /* 164 = unimplemented lwp_self */ + "#165 (unimplemented lwp_getprivate)", /* 165 = unimplemented lwp_getprivate */ + "#166 (unimplemented lwp_setprivate)", /* 166 = unimplemented lwp_setprivate */ + "#167 (unimplemented lwp_wait)", /* 167 = unimplemented lwp_wait */ + "#168 (unimplemented lwp_mutex_unlock)", /* 168 = unimplemented lwp_mutex_unlock */ + "#169 (unimplemented lwp_mutex_lock)", /* 169 = unimplemented lwp_mutex_lock */ + "#170 (unimplemented lwp_cond_wait)", /* 170 = unimplemented lwp_cond_wait */ + "#171 (unimplemented lwp_cond_signal)", /* 171 = unimplemented lwp_cond_signal */ + "#172 (unimplemented lwp_cond_broadcast)", /* 172 = unimplemented lwp_cond_broadcast */ + "#173 (unimplemented pread)", /* 173 = unimplemented pread */ + "#174 (unimplemented pwrite)", /* 174 = unimplemented pwrite */ + "#175 (unimplemented llseek)", /* 175 = unimplemented llseek */ + "#176 (unimplemented inst_sync)", /* 176 = unimplemented inst_sync */ + "#177 (unimplemented)", /* 177 = unimplemented */ + "#178 (unimplemented)", /* 178 = unimplemented */ + "#179 (unimplemented)", /* 179 = unimplemented */ + "#180 (unimplemented)", /* 180 = unimplemented */ + "#181 (unimplemented)", /* 181 = unimplemented */ + "#182 (unimplemented)", /* 182 = unimplemented */ + "#183 (unimplemented)", /* 183 = unimplemented */ + "#184 (unimplemented)", /* 184 = unimplemented */ + "#185 (unimplemented)", /* 185 = unimplemented */ + "#186 (unimplemented auditsys)", /* 186 = unimplemented auditsys */ +}; diff --git a/sys/compat/svr4/svr4_sysconfig.h b/sys/compat/svr4/svr4_sysconfig.h new file mode 100644 index 00000000000..b487ac86414 --- /dev/null +++ b/sys/compat/svr4/svr4_sysconfig.h @@ -0,0 +1,61 @@ +/* $NetBSD: svr4_sysconfig.h,v 1.1 1995/07/02 06:16:10 christos Exp $ */ + +/* + * Copyright (c) 1995 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_SYSCONFIG_H_ +#define _SVR4_SYSCONFIG_H_ + +#define SVR4_CONFIG_UNUSED 0x01 +#define SVR4_CONFIG_NGROUPS 0x02 +#define SVR4_CONFIG_CHILD_MAX 0x03 +#define SVR4_CONFIG_OPEN_FILES 0x04 +#define SVR4_CONFIG_POSIX_VER 0x05 +#define SVR4_CONFIG_PAGESIZE 0x06 +#define SVR4_CONFIG_CLK_TCK 0x07 +#define SVR4_CONFIG_XOPEN_VER 0x08 +#define SVR4_CONFIG_UNUSED_9 0x09 +#define SVR4_CONFIG_PROF_TCK 0x0a +#define SVR4_CONFIG_NPROC_CONF 0x0b +#define SVR4_CONFIG_NPROC_ONLN 0x0c +#define SVR4_CONFIG_AIO_LISTIO_MAX 0x0e +#define SVR4_CONFIG_AIO_MAX 0x0f +#define SVR4_CONFIG_AIO_PRIO_DELTA_MAX 0x10 +#define SVR4_CONFIG_DELAYTIMER_MAX 0x11 +#define SVR4_CONFIG_MQ_OPEN_MAX 0x12 +#define SVR4_CONFIG_MQ_PRIO_MAX 0x13 +#define SVR4_CONFIG_RTSIG_MAX 0x14 +#define SVR4_CONFIG_SEM_NSEMS_MAX 0x15 +#define SVR4_CONFIG_SEM_VALUE_MAX 0x16 +#define SVR4_CONFIG_SIGQUEUE_MAX 0x17 +#define SVR4_CONFIG_SIGRT_MIN 0x18 +#define SVR4_CONFIG_SIGRT_MAX 0x19 +#define SVR4_CONFIG_TIMER_MAX 0x20 +#define SVR4_CONFIG_PHYS_PAGES 0x21 +#define SVR4_CONFIG_AVPHYS_PAGES 0x22 + +#endif /* !_SVR4_SYSCONFIG_H_ */ diff --git a/sys/compat/svr4/svr4_sysent.c b/sys/compat/svr4/svr4_sysent.c new file mode 100644 index 00000000000..0ebc6629df5 --- /dev/null +++ b/sys/compat/svr4/svr4_sysent.c @@ -0,0 +1,430 @@ +/* + * System call switch table. + * + * DO NOT EDIT-- this file is automatically generated. + * created from NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/signal.h> +#include <sys/mount.h> +#include <sys/syscallargs.h> +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_ucontext.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_statvfs.h> + +#ifdef COMPAT_43 +#define compat_43(func) __CONCAT(compat_43_,func) +#else +#define compat_43(func) sys_nosys +#endif + +#ifdef COMPAT_09 +#define compat_09(func) __CONCAT(compat_09_,func) +#else +#define compat_09(func) sys_nosys +#endif + +#ifdef COMPAT_10 +#define compat_10(func) __CONCAT(compat_10_,func) +#else +#define compat_10(func) sys_nosys +#endif + +#define s(type) sizeof(type) + +struct sysent svr4_sysent[] = { + { 0, 0, + sys_nosys }, /* 0 = syscall */ + { 1, s(struct sys_exit_args), + sys_exit }, /* 1 = exit */ + { 0, 0, + sys_fork }, /* 2 = fork */ + { 3, s(struct sys_read_args), + sys_read }, /* 3 = read */ + { 3, s(struct sys_write_args), + sys_write }, /* 4 = write */ + { 3, s(struct svr4_sys_open_args), + svr4_sys_open }, /* 5 = open */ + { 1, s(struct sys_close_args), + sys_close }, /* 6 = close */ + { 1, s(struct svr4_sys_wait_args), + svr4_sys_wait }, /* 7 = wait */ + { 2, s(struct svr4_sys_creat_args), + svr4_sys_creat }, /* 8 = creat */ + { 2, s(struct sys_link_args), + sys_link }, /* 9 = link */ + { 1, s(struct sys_unlink_args), + sys_unlink }, /* 10 = unlink */ + { 2, s(struct svr4_sys_execv_args), + svr4_sys_execv }, /* 11 = execv */ + { 1, s(struct sys_chdir_args), + sys_chdir }, /* 12 = chdir */ + { 1, s(struct svr4_sys_time_args), + svr4_sys_time }, /* 13 = time */ + { 3, s(struct svr4_sys_mknod_args), + svr4_sys_mknod }, /* 14 = mknod */ + { 2, s(struct sys_chmod_args), + sys_chmod }, /* 15 = chmod */ + { 3, s(struct sys_chown_args), + sys_chown }, /* 16 = chown */ + { 1, s(struct svr4_sys_break_args), + svr4_sys_break }, /* 17 = break */ + { 2, s(struct svr4_sys_stat_args), + svr4_sys_stat }, /* 18 = stat */ + { 3, s(struct compat_43_sys_lseek_args), + compat_43_sys_lseek }, /* 19 = lseek */ + { 0, 0, + sys_getpid }, /* 20 = getpid */ + { 0, 0, + sys_nosys }, /* 21 = unimplemented old_mount */ + { 0, 0, + sys_nosys }, /* 22 = unimplemented System V umount */ + { 1, s(struct sys_setuid_args), + sys_setuid }, /* 23 = setuid */ + { 0, 0, + sys_getuid }, /* 24 = getuid */ + { 0, 0, + sys_nosys }, /* 25 = unimplemented stime */ + { 0, 0, + sys_nosys }, /* 26 = unimplemented ptrace */ + { 1, s(struct svr4_sys_alarm_args), + svr4_sys_alarm }, /* 27 = alarm */ + { 2, s(struct svr4_sys_fstat_args), + svr4_sys_fstat }, /* 28 = fstat */ + { 0, 0, + sys_nosys }, /* 29 = unimplemented pause */ + { 0, 0, + sys_nosys }, /* 30 = unimplemented utime */ + { 0, 0, + sys_nosys }, /* 31 = unimplemented was stty */ + { 0, 0, + sys_nosys }, /* 32 = unimplemented was gtty */ + { 2, s(struct svr4_sys_access_args), + svr4_sys_access }, /* 33 = access */ + { 0, 0, + sys_nosys }, /* 34 = unimplemented nice */ + { 0, 0, + sys_nosys }, /* 35 = unimplemented statfs */ + { 0, 0, + sys_sync }, /* 36 = sync */ + { 2, s(struct svr4_sys_kill_args), + svr4_sys_kill }, /* 37 = kill */ + { 0, 0, + sys_nosys }, /* 38 = unimplemented fstatfs */ + { 3, s(struct svr4_sys_pgrpsys_args), + svr4_sys_pgrpsys }, /* 39 = pgrpsys */ + { 0, 0, + sys_nosys }, /* 40 = unimplemented xenix */ + { 1, s(struct sys_dup_args), + sys_dup }, /* 41 = dup */ + { 0, 0, + sys_pipe }, /* 42 = pipe */ + { 1, s(struct svr4_sys_times_args), + svr4_sys_times }, /* 43 = times */ + { 0, 0, + sys_nosys }, /* 44 = unimplemented profil */ + { 0, 0, + sys_nosys }, /* 45 = unimplemented plock */ + { 1, s(struct sys_setgid_args), + sys_setgid }, /* 46 = setgid */ + { 0, 0, + sys_getgid }, /* 47 = getgid */ + { 2, s(struct svr4_sys_signal_args), + svr4_sys_signal }, /* 48 = signal */ +#ifdef SYSVMSG + { 0, 0, + sys_nosys }, /* 49 = unimplemented { int sys_msgsys ( int which , int a2 , int a3 , int a4 , int a5 , int a6 ) ; } */ +#else + { 0, 0, + sys_nosys }, /* 49 = unimplemented msgsys */ +#endif + { 2, s(struct svr4_sys_sysarch_args), + svr4_sys_sysarch }, /* 50 = sysarch */ + { 0, 0, + sys_nosys }, /* 51 = unimplemented acct */ +#ifdef SYSVSHM + { 0, 0, + sys_nosys }, /* 52 = unimplemented { int sys_shmsys ( int which , int a2 , int a3 , int a4 ) ; } */ +#else + { 0, 0, + sys_nosys }, /* 52 = unimplemented shmsys */ +#endif +#ifdef SYSVSEM + { 0, 0, + sys_nosys }, /* 53 = unimplemented { int sys_semsys ( int which , int a2 , int a3 , int a4 , int a5 ) ; } */ +#else + { 0, 0, + sys_nosys }, /* 53 = unimplemented semsys */ +#endif + { 3, s(struct svr4_sys_ioctl_args), + svr4_sys_ioctl }, /* 54 = ioctl */ + { 0, 0, + sys_nosys }, /* 55 = unimplemented uadmin */ + { 0, 0, + sys_nosys }, /* 56 = unimplemented exch */ + { 4, s(struct svr4_sys_utssys_args), + svr4_sys_utssys }, /* 57 = utssys */ + { 1, s(struct sys_fsync_args), + sys_fsync }, /* 58 = fsync */ + { 3, s(struct svr4_sys_execve_args), + svr4_sys_execve }, /* 59 = execve */ + { 1, s(struct sys_umask_args), + sys_umask }, /* 60 = umask */ + { 1, s(struct sys_chroot_args), + sys_chroot }, /* 61 = chroot */ + { 3, s(struct svr4_sys_fcntl_args), + svr4_sys_fcntl }, /* 62 = fcntl */ + { 2, s(struct svr4_sys_ulimit_args), + svr4_sys_ulimit }, /* 63 = ulimit */ + { 0, 0, + sys_nosys }, /* 64 = unimplemented reserved for unix/pc */ + { 0, 0, + sys_nosys }, /* 65 = unimplemented reserved for unix/pc */ + { 0, 0, + sys_nosys }, /* 66 = unimplemented reserved for unix/pc */ + { 0, 0, + sys_nosys }, /* 67 = unimplemented reserved for unix/pc */ + { 0, 0, + sys_nosys }, /* 68 = unimplemented reserved for unix/pc */ + { 0, 0, + sys_nosys }, /* 69 = unimplemented reserved for unix/pc */ + { 0, 0, + sys_nosys }, /* 70 = obsolete advfs */ + { 0, 0, + sys_nosys }, /* 71 = obsolete unadvfs */ + { 0, 0, + sys_nosys }, /* 72 = obsolete rmount */ + { 0, 0, + sys_nosys }, /* 73 = obsolete rumount */ + { 0, 0, + sys_nosys }, /* 74 = obsolete rfstart */ + { 0, 0, + sys_nosys }, /* 75 = obsolete sigret */ + { 0, 0, + sys_nosys }, /* 76 = obsolete rdebug */ + { 0, 0, + sys_nosys }, /* 77 = obsolete rfstop */ + { 0, 0, + sys_nosys }, /* 78 = unimplemented rfsys */ + { 1, s(struct sys_rmdir_args), + sys_rmdir }, /* 79 = rmdir */ + { 2, s(struct sys_mkdir_args), + sys_mkdir }, /* 80 = mkdir */ + { 3, s(struct svr4_sys_getdents_args), + svr4_sys_getdents }, /* 81 = getdents */ + { 0, 0, + sys_nosys }, /* 82 = obsolete libattach */ + { 0, 0, + sys_nosys }, /* 83 = obsolete libdetach */ + { 0, 0, + sys_nosys }, /* 84 = unimplemented sysfs */ + { 4, s(struct svr4_sys_getmsg_args), + svr4_sys_getmsg }, /* 85 = getmsg */ + { 4, s(struct svr4_sys_putmsg_args), + svr4_sys_putmsg }, /* 86 = putmsg */ + { 3, s(struct svr4_sys_poll_args), + svr4_sys_poll }, /* 87 = poll */ + { 2, s(struct svr4_sys_lstat_args), + svr4_sys_lstat }, /* 88 = lstat */ + { 2, s(struct sys_symlink_args), + sys_symlink }, /* 89 = symlink */ + { 3, s(struct sys_readlink_args), + sys_readlink }, /* 90 = readlink */ + { 2, s(struct sys_getgroups_args), + sys_getgroups }, /* 91 = getgroups */ + { 2, s(struct sys_setgroups_args), + sys_setgroups }, /* 92 = setgroups */ + { 2, s(struct sys_fchmod_args), + sys_fchmod }, /* 93 = fchmod */ + { 3, s(struct sys_fchown_args), + sys_fchown }, /* 94 = fchown */ + { 3, s(struct svr4_sys_sigprocmask_args), + svr4_sys_sigprocmask }, /* 95 = sigprocmask */ + { 1, s(struct svr4_sys_sigsuspend_args), + svr4_sys_sigsuspend }, /* 96 = sigsuspend */ + { 2, s(struct svr4_sys_sigaltstack_args), + svr4_sys_sigaltstack }, /* 97 = sigaltstack */ + { 3, s(struct svr4_sys_sigaction_args), + svr4_sys_sigaction }, /* 98 = sigaction */ + { 2, s(struct svr4_sys_sigpending_args), + svr4_sys_sigpending }, /* 99 = sigpending */ + { 2, s(struct svr4_sys_context_args), + svr4_sys_context }, /* 100 = context */ + { 0, 0, + sys_nosys }, /* 101 = unimplemented evsys */ + { 0, 0, + sys_nosys }, /* 102 = unimplemented evtrapret */ + { 2, s(struct svr4_sys_statvfs_args), + svr4_sys_statvfs }, /* 103 = statvfs */ + { 2, s(struct svr4_sys_fstatvfs_args), + svr4_sys_fstatvfs }, /* 104 = fstatvfs */ + { 0, 0, + sys_nosys }, /* 105 = unimplemented */ + { 0, 0, + sys_nosys }, /* 106 = unimplemented nfssvc */ + { 4, s(struct svr4_sys_waitsys_args), + svr4_sys_waitsys }, /* 107 = waitsys */ + { 0, 0, + sys_nosys }, /* 108 = unimplemented sigsendsys */ + { 5, s(struct svr4_sys_hrtsys_args), + svr4_sys_hrtsys }, /* 109 = hrtsys */ + { 0, 0, + sys_nosys }, /* 110 = unimplemented acancel */ + { 0, 0, + sys_nosys }, /* 111 = unimplemented async */ + { 0, 0, + sys_nosys }, /* 112 = unimplemented priocntlsys */ + { 0, 0, + sys_nosys }, /* 113 = unimplemented pathconf */ + { 0, 0, + sys_nosys }, /* 114 = unimplemented mincore */ + { 6, s(struct svr4_sys_mmap_args), + svr4_sys_mmap }, /* 115 = mmap */ + { 3, s(struct sys_mprotect_args), + sys_mprotect }, /* 116 = mprotect */ + { 2, s(struct sys_munmap_args), + sys_munmap }, /* 117 = munmap */ + { 2, s(struct sys_fpathconf_args), + sys_fpathconf }, /* 118 = fpathconf */ + { 0, 0, + sys_vfork }, /* 119 = vfork */ + { 1, s(struct sys_fchdir_args), + sys_fchdir }, /* 120 = fchdir */ + { 3, s(struct sys_readv_args), + sys_readv }, /* 121 = readv */ + { 3, s(struct sys_writev_args), + sys_writev }, /* 122 = writev */ + { 3, s(struct svr4_sys_xstat_args), + svr4_sys_xstat }, /* 123 = xstat */ + { 3, s(struct svr4_sys_lxstat_args), + svr4_sys_lxstat }, /* 124 = lxstat */ + { 3, s(struct svr4_sys_fxstat_args), + svr4_sys_fxstat }, /* 125 = fxstat */ + { 0, 0, + sys_nosys }, /* 126 = unimplemented xmknod */ + { 0, 0, + sys_nosys }, /* 127 = unimplemented clocal */ + { 2, s(struct svr4_sys_setrlimit_args), + svr4_sys_setrlimit }, /* 128 = setrlimit */ + { 2, s(struct svr4_sys_getrlimit_args), + svr4_sys_getrlimit }, /* 129 = getrlimit */ + { 0, 0, + sys_nosys }, /* 130 = unimplemented lchown */ + { 0, 0, + sys_nosys }, /* 131 = unimplemented memcntl */ + { 0, 0, + sys_nosys }, /* 132 = unimplemented getpmsg */ + { 0, 0, + sys_nosys }, /* 133 = unimplemented putpmsg */ + { 2, s(struct sys_rename_args), + sys_rename }, /* 134 = rename */ + { 2, s(struct svr4_sys_uname_args), + svr4_sys_uname }, /* 135 = uname */ + { 1, s(struct sys_setegid_args), + sys_setegid }, /* 136 = setegid */ + { 1, s(struct svr4_sys_sysconfig_args), + svr4_sys_sysconfig }, /* 137 = sysconfig */ + { 2, s(struct sys_adjtime_args), + sys_adjtime }, /* 138 = adjtime */ + { 3, s(struct svr4_sys_systeminfo_args), + svr4_sys_systeminfo }, /* 139 = systeminfo */ + { 0, 0, + sys_nosys }, /* 140 = unimplemented */ + { 1, s(struct sys_seteuid_args), + sys_seteuid }, /* 141 = seteuid */ + { 0, 0, + sys_nosys }, /* 142 = unimplemented vtrace */ + { 0, 0, + sys_nosys }, /* 143 = unimplemented fork1 */ + { 0, 0, + sys_nosys }, /* 144 = unimplemented sigwait */ + { 0, 0, + sys_nosys }, /* 145 = unimplemented lwp_info */ + { 0, 0, + sys_nosys }, /* 146 = unimplemented yield */ + { 0, 0, + sys_nosys }, /* 147 = unimplemented lwp_sema_p */ + { 0, 0, + sys_nosys }, /* 148 = unimplemented lwp_sema_v */ + { 0, 0, + sys_nosys }, /* 149 = unimplemented */ + { 0, 0, + sys_nosys }, /* 150 = unimplemented */ + { 0, 0, + sys_nosys }, /* 151 = unimplemented */ + { 0, 0, + sys_nosys }, /* 152 = unimplemented modctl */ + { 1, s(struct svr4_sys_fchroot_args), + svr4_sys_fchroot }, /* 153 = fchroot */ + { 0, 0, + sys_nosys }, /* 154 = unimplemented utimes */ + { 0, 0, + svr4_sys_vhangup }, /* 155 = vhangup */ + { 1, s(struct svr4_sys_gettimeofday_args), + svr4_sys_gettimeofday }, /* 156 = gettimeofday */ + { 2, s(struct sys_getitimer_args), + sys_getitimer }, /* 157 = getitimer */ + { 3, s(struct sys_setitimer_args), + sys_setitimer }, /* 158 = setitimer */ + { 0, 0, + sys_nosys }, /* 159 = unimplemented lwp_create */ + { 0, 0, + sys_nosys }, /* 160 = unimplemented lwp_exit */ + { 0, 0, + sys_nosys }, /* 161 = unimplemented lwp_suspend */ + { 0, 0, + sys_nosys }, /* 162 = unimplemented lwp_continue */ + { 0, 0, + sys_nosys }, /* 163 = unimplemented lwp_kill */ + { 0, 0, + sys_nosys }, /* 164 = unimplemented lwp_self */ + { 0, 0, + sys_nosys }, /* 165 = unimplemented lwp_getprivate */ + { 0, 0, + sys_nosys }, /* 166 = unimplemented lwp_setprivate */ + { 0, 0, + sys_nosys }, /* 167 = unimplemented lwp_wait */ + { 0, 0, + sys_nosys }, /* 168 = unimplemented lwp_mutex_unlock */ + { 0, 0, + sys_nosys }, /* 169 = unimplemented lwp_mutex_lock */ + { 0, 0, + sys_nosys }, /* 170 = unimplemented lwp_cond_wait */ + { 0, 0, + sys_nosys }, /* 171 = unimplemented lwp_cond_signal */ + { 0, 0, + sys_nosys }, /* 172 = unimplemented lwp_cond_broadcast */ + { 0, 0, + sys_nosys }, /* 173 = unimplemented pread */ + { 0, 0, + sys_nosys }, /* 174 = unimplemented pwrite */ + { 0, 0, + sys_nosys }, /* 175 = unimplemented llseek */ + { 0, 0, + sys_nosys }, /* 176 = unimplemented inst_sync */ + { 0, 0, + sys_nosys }, /* 177 = unimplemented */ + { 0, 0, + sys_nosys }, /* 178 = unimplemented */ + { 0, 0, + sys_nosys }, /* 179 = unimplemented */ + { 0, 0, + sys_nosys }, /* 180 = unimplemented */ + { 0, 0, + sys_nosys }, /* 181 = unimplemented */ + { 0, 0, + sys_nosys }, /* 182 = unimplemented */ + { 0, 0, + sys_nosys }, /* 183 = unimplemented */ + { 0, 0, + sys_nosys }, /* 184 = unimplemented */ + { 0, 0, + sys_nosys }, /* 185 = unimplemented */ + { 0, 0, + sys_nosys }, /* 186 = unimplemented auditsys */ +}; + diff --git a/sys/compat/svr4/svr4_systeminfo.h b/sys/compat/svr4/svr4_systeminfo.h new file mode 100644 index 00000000000..aa51734f92a --- /dev/null +++ b/sys/compat/svr4/svr4_systeminfo.h @@ -0,0 +1,45 @@ +/* $NetBSD: svr4_systeminfo.h,v 1.2 1994/11/18 02:54:18 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_SYSTEMINFO_H_ +#define _SVR4_SYSTEMINFO_H_ + +#define SVR4_SI_SYSNAME 1 +#define SVR4_SI_HOSTNAME 2 +#define SVR4_SI_RELEASE 3 +#define SVR4_SI_VERSION 4 +#define SVR4_SI_MACHINE 5 +#define SVR4_SI_ARCHITECTURE 6 +#define SVR4_SI_HW_SERIAL 7 +#define SVR4_SI_HW_PROVIDER 8 +#define SVR4_SI_SRPC_DOMAIN 9 +#define SVR4_SI_SET_HOSTNAME 258 +#define SVR4_SI_SET_SRPC_DOMAIN 265 + +#endif /* !_SVR4_SYSTEMINFO_H_ */ diff --git a/sys/compat/svr4/svr4_termios.c b/sys/compat/svr4/svr4_termios.c new file mode 100644 index 00000000000..984c7b514a1 --- /dev/null +++ b/sys/compat/svr4/svr4_termios.c @@ -0,0 +1,547 @@ +/* $NetBSD: svr4_termios.c,v 1.5 1995/10/07 06:27:55 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/proc.h> +#include <sys/systm.h> +#include <sys/file.h> +#include <sys/filedesc.h> +#include <sys/ioctl.h> +#include <sys/termios.h> +#include <sys/tty.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <sys/mount.h> +#include <net/if.h> +#include <sys/malloc.h> + +#include <sys/syscallargs.h> + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_stropts.h> +#include <compat/svr4/svr4_termios.h> + + +#ifndef __CONCAT3 +# if __STDC__ +# define __CONCAT3(a,b,c) a ## b ## c +# else +# define __CONCAT3(a,b,c) a/**/b/**/c +# endif +#endif + +static u_long bsd_to_svr4_speed __P((u_long sp, u_long mask)); +static u_long svr4_to_bsd_speed __P((u_long sp, u_long mask)); +static void svr4_to_bsd_termios __P((const struct svr4_termios *st, + struct termios *bt)); +static void bsd_to_svr4_termios __P((const struct termios *bt, + struct svr4_termios *st)); +static void svr4_termio_to_termios __P((const struct svr4_termio *t, + struct svr4_termios *ts)); +static void svr4_termios_to_termio __P((const struct svr4_termios *ts, + struct svr4_termio *t)); + +#define undefined_char(a,b) /**/ +#define undefined_flag1(f,a,b) /**/ +#define undefined_flag2(f,a,b,c1,t1,c2,t2) /**/ +#define undefined_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) /**/ + +#define svr4_to_bsd_char(a,b) \ + if (st->c_cc[__CONCAT(a,b)] == SVR4_POSIX_VDISABLE) \ + bt->c_cc[__CONCAT(a,b)] = _POSIX_VDISABLE; \ + else \ + bt->c_cc[__CONCAT(a,b)] = st->c_cc[__CONCAT3(SVR4_,a,b)] + +#define svr4_to_bsd_flag1(f,a,b) \ + if (st->f & __CONCAT3(SVR4_,a,b)) \ + bt->f |= __CONCAT(a,b); \ + else \ + bt->f &= ~__CONCAT(a,b) + +#define svr4_to_bsd_flag2(f,a,b,c1,t1,c2,t2) \ + bt->f &= ~__CONCAT(a,b); \ + switch (st->f & __CONCAT3(SVR4_,a,b)) { \ + case __CONCAT3(SVR4_,c1,t1): bt->f |= __CONCAT(c1,t1); break; \ + case __CONCAT3(SVR4_,c2,t2): bt->f |= __CONCAT(c2,t2); break; \ + } + +#define svr4_to_bsd_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) \ + bt->f &= ~__CONCAT(a,b); \ + switch (st->f & __CONCAT3(SVR4_,a,b)) { \ + case __CONCAT3(SVR4_,c1,t1): bt->f |= __CONCAT(c1,t1); break; \ + case __CONCAT3(SVR4_,c2,t2): bt->f |= __CONCAT(c2,t2); break; \ + case __CONCAT3(SVR4_,c3,t3): bt->f |= __CONCAT(c3,t3); break; \ + case __CONCAT3(SVR4_,c4,t4): bt->f |= __CONCAT(c4,t4); break; \ + } + + +#define bsd_to_svr4_char(a,b) \ + if (bt->c_cc[__CONCAT(a,b)] == _POSIX_VDISABLE) \ + st->c_cc[__CONCAT3(SVR4_,a,b)] = SVR4_POSIX_VDISABLE; \ + else \ + st->c_cc[__CONCAT3(SVR4_,a,b)] = bt->c_cc[__CONCAT(a,b)] + +#define bsd_to_svr4_flag1(f,a,b) \ + if (bt->f & __CONCAT(a,b)) \ + st->f |= __CONCAT3(SVR4_,a,b); \ + else \ + st->f &= ~__CONCAT3(SVR4_,a,b) + +#define bsd_to_svr4_flag2(f,a,b,c1,t1,c2,t2) \ + st->f &= ~__CONCAT(a,b); \ + switch (bt->f & __CONCAT(a,b)) { \ + case __CONCAT(c1,t1): st->f |= __CONCAT3(SVR4_,c1,t1); break; \ + case __CONCAT(c2,t2): st->f |= __CONCAT3(SVR4_,c2,t2); break; \ + } + +#define bsd_to_svr4_flag4(f,a,b,c1,t1,c2,t2,c3,t3,c4,t4) \ + st->f &= ~__CONCAT(a,b); \ + switch (bt->f & __CONCAT(a,b)) { \ + case __CONCAT(c1,t1): st->f |= __CONCAT3(SVR4_,c1,t1); break; \ + case __CONCAT(c2,t2): st->f |= __CONCAT3(SVR4_,c2,t2); break; \ + case __CONCAT(c3,t3): st->f |= __CONCAT3(SVR4_,c3,t3); break; \ + case __CONCAT(c4,t4): st->f |= __CONCAT3(SVR4_,c4,t4); break; \ + } + +static u_long +bsd_to_svr4_speed(sp, mask) + u_long sp; + u_long mask; +{ + switch (sp) { +#undef getval +#define getval(a,b) case __CONCAT(a,b): sp = __CONCAT3(SVR4_,a,b) + getval(B,0); + getval(B,50); + getval(B,75); + getval(B,110); + getval(B,134); + getval(B,150); + getval(B,200); + getval(B,300); + getval(B,600); + getval(B,1200); + getval(B,1800); + getval(B,2400); + getval(B,4800); + getval(B,9600); + getval(B,19200); + getval(B,38400); + default: sp = SVR4_B9600; /* XXX */ + } + + while ((mask & 1) == 0) { + mask >>= 1; + sp <<= 1; + } + + return sp; +} + + +static u_long +svr4_to_bsd_speed(sp, mask) + u_long sp; + u_long mask; +{ + while ((mask & 1) == 0) { + mask >>= 1; + sp >>= 1; + } + + switch (sp & mask) { +#undef getval +#define getval(a,b) case __CONCAT3(SVR4_,a,b): return __CONCAT(a,b) + getval(B,0); + getval(B,50); + getval(B,75); + getval(B,110); + getval(B,134); + getval(B,150); + getval(B,200); + getval(B,300); + getval(B,600); + getval(B,1200); + getval(B,1800); + getval(B,2400); + getval(B,4800); + getval(B,9600); + getval(B,19200); + getval(B,38400); + default: return B9600; /* XXX */ + } +} + + +static void +svr4_to_bsd_termios(st, bt) + const struct svr4_termios *st; + struct termios *bt; +{ + /* control characters */ + svr4_to_bsd_char(V,INTR); + svr4_to_bsd_char(V,QUIT); + svr4_to_bsd_char(V,ERASE); + svr4_to_bsd_char(V,KILL); + svr4_to_bsd_char(V,EOF); + svr4_to_bsd_char(V,EOL); + svr4_to_bsd_char(V,EOL2); + svr4_to_bsd_char(V,MIN); + svr4_to_bsd_char(V,TIME); + undefined_char(V,SWTCH); + svr4_to_bsd_char(V,START); + svr4_to_bsd_char(V,STOP); + svr4_to_bsd_char(V,SUSP); + svr4_to_bsd_char(V,DSUSP); + svr4_to_bsd_char(V,REPRINT); + svr4_to_bsd_char(V,DISCARD); + svr4_to_bsd_char(V,WERASE); + svr4_to_bsd_char(V,LNEXT); + + /* Input modes */ + svr4_to_bsd_flag1(c_iflag,I,GNBRK); + svr4_to_bsd_flag1(c_iflag,B,RKINT); + svr4_to_bsd_flag1(c_iflag,I,GNPAR); + svr4_to_bsd_flag1(c_iflag,P,ARMRK); + svr4_to_bsd_flag1(c_iflag,I,NPCK); + svr4_to_bsd_flag1(c_iflag,I,STRIP); + svr4_to_bsd_flag1(c_iflag,I,NLCR); + svr4_to_bsd_flag1(c_iflag,I,GNCR); + svr4_to_bsd_flag1(c_iflag,I,CRNL); + undefined_flag1(c_iflag,I,UCLC); + svr4_to_bsd_flag1(c_iflag,I,XON); + svr4_to_bsd_flag1(c_iflag,I,XANY); + svr4_to_bsd_flag1(c_iflag,I,XOFF); + svr4_to_bsd_flag1(c_iflag,I,MAXBEL); + undefined_flag1(c_iflag,D,OSMODE); + + /* Output modes */ + svr4_to_bsd_flag1(c_oflag,O,POST); + undefined_flag1(c_oflag,O,LCUC); + svr4_to_bsd_flag1(c_oflag,O,NLCR); + undefined_flag1(c_oflag,O,CRNL); + undefined_flag1(c_oflag,O,NOCR); + undefined_flag1(c_oflag,O,NLRET); + undefined_flag1(c_oflag,O,FILL); + undefined_flag1(c_oflag,O,FDEL); + undefined_flag2(c_oflag,N,LDLY,N,L0,N,L1); + undefined_flag4(c_oflag,C,RDLY,C,R0,C,R1,C,R2,C,R3); + undefined_flag4(c_oflag,T,ABDLY,T,AB0,T,AB1,T,AB2,T,AB3); + undefined_flag2(c_oflag,B,SDLY,B,S0,B,S1); + undefined_flag2(c_oflag,V,TDLY,V,T0,V,T1); + undefined_flag2(c_oflag,F,FDLY,F,F0,F,F1); + undefined_flag1(c_oflag,P,AGEOUT); + undefined_flag1(c_oflag,W,RAP); + + /* Control modes */ + bt->c_ospeed = svr4_to_bsd_speed(st->c_cflag, SVR4_CBAUD); + svr4_to_bsd_flag4(c_cflag,C,SIZE,C,S5,C,S6,C,S7,C,S8) + svr4_to_bsd_flag1(c_cflag,C,STOPB); + svr4_to_bsd_flag1(c_cflag,C,READ); + svr4_to_bsd_flag1(c_cflag,P,ARENB); + svr4_to_bsd_flag1(c_cflag,P,ARODD); + svr4_to_bsd_flag1(c_cflag,H,UPCL); + svr4_to_bsd_flag1(c_cflag,C,LOCAL); + undefined_flag1(c_cflag,R,CV1EN); + undefined_flag1(c_cflag,X,MT1EN); + undefined_flag1(c_cflag,L,OBLK); + undefined_flag1(c_cflag,X,CLUDE); + bt->c_ispeed = svr4_to_bsd_speed(st->c_cflag, SVR4_CIBAUD); + undefined_flag1(c_cflag,P,AREXT); + + /* line discipline modes */ + svr4_to_bsd_flag1(c_lflag,I,SIG); + svr4_to_bsd_flag1(c_lflag,I,CANON); + undefined_flag1(c_lflag,X,CASE); + svr4_to_bsd_flag1(c_lflag,E,CHO); + svr4_to_bsd_flag1(c_lflag,E,CHOE); + svr4_to_bsd_flag1(c_lflag,E,CHOK); + svr4_to_bsd_flag1(c_lflag,E,CHONL); + svr4_to_bsd_flag1(c_lflag,N,OFLSH); + svr4_to_bsd_flag1(c_lflag,T,OSTOP); + svr4_to_bsd_flag1(c_lflag,E,CHOCTL); + svr4_to_bsd_flag1(c_lflag,E,CHOPRT); + svr4_to_bsd_flag1(c_lflag,E,CHOKE); + undefined_flag1(c_lflag,D,EFECHO); + svr4_to_bsd_flag1(c_lflag,F,LUSHO); + svr4_to_bsd_flag1(c_lflag,P,ENDIN); + svr4_to_bsd_flag1(c_lflag,I,EXTEN); +} + + +static void +bsd_to_svr4_termios(bt, st) + const struct termios *bt; + struct svr4_termios *st; +{ + /* control characters */ + bsd_to_svr4_char(V,INTR); + bsd_to_svr4_char(V,QUIT); + bsd_to_svr4_char(V,ERASE); + bsd_to_svr4_char(V,KILL); + bsd_to_svr4_char(V,EOF); + bsd_to_svr4_char(V,EOL); + bsd_to_svr4_char(V,EOL2); + bsd_to_svr4_char(V,MIN); + bsd_to_svr4_char(V,TIME); + undefined_char(V,SWTCH); + bsd_to_svr4_char(V,START); + bsd_to_svr4_char(V,STOP); + bsd_to_svr4_char(V,SUSP); + bsd_to_svr4_char(V,DSUSP); + bsd_to_svr4_char(V,REPRINT); + bsd_to_svr4_char(V,DISCARD); + bsd_to_svr4_char(V,WERASE); + bsd_to_svr4_char(V,LNEXT); + + /* Input modes */ + bsd_to_svr4_flag1(c_iflag,I,GNBRK); + bsd_to_svr4_flag1(c_iflag,B,RKINT); + bsd_to_svr4_flag1(c_iflag,I,GNPAR); + bsd_to_svr4_flag1(c_iflag,P,ARMRK); + bsd_to_svr4_flag1(c_iflag,I,NPCK); + bsd_to_svr4_flag1(c_iflag,I,STRIP); + bsd_to_svr4_flag1(c_iflag,I,NLCR); + bsd_to_svr4_flag1(c_iflag,I,GNCR); + bsd_to_svr4_flag1(c_iflag,I,CRNL); + undefined_flag1(c_iflag,I,UCLC); + bsd_to_svr4_flag1(c_iflag,I,XON); + bsd_to_svr4_flag1(c_iflag,I,XANY); + bsd_to_svr4_flag1(c_iflag,I,XOFF); + bsd_to_svr4_flag1(c_iflag,I,MAXBEL); + undefined_flag1(c_iflag,D,OSMODE); + + /* Output modes */ + bsd_to_svr4_flag1(c_oflag,O,POST); + undefined_flag1(c_oflag,O,LCUC); + undefined_flag1(c_oflag,O,NLCR); + undefined_flag1(c_oflag,O,CRNL); + undefined_flag1(c_oflag,O,NOCR); + undefined_flag1(c_oflag,O,NLRET); + undefined_flag1(c_oflag,O,FILL); + undefined_flag1(c_oflag,O,FDEL); + undefined_flag2(c_oflag,N,LDLY,N,L0,N,L1); + undefined_flag4(c_oflag,C,RDLY,C,R0,C,R1,C,R2,C,R3); + undefined_flag4(c_oflag,T,ABDLY,T,AB0,T,AB1,T,AB2,T,AB3); + undefined_flag2(c_oflag,B,SDLY,B,S0,B,S1); + undefined_flag2(c_oflag,V,TDLY,V,T0,V,T1); + undefined_flag2(c_oflag,F,FDLY,F,F0,F,F1); + undefined_flag1(c_oflag,P,AGEOUT); + undefined_flag1(c_oflag,W,RAP); + + /* Control modes */ + st->c_cflag &= ~SVR4_CBAUD; + st->c_cflag |= bsd_to_svr4_speed(bt->c_ospeed, SVR4_CBAUD); + bsd_to_svr4_flag4(c_cflag,C,SIZE,C,S5,C,S6,C,S7,C,S8) + bsd_to_svr4_flag1(c_cflag,C,STOPB); + bsd_to_svr4_flag1(c_cflag,C,READ); + bsd_to_svr4_flag1(c_cflag,P,ARENB); + bsd_to_svr4_flag1(c_cflag,P,ARODD); + bsd_to_svr4_flag1(c_cflag,H,UPCL); + bsd_to_svr4_flag1(c_cflag,C,LOCAL); + undefined_flag1(c_cflag,R,CV1EN); + undefined_flag1(c_cflag,X,MT1EN); + undefined_flag1(c_cflag,L,OBLK); + undefined_flag1(c_cflag,X,CLUDE); + st->c_cflag &= ~SVR4_CIBAUD; + st->c_cflag |= bsd_to_svr4_speed(bt->c_ispeed, SVR4_CIBAUD); + + undefined_flag1(c_oflag,P,AREXT); + + /* line discipline modes */ + bsd_to_svr4_flag1(c_lflag,I,SIG); + bsd_to_svr4_flag1(c_lflag,I,CANON); + undefined_flag1(c_lflag,X,CASE); + bsd_to_svr4_flag1(c_lflag,E,CHO); + bsd_to_svr4_flag1(c_lflag,E,CHOE); + bsd_to_svr4_flag1(c_lflag,E,CHOK); + bsd_to_svr4_flag1(c_lflag,E,CHONL); + bsd_to_svr4_flag1(c_lflag,N,OFLSH); + bsd_to_svr4_flag1(c_lflag,T,OSTOP); + bsd_to_svr4_flag1(c_lflag,E,CHOCTL); + bsd_to_svr4_flag1(c_lflag,E,CHOPRT); + bsd_to_svr4_flag1(c_lflag,E,CHOKE); + undefined_flag1(c_lflag,D,EFECHO); + bsd_to_svr4_flag1(c_lflag,F,LUSHO); + bsd_to_svr4_flag1(c_lflag,P,ENDIN); + bsd_to_svr4_flag1(c_lflag,I,EXTEN); +} + + +static void +svr4_termio_to_termios(t, ts) + const struct svr4_termio *t; + struct svr4_termios *ts; +{ + int i; + + ts->c_iflag = (svr4_tcflag_t) t->c_iflag; + ts->c_oflag = (svr4_tcflag_t) t->c_oflag; + ts->c_cflag = (svr4_tcflag_t) t->c_cflag; + ts->c_lflag = (svr4_tcflag_t) t->c_lflag; + + for (i = 0; i < SVR4_NCC; i++) + ts->c_cc[i] = (svr4_cc_t) t->c_cc[i]; +} + + +static void +svr4_termios_to_termio(ts, t) + const struct svr4_termios *ts; + struct svr4_termio *t; +{ + int i; + + t->c_iflag = (u_short) ts->c_iflag; + t->c_oflag = (u_short) ts->c_oflag; + t->c_cflag = (u_short) ts->c_cflag; + t->c_lflag = (u_short) ts->c_lflag; + t->c_line = 0; /* XXX */ + + for (i = 0; i < SVR4_NCC; i++) + t->c_cc[i] = (u_char) ts->c_cc[i]; +} + +int +svr4_termioctl(fp, cmd, data, p, retval) + struct file *fp; + u_long cmd; + caddr_t data; + struct proc *p; + register_t *retval; +{ + struct termios bt; + struct svr4_termios st; + struct svr4_termio t; + int error; + int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) = + fp->f_ops->fo_ioctl; + + *retval = 0; + + switch (cmd) { + case SVR4_TCGETA: + case SVR4_TCGETS: + if ((error = (*ctl)(fp, TIOCGETA, (caddr_t) &bt, p)) != 0) + return error; + +#ifdef DEBUG_SVR4 + { + int i; + printf("iflag=%o oflag=%o cflag=%o lflag=%o\n", + bt.c_iflag, bt.c_oflag, bt.c_lflag); + printf("cc: "); + for (i = 0; i < NCCS; i++) + printf("%o ", bt.c_cc[i]); + printf("\n"); + } +#endif + + bsd_to_svr4_termios(&bt, &st); + + DPRINTF(("ioctl(TCGET[A|S]);\n")); + +#ifdef DEBUG_SVR4 + { + int i; + printf("iflag=%o oflag=%o cflag=%o lflag=%o\n", + st.c_iflag, st.c_oflag, st.c_lflag); + printf("cc: "); + for (i = 0; i < SVR4_NCCS; i++) + printf("%o ", st.c_cc[i]); + printf("\n"); + } +#endif + + if (cmd == SVR4_TCGETA) { + svr4_termios_to_termio(&st, &t); + return copyout(&t, data, sizeof(t)); + } + else { + return copyout(&st, data, sizeof(st)); + } + + case SVR4_TCSETA: + case SVR4_TCSETS: + case SVR4_TCSETAW: + case SVR4_TCSETSW: + case SVR4_TCSETAF: + case SVR4_TCSETSF: + /* get full BSD termios so we don't lose information */ + if ((error = (*ctl)(fp, TIOCGETA, (caddr_t) &bt, p)) != 0) + return error; + + switch (cmd) { + case SVR4_TCSETS: + case SVR4_TCSETSW: + case SVR4_TCSETSF: + if ((error = copyin(data, &st, sizeof(st))) != 0) + return error; + break; + + case SVR4_TCSETA: + case SVR4_TCSETAW: + case SVR4_TCSETAF: + if ((error = copyin(data, &t, sizeof(t))) != 0) + return error; + + svr4_termio_to_termios(&t, &st); + break; + } + + svr4_to_bsd_termios(&st, &bt); + + switch (cmd) { + case SVR4_TCSETA: + case SVR4_TCSETS: + DPRINTF(("ioctl(TCSET[A|S]);\n")); + cmd = TIOCSETA; + break; + case SVR4_TCSETAW: + case SVR4_TCSETSW: + DPRINTF(("ioctl(TCSET[A|S]W);\n")); + cmd = TIOCSETAW; + break; + case SVR4_TCSETAF: + case SVR4_TCSETSF: + DPRINTF(("ioctl(TCSET[A|S]F);\n")); + cmd = TIOCSETAF; + break; + } + + return (*ctl)(fp, cmd, (caddr_t) &bt, p); + + default: + DPRINTF(("Unknown svr4 termios %x\n", cmd)); + return ENOSYS; + } +} diff --git a/sys/compat/svr4/svr4_termios.h b/sys/compat/svr4/svr4_termios.h new file mode 100644 index 00000000000..930c696b833 --- /dev/null +++ b/sys/compat/svr4/svr4_termios.h @@ -0,0 +1,217 @@ +/* $NetBSD: svr4_termios.h,v 1.2 1994/11/18 02:54:21 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_TERMIOS_H_ +#define _SVR4_TERMIOS_H_ + +#define SVR4_POSIX_VDISABLE 0 +#define SVR4_NCC 8 +#define SVR4_NCCS 19 + +typedef u_long svr4_tcflag_t; +typedef u_char svr4_cc_t; +typedef u_long svr4_speed_t; + +struct svr4_termios { + svr4_tcflag_t c_iflag; + svr4_tcflag_t c_oflag; + svr4_tcflag_t c_cflag; + svr4_tcflag_t c_lflag; + svr4_cc_t c_cc[SVR4_NCCS]; +}; + +struct svr4_termio { + u_short c_iflag; + u_short c_oflag; + u_short c_cflag; + u_short c_lflag; + char c_line; + u_char c_cc[SVR4_NCC]; +}; + +/* control characters */ +#define SVR4_VINTR 0 +#define SVR4_VQUIT 1 +#define SVR4_VERASE 2 +#define SVR4_VKILL 3 +#define SVR4_VEOF 4 +#define SVR4_VEOL 5 +#define SVR4_VEOL2 6 +#define SVR4_VMIN 4 +#define SVR4_VTIME 5 +#define SVR4_VSWTCH 7 +#define SVR4_VSTART 8 +#define SVR4_VSTOP 9 +#define SVR4_VSUSP 10 +#define SVR4_VDSUSP 11 +#define SVR4_VREPRINT 12 +#define SVR4_VDISCARD 13 +#define SVR4_VWERASE 14 +#define SVR4_VLNEXT 15 + +/* Input modes */ +#define SVR4_IGNBRK 00000001 +#define SVR4_BRKINT 00000002 +#define SVR4_IGNPAR 00000004 +#define SVR4_PARMRK 00000010 +#define SVR4_INPCK 00000020 +#define SVR4_ISTRIP 00000040 +#define SVR4_INLCR 00000100 +#define SVR4_IGNCR 00000200 +#define SVR4_ICRNL 00000400 +#define SVR4_IUCLC 00001000 +#define SVR4_IXON 00002000 +#define SVR4_IXANY 00004000 +#define SVR4_IXOFF 00010000 +#define SVR4_IMAXBEL 00020000 +#define SVR4_DOSMODE 00100000 + +/* Output modes */ +#define SVR4_OPOST 00000001 +#define SVR4_OLCUC 00000002 +#define SVR4_ONLCR 00000004 +#define SVR4_OCRNL 00000010 +#define SVR4_ONOCR 00000020 +#define SVR4_ONLRET 00000040 +#define SVR4_OFILL 00000100 +#define SVR4_OFDEL 00000200 +#define SVR4_NLDLY 00000400 +#define SVR4_NL0 00000000 +#define SVR4_NL1 00000400 +#define SVR4_CRDLY 00003000 +#define SVR4_CR0 00000000 +#define SVR4_CR1 00001000 +#define SVR4_CR2 00002000 +#define SVR4_CR3 00003000 +#define SVR4_TABDLY 00014000 +#define SVR4_TAB0 00000000 +#define SVR4_TAB1 00004000 +#define SVR4_TAB2 00010000 +#define SVR4_TAB3 00014000 +#define SVR4_XTABS 00014000 +#define SVR4_BSDLY 00020000 +#define SVR4_BS0 00000000 +#define SVR4_BS1 00020000 +#define SVR4_VTDLY 00040000 +#define SVR4_VT0 00000000 +#define SVR4_VT1 00040000 +#define SVR4_FFDLY 00100000 +#define SVR4_FF0 00000000 +#define SVR4_FF1 00100000 +#define SVR4_PAGEOUT 00200000 +#define SVR4_WRAP 00400000 + +/* Control modes */ +#define SVR4_CBAUD 00000017 +#define SVR4_CSIZE 00000060 +#define SVR4_CS5 00000000 +#define SVR4_CS6 00000200 +#define SVR4_CS7 00000040 +#define SVR4_CS8 00000006 +#define SVR4_CSTOPB 00000100 +#define SVR4_CREAD 00000200 +#define SVR4_PARENB 00000400 +#define SVR4_PARODD 00001000 +#define SVR4_HUPCL 00002000 +#define SVR4_CLOCAL 00004000 +#define SVR4_RCV1EN 00010000 +#define SVR4_XMT1EN 00020000 +#define SVR4_LOBLK 00040000 +#define SVR4_XCLUDE 00100000 +#define SVR4_CIBAUD 03600000 +#define SVR4_PAREXT 04000000 + +/* line discipline modes */ +#define SVR4_ISIG 00000001 +#define SVR4_ICANON 00000002 +#define SVR4_XCASE 00000004 +#define SVR4_ECHO 00000010 +#define SVR4_ECHOE 00000020 +#define SVR4_ECHOK 00000040 +#define SVR4_ECHONL 00000100 +#define SVR4_NOFLSH 00000200 +#define SVR4_TOSTOP 00000400 +#define SVR4_ECHOCTL 00001000 +#define SVR4_ECHOPRT 00002000 +#define SVR4_ECHOKE 00004000 +#define SVR4_DEFECHO 00010000 +#define SVR4_FLUSHO 00020000 +#define SVR4_PENDIN 00040000 +#define SVR4_IEXTEN 00100000 + +#define SVR4_TIOC ('T' << 8) + +#define SVR4_TCGETA (SVR4_TIOC| 1) +#define SVR4_TCSETA (SVR4_TIOC| 2) +#define SVR4_TCSETAW (SVR4_TIOC| 3) +#define SVR4_TCSETAF (SVR4_TIOC| 4) +#define SVR4_TCSBRK (SVR4_TIOC| 5) +#define SVR4_TCXONC (SVR4_TIOC| 6) +#define SVR4_TCFLSH (SVR4_TIOC| 7) +#define SVR4_TIOCKBON (SVR4_TIOC| 8) +#define SVR4_TIOCKBOF (SVR4_TIOC| 9) +#define SVR4_KBENABLED (SVR4_TIOC|10) +#define SVR4_TCGETS (SVR4_TIOC|13) +#define SVR4_TCSETS (SVR4_TIOC|14) +#define SVR4_TCSETSW (SVR4_TIOC|15) +#define SVR4_TCSETSF (SVR4_TIOC|16) +#define SVR4_TCDSET (SVR4_TIOC|32) +#define SVR4_RTS_TOG (SVR4_TIOC|33) +#define SVR4_TCGETSC (SVR4_TIOC|34) +#define SVR4_TCSETSC (SVR4_TIOC|35) +#define SVR4_TCMOUSE (SVR4_TIOC|36) +#define SVR4_TIOCGWINSZ (SVR4_TIOC|104) +#define SVR4_TIOCSWINSZ (SVR4_TIOC|103) + +struct svr4_winsize { + u_short ws_row; + u_short ws_col; + u_short ws_xpixel; + u_short ws_ypixel; +}; + + +#define SVR4_B0 0 +#define SVR4_B50 1 +#define SVR4_B75 2 +#define SVR4_B110 3 +#define SVR4_B134 4 +#define SVR4_B150 5 +#define SVR4_B200 6 +#define SVR4_B300 7 +#define SVR4_B600 8 +#define SVR4_B1200 9 +#define SVR4_B1800 10 +#define SVR4_B2400 11 +#define SVR4_B4800 12 +#define SVR4_B9600 13 +#define SVR4_B19200 14 +#define SVR4_B38400 15 + +#endif /* !_SVR4_TERMIOS_H_ */ diff --git a/sys/compat/svr4/svr4_time.h b/sys/compat/svr4/svr4_time.h new file mode 100644 index 00000000000..8944788c4a2 --- /dev/null +++ b/sys/compat/svr4/svr4_time.h @@ -0,0 +1,36 @@ +/* $NetBSD: svr4_time.h,v 1.3 1994/10/29 00:43:28 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_TIME_H_ +#define _SVR4_TIME_H_ + +#include <compat/svr4/svr4_types.h> +#include <sys/time.h> + +#endif /* !_SVR4_TIME_H_ */ diff --git a/sys/compat/svr4/svr4_timod.h b/sys/compat/svr4/svr4_timod.h new file mode 100644 index 00000000000..e40a93887b9 --- /dev/null +++ b/sys/compat/svr4/svr4_timod.h @@ -0,0 +1,60 @@ +/* $NetBSD: svr4_timod.h,v 1.3 1995/01/10 00:04:11 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_TIMOD_H_ +#define _SVR4_TIMOD_H_ + +#define SVR4_TIMOD ('T' << 8) +#define SVR4_TI_GETINFO (SVR4_TIMOD|140) +#define SVR4_TI_OPTMGMT (SVR4_TIMOD|141) +#define SVR4_TI_BIND (SVR4_TIMOD|142) +#define SVR4_TI_UNBIND (SVR4_TIMOD|143) +#define SVR4_TI_GETMYNAME (SVR4_TIMOD|144) +#define SVR4_TI_GETPEERNAME (SVR4_TIMOD|145) +#define SVR4_TI_SETMYNAME (SVR4_TIMOD|146) +#define SVR4_TI_SETPEERNAME (SVR4_TIMOD|147) + +#define SVR4_TI_CONNECT_REQUEST 0x00 +#define SVR4_TI_INFO_REQUEST 0x05 +#define SVR4_TI_BIND_REQUEST 0x06 +#define SVR4_TI_SENDTO_REQUEST 0x08 + +#define SVR4_TI_CONNECT_REPLY 0x0c +#define SVR4_TI_INFO_REPLY 0x10 +#define SVR4_TI_BIND_REPLY 0x11 +#define SVR4_TI_OK_REPLY 0x13 +#define SVR4_TI_RECVFROM_REPLY 0x14 + +struct svr4_netbuf { + u_int maxlen; + u_int len; + char *buf; +}; + +#endif /* !_SVR4_TIMOD_H_ */ diff --git a/sys/compat/svr4/svr4_ttold.c b/sys/compat/svr4/svr4_ttold.c new file mode 100644 index 00000000000..dd71697e779 --- /dev/null +++ b/sys/compat/svr4/svr4_ttold.c @@ -0,0 +1,287 @@ +/* $NetBSD: svr4_ttold.c,v 1.6 1995/10/07 06:27:56 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/proc.h> +#include <sys/systm.h> +#include <sys/file.h> +#include <sys/filedesc.h> +#include <sys/ioctl.h> +#include <sys/termios.h> +#include <sys/tty.h> +#include <sys/socket.h> +#include <sys/ioctl.h> +#include <sys/mount.h> +#include <net/if.h> +#include <sys/malloc.h> + +#include <sys/syscallargs.h> + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_util.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_stropts.h> +#include <compat/svr4/svr4_ttold.h> + +static void svr4_tchars_to_bsd_tchars __P((const struct svr4_tchars *st, + struct tchars *bt)); +static void bsd_tchars_to_svr4_tchars __P((const struct tchars *bt, + struct svr4_tchars *st)); +static void svr4_sgttyb_to_bsd_sgttyb __P((const struct svr4_sgttyb *ss, + struct sgttyb *bs)); +static void bsd_sgttyb_to_svr4_sgttyb __P((const struct sgttyb *bs, + struct svr4_sgttyb *ss)); +static void svr4_ltchars_to_bsd_ltchars __P((const struct svr4_ltchars *sl, + struct ltchars *bl)); +static void bsd_ltchars_to_svr4_ltchars __P((const struct ltchars *bl, + struct svr4_ltchars *sl)); + +static void +svr4_tchars_to_bsd_tchars(st, bt) + const struct svr4_tchars *st; + struct tchars *bt; +{ + bt->t_intrc = st->t_intrc; + bt->t_quitc = st->t_quitc; + bt->t_startc = st->t_startc; + bt->t_stopc = st->t_stopc; + bt->t_eofc = st->t_eofc; + bt->t_brkc = st->t_brkc; +} + + +static void +bsd_tchars_to_svr4_tchars(bt, st) + const struct tchars *bt; + struct svr4_tchars *st; +{ + st->t_intrc = bt->t_intrc; + st->t_quitc = bt->t_quitc; + st->t_startc = bt->t_startc; + st->t_stopc = bt->t_stopc; + st->t_eofc = bt->t_eofc; + st->t_brkc = bt->t_brkc; +} + + +static void +svr4_sgttyb_to_bsd_sgttyb(ss, bs) + const struct svr4_sgttyb *ss; + struct sgttyb *bs; +{ + bs->sg_ispeed = ss->sg_ispeed; + bs->sg_ospeed = ss->sg_ospeed; + bs->sg_erase = ss->sg_erase; + bs->sg_kill = ss->sg_kill; + bs->sg_flags = ss->sg_flags; +}; + + +static void +bsd_sgttyb_to_svr4_sgttyb(bs, ss) + const struct sgttyb *bs; + struct svr4_sgttyb *ss; +{ + ss->sg_ispeed = bs->sg_ispeed; + ss->sg_ospeed = bs->sg_ospeed; + ss->sg_erase = bs->sg_erase; + ss->sg_kill = bs->sg_kill; + ss->sg_flags = bs->sg_flags; +} + + +static void +svr4_ltchars_to_bsd_ltchars(sl, bl) + const struct svr4_ltchars *sl; + struct ltchars *bl; +{ + bl->t_suspc = sl->t_suspc; + bl->t_dsuspc = sl->t_dsuspc; + bl->t_rprntc = sl->t_rprntc; + bl->t_flushc = sl->t_flushc; + bl->t_werasc = sl->t_werasc; + bl->t_lnextc = sl->t_lnextc; +} + + +static void +bsd_ltchars_to_svr4_ltchars(bl, sl) + const struct ltchars *bl; + struct svr4_ltchars *sl; +{ + sl->t_suspc = bl->t_suspc; + sl->t_dsuspc = bl->t_dsuspc; + sl->t_rprntc = bl->t_rprntc; + sl->t_flushc = bl->t_flushc; + sl->t_werasc = bl->t_werasc; + sl->t_lnextc = bl->t_lnextc; +} + + +int +svr4_ttoldioctl(fp, cmd, data, p, retval) + struct file *fp; + u_long cmd; + caddr_t data; + struct proc *p; + register_t *retval; +{ + int error; + int (*ctl) __P((struct file *, u_long, caddr_t, struct proc *)) = + fp->f_ops->fo_ioctl; + + *retval = 0; + + switch (cmd) { + case SVR4_TIOCGPGRP: + { + pid_t pid; + + if ((error = (*ctl)(fp, TIOCGPGRP, + (caddr_t) &pid, p)) != 0) + return error; + + DPRINTF(("TIOCGPGRP %d", pid)); + + if ((error = copyout(&pid, data, sizeof(pid))) != 0) + return error; + + } + + case SVR4_TIOCSPGRP: + { + pid_t pid; + + if ((error = copyin(data, &pid, sizeof(pid))) != 0) + return error; + + DPRINTF(("TIOCSPGRP %d", pid)); + + return (*ctl)(fp, TIOCSPGRP, (caddr_t) &pid, p); + } + + case SVR4_TIOCGSID: + { + pid_t pid; + + if ((error = (*ctl)(fp, TIOCGSID, + (caddr_t) &pid, p)) != 0) + return error; + + DPRINTF(("TIOCGSID %d", pid)); + + return copyout(&pid, data, sizeof(pid)); + } + + case SVR4_TIOCGETP: + { + struct sgttyb bs; + struct svr4_sgttyb ss; + + error = (*ctl)(fp, TIOCGETP, (caddr_t) &bs, p); + if (error) + return error; + + bsd_sgttyb_to_svr4_sgttyb(&bs, &ss); + return copyout(&ss, data, sizeof(ss)); + } + + case SVR4_TIOCSETP: + case SVR4_TIOCSETN: + { + struct sgttyb bs; + struct svr4_sgttyb ss; + + if ((error = copyin(data, &ss, sizeof(ss))) != 0) + return error; + + svr4_sgttyb_to_bsd_sgttyb(&ss, &bs); + + cmd = (cmd == SVR4_TIOCSETP) ? TIOCSETP : TIOCSETN; + return (*ctl)(fp, cmd, (caddr_t) &bs, p); + } + + case SVR4_TIOCGETC: + { + struct tchars bt; + struct svr4_tchars st; + + error = (*ctl)(fp, TIOCGETC, (caddr_t) &bt, p); + if (error) + return error; + + bsd_tchars_to_svr4_tchars(&bt, &st); + return copyout(&st, data, sizeof(st)); + } + + case SVR4_TIOCSETC: + { + struct tchars bt; + struct svr4_tchars st; + + if ((error = copyin(data, &st, sizeof(st))) != 0) + return error; + + svr4_tchars_to_bsd_tchars(&st, &bt); + + return (*ctl)(fp, TIOCSETC, (caddr_t) &bt, p); + } + + case SVR4_TIOCGLTC: + { + struct ltchars bl; + struct svr4_ltchars sl; + + error = (*ctl)(fp, TIOCGLTC, (caddr_t) &bl, p); + if (error) + return error; + + bsd_ltchars_to_svr4_ltchars(&bl, &sl); + return copyout(&sl, data, sizeof(sl)); + } + + case SVR4_TIOCSLTC: + { + struct ltchars bl; + struct svr4_ltchars sl; + + if ((error = copyin(data, &sl, sizeof(sl))) != 0) + return error; + + svr4_ltchars_to_bsd_ltchars(&sl, &bl); + + return (*ctl)(fp, TIOCSLTC, (caddr_t) &bl, p); + } + + default: + DPRINTF(("Unknown svr4 ttold %x\n", cmd)); + return 0; /* ENOSYS really */ + } +} diff --git a/sys/compat/svr4/svr4_ttold.h b/sys/compat/svr4/svr4_ttold.h new file mode 100644 index 00000000000..287d4ca63f4 --- /dev/null +++ b/sys/compat/svr4/svr4_ttold.h @@ -0,0 +1,121 @@ +/* $NetBSD: svr4_ttold.h,v 1.2 1994/11/18 02:54:25 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_TTOLD_H_ +#define _SVR4_TTOLD_H_ + +struct svr4_tchars { + char t_intrc; + char t_quitc; + char t_startc; + char t_stopc; + char t_eofc; + char t_brkc; +}; + +struct svr4_sgttyb { + u_char sg_ispeed; + u_char sg_ospeed; + u_char sg_erase; + u_char sg_kill; + int sg_flags; +}; + +struct svr4_ltchars { + char t_suspc; + char t_dsuspc; + char t_rprntc; + char t_flushc; + char t_werasc; + char t_lnextc; +}; + +#ifndef SVR4_tIOC +#define SVR4_tIOC ('t' << 8) +#endif + +#define SVR4_TIOCGETD (SVR4_tIOC | 0) +#define SVR4_TIOCSETD (SVR4_tIOC | 1) +#define SVR4_TIOCHPCL (SVR4_tIOC | 2) +#define SVR4_TIOCGETP (SVR4_tIOC | 8) +#define SVR4_TIOCSETP (SVR4_tIOC | 9) +#define SVR4_TIOCSETN (SVR4_tIOC | 10) +#define SVR4_TIOCEXCL (SVR4_tIOC | 13) +#define SVR4_TIOCNXCL (SVR4_tIOC | 14) +#define SVR4_TIOCFLUSH (SVR4_tIOC | 16) +#define SVR4_TIOCSETC (SVR4_tIOC | 17) +#define SVR4_TIOCGETC (SVR4_tIOC | 18) +#define SVR4_TIOCGPGRP (SVR4_tIOC | 20) +#define SVR4_TIOCSPGRP (SVR4_tIOC | 21) +#define SVR4_TIOCGSID (SVR4_tIOC | 22) +#define SVR4_TIOCSTI (SVR4_tIOC | 23) +#define SVR4_TIOCSSID (SVR4_tIOC | 24) +#define SVR4_TIOCMSET (SVR4_tIOC | 26) +#define SVR4_TIOCMBIS (SVR4_tIOC | 27) +#define SVR4_TIOCMBIC (SVR4_tIOC | 28) +#define SVR4_TIOCMGET (SVR4_tIOC | 29) +#define SVR4_TIOCREMOTE (SVR4_tIOC | 30) +#define SVR4_TIOCSIGNAL (SVR4_tIOC | 31) + +#define SVR4_TIOCSTART (SVR4_tIOC | 110) +#define SVR4_TIOCSTOP (SVR4_tIOC | 111) +#define SVR4_TIOCNOTTY (SVR4_tIOC | 113) +#define SVR4_TIOCOUTQ (SVR4_tIOC | 115) +#define SVR4_TIOCGLTC (SVR4_tIOC | 116) +#define SVR4_TIOCSLTC (SVR4_tIOC | 117) +#define SVR4_TIOCCDTR (SVR4_tIOC | 120) +#define SVR4_TIOCSDTR (SVR4_tIOC | 121) +#define SVR4_TIOCCBRK (SVR4_tIOC | 122) +#define SVR4_TIOCSBRK (SVR4_tIOC | 123) +#define SVR4_TIOCLGET (SVR4_tIOC | 124) +#define SVR4_TIOCLSET (SVR4_tIOC | 125) +#define SVR4_TIOCLBIC (SVR4_tIOC | 126) +#define SVR4_TIOCLBIS (SVR4_tIOC | 127) + +#define SVR4_TIOCM_LE 0001 +#define SVR4_TIOCM_DTR 0002 +#define SVR4_TIOCM_RTS 0004 +#define SVR4_TIOCM_ST 0010 +#define SVR4_TIOCM_SR 0020 +#define SVR4_TIOCM_CTS 0040 +#define SVR4_TIOCM_CAR 0100 +#define SVR4_TIOCM_CD SVR4_TIOCM_CAR +#define SVR4_TIOCM_RNG 0200 +#define SVR4_TIOCM_RI SVR4_TIOCM_RNG +#define SVR4_TIOCM_DSR 0400 + +#define SVR4_OTTYDISC 0 +#define SVR4_NETLDISC 1 +#define SVR4_NTTYDISC 2 +#define SVR4_TABLDISC 3 +#define SVR4_NTABLDISC 4 +#define SVR4_MOUSELDISC 5 +#define SVR4_KBDLDISC 6 + +#endif /* !_SVR4_TTOLD_H_ */ diff --git a/sys/compat/svr4/svr4_types.h b/sys/compat/svr4/svr4_types.h new file mode 100644 index 00000000000..ba553d432fd --- /dev/null +++ b/sys/compat/svr4/svr4_types.h @@ -0,0 +1,57 @@ +/* $NetBSD: svr4_types.h,v 1.6 1995/08/14 01:12:50 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_TYPES_H_ +#define _SVR4_TYPES_H_ + +typedef long svr4_off_t; +typedef u_long svr4_dev_t; +typedef u_long svr4_ino_t; +typedef u_long svr4_mode_t; +typedef u_long svr4_nlink_t; +typedef long svr4_uid_t; +typedef long svr4_gid_t; +typedef long svr4_daddr_t; +typedef long svr4_pid_t; +typedef long svr4_time_t; +typedef char *svr4_caddr_t; +typedef u_int svr4_size_t; + +typedef short svr4_o_dev_t; +typedef short svr4_o_pid_t; +typedef u_short svr4_o_ino_t; +typedef u_short svr4_o_mode_t; +typedef short svr4_o_nlink_t; +typedef u_short svr4_o_uid_t; +typedef u_short svr4_o_gid_t; +typedef long svr4_clock_t; + +typedef struct timespec svr4_timestruc_t; + +#endif /* !_SVR4_TYPES_H_ */ diff --git a/sys/compat/svr4/svr4_ucontext.h b/sys/compat/svr4/svr4_ucontext.h new file mode 100644 index 00000000000..5359acaa685 --- /dev/null +++ b/sys/compat/svr4/svr4_ucontext.h @@ -0,0 +1,76 @@ +/* $NetBSD: svr4_ucontext.h,v 1.3 1995/08/14 01:13:29 mycroft Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_UCONTEXT_H_ +#define _SVR4_UCONTEXT_H_ + +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_signal.h> +#include <machine/svr4_machdep.h> + +/* + * Machine context + */ + +#define SVR4_UC_SIGMASK 0x01 +#define SVR4_UC_STACK 0x02 + +#define SVR4_UC_CPU 0x04 +#define SVR4_UC_FPU 0x08 +#define SVR4_UC_WEITEK 0x10 + +#define SVR4_UC_MCONTEXT (SVR4_UC_CPU|SVR4_UC_FPU|SVR4_UC_WEITEK) + +#define SVR4_UC_ALL (SVR4_UC_SIGMASK|SVR4_UC_STACK|SVR4_UC_MCONTEXT) + +typedef struct svr4_ucontext { + u_long uc_flags; + struct svr4_ucontext *uc_link; + svr4_sigset_t uc_sigmask; + struct svr4_sigaltstack uc_stack; + svr4_mcontext_t uc_mcontext; + long uc_pad[5]; +} svr4_ucontext_t; + +#define SVR4_UC_GETREGSET 0 +#define SVR4_UC_SETREGSET 1 + +/* + * Signal frame + */ +struct svr4_sigframe { + int sf_signum; + union svr4_siginfo *sf_sip; + struct svr4_ucontext *sf_ucp; + sig_t sf_handler; + struct svr4_ucontext sf_uc; + union svr4_siginfo sf_si; +}; + +#endif /* !_SVR4_UCONTEXT_H_ */ diff --git a/sys/compat/svr4/svr4_ulimit.h b/sys/compat/svr4/svr4_ulimit.h new file mode 100644 index 00000000000..270ba05b4fe --- /dev/null +++ b/sys/compat/svr4/svr4_ulimit.h @@ -0,0 +1,40 @@ +/* $NetBSD: svr4_ulimit.h,v 1.2 1994/11/18 02:54:29 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_ULIMIT_H_ +#define _SVR4_ULIMIT_H_ + +#define SVR4_GFILLIM 1 +#define SVR4_SFILLIM 2 +#define SVR4_GMEMLIM 3 +#define SVR4_GDESLIM 4 +#define SVR4_GTXTOFF 64 + + +#endif /* !_SVR4_ULIMIT_H_ */ diff --git a/sys/compat/svr4/svr4_ustat.h b/sys/compat/svr4/svr4_ustat.h new file mode 100644 index 00000000000..af9f808a605 --- /dev/null +++ b/sys/compat/svr4/svr4_ustat.h @@ -0,0 +1,42 @@ +/* $NetBSD: svr4_ustat.h,v 1.3 1994/10/29 00:43:30 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_USTAT_H_ +#define _SVR4_USTAT_H_ + +#include <compat/svr4/svr4_types.h> + +struct svr4_ustat { + svr4_daddr_t f_tfree; + svr4_ino_t f_tinode; + char f_fname[6]; + char f_fpack[6]; +}; + +#endif /* !_SVR4_USTAT_H_ */ diff --git a/sys/compat/svr4/svr4_util.h b/sys/compat/svr4/svr4_util.h new file mode 100644 index 00000000000..d4211410bc4 --- /dev/null +++ b/sys/compat/svr4/svr4_util.h @@ -0,0 +1,46 @@ +/* $NetBSD: svr4_util.h,v 1.7 1995/06/24 20:29:31 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_UTIL_H_ +#define _SVR4_UTIL_H_ + +#include <compat/common/compat_util.h> + +#ifdef DEBUG_SVR4 +#define DPRINTF(a) printf a; +#else +#define DPRINTF(a) +#endif + +extern const char svr4_emul_path[]; + +#define SVR4_CHECK_ALT_EXIST(p, sgp, path) \ + CHECK_ALT_EXIST(p, sgp, svr4_emul_path, path) + +#endif /* !_SVR4_UTIL_H_ */ diff --git a/sys/compat/svr4/svr4_utsname.h b/sys/compat/svr4/svr4_utsname.h new file mode 100644 index 00000000000..73c0805a319 --- /dev/null +++ b/sys/compat/svr4/svr4_utsname.h @@ -0,0 +1,44 @@ +/* $NetBSD: svr4_utsname.h,v 1.3 1994/10/29 00:43:33 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_UTSNAME_H_ +#define _SVR4_UTSNAME_H_ + +#include <compat/svr4/svr4_types.h> +#include <sys/utsname.h> + +struct svr4_utsname { + char sysname[257]; + char nodename[257]; + char release[257]; + char version[257]; + char machine[257]; +}; + +#endif /* !_SVR4_UTSNAME_H_ */ diff --git a/sys/compat/svr4/svr4_wait.h b/sys/compat/svr4/svr4_wait.h new file mode 100644 index 00000000000..e726c67c970 --- /dev/null +++ b/sys/compat/svr4/svr4_wait.h @@ -0,0 +1,55 @@ +/* $NetBSD: svr4_wait.h,v 1.5 1995/03/31 03:06:50 christos Exp $ */ + +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _SVR4_WAIT_H_ +#define _SVR4_WAIT_H_ + + +#define SVR4_P_PID 0 +#define SVR4_P_PPID 1 +#define SVR4_P_PGID 2 +#define SVR4_P_SID 3 +#define SVR4_P_CID 4 +#define SVR4_P_UID 5 +#define SVR4_P_GID 6 +#define SVR4_P_ALL 7 + +#define SVR4_WEXITED 0x01 +#define SVR4_WTRAPPED 0x02 +#define SVR4_WSTOPPED 0x04 +#define SVR4_WCONTINUED 0x08 +#define SVR4_WUNDEF1 0x10 +#define SVR4_WUNDEF2 0x20 +#define SVR4_WNOHANG 0x40 +#define SVR4_WNOWAIT 0x80 + +#define SVR4_WOPTMASK (SVR4_WEXITED|SVR4_WTRAPPED|SVR4_WSTOPPED|\ + SVR4_WCONTINUED|SVR4_WNOHANG|SVR4_WNOWAIT) + +#endif /* !_SVR4_WAIT_H_ */ diff --git a/sys/compat/svr4/syscalls.conf b/sys/compat/svr4/syscalls.conf new file mode 100644 index 00000000000..2cb29b9c956 --- /dev/null +++ b/sys/compat/svr4/syscalls.conf @@ -0,0 +1,12 @@ +# $NetBSD: syscalls.conf,v 1.3 1994/10/26 05:28:08 cgd Exp $ + +sysnames="svr4_syscalls.c" +sysnumhdr="svr4_syscall.h" +syssw="svr4_sysent.c" +sysarghdr="svr4_syscallargs.h" +compatopts="compat_43 compat_09 compat_10" +libcompatopts="" + +switchname="svr4_sysent" +namesname="svr4_syscallnames" +constprefix="SVR4_SYS_" diff --git a/sys/compat/svr4/syscalls.master b/sys/compat/svr4/syscalls.master new file mode 100644 index 00000000000..23c9202537a --- /dev/null +++ b/sys/compat/svr4/syscalls.master @@ -0,0 +1,276 @@ + $NetBSD: syscalls.master,v 1.13 1995/10/07 06:27:57 mycroft Exp $ + +; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 + +; NetBSD COMPAT_SVR4 system call name/number "master" file. +; (See syscalls.conf to see what it is processed into.) +; +; Fields: number type [type-dependent ...] +; number system call number, must be in order +; type one of STD, OBSOL, UNIMPL, NODEF, NOARGS, or one of +; the compatibility options defined in syscalls.conf. +; +; types: +; STD always included +; OBSOL obsolete, not included in system +; UNIMPL unimplemented, not included in system +; NODEF included, but don't define the syscall number +; NOARGS included, but don't define the syscall args structure +; +; The compat options are defined in the syscalls.conf file, and the +; compat option name is prefixed to the syscall name. Other than +; that, they're like NODEF (for 'compat' options), or STD (for +; 'libcompat' options). +; +; The type-dependent arguments are as follows: +; For STD, NODEF, NOARGS, and compat syscalls: +; { pseudo-proto } [alias] +; For other syscalls: +; [comment] +; +; #ifdef's, etc. may be included, and are copied to the output files. +; #include's are copied to the syscall switch definition file only. + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/signal.h> +#include <sys/mount.h> +#include <sys/syscallargs.h> +#include <compat/svr4/svr4_types.h> +#include <compat/svr4/svr4_signal.h> +#include <compat/svr4/svr4_ucontext.h> +#include <compat/svr4/svr4_syscallargs.h> +#include <compat/svr4/svr4_statvfs.h> + +0 NOARGS { int sys_nosys(void); } syscall +1 NOARGS { int sys_exit(int rval); } +2 NOARGS { int sys_fork(void); } +3 NOARGS { int sys_read(int fd, char *buf, u_int nbyte); } +4 NOARGS { int sys_write(int fd, char *buf, u_int nbyte); } +5 STD { int svr4_sys_open(char *path, int flags, int mode); } +6 NOARGS { int sys_close(int fd); } +7 STD { int svr4_sys_wait(int *status); } +8 STD { int svr4_sys_creat(char *path, int mode); } +9 NOARGS { int sys_link(char *path, char *link); } +10 NOARGS { int sys_unlink(char *path); } +11 STD { int svr4_sys_execv(char *path, char **argp); } +12 NOARGS { int sys_chdir(char *path); } +13 STD { int svr4_sys_time(svr4_time_t *t); } +14 STD { int svr4_sys_mknod(char* path, int mode, int dev); } +15 NOARGS { int sys_chmod(char *path, int mode); } +16 NOARGS { int sys_chown(char *path, int uid, int gid); } +17 STD { int svr4_sys_break(caddr_t nsize); } +18 STD { int svr4_sys_stat(char* path, struct svr4_stat* ub); } +19 NOARGS { long compat_43_sys_lseek(int fd, long offset, \ + int whence); } +20 NOARGS { pid_t sys_getpid(void); } +21 UNIMPL old_mount +22 UNIMPL System V umount +23 NOARGS { int sys_setuid(uid_t uid); } +24 NOARGS { uid_t sys_getuid(void); } +25 UNIMPL stime +26 UNIMPL ptrace +27 STD { int svr4_sys_alarm(unsigned sec); } +28 STD { int svr4_sys_fstat(int fd, struct svr4_stat *sb); } +29 UNIMPL pause +30 UNIMPL utime +31 UNIMPL was stty +32 UNIMPL was gtty +33 STD { int svr4_sys_access(char *path, int flags); } +34 UNIMPL nice +35 UNIMPL statfs +36 NOARGS { int sys_sync(void); } +37 STD { int svr4_sys_kill(int pid, int signum); } +38 UNIMPL fstatfs +39 STD { int svr4_sys_pgrpsys(int cmd, int pid, int pgid); } +40 UNIMPL xenix +41 NOARGS { int sys_dup(u_int fd); } +42 NOARGS { int sys_pipe(void); } +43 STD { int svr4_sys_times(struct tms *tp); } +44 UNIMPL profil +45 UNIMPL plock +46 NOARGS { int sys_setgid(gid_t gid); } +47 NOARGS { gid_t sys_getgid(void); } +48 STD { int svr4_sys_signal(int signum, svr4_sig_t handler); } +#ifdef SYSVMSG +49 UNIMPL { int sys_msgsys(int which, int a2, int a3, int a4, \ + int a5, int a6); } +#else +49 UNIMPL msgsys +#endif +50 STD { int svr4_sys_sysarch(int op, void *a1); } +51 UNIMPL acct +#ifdef SYSVSHM +52 UNIMPL { int sys_shmsys(int which, int a2, int a3, int a4); } +#else +52 UNIMPL shmsys +#endif +#ifdef SYSVSEM +53 UNIMPL { int sys_semsys(int which, int a2, int a3, int a4, \ + int a5); } +#else +53 UNIMPL semsys +#endif +54 STD { int svr4_sys_ioctl(int fd, u_long com, \ + caddr_t data); } +55 UNIMPL uadmin +56 UNIMPL exch +57 STD { int svr4_sys_utssys(void *a1, void *a2, int sel, \ + void *a3); } +58 NOARGS { int sys_fsync(int fd); } +59 STD { int svr4_sys_execve(char *path, char **argp, \ + char **envp); } +60 NOARGS { int sys_umask(int newmask); } +61 NOARGS { int sys_chroot(char *path); } +62 STD { int svr4_sys_fcntl(int fd, int cmd, char *arg); } +63 STD { long svr4_sys_ulimit(int cmd, long newlimit); } +64 UNIMPL reserved for unix/pc +65 UNIMPL reserved for unix/pc +66 UNIMPL reserved for unix/pc +67 UNIMPL reserved for unix/pc +68 UNIMPL reserved for unix/pc +69 UNIMPL reserved for unix/pc +70 OBSOL advfs +71 OBSOL unadvfs +72 OBSOL rmount +73 OBSOL rumount +74 OBSOL rfstart +75 OBSOL sigret +76 OBSOL rdebug +77 OBSOL rfstop +78 UNIMPL rfsys +79 NOARGS { int sys_rmdir(char *path); } +80 NOARGS { int sys_mkdir(char *path, int mode); } +81 STD { int svr4_sys_getdents(int fd, char *buf, int nbytes); } +82 OBSOL libattach +83 OBSOL libdetach +84 UNIMPL sysfs +85 STD { int svr4_sys_getmsg(int fd, struct svr4_strbuf *ctl, \ + struct svr4_strbuf *dat, int *flags); } +86 STD { int svr4_sys_putmsg(int fd, struct svr4_strbuf *ctl, \ + struct svr4_strbuf *dat, int flags); } +87 STD { int svr4_sys_poll(struct svr4_pollfd *fds, \ + long nfds, int timeout); } +88 STD { int svr4_sys_lstat(char *path, \ + struct svr4_stat *ub); } +89 NOARGS { int sys_symlink(char *path, char *link); } +90 NOARGS { int sys_readlink(char *path, char *buf, int count); } +91 NOARGS { int sys_getgroups(u_int gidsetsize, gid_t *gidset); } +92 NOARGS { int sys_setgroups(u_int gidsetsize, gid_t *gidset); } +93 NOARGS { int sys_fchmod(int fd, int mode); } +94 NOARGS { int sys_fchown(int fd, int uid, int gid); } +95 STD { int svr4_sys_sigprocmask(int how, \ + svr4_sigset_t *set, svr4_sigset_t *oset); } +96 STD { int svr4_sys_sigsuspend(svr4_sigset_t *ss); } +97 STD { int svr4_sys_sigaltstack(struct svr4_sigaltstack *nss, \ + struct svr4_sigaltstack *oss); } +98 STD { int svr4_sys_sigaction(int signum, \ + struct svr4_sigaction *nsa, \ + struct svr4_sigaction *osa); } +99 STD { int svr4_sys_sigpending(int what, \ + svr4_sigset_t *mask); } +100 STD { int svr4_sys_context(int func, \ + struct svr4_ucontext *uc); } +101 UNIMPL evsys +102 UNIMPL evtrapret +103 STD { int svr4_sys_statvfs(char *path, \ + struct svr4_statvfs *fs); } +104 STD { int svr4_sys_fstatvfs(int fd, \ + struct svr4_statvfs *fs); } +105 UNIMPL +106 UNIMPL nfssvc +107 STD { int svr4_sys_waitsys(int grp, int id, \ + union svr4_siginfo *info, int options); } +108 UNIMPL sigsendsys +109 STD { int svr4_sys_hrtsys(int cmd, int fun, int sub, \ + void *rv1, void *rv2); } +110 UNIMPL acancel +111 UNIMPL async +112 UNIMPL priocntlsys +113 UNIMPL pathconf +114 UNIMPL mincore +115 STD { int svr4_sys_mmap(svr4_caddr_t addr, \ + svr4_size_t len, int prot, int flags, int fd, \ + svr4_off_t pos); } +116 NOARGS { int sys_mprotect(caddr_t addr, int len, int prot); } +117 NOARGS { int sys_munmap(caddr_t addr, int len); } +118 NOARGS { int sys_fpathconf(int fd, int name); } +119 NOARGS { int sys_vfork(void); } +120 NOARGS { int sys_fchdir(int fd); } +121 NOARGS { int sys_readv(int fd, struct iovec *iovp, u_int iovcnt); } +122 NOARGS { int sys_writev(int fd, struct iovec *iovp, \ + u_int iovcnt); } +123 STD { int svr4_sys_xstat(int two, char *path, \ + struct svr4_xstat *ub); } +124 STD { int svr4_sys_lxstat(int two, char *path, \ + struct svr4_xstat *ub); } +125 STD { int svr4_sys_fxstat(int two, int fd, \ + struct svr4_xstat *sb); } +126 UNIMPL xmknod +127 UNIMPL clocal +128 STD { int svr4_sys_setrlimit(int which, \ + struct ogetrlimit *rlp); } +129 STD { int svr4_sys_getrlimit(int which, \ + struct ogetrlimit *rlp); } +130 UNIMPL lchown +131 UNIMPL memcntl +132 UNIMPL getpmsg +133 UNIMPL putpmsg +134 NOARGS { int sys_rename(char *from, char *to); } +135 STD { int svr4_sys_uname(struct svr4_utsname* name, \ + int dummy); } +136 NOARGS { int sys_setegid(gid_t egid); } +137 STD { int svr4_sys_sysconfig(int name); } +138 NOARGS { int sys_adjtime(struct timeval *delta, \ + struct timeval *olddelta); } +139 STD { long svr4_sys_systeminfo(int what, char *buf, \ + long len); } +140 UNIMPL +141 NOARGS { int sys_seteuid(uid_t euid); } +142 UNIMPL vtrace +143 UNIMPL fork1 +144 UNIMPL sigwait +145 UNIMPL lwp_info +146 UNIMPL yield +147 UNIMPL lwp_sema_p +148 UNIMPL lwp_sema_v +149 UNIMPL +150 UNIMPL +151 UNIMPL +152 UNIMPL modctl +153 STD { int svr4_sys_fchroot(int fd); } +154 UNIMPL utimes +155 STD { int svr4_sys_vhangup(void); } +156 STD { int svr4_sys_gettimeofday(struct timeval *tp); } +157 NOARGS { int sys_getitimer(u_int which, \ + struct itimerval *itv); } +158 NOARGS { int sys_setitimer(u_int which, \ + struct itimerval *itv, struct itimerval *oitv); } +159 UNIMPL lwp_create +160 UNIMPL lwp_exit +161 UNIMPL lwp_suspend +162 UNIMPL lwp_continue +163 UNIMPL lwp_kill +164 UNIMPL lwp_self +165 UNIMPL lwp_getprivate +166 UNIMPL lwp_setprivate +167 UNIMPL lwp_wait +168 UNIMPL lwp_mutex_unlock +169 UNIMPL lwp_mutex_lock +170 UNIMPL lwp_cond_wait +171 UNIMPL lwp_cond_signal +172 UNIMPL lwp_cond_broadcast +173 UNIMPL pread +174 UNIMPL pwrite +175 UNIMPL llseek +176 UNIMPL inst_sync +177 UNIMPL +178 UNIMPL +179 UNIMPL +180 UNIMPL +181 UNIMPL +182 UNIMPL +183 UNIMPL +184 UNIMPL +185 UNIMPL +186 UNIMPL auditsys |