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