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