Home | History | Annotate | Line # | Download | only in ultrix
ultrix_misc.c revision 1.33
      1 /*	$NetBSD: ultrix_misc.c,v 1.33 1997/05/24 10:26:32 jonathan Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1995, 1997 Jonathan Stone (hereinafter referred to as the author)
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed by Matthew R. Green for
     18  *      the NetBSD Project.
     19  * 4. The name of the author may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission.
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
     23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
     26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     28  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     29  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     31  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     32  * SUCH DAMAGE.
     33  */
     34 
     35 /*
     36  * Copyright (c) 1992, 1993
     37  *	The Regents of the University of California.  All rights reserved.
     38  *
     39  * This software was developed by the Computer Systems Engineering group
     40  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
     41  * contributed to Berkeley.
     42  *
     43  * All advertising materials mentioning features or use of this software
     44  * must display the following acknowledgement:
     45  *	This product includes software developed by the University of
     46  *	California, Lawrence Berkeley Laboratory.
     47  *
     48  * Redistribution and use in source and binary forms, with or without
     49  * modification, are permitted provided that the following conditions
     50  * are met:
     51  * 1. Redistributions of source code must retain the above copyright
     52  *    notice, this list of conditions and the following disclaimer.
     53  * 2. Redistributions in binary form must reproduce the above copyright
     54  *    notice, this list of conditions and the following disclaimer in the
     55  *    documentation and/or other materials provided with the distribution.
     56  * 3. All advertising materials mentioning features or use of this software
     57  *    must display the following acknowledgement:
     58  *	This product includes software developed by the University of
     59  *	California, Berkeley and its contributors.
     60  * 4. Neither the name of the University nor the names of its contributors
     61  *    may be used to endorse or promote products derived from this software
     62  *    without specific prior written permission.
     63  *
     64  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     65  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     66  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     67  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     68  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     69  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     70  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     71  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     72  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     73  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     74  * SUCH DAMAGE.
     75  *
     76  *
     77  *	@(#)sun_misc.c	8.1 (Berkeley) 6/18/93
     78  *
     79  * from: Header: sun_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
     80  */
     81 
     82 /*
     83  * SunOS compatibility module.
     84  *
     85  * SunOS system calls that are implemented differently in BSD are
     86  * handled here.
     87  */
     88 
     89 #include <sys/param.h>
     90 #include <sys/systm.h>
     91 #include <sys/namei.h>
     92 #include <sys/dirent.h>
     93 #include <sys/proc.h>
     94 #include <sys/file.h>
     95 #include <sys/filedesc.h>
     96 /*#include <sys/stat.h>*/
     97 /*#include <sys/ioctl.h>*/
     98 #include <sys/kernel.h>
     99 #include <sys/exec.h>
    100 #include <sys/malloc.h>
    101 #include <sys/mbuf.h>
    102 #include <sys/mman.h>
    103 #include <sys/mount.h>
    104 #include <sys/resource.h>
    105 #include <sys/resourcevar.h>
    106 #include <sys/signal.h>
    107 #include <sys/signalvar.h>
    108 #include <sys/socket.h>
    109 #include <sys/vnode.h>
    110 #include <sys/uio.h>
    111 #include <sys/wait.h>
    112 #include <sys/utsname.h>
    113 #include <sys/unistd.h>
    114 #include <sys/ipc.h>
    115 
    116 #include <sys/syscallargs.h>
    117 
    118 #include <compat/ultrix/ultrix_syscall.h>
    119 #include <compat/ultrix/ultrix_syscallargs.h>
    120 #include <compat/common/compat_util.h>
    121 
    122 #include <netinet/in.h>
    123 
    124 #include <miscfs/specfs/specdev.h>
    125 
    126 #include <nfs/rpcv2.h>
    127 #include <nfs/nfsproto.h>
    128 #include <nfs/nfs.h>
    129 
    130 #include <vm/vm.h>
    131 
    132 #include <sys/conf.h>					/* iszerodev() */
    133 #include <sys/socketvar.h>				/* sosetopt() */
    134 
    135 extern struct sysent ultrix_sysent[];
    136 extern char *ultrix_syscallnames[];
    137 
    138 /*
    139  * Select the appropriate setregs callback for the target architecture.
    140  */
    141 #ifdef mips
    142 #include <machine/ecoff_machdep.h>
    143 #define ULTRIX_EXEC_SETREGS cpu_exec_ecoff_setregs
    144 #endif /* mips */
    145 
    146 #ifdef vax
    147 #define ULTRIX_EXEC_SETREGS setregs
    148 #endif /* mips */
    149 
    150 
    151 extern void ULTRIX_EXEC_SETREGS __P((struct proc *, struct exec_package *,
    152 					u_long, register_t *));
    153 extern char sigcode[], esigcode[];
    154 
    155 struct emul emul_ultrix = {
    156 	"ultrix",
    157 	NULL,
    158 	sendsig,
    159 	ULTRIX_SYS_syscall,
    160 	ULTRIX_SYS_MAXSYSCALL,
    161 	ultrix_sysent,
    162 	ultrix_syscallnames,
    163 	0,
    164 	copyargs,
    165 	ULTRIX_EXEC_SETREGS,
    166 	sigcode,
    167 	esigcode,
    168 };
    169 
    170 #define GSI_PROG_ENV 1
    171 
    172 int
    173 ultrix_sys_getsysinfo(p, v, retval)
    174 	struct proc *p;
    175 	void *v;
    176 	register_t *retval;
    177 {
    178 	struct ultrix_sys_getsysinfo_args *uap = v;
    179 	static short progenv = 0;
    180 
    181 	switch (SCARG(uap, op)) {
    182 		/* operations implemented: */
    183 	case GSI_PROG_ENV:
    184 		if (SCARG(uap, nbytes) < sizeof(short))
    185 			return EINVAL;
    186 		*retval = 1;
    187 		return (copyout(&progenv, SCARG(uap, buffer), sizeof(short)));
    188 	default:
    189 		*retval = 0; /* info unavail */
    190 		return 0;
    191 	}
    192 }
    193 
    194 int
    195 ultrix_sys_setsysinfo(p, v, retval)
    196 	struct proc *p;
    197 	void *v;
    198 	register_t *retval;
    199 {
    200 
    201 #ifdef notyet
    202 	struct ultrix_sys_setsysinfo_args *uap = v;
    203 #endif
    204 
    205 	*retval = 0;
    206 	return 0;
    207 }
    208 
    209 int
    210 ultrix_sys_waitpid(p, v, retval)
    211 	struct proc *p;
    212 	void *v;
    213 	register_t *retval;
    214 {
    215 	struct ultrix_sys_waitpid_args *uap = v;
    216 	struct sys_wait4_args ua;
    217 
    218 	SCARG(&ua, pid) = SCARG(uap, pid);
    219 	SCARG(&ua, status) = SCARG(uap, status);
    220 	SCARG(&ua, options) = SCARG(uap, options);
    221 	SCARG(&ua, rusage) = 0;
    222 
    223 	return (sys_wait4(p, &ua, retval));
    224 }
    225 
    226 int
    227 ultrix_sys_wait3(p, v, retval)
    228 	struct proc *p;
    229 	void *v;
    230 	register_t *retval;
    231 {
    232 	struct ultrix_sys_wait3_args *uap = v;
    233 	struct sys_wait4_args ua;
    234 
    235 	SCARG(&ua, pid) = -1;
    236 	SCARG(&ua, status) = SCARG(uap, status);
    237 	SCARG(&ua, options) = SCARG(uap, options);
    238 	SCARG(&ua, rusage) = SCARG(uap, rusage);
    239 
    240 	return (sys_wait4(p, &ua, retval));
    241 }
    242 
    243 /*
    244  * Ultrix binaries pass in FD_MAX as the first arg to select().
    245  * On Ultrix, FD_MAX is 4096, which is more than the NetBSD sys_select()
    246  * can handle.
    247  * Since we can't have more than the (native) FD_MAX descriptors open,
    248  * limit nfds to at most FD_MAX.
    249  */
    250 int
    251 ultrix_sys_select(p, v, retval)
    252 	struct proc *p;
    253 	void *v;
    254 	register_t *retval;
    255 {
    256 	struct sys_select_args *uap = v;
    257 	struct timeval atv;
    258 	int error;
    259 
    260 	/* Limit number of FDs selected on to the native maximum */
    261 
    262 	if (SCARG(uap, nd) > FD_SETSIZE)
    263 		SCARG(uap, nd) = FD_SETSIZE;
    264 
    265 	/* Check for negative timeval */
    266 	if (SCARG(uap, tv)) {
    267 		error = copyin((caddr_t)SCARG(uap, tv), (caddr_t)&atv,
    268 			       sizeof(atv));
    269 		if (error)
    270 			goto done;
    271 #ifdef DEBUG
    272 		/* Ultrix clients sometimes give negative timeouts? */
    273 		if (atv.tv_sec < 0 || atv.tv_usec < 0)
    274 			printf("ultrix select( %ld, %ld): negative timeout\n",
    275 			    atv.tv_sec, atv.tv_usec);
    276 		/*tvp = (timeval *)STACKGAPBASE;*/
    277 #endif
    278 
    279 	}
    280 	error = sys_select(p, (void*) uap, retval);
    281 	if (error == EINVAL)
    282 		printf("ultrix select: bad args?\n");
    283 
    284 done:
    285 	return error;
    286 }
    287 
    288 #if defined(NFS)
    289 int
    290 async_daemon(p, v, retval)
    291 	struct proc *p;
    292 	void *v;
    293 	register_t *retval;
    294 {
    295 	struct sys_nfssvc_args ouap;
    296 
    297 	SCARG(&ouap, flag) = NFSSVC_BIOD;
    298 	SCARG(&ouap, argp) = NULL;
    299 
    300 	return (sys_nfssvc(p, &ouap, retval));
    301 }
    302 #endif /* NFS */
    303 
    304 
    305 #define	SUN__MAP_NEW	0x80000000	/* if not, old mmap & cannot handle */
    306 
    307 int
    308 ultrix_sys_mmap(p, v, retval)
    309 	register struct proc *p;
    310 	void *v;
    311 	register_t *retval;
    312 {
    313 	register struct ultrix_sys_mmap_args *uap = v;
    314 	struct sys_mmap_args ouap;
    315 	register struct filedesc *fdp;
    316 	register struct file *fp;
    317 	register struct vnode *vp;
    318 
    319 	/*
    320 	 * Verify the arguments.
    321 	 */
    322 	if (SCARG(uap, prot) & ~(PROT_READ|PROT_WRITE|PROT_EXEC))
    323 		return (EINVAL);			/* XXX still needed? */
    324 
    325 	if ((SCARG(uap, flags) & SUN__MAP_NEW) == 0)
    326 		return (EINVAL);
    327 
    328 	SCARG(&ouap, flags) = SCARG(uap, flags) & ~SUN__MAP_NEW;
    329 	SCARG(&ouap, addr) = SCARG(uap, addr);
    330 
    331 	if ((SCARG(&ouap, flags) & MAP_FIXED) == 0 &&
    332 	    SCARG(&ouap, addr) != 0 &&
    333 	    SCARG(&ouap, addr) < (caddr_t)round_page(p->p_vmspace->vm_daddr+MAXDSIZ))
    334 		SCARG(&ouap, addr) = (caddr_t)round_page(p->p_vmspace->vm_daddr+MAXDSIZ);
    335 
    336 	SCARG(&ouap, len) = SCARG(uap, len);
    337 	SCARG(&ouap, prot) = SCARG(uap, prot);
    338 	SCARG(&ouap, fd) = SCARG(uap, fd);
    339 	SCARG(&ouap, pos) = SCARG(uap, pos);
    340 
    341 	/*
    342 	 * Special case: if fd refers to /dev/zero, map as MAP_ANON.  (XXX)
    343 	 */
    344 	fdp = p->p_fd;
    345 	if ((unsigned)SCARG(&ouap, fd) < fdp->fd_nfiles &&		/*XXX*/
    346 	    (fp = fdp->fd_ofiles[SCARG(&ouap, fd)]) != NULL &&		/*XXX*/
    347 	    fp->f_type == DTYPE_VNODE &&				/*XXX*/
    348 	    (vp = (struct vnode *)fp->f_data)->v_type == VCHR &&	/*XXX*/
    349 	    iszerodev(vp->v_rdev)) {					/*XXX*/
    350 		SCARG(&ouap, flags) |= MAP_ANON;
    351 		SCARG(&ouap, fd) = -1;
    352 	}
    353 
    354 	return (sys_mmap(p, &ouap, retval));
    355 }
    356 
    357 int
    358 ultrix_sys_setsockopt(p, v, retval)
    359 	struct proc *p;
    360 	void *v;
    361 	register_t *retval;
    362 {
    363 	register struct ultrix_sys_setsockopt_args *uap = v;
    364 	struct file *fp;
    365 	struct mbuf *m = NULL;
    366 	int error;
    367 
    368 	if ((error = getsock(p->p_fd, SCARG(uap, s), &fp))  != 0)
    369 		return (error);
    370 #define	SO_DONTLINGER (~SO_LINGER)
    371 	if (SCARG(uap, name) == SO_DONTLINGER) {
    372 		m = m_get(M_WAIT, MT_SOOPTS);
    373 		mtod(m, struct linger *)->l_onoff = 0;
    374 		m->m_len = sizeof(struct linger);
    375 		return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
    376 		    SO_LINGER, m));
    377 	}
    378 	if (SCARG(uap, level) == IPPROTO_IP) {
    379 #define		EMUL_IP_MULTICAST_IF		2
    380 #define		EMUL_IP_MULTICAST_TTL		3
    381 #define		EMUL_IP_MULTICAST_LOOP		4
    382 #define		EMUL_IP_ADD_MEMBERSHIP		5
    383 #define		EMUL_IP_DROP_MEMBERSHIP	6
    384 		static int ipoptxlat[] = {
    385 			IP_MULTICAST_IF,
    386 			IP_MULTICAST_TTL,
    387 			IP_MULTICAST_LOOP,
    388 			IP_ADD_MEMBERSHIP,
    389 			IP_DROP_MEMBERSHIP
    390 		};
    391 		if (SCARG(uap, name) >= EMUL_IP_MULTICAST_IF &&
    392 		    SCARG(uap, name) <= EMUL_IP_DROP_MEMBERSHIP) {
    393 			SCARG(uap, name) =
    394 			    ipoptxlat[SCARG(uap, name) - EMUL_IP_MULTICAST_IF];
    395 		}
    396 	}
    397 	if (SCARG(uap, valsize) > MLEN)
    398 		return (EINVAL);
    399 	if (SCARG(uap, val)) {
    400 		m = m_get(M_WAIT, MT_SOOPTS);
    401 		error = copyin(SCARG(uap, val), mtod(m, caddr_t),
    402 		    (u_int)SCARG(uap, valsize));
    403 		if (error) {
    404 			(void) m_free(m);
    405 			return (error);
    406 		}
    407 		m->m_len = SCARG(uap, valsize);
    408 	}
    409 	return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
    410 	    SCARG(uap, name), m));
    411 }
    412 
    413 struct ultrix_utsname {
    414 	char    sysname[9];
    415 	char    nodename[9];
    416 	char    nodeext[65-9];
    417 	char    release[9];
    418 	char    version[9];
    419 	char    machine[9];
    420 };
    421 
    422 int
    423 ultrix_sys_uname(p, v, retval)
    424 	struct proc *p;
    425 	void *v;
    426 	register_t *retval;
    427 {
    428 	struct ultrix_sys_uname_args *uap = v;
    429 	struct ultrix_utsname sut;
    430 	extern char ostype[], machine[], osrelease[];
    431 
    432 	bzero(&sut, sizeof(sut));
    433 
    434 	bcopy(ostype, sut.sysname, sizeof(sut.sysname) - 1);
    435 	bcopy(hostname, sut.nodename, sizeof(sut.nodename));
    436 	sut.nodename[sizeof(sut.nodename)-1] = '\0';
    437 	bcopy(osrelease, sut.release, sizeof(sut.release) - 1);
    438 	bcopy("1", sut.version, sizeof(sut.version) - 1);
    439 	bcopy(machine, sut.machine, sizeof(sut.machine) - 1);
    440 
    441 	return copyout((caddr_t)&sut, (caddr_t)SCARG(uap, name),
    442 	    sizeof(struct ultrix_utsname));
    443 }
    444 
    445 int
    446 ultrix_sys_setpgrp(p, v, retval)
    447 	struct proc *p;
    448 	void *v;
    449 	register_t *retval;
    450 {
    451 	struct ultrix_sys_setpgrp_args *uap = v;
    452 
    453 	/*
    454 	 * difference to our setpgid call is to include backwards
    455 	 * compatibility to pre-setsid() binaries. Do setsid()
    456 	 * instead of setpgid() in those cases where the process
    457 	 * tries to create a new session the old way.
    458 	 */
    459 	if (!SCARG(uap, pgid) &&
    460 	    (!SCARG(uap, pid) || SCARG(uap, pid) == p->p_pid))
    461 		return sys_setsid(p, uap, retval);
    462 	else
    463 		return sys_setpgid(p, uap, retval);
    464 }
    465 
    466 #if defined (NFSSERVER)
    467 int
    468 ultrix_sys_nfssvc(p, v, retval)
    469 	struct proc *p;
    470 	void *v;
    471 	register_t *retval;
    472 {
    473 
    474 #if 0	/* XXX */
    475 	struct ultrix_sys_nfssvc_args *uap = v;
    476 	struct emul *e = p->p_emul;
    477 	struct sys_nfssvc_args outuap;
    478 	struct sockaddr sa;
    479 	int error;
    480 
    481 	bzero(&outuap, sizeof outuap);
    482 	SCARG(&outuap, fd) = SCARG(uap, fd);
    483 	SCARG(&outuap, mskval) = STACKGAPBASE;
    484 	SCARG(&outuap, msklen) = sizeof sa;
    485 	SCARG(&outuap, mtchval) = outuap.mskval + sizeof sa;
    486 	SCARG(&outuap, mtchlen) = sizeof sa;
    487 
    488 	bzero(&sa, sizeof sa);
    489 	if (error = copyout(&sa, SCARG(&outuap, mskval), SCARG(&outuap, msklen)))
    490 		return (error);
    491 	if (error = copyout(&sa, SCARG(&outuap, mtchval), SCARG(&outuap, mtchlen)))
    492 		return (error);
    493 
    494 	return nfssvc(p, &outuap, retval);
    495 #else
    496 	return (ENOSYS);
    497 #endif
    498 }
    499 #endif /* NFSSERVER */
    500 
    501 struct ultrix_ustat {
    502 	daddr_t	f_tfree;	/* total free */
    503 	ino_t	f_tinode;	/* total inodes free */
    504 	char	f_fname[6];	/* filsys name */
    505 	char	f_fpack[6];	/* filsys pack name */
    506 };
    507 
    508 int
    509 ultrix_sys_ustat(p, v, retval)
    510 	struct proc *p;
    511 	void *v;
    512 	register_t *retval;
    513 {
    514 	struct ultrix_sys_ustat_args *uap = v;
    515 	struct ultrix_ustat us;
    516 	int error;
    517 
    518 	bzero(&us, sizeof us);
    519 
    520 	/*
    521 	 * XXX: should set f_tfree and f_tinode at least
    522 	 * How do we translate dev -> fstat? (and then to ultrix_ustat)
    523 	 */
    524 
    525 	if ((error = copyout(&us, SCARG(uap, buf), sizeof us)) != 0)
    526 		return (error);
    527 	return 0;
    528 }
    529 
    530 int
    531 ultrix_sys_quotactl(p, v, retval)
    532 	struct proc *p;
    533 	void *v;
    534 	register_t *retval;
    535 {
    536 
    537 #ifdef notyet
    538 	struct ultrix_sys_quotactl_args *uap = v;
    539 #endif
    540 
    541 	return EINVAL;
    542 }
    543 
    544 int
    545 ultrix_sys_vhangup(p, v, retval)
    546 	struct proc *p;
    547 	void *v;
    548 	register_t *retval;
    549 {
    550 
    551 	return 0;
    552 }
    553 
    554 int
    555 ultrix_sys_exportfs(p, v, retval)
    556 	struct proc *p;
    557 	void *v;
    558 	register_t *retval;
    559 {
    560 #ifdef notyet
    561 	struct ultrix_sys_exportfs_args *uap = v;
    562 #endif
    563 
    564 	/*
    565 	 * XXX: should perhaps translate into a mount(2)
    566 	 * with MOUNT_EXPORT?
    567 	 */
    568 	return 0;
    569 }
    570 
    571 int
    572 ultrix_sys_sigpending(p, v, retval)
    573 	struct proc *p;
    574 	void *v;
    575 	register_t *retval;
    576 {
    577 	struct ultrix_sys_sigpending_args *uap = v;
    578 	int mask = p->p_siglist & p->p_sigmask;
    579 
    580 	return (copyout((caddr_t)&mask, (caddr_t)SCARG(uap, mask), sizeof(int)));
    581 }
    582 
    583 int
    584 ultrix_sys_sigcleanup(p, v, retval)
    585 	struct proc *p;
    586 	void *v;
    587 	register_t *retval;
    588 {
    589 	struct ultrix_sys_sigcleanup_args *uap = v;
    590 
    591 	return sys_sigreturn(p, (struct sys_sigreturn_args *)uap, retval);
    592 }
    593 
    594 int
    595 ultrix_sys_sigreturn(p, v, retval)
    596 	struct proc *p;
    597 	void *v;
    598 	register_t *retval;
    599 {
    600 	struct ultrix_sys_sigcleanup_args *uap = v;
    601 
    602 #ifdef DEBUG
    603 	printf("ultrix sigreturn\n");
    604 #endif
    605 	return sys_sigreturn(p, (struct sys_sigreturn_args  *)uap, retval);
    606 }
    607 
    608 int
    609 ultrix_sys_shmsys(p, v, retval)
    610 	struct proc *p;
    611 	void *v;
    612 	register_t *retval;
    613 {
    614 
    615 #ifdef SYSVSHM
    616 
    617 	/* Ultrix SVSHM weirndess: */
    618 	struct ultrix_sys_shmsys_args *uap = v;
    619 	struct sys_shmat_args shmat_args;
    620 	struct sys_shmctl_args shmctl_args;
    621 	struct sys_shmdt_args shmdt_args;
    622 	struct sys_shmget_args shmget_args;
    623 
    624 
    625 	switch (SCARG(uap, shmop)) {
    626 	case 0:						/* Ultrix shmat() */
    627 		SCARG(&shmat_args, shmid) = SCARG(uap, a2);
    628 		SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a3);
    629 		SCARG(&shmat_args, shmflg) = SCARG(uap, a4);
    630 		return (sys_shmat(p, &shmat_args, retval));
    631 
    632 	case 1:						/* Ultrix shmctl() */
    633 		SCARG(&shmctl_args, shmid) = SCARG(uap, a2);
    634 		SCARG(&shmctl_args, cmd) = SCARG(uap, a3);
    635 		SCARG(&shmctl_args, buf) = (struct shmid_ds *)SCARG(uap, a4);
    636 		return (sys_shmctl(p, &shmctl_args, retval));
    637 
    638 	case 2:						/* Ultrix shmdt() */
    639 		SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a2);
    640 		return (sys_shmdt(p, &shmdt_args, retval));
    641 
    642 	case 3:						/* Ultrix shmget() */
    643 		SCARG(&shmget_args, key) = SCARG(uap, a2);
    644 		SCARG(&shmget_args, size) = SCARG(uap, a3);
    645 		SCARG(&shmget_args, shmflg) = SCARG(uap, a4)
    646 		    & (IPC_CREAT|IPC_EXCL|IPC_NOWAIT);
    647 		return (sys_shmget(p, &shmget_args, retval));
    648 
    649 	default:
    650 		return (EINVAL);
    651 	}
    652 #else
    653 	return (EOPNOTSUPP);
    654 #endif	/* SYSVSHM */
    655 }
    656