netbsd32_compat_43.c revision 1.12 1 /* $NetBSD: netbsd32_compat_43.c,v 1.12 2000/12/01 12:28:33 jdolecek Exp $ */
2
3 /*
4 * Copyright (c) 1998 Matthew R. Green
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. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31 #include <sys/param.h>
32 #include <sys/systm.h>
33 #include <sys/fcntl.h>
34 #include <sys/malloc.h>
35 #include <sys/mount.h>
36 #include <sys/proc.h>
37 #include <sys/stat.h>
38 #include <sys/syscallargs.h>
39 #include <sys/time.h>
40 #include <sys/ucred.h>
41 #include <uvm/uvm_extern.h>
42 #include <sys/sysctl.h>
43 #include <sys/swap.h>
44
45 #include <compat/netbsd32/netbsd32.h>
46 #include <compat/netbsd32/netbsd32_syscallargs.h>
47
48 static void netbsd32_from_stat43 __P((struct stat43 *, struct netbsd32_stat43 *));
49 int compat_43_netbsd32_sethostid __P((struct proc *, void *, register_t *));
50 int compat_43_netbsd32_killpg __P((struct proc *, void *, register_t *retval));
51 int compat_43_netbsd32_sigblock __P((struct proc *, void *, register_t *retval));
52 int compat_43_netbsd32_sigblock __P((struct proc *, void *, register_t *retval));
53
54 static void
55 netbsd32_from_stat43(sp43, sp32)
56 struct stat43 *sp43;
57 struct netbsd32_stat43 *sp32;
58 {
59
60 sp32->st_dev = sp43->st_dev;
61 sp32->st_ino = sp43->st_ino;
62 sp32->st_mode = sp43->st_mode;
63 sp32->st_nlink = sp43->st_nlink;
64 sp32->st_uid = sp43->st_uid;
65 sp32->st_gid = sp43->st_gid;
66 sp32->st_rdev = sp43->st_rdev;
67 sp32->st_size = sp43->st_size;
68 sp32->st_atimespec.tv_sec = sp43->st_atimespec.tv_sec;
69 sp32->st_atimespec.tv_nsec = sp43->st_atimespec.tv_nsec;
70 sp32->st_mtimespec.tv_sec = sp43->st_mtimespec.tv_sec;
71 sp32->st_mtimespec.tv_nsec = sp43->st_mtimespec.tv_nsec;
72 sp32->st_ctimespec.tv_sec = sp43->st_ctimespec.tv_sec;
73 sp32->st_ctimespec.tv_nsec = sp43->st_ctimespec.tv_nsec;
74 sp32->st_blksize = sp43->st_blksize;
75 sp32->st_blocks = sp43->st_blocks;
76 sp32->st_flags = sp43->st_flags;
77 sp32->st_gen = sp43->st_gen;
78 }
79
80 /* file system syscalls */
81 int
82 compat_43_netbsd32_ocreat(p, v, retval)
83 struct proc *p;
84 void *v;
85 register_t *retval;
86 {
87 struct compat_43_netbsd32_ocreat_args /* {
88 syscallarg(const netbsd32_charp) path;
89 syscallarg(mode_t) mode;
90 } */ *uap = v;
91 struct sys_open_args ua;
92 caddr_t sg;
93
94 NETBSD32TOP_UAP(path, const char);
95 NETBSD32TO64_UAP(mode);
96 SCARG(&ua, flags) = O_WRONLY | O_CREAT | O_TRUNC;
97 sg = stackgap_init(p->p_emul);
98 CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path));
99
100 return (sys_open(p, &ua, retval));
101 }
102
103 int
104 compat_43_netbsd32_olseek(p, v, retval)
105 struct proc *p;
106 void *v;
107 register_t *retval;
108 {
109 struct compat_43_netbsd32_olseek_args /* {
110 syscallarg(int) fd;
111 syscallarg(netbsd32_long) offset;
112 syscallarg(int) whence;
113 } */ *uap = v;
114 struct sys_lseek_args ua;
115 int rv;
116 off_t rt;
117
118 SCARG(&ua, fd) = SCARG(uap, fd);
119 NETBSD32TOX_UAP(offset, long);
120 NETBSD32TO64_UAP(whence);
121 rv = sys_lseek(p, &ua, (register_t *)&rt);
122 *(netbsd32_long *)retval = rt;
123
124 return (rv);
125 }
126
127 int
128 compat_43_netbsd32_stat43(p, v, retval)
129 struct proc *p;
130 void *v;
131 register_t *retval;
132 {
133 struct compat_43_netbsd32_stat43_args /* {
134 syscallarg(const netbsd32_charp) path;
135 syscallarg(netbsd32_stat43p_t) ub;
136 } */ *uap = v;
137 struct netbsd32_stat43 *sp32;
138 struct stat43 sb43;
139 struct stat43 *sp43 = &sb43;
140 struct compat_43_sys_stat_args ua;
141 caddr_t sg;
142 int rv;
143
144 NETBSD32TOP_UAP(path, const char);
145 SCARG(&ua, ub) = &sb43;
146 sg = stackgap_init(p->p_emul);
147 CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path));
148
149 rv = compat_43_sys_stat(p, &ua, retval);
150
151 sp32 = (struct netbsd32_stat43 *)(u_long)SCARG(uap, ub);
152 netbsd32_from_stat43(sp43, sp32);
153
154 return (rv);
155 }
156
157 int
158 compat_43_netbsd32_lstat43(p, v, retval)
159 struct proc *p;
160 void *v;
161 register_t *retval;
162 {
163 struct compat_43_netbsd32_lstat43_args /* {
164 syscallarg(const netbsd32_charp) path;
165 syscallarg(netbsd32_stat43p_t) ub;
166 } */ *uap = v;
167 struct netbsd32_stat43 *sp32;
168 struct stat43 sb43;
169 struct stat43 *sp43 = &sb43;
170 struct compat_43_sys_lstat_args ua;
171 caddr_t sg;
172 int rv;
173
174 NETBSD32TOP_UAP(path, const char);
175 SCARG(&ua, ub) = &sb43;
176 sg = stackgap_init(p->p_emul);
177 CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path));
178
179 rv = compat_43_sys_stat(p, &ua, retval);
180
181 sp32 = (struct netbsd32_stat43 *)(u_long)SCARG(uap, ub);
182 netbsd32_from_stat43(sp43, sp32);
183
184 return (rv);
185 }
186
187 int
188 compat_43_netbsd32_fstat43(p, v, retval)
189 struct proc *p;
190 void *v;
191 register_t *retval;
192 {
193 struct compat_43_netbsd32_fstat43_args /* {
194 syscallarg(int) fd;
195 syscallarg(netbsd32_stat43p_t) sb;
196 } */ *uap = v;
197 struct netbsd32_stat43 *sp32;
198 struct stat43 sb43;
199 struct stat43 *sp43 = &sb43;
200 struct compat_43_sys_fstat_args ua;
201 int rv;
202
203 NETBSD32TO64_UAP(fd);
204 SCARG(&ua, sb) = &sb43;
205 rv = compat_43_sys_fstat(p, &ua, retval);
206
207 sp32 = (struct netbsd32_stat43 *)(u_long)SCARG(uap, sb);
208 netbsd32_from_stat43(sp43, sp32);
209
210 return (rv);
211 }
212
213 int
214 compat_43_netbsd32_otruncate(p, v, retval)
215 struct proc *p;
216 void *v;
217 register_t *retval;
218 {
219 struct compat_43_netbsd32_otruncate_args /* {
220 syscallarg(const netbsd32_charp) path;
221 syscallarg(netbsd32_long) length;
222 } */ *uap = v;
223 struct sys_truncate_args ua;
224
225 NETBSD32TOP_UAP(path, const char);
226 NETBSD32TO64_UAP(length);
227 return (sys_ftruncate(p, &ua, retval));
228 }
229
230 int
231 compat_43_netbsd32_oftruncate(p, v, retval)
232 struct proc *p;
233 void *v;
234 register_t *retval;
235 {
236 struct compat_43_netbsd32_oftruncate_args /* {
237 syscallarg(int) fd;
238 syscallarg(netbsd32_long) length;
239 } */ *uap = v;
240 struct sys_ftruncate_args ua;
241
242 NETBSD32TO64_UAP(fd);
243 NETBSD32TO64_UAP(length);
244 return (sys_ftruncate(p, &ua, retval));
245 }
246
247 int
248 compat_43_netbsd32_ogetdirentries(p, v, retval)
249 struct proc *p;
250 void *v;
251 register_t *retval;
252 {
253 struct compat_43_netbsd32_ogetdirentries_args /* {
254 syscallarg(int) fd;
255 syscallarg(netbsd32_charp) buf;
256 syscallarg(u_int) count;
257 syscallarg(netbsd32_longp) basep;
258 } */ *uap = v;
259 struct compat_43_sys_getdirentries_args ua;
260
261 NETBSD32TO64_UAP(fd);
262 NETBSD32TOP_UAP(buf, char);
263 NETBSD32TO64_UAP(count);
264 NETBSD32TOP_UAP(basep, long);
265 return (compat_43_sys_getdirentries(p, &ua, retval));
266 }
267
268 /* kernel syscalls */
269 int
270 compat_43_netbsd32_ogetkerninfo(p, v, retval)
271 struct proc *p;
272 void *v;
273 register_t *retval;
274 {
275 struct compat_43_netbsd32_ogetkerninfo_args /* {
276 syscallarg(int) op;
277 syscallarg(netbsd32_charp) where;
278 syscallarg(netbsd32_intp) size;
279 syscallarg(int) arg;
280 } */ *uap = v;
281 struct compat_43_sys_getkerninfo_args ua;
282
283 NETBSD32TO64_UAP(op);
284 NETBSD32TOP_UAP(where, char);
285 NETBSD32TOP_UAP(size, int);
286 NETBSD32TO64_UAP(arg);
287 return (compat_43_sys_getkerninfo(p, &ua, retval));
288 }
289
290 int
291 compat_43_netbsd32_ogethostname(p, v, retval)
292 struct proc *p;
293 void *v;
294 register_t *retval;
295 {
296 struct compat_43_netbsd32_ogethostname_args /* {
297 syscallarg(netbsd32_charp) hostname;
298 syscallarg(u_int) len;
299 } */ *uap = v;
300 int name;
301 size_t sz;
302
303 name = KERN_HOSTNAME;
304 sz = SCARG(uap, len);
305 return (kern_sysctl(&name, 1, (char *)(u_long)SCARG(uap, hostname),
306 &sz, 0, 0, p));
307 }
308
309 int
310 compat_43_netbsd32_osethostname(p, v, retval)
311 struct proc *p;
312 void *v;
313 register_t *retval;
314 {
315 struct compat_43_netbsd32_osethostname_args /* {
316 syscallarg(netbsd32_charp) hostname;
317 syscallarg(u_int) len;
318 } */ *uap = v;
319 int name;
320 int error;
321
322 if ((error = suser(p->p_ucred, &p->p_acflag)) != 0)
323 return (error);
324 name = KERN_HOSTNAME;
325 return (kern_sysctl(&name, 1, 0, 0, (char *)(u_long)SCARG(uap,
326 hostname), SCARG(uap, len), p));
327 }
328
329 int
330 compat_43_netbsd32_sethostid(p, v, retval)
331 struct proc *p;
332 void *v;
333 register_t *retval;
334 {
335 struct compat_43_netbsd32_sethostid_args /* {
336 syscallarg(int32_t) hostid;
337 } */ *uap = v;
338 struct compat_43_sys_sethostid_args ua;
339
340 NETBSD32TO64_UAP(hostid);
341 return (compat_43_sys_sethostid(p, &ua, retval));
342 }
343
344 int
345 compat_43_netbsd32_ogetrlimit(p, v, retval)
346 struct proc *p;
347 void *v;
348 register_t *retval;
349 {
350 struct compat_43_netbsd32_ogetrlimit_args /* {
351 syscallarg(int) which;
352 syscallarg(netbsd32_orlimitp_t) rlp;
353 } */ *uap = v;
354 struct compat_43_sys_getrlimit_args ua;
355
356 NETBSD32TO64_UAP(which);
357 NETBSD32TOP_UAP(rlp, struct orlimit);
358 return (compat_43_sys_getrlimit(p, &ua, retval));
359 }
360
361 int
362 compat_43_netbsd32_osetrlimit(p, v, retval)
363 struct proc *p;
364 void *v;
365 register_t *retval;
366 {
367 struct compat_43_netbsd32_osetrlimit_args /* {
368 syscallarg(int) which;
369 syscallarg(netbsd32_orlimitp_t) rlp;
370 } */ *uap = v;
371 struct compat_43_sys_setrlimit_args ua;
372
373 NETBSD32TO64_UAP(which);
374 NETBSD32TOP_UAP(rlp, struct orlimit);
375 return (compat_43_sys_setrlimit(p, &ua, retval));
376 }
377
378 int
379 compat_43_netbsd32_killpg(p, v, retval)
380 struct proc *p;
381 void *v;
382 register_t *retval;
383 {
384 struct compat_43_netbsd32_killpg_args /* {
385 syscallarg(int) pgid;
386 syscallarg(int) signum;
387 } */ *uap = v;
388 struct compat_43_sys_killpg_args ua;
389
390 NETBSD32TO64_UAP(pgid);
391 NETBSD32TO64_UAP(signum);
392 return (compat_43_sys_killpg(p, &ua, retval));
393 }
394
395 /* virtual memory syscalls */
396 int
397 compat_43_netbsd32_ommap(p, v, retval)
398 struct proc *p;
399 void *v;
400 register_t *retval;
401 {
402 struct compat_43_netbsd32_ommap_args /* {
403 syscallarg(netbsd32_caddr_t) addr;
404 syscallarg(netbsd32_size_t) len;
405 syscallarg(int) prot;
406 syscallarg(int) flags;
407 syscallarg(int) fd;
408 syscallarg(netbsd32_long) pos;
409 } */ *uap = v;
410 struct compat_43_sys_mmap_args ua;
411
412 NETBSD32TOX64_UAP(addr, caddr_t);
413 NETBSD32TOX_UAP(len, size_t);
414 NETBSD32TO64_UAP(prot);
415 NETBSD32TO64_UAP(flags);
416 NETBSD32TO64_UAP(fd);
417 NETBSD32TOX_UAP(pos, long);
418 return (compat_43_sys_mmap(p, &ua, retval));
419 }
420
421 /* network syscalls */
422 int
423 compat_43_netbsd32_oaccept(p, v, retval)
424 struct proc *p;
425 void *v;
426 register_t *retval;
427 {
428 struct compat_43_netbsd32_oaccept_args /* {
429 syscallarg(int) s;
430 syscallarg(netbsd32_caddr_t) name;
431 syscallarg(netbsd32_intp) anamelen;
432 } */ *uap = v;
433 struct compat_43_sys_accept_args ua;
434
435 NETBSD32TOX_UAP(s, int);
436 NETBSD32TOX64_UAP(name, caddr_t);
437 NETBSD32TOP_UAP(anamelen, int);
438 return (compat_43_sys_accept(p, &ua, retval));
439 }
440
441 int
442 compat_43_netbsd32_osend(p, v, retval)
443 struct proc *p;
444 void *v;
445 register_t *retval;
446 {
447 struct compat_43_netbsd32_osend_args /* {
448 syscallarg(int) s;
449 syscallarg(netbsd32_caddr_t) buf;
450 syscallarg(int) len;
451 syscallarg(int) flags;
452 } */ *uap = v;
453 struct compat_43_sys_send_args ua;
454
455 NETBSD32TO64_UAP(s);
456 NETBSD32TOX64_UAP(buf, caddr_t);
457 NETBSD32TO64_UAP(len);
458 NETBSD32TO64_UAP(flags);
459 return (compat_43_sys_send(p, &ua, retval));
460 }
461
462 int
463 compat_43_netbsd32_orecv(p, v, retval)
464 struct proc *p;
465 void *v;
466 register_t *retval;
467 {
468 struct compat_43_netbsd32_orecv_args /* {
469 syscallarg(int) s;
470 syscallarg(netbsd32_caddr_t) buf;
471 syscallarg(int) len;
472 syscallarg(int) flags;
473 } */ *uap = v;
474 struct compat_43_sys_recv_args ua;
475
476 NETBSD32TO64_UAP(s);
477 NETBSD32TOX64_UAP(buf, caddr_t);
478 NETBSD32TO64_UAP(len);
479 NETBSD32TO64_UAP(flags);
480 return (compat_43_sys_recv(p, &ua, retval));
481 }
482
483 /*
484 * XXX convert these to use a common iovec code to the native
485 * netbsd call.
486 */
487 int
488 compat_43_netbsd32_orecvmsg(p, v, retval)
489 struct proc *p;
490 void *v;
491 register_t *retval;
492 {
493 struct compat_43_netbsd32_orecvmsg_args /* {
494 syscallarg(int) s;
495 syscallarg(netbsd32_omsghdrp_t) msg;
496 syscallarg(int) flags;
497 } */ *uap = v;
498 struct compat_43_sys_recvmsg_args ua;
499 struct omsghdr omh;
500 struct omsghdr *omhp = &omh;
501 struct netbsd32_omsghdr *omhp32;
502 struct iovec *iovec43p;
503 struct netbsd32_iovec *iovec32p;
504 int i;
505
506 NETBSD32TO64_UAP(s);
507 NETBSD32TO64_UAP(flags);
508
509 SCARG(&ua, msg) = omhp;
510 omhp32 = (struct netbsd32_omsghdr *)(u_long)SCARG(uap, msg);
511 omhp->msg_name = (caddr_t)(u_long)omhp32->msg_name;
512 omhp->msg_namelen = omhp32->msg_namelen;
513 omhp->msg_iovlen = (size_t)omhp32->msg_iovlen;
514 MALLOC(omhp->msg_iov, struct iovec *, sizeof(struct iovec) * omhp->msg_iovlen, M_TEMP, M_WAITOK);
515 iovec43p = omhp->msg_iov;
516 iovec32p = (struct netbsd32_iovec *)(u_long)omhp32->msg_iov;
517 for (i = 0; i < omhp->msg_iovlen; i++, iovec43p++, iovec32p++) {
518 iovec43p->iov_base = (struct iovec *)(u_long)iovec32p->iov_base;
519 iovec43p->iov_len = (size_t)iovec32p->iov_len;
520 }
521
522 omhp->msg_accrights = (caddr_t)(u_long)omhp32->msg_accrights;
523 omhp->msg_accrightslen = omhp32->msg_accrightslen;
524
525 return (compat_43_sys_recvmsg(p, &ua, retval));
526 }
527
528 int
529 compat_43_netbsd32_osendmsg(p, v, retval)
530 struct proc *p;
531 void *v;
532 register_t *retval;
533 {
534 struct compat_43_netbsd32_osendmsg_args /* {
535 syscallarg(int) s;
536 syscallarg(netbsd32_caddr_t) msg;
537 syscallarg(int) flags;
538 } */ *uap = v;
539 struct compat_43_sys_sendmsg_args ua;
540 struct omsghdr omh;
541 struct omsghdr *omhp = &omh;
542 struct netbsd32_omsghdr *omhp32;
543 struct iovec *iovec43p;
544 struct netbsd32_iovec *iovec32p;
545 int i;
546
547 NETBSD32TO64_UAP(s);
548 NETBSD32TO64_UAP(flags);
549
550 SCARG(&ua, msg) = (caddr_t)(u_long)omhp;
551 omhp32 = (struct netbsd32_omsghdr *)(u_long)SCARG(uap, msg);
552 omhp->msg_name = (caddr_t)(u_long)omhp32->msg_name;
553 omhp->msg_namelen = omhp32->msg_namelen;
554 omhp->msg_iovlen = (size_t)omhp32->msg_iovlen;
555 MALLOC(omhp->msg_iov, struct iovec *, sizeof(struct iovec) * omhp->msg_iovlen, M_TEMP, M_WAITOK);
556 iovec43p = omhp->msg_iov;
557 iovec32p = (struct netbsd32_iovec *)(u_long)omhp32->msg_iov;
558 for (i = 0; i < omhp->msg_iovlen; i++, iovec43p++, iovec32p++) {
559 iovec43p->iov_base = (void *)(u_long)iovec32p->iov_base;
560 iovec43p->iov_len = (size_t)iovec32p->iov_len;
561 }
562
563 omhp->msg_accrights = (caddr_t)(u_long)omhp32->msg_accrights;
564 omhp->msg_accrightslen = omhp32->msg_accrightslen;
565
566 return (compat_43_sys_sendmsg(p, &ua, retval));
567 }
568
569 int
570 compat_43_netbsd32_orecvfrom(p, v, retval)
571 struct proc *p;
572 void *v;
573 register_t *retval;
574 {
575 struct compat_43_netbsd32_orecvfrom_args /* {
576 syscallarg(int) s;
577 syscallarg(netbsd32_caddr_t) buf;
578 syscallarg(netbsd32_size_t) len;
579 syscallarg(int) flags;
580 syscallarg(netbsd32_caddr_t) from;
581 syscallarg(netbsd32_intp) fromlenaddr;
582 } */ *uap = v;
583 struct compat_43_sys_recvfrom_args ua;
584
585 NETBSD32TO64_UAP(s);
586 NETBSD32TOX64_UAP(buf, caddr_t);
587 NETBSD32TOX_UAP(len, size_t);
588 NETBSD32TO64_UAP(flags);
589 NETBSD32TOX64_UAP(from, caddr_t);
590 NETBSD32TOP_UAP(fromlenaddr, int);
591 return (compat_43_sys_recvfrom(p, &ua, retval));
592 }
593
594 int
595 compat_43_netbsd32_ogetsockname(p, v, retval)
596 struct proc *p;
597 void *v;
598 register_t *retval;
599 {
600 struct compat_43_netbsd32_ogetsockname_args /* {
601 syscallarg(int) fdec;
602 syscallarg(netbsd32_caddr_t) asa;
603 syscallarg(netbsd32_intp) alen;
604 } */ *uap = v;
605 struct compat_43_sys_getsockname_args ua;
606
607 NETBSD32TO64_UAP(fdec);
608 NETBSD32TOX64_UAP(asa, caddr_t);
609 NETBSD32TOP_UAP(alen, int);
610 return (compat_43_sys_getsockname(p, &ua, retval));
611 }
612
613 int
614 compat_43_netbsd32_ogetpeername(p, v, retval)
615 struct proc *p;
616 void *v;
617 register_t *retval;
618 {
619 struct compat_43_netbsd32_ogetpeername_args /* {
620 syscallarg(int) fdes;
621 syscallarg(netbsd32_caddr_t) asa;
622 syscallarg(netbsd32_intp) alen;
623 } */ *uap = v;
624 struct compat_43_sys_getpeername_args ua;
625
626 NETBSD32TO64_UAP(fdes);
627 NETBSD32TOX64_UAP(asa, caddr_t);
628 NETBSD32TOP_UAP(alen, int);
629 return (compat_43_sys_getpeername(p, &ua, retval));
630 }
631
632 /* signal syscalls */
633 int
634 compat_43_netbsd32_osigvec(p, v, retval)
635 struct proc *p;
636 void *v;
637 register_t *retval;
638 {
639 struct compat_43_netbsd32_osigvec_args /* {
640 syscallarg(int) signum;
641 syscallarg(netbsd32_sigvecp_t) nsv;
642 syscallarg(netbsd32_sigvecp_t) osv;
643 } */ *uap = v;
644 struct compat_43_sys_sigvec_args ua;
645 struct netbsd32_sigvec *sv32p;
646 struct sigvec nsv, osv;
647 int rv;
648
649 NETBSD32TO64_UAP(signum);
650 if (SCARG(uap, osv))
651 SCARG(&ua, osv) = &osv;
652 else
653 SCARG(&ua, osv) = NULL;
654 if (SCARG(uap, nsv)) {
655 SCARG(&ua, nsv) = &nsv;
656 sv32p = (struct netbsd32_sigvec *)(u_long)SCARG(uap, nsv);
657 nsv.sv_handler = (void *)(u_long)sv32p->sv_handler;
658 nsv.sv_mask = sv32p->sv_mask;
659 nsv.sv_flags = sv32p->sv_flags;
660 } else
661 SCARG(&ua, nsv) = NULL;
662 rv = compat_43_sys_sigvec(p, &ua, retval);
663 if (rv)
664 return (rv);
665
666 if (SCARG(uap, osv)) {
667 sv32p = (struct netbsd32_sigvec *)(u_long)SCARG(uap, osv);
668 sv32p->sv_handler = (netbsd32_sigvecp_t)(u_long)osv.sv_handler;
669 sv32p->sv_mask = osv.sv_mask;
670 sv32p->sv_flags = osv.sv_flags;
671 }
672
673 return (0);
674 }
675
676 int
677 compat_43_netbsd32_sigblock(p, v, retval)
678 struct proc *p;
679 void *v;
680 register_t *retval;
681 {
682 struct compat_43_netbsd32_sigblock_args /* {
683 syscallarg(int) mask;
684 } */ *uap = v;
685 struct compat_43_sys_sigblock_args ua;
686
687 NETBSD32TO64_UAP(mask);
688 return (compat_43_sys_sigblock(p, &ua, retval));
689 }
690
691 int
692 compat_43_netbsd32_sigsetmask(p, v, retval)
693 struct proc *p;
694 void *v;
695 register_t *retval;
696 {
697 struct compat_43_netbsd32_sigsetmask_args /* {
698 syscallarg(int) mask;
699 } */ *uap = v;
700 struct compat_43_sys_sigsetmask_args ua;
701
702 NETBSD32TO64_UAP(mask);
703 return (compat_43_sys_sigsetmask(p, &ua, retval));
704 }
705
706 int
707 compat_43_netbsd32_osigstack(p, v, retval)
708 struct proc *p;
709 void *v;
710 register_t *retval;
711 {
712 struct compat_43_netbsd32_osigstack_args /* {
713 syscallarg(netbsd32_sigstackp_t) nss;
714 syscallarg(netbsd32_sigstackp_t) oss;
715 } */ *uap = v;
716 struct compat_43_sys_sigstack_args ua;
717 struct netbsd32_sigstack *ss32p;
718 struct sigstack nss, oss;
719 int rv;
720
721 if (SCARG(uap, oss))
722 SCARG(&ua, oss) = &oss;
723 else
724 SCARG(&ua, oss) = NULL;
725 if (SCARG(uap, nss)) {
726 SCARG(&ua, nss) = &nss;
727 ss32p = (struct netbsd32_sigstack *)(u_long)SCARG(uap, nss);
728 nss.ss_sp = (void *)(u_long)ss32p->ss_sp;
729 nss.ss_onstack = ss32p->ss_onstack;
730 } else
731 SCARG(&ua, nss) = NULL;
732
733 rv = compat_43_sys_sigstack(p, &ua, retval);
734 if (rv)
735 return (rv);
736
737 if (SCARG(uap, oss)) {
738 ss32p = (struct netbsd32_sigstack *)(u_long)SCARG(uap, oss);
739 ss32p->ss_sp = (netbsd32_sigstackp_t)(u_long)oss.ss_sp;
740 ss32p->ss_onstack = oss.ss_onstack;
741 }
742
743 return (0);
744 }
745