diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/compat/svr4/svr4_acl.h | 45 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_ipc.c | 7 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_misc.c | 89 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_net.c | 5 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_signal.c | 17 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_socket.c | 8 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_stream.c | 457 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_stropts.h | 21 | ||||
-rw-r--r-- | sys/compat/svr4/svr4_timod.h | 7 | ||||
-rw-r--r-- | sys/compat/svr4/syscalls.master | 24 |
10 files changed, 496 insertions, 184 deletions
diff --git a/sys/compat/svr4/svr4_acl.h b/sys/compat/svr4/svr4_acl.h new file mode 100644 index 00000000000..03f6c62553a --- /dev/null +++ b/sys/compat/svr4/svr4_acl.h @@ -0,0 +1,45 @@ +/* $OpenBSD: svr4_acl.h,v 1.1 1997/02/13 19:45:16 niklas Exp $ */ +/* $NetBSD: svr4_acl.h,v 1.1 1996/12/06 03:23:30 christos Exp $ */ + +/* + * Copyright (c) 1996 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. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christos Zoulas. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _SVR4_ACL_H_ +#define _SVR4_ACL_H_ + +typedef struct svr4_aclent { + int a_type; + svr4_uid_t a_id; + svr4_o_mode_t a_perm; +} svr4_aclent_t; + +#define SVR4_SYS_GETACL 1 +#define SVR4_SYS_SETACL 2 +#define SVR4_SYS_GETACLCNT 3 + +#endif /* !_SVR4_ACL_H_ */ diff --git a/sys/compat/svr4/svr4_ipc.c b/sys/compat/svr4/svr4_ipc.c index 3426cf4ec52..9bf62137c9f 100644 --- a/sys/compat/svr4/svr4_ipc.c +++ b/sys/compat/svr4/svr4_ipc.c @@ -1,5 +1,5 @@ -/* $OpenBSD: svr4_ipc.c,v 1.2 1996/08/02 20:35:39 niklas Exp $ */ -/* $NetBSD: svr4_ipc.c,v 1.1 1995/10/14 20:24:30 christos Exp $ */ +/* $OpenBSD: svr4_ipc.c,v 1.3 1997/02/13 19:45:18 niklas Exp $ */ +/* $NetBSD: svr4_ipc.c,v 1.2 1996/10/28 08:46:35 fvdl Exp $ */ /* * Copyright (c) 1995 Christos Zoulas. All rights reserved. @@ -349,7 +349,8 @@ bsd_to_svr4_msqid_ds(bds, sds) /* use the padding for the rest of the fields */ { - short *pad = (short *) bds->msg_pad4; + const short *pad = (const short *)bds->msg_pad4; + sds->msg_cv = pad[0]; sds->msg_qnum_cv = pad[1]; } diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index 55c6032a3a0..800cab4e53c 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -1,5 +1,5 @@ -/* $OpenBSD: svr4_misc.c,v 1.7 1997/01/27 01:16:51 deraadt Exp $ */ -/* $NetBSD: svr4_misc.c,v 1.36 1996/03/30 22:38:02 christos Exp $ */ +/* $OpenBSD: svr4_misc.c,v 1.8 1997/02/13 19:45:19 niklas Exp $ */ +/* $NetBSD: svr4_misc.c,v 1.42 1996/12/06 03:22:34 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -80,6 +80,7 @@ #include <compat/svr4/svr4_wait.h> #include <compat/svr4/svr4_statvfs.h> #include <compat/svr4/svr4_sysconfig.h> +#include <compat/svr4/svr4_acl.h> #include <vm/vm.h> @@ -137,17 +138,20 @@ svr4_sys_execv(p, v, retval) void *v; register_t *retval; { - struct svr4_sys_execv_args *uap = v; - struct sys_execve_args ex; - + struct svr4_sys_execv_args /* { + syscallarg(char *) path; + syscallarg(char **) argv; + } */ *uap = v; + struct sys_execve_args ap; 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; + SCARG(&ap, path) = SCARG(uap, path); + SCARG(&ap, argp) = SCARG(uap, argp); + SCARG(&ap, envp) = NULL; - return sys_execve(p, &ex, retval); + return sys_execve(p, &ap, retval); } @@ -157,8 +161,13 @@ svr4_sys_execve(p, v, retval) void *v; register_t *retval; { - struct sys_execve_args *uap = v; + struct sys_execve_args /* { + syscallarg(char *) path; + syscallarg(char **) argv; + syscallarg(char **) envp; + } */ *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); @@ -320,6 +329,9 @@ svr4_sys_mmap(p, v, retval) if (SCARG(uap, prot) & ~(PROT_READ | PROT_WRITE | PROT_EXEC)) return EINVAL; /* XXX still needed? */ + if (SCARG(uap, len) == 0) + return EINVAL; + SCARG(&mm, prot) = SCARG(uap, prot); SCARG(&mm, len) = SCARG(uap, len); SCARG(&mm, flags) = SCARG(uap, flags) & ~_MAP_NEW; @@ -1090,8 +1102,8 @@ 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_bsize = bfs->f_iosize; /* XXX */ + sfs->f_frsize = bfs->f_bsize; sfs->f_blocks = bfs->f_blocks; sfs->f_bfree = bfs->f_bfree; sfs->f_bavail = bfs->f_bavail; @@ -1227,3 +1239,56 @@ svr4_sys_gettimeofday(p, v, retval) return 0; } + +int +svr4_sys_facl(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_facl_args *uap = v; + + *retval = 0; + + switch (SCARG(uap, cmd)) { + case SVR4_SYS_SETACL: + /* We don't support acls on any filesystem */ + return ENOSYS; + + case SVR4_SYS_GETACL: + return copyout(retval, &SCARG(uap, num), + sizeof(SCARG(uap, num))); + + case SVR4_SYS_GETACLCNT: + return 0; + + default: + return EINVAL; + } +} + +int +svr4_sys_acl(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + return svr4_sys_facl(p, v, retval); /* XXX: for now the same */ +} + +int +svr4_sys_memcntl(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct svr4_sys_memcntl_args *uap = v; + struct sys_mprotect_args ap; + + SCARG(&ap, addr) = SCARG(uap, addr); + SCARG(&ap, len) = SCARG(uap, len); + SCARG(&ap, prot) = SCARG(uap, attr); + + /* XXX: no locking, invalidating, or syncing supported */ + return sys_mprotect(p, &ap, retval); +} diff --git a/sys/compat/svr4/svr4_net.c b/sys/compat/svr4/svr4_net.c index 2b88bd5a15d..cbdc30b911d 100644 --- a/sys/compat/svr4/svr4_net.c +++ b/sys/compat/svr4/svr4_net.c @@ -1,5 +1,5 @@ -/* $OpenBSD: svr4_net.c,v 1.7 1996/08/01 00:50:53 niklas Exp $ */ -/* $NetBSD: svr4_net.c,v 1.9 1996/04/11 12:52:41 christos Exp $ */ +/* $OpenBSD: svr4_net.c,v 1.8 1997/02/13 19:45:20 niklas Exp $ */ +/* $NetBSD: svr4_net.c,v 1.12 1996/09/07 12:40:51 mycroft Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -220,6 +220,7 @@ svr4_stream_get(fp) st = malloc(sizeof(struct svr4_strm), M_NETADDR, M_WAITOK); st->s_family = so->so_proto->pr_domain->dom_family; st->s_cmd = ~0; + st->s_afd = -1; so->so_internal = st; return st; diff --git a/sys/compat/svr4/svr4_signal.c b/sys/compat/svr4/svr4_signal.c index 4ba26f57853..b54d2d8114c 100644 --- a/sys/compat/svr4/svr4_signal.c +++ b/sys/compat/svr4/svr4_signal.c @@ -1,5 +1,6 @@ -/* $OpenBSD: svr4_signal.c,v 1.4 1996/04/17 05:24:20 mickey Exp $ */ -/* $NetBSD: svr4_signal.c,v 1.23 1996/03/30 22:38:07 christos Exp $ */ +/* $OpenBSD: svr4_signal.c,v 1.5 1997/02/13 19:45:21 niklas Exp $ */ +/* $NetBSD: svr4_signal.c,v 1.24 1996/12/06 03:21:53 christos Exp $ */ + /* * Copyright (c) 1994 Christos Zoulas * All rights reserved. @@ -649,3 +650,15 @@ svr4_sys_context(p, v, retval) } return 0; } + +int +svr4_sys_pause(p, v, retval) + register struct proc *p; + void *v; + register_t *retval; +{ + struct sys_sigsuspend_args bsa; + + SCARG(&bsa, mask) = p->p_sigmask; + return sys_sigsuspend(p, &bsa, retval); +} diff --git a/sys/compat/svr4/svr4_socket.c b/sys/compat/svr4/svr4_socket.c index a7dc208863c..34d2a1d5346 100644 --- a/sys/compat/svr4/svr4_socket.c +++ b/sys/compat/svr4/svr4_socket.c @@ -1,5 +1,5 @@ -/* $OpenBSD: svr4_socket.c,v 1.1 1996/04/21 22:18:24 deraadt Exp $ */ -/* $NetBSD: svr4_socket.c,v 1.1 1996/04/11 12:43:30 christos Exp $ */ +/* $OpenBSD: svr4_socket.c,v 1.2 1997/02/13 19:45:22 niklas Exp $ */ +/* $NetBSD: svr4_socket.c,v 1.3 1996/10/28 08:46:36 fvdl Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -78,6 +78,8 @@ svr4_find_socket(p, fp, dev, ino) void *cookie = ((struct socket *) fp->f_data)->so_internal; if (!initialized) { + DPRINTF(("svr4_find_socket: uninitialized [%p,%d,%d]\n", + p, dev, ino)); TAILQ_INIT(&svr4_head); initialized = 1; return NULL; @@ -146,7 +148,7 @@ svr4_add_socket(p, path, st) e->ino = st->st_ino; e->p = p; - if ((error = copyinstr((char *) path, e->sock.sun_path, + if ((error = copyinstr(path, e->sock.sun_path, sizeof(e->sock.sun_path), &len)) != 0) { DPRINTF(("svr4_add_socket: copyinstr failed %d\n", error)); free(e, M_TEMP); diff --git a/sys/compat/svr4/svr4_stream.c b/sys/compat/svr4/svr4_stream.c index 33a15453cdf..0e15252f145 100644 --- a/sys/compat/svr4/svr4_stream.c +++ b/sys/compat/svr4/svr4_stream.c @@ -1,5 +1,6 @@ -/* $OpenBSD: svr4_stream.c,v 1.6 1996/08/01 00:50:54 niklas Exp $ */ -/* $NetBSD: svr4_stream.c,v 1.14 1996/05/13 16:57:50 christos Exp $ */ +/* $OpenBSD: svr4_stream.c,v 1.7 1997/02/13 19:45:24 niklas Exp $ */ +/* $NetBSD: svr4_stream.c,v 1.19 1996/12/22 23:00:03 fvdl Exp $ */ + /* * Copyright (c) 1994, 1996 Christos Zoulas. All rights reserved. * @@ -28,12 +29,12 @@ * (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... * Yes, this is gross. * * ToDo: The state machine for getmsg needs re-thinking - * We really need I_FDINSERT and it is going to be a pain. */ #include <sys/param.h> @@ -86,8 +87,14 @@ static void netaddr_to_sockaddr_un __P((struct sockaddr_un *, /* stream ioctls */ static int i_nread __P((struct file *, struct proc *, register_t *, int, u_long, caddr_t)); +static int i_fdinsert __P((struct file *, struct proc *, register_t *, int, + u_long, caddr_t)); static int i_str __P((struct file *, struct proc *, register_t *, int, u_long, caddr_t)); +static int _i_bind_rsvd __P((struct file *, struct proc *, register_t *, int, + u_long, caddr_t)); +static int _i_rele_rsvd __P((struct file *, struct proc *, register_t *, int, + u_long, caddr_t)); /* i_str sockmod calls */ static int sockmod __P((struct file *, int, struct svr4_strioctl *, @@ -98,6 +105,8 @@ static int si_ogetudata __P((struct file *, int, struct svr4_strioctl *, struct proc *)); static int si_sockparams __P((struct file *, int, struct svr4_strioctl *, struct proc *)); +static int si_shutdown __P((struct file *, int, struct svr4_strioctl *, + struct proc *)); static int si_getudata __P((struct file *, int, struct svr4_strioctl *, struct proc *)); @@ -110,20 +119,34 @@ static int ti_bind __P((struct file *, int, struct svr4_strioctl *, struct proc *)); #ifdef DEBUG_SVR4 +static void bufprint __P((u_char *, size_t)); static int show_ioc __P((const char *, struct svr4_strioctl *)); static int show_strbuf __P((struct svr4_strbuf *)); static void show_msg __P((const char *, int, struct svr4_strbuf *, struct svr4_strbuf *, int)); -static void show_strmcmd __P((const char *, struct svr4_strmcmd *)); + +static void +bufprint(buf, len) + u_char *buf; + size_t len; +{ + size_t i; + + uprintf("\n\t"); + for (i = 0; i < len; i++) { + uprintf("%x ", buf[i]); + if (i && (i % 16) == 0) + uprintf("\n\t"); + } +} static int show_ioc(str, ioc) const char *str; struct svr4_strioctl *ioc; { - char *ptr = (char *) malloc(ioc->len, M_TEMP, M_WAITOK); + u_char *ptr = (u_char *)malloc(ioc->len, M_TEMP, M_WAITOK); int error; - int i; uprintf("%s cmd = %ld, timeout = %d, len = %d, buf = %p { ", str, ioc->cmd, ioc->timeout, ioc->len, ioc->buf); @@ -133,8 +156,7 @@ show_ioc(str, ioc) return error; } - for (i = 0; i < ioc->len; i++) - uprintf("%x ", (unsigned char) ptr[i]); + bufprint(ptr, ioc->len); uprintf("}\n"); @@ -148,19 +170,18 @@ show_strbuf(str) struct svr4_strbuf *str; { int error; - int i; - char *ptr = NULL; + u_char *ptr = NULL; int maxlen = str->maxlen; int len = str->len; if (maxlen < 0) maxlen = 0; - if (len >= maxlen || len <= 0) + if (len >= maxlen) len = maxlen; - if (len != 0) { - ptr = malloc(len, M_TEMP, M_WAITOK); + if (len > 0) { + ptr = (u_char *)malloc(len, M_TEMP, M_WAITOK); if ((error = copyin(str->buf, ptr, len)) != 0) { free((char *) ptr, M_TEMP); @@ -170,8 +191,8 @@ show_strbuf(str) uprintf(", { %d, %d, %p=[ ", str->maxlen, str->len, str->buf); - for (i = 0; i < len; i++) - uprintf("%x ", (unsigned char) ptr[i]); + if (ptr) + bufprint(ptr, len); uprintf("]}"); @@ -212,26 +233,8 @@ show_msg(str, fd, ctl, dat, flags) uprintf(", %x);\n", flags); } - - -static void -show_strmcmd(str, cmd) - const char *str; - struct svr4_strmcmd *cmd; -{ - int i; - - uprintf("%s cmd = %ld, len = %ld, offs = %ld { ", - str, cmd->cmd, cmd->len, cmd->offs); - - for (i = 0; i < sizeof(cmd->pad) / sizeof(cmd->pad[0]); i++) - uprintf("%lx ", cmd->pad[i]); - - uprintf("}\n"); -} #endif /* DEBUG_SVR4 */ - /* * We are faced with an interesting situation. On svr4 unix sockets * are really pipes. But we really have sockets, and we might as @@ -384,7 +387,7 @@ getparm(fp, pa) case SOCK_STREAM: pa->type = SVR4_SOCK_STREAM; - pa->protocol = IPPROTO_TCP; + pa->protocol = IPPROTO_IP; return; case SOCK_RAW: @@ -424,11 +427,18 @@ si_ogetudata(fp, fd, ioc, p) switch (pa.family) { case AF_INET: + ud.tidusize = 16384; ud.addrsize = sizeof(struct sockaddr_in); + if (pa.type == SVR4_SOCK_STREAM) + ud.etsdusize = 1; + else + ud.etsdusize = 0; break; case AF_UNIX: - ud.addrsize = sizeof(struct sockaddr_un); + ud.tidusize = 65536; + ud.addrsize = 128; + ud.etsdusize = 128; break; default: @@ -438,16 +448,8 @@ si_ogetudata(fp, fd, ioc, p) } /* I have no idea what these should be! */ - ud.tidusize = 16384; ud.optsize = 128; - if (ioc->len == sizeof(ud)) - ud.tsdusize = 128; - - if (pa.type == SVR4_SOCK_STREAM) - ud.etsdusize = 1; - else - ud.etsdusize = 0; - + ud.tsdusize = 128; ud.servtype = pa.type; /* XXX: Fixme */ @@ -481,13 +483,6 @@ si_listen(fp, fd, ioc, p) int error; struct svr4_strm *st = svr4_stream_get(fp); register_t retval; -#if 0 - struct sockaddr_in sain; - struct sockaddr_un saun; - caddr_t sg; - void *skp, *sup; - int sasize; -#endif struct svr4_strmcmd lst; struct sys_listen_args la; @@ -496,43 +491,36 @@ si_listen(fp, fd, ioc, p) if ((error = copyin(ioc->buf, &lst, ioc->len)) != 0) return error; + if (lst.cmd != SVR4_TI_BIND_REQUEST) { + DPRINTF(("si_listen: bad request %ld\n", lst.cmd)); + return EINVAL; + } -#ifdef DEBUG_SVR4 - show_strmcmd(">si_listen", &lst); -#endif - -#if 0 - switch (st->s_family) { - case AF_INET: - skp = &sain; - sasize = sizeof(sain); + /* + * We are making assumptions again... + */ + SCARG(&la, s) = fd; + DPRINTF(("SI_LISTEN: fileno %d backlog = %d\n", fd, 5)); + SCARG(&la, backlog) = 5; - if (lst.offs == 0) - goto reply; + if ((error = sys_listen(p, &la, &retval)) != 0) { + DPRINTF(("SI_LISTEN: listen failed %d\n", error)); + return error; + } - netaddr_to_sockaddr_in(&sain, &lst); + st->s_cmd = SVR4_TI__ACCEPT_WAIT; + lst.cmd = SVR4_TI_BIND_REPLY; - DPRINTF(("SI_LISTEN: fam %d, port %d, addr %x\n", - sain.sin_family, sain.sin_port, - sain.sin_addr.s_addr)); + switch (st->s_family) { + case AF_INET: + /* XXX: Fill the length here */ break; case AF_UNIX: - skp = &saun; - sasize = sizeof(saun); - if (lst.offs == 0) - goto reply; - - netaddr_to_sockaddr_un(&saun, &lst); - - if (saun.sun_path[0] == '\0') - goto reply; - - DPRINTF(("SI_LISTEN: fam %d, path %s\n", - saun.sun_family, saun.sun_path)); - - if ((error = clean_pipe(p, saun.sun_path)) != 0) - return error; + lst.len = 140; + lst.pad[28] = 0x00000000; /* magic again */ + lst.pad[29] = 0x00000800; /* magic again */ + lst.pad[30] = 0x80001400; /* magic again */ break; default: @@ -541,39 +529,11 @@ si_listen(fp, fd, ioc, p) return ENOSYS; } - sg = stackgap_init(p->p_emul); - sup = stackgap_alloc(&sg, sasize); - - if ((error = copyout(skp, sup, sasize)) != 0) - return error; -#endif - - SCARG(&la, s) = fd; - DPRINTF(("SI_LISTEN: fileno %d backlog = %d\n", fd, 5)); - SCARG(&la, backlog) = 5; - - if ((error = sys_listen(p, &la, &retval)) != 0) { - DPRINTF(("SI_LISTEN: listen failed %d\n", error)); - return error; - } - - st->s_cmd = SVR4_TI_ACCEPT_REPLY; - return 0; - -#if 0 -reply: - bzero(&lst, sizeof(lst)); - lst.cmd = SVR4_TI_BIND_REPLY; - lst.len = sasize; - lst.offs = 0x10; /* XXX */ - - ioc->len = 32; if ((error = copyout(&lst, ioc->buf, ioc->len)) != 0) return error; return 0; -#endif } @@ -600,11 +560,22 @@ si_getudata(fp, fd, ioc, p) switch (ud.sockparms.family) { case AF_INET: + ud.tidusize = 16384; + ud.tsdusize = 16384; ud.addrsize = sizeof(struct sockaddr_in); + if (ud.sockparms.type == SVR4_SOCK_STREAM) + ud.etsdusize = 1; + else + ud.etsdusize = 0; + ud.optsize = 0; break; case AF_UNIX: - ud.addrsize = sizeof(struct sockaddr_un); + ud.tidusize = 65536; + ud.tsdusize = 128; + ud.addrsize = 128; + ud.etsdusize = 128; + ud.optsize = 128; break; default: @@ -613,17 +584,6 @@ si_getudata(fp, fd, ioc, p) return ENOSYS; } - /* I have no idea what these should be! */ - ud.tidusize = 16384; - ud.optsize = 128; - ud.tsdusize = 16384; - - - if (ud.sockparms.type == SVR4_SOCK_STREAM) - ud.etsdusize = 1; - else - ud.etsdusize = 0; - ud.servtype = ud.sockparms.type; /* XXX: Fixme */ @@ -634,6 +594,31 @@ si_getudata(fp, fd, ioc, p) static int +si_shutdown(fp, fd, ioc, p) + struct file *fp; + int fd; + struct svr4_strioctl *ioc; + struct proc *p; +{ + int error; + struct sys_shutdown_args ap; + register_t retval; + + if (ioc->len != sizeof(SCARG(&ap, how))) { + DPRINTF(("SI_SHUTDOWN: Wrong size %d != %d\n", + sizeof(SCARG(&ap, how)), ioc->len)); + return EINVAL; + } + + if ((error = copyin(ioc->buf, &SCARG(&ap, how), ioc->len)) != 0) + return error; + + SCARG(&ap, s) = fd; + + return sys_shutdown(p, &ap, &retval); +} + +static int sockmod(fp, fd, ioc, p) struct file *fp; int fd; @@ -647,7 +632,7 @@ sockmod(fp, fd, ioc, p) case SVR4_SI_SHUTDOWN: DPRINTF(("SI_SHUTDOWN\n")); - return 0; + return si_shutdown(fp, fd, ioc, p); case SVR4_SI_LISTEN: DPRINTF(("SI_LISTEN\n")); @@ -745,14 +730,18 @@ ti_bind(fp, fd, ioc, p) struct svr4_strmcmd bnd; struct sys_bind_args ba; - if (st == NULL) + if (st == NULL) { + DPRINTF(("ti_bind: bad file descriptor\n")); return EINVAL; + } if ((error = copyin(ioc->buf, &bnd, ioc->len)) != 0) return error; - if (bnd.cmd != SVR4_TI_BIND_REQUEST) + if (bnd.cmd != SVR4_TI_BIND_REQUEST) { + DPRINTF(("ti_bind: bad request %ld\n", bnd.cmd)); return EINVAL; + } switch (st->s_family) { case AF_INET: @@ -785,6 +774,8 @@ ti_bind(fp, fd, ioc, p) if ((error = clean_pipe(p, saun.sun_path)) != 0) return error; + + bnd.pad[28] = 0x00001000; /* magic again */ break; default: @@ -801,7 +792,7 @@ ti_bind(fp, fd, ioc, p) SCARG(&ba, s) = fd; DPRINTF(("TI_BIND: fileno %d\n", fd)); - SCARG(&ba, name) = (caddr_t) sup; + SCARG(&ba, name) = (void *)sup; SCARG(&ba, namelen) = sasize; if ((error = sys_bind(p, &ba, &retval)) != 0) { @@ -812,7 +803,7 @@ ti_bind(fp, fd, ioc, p) reply: if (sup == NULL) { bzero(&bnd, sizeof(bnd)); - bnd.len = sasize; + bnd.len = sasize + 4; bnd.offs = 0x10; /* XXX */ } @@ -966,18 +957,18 @@ svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, dat) switch (st->s_family) { case AF_INET: sockaddr_to_netaddr_in(&sc, &sain); + skb.len = sasize; break; case AF_UNIX: sockaddr_to_netaddr_un(&sc, &saun); + skb.len = sasize + 4; break; default: return ENOSYS; } - skb.len = sasize; - if ((error = copyout(SVR4_ADDROF(&sc), skb.buf, sasize)) != 0) { DPRINTF(("ti_ioctl: error copying out socket data\n")); return error; @@ -991,9 +982,6 @@ svr4_stream_ti_ioctl(fp, p, retval, fd, cmd, dat) return error; } - - - static int i_nread(fp, p, retval, fd, cmd, dat) struct file *fp; @@ -1025,6 +1013,111 @@ i_nread(fp, p, retval, fd, cmd, dat) return copyout(&nread, dat, sizeof(nread)); } +static int +i_fdinsert(fp, p, retval, fd, cmd, dat) + struct file *fp; + struct proc *p; + register_t *retval; + int fd; + u_long cmd; + caddr_t dat; +{ + /* + * Major hack again here. We assume that we are using this to + * implement accept(2). If that is the case, we have already + * called accept, and we have stored the file descriptor in + * afd. We find the file descriptor that the code wants to use + * in fd insert, and then we dup2() our accepted file descriptor + * to it. + */ + int error; + struct svr4_strm *st = svr4_stream_get(fp); + struct svr4_strfdinsert fdi; + struct sys_dup2_args d2p; + struct sys_close_args clp; + + if (st == NULL) { + DPRINTF(("fdinsert: bad file type\n")); + return EINVAL; + } + + if (st->s_afd == -1) { + DPRINTF(("fdinsert: accept fd not found\n")); + return ENOENT; + } + + if ((error = copyin(dat, &fdi, sizeof(fdi))) != 0) { + DPRINTF(("fdinsert: copyin failed %d\n", error)); + return error; + } + + SCARG(&d2p, from) = st->s_afd; + SCARG(&d2p, to) = fdi.fd; + + if ((error = sys_dup2(p, &d2p, retval)) != 0) { + DPRINTF(("fdinsert: dup2(%d, %d) failed %d\n", + st->s_afd, fdi.fd, error)); + return error; + } + + SCARG(&clp, fd) = st->s_afd; + + if ((error = sys_close(p, &clp, retval)) != 0) { + DPRINTF(("fdinsert: close(%d) failed %d\n", + st->s_afd, error)); + return error; + } + + st->s_afd = -1; + + *retval = 0; + return 0; +} + + +static int +_i_bind_rsvd(fp, p, retval, fd, cmd, dat) + struct file *fp; + struct proc *p; + register_t *retval; + int fd; + u_long cmd; + caddr_t dat; +{ + struct sys_mknod_args ap; + + /* + * This is a supposed to be a kernel and library only ioctl. + * It gets called before ti_bind, when we have a unix + * socket, to physically create the socket transport and + * ``reserve'' it. I don't know how this get reserved inside + * the kernel, but we are going to create it nevertheless. + */ + SCARG(&ap, path) = dat; + SCARG(&ap, mode) = S_IFIFO; + + return sys_mkfifo(p, &ap, retval); +} + +static int +_i_rele_rsvd(fp, p, retval, fd, cmd, dat) + struct file *fp; + struct proc *p; + register_t *retval; + int fd; + u_long cmd; + caddr_t dat; +{ + struct sys_unlink_args ap; + + /* + * This is a supposed to be a kernel and library only ioctl. + * I guess it is supposed to release the socket. + */ + SCARG(&ap, path) = dat; + + return sys_unlink(p, &ap, retval); +} static int i_str(fp, p, retval, fd, cmd, dat) @@ -1120,7 +1213,19 @@ svr4_stream_ioctl(fp, p, retval, fd, cmd, dat) case SVR4_I_SETSIG: DPRINTF(("I_SETSIG\n")); - return 0; + /* + * This is the best we can do for now; we cannot generate + * signals only for specific events so the signal mask gets + * ignored + */ + { + struct sys_fcntl_args fa; + + SCARG(&fa, fd) = fd; + SCARG(&fa, cmd) = F_SETOWN; + SCARG(&fa, arg) = (void *) p->p_pid; + return sys_fcntl(p, &fa, retval); + } case SVR4_I_GETSIG: DPRINTF(("I_GETSIG\n")); @@ -1153,7 +1258,7 @@ svr4_stream_ioctl(fp, p, retval, fd, cmd, dat) case SVR4_I_FDINSERT: DPRINTF(("I_FDINSERT\n")); - return 0; + return i_fdinsert(fp, p, retval, fd, cmd, dat); case SVR4_I_SENDFD: DPRINTF(("I_SENDFD\n")); @@ -1227,6 +1332,14 @@ svr4_stream_ioctl(fp, p, retval, fd, cmd, dat) DPRINTF(("I_CANPUT\n")); return 0; + case SVR4__I_BIND_RSVD: + DPRINTF(("_I_BIND_RSVD\n")); + return _i_bind_rsvd(fp, p, retval, fd, cmd, dat); + + case SVR4__I_RELE_RSVD: + DPRINTF(("_I_RELE_RSVD\n")); + return _i_rele_rsvd(fp, p, retval, fd, cmd, dat); + default: DPRINTF(("unimpl cmd = %lx\n", cmd)); break; @@ -1314,12 +1427,21 @@ svr4_sys_putmsg(p, v, retval) break; case AF_UNIX: - { - /* We've been given a device/inode pair */ + if (ctl.len == 8) { + /* We are doing an accept; succeed */ + DPRINTF(("putmsg: Do nothing\n")); + *retval = 0; + return 0; + } else { + /* Maybe we've been given a device/inode pair */ dev_t *dev = SVR4_ADDROF(&sc); ino_t *ino = (ino_t *) &dev[1]; - if ((skp = svr4_find_socket(p, fp, *dev, *ino)) == NULL) - return ENOENT; + skp = svr4_find_socket(p, fp, *dev, *ino); + if (skp == NULL) { + skp = &saun; + /* I guess we have it by name */ + netaddr_to_sockaddr_un(skp, &sc); + } sasize = sizeof(saun); } break; @@ -1342,8 +1464,8 @@ svr4_sys_putmsg(p, v, retval) struct sys_connect_args co; co.s = SCARG(uap, fd); - co.name = (caddr_t) sup; - co.namelen = (int) sasize; + co.name = (void *)sup; + co.namelen = (int)sasize; return sys_connect(p, &co, retval); } @@ -1470,6 +1592,7 @@ svr4_sys_getmsg(p, v, retval) switch (st->s_cmd) { case SVR4_TI_CONNECT_REQUEST: + DPRINTF(("getmsg: TI_CONNECT_REQUEST\n")); /* * We do the connect in one step, so the putmsg should * have gotten the error. @@ -1480,15 +1603,18 @@ svr4_sys_getmsg(p, v, retval) ctl.len = 8; dat.len = -1; fl = 1; + st->s_cmd = sc.cmd; break; case SVR4_TI_OK_REPLY: + DPRINTF(("getmsg: TI_OK_REPLY\n")); + /* * We are immediately after a connect reply, so we send - * an connect verification. + * a connect verification. */ SCARG(&ga, fdes) = SCARG(uap, fd); - SCARG(&ga, asa) = (caddr_t) sup; + SCARG(&ga, asa) = (void *)sup; SCARG(&ga, alen) = flen; if ((error = sys_getpeername(p, &ga, retval)) != 0) { @@ -1500,18 +1626,19 @@ svr4_sys_getmsg(p, v, retval) return error; sc.cmd = SVR4_TI_CONNECT_REPLY; - sc.len = sasize; - sc.offs = 0x18; sc.pad[0] = 0x4; + sc.offs = 0x18; sc.pad[1] = 0x14; sc.pad[2] = 0x04000402; switch (st->s_family) { case AF_INET: + sc.len = sasize; sockaddr_to_netaddr_in(&sc, &sain); break; case AF_UNIX: + sc.len = sasize + 4; sockaddr_to_netaddr_un(&sc, &saun); break; @@ -1522,21 +1649,42 @@ svr4_sys_getmsg(p, v, retval) ctl.len = 40; dat.len = -1; fl = 0; + st->s_cmd = sc.cmd; + break; + + case SVR4_TI__ACCEPT_OK: + DPRINTF(("getmsg: TI__ACCEPT_OK\n")); + /* + * We do the connect in one step, so the putmsg should + * have gotten the error. + */ + sc.cmd = SVR4_TI_OK_REPLY; + sc.len = 1; + + ctl.len = 8; + dat.len = -1; + fl = 1; + st->s_cmd = SVR4_TI__ACCEPT_WAIT; break; - case SVR4_TI_ACCEPT_REPLY: + case SVR4_TI__ACCEPT_WAIT: + DPRINTF(("getmsg: TI__ACCEPT_WAIT\n")); /* * We are after a listen, so we try to accept... */ SCARG(&aa, s) = SCARG(uap, fd); - SCARG(&aa, name) = (caddr_t) sup; + SCARG(&aa, name) = (void *)sup; SCARG(&aa, anamelen) = flen; if ((error = sys_accept(p, &aa, retval)) != 0) { - DPRINTF(("getmsg: getpeername failed %d\n", error)); + DPRINTF(("getmsg: accept failed %d\n", error)); return error; } + st->s_afd = *retval; + + DPRINTF(("getmsg: Accept fd = %d\n", st->s_afd)); + if ((error = copyin(sup, skp, sasize)) != 0) return error; @@ -1549,11 +1697,18 @@ svr4_sys_getmsg(p, v, retval) switch (st->s_family) { case AF_INET: + sc.pad[1] = 0x28; sockaddr_to_netaddr_in(&sc, &sain); + ctl.len = 40; + sc.len = sasize; break; case AF_UNIX: - sockaddr_to_netaddr_un(&sc, &saun); + sc.pad[1] = 0x00010000; + sc.pad[2] = 0xf6bcdaa0; /* I don't know what that is */ + sc.pad[3] = 0x00010000; + ctl.len = 134; + sc.len = sasize + 4; break; default: @@ -1563,9 +1718,11 @@ svr4_sys_getmsg(p, v, retval) ctl.len = 40; dat.len = -1; fl = 0; + st->s_cmd = SVR4_TI__ACCEPT_OK; break; case SVR4_TI_SENDTO_REQUEST: + DPRINTF(("getmsg: TI_SENDTO_REQUEST\n")); if (ctl.maxlen > 36 && ctl.len < 36) ctl.len = 36; @@ -1605,14 +1762,15 @@ svr4_sys_getmsg(p, v, retval) return error; sc.cmd = SVR4_TI_RECVFROM_REPLY; - sc.len = sasize; switch (st->s_family) { case AF_INET: + sc.len = sasize; sockaddr_to_netaddr_in(&sc, &sain); break; case AF_UNIX: + sc.len = sasize + 4; sockaddr_to_netaddr_un(&sc, &saun); break; @@ -1622,14 +1780,15 @@ svr4_sys_getmsg(p, v, retval) dat.len = *retval; fl = 0; + st->s_cmd = sc.cmd; break; default: + st->s_cmd = sc.cmd; 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) diff --git a/sys/compat/svr4/svr4_stropts.h b/sys/compat/svr4/svr4_stropts.h index 2c044205d1e..bd217824041 100644 --- a/sys/compat/svr4/svr4_stropts.h +++ b/sys/compat/svr4/svr4_stropts.h @@ -1,5 +1,5 @@ -/* $OpenBSD: svr4_stropts.h,v 1.3 1996/08/01 00:50:55 niklas Exp $ */ -/* $NetBSD: svr4_stropts.h,v 1.6 1996/04/11 12:50:31 christos Exp $ */ +/* $OpenBSD: svr4_stropts.h,v 1.4 1997/02/13 19:45:25 niklas Exp $ */ +/* $NetBSD: svr4_stropts.h,v 1.9 1996/10/28 08:46:38 fvdl Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -74,6 +74,13 @@ struct svr4_strbuf { #define SVR4_I_GETCLTIME (SVR4_STR|33) #define SVR4_I_CANPUT (SVR4_STR|34) +/* + * The following two ioctls are OS specific and + * undocumented. + */ +#define SVR4__I_BIND_RSVD (SVR4_STR|242) +#define SVR4__I_RELE_RSVD (SVR4_STR|243) + /* Struct passed for SVR4_I_STR */ struct svr4_strioctl { u_long cmd; @@ -91,6 +98,7 @@ struct svr4_strioctl { struct svr4_strm { int s_family; /* socket family */ int s_cmd; /* last getmsg reply or putmsg request */ + int s_afd; /* last accepted fd; [for fd_insert] */ }; /* @@ -117,6 +125,14 @@ struct svr4_infocmd { long provider; }; +struct svr4_strfdinsert { + struct svr4_strbuf ctl; + struct svr4_strbuf data; + long flags; + int fd; + int offset; +}; + struct svr4_netaddr_in { u_short family; u_short port; @@ -129,6 +145,7 @@ struct svr4_netaddr_un { }; #define SVR4_ADDROF(sc) (void *) (((char *) (sc)) + (sc)->offs) +#define SVR4_C_ADDROF(sc) (const void *) (((const char *) (sc)) + (sc)->offs) struct svr4_strm *svr4_stream_get __P((struct file *fp)); diff --git a/sys/compat/svr4/svr4_timod.h b/sys/compat/svr4/svr4_timod.h index 5daa02886cd..8c7c03761a1 100644 --- a/sys/compat/svr4/svr4_timod.h +++ b/sys/compat/svr4/svr4_timod.h @@ -1,5 +1,5 @@ -/* $OpenBSD: svr4_timod.h,v 1.2 1996/04/21 22:18:39 deraadt Exp $ */ -/* $NetBSD: svr4_timod.h,v 1.4 1996/04/11 12:52:03 christos Exp $ */ +/* $OpenBSD: svr4_timod.h,v 1.3 1997/02/13 19:45:26 niklas Exp $ */ +/* $NetBSD: svr4_timod.h,v 1.5 1996/08/30 23:06:42 christos Exp $ */ /* * Copyright (c) 1994 Christos Zoulas @@ -53,6 +53,9 @@ #define SVR4_TI_OK_REPLY 0x13 #define SVR4_TI_RECVFROM_REPLY 0x14 +#define SVR4_TI__ACCEPT_WAIT 0x10000001 +#define SVR4_TI__ACCEPT_OK 0x10000002 + struct svr4_netbuf { u_int maxlen; u_int len; diff --git a/sys/compat/svr4/syscalls.master b/sys/compat/svr4/syscalls.master index 603e53ccc66..1d1d2cb8ca3 100644 --- a/sys/compat/svr4/syscalls.master +++ b/sys/compat/svr4/syscalls.master @@ -1,4 +1,4 @@ - $OpenBSD: syscalls.master,v 1.10 1997/01/26 23:02:24 downsj Exp $ + $OpenBSD: syscalls.master,v 1.11 1997/02/13 19:45:27 niklas Exp $ ; $NetBSD: syscalls.master,v 1.17 1996/02/10 17:12:51 christos Exp $ ; @(#)syscalls.master 8.1 (Berkeley) 7/19/93 @@ -37,12 +37,14 @@ #include <sys/signal.h> #include <sys/mount.h> #include <sys/syscallargs.h> + #include <compat/svr4/svr4_types.h> #include <compat/svr4/svr4_time.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> +#include <compat/svr4/svr4_acl.h> 0 NOARGS { int sys_nosys(void); } syscall 1 NOARGS { int sys_exit(int rval); } @@ -74,7 +76,7 @@ 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 +29 STD { int svr4_sys_pause(void); } 30 STD { int svr4_sys_utime(char *path, \ struct svr4_utimbuf *ubuf); } 31 UNIMPL was stty @@ -157,8 +159,8 @@ 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 NOARGS { int sys_poll(struct pollfd *fds, \ - unsigned long nfds, int timeout); } +87 NOARGS { int sys_poll(struct pollfd *fds, u_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); } @@ -222,7 +224,9 @@ 129 STD { int svr4_sys_getrlimit(int which, \ struct ogetrlimit *rlp); } 130 NOARGS { int sys_lchown(char *path, int uid, int gid); } -131 UNIMPL memcntl +131 STD { int svr4_sys_memcntl(svr4_caddr_t addr, \ + svr4_size_t len, int cmd, svr4_caddr_t arg, \ + int attr, int mask); } 132 UNIMPL getpmsg 133 UNIMPL putpmsg 134 NOARGS { int sys_rename(char *from, char *to); } @@ -282,7 +286,8 @@ 182 UNIMPL 183 UNIMPL 184 UNIMPL tsolsys -185 UNIMPL acl +185 STD { int svr4_sys_acl(char *path, int cmd, int num, \ + struct svr4_aclent *buf); } 186 UNIMPL auditsys 187 UNIMPL processor_bind 188 UNIMPL processor_info @@ -297,10 +302,11 @@ 197 UNIMPL timer_gettime 198 UNIMPL timer_getoverrun 199 UNIMPL nanosleep -200 UNIMPL facl +200 STD { int svr4_sys_facl(int fd, int cmd, int num, \ + struct svr4_aclent *buf); } 201 UNIMPL door -202 UNIMPL setreuid -203 UNIMPL setregid +202 NOARGS { int compat_43_sys_setreuid(int ruid, int euid); } +203 NOARGS { int compat_43_sys_setregid(int rgid, int egid); } 204 UNIMPL 205 UNIMPL 206 UNIMPL |