netbsd32_compat_43.c revision 1.9 1 /* $NetBSD: netbsd32_compat_43.c,v 1.9 1999/12/30 15:40:45 eeh 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 <vm/vm.h> /* XXX for <sys/sysctl.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 NETBSD32_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 NETBSD32_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 NETBSD32_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 /* virtual memory syscalls */
422 int
423 netbsd32_ovadvise(p, v, retval)
424 struct proc *p;
425 void *v;
426 register_t *retval;
427 {
428 struct netbsd32_ovadvise_args /* {
429 syscallarg(int) anom;
430 } */ *uap = v;
431 struct sys_ovadvise_args ua;
432
433 NETBSD32TO64_UAP(anom);
434 return (sys_ovadvise(p, &ua, retval));
435 }
436
437 /* network syscalls */
438 int
439 compat_43_netbsd32_oaccept(p, v, retval)
440 struct proc *p;
441 void *v;
442 register_t *retval;
443 {
444 struct compat_43_netbsd32_oaccept_args /* {
445 syscallarg(int) s;
446 syscallarg(netbsd32_caddr_t) name;
447 syscallarg(netbsd32_intp) anamelen;
448 } */ *uap = v;
449 struct compat_43_sys_accept_args ua;
450
451 NETBSD32TOX_UAP(s, int);
452 NETBSD32TOX64_UAP(name, caddr_t);
453 NETBSD32TOP_UAP(anamelen, int);
454 return (compat_43_sys_accept(p, &ua, retval));
455 }
456
457 int
458 compat_43_netbsd32_osend(p, v, retval)
459 struct proc *p;
460 void *v;
461 register_t *retval;
462 {
463 struct compat_43_netbsd32_osend_args /* {
464 syscallarg(int) s;
465 syscallarg(netbsd32_caddr_t) buf;
466 syscallarg(int) len;
467 syscallarg(int) flags;
468 } */ *uap = v;
469 struct compat_43_sys_send_args ua;
470
471 NETBSD32TO64_UAP(s);
472 NETBSD32TOX64_UAP(buf, caddr_t);
473 NETBSD32TO64_UAP(len);
474 NETBSD32TO64_UAP(flags);
475 return (compat_43_sys_send(p, &ua, retval));
476 }
477
478 int
479 compat_43_netbsd32_orecv(p, v, retval)
480 struct proc *p;
481 void *v;
482 register_t *retval;
483 {
484 struct compat_43_netbsd32_orecv_args /* {
485 syscallarg(int) s;
486 syscallarg(netbsd32_caddr_t) buf;
487 syscallarg(int) len;
488 syscallarg(int) flags;
489 } */ *uap = v;
490 struct compat_43_sys_recv_args ua;
491
492 NETBSD32TO64_UAP(s);
493 NETBSD32TOX64_UAP(buf, caddr_t);
494 NETBSD32TO64_UAP(len);
495 NETBSD32TO64_UAP(flags);
496 return (compat_43_sys_recv(p, &ua, retval));
497 }
498
499 /*
500 * XXX convert these to use a common iovec code to the native
501 * netbsd call.
502 */
503 int
504 compat_43_netbsd32_orecvmsg(p, v, retval)
505 struct proc *p;
506 void *v;
507 register_t *retval;
508 {
509 struct compat_43_netbsd32_orecvmsg_args /* {
510 syscallarg(int) s;
511 syscallarg(netbsd32_omsghdrp_t) msg;
512 syscallarg(int) flags;
513 } */ *uap = v;
514 struct compat_43_sys_recvmsg_args ua;
515 struct omsghdr omh;
516 struct omsghdr *omhp = &omh;
517 struct netbsd32_omsghdr *omhp32;
518 struct iovec *iovec43p;
519 struct netbsd32_iovec *iovec32p;
520 int i;
521
522 NETBSD32TO64_UAP(s);
523 NETBSD32TO64_UAP(flags);
524
525 SCARG(&ua, msg) = omhp;
526 omhp32 = (struct netbsd32_omsghdr *)(u_long)SCARG(uap, msg);
527 omhp->msg_name = (caddr_t)(u_long)omhp32->msg_name;
528 omhp->msg_namelen = omhp32->msg_namelen;
529 omhp->msg_iovlen = (size_t)omhp32->msg_iovlen;
530 MALLOC(omhp->msg_iov, struct iovec *, sizeof(struct iovec) * omhp->msg_iovlen, M_TEMP, M_WAITOK);
531 iovec43p = omhp->msg_iov;
532 iovec32p = (struct netbsd32_iovec *)(u_long)omhp32->msg_iov;
533 for (i = 0; i < omhp->msg_iovlen; i++, iovec43p++, iovec32p++) {
534 iovec43p->iov_base = (struct iovec *)(u_long)iovec32p->iov_base;
535 iovec43p->iov_len = (size_t)iovec32p->iov_len;
536 }
537
538 omhp->msg_accrights = (caddr_t)(u_long)omhp32->msg_accrights;
539 omhp->msg_accrightslen = omhp32->msg_accrightslen;
540
541 return (compat_43_sys_recvmsg(p, &ua, retval));
542 }
543
544 int
545 compat_43_netbsd32_osendmsg(p, v, retval)
546 struct proc *p;
547 void *v;
548 register_t *retval;
549 {
550 struct compat_43_netbsd32_osendmsg_args /* {
551 syscallarg(int) s;
552 syscallarg(netbsd32_caddr_t) msg;
553 syscallarg(int) flags;
554 } */ *uap = v;
555 struct compat_43_sys_sendmsg_args ua;
556 struct omsghdr omh;
557 struct omsghdr *omhp = &omh;
558 struct netbsd32_omsghdr *omhp32;
559 struct iovec *iovec43p;
560 struct netbsd32_iovec *iovec32p;
561 int i;
562
563 NETBSD32TO64_UAP(s);
564 NETBSD32TO64_UAP(flags);
565
566 SCARG(&ua, msg) = (caddr_t)(u_long)omhp;
567 omhp32 = (struct netbsd32_omsghdr *)(u_long)SCARG(uap, msg);
568 omhp->msg_name = (caddr_t)(u_long)omhp32->msg_name;
569 omhp->msg_namelen = omhp32->msg_namelen;
570 omhp->msg_iovlen = (size_t)omhp32->msg_iovlen;
571 MALLOC(omhp->msg_iov, struct iovec *, sizeof(struct iovec) * omhp->msg_iovlen, M_TEMP, M_WAITOK);
572 iovec43p = omhp->msg_iov;
573 iovec32p = (struct netbsd32_iovec *)(u_long)omhp32->msg_iov;
574 for (i = 0; i < omhp->msg_iovlen; i++, iovec43p++, iovec32p++) {
575 iovec43p->iov_base = (void *)(u_long)iovec32p->iov_base;
576 iovec43p->iov_len = (size_t)iovec32p->iov_len;
577 }
578
579 omhp->msg_accrights = (caddr_t)(u_long)omhp32->msg_accrights;
580 omhp->msg_accrightslen = omhp32->msg_accrightslen;
581
582 return (compat_43_sys_sendmsg(p, &ua, retval));
583 }
584
585 int
586 compat_43_netbsd32_orecvfrom(p, v, retval)
587 struct proc *p;
588 void *v;
589 register_t *retval;
590 {
591 struct compat_43_netbsd32_orecvfrom_args /* {
592 syscallarg(int) s;
593 syscallarg(netbsd32_caddr_t) buf;
594 syscallarg(netbsd32_size_t) len;
595 syscallarg(int) flags;
596 syscallarg(netbsd32_caddr_t) from;
597 syscallarg(netbsd32_intp) fromlenaddr;
598 } */ *uap = v;
599 struct compat_43_sys_recvfrom_args ua;
600
601 NETBSD32TO64_UAP(s);
602 NETBSD32TOX64_UAP(buf, caddr_t);
603 NETBSD32TOX_UAP(len, size_t);
604 NETBSD32TO64_UAP(flags);
605 NETBSD32TOX64_UAP(from, caddr_t);
606 NETBSD32TOP_UAP(fromlenaddr, int);
607 return (compat_43_sys_recvfrom(p, &ua, retval));
608 }
609
610 int
611 compat_43_netbsd32_ogetsockname(p, v, retval)
612 struct proc *p;
613 void *v;
614 register_t *retval;
615 {
616 struct compat_43_netbsd32_ogetsockname_args /* {
617 syscallarg(int) fdec;
618 syscallarg(netbsd32_caddr_t) asa;
619 syscallarg(netbsd32_intp) alen;
620 } */ *uap = v;
621 struct compat_43_sys_getsockname_args ua;
622
623 NETBSD32TO64_UAP(fdec);
624 NETBSD32TOX64_UAP(asa, caddr_t);
625 NETBSD32TOP_UAP(alen, int);
626 return (compat_43_sys_getsockname(p, &ua, retval));
627 }
628
629 int
630 compat_43_netbsd32_ogetpeername(p, v, retval)
631 struct proc *p;
632 void *v;
633 register_t *retval;
634 {
635 struct compat_43_netbsd32_ogetpeername_args /* {
636 syscallarg(int) fdes;
637 syscallarg(netbsd32_caddr_t) asa;
638 syscallarg(netbsd32_intp) alen;
639 } */ *uap = v;
640 struct compat_43_sys_getpeername_args ua;
641
642 NETBSD32TO64_UAP(fdes);
643 NETBSD32TOX64_UAP(asa, caddr_t);
644 NETBSD32TOP_UAP(alen, int);
645 return (compat_43_sys_getpeername(p, &ua, retval));
646 }
647
648 /* signal syscalls */
649 int
650 compat_43_netbsd32_osigvec(p, v, retval)
651 struct proc *p;
652 void *v;
653 register_t *retval;
654 {
655 struct compat_43_netbsd32_osigvec_args /* {
656 syscallarg(int) signum;
657 syscallarg(netbsd32_sigvecp_t) nsv;
658 syscallarg(netbsd32_sigvecp_t) osv;
659 } */ *uap = v;
660 struct compat_43_sys_sigvec_args ua;
661 struct netbsd32_sigvec *sv32p;
662 struct sigvec nsv, osv;
663 int rv;
664
665 NETBSD32TO64_UAP(signum);
666 if (SCARG(uap, osv))
667 SCARG(&ua, osv) = &osv;
668 else
669 SCARG(&ua, osv) = NULL;
670 if (SCARG(uap, nsv)) {
671 SCARG(&ua, nsv) = &nsv;
672 sv32p = (struct netbsd32_sigvec *)(u_long)SCARG(uap, nsv);
673 nsv.sv_handler = (void *)(u_long)sv32p->sv_handler;
674 nsv.sv_mask = sv32p->sv_mask;
675 nsv.sv_flags = sv32p->sv_flags;
676 } else
677 SCARG(&ua, nsv) = NULL;
678 rv = compat_43_sys_sigvec(p, &ua, retval);
679 if (rv)
680 return (rv);
681
682 if (SCARG(uap, osv)) {
683 sv32p = (struct netbsd32_sigvec *)(u_long)SCARG(uap, osv);
684 sv32p->sv_handler = (netbsd32_sigvecp_t)(u_long)osv.sv_handler;
685 sv32p->sv_mask = osv.sv_mask;
686 sv32p->sv_flags = osv.sv_flags;
687 }
688
689 return (0);
690 }
691
692 int
693 compat_43_netbsd32_sigblock(p, v, retval)
694 struct proc *p;
695 void *v;
696 register_t *retval;
697 {
698 struct compat_43_netbsd32_sigblock_args /* {
699 syscallarg(int) mask;
700 } */ *uap = v;
701 struct compat_43_sys_sigblock_args ua;
702
703 NETBSD32TO64_UAP(mask);
704 return (compat_43_sys_sigblock(p, &ua, retval));
705 }
706
707 int
708 compat_43_netbsd32_sigsetmask(p, v, retval)
709 struct proc *p;
710 void *v;
711 register_t *retval;
712 {
713 struct compat_43_netbsd32_sigsetmask_args /* {
714 syscallarg(int) mask;
715 } */ *uap = v;
716 struct compat_43_sys_sigsetmask_args ua;
717
718 NETBSD32TO64_UAP(mask);
719 return (compat_43_sys_sigsetmask(p, &ua, retval));
720 }
721
722 int
723 compat_43_netbsd32_osigstack(p, v, retval)
724 struct proc *p;
725 void *v;
726 register_t *retval;
727 {
728 struct compat_43_netbsd32_osigstack_args /* {
729 syscallarg(netbsd32_sigstackp_t) nss;
730 syscallarg(netbsd32_sigstackp_t) oss;
731 } */ *uap = v;
732 struct compat_43_sys_sigstack_args ua;
733 struct netbsd32_sigstack *ss32p;
734 struct sigstack nss, oss;
735 int rv;
736
737 if (SCARG(uap, oss))
738 SCARG(&ua, oss) = &oss;
739 else
740 SCARG(&ua, oss) = NULL;
741 if (SCARG(uap, nss)) {
742 SCARG(&ua, nss) = &nss;
743 ss32p = (struct netbsd32_sigstack *)(u_long)SCARG(uap, nss);
744 nss.ss_sp = (void *)(u_long)ss32p->ss_sp;
745 nss.ss_onstack = ss32p->ss_onstack;
746 } else
747 SCARG(&ua, nss) = NULL;
748
749 rv = compat_43_sys_sigstack(p, &ua, retval);
750 if (rv)
751 return (rv);
752
753 if (SCARG(uap, oss)) {
754 ss32p = (struct netbsd32_sigstack *)(u_long)SCARG(uap, oss);
755 ss32p->ss_sp = (netbsd32_sigstackp_t)(u_long)oss.ss_sp;
756 ss32p->ss_onstack = oss.ss_onstack;
757 }
758
759 return (0);
760 }
761