1 /* $NetBSD: ultrix_misc.c,v 1.38 1997/10/19 00:15:31 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 Jonathan Stone 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 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 83 84 __KERNEL_RCSID(0, "$NetBSD: ultrix_misc.c,v 1.38 1997/10/19 00:15:31 jonathan Exp $"); 85 86 /* 87 * SunOS compatibility module. 88 * 89 * SunOS system calls that are implemented differently in BSD are 90 * handled here. 91 */ 92 93 #include <sys/param.h> 94 #include <sys/systm.h> 95 #include <sys/namei.h> 96 #include <sys/dirent.h> 97 #include <sys/proc.h> 98 #include <sys/file.h> 99 #include <sys/filedesc.h> 100 /*#include <sys/stat.h>*/ 101 /*#include <sys/ioctl.h>*/ 102 #include <sys/kernel.h> 103 #include <sys/exec.h> 104 #include <sys/malloc.h> 105 #include <sys/mbuf.h> 106 #include <sys/mman.h> 107 #include <sys/mount.h> 108 #include <sys/resource.h> 109 #include <sys/resourcevar.h> 110 #include <sys/signal.h> 111 #include <sys/signalvar.h> 112 #include <sys/socket.h> 113 #include <sys/vnode.h> 114 #include <sys/uio.h> 115 #include <sys/wait.h> 116 #include <sys/utsname.h> 117 #include <sys/unistd.h> 118 #include <sys/ipc.h> 119 120 #include <sys/syscallargs.h> 121 122 #include <compat/ultrix/ultrix_syscall.h> 123 #include <compat/ultrix/ultrix_syscallargs.h> 124 #include <compat/common/compat_util.h> 125 126 #include <netinet/in.h> 127 128 #include <miscfs/specfs/specdev.h> 129 130 #include <nfs/rpcv2.h> 131 #include <nfs/nfsproto.h> 132 #include <nfs/nfs.h> 133 134 #include <vm/vm.h> /* pmap declarations */ 135 136 #include <sys/conf.h> /* iszerodev() */ 137 #include <sys/socketvar.h> /* sosetopt() */ 138 139 140 extern struct sysent ultrix_sysent[]; 141 extern char *ultrix_syscallnames[]; 142 143 144 /* 145 * Select the appropriate setregs callback for the target architecture. 146 */ 147 #ifdef mips 148 #include <machine/ecoff_machdep.h> 149 #define ULTRIX_EXEC_SETREGS cpu_exec_ecoff_setregs 150 #endif /* mips */ 151 152 #ifdef vax 153 #define ULTRIX_EXEC_SETREGS setregs 154 #endif /* mips */ 155 156 157 extern void ULTRIX_EXEC_SETREGS __P((struct proc *, struct exec_package *, 158 u_long)); 159 extern char sigcode[], esigcode[]; 160 161 struct emul emul_ultrix = { 162 "ultrix", 163 NULL, 164 sendsig, 165 ULTRIX_SYS_syscall, 166 ULTRIX_SYS_MAXSYSCALL, 167 ultrix_sysent, 168 ultrix_syscallnames, 169 0, 170 copyargs, 171 ULTRIX_EXEC_SETREGS, 172 sigcode, 173 esigcode, 174 }; 175 176 #define GSI_PROG_ENV 1 177 178 int 179 ultrix_sys_getsysinfo(p, v, retval) 180 struct proc *p; 181 void *v; 182 register_t *retval; 183 { 184 struct ultrix_sys_getsysinfo_args *uap = v; 185 static short progenv = 0; 186 187 switch (SCARG(uap, op)) { 188 /* operations implemented: */ 189 case GSI_PROG_ENV: 190 if (SCARG(uap, nbytes) < sizeof(short)) 191 return EINVAL; 192 *retval = 1; 193 return (copyout(&progenv, SCARG(uap, buffer), sizeof(short))); 194 default: 195 *retval = 0; /* info unavail */ 196 return 0; 197 } 198 } 199 200 int 201 ultrix_sys_setsysinfo(p, v, retval) 202 struct proc *p; 203 void *v; 204 register_t *retval; 205 { 206 207 #ifdef notyet 208 struct ultrix_sys_setsysinfo_args *uap = v; 209 #endif 210 211 *retval = 0; 212 return 0; 213 } 214 215 int 216 ultrix_sys_waitpid(p, v, retval) 217 struct proc *p; 218 void *v; 219 register_t *retval; 220 { 221 struct ultrix_sys_waitpid_args *uap = v; 222 struct sys_wait4_args ua; 223 224 SCARG(&ua, pid) = SCARG(uap, pid); 225 SCARG(&ua, status) = SCARG(uap, status); 226 SCARG(&ua, options) = SCARG(uap, options); 227 SCARG(&ua, rusage) = 0; 228 229 return (sys_wait4(p, &ua, retval)); 230 } 231 232 int 233 ultrix_sys_wait3(p, v, retval) 234 struct proc *p; 235 void *v; 236 register_t *retval; 237 { 238 struct ultrix_sys_wait3_args *uap = v; 239 struct sys_wait4_args ua; 240 241 SCARG(&ua, pid) = -1; 242 SCARG(&ua, status) = SCARG(uap, status); 243 SCARG(&ua, options) = SCARG(uap, options); 244 SCARG(&ua, rusage) = SCARG(uap, rusage); 245 246 return (sys_wait4(p, &ua, retval)); 247 } 248 249 /* 250 * Ultrix binaries pass in FD_MAX as the first arg to select(). 251 * On Ultrix, FD_MAX is 4096, which is more than the NetBSD sys_select() 252 * can handle. 253 * Since we can't have more than the (native) FD_MAX descriptors open, 254 * limit nfds to at most FD_MAX. 255 */ 256 int 257 ultrix_sys_select(p, v, retval) 258 struct proc *p; 259 void *v; 260 register_t *retval; 261 { 262 struct sys_select_args *uap = v; 263 struct timeval atv; 264 int error; 265 266 /* Limit number of FDs selected on to the native maximum */ 267 268 if (SCARG(uap, nd) > FD_SETSIZE) 269 SCARG(uap, nd) = FD_SETSIZE; 270 271 /* Check for negative timeval */ 272 if (SCARG(uap, tv)) { 273 error = copyin((caddr_t)SCARG(uap, tv), (caddr_t)&atv, 274 sizeof(atv)); 275 if (error) 276 goto done; 277 #ifdef DEBUG 278 /* Ultrix clients sometimes give negative timeouts? */ 279 if (atv.tv_sec < 0 || atv.tv_usec < 0) 280 printf("ultrix select( %ld, %ld): negative timeout\n", 281 atv.tv_sec, atv.tv_usec); 282 /*tvp = (timeval *)STACKGAPBASE;*/ 283 #endif 284 285 } 286 error = sys_select(p, (void*) uap, retval); 287 if (error == EINVAL) 288 printf("ultrix select: bad args?\n"); 289 290 done: 291 return error; 292 } 293 294 #if defined(NFS) 295 int 296 async_daemon(p, v, retval) 297 struct proc *p; 298 void *v; 299 register_t *retval; 300 { 301 struct sys_nfssvc_args ouap; 302 303 SCARG(&ouap, flag) = NFSSVC_BIOD; 304 SCARG(&ouap, argp) = NULL; 305 306 return (sys_nfssvc(p, &ouap, retval)); 307 } 308 #endif /* NFS */ 309 310 311 #define SUN__MAP_NEW 0x80000000 /* if not, old mmap & cannot handle */ 312 313 int 314 ultrix_sys_mmap(p, v, retval) 315 register struct proc *p; 316 void *v; 317 register_t *retval; 318 { 319 register struct ultrix_sys_mmap_args *uap = v; 320 struct sys_mmap_args ouap; 321 register struct filedesc *fdp; 322 register struct file *fp; 323 register struct vnode *vp; 324 325 /* 326 * Verify the arguments. 327 */ 328 if (SCARG(uap, prot) & ~(PROT_READ|PROT_WRITE|PROT_EXEC)) 329 return (EINVAL); /* XXX still needed? */ 330 331 if ((SCARG(uap, flags) & SUN__MAP_NEW) == 0) 332 return (EINVAL); 333 334 SCARG(&ouap, flags) = SCARG(uap, flags) & ~SUN__MAP_NEW; 335 SCARG(&ouap, addr) = SCARG(uap, addr); 336 337 if ((SCARG(&ouap, flags) & MAP_FIXED) == 0 && 338 SCARG(&ouap, addr) != 0 && 339 SCARG(&ouap, addr) < (void *)round_page(p->p_vmspace->vm_daddr+MAXDSIZ)) 340 SCARG(&ouap, addr) = (void *)round_page(p->p_vmspace->vm_daddr+MAXDSIZ); 341 342 SCARG(&ouap, len) = SCARG(uap, len); 343 SCARG(&ouap, prot) = SCARG(uap, prot); 344 SCARG(&ouap, fd) = SCARG(uap, fd); 345 SCARG(&ouap, pos) = SCARG(uap, pos); 346 347 /* 348 * Special case: if fd refers to /dev/zero, map as MAP_ANON. (XXX) 349 */ 350 fdp = p->p_fd; 351 if ((unsigned)SCARG(&ouap, fd) < fdp->fd_nfiles && /*XXX*/ 352 (fp = fdp->fd_ofiles[SCARG(&ouap, fd)]) != NULL && /*XXX*/ 353 fp->f_type == DTYPE_VNODE && /*XXX*/ 354 (vp = (struct vnode *)fp->f_data)->v_type == VCHR && /*XXX*/ 355 iszerodev(vp->v_rdev)) { /*XXX*/ 356 SCARG(&ouap, flags) |= MAP_ANON; 357 SCARG(&ouap, fd) = -1; 358 } 359 360 return (sys_mmap(p, &ouap, retval)); 361 } 362 363 int 364 ultrix_sys_setsockopt(p, v, retval) 365 struct proc *p; 366 void *v; 367 register_t *retval; 368 { 369 register struct ultrix_sys_setsockopt_args *uap = v; 370 struct file *fp; 371 struct mbuf *m = NULL; 372 int error; 373 374 if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0) 375 return (error); 376 #define SO_DONTLINGER (~SO_LINGER) 377 if (SCARG(uap, name) == SO_DONTLINGER) { 378 m = m_get(M_WAIT, MT_SOOPTS); 379 mtod(m, struct linger *)->l_onoff = 0; 380 m->m_len = sizeof(struct linger); 381 return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level), 382 SO_LINGER, m)); 383 } 384 if (SCARG(uap, level) == IPPROTO_IP) { 385 #define EMUL_IP_MULTICAST_IF 2 386 #define EMUL_IP_MULTICAST_TTL 3 387 #define EMUL_IP_MULTICAST_LOOP 4 388 #define EMUL_IP_ADD_MEMBERSHIP 5 389 #define EMUL_IP_DROP_MEMBERSHIP 6 390 static int ipoptxlat[] = { 391 IP_MULTICAST_IF, 392 IP_MULTICAST_TTL, 393 IP_MULTICAST_LOOP, 394 IP_ADD_MEMBERSHIP, 395 IP_DROP_MEMBERSHIP 396 }; 397 if (SCARG(uap, name) >= EMUL_IP_MULTICAST_IF && 398 SCARG(uap, name) <= EMUL_IP_DROP_MEMBERSHIP) { 399 SCARG(uap, name) = 400 ipoptxlat[SCARG(uap, name) - EMUL_IP_MULTICAST_IF]; 401 } 402 } 403 if (SCARG(uap, valsize) > MLEN) 404 return (EINVAL); 405 if (SCARG(uap, val)) { 406 m = m_get(M_WAIT, MT_SOOPTS); 407 error = copyin(SCARG(uap, val), mtod(m, caddr_t), 408 (u_int)SCARG(uap, valsize)); 409 if (error) { 410 (void) m_free(m); 411 return (error); 412 } 413 m->m_len = SCARG(uap, valsize); 414 } 415 return (sosetopt((struct socket *)fp->f_data, SCARG(uap, level), 416 SCARG(uap, name), m)); 417 } 418 419 struct ultrix_utsname { 420 char sysname[9]; 421 char nodename[9]; 422 char nodeext[65-9]; 423 char release[9]; 424 char version[9]; 425 char machine[9]; 426 }; 427 428 int 429 ultrix_sys_uname(p, v, retval) 430 struct proc *p; 431 void *v; 432 register_t *retval; 433 { 434 struct ultrix_sys_uname_args *uap = v; 435 struct ultrix_utsname sut; 436 extern char ostype[], machine[], osrelease[]; 437 438 bzero(&sut, sizeof(sut)); 439 440 bcopy(ostype, sut.sysname, sizeof(sut.sysname) - 1); 441 bcopy(hostname, sut.nodename, sizeof(sut.nodename)); 442 sut.nodename[sizeof(sut.nodename)-1] = '\0'; 443 bcopy(osrelease, sut.release, sizeof(sut.release) - 1); 444 bcopy("1", sut.version, sizeof(sut.version) - 1); 445 bcopy(machine, sut.machine, sizeof(sut.machine) - 1); 446 447 return copyout((caddr_t)&sut, (caddr_t)SCARG(uap, name), 448 sizeof(struct ultrix_utsname)); 449 } 450 451 int 452 ultrix_sys_setpgrp(p, v, retval) 453 struct proc *p; 454 void *v; 455 register_t *retval; 456 { 457 struct ultrix_sys_setpgrp_args *uap = v; 458 459 /* 460 * difference to our setpgid call is to include backwards 461 * compatibility to pre-setsid() binaries. Do setsid() 462 * instead of setpgid() in those cases where the process 463 * tries to create a new session the old way. 464 */ 465 if (!SCARG(uap, pgid) && 466 (!SCARG(uap, pid) || SCARG(uap, pid) == p->p_pid)) 467 return sys_setsid(p, uap, retval); 468 else 469 return sys_setpgid(p, uap, retval); 470 } 471 472 #if defined (NFSSERVER) 473 int 474 ultrix_sys_nfssvc(p, v, retval) 475 struct proc *p; 476 void *v; 477 register_t *retval; 478 { 479 480 #if 0 /* XXX */ 481 struct ultrix_sys_nfssvc_args *uap = v; 482 struct emul *e = p->p_emul; 483 struct sys_nfssvc_args outuap; 484 struct sockaddr sa; 485 int error; 486 487 bzero(&outuap, sizeof outuap); 488 SCARG(&outuap, fd) = SCARG(uap, fd); 489 SCARG(&outuap, mskval) = STACKGAPBASE; 490 SCARG(&outuap, msklen) = sizeof sa; 491 SCARG(&outuap, mtchval) = outuap.mskval + sizeof sa; 492 SCARG(&outuap, mtchlen) = sizeof sa; 493 494 bzero(&sa, sizeof sa); 495 if (error = copyout(&sa, SCARG(&outuap, mskval), SCARG(&outuap, msklen))) 496 return (error); 497 if (error = copyout(&sa, SCARG(&outuap, mtchval), SCARG(&outuap, mtchlen))) 498 return (error); 499 500 return nfssvc(p, &outuap, retval); 501 #else 502 return (ENOSYS); 503 #endif 504 } 505 #endif /* NFSSERVER */ 506 507 struct ultrix_ustat { 508 daddr_t f_tfree; /* total free */ 509 ino_t f_tinode; /* total inodes free */ 510 char f_fname[6]; /* filsys name */ 511 char f_fpack[6]; /* filsys pack name */ 512 }; 513 514 int 515 ultrix_sys_ustat(p, v, retval) 516 struct proc *p; 517 void *v; 518 register_t *retval; 519 { 520 struct ultrix_sys_ustat_args *uap = v; 521 struct ultrix_ustat us; 522 int error; 523 524 bzero(&us, sizeof us); 525 526 /* 527 * XXX: should set f_tfree and f_tinode at least 528 * How do we translate dev -> fstat? (and then to ultrix_ustat) 529 */ 530 531 if ((error = copyout(&us, SCARG(uap, buf), sizeof us)) != 0) 532 return (error); 533 return 0; 534 } 535 536 int 537 ultrix_sys_quotactl(p, v, retval) 538 struct proc *p; 539 void *v; 540 register_t *retval; 541 { 542 543 #ifdef notyet 544 struct ultrix_sys_quotactl_args *uap = v; 545 #endif 546 547 return EINVAL; 548 } 549 550 int 551 ultrix_sys_vhangup(p, v, retval) 552 struct proc *p; 553 void *v; 554 register_t *retval; 555 { 556 557 return 0; 558 } 559 560 561 /* 562 * RISC Ultrix cache control syscalls 563 */ 564 #ifdef __mips 565 int 566 ultrix_sys_cacheflush(p, v, retval) 567 register struct proc *p; 568 void *v; 569 register_t *retval; 570 { 571 register struct ultrix_sys_cacheflush_args /* { 572 syscallarg(void *) addr; 573 syscallarg(int) nbytes; 574 syscallarg(int) flag; 575 } */ *uap = v; 576 register vm_offset_t va = (vm_offset_t)SCARG(uap, addr); 577 register int nbytes = SCARG(uap, nbytes); 578 register int whichcache = SCARG(uap, whichcache); 579 580 return (mips_user_cacheflush(p, va, nbytes, whichcache)); 581 } 582 583 584 int 585 ultrix_sys_cachectl(p, v, retval) 586 register struct proc *p; 587 void *v; 588 register_t *retval; 589 { 590 register struct ultrix_sys_cachectl_args /* { 591 syscallarg(void *) addr; 592 syscallarg(int) nbytes; 593 syscallarg(int) cacheop; 594 } */ *uap = v; 595 register vm_offset_t va = (vm_offset_t)SCARG(uap, addr); 596 register int nbytes = SCARG(uap, nbytes); 597 register int cacheop = SCARG(uap, cacheop); 598 599 return mips_user_cachectl(p, va, nbytes, cacheop); 600 } 601 602 #endif /* __mips */ 603 604 605 int 606 ultrix_sys_exportfs(p, v, retval) 607 struct proc *p; 608 void *v; 609 register_t *retval; 610 { 611 #ifdef notyet 612 struct ultrix_sys_exportfs_args *uap = v; 613 #endif 614 615 /* 616 * XXX: should perhaps translate into a mount(2) 617 * with MOUNT_EXPORT? 618 */ 619 return 0; 620 } 621 622 int 623 ultrix_sys_sigpending(p, v, retval) 624 struct proc *p; 625 void *v; 626 register_t *retval; 627 { 628 struct ultrix_sys_sigpending_args *uap = v; 629 int mask = p->p_siglist & p->p_sigmask; 630 631 return (copyout((caddr_t)&mask, (caddr_t)SCARG(uap, mask), sizeof(int))); 632 } 633 634 int 635 ultrix_sys_sigcleanup(p, v, retval) 636 struct proc *p; 637 void *v; 638 register_t *retval; 639 { 640 struct ultrix_sys_sigcleanup_args *uap = v; 641 642 return sys_sigreturn(p, (struct sys_sigreturn_args *)uap, retval); 643 } 644 645 646 int 647 ultrix_sys_shmsys(p, v, retval) 648 struct proc *p; 649 void *v; 650 register_t *retval; 651 { 652 653 #ifdef SYSVSHM 654 655 /* Ultrix SVSHM weirndess: */ 656 struct ultrix_sys_shmsys_args *uap = v; 657 struct sys_shmat_args shmat_args; 658 struct sys_shmctl_args shmctl_args; 659 struct sys_shmdt_args shmdt_args; 660 struct sys_shmget_args shmget_args; 661 662 663 switch (SCARG(uap, shmop)) { 664 case 0: /* Ultrix shmat() */ 665 SCARG(&shmat_args, shmid) = SCARG(uap, a2); 666 SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a3); 667 SCARG(&shmat_args, shmflg) = SCARG(uap, a4); 668 return (sys_shmat(p, &shmat_args, retval)); 669 670 case 1: /* Ultrix shmctl() */ 671 SCARG(&shmctl_args, shmid) = SCARG(uap, a2); 672 SCARG(&shmctl_args, cmd) = SCARG(uap, a3); 673 SCARG(&shmctl_args, buf) = (struct shmid_ds *)SCARG(uap, a4); 674 return (sys_shmctl(p, &shmctl_args, retval)); 675 676 case 2: /* Ultrix shmdt() */ 677 SCARG(&shmat_args, shmaddr) = (void *)SCARG(uap, a2); 678 return (sys_shmdt(p, &shmdt_args, retval)); 679 680 case 3: /* Ultrix shmget() */ 681 SCARG(&shmget_args, key) = SCARG(uap, a2); 682 SCARG(&shmget_args, size) = SCARG(uap, a3); 683 SCARG(&shmget_args, shmflg) = SCARG(uap, a4) 684 & (IPC_CREAT|IPC_EXCL|IPC_NOWAIT); 685 return (sys_shmget(p, &shmget_args, retval)); 686 687 default: 688 return (EINVAL); 689 } 690 #else 691 return (EOPNOTSUPP); 692 #endif /* SYSVSHM */ 693 } 694