sunos_misc.c revision 1.108.2.9 1 /* $NetBSD: sunos_misc.c,v 1.108.2.9 2002/06/21 05:52:33 gmcgarry Exp $ */
2
3 /*
4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley.
10 *
11 * All advertising materials mentioning features or use of this software
12 * must display the following acknowledgement:
13 * This product includes software developed by the University of
14 * California, Lawrence Berkeley Laboratory.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
18 * are met:
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. All advertising materials mentioning features or use of this software
25 * must display the following acknowledgement:
26 * This product includes software developed by the University of
27 * California, Berkeley and its contributors.
28 * 4. Neither the name of the University nor the names of its contributors
29 * may be used to endorse or promote products derived from this software
30 * without specific prior written permission.
31 *
32 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * SUCH DAMAGE.
43 *
44 * @(#)sunos_misc.c 8.1 (Berkeley) 6/18/93
45 *
46 * Header: sunos_misc.c,v 1.16 93/04/07 02:46:27 torek Exp
47 */
48
49 /*
50 * SunOS compatibility module.
51 *
52 * SunOS system calls that are implemented differently in BSD are
53 * handled here.
54 */
55
56 #include <sys/cdefs.h>
57 __KERNEL_RCSID(0, "$NetBSD: sunos_misc.c,v 1.108.2.9 2002/06/21 05:52:33 gmcgarry Exp $");
58
59 #if defined(_KERNEL_OPT)
60 #include "opt_nfsserver.h"
61 #include "fs_nfs.h"
62 #endif
63
64 #include <sys/param.h>
65 #include <sys/systm.h>
66 #include <sys/namei.h>
67 #include <sys/proc.h>
68 #include <sys/lwp.h>
69 #include <sys/dirent.h>
70 #include <sys/file.h>
71 #include <sys/stat.h>
72 #include <sys/filedesc.h>
73 #include <sys/ioctl.h>
74 #include <sys/kernel.h>
75 #include <sys/reboot.h>
76 #include <sys/malloc.h>
77 #include <sys/mbuf.h>
78 #include <sys/mman.h>
79 #include <sys/mount.h>
80 #include <sys/ptrace.h>
81 #include <sys/resource.h>
82 #include <sys/resourcevar.h>
83 #include <sys/signal.h>
84 #include <sys/signalvar.h>
85 #include <sys/socket.h>
86 #include <sys/tty.h>
87 #include <sys/vnode.h>
88 #include <sys/uio.h>
89 #include <sys/wait.h>
90 #include <sys/utsname.h>
91 #include <sys/unistd.h>
92 #include <sys/sa.h>
93 #include <sys/syscallargs.h>
94 #include <sys/conf.h>
95 #include <sys/socketvar.h>
96 #include <sys/exec.h>
97 #include <sys/swap.h>
98
99 #include <compat/sunos/sunos.h>
100 #include <compat/sunos/sunos_syscallargs.h>
101 #include <compat/common/compat_util.h>
102 #include <compat/sunos/sunos_dirent.h>
103
104 #include <netinet/in.h>
105
106 #include <miscfs/specfs/specdev.h>
107
108 #include <nfs/rpcv2.h>
109 #include <nfs/nfsproto.h>
110 #include <nfs/nfs.h>
111 #include <nfs/nfsmount.h>
112
113 static int sunstatfs __P((struct statfs *, caddr_t));
114
115 int
116 sunos_sys_stime(l, v, retval)
117 struct lwp *l;
118 void *v;
119 register_t *retval;
120 {
121 struct sunos_sys_stime_args *uap = v;
122 struct sys_settimeofday_args ap;
123 struct proc *p = l->l_proc;
124 caddr_t sg = stackgap_init(p, 0);
125 struct timeval tv, *sgtvp;
126 int error;
127
128 error = copyin(SCARG(uap, tp), &tv.tv_sec, sizeof(tv.tv_sec));
129 if (error)
130 return error;
131 tv.tv_usec = 0;
132
133 SCARG(&ap, tv) = sgtvp = stackgap_alloc(p, &sg, sizeof(struct timeval));
134 SCARG(&ap, tzp) = NULL;
135
136 error = copyout(&tv, sgtvp, sizeof(struct timeval));
137 if (error)
138 return error;
139
140 return sys_settimeofday(l, &ap, retval);
141 }
142
143 int
144 sunos_sys_wait4(l, v, retval)
145 struct lwp *l;
146 void *v;
147 register_t *retval;
148 {
149 struct sunos_sys_wait4_args *uap = v;
150 if (SCARG(uap, pid) == 0)
151 SCARG(uap, pid) = WAIT_ANY;
152 return (sys_wait4(l, uap, retval));
153 }
154
155 int
156 sunos_sys_creat(l, v, retval)
157 struct lwp *l;
158 void *v;
159 register_t *retval;
160 {
161 struct sunos_sys_creat_args *uap = v;
162 struct proc *p = l->l_proc;
163 struct sys_open_args ouap;
164
165 caddr_t sg = stackgap_init(p, 0);
166 CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
167
168 SCARG(&ouap, path) = SCARG(uap, path);
169 SCARG(&ouap, flags) = O_WRONLY | O_CREAT | O_TRUNC;
170 SCARG(&ouap, mode) = SCARG(uap, mode);
171
172 return (sys_open(l, &ouap, retval));
173 }
174
175 int
176 sunos_sys_access(l, v, retval)
177 struct lwp *l;
178 void *v;
179 register_t *retval;
180 {
181 struct sunos_sys_access_args *uap = v;
182 struct proc *p = l->l_proc;
183 caddr_t sg = stackgap_init(p, 0);
184 CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
185
186 return (sys_access(l, uap, retval));
187 }
188
189 int
190 sunos_sys_stat(l, v, retval)
191 struct lwp *l;
192 void *v;
193 register_t *retval;
194 {
195 struct sunos_sys_stat_args *uap = v;
196 struct proc *p = l->l_proc;
197 caddr_t sg = stackgap_init(p, 0);
198 CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
199
200 return (compat_43_sys_stat(l, uap, retval));
201 }
202
203 int
204 sunos_sys_lstat(l, v, retval)
205 struct lwp *l;
206 void *v;
207 register_t *retval;
208 {
209 struct sunos_sys_lstat_args *uap = v;
210 struct proc *p = l->l_proc;
211 caddr_t sg = stackgap_init(p, 0);
212 CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
213
214 return (compat_43_sys_lstat(l, uap, retval));
215 }
216
217 int
218 sunos_sys_execv(l, v, retval)
219 struct lwp *l;
220 void *v;
221 register_t *retval;
222 {
223 struct sunos_sys_execv_args /* {
224 syscallarg(const char *) path;
225 syscallarg(char **) argv;
226 } */ *uap = v;
227 struct proc *p = l->l_proc;
228 struct sys_execve_args ap;
229 caddr_t sg;
230
231 sg = stackgap_init(p, 0);
232 CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
233
234 SCARG(&ap, path) = SCARG(uap, path);
235 SCARG(&ap, argp) = SCARG(uap, argp);
236 SCARG(&ap, envp) = NULL;
237
238 return (sys_execve(l, &ap, retval));
239 }
240
241 int
242 sunos_sys_execve(l, v, retval)
243 struct lwp *l;
244 void *v;
245 register_t *retval;
246 {
247 struct sunos_sys_execve_args /* {
248 syscallarg(const char *) path;
249 syscallarg(char **) argv;
250 syscallarg(char **) envp;
251 } */ *uap = v;
252 struct sys_execve_args ap;
253 struct proc *p = l->l_proc;
254 caddr_t sg;
255
256 sg = stackgap_init(p, 0);
257 CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
258
259 SCARG(&ap, path) = SCARG(uap, path);
260 SCARG(&ap, argp) = SCARG(uap, argp);
261 SCARG(&ap, envp) = SCARG(uap, envp);
262
263 return (sys_execve(l, &ap, retval));
264 }
265
266 int
267 sunos_sys_omsync(l, v, retval)
268 struct lwp *l;
269 void *v;
270 register_t *retval;
271 {
272 struct sunos_sys_omsync_args *uap = v;
273 struct sys___msync13_args ouap;
274
275 SCARG(&ouap, addr) = SCARG(uap, addr);
276 SCARG(&ouap, len) = SCARG(uap, len);
277 SCARG(&ouap, flags) = SCARG(uap, flags);
278
279 return (sys___msync13(l, &ouap, retval));
280 }
281
282 int
283 sunos_sys_unmount(l, v, retval)
284 struct lwp *l;
285 void *v;
286 register_t *retval;
287 {
288 struct sunos_sys_unmount_args *uap = v;
289 struct sys_unmount_args ouap;
290
291 SCARG(&ouap, path) = SCARG(uap, path);
292 SCARG(&ouap, flags) = 0;
293
294 return (sys_unmount(l, &ouap, retval));
295 }
296
297 /*
298 * Conversion table for SunOS NFS mount flags.
299 */
300 static struct {
301 int sun_flg;
302 int bsd_flg;
303 } sunnfs_flgtab[] = {
304 { SUNNFS_SOFT, NFSMNT_SOFT },
305 { SUNNFS_WSIZE, NFSMNT_WSIZE },
306 { SUNNFS_RSIZE, NFSMNT_RSIZE },
307 { SUNNFS_TIMEO, NFSMNT_TIMEO },
308 { SUNNFS_RETRANS, NFSMNT_RETRANS },
309 { SUNNFS_HOSTNAME, 0 }, /* Ignored */
310 { SUNNFS_INT, NFSMNT_INT },
311 { SUNNFS_NOAC, 0 }, /* Ignored */
312 { SUNNFS_ACREGMIN, 0 }, /* Ignored */
313 { SUNNFS_ACREGMAX, 0 }, /* Ignored */
314 { SUNNFS_ACDIRMIN, 0 }, /* Ignored */
315 { SUNNFS_ACDIRMAX, 0 }, /* Ignored */
316 { SUNNFS_SECURE, 0 }, /* Ignored */
317 { SUNNFS_NOCTO, 0 }, /* Ignored */
318 { SUNNFS_POSIX, 0 } /* Ignored */
319 };
320
321 int
322 sunos_sys_mount(l, v, retval)
323 struct lwp *l;
324 void *v;
325 register_t *retval;
326 {
327 struct sunos_sys_mount_args *uap = v;
328 struct proc *p = l->l_proc;
329 int oflags = SCARG(uap, flags), nflags, error;
330 char fsname[MFSNAMELEN];
331 caddr_t sg = stackgap_init(p, 0);
332
333 if (oflags & (SUNM_NOSUB | SUNM_SYS5))
334 return (EINVAL);
335 if ((oflags & SUNM_NEWTYPE) == 0)
336 return (EINVAL);
337 nflags = 0;
338 if (oflags & SUNM_RDONLY)
339 nflags |= MNT_RDONLY;
340 if (oflags & SUNM_NOSUID)
341 nflags |= MNT_NOSUID;
342 if (oflags & SUNM_REMOUNT)
343 nflags |= MNT_UPDATE;
344 SCARG(uap, flags) = nflags;
345
346 error = copyinstr((caddr_t)SCARG(uap, type), fsname,
347 sizeof fsname, (size_t *)0);
348 if (error)
349 return (error);
350
351 if (strncmp(fsname, "4.2", sizeof fsname) == 0) {
352 SCARG(uap, type) = stackgap_alloc(p, &sg, sizeof("ffs"));
353 error = copyout("ffs", SCARG(uap, type), sizeof("ffs"));
354 if (error)
355 return (error);
356 } else if (strncmp(fsname, "nfs", sizeof fsname) == 0) {
357 struct sunos_nfs_args sna;
358 struct sockaddr_in sain;
359 struct nfs_args na;
360 struct sockaddr sa;
361 int n;
362
363 error = copyin(SCARG(uap, data), &sna, sizeof sna);
364 if (error)
365 return (error);
366 error = copyin(sna.addr, &sain, sizeof sain);
367 if (error)
368 return (error);
369 memcpy(&sa, &sain, sizeof sa);
370 sa.sa_len = sizeof(sain);
371 SCARG(uap, data) = stackgap_alloc(p, &sg, sizeof(na));
372 na.version = NFS_ARGSVERSION;
373 na.addr = stackgap_alloc(p, &sg, sizeof(struct sockaddr));
374 na.addrlen = sizeof(struct sockaddr);
375 na.sotype = SOCK_DGRAM;
376 na.proto = IPPROTO_UDP;
377 na.fh = (void *)sna.fh;
378 na.fhsize = NFSX_V2FH;
379 na.flags = 0;
380 n = sizeof(sunnfs_flgtab) / sizeof(sunnfs_flgtab[0]);
381 while (--n >= 0)
382 if (sna.flags & sunnfs_flgtab[n].sun_flg)
383 na.flags |= sunnfs_flgtab[n].bsd_flg;
384 na.wsize = sna.wsize;
385 na.rsize = sna.rsize;
386 if (na.flags & NFSMNT_RSIZE) {
387 na.flags |= NFSMNT_READDIRSIZE;
388 na.readdirsize = na.rsize;
389 }
390 na.timeo = sna.timeo;
391 na.retrans = sna.retrans;
392 na.hostname = (char *)(u_long)sna.hostname;
393
394 error = copyout(&sa, na.addr, sizeof sa);
395 if (error)
396 return (error);
397 error = copyout(&na, SCARG(uap, data), sizeof na);
398 if (error)
399 return (error);
400 }
401 return (sys_mount(l, (struct sys_mount_args *)uap, retval));
402 }
403
404 #if defined(NFS)
405 int
406 async_daemon(l, v, retval)
407 struct lwp *l;
408 void *v;
409 register_t *retval;
410 {
411 struct sys_nfssvc_args ouap;
412
413 SCARG(&ouap, flag) = NFSSVC_BIOD;
414 SCARG(&ouap, argp) = NULL;
415
416 return (sys_nfssvc(l, &ouap, retval));
417 }
418 #endif /* NFS */
419
420 void native_to_sunos_sigset __P((const sigset_t *, int *));
421 void sunos_to_native_sigset __P((const int, sigset_t *));
422
423 __inline__ void
424 native_to_sunos_sigset(ss, mask)
425 const sigset_t *ss;
426 int *mask;
427 {
428 *mask = ss->__bits[0];
429 }
430
431 __inline__ void
432 sunos_to_native_sigset(mask, ss)
433 const int mask;
434 sigset_t *ss;
435 {
436
437 ss->__bits[0] = mask;
438 ss->__bits[1] = 0;
439 ss->__bits[2] = 0;
440 ss->__bits[3] = 0;
441 }
442
443 int
444 sunos_sys_sigpending(l, v, retval)
445 struct lwp *l;
446 void *v;
447 register_t *retval;
448 {
449 struct sunos_sys_sigpending_args *uap = v;
450 sigset_t ss;
451 int mask;
452
453 sigpending1(l->l_proc, &ss);
454 native_to_sunos_sigset(&ss, &mask);
455
456 return (copyout((caddr_t)&mask, (caddr_t)SCARG(uap, mask), sizeof(int)));
457 }
458
459 int
460 sunos_sys_sigsuspend(l, v, retval)
461 struct lwp *l;
462 void *v;
463 register_t *retval;
464 {
465 struct sunos_sys_sigsuspend_args /* {
466 syscallarg(int) mask;
467 } */ *uap = v;
468 int mask;
469 sigset_t ss;
470
471 mask = SCARG(uap, mask);
472 sunos_to_native_sigset(mask, &ss);
473 return (sigsuspend1(l->l_proc, &ss));
474 }
475
476 /*
477 * Read Sun-style directory entries. We suck them into kernel space so
478 * that they can be massaged before being copied out to user code. Like
479 * SunOS, we squish out `empty' entries.
480 *
481 * This is quite ugly, but what do you expect from compatibility code?
482 */
483 int
484 sunos_sys_getdents(l, v, retval)
485 struct lwp *l;
486 void *v;
487 register_t *retval;
488 {
489 struct sunos_sys_getdents_args *uap = v;
490 struct proc *p = l->l_proc;
491 struct dirent *bdp;
492 struct vnode *vp;
493 caddr_t inp, buf; /* BSD-format */
494 int len, reclen; /* BSD-format */
495 caddr_t outp; /* Sun-format */
496 int resid, sunos_reclen;/* Sun-format */
497 struct file *fp;
498 struct uio auio;
499 struct iovec aiov;
500 struct sunos_dirent idb;
501 off_t off; /* true file offset */
502 int buflen, error, eofflag;
503 off_t *cookiebuf, *cookie;
504 int ncookies;
505
506 /* getvnode() will use the descriptor for us */
507 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
508 return (error);
509
510 if ((fp->f_flag & FREAD) == 0) {
511 error = EBADF;
512 goto out1;
513 }
514
515 vp = (struct vnode *)fp->f_data;
516 if (vp->v_type != VDIR) {
517 error = EINVAL;
518 goto out1;
519 }
520
521 buflen = min(MAXBSIZE, SCARG(uap, nbytes));
522 buf = malloc(buflen, M_TEMP, M_WAITOK);
523 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
524 off = fp->f_offset;
525 again:
526 aiov.iov_base = buf;
527 aiov.iov_len = buflen;
528 auio.uio_iov = &aiov;
529 auio.uio_iovcnt = 1;
530 auio.uio_rw = UIO_READ;
531 auio.uio_segflg = UIO_SYSSPACE;
532 auio.uio_procp = p;
533 auio.uio_resid = buflen;
534 auio.uio_offset = off;
535 /*
536 * First we read into the malloc'ed buffer, then
537 * we massage it into user space, one record at a time.
538 */
539 error = VOP_READDIR(vp, &auio, fp->f_cred, &eofflag, &cookiebuf,
540 &ncookies);
541 if (error)
542 goto out;
543
544 inp = buf;
545 outp = SCARG(uap, buf);
546 resid = SCARG(uap, nbytes);
547 if ((len = buflen - auio.uio_resid) == 0)
548 goto eof;
549
550 for (cookie = cookiebuf; len > 0; len -= reclen) {
551 bdp = (struct dirent *)inp;
552 reclen = bdp->d_reclen;
553 if (reclen & 3)
554 panic("sunos_getdents");
555 if ((*cookie >> 32) != 0) {
556 compat_offseterr(vp, "sunos_getdents");
557 error = EINVAL;
558 goto out;
559 }
560 if (bdp->d_fileno == 0) {
561 inp += reclen; /* it is a hole; squish it out */
562 off = *cookie++;
563 continue;
564 }
565 sunos_reclen = SUNOS_RECLEN(&idb, bdp->d_namlen);
566 if (reclen > len || resid < sunos_reclen) {
567 /* entry too big for buffer, so just stop */
568 outp++;
569 break;
570 }
571 off = *cookie++; /* each entry points to next */
572 /*
573 * Massage in place to make a Sun-shaped dirent (otherwise
574 * we have to worry about touching user memory outside of
575 * the copyout() call).
576 */
577 idb.d_fileno = bdp->d_fileno;
578 idb.d_off = off;
579 idb.d_reclen = sunos_reclen;
580 idb.d_namlen = bdp->d_namlen;
581 strcpy(idb.d_name, bdp->d_name);
582 if ((error = copyout((caddr_t)&idb, outp, sunos_reclen)) != 0)
583 goto out;
584 /* advance past this real entry */
585 inp += reclen;
586 /* advance output past Sun-shaped entry */
587 outp += sunos_reclen;
588 resid -= sunos_reclen;
589 }
590
591 /* if we squished out the whole block, try again */
592 if (outp == SCARG(uap, buf))
593 goto again;
594 fp->f_offset = off; /* update the vnode offset */
595
596 eof:
597 *retval = SCARG(uap, nbytes) - resid;
598 out:
599 VOP_UNLOCK(vp, 0);
600 free(cookiebuf, M_TEMP);
601 free(buf, M_TEMP);
602 out1:
603 FILE_UNUSE(fp, p);
604 return (error);
605 }
606
607 #define SUNOS__MAP_NEW 0x80000000 /* if not, old mmap & cannot handle */
608
609 int
610 sunos_sys_mmap(l, v, retval)
611 struct lwp *l;
612 void *v;
613 register_t *retval;
614 {
615 struct sunos_sys_mmap_args *uap = v;
616 struct proc *p = l->l_proc;
617 struct sys_mmap_args ouap;
618 struct filedesc *fdp;
619 struct file *fp;
620 struct vnode *vp;
621
622 /*
623 * Verify the arguments.
624 */
625 if (SCARG(uap, prot) & ~(PROT_READ|PROT_WRITE|PROT_EXEC))
626 return (EINVAL); /* XXX still needed? */
627
628 if ((SCARG(uap, flags) & SUNOS__MAP_NEW) == 0)
629 return (EINVAL);
630
631 SCARG(&ouap, flags) = SCARG(uap, flags) & ~SUNOS__MAP_NEW;
632 SCARG(&ouap, addr) = SCARG(uap, addr);
633
634 if ((SCARG(&ouap, flags) & MAP_FIXED) == 0 &&
635 SCARG(&ouap, addr) != 0 &&
636 SCARG(&ouap, addr) < (void *)round_page((vaddr_t)p->p_vmspace->vm_daddr+MAXDSIZ))
637 SCARG(&ouap, addr) = (caddr_t)round_page((vaddr_t)p->p_vmspace->vm_daddr+MAXDSIZ);
638
639 SCARG(&ouap, len) = SCARG(uap, len);
640 SCARG(&ouap, prot) = SCARG(uap, prot);
641 SCARG(&ouap, fd) = SCARG(uap, fd);
642 SCARG(&ouap, pos) = SCARG(uap, pos);
643
644 /*
645 * Special case: if fd refers to /dev/zero, map as MAP_ANON. (XXX)
646 */
647 fdp = p->p_fd;
648 if ((fp = fd_getfile(fdp, SCARG(&ouap, fd))) != NULL && /*XXX*/
649 fp->f_type == DTYPE_VNODE && /*XXX*/
650 (vp = (struct vnode *)fp->f_data)->v_type == VCHR && /*XXX*/
651 iszerodev(vp->v_rdev)) { /*XXX*/
652 SCARG(&ouap, flags) |= MAP_ANON;
653 SCARG(&ouap, fd) = -1;
654 }
655
656 return (sys_mmap(l, &ouap, retval));
657 }
658
659 #define MC_SYNC 1
660 #define MC_LOCK 2
661 #define MC_UNLOCK 3
662 #define MC_ADVISE 4
663 #define MC_LOCKAS 5
664 #define MC_UNLOCKAS 6
665
666 int
667 sunos_sys_mctl(l, v, retval)
668 struct lwp *l;
669 void *v;
670 register_t *retval;
671 {
672 struct sunos_sys_mctl_args *uap = v;
673
674 switch (SCARG(uap, func)) {
675 case MC_ADVISE: /* ignore for now */
676 return (0);
677 case MC_SYNC: /* translate to msync */
678 return (sys___msync13(l, uap, retval));
679 default:
680 return (EINVAL);
681 }
682 }
683
684 int
685 sunos_sys_setsockopt(l, v, retval)
686 struct lwp *l;
687 void *v;
688 register_t *retval;
689 {
690 struct sunos_sys_setsockopt_args *uap = v;
691 struct proc *p = l->l_proc;
692 struct file *fp;
693 struct mbuf *m = NULL;
694 int error;
695
696 /* getsock() will use the descriptor for us */
697 if ((error = getsock(p->p_fd, SCARG(uap, s), &fp)) != 0)
698 return (error);
699 #define SO_DONTLINGER (~SO_LINGER)
700 if (SCARG(uap, name) == SO_DONTLINGER) {
701 m = m_get(M_WAIT, MT_SOOPTS);
702 mtod(m, struct linger *)->l_onoff = 0;
703 m->m_len = sizeof(struct linger);
704 error = sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
705 SO_LINGER, m);
706 goto out;
707 }
708 if (SCARG(uap, level) == IPPROTO_IP) {
709 #define SUNOS_IP_MULTICAST_IF 2
710 #define SUNOS_IP_MULTICAST_TTL 3
711 #define SUNOS_IP_MULTICAST_LOOP 4
712 #define SUNOS_IP_ADD_MEMBERSHIP 5
713 #define SUNOS_IP_DROP_MEMBERSHIP 6
714 static int ipoptxlat[] = {
715 IP_MULTICAST_IF,
716 IP_MULTICAST_TTL,
717 IP_MULTICAST_LOOP,
718 IP_ADD_MEMBERSHIP,
719 IP_DROP_MEMBERSHIP
720 };
721 if (SCARG(uap, name) >= SUNOS_IP_MULTICAST_IF &&
722 SCARG(uap, name) <= SUNOS_IP_DROP_MEMBERSHIP) {
723 SCARG(uap, name) =
724 ipoptxlat[SCARG(uap, name) - SUNOS_IP_MULTICAST_IF];
725 }
726 }
727 if (SCARG(uap, valsize) > MLEN) {
728 error = EINVAL;
729 goto out;
730 }
731 if (SCARG(uap, val)) {
732 m = m_get(M_WAIT, MT_SOOPTS);
733 error = copyin(SCARG(uap, val), mtod(m, caddr_t),
734 (u_int)SCARG(uap, valsize));
735 if (error) {
736 (void) m_free(m);
737 goto out;
738 }
739 m->m_len = SCARG(uap, valsize);
740 }
741 error = sosetopt((struct socket *)fp->f_data, SCARG(uap, level),
742 SCARG(uap, name), m);
743 out:
744 FILE_UNUSE(fp, p);
745 return (error);
746 }
747
748 static __inline__ int sunos_sys_socket_common(struct lwp *, register_t *,
749 int type);
750 static __inline__ int
751 sunos_sys_socket_common(l, retval, type)
752 struct lwp *l;
753 register_t *retval;
754 int type;
755 {
756 struct socket *so;
757 struct file *fp;
758 int error, fd;
759
760 /* getsock() will use the descriptor for us */
761 fd = (int)*retval;
762 if ((error = getsock(l->l_proc->p_fd, fd, &fp)) == 0) {
763 so = (struct socket *)fp->f_data;
764 if (type == SOCK_DGRAM)
765 so->so_options |= SO_BROADCAST;
766 }
767 FILE_UNUSE(fp, l->l_proc);
768 return (error);
769 }
770
771 int
772 sunos_sys_socket(l, v, retval)
773 struct lwp *l;
774 void *v;
775 register_t *retval;
776 {
777 struct sunos_sys_socket_args /* {
778 syscallarg(int) domain;
779 syscallarg(int) type;
780 syscallarg(int) protocol;
781 } */ *uap = v;
782 int error;
783
784 error = sys_socket(l, v, retval);
785 if (error)
786 return (error);
787 return sunos_sys_socket_common(l, retval, SCARG(uap, type));
788 }
789
790 int
791 sunos_sys_socketpair(l, v, retval)
792 struct lwp *l;
793 void *v;
794 register_t *retval;
795 {
796 struct sunos_sys_socketpair_args /* {
797 syscallarg(int) domain;
798 syscallarg(int) type;
799 syscallarg(int) protocol;
800 syscallarg(int *) rsv;
801 } */ *uap = v;
802 int error;
803
804 error = sys_socketpair(l, v, retval);
805 if (error)
806 return (error);
807 return sunos_sys_socket_common(l, retval, SCARG(uap, type));
808 }
809
810 /*
811 * XXX: This needs cleaning up.
812 */
813 int
814 sunos_sys_auditsys(l, v, retval)
815 struct lwp *l;
816 void *v;
817 register_t *retval;
818 {
819 return 0;
820 }
821
822 int
823 sunos_sys_uname(l, v, retval)
824 struct lwp *l;
825 void *v;
826 register_t *retval;
827 {
828 struct sunos_sys_uname_args *uap = v;
829 struct sunos_utsname sut;
830
831 memset(&sut, 0, sizeof(sut));
832
833 memcpy(sut.sysname, ostype, sizeof(sut.sysname) - 1);
834 memcpy(sut.nodename, hostname, sizeof(sut.nodename));
835 sut.nodename[sizeof(sut.nodename)-1] = '\0';
836 memcpy(sut.release, osrelease, sizeof(sut.release) - 1);
837 memcpy(sut.version, "1", sizeof(sut.version) - 1);
838 memcpy(sut.machine, machine, sizeof(sut.machine) - 1);
839
840 return copyout((caddr_t)&sut, (caddr_t)SCARG(uap, name),
841 sizeof(struct sunos_utsname));
842 }
843
844 int
845 sunos_sys_setpgrp(l, v, retval)
846 struct lwp *l;
847 void *v;
848 register_t *retval;
849 {
850 struct sunos_sys_setpgrp_args *uap = v;
851 struct proc *p = l->l_proc;
852
853 /*
854 * difference to our setpgid call is to include backwards
855 * compatibility to pre-setsid() binaries. Do setsid()
856 * instead of setpgid() in those cases where the process
857 * tries to create a new session the old way.
858 */
859 if (!SCARG(uap, pgid) &&
860 (!SCARG(uap, pid) || SCARG(uap, pid) == p->p_pid))
861 return sys_setsid(l, uap, retval);
862 else
863 return sys_setpgid(l, uap, retval);
864 }
865
866 int
867 sunos_sys_open(l, v, retval)
868 struct lwp *l;
869 void *v;
870 register_t *retval;
871 {
872 struct sunos_sys_open_args *uap = v;
873 struct proc *p = l->l_proc;
874 int smode, nmode;
875 int noctty;
876 int ret;
877
878 caddr_t sg = stackgap_init(p, 0);
879
880 /* convert mode into NetBSD mode */
881 smode = SCARG(uap, flags);
882 noctty = smode & 0x8000;
883 nmode = smode &
884 (0x0001 | 0x0002 | 0x0008 | 0x0040 | 0x0200 | 0x0400 | 0x0800);
885 nmode |= ((smode & (0x0004 | 0x1000 | 0x4000)) ? O_NONBLOCK : 0);
886 nmode |= ((smode & 0x0080) ? O_SHLOCK : 0);
887 nmode |= ((smode & 0x0100) ? O_EXLOCK : 0);
888 nmode |= ((smode & 0x2000) ? O_FSYNC : 0);
889
890 if (nmode & O_CREAT)
891 CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
892 else
893 CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
894
895 SCARG(uap, flags) = nmode;
896 ret = sys_open(l, (struct sys_open_args *)uap, retval);
897
898 if (!ret && !noctty && SESS_LEADER(p) && !(p->p_flag & P_CONTROLT)) {
899 struct filedesc *fdp = p->p_fd;
900 struct file *fp;
901
902 fp = fd_getfile(fdp, *retval);
903
904 /* ignore any error, just give it a try */
905 if (fp != NULL && fp->f_type == DTYPE_VNODE)
906 (fp->f_ops->fo_ioctl)(fp, TIOCSCTTY, (caddr_t)0, p);
907 }
908 return ret;
909 }
910
911 #if defined (NFSSERVER)
912 int
913 sunos_sys_nfssvc(l, v, retval)
914 struct lwp *l;
915 void *v;
916 register_t *retval;
917 {
918 #if 0
919 struct sunos_sys_nfssvc_args *uap = v;
920 struct proc *p = l->l_proc;
921 struct emul *e = p->p_emul;
922 struct sys_nfssvc_args outuap;
923 struct sockaddr sa;
924 int error;
925 caddr_t sg = stackgap_init(p, 0);
926
927 memset(&outuap, 0, sizeof outuap);
928 SCARG(&outuap, fd) = SCARG(uap, fd);
929 SCARG(&outuap, mskval) = stackgap_alloc(p, &sg, sizeof(sa));
930 SCARG(&outuap, msklen) = sizeof(sa);
931 SCARG(&outuap, mtchval) = stackgap_alloc(p, &sg, sizeof(sa));
932 SCARG(&outuap, mtchlen) = sizeof(sa);
933
934 memset(&sa, 0, sizeof sa);
935 if (error = copyout(&sa, SCARG(&outuap, mskval), SCARG(&outuap, msklen)))
936 return (error);
937 if (error = copyout(&sa, SCARG(&outuap, mtchval), SCARG(&outuap, mtchlen)))
938 return (error);
939
940 return nfssvc(l, &outuap, retval);
941 #else
942 return (ENOSYS);
943 #endif
944 }
945 #endif /* NFSSERVER */
946
947 int
948 sunos_sys_ustat(l, v, retval)
949 struct lwp *l;
950 void *v;
951 register_t *retval;
952 {
953 struct sunos_sys_ustat_args *uap = v;
954 struct sunos_ustat us;
955 int error;
956
957 memset(&us, 0, sizeof us);
958
959 /*
960 * XXX: should set f_tfree and f_tinode at least
961 * How do we translate dev -> fstat? (and then to sunos_ustat)
962 */
963
964 if ((error = copyout(&us, SCARG(uap, buf), sizeof us)) != 0)
965 return (error);
966 return 0;
967 }
968
969 int
970 sunos_sys_quotactl(l, v, retval)
971 struct lwp *l;
972 void *v;
973 register_t *retval;
974 {
975
976 return EINVAL;
977 }
978
979 int
980 sunos_sys_vhangup(l, v, retval)
981 struct lwp *l;
982 void *v;
983 register_t *retval;
984 {
985 struct proc *p = l->l_proc;
986 struct session *sp = p->p_session;
987
988 if (sp->s_ttyvp == 0)
989 return 0;
990
991 if (sp->s_ttyp && sp->s_ttyp->t_session == sp && sp->s_ttyp->t_pgrp)
992 pgsignal(sp->s_ttyp->t_pgrp, SIGHUP, 1);
993
994 (void) ttywait(sp->s_ttyp);
995 if (sp->s_ttyvp)
996 VOP_REVOKE(sp->s_ttyvp, REVOKEALL);
997 if (sp->s_ttyvp)
998 vrele(sp->s_ttyvp);
999 sp->s_ttyvp = NULL;
1000
1001 return 0;
1002 }
1003
1004 static int
1005 sunstatfs(sp, buf)
1006 struct statfs *sp;
1007 caddr_t buf;
1008 {
1009 struct sunos_statfs ssfs;
1010
1011 memset(&ssfs, 0, sizeof ssfs);
1012 ssfs.f_type = 0;
1013 ssfs.f_bsize = sp->f_bsize;
1014 ssfs.f_blocks = sp->f_blocks;
1015 ssfs.f_bfree = sp->f_bfree;
1016 ssfs.f_bavail = sp->f_bavail;
1017 ssfs.f_files = sp->f_files;
1018 ssfs.f_ffree = sp->f_ffree;
1019 ssfs.f_fsid = sp->f_fsid;
1020 return copyout((caddr_t)&ssfs, buf, sizeof ssfs);
1021 }
1022
1023 int
1024 sunos_sys_statfs(l, v, retval)
1025 struct lwp *l;
1026 void *v;
1027 register_t *retval;
1028 {
1029 struct sunos_sys_statfs_args *uap = v;
1030 struct proc *p = l->l_proc;
1031 struct mount *mp;
1032 struct statfs *sp;
1033 int error;
1034 struct nameidata nd;
1035
1036 caddr_t sg = stackgap_init(p, 0);
1037 CHECK_ALT_EXIST(p, &sg, SCARG(uap, path));
1038
1039 NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, SCARG(uap, path), p);
1040 if ((error = namei(&nd)) != 0)
1041 return (error);
1042 mp = nd.ni_vp->v_mount;
1043 sp = &mp->mnt_stat;
1044 vrele(nd.ni_vp);
1045 if ((error = VFS_STATFS(mp, sp, p)) != 0)
1046 return (error);
1047 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
1048 return sunstatfs(sp, (caddr_t)SCARG(uap, buf));
1049 }
1050
1051 int
1052 sunos_sys_fstatfs(l, v, retval)
1053 struct lwp *l;
1054 void *v;
1055 register_t *retval;
1056 {
1057 struct sunos_sys_fstatfs_args *uap = v;
1058 struct proc *p = l->l_proc;
1059 struct file *fp;
1060 struct mount *mp;
1061 struct statfs *sp;
1062 int error;
1063
1064 /* getvnode() will use the descriptor for us */
1065 if ((error = getvnode(p->p_fd, SCARG(uap, fd), &fp)) != 0)
1066 return (error);
1067 mp = ((struct vnode *)fp->f_data)->v_mount;
1068 sp = &mp->mnt_stat;
1069 if ((error = VFS_STATFS(mp, sp, p)) != 0)
1070 goto out;
1071 sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
1072 error = sunstatfs(sp, (caddr_t)SCARG(uap, buf));
1073 out:
1074 FILE_UNUSE(fp, p);
1075 return (error);
1076 }
1077
1078 int
1079 sunos_sys_exportfs(l, v, retval)
1080 struct lwp *l;
1081 void *v;
1082 register_t *retval;
1083 {
1084 /*
1085 * XXX: should perhaps translate into a mount(2)
1086 * with MOUNT_EXPORT?
1087 */
1088 return 0;
1089 }
1090
1091 int
1092 sunos_sys_mknod(l, v, retval)
1093 struct lwp *l;
1094 void *v;
1095 register_t *retval;
1096 {
1097 struct sunos_sys_mknod_args *uap = v;
1098 struct proc *p = l->l_proc;
1099
1100 caddr_t sg = stackgap_init(p, 0);
1101 CHECK_ALT_CREAT(p, &sg, SCARG(uap, path));
1102
1103 if (S_ISFIFO(SCARG(uap, mode)))
1104 return sys_mkfifo(l, uap, retval);
1105
1106 return sys_mknod(l, (struct sys_mknod_args *)uap, retval);
1107 }
1108
1109 #define SUNOS_SC_ARG_MAX 1
1110 #define SUNOS_SC_CHILD_MAX 2
1111 #define SUNOS_SC_CLK_TCK 3
1112 #define SUNOS_SC_NGROUPS_MAX 4
1113 #define SUNOS_SC_OPEN_MAX 5
1114 #define SUNOS_SC_JOB_CONTROL 6
1115 #define SUNOS_SC_SAVED_IDS 7
1116 #define SUNOS_SC_VERSION 8
1117
1118 int
1119 sunos_sys_sysconf(l, v, retval)
1120 struct lwp *l;
1121 void *v;
1122 register_t *retval;
1123 {
1124 struct sunos_sys_sysconf_args *uap = v;
1125 extern int maxfiles;
1126
1127 switch(SCARG(uap, name)) {
1128 case SUNOS_SC_ARG_MAX:
1129 *retval = ARG_MAX;
1130 break;
1131 case SUNOS_SC_CHILD_MAX:
1132 *retval = maxproc;
1133 break;
1134 case SUNOS_SC_CLK_TCK:
1135 *retval = 60; /* should this be `hz', ie. 100? */
1136 break;
1137 case SUNOS_SC_NGROUPS_MAX:
1138 *retval = NGROUPS_MAX;
1139 break;
1140 case SUNOS_SC_OPEN_MAX:
1141 *retval = maxfiles;
1142 break;
1143 case SUNOS_SC_JOB_CONTROL:
1144 *retval = 1;
1145 break;
1146 case SUNOS_SC_SAVED_IDS:
1147 #ifdef _POSIX_SAVED_IDS
1148 *retval = 1;
1149 #else
1150 *retval = 0;
1151 #endif
1152 break;
1153 case SUNOS_SC_VERSION:
1154 *retval = 198808;
1155 break;
1156 default:
1157 return EINVAL;
1158 }
1159 return 0;
1160 }
1161
1162 #define SUNOS_RLIMIT_NOFILE 6 /* Other RLIMIT_* are the same */
1163 #define SUNOS_RLIM_NLIMITS 7
1164
1165 int
1166 sunos_sys_getrlimit(l, v, retval)
1167 struct lwp *l;
1168 void *v;
1169 register_t *retval;
1170 {
1171 struct sunos_sys_getrlimit_args *uap = v;
1172
1173 if (SCARG(uap, which) >= SUNOS_RLIM_NLIMITS)
1174 return EINVAL;
1175
1176 if (SCARG(uap, which) == SUNOS_RLIMIT_NOFILE)
1177 SCARG(uap, which) = RLIMIT_NOFILE;
1178
1179 return compat_43_sys_getrlimit(l, uap, retval);
1180 }
1181
1182 int
1183 sunos_sys_setrlimit(l, v, retval)
1184 struct lwp *l;
1185 void *v;
1186 register_t *retval;
1187 {
1188 struct sunos_sys_getrlimit_args *uap = v;
1189
1190 if (SCARG(uap, which) >= SUNOS_RLIM_NLIMITS)
1191 return EINVAL;
1192
1193 if (SCARG(uap, which) == SUNOS_RLIMIT_NOFILE)
1194 SCARG(uap, which) = RLIMIT_NOFILE;
1195
1196 return compat_43_sys_setrlimit(l, uap, retval);
1197 }
1198
1199 /* for the m68k machines */
1200 #ifndef PT_GETFPREGS
1201 #define PT_GETFPREGS -1
1202 #endif
1203 #ifndef PT_SETFPREGS
1204 #define PT_SETFPREGS -1
1205 #endif
1206
1207 static int sreq2breq[] = {
1208 PT_TRACE_ME, PT_READ_I, PT_READ_D, -1,
1209 PT_WRITE_I, PT_WRITE_D, -1, PT_CONTINUE,
1210 PT_KILL, -1, PT_ATTACH, PT_DETACH,
1211 PT_GETREGS, PT_SETREGS, PT_GETFPREGS, PT_SETFPREGS
1212 };
1213 static int nreqs = sizeof(sreq2breq) / sizeof(sreq2breq[0]);
1214
1215 int
1216 sunos_sys_ptrace(l, v, retval)
1217 struct lwp *l;
1218 void *v;
1219 register_t *retval;
1220 {
1221 struct sunos_sys_ptrace_args *uap = v;
1222 struct sys_ptrace_args pa;
1223 int req;
1224
1225 req = SCARG(uap, req);
1226
1227 if (req < 0 || req >= nreqs)
1228 return (EINVAL);
1229
1230 req = sreq2breq[req];
1231 if (req == -1)
1232 return (EINVAL);
1233
1234 SCARG(&pa, req) = req;
1235 SCARG(&pa, pid) = (pid_t)SCARG(uap, pid);
1236 SCARG(&pa, addr) = (caddr_t)SCARG(uap, addr);
1237 SCARG(&pa, data) = SCARG(uap, data);
1238
1239 return sys_ptrace(l, &pa, retval);
1240 }
1241
1242 /*
1243 * SunOS reboot system call (for compatibility).
1244 * Sun lets you pass in a boot string which the PROM
1245 * saves and provides to the next boot program.
1246 */
1247
1248 #define SUNOS_RB_ASKNAME 0x001
1249 #define SUNOS_RB_SINGLE 0x002
1250 #define SUNOS_RB_NOSYNC 0x004
1251 #define SUNOS_RB_HALT 0x008
1252 #define SUNOS_RB_DUMP 0x080
1253 #define SUNOS_RB_STRING 0x200
1254
1255 static struct sunos_howto_conv {
1256 int sun_howto;
1257 int bsd_howto;
1258 } sunos_howto_conv[] = {
1259 { SUNOS_RB_ASKNAME, RB_ASKNAME },
1260 { SUNOS_RB_SINGLE, RB_SINGLE },
1261 { SUNOS_RB_NOSYNC, RB_NOSYNC },
1262 { SUNOS_RB_HALT, RB_HALT },
1263 { SUNOS_RB_DUMP, RB_DUMP },
1264 { SUNOS_RB_STRING, RB_STRING },
1265 { 0x000, 0 },
1266 };
1267
1268 int
1269 sunos_sys_reboot(l, v, retval)
1270 struct lwp *l;
1271 void *v;
1272 register_t *retval;
1273 {
1274 struct sunos_sys_reboot_args *uap = v;
1275 struct proc *p = l->l_proc;
1276 struct sys_reboot_args ua;
1277 struct sunos_howto_conv *convp;
1278 int error, bsd_howto, sun_howto;
1279 char *bootstr;
1280
1281 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
1282 return (error);
1283
1284 /*
1285 * Convert howto bits to BSD format.
1286 */
1287 sun_howto = SCARG(uap, howto);
1288 bsd_howto = 0;
1289 convp = sunos_howto_conv;
1290 while (convp->sun_howto) {
1291 if (sun_howto & convp->sun_howto)
1292 bsd_howto |= convp->bsd_howto;
1293 convp++;
1294 }
1295
1296 /*
1297 * Sun RB_STRING (Get user supplied bootstring.)
1298 * If the machine supports passing a string to the
1299 * next booted kernel.
1300 */
1301 if (sun_howto & SUNOS_RB_STRING) {
1302 char bs[128];
1303
1304 error = copyinstr(SCARG(uap, bootstr), bs, sizeof(bs), 0);
1305
1306 if (error)
1307 bootstr = NULL;
1308 else
1309 bootstr = bs;
1310 } else
1311 bootstr = NULL;
1312
1313 SCARG(&ua, opt) = bsd_howto;
1314 SCARG(&ua, bootstr) = bootstr;
1315 sys_reboot(l, &ua, retval);
1316 return(0);
1317 }
1318
1319 /*
1320 * Generalized interface signal handler, 4.3-compatible.
1321 */
1322 /* ARGSUSED */
1323 int
1324 sunos_sys_sigvec(l, v, retval)
1325 struct lwp *l;
1326 void *v;
1327 register_t *retval;
1328 {
1329 struct sunos_sys_sigvec_args /* {
1330 syscallarg(int) signum;
1331 syscallarg(struct sigvec *) nsv;
1332 syscallarg(struct sigvec *) osv;
1333 } */ *uap = v;
1334 struct sigvec nsv, osv;
1335 struct sigaction nsa, osa;
1336 int error;
1337 /*XXX*/extern void compat_43_sigvec_to_sigaction
1338 __P((const struct sigvec *, struct sigaction *));
1339 /*XXX*/extern void compat_43_sigaction_to_sigvec
1340 __P((const struct sigaction *, struct sigvec *));
1341
1342 if (SCARG(uap, nsv)) {
1343 error = copyin(SCARG(uap, nsv), &nsv, sizeof(nsv));
1344 if (error != 0)
1345 return (error);
1346
1347 /*
1348 * SunOS uses the mask 0x0004 as SV_RESETHAND
1349 * meaning: `reset to SIG_DFL on delivery'.
1350 * We support only the bits in: 0xF
1351 * (those bits are the same as ours)
1352 */
1353 if (nsv.sv_flags & ~0xF)
1354 return (EINVAL);
1355
1356 compat_43_sigvec_to_sigaction(&nsv, &nsa);
1357 }
1358 error = sigaction1(l->l_proc, SCARG(uap, signum),
1359 SCARG(uap, nsv) ? &nsa : 0,
1360 SCARG(uap, osv) ? &osa : 0);
1361 if (error != 0)
1362 return (error);
1363
1364 if (SCARG(uap, osv)) {
1365 compat_43_sigaction_to_sigvec(&osa, &osv);
1366 error = copyout(&osv, SCARG(uap, osv), sizeof(osv));
1367 if (error != 0)
1368 return (error);
1369 }
1370
1371 return (0);
1372 }
1373