xref: /netbsd-src/sys/compat/netbsd32/netbsd32_netbsd.c (revision 27578b9aac214cc7796ead81dcc5427e79d5f2a0)
1 /*	$NetBSD: netbsd32_netbsd.c,v 1.61 2001/09/18 19:36:40 jdolecek Exp $	*/
2 
3 /*
4  * Copyright (c) 1998, 2001 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_OPT)
32 #include "opt_ddb.h"
33 #include "opt_ktrace.h"
34 #include "opt_ntp.h"
35 #include "opt_compat_netbsd.h"
36 #include "opt_compat_43.h"
37 #include "opt_sysv.h"
38 
39 #include "fs_lfs.h"
40 #include "fs_nfs.h"
41 #endif
42 
43 /*
44  * Though COMPAT_OLDSOCK is needed only for COMPAT_43, SunOS, Linux,
45  * HP-UX, FreeBSD, Ultrix, OSF1, we define it unconditionally so that
46  * this would be LKM-safe.
47  */
48 #define COMPAT_OLDSOCK /* used by <sys/socket.h> */
49 
50 #include <sys/param.h>
51 #include <sys/systm.h>
52 #include <sys/kernel.h>
53 //#define msg __msg /* Don't ask me! */
54 #include <sys/malloc.h>
55 #include <sys/mount.h>
56 #include <sys/socket.h>
57 #include <sys/sockio.h>
58 #include <sys/socketvar.h>
59 #include <sys/mbuf.h>
60 #include <sys/stat.h>
61 #include <sys/time.h>
62 #include <sys/signalvar.h>
63 #include <sys/ptrace.h>
64 #include <sys/ktrace.h>
65 #include <sys/trace.h>
66 #include <sys/resourcevar.h>
67 #include <sys/pool.h>
68 #include <sys/vnode.h>
69 #include <sys/file.h>
70 #include <sys/filedesc.h>
71 #include <sys/namei.h>
72 
73 #include <uvm/uvm_extern.h>
74 
75 #include <sys/syscallargs.h>
76 #include <sys/proc.h>
77 #include <sys/acct.h>
78 #include <sys/exec.h>
79 
80 #include <net/if.h>
81 
82 #include <compat/netbsd32/netbsd32.h>
83 #include <compat/netbsd32/netbsd32_syscall.h>
84 #include <compat/netbsd32/netbsd32_syscallargs.h>
85 #include <compat/netbsd32/netbsd32_conv.h>
86 
87 #include <machine/frame.h>
88 
89 #if defined(DDB)
90 #include <ddb/ddbvar.h>
91 #endif
92 
93 extern char netbsd32_sigcode[], netbsd32_esigcode[];
94 extern struct sysent netbsd32_sysent[];
95 #ifdef SYSCALL_DEBUG
96 extern const char * const netbsd32_syscallnames[];
97 #endif
98 #ifdef __HAVE_SYSCALL_INTERN
99 void netbsd32_syscall_intern __P((struct proc *));
100 #else
101 void syscall __P((void));
102 #endif
103 
104 const struct emul emul_netbsd32 = {
105 	"netbsd32",
106 	"/emul/netbsd32",
107 #ifndef __HAVE_MINIMAL_EMUL
108 	0,
109 	NULL,
110 	netbsd32_SYS_syscall,
111 	netbsd32_SYS_MAXSYSCALL,
112 #endif
113 	netbsd32_sysent,
114 #ifdef SYSCALL_DEBUG
115 	netbsd32_syscallnames,
116 #else
117 	NULL,
118 #endif
119 	netbsd32_sendsig,
120 	trapsignal,
121 	netbsd32_sigcode,
122 	netbsd32_esigcode,
123 	netbsd32_setregs,
124 	NULL,
125 	NULL,
126 	NULL,
127 #ifdef __HAVE_SYSCALL_INTERN
128 	netbsd32_syscall_intern,
129 #else
130 	syscall,
131 #endif
132 };
133 
134 /*
135  * below are all the standard NetBSD system calls, in the 32bit
136  * environment, with the necessary conversions to 64bit before
137  * calling the real syscall.  anything that needs special
138  * attention is handled elsewhere.
139  */
140 
141 int
142 netbsd32_exit(p, v, retval)
143 	struct proc *p;
144 	void *v;
145 	register_t *retval;
146 {
147 	struct netbsd32_exit_args /* {
148 		syscallarg(int) rval;
149 	} */ *uap = v;
150 	struct sys_exit_args ua;
151 
152 	NETBSD32TO64_UAP(rval);
153 	return sys_exit(p, &ua, retval);
154 }
155 
156 int
157 netbsd32_read(p, v, retval)
158 	struct proc *p;
159 	void *v;
160 	register_t *retval;
161 {
162 	struct netbsd32_read_args /* {
163 		syscallarg(int) fd;
164 		syscallarg(netbsd32_voidp) buf;
165 		syscallarg(netbsd32_size_t) nbyte;
166 	} */ *uap = v;
167 	struct sys_read_args ua;
168 
169 	NETBSD32TO64_UAP(fd);
170 	NETBSD32TOP_UAP(buf, void *);
171 	NETBSD32TOX_UAP(nbyte, size_t);
172 	return sys_read(p, &ua, retval);
173 }
174 
175 int
176 netbsd32_write(p, v, retval)
177 	struct proc *p;
178 	void *v;
179 	register_t *retval;
180 {
181 	struct netbsd32_write_args /* {
182 		syscallarg(int) fd;
183 		syscallarg(const netbsd32_voidp) buf;
184 		syscallarg(netbsd32_size_t) nbyte;
185 	} */ *uap = v;
186 	struct sys_write_args ua;
187 
188 	NETBSD32TO64_UAP(fd);
189 	NETBSD32TOP_UAP(buf, void *);
190 	NETBSD32TOX_UAP(nbyte, size_t);
191 	return sys_write(p, &ua, retval);
192 }
193 
194 int
195 netbsd32_close(p, v, retval)
196 	struct proc *p;
197 	void *v;
198 	register_t *retval;
199 {
200 	struct netbsd32_close_args /* {
201 		syscallarg(int) fd;
202 	} */ *uap = v;
203 	struct sys_close_args ua;
204 
205 	NETBSD32TO64_UAP(fd);
206 	return sys_close(p, &ua, retval);
207 }
208 
209 int
210 netbsd32_open(p, v, retval)
211 	struct proc *p;
212 	void *v;
213 	register_t *retval;
214 {
215 	struct netbsd32_open_args /* {
216 		syscallarg(const netbsd32_charp) path;
217 		syscallarg(int) flags;
218 		syscallarg(mode_t) mode;
219 	} */ *uap = v;
220 	struct sys_open_args ua;
221 	caddr_t sg;
222 
223 	NETBSD32TOP_UAP(path, const char);
224 	NETBSD32TO64_UAP(flags);
225 	NETBSD32TO64_UAP(mode);
226 	sg = stackgap_init(p->p_emul);
227 	CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path));
228 
229 	return (sys_open(p, &ua, retval));
230 }
231 
232 int
233 netbsd32_link(p, v, retval)
234 	struct proc *p;
235 	void *v;
236 	register_t *retval;
237 {
238 	struct netbsd32_link_args /* {
239 		syscallarg(const netbsd32_charp) path;
240 		syscallarg(const netbsd32_charp) link;
241 	} */ *uap = v;
242 	struct sys_link_args ua;
243 
244 	NETBSD32TOP_UAP(path, const char);
245 	NETBSD32TOP_UAP(link, const char);
246 	return (sys_link(p, &ua, retval));
247 }
248 
249 int
250 netbsd32_unlink(p, v, retval)
251 	struct proc *p;
252 	void *v;
253 	register_t *retval;
254 {
255 	struct netbsd32_unlink_args /* {
256 		syscallarg(const netbsd32_charp) path;
257 	} */ *uap = v;
258 	struct sys_unlink_args ua;
259 
260 	NETBSD32TOP_UAP(path, const char);
261 
262 	return (sys_unlink(p, &ua, retval));
263 }
264 
265 int
266 netbsd32_chdir(p, v, retval)
267 	struct proc *p;
268 	void *v;
269 	register_t *retval;
270 {
271 	struct netbsd32_chdir_args /* {
272 		syscallarg(const netbsd32_charp) path;
273 	} */ *uap = v;
274 	struct sys_chdir_args ua;
275 
276 	NETBSD32TOP_UAP(path, const char);
277 
278 	return (sys_chdir(p, &ua, retval));
279 }
280 
281 int
282 netbsd32_fchdir(p, v, retval)
283 	struct proc *p;
284 	void *v;
285 	register_t *retval;
286 {
287 	struct netbsd32_fchdir_args /* {
288 		syscallarg(int) fd;
289 	} */ *uap = v;
290 	struct sys_fchdir_args ua;
291 
292 	NETBSD32TO64_UAP(fd);
293 
294 	return (sys_fchdir(p, &ua, retval));
295 }
296 
297 int
298 netbsd32_mknod(p, v, retval)
299 	struct proc *p;
300 	void *v;
301 	register_t *retval;
302 {
303 	struct netbsd32_mknod_args /* {
304 		syscallarg(const netbsd32_charp) path;
305 		syscallarg(mode_t) mode;
306 		syscallarg(dev_t) dev;
307 	} */ *uap = v;
308 	struct sys_mknod_args ua;
309 
310 	NETBSD32TOP_UAP(path, const char);
311 	NETBSD32TO64_UAP(dev);
312 	NETBSD32TO64_UAP(mode);
313 
314 	return (sys_mknod(p, &ua, retval));
315 }
316 
317 int
318 netbsd32_chmod(p, v, retval)
319 	struct proc *p;
320 	void *v;
321 	register_t *retval;
322 {
323 	struct netbsd32_chmod_args /* {
324 		syscallarg(const netbsd32_charp) path;
325 		syscallarg(mode_t) mode;
326 	} */ *uap = v;
327 	struct sys_chmod_args ua;
328 
329 	NETBSD32TOP_UAP(path, const char);
330 	NETBSD32TO64_UAP(mode);
331 
332 	return (sys_chmod(p, &ua, retval));
333 }
334 
335 int
336 netbsd32_chown(p, v, retval)
337 	struct proc *p;
338 	void *v;
339 	register_t *retval;
340 {
341 	struct netbsd32_chown_args /* {
342 		syscallarg(const netbsd32_charp) path;
343 		syscallarg(uid_t) uid;
344 		syscallarg(gid_t) gid;
345 	} */ *uap = v;
346 	struct sys_chown_args ua;
347 
348 	NETBSD32TOP_UAP(path, const char);
349 	NETBSD32TO64_UAP(uid);
350 	NETBSD32TO64_UAP(gid);
351 
352 	return (sys_chown(p, &ua, retval));
353 }
354 
355 int
356 netbsd32_break(p, v, retval)
357 	struct proc *p;
358 	void *v;
359 	register_t *retval;
360 {
361 	struct netbsd32_break_args /* {
362 		syscallarg(netbsd32_charp) nsize;
363 	} */ *uap = v;
364 	struct sys_obreak_args ua;
365 
366 	SCARG(&ua, nsize) = (char *)(u_long)SCARG(uap, nsize);
367 	NETBSD32TOP_UAP(nsize, char);
368 	return (sys_obreak(p, &ua, retval));
369 }
370 
371 int
372 netbsd32_mount(p, v, retval)
373 	struct proc *p;
374 	void *v;
375 	register_t *retval;
376 {
377 	struct netbsd32_mount_args /* {
378 		syscallarg(const netbsd32_charp) type;
379 		syscallarg(const netbsd32_charp) path;
380 		syscallarg(int) flags;
381 		syscallarg(netbsd32_voidp) data;
382 	} */ *uap = v;
383 	struct sys_mount_args ua;
384 
385 	NETBSD32TOP_UAP(type, const char);
386 	NETBSD32TOP_UAP(path, const char);
387 	NETBSD32TO64_UAP(flags);
388 	NETBSD32TOP_UAP(data, void);
389 	return (sys_mount(p, &ua, retval));
390 }
391 
392 int
393 netbsd32_unmount(p, v, retval)
394 	struct proc *p;
395 	void *v;
396 	register_t *retval;
397 {
398 	struct netbsd32_unmount_args /* {
399 		syscallarg(const netbsd32_charp) path;
400 		syscallarg(int) flags;
401 	} */ *uap = v;
402 	struct sys_unmount_args ua;
403 
404 	NETBSD32TOP_UAP(path, const char);
405 	NETBSD32TO64_UAP(flags);
406 	return (sys_unmount(p, &ua, retval));
407 }
408 
409 int
410 netbsd32_setuid(p, v, retval)
411 	struct proc *p;
412 	void *v;
413 	register_t *retval;
414 {
415 	struct netbsd32_setuid_args /* {
416 		syscallarg(uid_t) uid;
417 	} */ *uap = v;
418 	struct sys_setuid_args ua;
419 
420 	NETBSD32TO64_UAP(uid);
421 	return (sys_setuid(p, &ua, retval));
422 }
423 
424 int
425 netbsd32_ptrace(p, v, retval)
426 	struct proc *p;
427 	void *v;
428 	register_t *retval;
429 {
430 	struct netbsd32_ptrace_args /* {
431 		syscallarg(int) req;
432 		syscallarg(pid_t) pid;
433 		syscallarg(netbsd32_caddr_t) addr;
434 		syscallarg(int) data;
435 	} */ *uap = v;
436 	struct sys_ptrace_args ua;
437 
438 	NETBSD32TO64_UAP(req);
439 	NETBSD32TO64_UAP(pid);
440 	NETBSD32TOX64_UAP(addr, caddr_t);
441 	NETBSD32TO64_UAP(data);
442 	return (sys_ptrace(p, &ua, retval));
443 }
444 
445 int
446 netbsd32_accept(p, v, retval)
447 	struct proc *p;
448 	void *v;
449 	register_t *retval;
450 {
451 	struct netbsd32_accept_args /* {
452 		syscallarg(int) s;
453 		syscallarg(netbsd32_sockaddrp_t) name;
454 		syscallarg(netbsd32_intp) anamelen;
455 	} */ *uap = v;
456 	struct sys_accept_args ua;
457 
458 	NETBSD32TO64_UAP(s);
459 	NETBSD32TOP_UAP(name, struct sockaddr);
460 	NETBSD32TOP_UAP(anamelen, int);
461 	return (sys_accept(p, &ua, retval));
462 }
463 
464 int
465 netbsd32_getpeername(p, v, retval)
466 	struct proc *p;
467 	void *v;
468 	register_t *retval;
469 {
470 	struct netbsd32_getpeername_args /* {
471 		syscallarg(int) fdes;
472 		syscallarg(netbsd32_sockaddrp_t) asa;
473 		syscallarg(netbsd32_intp) alen;
474 	} */ *uap = v;
475 	struct sys_getpeername_args ua;
476 
477 	NETBSD32TO64_UAP(fdes);
478 	NETBSD32TOP_UAP(asa, struct sockaddr);
479 	NETBSD32TOP_UAP(alen, int);
480 /* NB: do the protocol specific sockaddrs need to be converted? */
481 	return (sys_getpeername(p, &ua, retval));
482 }
483 
484 int
485 netbsd32_getsockname(p, v, retval)
486 	struct proc *p;
487 	void *v;
488 	register_t *retval;
489 {
490 	struct netbsd32_getsockname_args /* {
491 		syscallarg(int) fdes;
492 		syscallarg(netbsd32_sockaddrp_t) asa;
493 		syscallarg(netbsd32_intp) alen;
494 	} */ *uap = v;
495 	struct sys_getsockname_args ua;
496 
497 	NETBSD32TO64_UAP(fdes);
498 	NETBSD32TOP_UAP(asa, struct sockaddr);
499 	NETBSD32TOP_UAP(alen, int);
500 	return (sys_getsockname(p, &ua, retval));
501 }
502 
503 int
504 netbsd32_access(p, v, retval)
505 	struct proc *p;
506 	void *v;
507 	register_t *retval;
508 {
509 	struct netbsd32_access_args /* {
510 		syscallarg(const netbsd32_charp) path;
511 		syscallarg(int) flags;
512 	} */ *uap = v;
513 	struct sys_access_args ua;
514 	caddr_t sg;
515 
516 	NETBSD32TOP_UAP(path, const char);
517 	NETBSD32TO64_UAP(flags);
518 	sg = stackgap_init(p->p_emul);
519 	CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path));
520 
521 	return (sys_access(p, &ua, retval));
522 }
523 
524 int
525 netbsd32_chflags(p, v, retval)
526 	struct proc *p;
527 	void *v;
528 	register_t *retval;
529 {
530 	struct netbsd32_chflags_args /* {
531 		syscallarg(const netbsd32_charp) path;
532 		syscallarg(netbsd32_u_long) flags;
533 	} */ *uap = v;
534 	struct sys_chflags_args ua;
535 
536 	NETBSD32TOP_UAP(path, const char);
537 	NETBSD32TO64_UAP(flags);
538 
539 	return (sys_chflags(p, &ua, retval));
540 }
541 
542 int
543 netbsd32_fchflags(p, v, retval)
544 	struct proc *p;
545 	void *v;
546 	register_t *retval;
547 {
548 	struct netbsd32_fchflags_args /* {
549 		syscallarg(int) fd;
550 		syscallarg(netbsd32_u_long) flags;
551 	} */ *uap = v;
552 	struct sys_fchflags_args ua;
553 
554 	NETBSD32TO64_UAP(fd);
555 	NETBSD32TO64_UAP(flags);
556 
557 	return (sys_fchflags(p, &ua, retval));
558 }
559 
560 int
561 netbsd32_lchflags(p, v, retval)
562 	struct proc *p;
563 	void *v;
564 	register_t *retval;
565 {
566 	struct netbsd32_lchflags_args /* {
567 		syscallarg(int) fd;
568 		syscallarg(netbsd32_u_long) flags;
569 	} */ *uap = v;
570 	struct sys_lchflags_args ua;
571 
572 	NETBSD32TOP_UAP(path, const char);
573 	NETBSD32TO64_UAP(flags);
574 
575 	return (sys_lchflags(p, &ua, retval));
576 }
577 
578 int
579 netbsd32_kill(p, v, retval)
580 	struct proc *p;
581 	void *v;
582 	register_t *retval;
583 {
584 	struct netbsd32_kill_args /* {
585 		syscallarg(int) pid;
586 		syscallarg(int) signum;
587 	} */ *uap = v;
588 	struct sys_kill_args ua;
589 
590 	NETBSD32TO64_UAP(pid);
591 	NETBSD32TO64_UAP(signum);
592 
593 	return (sys_kill(p, &ua, retval));
594 }
595 
596 int
597 netbsd32_dup(p, v, retval)
598 	struct proc *p;
599 	void *v;
600 	register_t *retval;
601 {
602 	struct netbsd32_dup_args /* {
603 		syscallarg(int) fd;
604 	} */ *uap = v;
605 	struct sys_dup_args ua;
606 
607 	NETBSD32TO64_UAP(fd);
608 
609 	return (sys_dup(p, &ua, retval));
610 }
611 
612 int
613 netbsd32_profil(p, v, retval)
614 	struct proc *p;
615 	void *v;
616 	register_t *retval;
617 {
618 	struct netbsd32_profil_args /* {
619 		syscallarg(netbsd32_caddr_t) samples;
620 		syscallarg(netbsd32_size_t) size;
621 		syscallarg(netbsd32_u_long) offset;
622 		syscallarg(u_int) scale;
623 	} */ *uap = v;
624 	struct sys_profil_args ua;
625 
626 	NETBSD32TOX64_UAP(samples, caddr_t);
627 	NETBSD32TOX_UAP(size, size_t);
628 	NETBSD32TOX_UAP(offset, u_long);
629 	NETBSD32TO64_UAP(scale);
630 	return (sys_profil(p, &ua, retval));
631 }
632 
633 #ifdef KTRACE
634 int
635 netbsd32_ktrace(p, v, retval)
636 	struct proc *p;
637 	void *v;
638 	register_t *retval;
639 {
640 	struct netbsd32_ktrace_args /* {
641 		syscallarg(const netbsd32_charp) fname;
642 		syscallarg(int) ops;
643 		syscallarg(int) facs;
644 		syscallarg(int) pid;
645 	} */ *uap = v;
646 	struct sys_ktrace_args ua;
647 
648 	NETBSD32TOP_UAP(fname, const char);
649 	NETBSD32TO64_UAP(ops);
650 	NETBSD32TO64_UAP(facs);
651 	NETBSD32TO64_UAP(pid);
652 	return (sys_ktrace(p, &ua, retval));
653 }
654 #endif /* KTRACE */
655 
656 int
657 netbsd32_utrace(p, v, retval)
658 	struct proc *p;
659 	void *v;
660 	register_t *retval;
661 {
662 	struct netbsd32_utrace_args /* {
663 		syscallarg(const netbsd32_charp) label;
664 		syscallarg(netbsd32_voidp) addr;
665 		syscallarg(netbsd32_size_t) len;
666 	} */ *uap = v;
667 	struct sys_utrace_args ua;
668 
669 	NETBSD32TOP_UAP(label, const char);
670 	NETBSD32TOP_UAP(addr, void);
671 	NETBSD32TO64_UAP(len);
672 	return (sys_utrace(p, &ua, retval));
673 }
674 
675 int
676 netbsd32___getlogin(p, v, retval)
677 	struct proc *p;
678 	void *v;
679 	register_t *retval;
680 {
681 	struct netbsd32___getlogin_args /* {
682 		syscallarg(netbsd32_charp) namebuf;
683 		syscallarg(u_int) namelen;
684 	} */ *uap = v;
685 	struct sys___getlogin_args ua;
686 
687 	NETBSD32TOP_UAP(namebuf, char);
688 	NETBSD32TO64_UAP(namelen);
689 	return (sys___getlogin(p, &ua, retval));
690 }
691 
692 int
693 netbsd32_setlogin(p, v, retval)
694 	struct proc *p;
695 	void *v;
696 	register_t *retval;
697 {
698 	struct netbsd32_setlogin_args /* {
699 		syscallarg(const netbsd32_charp) namebuf;
700 	} */ *uap = v;
701 	struct sys_setlogin_args ua;
702 
703 	NETBSD32TOP_UAP(namebuf, char);
704 	return (sys_setlogin(p, &ua, retval));
705 }
706 
707 int
708 netbsd32_acct(p, v, retval)
709 	struct proc *p;
710 	void *v;
711 	register_t *retval;
712 {
713 	struct netbsd32_acct_args /* {
714 		syscallarg(const netbsd32_charp) path;
715 	} */ *uap = v;
716 	struct sys_acct_args ua;
717 
718 	NETBSD32TOP_UAP(path, const char);
719 	return (sys_acct(p, &ua, retval));
720 }
721 
722 int
723 netbsd32_revoke(p, v, retval)
724 	struct proc *p;
725 	void *v;
726 	register_t *retval;
727 {
728 	struct netbsd32_revoke_args /* {
729 		syscallarg(const netbsd32_charp) path;
730 	} */ *uap = v;
731 	struct sys_revoke_args ua;
732 	caddr_t sg;
733 
734 	NETBSD32TOP_UAP(path, const char);
735 	sg = stackgap_init(p->p_emul);
736 	CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path));
737 
738 	return (sys_revoke(p, &ua, retval));
739 }
740 
741 int
742 netbsd32_symlink(p, v, retval)
743 	struct proc *p;
744 	void *v;
745 	register_t *retval;
746 {
747 	struct netbsd32_symlink_args /* {
748 		syscallarg(const netbsd32_charp) path;
749 		syscallarg(const netbsd32_charp) link;
750 	} */ *uap = v;
751 	struct sys_symlink_args ua;
752 
753 	NETBSD32TOP_UAP(path, const char);
754 	NETBSD32TOP_UAP(link, const char);
755 
756 	return (sys_symlink(p, &ua, retval));
757 }
758 
759 int
760 netbsd32_readlink(p, v, retval)
761 	struct proc *p;
762 	void *v;
763 	register_t *retval;
764 {
765 	struct netbsd32_readlink_args /* {
766 		syscallarg(const netbsd32_charp) path;
767 		syscallarg(netbsd32_charp) buf;
768 		syscallarg(netbsd32_size_t) count;
769 	} */ *uap = v;
770 	struct sys_readlink_args ua;
771 	caddr_t sg;
772 
773 	NETBSD32TOP_UAP(path, const char);
774 	NETBSD32TOP_UAP(buf, char);
775 	NETBSD32TOX_UAP(count, size_t);
776 	sg = stackgap_init(p->p_emul);
777 	CHECK_ALT_SYMLINK(p, &sg, SCARG(&ua, path));
778 
779 	return (sys_readlink(p, &ua, retval));
780 }
781 
782 int
783 netbsd32_umask(p, v, retval)
784 	struct proc *p;
785 	void *v;
786 	register_t *retval;
787 {
788 	struct netbsd32_umask_args /* {
789 		syscallarg(mode_t) newmask;
790 	} */ *uap = v;
791 	struct sys_umask_args ua;
792 
793 	NETBSD32TO64_UAP(newmask);
794 	return (sys_umask(p, &ua, retval));
795 }
796 
797 int
798 netbsd32_chroot(p, v, retval)
799 	struct proc *p;
800 	void *v;
801 	register_t *retval;
802 {
803 	struct netbsd32_chroot_args /* {
804 		syscallarg(const netbsd32_charp) path;
805 	} */ *uap = v;
806 	struct sys_chroot_args ua;
807 
808 	NETBSD32TOP_UAP(path, const char);
809 	return (sys_chroot(p, &ua, retval));
810 }
811 
812 int
813 netbsd32_sbrk(p, v, retval)
814 	struct proc *p;
815 	void *v;
816 	register_t *retval;
817 {
818 	struct netbsd32_sbrk_args /* {
819 		syscallarg(int) incr;
820 	} */ *uap = v;
821 	struct sys_sbrk_args ua;
822 
823 	NETBSD32TO64_UAP(incr);
824 	return (sys_sbrk(p, &ua, retval));
825 }
826 
827 int
828 netbsd32_sstk(p, v, retval)
829 	struct proc *p;
830 	void *v;
831 	register_t *retval;
832 {
833 	struct netbsd32_sstk_args /* {
834 		syscallarg(int) incr;
835 	} */ *uap = v;
836 	struct sys_sstk_args ua;
837 
838 	NETBSD32TO64_UAP(incr);
839 	return (sys_sstk(p, &ua, retval));
840 }
841 
842 int
843 netbsd32_munmap(p, v, retval)
844 	struct proc *p;
845 	void *v;
846 	register_t *retval;
847 {
848 	struct netbsd32_munmap_args /* {
849 		syscallarg(netbsd32_voidp) addr;
850 		syscallarg(netbsd32_size_t) len;
851 	} */ *uap = v;
852 	struct sys_munmap_args ua;
853 
854 	NETBSD32TOP_UAP(addr, void);
855 	NETBSD32TOX_UAP(len, size_t);
856 	return (sys_munmap(p, &ua, retval));
857 }
858 
859 int
860 netbsd32_mprotect(p, v, retval)
861 	struct proc *p;
862 	void *v;
863 	register_t *retval;
864 {
865 	struct netbsd32_mprotect_args /* {
866 		syscallarg(netbsd32_voidp) addr;
867 		syscallarg(netbsd32_size_t) len;
868 		syscallarg(int) prot;
869 	} */ *uap = v;
870 	struct sys_mprotect_args ua;
871 
872 	NETBSD32TOP_UAP(addr, void);
873 	NETBSD32TOX_UAP(len, size_t);
874 	NETBSD32TO64_UAP(prot);
875 	return (sys_mprotect(p, &ua, retval));
876 }
877 
878 int
879 netbsd32_madvise(p, v, retval)
880 	struct proc *p;
881 	void *v;
882 	register_t *retval;
883 {
884 	struct netbsd32_madvise_args /* {
885 		syscallarg(netbsd32_voidp) addr;
886 		syscallarg(netbsd32_size_t) len;
887 		syscallarg(int) behav;
888 	} */ *uap = v;
889 	struct sys_madvise_args ua;
890 
891 	NETBSD32TOP_UAP(addr, void);
892 	NETBSD32TOX_UAP(len, size_t);
893 	NETBSD32TO64_UAP(behav);
894 	return (sys_madvise(p, &ua, retval));
895 }
896 
897 int
898 netbsd32_mincore(p, v, retval)
899 	struct proc *p;
900 	void *v;
901 	register_t *retval;
902 {
903 	struct netbsd32_mincore_args /* {
904 		syscallarg(netbsd32_caddr_t) addr;
905 		syscallarg(netbsd32_size_t) len;
906 		syscallarg(netbsd32_charp) vec;
907 	} */ *uap = v;
908 	struct sys_mincore_args ua;
909 
910 	NETBSD32TOX64_UAP(addr, caddr_t);
911 	NETBSD32TOX_UAP(len, size_t);
912 	NETBSD32TOP_UAP(vec, char);
913 	return (sys_mincore(p, &ua, retval));
914 }
915 
916 /* XXX MOVE ME XXX ? */
917 int
918 netbsd32_getgroups(p, v, retval)
919 	struct proc *p;
920 	void *v;
921 	register_t *retval;
922 {
923 	struct netbsd32_getgroups_args /* {
924 		syscallarg(int) gidsetsize;
925 		syscallarg(netbsd32_gid_tp) gidset;
926 	} */ *uap = v;
927 	struct pcred *pc = p->p_cred;
928 	int ngrp;
929 	int error;
930 
931 	ngrp = SCARG(uap, gidsetsize);
932 	if (ngrp == 0) {
933 		*retval = pc->pc_ucred->cr_ngroups;
934 		return (0);
935 	}
936 	if (ngrp < pc->pc_ucred->cr_ngroups)
937 		return (EINVAL);
938 	ngrp = pc->pc_ucred->cr_ngroups;
939 	/* Should convert gid_t to netbsd32_gid_t, but they're the same */
940 	error = copyout((caddr_t)pc->pc_ucred->cr_groups,
941 			(caddr_t)(u_long)SCARG(uap, gidset),
942 			ngrp * sizeof(gid_t));
943 	if (error)
944 		return (error);
945 	*retval = ngrp;
946 	return (0);
947 }
948 
949 int
950 netbsd32_setgroups(p, v, retval)
951 	struct proc *p;
952 	void *v;
953 	register_t *retval;
954 {
955 	struct netbsd32_setgroups_args /* {
956 		syscallarg(int) gidsetsize;
957 		syscallarg(const netbsd32_gid_tp) gidset;
958 	} */ *uap = v;
959 	struct sys_setgroups_args ua;
960 
961 	NETBSD32TO64_UAP(gidsetsize);
962 	NETBSD32TOP_UAP(gidset, gid_t);
963 	return (sys_setgroups(p, &ua, retval));
964 }
965 
966 int
967 netbsd32_setpgid(p, v, retval)
968 	struct proc *p;
969 	void *v;
970 	register_t *retval;
971 {
972 	struct netbsd32_setpgid_args /* {
973 		syscallarg(int) pid;
974 		syscallarg(int) pgid;
975 	} */ *uap = v;
976 	struct sys_setpgid_args ua;
977 
978 	NETBSD32TO64_UAP(pid);
979 	NETBSD32TO64_UAP(pgid);
980 	return (sys_setpgid(p, &ua, retval));
981 }
982 
983 int
984 netbsd32_fcntl(p, v, retval)
985 	struct proc *p;
986 	void *v;
987 	register_t *retval;
988 {
989 	struct netbsd32_fcntl_args /* {
990 		syscallarg(int) fd;
991 		syscallarg(int) cmd;
992 		syscallarg(netbsd32_voidp) arg;
993 	} */ *uap = v;
994 	struct sys_fcntl_args ua;
995 
996 	NETBSD32TO64_UAP(fd);
997 	NETBSD32TO64_UAP(cmd);
998 	NETBSD32TOP_UAP(arg, void);
999 	/* we can do this because `struct flock' doesn't change */
1000 	return (sys_fcntl(p, &ua, retval));
1001 }
1002 
1003 int
1004 netbsd32_dup2(p, v, retval)
1005 	struct proc *p;
1006 	void *v;
1007 	register_t *retval;
1008 {
1009 	struct netbsd32_dup2_args /* {
1010 		syscallarg(int) from;
1011 		syscallarg(int) to;
1012 	} */ *uap = v;
1013 	struct sys_dup2_args ua;
1014 
1015 	NETBSD32TO64_UAP(from);
1016 	NETBSD32TO64_UAP(to);
1017 	return (sys_dup2(p, &ua, retval));
1018 }
1019 
1020 int
1021 netbsd32_fsync(p, v, retval)
1022 	struct proc *p;
1023 	void *v;
1024 	register_t *retval;
1025 {
1026 	struct netbsd32_fsync_args /* {
1027 		syscallarg(int) fd;
1028 	} */ *uap = v;
1029 	struct sys_fsync_args ua;
1030 
1031 	NETBSD32TO64_UAP(fd);
1032 	return (sys_fsync(p, &ua, retval));
1033 }
1034 
1035 int
1036 netbsd32_setpriority(p, v, retval)
1037 	struct proc *p;
1038 	void *v;
1039 	register_t *retval;
1040 {
1041 	struct netbsd32_setpriority_args /* {
1042 		syscallarg(int) which;
1043 		syscallarg(int) who;
1044 		syscallarg(int) prio;
1045 	} */ *uap = v;
1046 	struct sys_setpriority_args ua;
1047 
1048 	NETBSD32TO64_UAP(which);
1049 	NETBSD32TO64_UAP(who);
1050 	NETBSD32TO64_UAP(prio);
1051 	return (sys_setpriority(p, &ua, retval));
1052 }
1053 
1054 int
1055 netbsd32_socket(p, v, retval)
1056 	struct proc *p;
1057 	void *v;
1058 	register_t *retval;
1059 {
1060 	struct netbsd32_socket_args /* {
1061 		syscallarg(int) domain;
1062 		syscallarg(int) type;
1063 		syscallarg(int) protocol;
1064 	} */ *uap = v;
1065 	struct sys_socket_args ua;
1066 
1067 	NETBSD32TO64_UAP(domain);
1068 	NETBSD32TO64_UAP(type);
1069 	NETBSD32TO64_UAP(protocol);
1070 	return (sys_socket(p, &ua, retval));
1071 }
1072 
1073 int
1074 netbsd32_connect(p, v, retval)
1075 	struct proc *p;
1076 	void *v;
1077 	register_t *retval;
1078 {
1079 	struct netbsd32_connect_args /* {
1080 		syscallarg(int) s;
1081 		syscallarg(const netbsd32_sockaddrp_t) name;
1082 		syscallarg(int) namelen;
1083 	} */ *uap = v;
1084 	struct sys_connect_args ua;
1085 
1086 	NETBSD32TO64_UAP(s);
1087 	NETBSD32TOP_UAP(name, struct sockaddr);
1088 	NETBSD32TO64_UAP(namelen);
1089 	return (sys_connect(p, &ua, retval));
1090 }
1091 
1092 int
1093 netbsd32_getpriority(p, v, retval)
1094 	struct proc *p;
1095 	void *v;
1096 	register_t *retval;
1097 {
1098 	struct netbsd32_getpriority_args /* {
1099 		syscallarg(int) which;
1100 		syscallarg(int) who;
1101 	} */ *uap = v;
1102 	struct sys_getpriority_args ua;
1103 
1104 	NETBSD32TO64_UAP(which);
1105 	NETBSD32TO64_UAP(who);
1106 	return (sys_getpriority(p, &ua, retval));
1107 }
1108 
1109 int
1110 netbsd32_bind(p, v, retval)
1111 	struct proc *p;
1112 	void *v;
1113 	register_t *retval;
1114 {
1115 	struct netbsd32_bind_args /* {
1116 		syscallarg(int) s;
1117 		syscallarg(const netbsd32_sockaddrp_t) name;
1118 		syscallarg(int) namelen;
1119 	} */ *uap = v;
1120 	struct sys_bind_args ua;
1121 
1122 	NETBSD32TO64_UAP(s);
1123 	NETBSD32TOP_UAP(name, struct sockaddr);
1124 	NETBSD32TO64_UAP(namelen);
1125 	return (sys_bind(p, &ua, retval));
1126 }
1127 
1128 int
1129 netbsd32_setsockopt(p, v, retval)
1130 	struct proc *p;
1131 	void *v;
1132 	register_t *retval;
1133 {
1134 	struct netbsd32_setsockopt_args /* {
1135 		syscallarg(int) s;
1136 		syscallarg(int) level;
1137 		syscallarg(int) name;
1138 		syscallarg(const netbsd32_voidp) val;
1139 		syscallarg(int) valsize;
1140 	} */ *uap = v;
1141 	struct sys_setsockopt_args ua;
1142 
1143 	NETBSD32TO64_UAP(s);
1144 	NETBSD32TO64_UAP(level);
1145 	NETBSD32TO64_UAP(name);
1146 	NETBSD32TOP_UAP(val, void);
1147 	NETBSD32TO64_UAP(valsize);
1148 	/* may be more efficient to do this inline. */
1149 	return (sys_setsockopt(p, &ua, retval));
1150 }
1151 
1152 int
1153 netbsd32_listen(p, v, retval)
1154 	struct proc *p;
1155 	void *v;
1156 	register_t *retval;
1157 {
1158 	struct netbsd32_listen_args /* {
1159 		syscallarg(int) s;
1160 		syscallarg(int) backlog;
1161 	} */ *uap = v;
1162 	struct sys_listen_args ua;
1163 
1164 	NETBSD32TO64_UAP(s);
1165 	NETBSD32TO64_UAP(backlog);
1166 	return (sys_listen(p, &ua, retval));
1167 }
1168 
1169 int
1170 netbsd32_fchown(p, v, retval)
1171 	struct proc *p;
1172 	void *v;
1173 	register_t *retval;
1174 {
1175 	struct netbsd32_fchown_args /* {
1176 		syscallarg(int) fd;
1177 		syscallarg(uid_t) uid;
1178 		syscallarg(gid_t) gid;
1179 	} */ *uap = v;
1180 	struct sys_fchown_args ua;
1181 
1182 	NETBSD32TO64_UAP(fd);
1183 	NETBSD32TO64_UAP(uid);
1184 	NETBSD32TO64_UAP(gid);
1185 	return (sys_fchown(p, &ua, retval));
1186 }
1187 
1188 int
1189 netbsd32_fchmod(p, v, retval)
1190 	struct proc *p;
1191 	void *v;
1192 	register_t *retval;
1193 {
1194 	struct netbsd32_fchmod_args /* {
1195 		syscallarg(int) fd;
1196 		syscallarg(mode_t) mode;
1197 	} */ *uap = v;
1198 	struct sys_fchmod_args ua;
1199 
1200 	NETBSD32TO64_UAP(fd);
1201 	NETBSD32TO64_UAP(mode);
1202 	return (sys_fchmod(p, &ua, retval));
1203 }
1204 
1205 int
1206 netbsd32_setreuid(p, v, retval)
1207 	struct proc *p;
1208 	void *v;
1209 	register_t *retval;
1210 {
1211 	struct netbsd32_setreuid_args /* {
1212 		syscallarg(uid_t) ruid;
1213 		syscallarg(uid_t) euid;
1214 	} */ *uap = v;
1215 	struct sys_setreuid_args ua;
1216 
1217 	NETBSD32TO64_UAP(ruid);
1218 	NETBSD32TO64_UAP(euid);
1219 	return (sys_setreuid(p, &ua, retval));
1220 }
1221 
1222 int
1223 netbsd32_setregid(p, v, retval)
1224 	struct proc *p;
1225 	void *v;
1226 	register_t *retval;
1227 {
1228 	struct netbsd32_setregid_args /* {
1229 		syscallarg(gid_t) rgid;
1230 		syscallarg(gid_t) egid;
1231 	} */ *uap = v;
1232 	struct sys_setregid_args ua;
1233 
1234 	NETBSD32TO64_UAP(rgid);
1235 	NETBSD32TO64_UAP(egid);
1236 	return (sys_setregid(p, &ua, retval));
1237 }
1238 
1239 int
1240 netbsd32_getsockopt(p, v, retval)
1241 	struct proc *p;
1242 	void *v;
1243 	register_t *retval;
1244 {
1245 	struct netbsd32_getsockopt_args /* {
1246 		syscallarg(int) s;
1247 		syscallarg(int) level;
1248 		syscallarg(int) name;
1249 		syscallarg(netbsd32_voidp) val;
1250 		syscallarg(netbsd32_intp) avalsize;
1251 	} */ *uap = v;
1252 	struct sys_getsockopt_args ua;
1253 
1254 	NETBSD32TO64_UAP(s);
1255 	NETBSD32TO64_UAP(level);
1256 	NETBSD32TO64_UAP(name);
1257 	NETBSD32TOP_UAP(val, void);
1258 	NETBSD32TOP_UAP(avalsize, int);
1259 	return (sys_getsockopt(p, &ua, retval));
1260 }
1261 
1262 int
1263 netbsd32_rename(p, v, retval)
1264 	struct proc *p;
1265 	void *v;
1266 	register_t *retval;
1267 {
1268 	struct netbsd32_rename_args /* {
1269 		syscallarg(const netbsd32_charp) from;
1270 		syscallarg(const netbsd32_charp) to;
1271 	} */ *uap = v;
1272 	struct sys_rename_args ua;
1273 
1274 	NETBSD32TOP_UAP(from, const char);
1275 	NETBSD32TOP_UAP(to, const char)
1276 
1277 	return (sys_rename(p, &ua, retval));
1278 }
1279 
1280 int
1281 netbsd32_flock(p, v, retval)
1282 	struct proc *p;
1283 	void *v;
1284 	register_t *retval;
1285 {
1286 	struct netbsd32_flock_args /* {
1287 		syscallarg(int) fd;
1288 		syscallarg(int) how;
1289 	} */ *uap = v;
1290 	struct sys_flock_args ua;
1291 
1292 	NETBSD32TO64_UAP(fd);
1293 	NETBSD32TO64_UAP(how)
1294 
1295 	return (sys_flock(p, &ua, retval));
1296 }
1297 
1298 int
1299 netbsd32_mkfifo(p, v, retval)
1300 	struct proc *p;
1301 	void *v;
1302 	register_t *retval;
1303 {
1304 	struct netbsd32_mkfifo_args /* {
1305 		syscallarg(const netbsd32_charp) path;
1306 		syscallarg(mode_t) mode;
1307 	} */ *uap = v;
1308 	struct sys_mkfifo_args ua;
1309 
1310 	NETBSD32TOP_UAP(path, const char)
1311 	NETBSD32TO64_UAP(mode);
1312 	return (sys_mkfifo(p, &ua, retval));
1313 }
1314 
1315 int
1316 netbsd32_shutdown(p, v, retval)
1317 	struct proc *p;
1318 	void *v;
1319 	register_t *retval;
1320 {
1321 	struct netbsd32_shutdown_args /* {
1322 		syscallarg(int) s;
1323 		syscallarg(int) how;
1324 	} */ *uap = v;
1325 	struct sys_shutdown_args ua;
1326 
1327 	NETBSD32TO64_UAP(s)
1328 	NETBSD32TO64_UAP(how);
1329 	return (sys_shutdown(p, &ua, retval));
1330 }
1331 
1332 int
1333 netbsd32_socketpair(p, v, retval)
1334 	struct proc *p;
1335 	void *v;
1336 	register_t *retval;
1337 {
1338 	struct netbsd32_socketpair_args /* {
1339 		syscallarg(int) domain;
1340 		syscallarg(int) type;
1341 		syscallarg(int) protocol;
1342 		syscallarg(netbsd32_intp) rsv;
1343 	} */ *uap = v;
1344 	struct sys_socketpair_args ua;
1345 
1346 	NETBSD32TO64_UAP(domain);
1347 	NETBSD32TO64_UAP(type);
1348 	NETBSD32TO64_UAP(protocol);
1349 	NETBSD32TOP_UAP(rsv, int);
1350 	/* Since we're just copying out two `int's we can do this */
1351 	return (sys_socketpair(p, &ua, retval));
1352 }
1353 
1354 int
1355 netbsd32_mkdir(p, v, retval)
1356 	struct proc *p;
1357 	void *v;
1358 	register_t *retval;
1359 {
1360 	struct netbsd32_mkdir_args /* {
1361 		syscallarg(const netbsd32_charp) path;
1362 		syscallarg(mode_t) mode;
1363 	} */ *uap = v;
1364 	struct sys_mkdir_args ua;
1365 
1366 	NETBSD32TOP_UAP(path, const char)
1367 	NETBSD32TO64_UAP(mode);
1368 	return (sys_mkdir(p, &ua, retval));
1369 }
1370 
1371 int
1372 netbsd32_rmdir(p, v, retval)
1373 	struct proc *p;
1374 	void *v;
1375 	register_t *retval;
1376 {
1377 	struct netbsd32_rmdir_args /* {
1378 		syscallarg(const netbsd32_charp) path;
1379 	} */ *uap = v;
1380 	struct sys_rmdir_args ua;
1381 
1382 	NETBSD32TOP_UAP(path, const char);
1383 	return (sys_rmdir(p, &ua, retval));
1384 }
1385 
1386 int
1387 netbsd32_quotactl(p, v, retval)
1388 	struct proc *p;
1389 	void *v;
1390 	register_t *retval;
1391 {
1392 	struct netbsd32_quotactl_args /* {
1393 		syscallarg(const netbsd32_charp) path;
1394 		syscallarg(int) cmd;
1395 		syscallarg(int) uid;
1396 		syscallarg(netbsd32_caddr_t) arg;
1397 	} */ *uap = v;
1398 	struct sys_quotactl_args ua;
1399 
1400 	NETBSD32TOP_UAP(path, const char);
1401 	NETBSD32TO64_UAP(cmd);
1402 	NETBSD32TO64_UAP(uid);
1403 	NETBSD32TOX64_UAP(arg, caddr_t);
1404 	return (sys_quotactl(p, &ua, retval));
1405 }
1406 
1407 #if defined(NFS) || defined(NFSSERVER)
1408 int
1409 netbsd32_nfssvc(p, v, retval)
1410 	struct proc *p;
1411 	void *v;
1412 	register_t *retval;
1413 {
1414 #if 0
1415 	struct netbsd32_nfssvc_args /* {
1416 		syscallarg(int) flag;
1417 		syscallarg(netbsd32_voidp) argp;
1418 	} */ *uap = v;
1419 	struct sys_nfssvc_args ua;
1420 
1421 	NETBSD32TO64_UAP(flag);
1422 	NETBSD32TOP_UAP(argp, void);
1423 	return (sys_nfssvc(p, &ua, retval));
1424 #else
1425 	/* Why would we want to support a 32-bit nfsd? */
1426 	return (ENOSYS);
1427 #endif
1428 }
1429 #endif
1430 
1431 #if defined(NFS) || defined(NFSSERVER)
1432 int
1433 netbsd32_getfh(p, v, retval)
1434 	struct proc *p;
1435 	void *v;
1436 	register_t *retval;
1437 {
1438 	struct netbsd32_getfh_args /* {
1439 		syscallarg(const netbsd32_charp) fname;
1440 		syscallarg(netbsd32_fhandlep_t) fhp;
1441 	} */ *uap = v;
1442 	struct sys_getfh_args ua;
1443 
1444 	NETBSD32TOP_UAP(fname, const char);
1445 	NETBSD32TOP_UAP(fhp, struct fhandle);
1446 	/* Lucky for us a fhandlep_t doesn't change sizes */
1447 	return (sys_getfh(p, &ua, retval));
1448 }
1449 #endif
1450 
1451 int
1452 netbsd32_sysarch(p, v, retval)
1453 	struct proc *p;
1454 	void *v;
1455 	register_t *retval;
1456 {
1457 	struct netbsd32_sysarch_args /* {
1458 		syscallarg(int) op;
1459 		syscallarg(netbsd32_voidp) parms;
1460 	} */ *uap = v;
1461 
1462 	switch (SCARG(uap, op)) {
1463 	default:
1464 		printf("(%s) netbsd32_sysarch(%d)\n", MACHINE, SCARG(uap, op));
1465 		return EINVAL;
1466 	}
1467 }
1468 
1469 int
1470 netbsd32_pread(p, v, retval)
1471 	struct proc *p;
1472 	void *v;
1473 	register_t *retval;
1474 {
1475 	struct netbsd32_pread_args /* {
1476 		syscallarg(int) fd;
1477 		syscallarg(netbsd32_voidp) buf;
1478 		syscallarg(netbsd32_size_t) nbyte;
1479 		syscallarg(int) pad;
1480 		syscallarg(off_t) offset;
1481 	} */ *uap = v;
1482 	struct sys_pread_args ua;
1483 	ssize_t rt;
1484 	int error;
1485 
1486 	NETBSD32TO64_UAP(fd);
1487 	NETBSD32TOP_UAP(buf, void);
1488 	NETBSD32TOX_UAP(nbyte, size_t);
1489 	NETBSD32TO64_UAP(pad);
1490 	NETBSD32TO64_UAP(offset);
1491 	error = sys_pread(p, &ua, (register_t *)&rt);
1492 	*retval = rt;
1493 	return (error);
1494 }
1495 
1496 int
1497 netbsd32_pwrite(p, v, retval)
1498 	struct proc *p;
1499 	void *v;
1500 	register_t *retval;
1501 {
1502 	struct netbsd32_pwrite_args /* {
1503 		syscallarg(int) fd;
1504 		syscallarg(const netbsd32_voidp) buf;
1505 		syscallarg(netbsd32_size_t) nbyte;
1506 		syscallarg(int) pad;
1507 		syscallarg(off_t) offset;
1508 	} */ *uap = v;
1509 	struct sys_pwrite_args ua;
1510 	ssize_t rt;
1511 	int error;
1512 
1513 	NETBSD32TO64_UAP(fd);
1514 	NETBSD32TOP_UAP(buf, void);
1515 	NETBSD32TOX_UAP(nbyte, size_t);
1516 	NETBSD32TO64_UAP(pad);
1517 	NETBSD32TO64_UAP(offset);
1518 	error = sys_pwrite(p, &ua, (register_t *)&rt);
1519 	*retval = rt;
1520 	return (error);
1521 }
1522 
1523 int
1524 netbsd32_setgid(p, v, retval)
1525 	struct proc *p;
1526 	void *v;
1527 	register_t *retval;
1528 {
1529 	struct netbsd32_setgid_args /* {
1530 		syscallarg(gid_t) gid;
1531 	} */ *uap = v;
1532 	struct sys_setgid_args ua;
1533 
1534 	NETBSD32TO64_UAP(gid);
1535 	return (sys_setgid(p, v, retval));
1536 }
1537 
1538 int
1539 netbsd32_setegid(p, v, retval)
1540 	struct proc *p;
1541 	void *v;
1542 	register_t *retval;
1543 {
1544 	struct netbsd32_setegid_args /* {
1545 		syscallarg(gid_t) egid;
1546 	} */ *uap = v;
1547 	struct sys_setegid_args ua;
1548 
1549 	NETBSD32TO64_UAP(egid);
1550 	return (sys_setegid(p, v, retval));
1551 }
1552 
1553 int
1554 netbsd32_seteuid(p, v, retval)
1555 	struct proc *p;
1556 	void *v;
1557 	register_t *retval;
1558 {
1559 	struct netbsd32_seteuid_args /* {
1560 		syscallarg(gid_t) euid;
1561 	} */ *uap = v;
1562 	struct sys_seteuid_args ua;
1563 
1564 	NETBSD32TO64_UAP(euid);
1565 	return (sys_seteuid(p, v, retval));
1566 }
1567 
1568 #ifdef LFS
1569 int
1570 netbsd32_sys_lfs_bmapv(p, v, retval)
1571 	struct proc *p;
1572 	void *v;
1573 	register_t *retval;
1574 {
1575 
1576 	return (ENOSYS);	/* XXX */
1577 }
1578 
1579 int
1580 netbsd32_sys_lfs_markv(p, v, retval)
1581 	struct proc *p;
1582 	void *v;
1583 	register_t *retval;
1584 {
1585 
1586 	return (ENOSYS);	/* XXX */
1587 }
1588 
1589 int
1590 netbsd32_sys_lfs_segclean(p, v, retval)
1591 	struct proc *p;
1592 	void *v;
1593 	register_t *retval;
1594 {
1595 
1596 	return (ENOSYS);	/* XXX */
1597 }
1598 
1599 int
1600 netbsd32_sys_lfs_segwait(p, v, retval)
1601 	struct proc *p;
1602 	void *v;
1603 	register_t *retval;
1604 {
1605 
1606 	return (ENOSYS);	/* XXX */
1607 }
1608 #endif
1609 
1610 int
1611 netbsd32_pathconf(p, v, retval)
1612 	struct proc *p;
1613 	void *v;
1614 	register_t *retval;
1615 {
1616 	struct netbsd32_pathconf_args /* {
1617 		syscallarg(int) fd;
1618 		syscallarg(int) name;
1619 	} */ *uap = v;
1620 	struct sys_pathconf_args ua;
1621 	long rt;
1622 	int error;
1623 
1624 	NETBSD32TOP_UAP(path, const char);
1625 	NETBSD32TO64_UAP(name);
1626 	error = sys_pathconf(p, &ua, (register_t *)&rt);
1627 	*retval = rt;
1628 	return (error);
1629 }
1630 
1631 int
1632 netbsd32_fpathconf(p, v, retval)
1633 	struct proc *p;
1634 	void *v;
1635 	register_t *retval;
1636 {
1637 	struct netbsd32_fpathconf_args /* {
1638 		syscallarg(int) fd;
1639 		syscallarg(int) name;
1640 	} */ *uap = v;
1641 	struct sys_fpathconf_args ua;
1642 	long rt;
1643 	int error;
1644 
1645 	NETBSD32TO64_UAP(fd);
1646 	NETBSD32TO64_UAP(name);
1647 	error = sys_fpathconf(p, &ua, (register_t *)&rt);
1648 	*retval = rt;
1649 	return (error);
1650 }
1651 
1652 int
1653 netbsd32_getrlimit(p, v, retval)
1654 	struct proc *p;
1655 	void *v;
1656 	register_t *retval;
1657 {
1658 	struct netbsd32_getrlimit_args /* {
1659 		syscallarg(int) which;
1660 		syscallarg(netbsd32_rlimitp_t) rlp;
1661 	} */ *uap = v;
1662 	int which = SCARG(uap, which);
1663 
1664 	if ((u_int)which >= RLIM_NLIMITS)
1665 		return (EINVAL);
1666 	return (copyout(&p->p_rlimit[which], (caddr_t)(u_long)SCARG(uap, rlp),
1667 	    sizeof(struct rlimit)));
1668 }
1669 
1670 int
1671 netbsd32_setrlimit(p, v, retval)
1672 	struct proc *p;
1673 	void *v;
1674 	register_t *retval;
1675 {
1676 	struct netbsd32_setrlimit_args /* {
1677 		syscallarg(int) which;
1678 		syscallarg(const netbsd32_rlimitp_t) rlp;
1679 	} */ *uap = v;
1680 		int which = SCARG(uap, which);
1681 	struct rlimit alim;
1682 	int error;
1683 
1684 	error = copyin((caddr_t)(u_long)SCARG(uap, rlp), &alim, sizeof(struct rlimit));
1685 	if (error)
1686 		return (error);
1687 	return (dosetrlimit(p, p->p_cred, which, &alim));
1688 }
1689 
1690 int
1691 netbsd32_mmap(p, v, retval)
1692 	struct proc *p;
1693 	void *v;
1694 	register_t *retval;
1695 {
1696 	struct netbsd32_mmap_args /* {
1697 		syscallarg(netbsd32_voidp) addr;
1698 		syscallarg(netbsd32_size_t) len;
1699 		syscallarg(int) prot;
1700 		syscallarg(int) flags;
1701 		syscallarg(int) fd;
1702 		syscallarg(netbsd32_long) pad;
1703 		syscallarg(off_t) pos;
1704 	} */ *uap = v;
1705 	struct sys_mmap_args ua;
1706 	void *rt;
1707 	int error;
1708 
1709 	NETBSD32TOP_UAP(addr, void);
1710 	NETBSD32TOX_UAP(len, size_t);
1711 	NETBSD32TO64_UAP(prot);
1712 	NETBSD32TO64_UAP(flags);
1713 	NETBSD32TO64_UAP(fd);
1714 	NETBSD32TOX_UAP(pad, long);
1715 	NETBSD32TOX_UAP(pos, off_t);
1716 	error = sys_mmap(p, &ua, (register_t *)&rt);
1717 	if ((u_long)rt > (u_long)UINT_MAX) {
1718 		printf("netbsd32_mmap: retval out of range: %p", rt);
1719 		/* Should try to recover and return an error here. */
1720 	}
1721 	*retval = (netbsd32_voidp)(u_long)rt;
1722 	return (error);
1723 }
1724 
1725 int
1726 netbsd32_lseek(p, v, retval)
1727 	struct proc *p;
1728 	void *v;
1729 	register_t *retval;
1730 {
1731 	struct netbsd32_lseek_args /* {
1732 		syscallarg(int) fd;
1733 		syscallarg(int) pad;
1734 		syscallarg(off_t) offset;
1735 		syscallarg(int) whence;
1736 	} */ *uap = v;
1737 	struct sys_lseek_args ua;
1738 
1739 	NETBSD32TO64_UAP(fd);
1740 	NETBSD32TO64_UAP(pad);
1741 	NETBSD32TO64_UAP(offset);
1742 	NETBSD32TO64_UAP(whence);
1743 	return (sys_lseek(p, &ua, retval));
1744 }
1745 
1746 int
1747 netbsd32_truncate(p, v, retval)
1748 	struct proc *p;
1749 	void *v;
1750 	register_t *retval;
1751 {
1752 	struct netbsd32_truncate_args /* {
1753 		syscallarg(const netbsd32_charp) path;
1754 		syscallarg(int) pad;
1755 		syscallarg(off_t) length;
1756 	} */ *uap = v;
1757 	struct sys_truncate_args ua;
1758 
1759 	NETBSD32TOP_UAP(path, const char);
1760 	NETBSD32TO64_UAP(pad);
1761 	NETBSD32TO64_UAP(length);
1762 	return (sys_truncate(p, &ua, retval));
1763 }
1764 
1765 int
1766 netbsd32_ftruncate(p, v, retval)
1767 	struct proc *p;
1768 	void *v;
1769 	register_t *retval;
1770 {
1771 	struct netbsd32_ftruncate_args /* {
1772 		syscallarg(int) fd;
1773 		syscallarg(int) pad;
1774 		syscallarg(off_t) length;
1775 	} */ *uap = v;
1776 	struct sys_ftruncate_args ua;
1777 
1778 	NETBSD32TO64_UAP(fd);
1779 	NETBSD32TO64_UAP(pad);
1780 	NETBSD32TO64_UAP(length);
1781 	return (sys_ftruncate(p, &ua, retval));
1782 }
1783 
1784 int
1785 netbsd32_mlock(p, v, retval)
1786 	struct proc *p;
1787 	void *v;
1788 	register_t *retval;
1789 {
1790 	struct netbsd32_mlock_args /* {
1791 		syscallarg(const netbsd32_voidp) addr;
1792 		syscallarg(netbsd32_size_t) len;
1793 	} */ *uap = v;
1794 	struct sys_mlock_args ua;
1795 
1796 	NETBSD32TOP_UAP(addr, const void);
1797 	NETBSD32TO64_UAP(len);
1798 	return (sys_mlock(p, &ua, retval));
1799 }
1800 
1801 int
1802 netbsd32_munlock(p, v, retval)
1803 	struct proc *p;
1804 	void *v;
1805 	register_t *retval;
1806 {
1807 	struct netbsd32_munlock_args /* {
1808 		syscallarg(const netbsd32_voidp) addr;
1809 		syscallarg(netbsd32_size_t) len;
1810 	} */ *uap = v;
1811 	struct sys_munlock_args ua;
1812 
1813 	NETBSD32TOP_UAP(addr, const void);
1814 	NETBSD32TO64_UAP(len);
1815 	return (sys_munlock(p, &ua, retval));
1816 }
1817 
1818 int
1819 netbsd32_undelete(p, v, retval)
1820 	struct proc *p;
1821 	void *v;
1822 	register_t *retval;
1823 {
1824 	struct netbsd32_undelete_args /* {
1825 		syscallarg(const netbsd32_charp) path;
1826 	} */ *uap = v;
1827 	struct sys_undelete_args ua;
1828 
1829 	NETBSD32TOP_UAP(path, const char);
1830 	return (sys_undelete(p, &ua, retval));
1831 }
1832 
1833 int
1834 netbsd32_getpgid(p, v, retval)
1835 	struct proc *p;
1836 	void *v;
1837 	register_t *retval;
1838 {
1839 	struct netbsd32_getpgid_args /* {
1840 		syscallarg(pid_t) pid;
1841 	} */ *uap = v;
1842 	struct sys_getpgid_args ua;
1843 
1844 	NETBSD32TO64_UAP(pid);
1845 	return (sys_getpgid(p, &ua, retval));
1846 }
1847 
1848 int
1849 netbsd32_reboot(p, v, retval)
1850 	struct proc *p;
1851 	void *v;
1852 	register_t *retval;
1853 {
1854 	struct netbsd32_reboot_args /* {
1855 		syscallarg(int) opt;
1856 		syscallarg(netbsd32_charp) bootstr;
1857 	} */ *uap = v;
1858 	struct sys_reboot_args ua;
1859 
1860 	NETBSD32TO64_UAP(opt);
1861 	NETBSD32TOP_UAP(bootstr, char);
1862 	return (sys_reboot(p, &ua, retval));
1863 }
1864 
1865 int
1866 netbsd32_poll(p, v, retval)
1867 	struct proc *p;
1868 	void *v;
1869 	register_t *retval;
1870 {
1871 	struct netbsd32_poll_args /* {
1872 		syscallarg(netbsd32_pollfdp_t) fds;
1873 		syscallarg(u_int) nfds;
1874 		syscallarg(int) timeout;
1875 	} */ *uap = v;
1876 	struct sys_poll_args ua;
1877 
1878 	NETBSD32TOP_UAP(fds, struct pollfd);
1879 	NETBSD32TO64_UAP(nfds);
1880 	NETBSD32TO64_UAP(timeout);
1881 	return (sys_poll(p, &ua, retval));
1882 }
1883 
1884 int
1885 netbsd32_fdatasync(p, v, retval)
1886 	struct proc *p;
1887 	void *v;
1888 	register_t *retval;
1889 {
1890 	struct netbsd32_fdatasync_args /* {
1891 		syscallarg(int) fd;
1892 	} */ *uap = v;
1893 	struct sys_fdatasync_args ua;
1894 
1895 	NETBSD32TO64_UAP(fd);
1896 	return (sys_fdatasync(p, &ua, retval));
1897 }
1898 
1899 int
1900 netbsd32___posix_rename(p, v, retval)
1901 	struct proc *p;
1902 	void *v;
1903 	register_t *retval;
1904 {
1905 	struct netbsd32___posix_rename_args /* {
1906 		syscallarg(const netbsd32_charp) from;
1907 		syscallarg(const netbsd32_charp) to;
1908 	} */ *uap = v;
1909 	struct sys___posix_rename_args ua;
1910 
1911 	NETBSD32TOP_UAP(from, const char);
1912 	NETBSD32TOP_UAP(to, const char);
1913 	return (sys___posix_rename(p, &ua, retval));
1914 }
1915 
1916 int
1917 netbsd32_swapctl(p, v, retval)
1918 	struct proc *p;
1919 	void *v;
1920 	register_t *retval;
1921 {
1922 	struct netbsd32_swapctl_args /* {
1923 		syscallarg(int) cmd;
1924 		syscallarg(const netbsd32_voidp) arg;
1925 		syscallarg(int) misc;
1926 	} */ *uap = v;
1927 	struct sys_swapctl_args ua;
1928 
1929 	NETBSD32TO64_UAP(cmd);
1930 	NETBSD32TOP_UAP(arg, const void);
1931 	NETBSD32TO64_UAP(misc);
1932 	return (sys_swapctl(p, &ua, retval));
1933 }
1934 
1935 int
1936 netbsd32_minherit(p, v, retval)
1937 	struct proc *p;
1938 	void *v;
1939 	register_t *retval;
1940 {
1941 	struct netbsd32_minherit_args /* {
1942 		syscallarg(netbsd32_voidp) addr;
1943 		syscallarg(netbsd32_size_t) len;
1944 		syscallarg(int) inherit;
1945 	} */ *uap = v;
1946 	struct sys_minherit_args ua;
1947 
1948 	NETBSD32TOP_UAP(addr, void);
1949 	NETBSD32TOX_UAP(len, size_t);
1950 	NETBSD32TO64_UAP(inherit);
1951 	return (sys_minherit(p, &ua, retval));
1952 }
1953 
1954 int
1955 netbsd32_lchmod(p, v, retval)
1956 	struct proc *p;
1957 	void *v;
1958 	register_t *retval;
1959 {
1960 	struct netbsd32_lchmod_args /* {
1961 		syscallarg(const netbsd32_charp) path;
1962 		syscallarg(mode_t) mode;
1963 	} */ *uap = v;
1964 	struct sys_lchmod_args ua;
1965 
1966 	NETBSD32TOP_UAP(path, const char);
1967 	NETBSD32TO64_UAP(mode);
1968 	return (sys_lchmod(p, &ua, retval));
1969 }
1970 
1971 int
1972 netbsd32_lchown(p, v, retval)
1973 	struct proc *p;
1974 	void *v;
1975 	register_t *retval;
1976 {
1977 	struct netbsd32_lchown_args /* {
1978 		syscallarg(const netbsd32_charp) path;
1979 		syscallarg(uid_t) uid;
1980 		syscallarg(gid_t) gid;
1981 	} */ *uap = v;
1982 	struct sys_lchown_args ua;
1983 
1984 	NETBSD32TOP_UAP(path, const char);
1985 	NETBSD32TO64_UAP(uid);
1986 	NETBSD32TO64_UAP(gid);
1987 	return (sys_lchown(p, &ua, retval));
1988 }
1989 
1990 int
1991 netbsd32___msync13(p, v, retval)
1992 	struct proc *p;
1993 	void *v;
1994 	register_t *retval;
1995 {
1996 	struct netbsd32___msync13_args /* {
1997 		syscallarg(netbsd32_voidp) addr;
1998 		syscallarg(netbsd32_size_t) len;
1999 		syscallarg(int) flags;
2000 	} */ *uap = v;
2001 	struct sys___msync13_args ua;
2002 
2003 	NETBSD32TOP_UAP(addr, void);
2004 	NETBSD32TOX_UAP(len, size_t);
2005 	NETBSD32TO64_UAP(flags);
2006 	return (sys___msync13(p, &ua, retval));
2007 }
2008 
2009 int
2010 netbsd32___posix_chown(p, v, retval)
2011 	struct proc *p;
2012 	void *v;
2013 	register_t *retval;
2014 {
2015 	struct netbsd32___posix_chown_args /* {
2016 		syscallarg(const netbsd32_charp) path;
2017 		syscallarg(uid_t) uid;
2018 		syscallarg(gid_t) gid;
2019 	} */ *uap = v;
2020 	struct sys___posix_chown_args ua;
2021 
2022 	NETBSD32TOP_UAP(path, const char);
2023 	NETBSD32TO64_UAP(uid);
2024 	NETBSD32TO64_UAP(gid);
2025 	return (sys___posix_chown(p, &ua, retval));
2026 }
2027 
2028 int
2029 netbsd32___posix_fchown(p, v, retval)
2030 	struct proc *p;
2031 	void *v;
2032 	register_t *retval;
2033 {
2034 	struct netbsd32___posix_fchown_args /* {
2035 		syscallarg(int) fd;
2036 		syscallarg(uid_t) uid;
2037 		syscallarg(gid_t) gid;
2038 	} */ *uap = v;
2039 	struct sys___posix_fchown_args ua;
2040 
2041 	NETBSD32TO64_UAP(fd);
2042 	NETBSD32TO64_UAP(uid);
2043 	NETBSD32TO64_UAP(gid);
2044 	return (sys___posix_fchown(p, &ua, retval));
2045 }
2046 
2047 int
2048 netbsd32___posix_lchown(p, v, retval)
2049 	struct proc *p;
2050 	void *v;
2051 	register_t *retval;
2052 {
2053 	struct netbsd32___posix_lchown_args /* {
2054 		syscallarg(const netbsd32_charp) path;
2055 		syscallarg(uid_t) uid;
2056 		syscallarg(gid_t) gid;
2057 	} */ *uap = v;
2058 	struct sys___posix_lchown_args ua;
2059 
2060 	NETBSD32TOP_UAP(path, const char);
2061 	NETBSD32TO64_UAP(uid);
2062 	NETBSD32TO64_UAP(gid);
2063 	return (sys___posix_lchown(p, &ua, retval));
2064 }
2065 
2066 int
2067 netbsd32_getsid(p, v, retval)
2068 	struct proc *p;
2069 	void *v;
2070 	register_t *retval;
2071 {
2072 	struct netbsd32_getsid_args /* {
2073 		syscallarg(pid_t) pid;
2074 	} */ *uap = v;
2075 	struct sys_getsid_args ua;
2076 
2077 	NETBSD32TO64_UAP(pid);
2078 	return (sys_getsid(p, &ua, retval));
2079 }
2080 
2081 #ifdef KTRACE
2082 int
2083 netbsd32_fktrace(p, v, retval)
2084 	struct proc *p;
2085 	void *v;
2086 	register_t *retval;
2087 {
2088 	struct netbsd32_fktrace_args /* {
2089 		syscallarg(const int) fd;
2090 		syscallarg(int) ops;
2091 		syscallarg(int) facs;
2092 		syscallarg(int) pid;
2093 	} */ *uap = v;
2094 #if 0
2095 	struct sys_fktrace_args ua;
2096 #else
2097 	/* XXXX */
2098 	struct sys_fktrace_noconst_args {
2099 		syscallarg(int) fd;
2100 		syscallarg(int) ops;
2101 		syscallarg(int) facs;
2102 		syscallarg(int) pid;
2103 	} ua;
2104 #endif
2105 
2106 	NETBSD32TOX_UAP(fd, int);
2107 	NETBSD32TO64_UAP(ops);
2108 	NETBSD32TO64_UAP(facs);
2109 	NETBSD32TO64_UAP(pid);
2110 	return (sys_fktrace(p, &ua, retval));
2111 }
2112 #endif /* KTRACE */
2113 
2114 int netbsd32___sigpending14(p, v, retval)
2115 	struct proc *p;
2116 	void   *v;
2117 	register_t *retval;
2118 {
2119 	struct netbsd32___sigpending14_args /* {
2120 		syscallarg(sigset_t *) set;
2121 	} */ *uap = v;
2122 	struct sys___sigpending14_args ua;
2123 
2124 	NETBSD32TOP_UAP(set, sigset_t);
2125 	return (sys___sigpending14(p, &ua, retval));
2126 }
2127 
2128 int netbsd32___sigprocmask14(p, v, retval)
2129 	struct proc *p;
2130 	void   *v;
2131 	register_t *retval;
2132 {
2133 	struct netbsd32___sigprocmask14_args /* {
2134 		syscallarg(int) how;
2135 		syscallarg(const sigset_t *) set;
2136 		syscallarg(sigset_t *) oset;
2137 	} */ *uap = v;
2138 	struct sys___sigprocmask14_args ua;
2139 
2140 	NETBSD32TO64_UAP(how);
2141 	NETBSD32TOP_UAP(set, sigset_t);
2142 	NETBSD32TOP_UAP(oset, sigset_t);
2143 	return (sys___sigprocmask14(p, &ua, retval));
2144 }
2145 
2146 int netbsd32___sigsuspend14(p, v, retval)
2147 	struct proc *p;
2148 	void   *v;
2149 	register_t *retval;
2150 {
2151 	struct netbsd32___sigsuspend14_args /* {
2152 		syscallarg(const sigset_t *) set;
2153 	} */ *uap = v;
2154 	struct sys___sigsuspend14_args ua;
2155 
2156 	NETBSD32TOP_UAP(set, sigset_t);
2157 	return (sys___sigsuspend14(p, &ua, retval));
2158 };
2159 
2160 int netbsd32_fchroot(p, v, retval)
2161 	struct proc *p;
2162 	void *v;
2163 	register_t *retval;
2164 {
2165 	struct netbsd32_fchroot_args /* {
2166 		syscallarg(int) fd;
2167 	} */ *uap = v;
2168 	struct sys_fchroot_args ua;
2169 
2170 	NETBSD32TO64_UAP(fd);
2171 	return (sys_fchroot(p, &ua, retval));
2172 }
2173 
2174 /*
2175  * Open a file given a file handle.
2176  *
2177  * Check permissions, allocate an open file structure,
2178  * and call the device open routine if any.
2179  */
2180 int
2181 netbsd32_fhopen(p, v, retval)
2182 	struct proc *p;
2183 	void *v;
2184 	register_t *retval;
2185 {
2186 	struct netbsd32_fhopen_args /* {
2187 		syscallarg(const fhandle_t *) fhp;
2188 		syscallarg(int) flags;
2189 	} */ *uap = v;
2190 	struct sys_fhopen_args ua;
2191 
2192 	NETBSD32TOP_UAP(fhp, fhandle_t);
2193 	NETBSD32TO64_UAP(flags);
2194 	return (sys_fhopen(p, &ua, retval));
2195 }
2196 
2197 int netbsd32_fhstat(p, v, retval)
2198 	struct proc *p;
2199 	void *v;
2200 	register_t *retval;
2201 {
2202 	struct netbsd32_fhstat_args /* {
2203 		syscallarg(const netbsd32_fhandlep_t) fhp;
2204 		syscallarg(struct stat *) sb;
2205 	} */ *uap = v;
2206 	struct sys_fhstat_args ua;
2207 
2208 	NETBSD32TOP_UAP(fhp, const fhandle_t);
2209 	NETBSD32TOP_UAP(sb, struct stat);
2210 	return (sys_fhstat(p, &ua, retval));
2211 }
2212 
2213 int netbsd32_fhstatfs(p, v, retval)
2214 	struct proc *p;
2215 	void *v;
2216 	register_t *retval;
2217 {
2218 	struct netbsd32_fhstatfs_args /* {
2219 		syscallarg(const netbsd32_fhandlep_t) fhp;
2220 		syscallarg(struct statfs *) buf;
2221 	} */ *uap = v;
2222 	struct sys_fhstatfs_args ua;
2223 
2224 	NETBSD32TOP_UAP(fhp, const fhandle_t);
2225 	NETBSD32TOP_UAP(buf, struct statfs);
2226 	return (sys_fhstatfs(p, &ua, retval));
2227 }
2228 
2229 /* virtual memory syscalls */
2230 int
2231 netbsd32_ovadvise(p, v, retval)
2232 	struct proc *p;
2233 	void *v;
2234 	register_t *retval;
2235 {
2236 	struct netbsd32_ovadvise_args /* {
2237 		syscallarg(int) anom;
2238 	} */ *uap = v;
2239 	struct sys_ovadvise_args ua;
2240 
2241 	NETBSD32TO64_UAP(anom);
2242 	return (sys_ovadvise(p, &ua, retval));
2243 }
2244 
2245