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