xref: /netbsd-src/sys/compat/netbsd32/netbsd32_netbsd.c (revision de2138164cd16145ee5fd4d0aef1e8f952c1a9fb)
1 /*	$NetBSD: netbsd32_netbsd.c,v 1.117 2007/02/19 15:10:03 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.117 2007/02/19 15:10:03 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 #include "opt_ptrace.h"
44 
45 #include "fs_lfs.h"
46 #include "fs_nfs.h"
47 #endif
48 
49 /*
50  * Though COMPAT_OLDSOCK is needed only for COMPAT_43, SunOS, Linux,
51  * HP-UX, FreeBSD, Ultrix, OSF1, we define it unconditionally so that
52  * this would be LKM-safe.
53  */
54 #define COMPAT_OLDSOCK /* used by <sys/socket.h> */
55 
56 #include <sys/param.h>
57 #include <sys/systm.h>
58 #include <sys/kernel.h>
59 //#define msg __msg /* Don't ask me! */
60 #include <sys/malloc.h>
61 #include <sys/mount.h>
62 #include <sys/socket.h>
63 #include <sys/sockio.h>
64 #include <sys/socketvar.h>
65 #include <sys/mbuf.h>
66 #include <sys/stat.h>
67 #include <sys/time.h>
68 #include <sys/signalvar.h>
69 #include <sys/ptrace.h>
70 #include <sys/ktrace.h>
71 #include <sys/trace.h>
72 #include <sys/resourcevar.h>
73 #include <sys/pool.h>
74 #include <sys/vnode.h>
75 #include <sys/file.h>
76 #include <sys/filedesc.h>
77 #include <sys/namei.h>
78 #include <sys/dirent.h>
79 #include <sys/kauth.h>
80 
81 #include <uvm/uvm_extern.h>
82 
83 #include <sys/syscallargs.h>
84 #include <sys/proc.h>
85 #include <sys/acct.h>
86 #include <sys/exec.h>
87 
88 #include <net/if.h>
89 
90 #include <compat/netbsd32/netbsd32.h>
91 #include <compat/netbsd32/netbsd32_exec.h>
92 #include <compat/netbsd32/netbsd32_syscall.h>
93 #include <compat/netbsd32/netbsd32_syscallargs.h>
94 #include <compat/netbsd32/netbsd32_conv.h>
95 
96 #include <machine/frame.h>
97 
98 #if defined(DDB)
99 #include <ddb/ddbvar.h>
100 #endif
101 
102 extern struct sysent netbsd32_sysent[];
103 #ifdef SYSCALL_DEBUG
104 extern const char * const netbsd32_syscallnames[];
105 #endif
106 #ifdef __HAVE_SYSCALL_INTERN
107 void netbsd32_syscall_intern __P((struct proc *));
108 #else
109 void syscall __P((void));
110 #endif
111 
112 #define LIMITCHECK(a, b) ((a) != RLIM_INFINITY && (a) > (b))
113 
114 #ifdef COMPAT_16
115 extern char netbsd32_sigcode[], netbsd32_esigcode[];
116 struct uvm_object *emul_netbsd32_object;
117 #endif
118 
119 extern struct sysctlnode netbsd32_sysctl_root;
120 
121 const struct emul emul_netbsd32 = {
122 	"netbsd32",
123 	"/emul/netbsd32",
124 #ifndef __HAVE_MINIMAL_EMUL
125 	0,
126 	NULL,
127 	netbsd32_SYS_syscall,
128 	netbsd32_SYS_NSYSENT,
129 #endif
130 	netbsd32_sysent,
131 #ifdef SYSCALL_DEBUG
132 	netbsd32_syscallnames,
133 #else
134 	NULL,
135 #endif
136 	netbsd32_sendsig,
137 	trapsignal,
138 	NULL,
139 #ifdef COMPAT_16
140 	netbsd32_sigcode,
141 	netbsd32_esigcode,
142 	&emul_netbsd32_object,
143 #else
144 	NULL,
145 	NULL,
146 	NULL,
147 #endif
148 	netbsd32_setregs,
149 	NULL,
150 	NULL,
151 	NULL,
152 	NULL,
153 	NULL,
154 #ifdef __HAVE_SYSCALL_INTERN
155 	netbsd32_syscall_intern,
156 #else
157 	syscall,
158 #endif
159 	&netbsd32_sysctl_root,
160 	NULL,
161 
162 	netbsd32_vm_default_addr,
163 	NULL,
164 	sizeof(ucontext32_t),
165 	startlwp32,
166 };
167 
168 /*
169  * below are all the standard NetBSD system calls, in the 32bit
170  * environment, with the necessary conversions to 64bit before
171  * calling the real syscall.  anything that needs special
172  * attention is handled elsewhere.
173  */
174 
175 int
176 netbsd32_exit(l, v, retval)
177 	struct lwp *l;
178 	void *v;
179 	register_t *retval;
180 {
181 	struct netbsd32_exit_args /* {
182 		syscallarg(int) rval;
183 	} */ *uap = v;
184 	struct sys_exit_args ua;
185 
186 	NETBSD32TO64_UAP(rval);
187 	return sys_exit(l, &ua, retval);
188 }
189 
190 int
191 netbsd32_read(l, v, retval)
192 	struct lwp *l;
193 	void *v;
194 	register_t *retval;
195 {
196 	struct netbsd32_read_args /* {
197 		syscallarg(int) fd;
198 		syscallarg(netbsd32_voidp) buf;
199 		syscallarg(netbsd32_size_t) nbyte;
200 	} */ *uap = v;
201 	struct sys_read_args ua;
202 
203 	NETBSD32TO64_UAP(fd);
204 	NETBSD32TOP_UAP(buf, void *);
205 	NETBSD32TOX_UAP(nbyte, size_t);
206 	return sys_read(l, &ua, retval);
207 }
208 
209 int
210 netbsd32_write(l, v, retval)
211 	struct lwp *l;
212 	void *v;
213 	register_t *retval;
214 {
215 	struct netbsd32_write_args /* {
216 		syscallarg(int) fd;
217 		syscallarg(const netbsd32_voidp) buf;
218 		syscallarg(netbsd32_size_t) nbyte;
219 	} */ *uap = v;
220 	struct sys_write_args ua;
221 
222 	NETBSD32TO64_UAP(fd);
223 	NETBSD32TOP_UAP(buf, void *);
224 	NETBSD32TOX_UAP(nbyte, size_t);
225 	return sys_write(l, &ua, retval);
226 }
227 
228 int
229 netbsd32_close(l, v, retval)
230 	struct lwp *l;
231 	void *v;
232 	register_t *retval;
233 {
234 	struct netbsd32_close_args /* {
235 		syscallarg(int) fd;
236 	} */ *uap = v;
237 	struct sys_close_args ua;
238 
239 	NETBSD32TO64_UAP(fd);
240 	return sys_close(l, &ua, retval);
241 }
242 
243 int
244 netbsd32_open(l, v, retval)
245 	struct lwp *l;
246 	void *v;
247 	register_t *retval;
248 {
249 	struct netbsd32_open_args /* {
250 		syscallarg(const netbsd32_charp) path;
251 		syscallarg(int) flags;
252 		syscallarg(mode_t) mode;
253 	} */ *uap = v;
254 	struct sys_open_args ua;
255 	caddr_t sg;
256 
257 	NETBSD32TOP_UAP(path, const char);
258 	NETBSD32TO64_UAP(flags);
259 	NETBSD32TO64_UAP(mode);
260 	sg = stackgap_init(l->l_proc, 0);
261 	CHECK_ALT_EXIST(l, &sg, SCARG(&ua, path));
262 
263 	return (sys_open(l, &ua, retval));
264 }
265 
266 int
267 netbsd32_link(l, v, retval)
268 	struct lwp *l;
269 	void *v;
270 	register_t *retval;
271 {
272 	struct netbsd32_link_args /* {
273 		syscallarg(const netbsd32_charp) path;
274 		syscallarg(const netbsd32_charp) link;
275 	} */ *uap = v;
276 	struct sys_link_args ua;
277 
278 	NETBSD32TOP_UAP(path, const char);
279 	NETBSD32TOP_UAP(link, const char);
280 	return (sys_link(l, &ua, retval));
281 }
282 
283 int
284 netbsd32_unlink(l, v, retval)
285 	struct lwp *l;
286 	void *v;
287 	register_t *retval;
288 {
289 	struct netbsd32_unlink_args /* {
290 		syscallarg(const netbsd32_charp) path;
291 	} */ *uap = v;
292 	struct sys_unlink_args ua;
293 
294 	NETBSD32TOP_UAP(path, const char);
295 
296 	return (sys_unlink(l, &ua, retval));
297 }
298 
299 int
300 netbsd32_chdir(l, v, retval)
301 	struct lwp *l;
302 	void *v;
303 	register_t *retval;
304 {
305 	struct netbsd32_chdir_args /* {
306 		syscallarg(const netbsd32_charp) path;
307 	} */ *uap = v;
308 	struct sys_chdir_args ua;
309 
310 	NETBSD32TOP_UAP(path, const char);
311 
312 	return (sys_chdir(l, &ua, retval));
313 }
314 
315 int
316 netbsd32_fchdir(l, v, retval)
317 	struct lwp *l;
318 	void *v;
319 	register_t *retval;
320 {
321 	struct netbsd32_fchdir_args /* {
322 		syscallarg(int) fd;
323 	} */ *uap = v;
324 	struct sys_fchdir_args ua;
325 
326 	NETBSD32TO64_UAP(fd);
327 
328 	return (sys_fchdir(l, &ua, retval));
329 }
330 
331 int
332 netbsd32_mknod(l, v, retval)
333 	struct lwp *l;
334 	void *v;
335 	register_t *retval;
336 {
337 	struct netbsd32_mknod_args /* {
338 		syscallarg(const netbsd32_charp) path;
339 		syscallarg(mode_t) mode;
340 		syscallarg(dev_t) dev;
341 	} */ *uap = v;
342 	struct sys_mknod_args ua;
343 
344 	NETBSD32TOP_UAP(path, const char);
345 	NETBSD32TO64_UAP(dev);
346 	NETBSD32TO64_UAP(mode);
347 
348 	return (sys_mknod(l, &ua, retval));
349 }
350 
351 int
352 netbsd32_chmod(l, v, retval)
353 	struct lwp *l;
354 	void *v;
355 	register_t *retval;
356 {
357 	struct netbsd32_chmod_args /* {
358 		syscallarg(const netbsd32_charp) path;
359 		syscallarg(mode_t) mode;
360 	} */ *uap = v;
361 	struct sys_chmod_args ua;
362 
363 	NETBSD32TOP_UAP(path, const char);
364 	NETBSD32TO64_UAP(mode);
365 
366 	return (sys_chmod(l, &ua, retval));
367 }
368 
369 int
370 netbsd32_chown(l, v, retval)
371 	struct lwp *l;
372 	void *v;
373 	register_t *retval;
374 {
375 	struct netbsd32_chown_args /* {
376 		syscallarg(const netbsd32_charp) path;
377 		syscallarg(uid_t) uid;
378 		syscallarg(gid_t) gid;
379 	} */ *uap = v;
380 	struct sys_chown_args ua;
381 
382 	NETBSD32TOP_UAP(path, const char);
383 	NETBSD32TO64_UAP(uid);
384 	NETBSD32TO64_UAP(gid);
385 
386 	return (sys_chown(l, &ua, retval));
387 }
388 
389 int
390 netbsd32_break(l, v, retval)
391 	struct lwp *l;
392 	void *v;
393 	register_t *retval;
394 {
395 	struct netbsd32_break_args /* {
396 		syscallarg(netbsd32_charp) nsize;
397 	} */ *uap = v;
398 	struct sys_obreak_args ua;
399 
400 	SCARG(&ua, nsize) = (char *)NETBSD32PTR64(SCARG(uap, nsize));
401 	NETBSD32TOP_UAP(nsize, char);
402 	return (sys_obreak(l, &ua, retval));
403 }
404 
405 int
406 netbsd32_mount(l, v, retval)
407 	struct lwp *l;
408 	void *v;
409 	register_t *retval;
410 {
411 	struct netbsd32_mount_args /* {
412 		syscallarg(const netbsd32_charp) type;
413 		syscallarg(const netbsd32_charp) path;
414 		syscallarg(int) flags;
415 		syscallarg(netbsd32_voidp) data;
416 	} */ *uap = v;
417 	struct sys_mount_args ua;
418 
419 	NETBSD32TOP_UAP(type, const char);
420 	NETBSD32TOP_UAP(path, const char);
421 	NETBSD32TO64_UAP(flags);
422 	NETBSD32TOP_UAP(data, void);
423 	return (sys_mount(l, &ua, retval));
424 }
425 
426 int
427 netbsd32_unmount(l, v, retval)
428 	struct lwp *l;
429 	void *v;
430 	register_t *retval;
431 {
432 	struct netbsd32_unmount_args /* {
433 		syscallarg(const netbsd32_charp) path;
434 		syscallarg(int) flags;
435 	} */ *uap = v;
436 	struct sys_unmount_args ua;
437 
438 	NETBSD32TOP_UAP(path, const char);
439 	NETBSD32TO64_UAP(flags);
440 	return (sys_unmount(l, &ua, retval));
441 }
442 
443 int
444 netbsd32_setuid(l, v, retval)
445 	struct lwp *l;
446 	void *v;
447 	register_t *retval;
448 {
449 	struct netbsd32_setuid_args /* {
450 		syscallarg(uid_t) uid;
451 	} */ *uap = v;
452 	struct sys_setuid_args ua;
453 
454 	NETBSD32TO64_UAP(uid);
455 	return (sys_setuid(l, &ua, retval));
456 }
457 
458 int
459 netbsd32_ptrace(l, v, retval)
460 	struct lwp *l;
461 	void *v;
462 	register_t *retval;
463 {
464 #if defined(PTRACE) || defined(_LKM)
465 	struct netbsd32_ptrace_args /* {
466 		syscallarg(int) req;
467 		syscallarg(pid_t) pid;
468 		syscallarg(netbsd32_caddr_t) addr;
469 		syscallarg(int) data;
470 	} */ *uap = v;
471 	struct sys_ptrace_args ua;
472 
473 	NETBSD32TO64_UAP(req);
474 	NETBSD32TO64_UAP(pid);
475 	NETBSD32TOX64_UAP(addr, caddr_t);
476 	NETBSD32TO64_UAP(data);
477 #ifdef _LKM
478 	return (*sysent[SYS_ptrace].sy_call)(l, &ua, retval);
479 #else
480 	return sys_ptrace(l, &ua, retval);
481 #endif
482 #else
483 	return (ENOSYS);
484 #endif /* PTRACE || _LKM */
485 }
486 
487 int
488 netbsd32_accept(l, v, retval)
489 	struct lwp *l;
490 	void *v;
491 	register_t *retval;
492 {
493 	struct netbsd32_accept_args /* {
494 		syscallarg(int) s;
495 		syscallarg(netbsd32_sockaddrp_t) name;
496 		syscallarg(netbsd32_intp) anamelen;
497 	} */ *uap = v;
498 	struct sys_accept_args ua;
499 
500 	NETBSD32TO64_UAP(s);
501 	NETBSD32TOP_UAP(name, struct sockaddr);
502 	NETBSD32TOP_UAP(anamelen, socklen_t);
503 	return (sys_accept(l, &ua, retval));
504 }
505 
506 int
507 netbsd32_getpeername(l, v, retval)
508 	struct lwp *l;
509 	void *v;
510 	register_t *retval;
511 {
512 	struct netbsd32_getpeername_args /* {
513 		syscallarg(int) fdes;
514 		syscallarg(netbsd32_sockaddrp_t) asa;
515 		syscallarg(netbsd32_intp) alen;
516 	} */ *uap = v;
517 	struct sys_getpeername_args ua;
518 
519 	NETBSD32TO64_UAP(fdes);
520 	NETBSD32TOP_UAP(asa, struct sockaddr);
521 	NETBSD32TOP_UAP(alen, socklen_t);
522 /* NB: do the protocol specific sockaddrs need to be converted? */
523 	return (sys_getpeername(l, &ua, retval));
524 }
525 
526 int
527 netbsd32_getsockname(l, v, retval)
528 	struct lwp *l;
529 	void *v;
530 	register_t *retval;
531 {
532 	struct netbsd32_getsockname_args /* {
533 		syscallarg(int) fdes;
534 		syscallarg(netbsd32_sockaddrp_t) asa;
535 		syscallarg(netbsd32_intp) alen;
536 	} */ *uap = v;
537 	struct sys_getsockname_args ua;
538 
539 	NETBSD32TO64_UAP(fdes);
540 	NETBSD32TOP_UAP(asa, struct sockaddr);
541 	NETBSD32TOP_UAP(alen, socklen_t);
542 	return (sys_getsockname(l, &ua, retval));
543 }
544 
545 int
546 netbsd32_access(l, v, retval)
547 	struct lwp *l;
548 	void *v;
549 	register_t *retval;
550 {
551 	struct netbsd32_access_args /* {
552 		syscallarg(const netbsd32_charp) path;
553 		syscallarg(int) flags;
554 	} */ *uap = v;
555 	struct sys_access_args ua;
556 	caddr_t sg;
557 
558 	NETBSD32TOP_UAP(path, const char);
559 	NETBSD32TO64_UAP(flags);
560 	sg = stackgap_init(l->l_proc, 0);
561 	CHECK_ALT_EXIST(l, &sg, SCARG(&ua, path));
562 
563 	return (sys_access(l, &ua, retval));
564 }
565 
566 int
567 netbsd32_chflags(l, v, retval)
568 	struct lwp *l;
569 	void *v;
570 	register_t *retval;
571 {
572 	struct netbsd32_chflags_args /* {
573 		syscallarg(const netbsd32_charp) path;
574 		syscallarg(netbsd32_u_long) flags;
575 	} */ *uap = v;
576 	struct sys_chflags_args ua;
577 
578 	NETBSD32TOP_UAP(path, const char);
579 	NETBSD32TO64_UAP(flags);
580 
581 	return (sys_chflags(l, &ua, retval));
582 }
583 
584 int
585 netbsd32_fchflags(l, v, retval)
586 	struct lwp *l;
587 	void *v;
588 	register_t *retval;
589 {
590 	struct netbsd32_fchflags_args /* {
591 		syscallarg(int) fd;
592 		syscallarg(netbsd32_u_long) flags;
593 	} */ *uap = v;
594 	struct sys_fchflags_args ua;
595 
596 	NETBSD32TO64_UAP(fd);
597 	NETBSD32TO64_UAP(flags);
598 
599 	return (sys_fchflags(l, &ua, retval));
600 }
601 
602 int
603 netbsd32_lchflags(l, v, retval)
604 	struct lwp *l;
605 	void *v;
606 	register_t *retval;
607 {
608 	struct netbsd32_lchflags_args /* {
609 		syscallarg(const char *) path;
610 		syscallarg(netbsd32_u_long) flags;
611 	} */ *uap = v;
612 	struct sys_lchflags_args ua;
613 
614 	NETBSD32TOP_UAP(path, const char);
615 	NETBSD32TO64_UAP(flags);
616 
617 	return (sys_lchflags(l, &ua, retval));
618 }
619 
620 int
621 netbsd32_kill(l, v, retval)
622 	struct lwp *l;
623 	void *v;
624 	register_t *retval;
625 {
626 	struct netbsd32_kill_args /* {
627 		syscallarg(int) pid;
628 		syscallarg(int) signum;
629 	} */ *uap = v;
630 	struct sys_kill_args ua;
631 
632 	NETBSD32TO64_UAP(pid);
633 	NETBSD32TO64_UAP(signum);
634 
635 	return (sys_kill(l, &ua, retval));
636 }
637 
638 int
639 netbsd32_dup(l, v, retval)
640 	struct lwp *l;
641 	void *v;
642 	register_t *retval;
643 {
644 	struct netbsd32_dup_args /* {
645 		syscallarg(int) fd;
646 	} */ *uap = v;
647 	struct sys_dup_args ua;
648 
649 	NETBSD32TO64_UAP(fd);
650 
651 	return (sys_dup(l, &ua, retval));
652 }
653 
654 int
655 netbsd32_profil(l, v, retval)
656 	struct lwp *l;
657 	void *v;
658 	register_t *retval;
659 {
660 	struct netbsd32_profil_args /* {
661 		syscallarg(netbsd32_caddr_t) samples;
662 		syscallarg(netbsd32_size_t) size;
663 		syscallarg(netbsd32_u_long) offset;
664 		syscallarg(u_int) scale;
665 	} */ *uap = v;
666 	struct sys_profil_args ua;
667 
668 	NETBSD32TOX64_UAP(samples, caddr_t);
669 	NETBSD32TOX_UAP(size, size_t);
670 	NETBSD32TOX_UAP(offset, u_long);
671 	NETBSD32TO64_UAP(scale);
672 	return (sys_profil(l, &ua, retval));
673 }
674 
675 #ifdef KTRACE
676 int
677 netbsd32_ktrace(l, v, retval)
678 	struct lwp *l;
679 	void *v;
680 	register_t *retval;
681 {
682 	struct netbsd32_ktrace_args /* {
683 		syscallarg(const netbsd32_charp) fname;
684 		syscallarg(int) ops;
685 		syscallarg(int) facs;
686 		syscallarg(int) pid;
687 	} */ *uap = v;
688 	struct sys_ktrace_args ua;
689 
690 	NETBSD32TOP_UAP(fname, const char);
691 	NETBSD32TO64_UAP(ops);
692 	NETBSD32TO64_UAP(facs);
693 	NETBSD32TO64_UAP(pid);
694 	return (sys_ktrace(l, &ua, retval));
695 }
696 #endif /* KTRACE */
697 
698 int
699 netbsd32_utrace(l, v, retval)
700 	struct lwp *l;
701 	void *v;
702 	register_t *retval;
703 {
704 	struct netbsd32_utrace_args /* {
705 		syscallarg(const netbsd32_charp) label;
706 		syscallarg(netbsd32_voidp) addr;
707 		syscallarg(netbsd32_size_t) len;
708 	} */ *uap = v;
709 	struct sys_utrace_args ua;
710 
711 	NETBSD32TOP_UAP(label, const char);
712 	NETBSD32TOP_UAP(addr, void);
713 	NETBSD32TO64_UAP(len);
714 	return (sys_utrace(l, &ua, retval));
715 }
716 
717 int
718 netbsd32___getlogin(l, v, retval)
719 	struct lwp *l;
720 	void *v;
721 	register_t *retval;
722 {
723 	struct netbsd32___getlogin_args /* {
724 		syscallarg(netbsd32_charp) namebuf;
725 		syscallarg(u_int) namelen;
726 	} */ *uap = v;
727 	struct sys___getlogin_args ua;
728 
729 	NETBSD32TOP_UAP(namebuf, char);
730 	NETBSD32TO64_UAP(namelen);
731 	return (sys___getlogin(l, &ua, retval));
732 }
733 
734 int
735 netbsd32_setlogin(l, v, retval)
736 	struct lwp *l;
737 	void *v;
738 	register_t *retval;
739 {
740 	struct netbsd32_setlogin_args /* {
741 		syscallarg(const netbsd32_charp) namebuf;
742 	} */ *uap = v;
743 	struct sys___setlogin_args ua;
744 
745 	NETBSD32TOP_UAP(namebuf, char);
746 	return (sys___setlogin(l, &ua, retval));
747 }
748 
749 int
750 netbsd32_acct(l, v, retval)
751 	struct lwp *l;
752 	void *v;
753 	register_t *retval;
754 {
755 	struct netbsd32_acct_args /* {
756 		syscallarg(const netbsd32_charp) path;
757 	} */ *uap = v;
758 	struct sys_acct_args ua;
759 
760 	NETBSD32TOP_UAP(path, const char);
761 	return (sys_acct(l, &ua, retval));
762 }
763 
764 int
765 netbsd32_revoke(l, v, retval)
766 	struct lwp *l;
767 	void *v;
768 	register_t *retval;
769 {
770 	struct netbsd32_revoke_args /* {
771 		syscallarg(const netbsd32_charp) path;
772 	} */ *uap = v;
773 	struct sys_revoke_args ua;
774 	caddr_t sg;
775 
776 	NETBSD32TOP_UAP(path, const char);
777 	sg = stackgap_init(l->l_proc, 0);
778 	CHECK_ALT_EXIST(l, &sg, SCARG(&ua, path));
779 
780 	return (sys_revoke(l, &ua, retval));
781 }
782 
783 int
784 netbsd32_symlink(l, v, retval)
785 	struct lwp *l;
786 	void *v;
787 	register_t *retval;
788 {
789 	struct netbsd32_symlink_args /* {
790 		syscallarg(const netbsd32_charp) path;
791 		syscallarg(const netbsd32_charp) link;
792 	} */ *uap = v;
793 	struct sys_symlink_args ua;
794 
795 	NETBSD32TOP_UAP(path, const char);
796 	NETBSD32TOP_UAP(link, const char);
797 
798 	return (sys_symlink(l, &ua, retval));
799 }
800 
801 int
802 netbsd32_readlink(l, v, retval)
803 	struct lwp *l;
804 	void *v;
805 	register_t *retval;
806 {
807 	struct netbsd32_readlink_args /* {
808 		syscallarg(const netbsd32_charp) path;
809 		syscallarg(netbsd32_charp) buf;
810 		syscallarg(netbsd32_size_t) count;
811 	} */ *uap = v;
812 	struct sys_readlink_args ua;
813 	caddr_t sg;
814 
815 	NETBSD32TOP_UAP(path, const char);
816 	NETBSD32TOP_UAP(buf, char);
817 	NETBSD32TOX_UAP(count, size_t);
818 	sg = stackgap_init(l->l_proc, 0);
819 	CHECK_ALT_SYMLINK(l, &sg, SCARG(&ua, path));
820 
821 	return (sys_readlink(l, &ua, retval));
822 }
823 
824 int
825 netbsd32_umask(l, v, retval)
826 	struct lwp *l;
827 	void *v;
828 	register_t *retval;
829 {
830 	struct netbsd32_umask_args /* {
831 		syscallarg(mode_t) newmask;
832 	} */ *uap = v;
833 	struct sys_umask_args ua;
834 
835 	NETBSD32TO64_UAP(newmask);
836 	return (sys_umask(l, &ua, retval));
837 }
838 
839 int
840 netbsd32_chroot(l, v, retval)
841 	struct lwp *l;
842 	void *v;
843 	register_t *retval;
844 {
845 	struct netbsd32_chroot_args /* {
846 		syscallarg(const netbsd32_charp) path;
847 	} */ *uap = v;
848 	struct sys_chroot_args ua;
849 
850 	NETBSD32TOP_UAP(path, const char);
851 	return (sys_chroot(l, &ua, retval));
852 }
853 
854 int
855 netbsd32_sbrk(l, v, retval)
856 	struct lwp *l;
857 	void *v;
858 	register_t *retval;
859 {
860 	struct netbsd32_sbrk_args /* {
861 		syscallarg(int) incr;
862 	} */ *uap = v;
863 	struct sys_sbrk_args ua;
864 
865 	NETBSD32TO64_UAP(incr);
866 	return (sys_sbrk(l, &ua, retval));
867 }
868 
869 int
870 netbsd32_sstk(l, v, retval)
871 	struct lwp *l;
872 	void *v;
873 	register_t *retval;
874 {
875 	struct netbsd32_sstk_args /* {
876 		syscallarg(int) incr;
877 	} */ *uap = v;
878 	struct sys_sstk_args ua;
879 
880 	NETBSD32TO64_UAP(incr);
881 	return (sys_sstk(l, &ua, retval));
882 }
883 
884 int
885 netbsd32_munmap(l, v, retval)
886 	struct lwp *l;
887 	void *v;
888 	register_t *retval;
889 {
890 	struct netbsd32_munmap_args /* {
891 		syscallarg(netbsd32_voidp) addr;
892 		syscallarg(netbsd32_size_t) len;
893 	} */ *uap = v;
894 	struct sys_munmap_args ua;
895 
896 	NETBSD32TOP_UAP(addr, void);
897 	NETBSD32TOX_UAP(len, size_t);
898 	return (sys_munmap(l, &ua, retval));
899 }
900 
901 int
902 netbsd32_mprotect(l, v, retval)
903 	struct lwp *l;
904 	void *v;
905 	register_t *retval;
906 {
907 	struct netbsd32_mprotect_args /* {
908 		syscallarg(netbsd32_voidp) addr;
909 		syscallarg(netbsd32_size_t) len;
910 		syscallarg(int) prot;
911 	} */ *uap = v;
912 	struct sys_mprotect_args ua;
913 
914 	NETBSD32TOP_UAP(addr, void);
915 	NETBSD32TOX_UAP(len, size_t);
916 	NETBSD32TO64_UAP(prot);
917 	return (sys_mprotect(l, &ua, retval));
918 }
919 
920 int
921 netbsd32_madvise(l, v, retval)
922 	struct lwp *l;
923 	void *v;
924 	register_t *retval;
925 {
926 	struct netbsd32_madvise_args /* {
927 		syscallarg(netbsd32_voidp) addr;
928 		syscallarg(netbsd32_size_t) len;
929 		syscallarg(int) behav;
930 	} */ *uap = v;
931 	struct sys_madvise_args ua;
932 
933 	NETBSD32TOP_UAP(addr, void);
934 	NETBSD32TOX_UAP(len, size_t);
935 	NETBSD32TO64_UAP(behav);
936 	return (sys_madvise(l, &ua, retval));
937 }
938 
939 int
940 netbsd32_mincore(l, v, retval)
941 	struct lwp *l;
942 	void *v;
943 	register_t *retval;
944 {
945 	struct netbsd32_mincore_args /* {
946 		syscallarg(netbsd32_caddr_t) addr;
947 		syscallarg(netbsd32_size_t) len;
948 		syscallarg(netbsd32_charp) vec;
949 	} */ *uap = v;
950 	struct sys_mincore_args ua;
951 
952 	NETBSD32TOX64_UAP(addr, caddr_t);
953 	NETBSD32TOX_UAP(len, size_t);
954 	NETBSD32TOP_UAP(vec, char);
955 	return (sys_mincore(l, &ua, retval));
956 }
957 
958 /* XXX MOVE ME XXX ? */
959 int
960 netbsd32_getgroups(l, v, retval)
961 	struct lwp *l;
962 	void *v;
963 	register_t *retval;
964 {
965 	struct netbsd32_getgroups_args /* {
966 		syscallarg(int) gidsetsize;
967 		syscallarg(netbsd32_gid_tp) gidset;
968 	} */ *uap = v;
969 	kauth_cred_t pc = l->l_cred;
970 	int ngrp;
971 	int error;
972 	gid_t *grbuf;
973 
974 	ngrp = SCARG(uap, gidsetsize);
975 	if (ngrp == 0) {
976 		*retval = kauth_cred_ngroups(pc);
977 		return (0);
978 	}
979 	if (ngrp < kauth_cred_ngroups(pc))
980 		return (EINVAL);
981 	ngrp = kauth_cred_ngroups(pc);
982 	/* Should convert gid_t to netbsd32_gid_t, but they're the same */
983 	grbuf = malloc(ngrp * sizeof(*grbuf), M_TEMP, M_WAITOK);
984 	kauth_cred_getgroups(pc, grbuf, ngrp);
985 	error = copyout(grbuf, (caddr_t)NETBSD32PTR64(SCARG(uap, gidset)),
986 			ngrp * sizeof(*grbuf));
987 	free(grbuf, M_TEMP);
988 	if (error)
989 		return (error);
990 	*retval = ngrp;
991 	return (0);
992 }
993 
994 int
995 netbsd32_setgroups(l, v, retval)
996 	struct lwp *l;
997 	void *v;
998 	register_t *retval;
999 {
1000 	struct netbsd32_setgroups_args /* {
1001 		syscallarg(int) gidsetsize;
1002 		syscallarg(const netbsd32_gid_tp) gidset;
1003 	} */ *uap = v;
1004 	struct sys_setgroups_args ua;
1005 
1006 	NETBSD32TO64_UAP(gidsetsize);
1007 	NETBSD32TOP_UAP(gidset, gid_t);
1008 	return (sys_setgroups(l, &ua, retval));
1009 }
1010 
1011 int
1012 netbsd32_setpgid(l, v, retval)
1013 	struct lwp *l;
1014 	void *v;
1015 	register_t *retval;
1016 {
1017 	struct netbsd32_setpgid_args /* {
1018 		syscallarg(int) pid;
1019 		syscallarg(int) pgid;
1020 	} */ *uap = v;
1021 	struct sys_setpgid_args ua;
1022 
1023 	NETBSD32TO64_UAP(pid);
1024 	NETBSD32TO64_UAP(pgid);
1025 	return (sys_setpgid(l, &ua, retval));
1026 }
1027 
1028 int
1029 netbsd32_fcntl(l, v, retval)
1030 	struct lwp *l;
1031 	void *v;
1032 	register_t *retval;
1033 {
1034 	struct netbsd32_fcntl_args /* {
1035 		syscallarg(int) fd;
1036 		syscallarg(int) cmd;
1037 		syscallarg(netbsd32_voidp) arg;
1038 	} */ *uap = v;
1039 	struct sys_fcntl_args ua;
1040 
1041 	NETBSD32TO64_UAP(fd);
1042 	NETBSD32TO64_UAP(cmd);
1043 	NETBSD32TOP_UAP(arg, void);
1044 	/* we can do this because `struct flock' doesn't change */
1045 	return (sys_fcntl(l, &ua, retval));
1046 }
1047 
1048 int
1049 netbsd32_dup2(l, v, retval)
1050 	struct lwp *l;
1051 	void *v;
1052 	register_t *retval;
1053 {
1054 	struct netbsd32_dup2_args /* {
1055 		syscallarg(int) from;
1056 		syscallarg(int) to;
1057 	} */ *uap = v;
1058 	struct sys_dup2_args ua;
1059 
1060 	NETBSD32TO64_UAP(from);
1061 	NETBSD32TO64_UAP(to);
1062 	return (sys_dup2(l, &ua, retval));
1063 }
1064 
1065 int
1066 netbsd32_fsync(l, v, retval)
1067 	struct lwp *l;
1068 	void *v;
1069 	register_t *retval;
1070 {
1071 	struct netbsd32_fsync_args /* {
1072 		syscallarg(int) fd;
1073 	} */ *uap = v;
1074 	struct sys_fsync_args ua;
1075 
1076 	NETBSD32TO64_UAP(fd);
1077 	return (sys_fsync(l, &ua, retval));
1078 }
1079 
1080 int
1081 netbsd32_setpriority(l, v, retval)
1082 	struct lwp *l;
1083 	void *v;
1084 	register_t *retval;
1085 {
1086 	struct netbsd32_setpriority_args /* {
1087 		syscallarg(int) which;
1088 		syscallarg(int) who;
1089 		syscallarg(int) prio;
1090 	} */ *uap = v;
1091 	struct sys_setpriority_args ua;
1092 
1093 	NETBSD32TO64_UAP(which);
1094 	NETBSD32TO64_UAP(who);
1095 	NETBSD32TO64_UAP(prio);
1096 	return (sys_setpriority(l, &ua, retval));
1097 }
1098 
1099 int
1100 netbsd32_sys___socket30(l, v, retval)
1101 	struct lwp *l;
1102 	void *v;
1103 	register_t *retval;
1104 {
1105 	struct netbsd32_sys___socket30_args /* {
1106 		syscallarg(int) domain;
1107 		syscallarg(int) type;
1108 		syscallarg(int) protocol;
1109 	} */ *uap = v;
1110 	struct sys___socket30_args ua;
1111 
1112 	NETBSD32TO64_UAP(domain);
1113 	NETBSD32TO64_UAP(type);
1114 	NETBSD32TO64_UAP(protocol);
1115 	return (sys___socket30(l, &ua, retval));
1116 }
1117 
1118 int
1119 netbsd32_connect(l, v, retval)
1120 	struct lwp *l;
1121 	void *v;
1122 	register_t *retval;
1123 {
1124 	struct netbsd32_connect_args /* {
1125 		syscallarg(int) s;
1126 		syscallarg(const netbsd32_sockaddrp_t) name;
1127 		syscallarg(int) namelen;
1128 	} */ *uap = v;
1129 	struct sys_connect_args ua;
1130 
1131 	NETBSD32TO64_UAP(s);
1132 	NETBSD32TOP_UAP(name, struct sockaddr);
1133 	NETBSD32TO64_UAP(namelen);
1134 	return (sys_connect(l, &ua, retval));
1135 }
1136 
1137 int
1138 netbsd32_getpriority(l, v, retval)
1139 	struct lwp *l;
1140 	void *v;
1141 	register_t *retval;
1142 {
1143 	struct netbsd32_getpriority_args /* {
1144 		syscallarg(int) which;
1145 		syscallarg(int) who;
1146 	} */ *uap = v;
1147 	struct sys_getpriority_args ua;
1148 
1149 	NETBSD32TO64_UAP(which);
1150 	NETBSD32TO64_UAP(who);
1151 	return (sys_getpriority(l, &ua, retval));
1152 }
1153 
1154 int
1155 netbsd32_bind(l, v, retval)
1156 	struct lwp *l;
1157 	void *v;
1158 	register_t *retval;
1159 {
1160 	struct netbsd32_bind_args /* {
1161 		syscallarg(int) s;
1162 		syscallarg(const netbsd32_sockaddrp_t) name;
1163 		syscallarg(int) namelen;
1164 	} */ *uap = v;
1165 	struct sys_bind_args ua;
1166 
1167 	NETBSD32TO64_UAP(s);
1168 	NETBSD32TOP_UAP(name, struct sockaddr);
1169 	NETBSD32TO64_UAP(namelen);
1170 	return (sys_bind(l, &ua, retval));
1171 }
1172 
1173 int
1174 netbsd32_setsockopt(l, v, retval)
1175 	struct lwp *l;
1176 	void *v;
1177 	register_t *retval;
1178 {
1179 	struct netbsd32_setsockopt_args /* {
1180 		syscallarg(int) s;
1181 		syscallarg(int) level;
1182 		syscallarg(int) name;
1183 		syscallarg(const netbsd32_voidp) val;
1184 		syscallarg(int) valsize;
1185 	} */ *uap = v;
1186 	struct sys_setsockopt_args ua;
1187 
1188 	NETBSD32TO64_UAP(s);
1189 	NETBSD32TO64_UAP(level);
1190 	NETBSD32TO64_UAP(name);
1191 	NETBSD32TOP_UAP(val, void);
1192 	NETBSD32TO64_UAP(valsize);
1193 	/* may be more efficient to do this inline. */
1194 	return (sys_setsockopt(l, &ua, retval));
1195 }
1196 
1197 int
1198 netbsd32_listen(l, v, retval)
1199 	struct lwp *l;
1200 	void *v;
1201 	register_t *retval;
1202 {
1203 	struct netbsd32_listen_args /* {
1204 		syscallarg(int) s;
1205 		syscallarg(int) backlog;
1206 	} */ *uap = v;
1207 	struct sys_listen_args ua;
1208 
1209 	NETBSD32TO64_UAP(s);
1210 	NETBSD32TO64_UAP(backlog);
1211 	return (sys_listen(l, &ua, retval));
1212 }
1213 
1214 int
1215 netbsd32_fchown(l, v, retval)
1216 	struct lwp *l;
1217 	void *v;
1218 	register_t *retval;
1219 {
1220 	struct netbsd32_fchown_args /* {
1221 		syscallarg(int) fd;
1222 		syscallarg(uid_t) uid;
1223 		syscallarg(gid_t) gid;
1224 	} */ *uap = v;
1225 	struct sys_fchown_args ua;
1226 
1227 	NETBSD32TO64_UAP(fd);
1228 	NETBSD32TO64_UAP(uid);
1229 	NETBSD32TO64_UAP(gid);
1230 	return (sys_fchown(l, &ua, retval));
1231 }
1232 
1233 int
1234 netbsd32_fchmod(l, v, retval)
1235 	struct lwp *l;
1236 	void *v;
1237 	register_t *retval;
1238 {
1239 	struct netbsd32_fchmod_args /* {
1240 		syscallarg(int) fd;
1241 		syscallarg(mode_t) mode;
1242 	} */ *uap = v;
1243 	struct sys_fchmod_args ua;
1244 
1245 	NETBSD32TO64_UAP(fd);
1246 	NETBSD32TO64_UAP(mode);
1247 	return (sys_fchmod(l, &ua, retval));
1248 }
1249 
1250 int
1251 netbsd32_setreuid(l, v, retval)
1252 	struct lwp *l;
1253 	void *v;
1254 	register_t *retval;
1255 {
1256 	struct netbsd32_setreuid_args /* {
1257 		syscallarg(uid_t) ruid;
1258 		syscallarg(uid_t) euid;
1259 	} */ *uap = v;
1260 	struct sys_setreuid_args ua;
1261 
1262 	NETBSD32TO64_UAP(ruid);
1263 	NETBSD32TO64_UAP(euid);
1264 	return (sys_setreuid(l, &ua, retval));
1265 }
1266 
1267 int
1268 netbsd32_setregid(l, v, retval)
1269 	struct lwp *l;
1270 	void *v;
1271 	register_t *retval;
1272 {
1273 	struct netbsd32_setregid_args /* {
1274 		syscallarg(gid_t) rgid;
1275 		syscallarg(gid_t) egid;
1276 	} */ *uap = v;
1277 	struct sys_setregid_args ua;
1278 
1279 	NETBSD32TO64_UAP(rgid);
1280 	NETBSD32TO64_UAP(egid);
1281 	return (sys_setregid(l, &ua, retval));
1282 }
1283 
1284 int
1285 netbsd32_getsockopt(l, v, retval)
1286 	struct lwp *l;
1287 	void *v;
1288 	register_t *retval;
1289 {
1290 	struct netbsd32_getsockopt_args /* {
1291 		syscallarg(int) s;
1292 		syscallarg(int) level;
1293 		syscallarg(int) name;
1294 		syscallarg(netbsd32_voidp) val;
1295 		syscallarg(netbsd32_intp) avalsize;
1296 	} */ *uap = v;
1297 	struct sys_getsockopt_args ua;
1298 
1299 	NETBSD32TO64_UAP(s);
1300 	NETBSD32TO64_UAP(level);
1301 	NETBSD32TO64_UAP(name);
1302 	NETBSD32TOP_UAP(val, void);
1303 	NETBSD32TOP_UAP(avalsize, socklen_t);
1304 	return (sys_getsockopt(l, &ua, retval));
1305 }
1306 
1307 int
1308 netbsd32_rename(l, v, retval)
1309 	struct lwp *l;
1310 	void *v;
1311 	register_t *retval;
1312 {
1313 	struct netbsd32_rename_args /* {
1314 		syscallarg(const netbsd32_charp) from;
1315 		syscallarg(const netbsd32_charp) to;
1316 	} */ *uap = v;
1317 	struct sys_rename_args ua;
1318 
1319 	NETBSD32TOP_UAP(from, const char);
1320 	NETBSD32TOP_UAP(to, const char)
1321 
1322 	return (sys_rename(l, &ua, retval));
1323 }
1324 
1325 int
1326 netbsd32_flock(l, v, retval)
1327 	struct lwp *l;
1328 	void *v;
1329 	register_t *retval;
1330 {
1331 	struct netbsd32_flock_args /* {
1332 		syscallarg(int) fd;
1333 		syscallarg(int) how;
1334 	} */ *uap = v;
1335 	struct sys_flock_args ua;
1336 
1337 	NETBSD32TO64_UAP(fd);
1338 	NETBSD32TO64_UAP(how)
1339 
1340 	return (sys_flock(l, &ua, retval));
1341 }
1342 
1343 int
1344 netbsd32_mkfifo(l, v, retval)
1345 	struct lwp *l;
1346 	void *v;
1347 	register_t *retval;
1348 {
1349 	struct netbsd32_mkfifo_args /* {
1350 		syscallarg(const netbsd32_charp) path;
1351 		syscallarg(mode_t) mode;
1352 	} */ *uap = v;
1353 	struct sys_mkfifo_args ua;
1354 
1355 	NETBSD32TOP_UAP(path, const char)
1356 	NETBSD32TO64_UAP(mode);
1357 	return (sys_mkfifo(l, &ua, retval));
1358 }
1359 
1360 int
1361 netbsd32_shutdown(l, v, retval)
1362 	struct lwp *l;
1363 	void *v;
1364 	register_t *retval;
1365 {
1366 	struct netbsd32_shutdown_args /* {
1367 		syscallarg(int) s;
1368 		syscallarg(int) how;
1369 	} */ *uap = v;
1370 	struct sys_shutdown_args ua;
1371 
1372 	NETBSD32TO64_UAP(s)
1373 	NETBSD32TO64_UAP(how);
1374 	return (sys_shutdown(l, &ua, retval));
1375 }
1376 
1377 int
1378 netbsd32_socketpair(l, v, retval)
1379 	struct lwp *l;
1380 	void *v;
1381 	register_t *retval;
1382 {
1383 	struct netbsd32_socketpair_args /* {
1384 		syscallarg(int) domain;
1385 		syscallarg(int) type;
1386 		syscallarg(int) protocol;
1387 		syscallarg(netbsd32_intp) rsv;
1388 	} */ *uap = v;
1389 	struct sys_socketpair_args ua;
1390 
1391 	NETBSD32TO64_UAP(domain);
1392 	NETBSD32TO64_UAP(type);
1393 	NETBSD32TO64_UAP(protocol);
1394 	NETBSD32TOP_UAP(rsv, int);
1395 	/* Since we're just copying out two `int's we can do this */
1396 	return (sys_socketpair(l, &ua, retval));
1397 }
1398 
1399 int
1400 netbsd32_mkdir(l, v, retval)
1401 	struct lwp *l;
1402 	void *v;
1403 	register_t *retval;
1404 {
1405 	struct netbsd32_mkdir_args /* {
1406 		syscallarg(const netbsd32_charp) path;
1407 		syscallarg(mode_t) mode;
1408 	} */ *uap = v;
1409 	struct sys_mkdir_args ua;
1410 
1411 	NETBSD32TOP_UAP(path, const char)
1412 	NETBSD32TO64_UAP(mode);
1413 	return (sys_mkdir(l, &ua, retval));
1414 }
1415 
1416 int
1417 netbsd32_rmdir(l, v, retval)
1418 	struct lwp *l;
1419 	void *v;
1420 	register_t *retval;
1421 {
1422 	struct netbsd32_rmdir_args /* {
1423 		syscallarg(const netbsd32_charp) path;
1424 	} */ *uap = v;
1425 	struct sys_rmdir_args ua;
1426 
1427 	NETBSD32TOP_UAP(path, const char);
1428 	return (sys_rmdir(l, &ua, retval));
1429 }
1430 
1431 int
1432 netbsd32_quotactl(l, v, retval)
1433 	struct lwp *l;
1434 	void *v;
1435 	register_t *retval;
1436 {
1437 	struct netbsd32_quotactl_args /* {
1438 		syscallarg(const netbsd32_charp) path;
1439 		syscallarg(int) cmd;
1440 		syscallarg(int) uid;
1441 		syscallarg(netbsd32_caddr_t) arg;
1442 	} */ *uap = v;
1443 	struct sys_quotactl_args ua;
1444 
1445 	NETBSD32TOP_UAP(path, const char);
1446 	NETBSD32TO64_UAP(cmd);
1447 	NETBSD32TO64_UAP(uid);
1448 	NETBSD32TOX64_UAP(arg, caddr_t);
1449 	return (sys_quotactl(l, &ua, retval));
1450 }
1451 
1452 #if defined(NFS) || defined(NFSSERVER)
1453 int
1454 netbsd32_nfssvc(l, v, retval)
1455 	struct lwp *l;
1456 	void *v;
1457 	register_t *retval;
1458 {
1459 #if 0
1460 	struct netbsd32_nfssvc_args /* {
1461 		syscallarg(int) flag;
1462 		syscallarg(netbsd32_voidp) argp;
1463 	} */ *uap = v;
1464 	struct sys_nfssvc_args ua;
1465 
1466 	NETBSD32TO64_UAP(flag);
1467 	NETBSD32TOP_UAP(argp, void);
1468 	return (sys_nfssvc(l, &ua, retval));
1469 #else
1470 	/* Why would we want to support a 32-bit nfsd? */
1471 	return (ENOSYS);
1472 #endif
1473 }
1474 #endif
1475 
1476 int
1477 netbsd32___getfh30(l, v, retval)
1478 	struct lwp *l;
1479 	void *v;
1480 	register_t *retval;
1481 {
1482 	struct netbsd32___getfh30_args /* {
1483 		syscallarg(const netbsd32_charp) fname;
1484 		syscallarg(netbsd32_fhandlep_t) fhp;
1485 		syscallarg(netbsd32_size_tp) fh_size;
1486 	} */ *uap = v;
1487 	struct vnode *vp;
1488 	fhandle_t *fh;
1489 	int error;
1490 	struct nameidata nd;
1491 	netbsd32_size_t sz32;
1492 	size_t sz;
1493 
1494 	/*
1495 	 * Must be super user
1496 	 */
1497 	error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FILEHANDLE,
1498 	    0, NULL, NULL, NULL);
1499 	if (error)
1500 		return (error);
1501 	fh = NULL;
1502 	NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
1503 	    (char *)NETBSD32PTR64(SCARG(uap, fname)), l);
1504 	error = namei(&nd);
1505 	if (error)
1506 		return (error);
1507 	vp = nd.ni_vp;
1508 	error = copyin(NETBSD32PTR64(SCARG(uap, fh_size)), &sz32,
1509 	    sizeof(netbsd32_size_t));
1510 	if (!error) {
1511 		fh = malloc(sz32, M_TEMP, M_WAITOK);
1512 		if (fh == NULL)
1513 			return EINVAL;
1514 		sz = sz32;
1515 		error = vfs_composefh(vp, fh, &sz);
1516 		sz32 = sz;
1517 	}
1518 	vput(vp);
1519 	if (error == E2BIG)
1520 		copyout(&sz, NETBSD32PTR64(SCARG(uap, fh_size)), sizeof(size_t));
1521 	if (error == 0) {
1522 		error = copyout(&sz32, NETBSD32PTR64(SCARG(uap, fh_size)),
1523 		    sizeof(netbsd32_size_t));
1524 		if (!error)
1525 			error = copyout(fh, NETBSD32PTR64(SCARG(uap, fhp)), sz);
1526 	}
1527 	free(fh, M_TEMP);
1528 	return (error);
1529 }
1530 
1531 int
1532 netbsd32_pread(l, v, retval)
1533 	struct lwp *l;
1534 	void *v;
1535 	register_t *retval;
1536 {
1537 	struct netbsd32_pread_args /* {
1538 		syscallarg(int) fd;
1539 		syscallarg(netbsd32_voidp) buf;
1540 		syscallarg(netbsd32_size_t) nbyte;
1541 		syscallarg(int) pad;
1542 		syscallarg(off_t) offset;
1543 	} */ *uap = v;
1544 	struct sys_pread_args ua;
1545 	ssize_t rt;
1546 	int error;
1547 
1548 	NETBSD32TO64_UAP(fd);
1549 	NETBSD32TOP_UAP(buf, void);
1550 	NETBSD32TOX_UAP(nbyte, size_t);
1551 	NETBSD32TO64_UAP(pad);
1552 	NETBSD32TO64_UAP(offset);
1553 	error = sys_pread(l, &ua, (register_t *)&rt);
1554 	*retval = rt;
1555 	return (error);
1556 }
1557 
1558 int
1559 netbsd32_pwrite(l, v, retval)
1560 	struct lwp *l;
1561 	void *v;
1562 	register_t *retval;
1563 {
1564 	struct netbsd32_pwrite_args /* {
1565 		syscallarg(int) fd;
1566 		syscallarg(const netbsd32_voidp) buf;
1567 		syscallarg(netbsd32_size_t) nbyte;
1568 		syscallarg(int) pad;
1569 		syscallarg(off_t) offset;
1570 	} */ *uap = v;
1571 	struct sys_pwrite_args ua;
1572 	ssize_t rt;
1573 	int error;
1574 
1575 	NETBSD32TO64_UAP(fd);
1576 	NETBSD32TOP_UAP(buf, void);
1577 	NETBSD32TOX_UAP(nbyte, size_t);
1578 	NETBSD32TO64_UAP(pad);
1579 	NETBSD32TO64_UAP(offset);
1580 	error = sys_pwrite(l, &ua, (register_t *)&rt);
1581 	*retval = rt;
1582 	return (error);
1583 }
1584 
1585 int
1586 netbsd32_setgid(l, v, retval)
1587 	struct lwp *l;
1588 	void *v;
1589 	register_t *retval;
1590 {
1591 	struct netbsd32_setgid_args /* {
1592 		syscallarg(gid_t) gid;
1593 	} */ *uap = v;
1594 	struct sys_setgid_args ua;
1595 
1596 	NETBSD32TO64_UAP(gid);
1597 	return (sys_setgid(l, v, retval));
1598 }
1599 
1600 int
1601 netbsd32_setegid(l, v, retval)
1602 	struct lwp *l;
1603 	void *v;
1604 	register_t *retval;
1605 {
1606 	struct netbsd32_setegid_args /* {
1607 		syscallarg(gid_t) egid;
1608 	} */ *uap = v;
1609 	struct sys_setegid_args ua;
1610 
1611 	NETBSD32TO64_UAP(egid);
1612 	return (sys_setegid(l, v, retval));
1613 }
1614 
1615 int
1616 netbsd32_seteuid(l, v, retval)
1617 	struct lwp *l;
1618 	void *v;
1619 	register_t *retval;
1620 {
1621 	struct netbsd32_seteuid_args /* {
1622 		syscallarg(gid_t) euid;
1623 	} */ *uap = v;
1624 	struct sys_seteuid_args ua;
1625 
1626 	NETBSD32TO64_UAP(euid);
1627 	return (sys_seteuid(l, v, retval));
1628 }
1629 
1630 #ifdef LFS
1631 int
1632 netbsd32_sys_lfs_bmapv(l, v, retval)
1633 	struct lwp *l;
1634 	void *v;
1635 	register_t *retval;
1636 {
1637 
1638 	return (ENOSYS);	/* XXX */
1639 }
1640 
1641 int
1642 netbsd32_sys_lfs_markv(l, v, retval)
1643 	struct lwp *l;
1644 	void *v;
1645 	register_t *retval;
1646 {
1647 
1648 	return (ENOSYS);	/* XXX */
1649 }
1650 
1651 int
1652 netbsd32_sys_lfs_segclean(l, v, retval)
1653 	struct lwp *l;
1654 	void *v;
1655 	register_t *retval;
1656 {
1657 
1658 	return (ENOSYS);	/* XXX */
1659 }
1660 
1661 int
1662 netbsd32_sys_lfs_segwait(l, v, retval)
1663 	struct lwp *l;
1664 	void *v;
1665 	register_t *retval;
1666 {
1667 
1668 	return (ENOSYS);	/* XXX */
1669 }
1670 #endif
1671 
1672 int
1673 netbsd32_pathconf(l, v, retval)
1674 	struct lwp *l;
1675 	void *v;
1676 	register_t *retval;
1677 {
1678 	struct netbsd32_pathconf_args /* {
1679 		syscallarg(int) fd;
1680 		syscallarg(int) name;
1681 	} */ *uap = v;
1682 	struct sys_pathconf_args ua;
1683 	long rt;
1684 	int error;
1685 
1686 	NETBSD32TOP_UAP(path, const char);
1687 	NETBSD32TO64_UAP(name);
1688 	error = sys_pathconf(l, &ua, (register_t *)&rt);
1689 	*retval = rt;
1690 	return (error);
1691 }
1692 
1693 int
1694 netbsd32_fpathconf(l, v, retval)
1695 	struct lwp *l;
1696 	void *v;
1697 	register_t *retval;
1698 {
1699 	struct netbsd32_fpathconf_args /* {
1700 		syscallarg(int) fd;
1701 		syscallarg(int) name;
1702 	} */ *uap = v;
1703 	struct sys_fpathconf_args ua;
1704 	long rt;
1705 	int error;
1706 
1707 	NETBSD32TO64_UAP(fd);
1708 	NETBSD32TO64_UAP(name);
1709 	error = sys_fpathconf(l, &ua, (register_t *)&rt);
1710 	*retval = rt;
1711 	return (error);
1712 }
1713 
1714 int
1715 netbsd32_getrlimit(l, v, retval)
1716 	struct lwp *l;
1717 	void *v;
1718 	register_t *retval;
1719 {
1720 	struct netbsd32_getrlimit_args /* {
1721 		syscallarg(int) which;
1722 		syscallarg(netbsd32_rlimitp_t) rlp;
1723 	} */ *uap = v;
1724 	int which = SCARG(uap, which);
1725 
1726 	if ((u_int)which >= RLIM_NLIMITS)
1727 		return (EINVAL);
1728 	return (copyout(&l->l_proc->p_rlimit[which],
1729 	    (caddr_t)NETBSD32PTR64(SCARG(uap, rlp)), sizeof(struct rlimit)));
1730 }
1731 
1732 int
1733 netbsd32_setrlimit(l, v, retval)
1734 	struct lwp *l;
1735 	void *v;
1736 	register_t *retval;
1737 {
1738 	struct netbsd32_setrlimit_args /* {
1739 		syscallarg(int) which;
1740 		syscallarg(const netbsd32_rlimitp_t) rlp;
1741 	} */ *uap = v;
1742 		int which = SCARG(uap, which);
1743 	struct rlimit alim;
1744 	int error;
1745 
1746 	error = copyin((caddr_t)NETBSD32PTR64(SCARG(uap, rlp)), &alim,
1747 	    sizeof(struct rlimit));
1748 	if (error)
1749 		return (error);
1750 
1751 	switch (which) {
1752 	case RLIMIT_DATA:
1753 		if (LIMITCHECK(alim.rlim_cur, MAXDSIZ32))
1754 			alim.rlim_cur = MAXDSIZ32;
1755 		if (LIMITCHECK(alim.rlim_max, MAXDSIZ32))
1756 			alim.rlim_max = MAXDSIZ32;
1757 		break;
1758 
1759 	case RLIMIT_STACK:
1760 		if (LIMITCHECK(alim.rlim_cur, MAXSSIZ32))
1761 			alim.rlim_cur = MAXSSIZ32;
1762 		if (LIMITCHECK(alim.rlim_max, MAXSSIZ32))
1763 			alim.rlim_max = MAXSSIZ32;
1764 	default:
1765 		break;
1766 	}
1767 
1768 	return (dosetrlimit(l, l->l_proc, which, &alim));
1769 }
1770 
1771 int
1772 netbsd32_mmap(l, v, retval)
1773 	struct lwp *l;
1774 	void *v;
1775 	register_t *retval;
1776 {
1777 	struct netbsd32_mmap_args /* {
1778 		syscallarg(netbsd32_voidp) addr;
1779 		syscallarg(netbsd32_size_t) len;
1780 		syscallarg(int) prot;
1781 		syscallarg(int) flags;
1782 		syscallarg(int) fd;
1783 		syscallarg(netbsd32_long) pad;
1784 		syscallarg(off_t) pos;
1785 	} */ *uap = v;
1786 	struct sys_mmap_args ua;
1787 	int error;
1788 
1789 	NETBSD32TOP_UAP(addr, void);
1790 	NETBSD32TOX_UAP(len, size_t);
1791 	NETBSD32TO64_UAP(prot);
1792 	NETBSD32TO64_UAP(flags);
1793 	NETBSD32TO64_UAP(fd);
1794 	NETBSD32TOX_UAP(pad, long);
1795 	NETBSD32TOX_UAP(pos, off_t);
1796 	error = sys_mmap(l, &ua, retval);
1797 	if ((u_long)*retval > (u_long)UINT_MAX) {
1798 		printf("netbsd32_mmap: retval out of range: 0x%lx",
1799 		    (u_long)*retval);
1800 		/* Should try to recover and return an error here. */
1801 	}
1802 	return (error);
1803 }
1804 
1805 int
1806 netbsd32_lseek(l, v, retval)
1807 	struct lwp *l;
1808 	void *v;
1809 	register_t *retval;
1810 {
1811 	struct netbsd32_lseek_args /* {
1812 		syscallarg(int) fd;
1813 		syscallarg(int) pad;
1814 		syscallarg(off_t) offset;
1815 		syscallarg(int) whence;
1816 	} */ *uap = v;
1817 	struct sys_lseek_args ua;
1818 	int rv;
1819 
1820 	NETBSD32TO64_UAP(fd);
1821 	NETBSD32TO64_UAP(pad);
1822 	NETBSD32TO64_UAP(offset);
1823 	NETBSD32TO64_UAP(whence);
1824 	rv = sys_lseek(l, &ua, retval);
1825 #ifdef NETBSD32_OFF_T_RETURN
1826 	if (rv == 0)
1827 		NETBSD32_OFF_T_RETURN(retval);
1828 #endif
1829 	return rv;
1830 }
1831 
1832 int
1833 netbsd32_truncate(l, v, retval)
1834 	struct lwp *l;
1835 	void *v;
1836 	register_t *retval;
1837 {
1838 	struct netbsd32_truncate_args /* {
1839 		syscallarg(const netbsd32_charp) path;
1840 		syscallarg(int) pad;
1841 		syscallarg(off_t) length;
1842 	} */ *uap = v;
1843 	struct sys_truncate_args ua;
1844 
1845 	NETBSD32TOP_UAP(path, const char);
1846 	NETBSD32TO64_UAP(pad);
1847 	NETBSD32TO64_UAP(length);
1848 	return (sys_truncate(l, &ua, retval));
1849 }
1850 
1851 int
1852 netbsd32_ftruncate(l, v, retval)
1853 	struct lwp *l;
1854 	void *v;
1855 	register_t *retval;
1856 {
1857 	struct netbsd32_ftruncate_args /* {
1858 		syscallarg(int) fd;
1859 		syscallarg(int) pad;
1860 		syscallarg(off_t) length;
1861 	} */ *uap = v;
1862 	struct sys_ftruncate_args ua;
1863 
1864 	NETBSD32TO64_UAP(fd);
1865 	NETBSD32TO64_UAP(pad);
1866 	NETBSD32TO64_UAP(length);
1867 	return (sys_ftruncate(l, &ua, retval));
1868 }
1869 
1870 int
1871 netbsd32_mlock(l, v, retval)
1872 	struct lwp *l;
1873 	void *v;
1874 	register_t *retval;
1875 {
1876 	struct netbsd32_mlock_args /* {
1877 		syscallarg(const netbsd32_voidp) addr;
1878 		syscallarg(netbsd32_size_t) len;
1879 	} */ *uap = v;
1880 	struct sys_mlock_args ua;
1881 
1882 	NETBSD32TOP_UAP(addr, const void);
1883 	NETBSD32TO64_UAP(len);
1884 	return (sys_mlock(l, &ua, retval));
1885 }
1886 
1887 int
1888 netbsd32_munlock(l, v, retval)
1889 	struct lwp *l;
1890 	void *v;
1891 	register_t *retval;
1892 {
1893 	struct netbsd32_munlock_args /* {
1894 		syscallarg(const netbsd32_voidp) addr;
1895 		syscallarg(netbsd32_size_t) len;
1896 	} */ *uap = v;
1897 	struct sys_munlock_args ua;
1898 
1899 	NETBSD32TOP_UAP(addr, const void);
1900 	NETBSD32TO64_UAP(len);
1901 	return (sys_munlock(l, &ua, retval));
1902 }
1903 
1904 int
1905 netbsd32_undelete(l, v, retval)
1906 	struct lwp *l;
1907 	void *v;
1908 	register_t *retval;
1909 {
1910 	struct netbsd32_undelete_args /* {
1911 		syscallarg(const netbsd32_charp) path;
1912 	} */ *uap = v;
1913 	struct sys_undelete_args ua;
1914 
1915 	NETBSD32TOP_UAP(path, const char);
1916 	return (sys_undelete(l, &ua, retval));
1917 }
1918 
1919 int
1920 netbsd32_getpgid(l, v, retval)
1921 	struct lwp *l;
1922 	void *v;
1923 	register_t *retval;
1924 {
1925 	struct netbsd32_getpgid_args /* {
1926 		syscallarg(pid_t) pid;
1927 	} */ *uap = v;
1928 	struct sys_getpgid_args ua;
1929 
1930 	NETBSD32TO64_UAP(pid);
1931 	return (sys_getpgid(l, &ua, retval));
1932 }
1933 
1934 int
1935 netbsd32_reboot(l, v, retval)
1936 	struct lwp *l;
1937 	void *v;
1938 	register_t *retval;
1939 {
1940 	struct netbsd32_reboot_args /* {
1941 		syscallarg(int) opt;
1942 		syscallarg(netbsd32_charp) bootstr;
1943 	} */ *uap = v;
1944 	struct sys_reboot_args ua;
1945 
1946 	NETBSD32TO64_UAP(opt);
1947 	NETBSD32TOP_UAP(bootstr, char);
1948 	return (sys_reboot(l, &ua, retval));
1949 }
1950 
1951 #include <sys/poll.h>
1952 int
1953 netbsd32_poll(l, v, retval)
1954 	struct lwp *l;
1955 	void *v;
1956 	register_t *retval;
1957 {
1958 	struct netbsd32_poll_args /* {
1959 		syscallarg(netbsd32_pollfdp_t) fds;
1960 		syscallarg(u_int) nfds;
1961 		syscallarg(int) timeout;
1962 	} */ *uap = v;
1963 	struct sys_poll_args ua;
1964 
1965 	NETBSD32TOP_UAP(fds, struct pollfd);
1966 	NETBSD32TO64_UAP(nfds);
1967 	NETBSD32TO64_UAP(timeout);
1968 
1969 	return (sys_poll(l, &ua, retval));
1970 }
1971 
1972 int
1973 netbsd32_fdatasync(l, v, retval)
1974 	struct lwp *l;
1975 	void *v;
1976 	register_t *retval;
1977 {
1978 	struct netbsd32_fdatasync_args /* {
1979 		syscallarg(int) fd;
1980 	} */ *uap = v;
1981 	struct sys_fdatasync_args ua;
1982 
1983 	NETBSD32TO64_UAP(fd);
1984 	return (sys_fdatasync(l, &ua, retval));
1985 }
1986 
1987 int
1988 netbsd32___posix_rename(l, v, retval)
1989 	struct lwp *l;
1990 	void *v;
1991 	register_t *retval;
1992 {
1993 	struct netbsd32___posix_rename_args /* {
1994 		syscallarg(const netbsd32_charp) from;
1995 		syscallarg(const netbsd32_charp) to;
1996 	} */ *uap = v;
1997 	struct sys___posix_rename_args ua;
1998 
1999 	NETBSD32TOP_UAP(from, const char);
2000 	NETBSD32TOP_UAP(to, const char);
2001 	return (sys___posix_rename(l, &ua, retval));
2002 }
2003 
2004 int
2005 netbsd32_swapctl(l, v, retval)
2006 	struct lwp *l;
2007 	void *v;
2008 	register_t *retval;
2009 {
2010 	struct netbsd32_swapctl_args /* {
2011 		syscallarg(int) cmd;
2012 		syscallarg(const netbsd32_voidp) arg;
2013 		syscallarg(int) misc;
2014 	} */ *uap = v;
2015 	struct sys_swapctl_args ua;
2016 
2017 	NETBSD32TO64_UAP(cmd);
2018 	NETBSD32TOP_UAP(arg, void);
2019 	NETBSD32TO64_UAP(misc);
2020 	return (sys_swapctl(l, &ua, retval));
2021 }
2022 
2023 int
2024 netbsd32_minherit(l, v, retval)
2025 	struct lwp *l;
2026 	void *v;
2027 	register_t *retval;
2028 {
2029 	struct netbsd32_minherit_args /* {
2030 		syscallarg(netbsd32_voidp) addr;
2031 		syscallarg(netbsd32_size_t) len;
2032 		syscallarg(int) inherit;
2033 	} */ *uap = v;
2034 	struct sys_minherit_args ua;
2035 
2036 	NETBSD32TOP_UAP(addr, void);
2037 	NETBSD32TOX_UAP(len, size_t);
2038 	NETBSD32TO64_UAP(inherit);
2039 	return (sys_minherit(l, &ua, retval));
2040 }
2041 
2042 int
2043 netbsd32_lchmod(l, v, retval)
2044 	struct lwp *l;
2045 	void *v;
2046 	register_t *retval;
2047 {
2048 	struct netbsd32_lchmod_args /* {
2049 		syscallarg(const netbsd32_charp) path;
2050 		syscallarg(mode_t) mode;
2051 	} */ *uap = v;
2052 	struct sys_lchmod_args ua;
2053 
2054 	NETBSD32TOP_UAP(path, const char);
2055 	NETBSD32TO64_UAP(mode);
2056 	return (sys_lchmod(l, &ua, retval));
2057 }
2058 
2059 int
2060 netbsd32_lchown(l, v, retval)
2061 	struct lwp *l;
2062 	void *v;
2063 	register_t *retval;
2064 {
2065 	struct netbsd32_lchown_args /* {
2066 		syscallarg(const netbsd32_charp) path;
2067 		syscallarg(uid_t) uid;
2068 		syscallarg(gid_t) gid;
2069 	} */ *uap = v;
2070 	struct sys_lchown_args ua;
2071 
2072 	NETBSD32TOP_UAP(path, const char);
2073 	NETBSD32TO64_UAP(uid);
2074 	NETBSD32TO64_UAP(gid);
2075 	return (sys_lchown(l, &ua, retval));
2076 }
2077 
2078 int
2079 netbsd32___msync13(l, v, retval)
2080 	struct lwp *l;
2081 	void *v;
2082 	register_t *retval;
2083 {
2084 	struct netbsd32___msync13_args /* {
2085 		syscallarg(netbsd32_voidp) addr;
2086 		syscallarg(netbsd32_size_t) len;
2087 		syscallarg(int) flags;
2088 	} */ *uap = v;
2089 	struct sys___msync13_args ua;
2090 
2091 	NETBSD32TOP_UAP(addr, void);
2092 	NETBSD32TOX_UAP(len, size_t);
2093 	NETBSD32TO64_UAP(flags);
2094 	return (sys___msync13(l, &ua, retval));
2095 }
2096 
2097 int
2098 netbsd32___posix_chown(l, v, retval)
2099 	struct lwp *l;
2100 	void *v;
2101 	register_t *retval;
2102 {
2103 	struct netbsd32___posix_chown_args /* {
2104 		syscallarg(const netbsd32_charp) path;
2105 		syscallarg(uid_t) uid;
2106 		syscallarg(gid_t) gid;
2107 	} */ *uap = v;
2108 	struct sys___posix_chown_args ua;
2109 
2110 	NETBSD32TOP_UAP(path, const char);
2111 	NETBSD32TO64_UAP(uid);
2112 	NETBSD32TO64_UAP(gid);
2113 	return (sys___posix_chown(l, &ua, retval));
2114 }
2115 
2116 int
2117 netbsd32___posix_fchown(l, v, retval)
2118 	struct lwp *l;
2119 	void *v;
2120 	register_t *retval;
2121 {
2122 	struct netbsd32___posix_fchown_args /* {
2123 		syscallarg(int) fd;
2124 		syscallarg(uid_t) uid;
2125 		syscallarg(gid_t) gid;
2126 	} */ *uap = v;
2127 	struct sys___posix_fchown_args ua;
2128 
2129 	NETBSD32TO64_UAP(fd);
2130 	NETBSD32TO64_UAP(uid);
2131 	NETBSD32TO64_UAP(gid);
2132 	return (sys___posix_fchown(l, &ua, retval));
2133 }
2134 
2135 int
2136 netbsd32___posix_lchown(l, v, retval)
2137 	struct lwp *l;
2138 	void *v;
2139 	register_t *retval;
2140 {
2141 	struct netbsd32___posix_lchown_args /* {
2142 		syscallarg(const netbsd32_charp) path;
2143 		syscallarg(uid_t) uid;
2144 		syscallarg(gid_t) gid;
2145 	} */ *uap = v;
2146 	struct sys___posix_lchown_args ua;
2147 
2148 	NETBSD32TOP_UAP(path, const char);
2149 	NETBSD32TO64_UAP(uid);
2150 	NETBSD32TO64_UAP(gid);
2151 	return (sys___posix_lchown(l, &ua, retval));
2152 }
2153 
2154 int
2155 netbsd32_getsid(l, v, retval)
2156 	struct lwp *l;
2157 	void *v;
2158 	register_t *retval;
2159 {
2160 	struct netbsd32_getsid_args /* {
2161 		syscallarg(pid_t) pid;
2162 	} */ *uap = v;
2163 	struct sys_getsid_args ua;
2164 
2165 	NETBSD32TO64_UAP(pid);
2166 	return (sys_getsid(l, &ua, retval));
2167 }
2168 
2169 #ifdef KTRACE
2170 int
2171 netbsd32_fktrace(l, v, retval)
2172 	struct lwp *l;
2173 	void *v;
2174 	register_t *retval;
2175 {
2176 	struct netbsd32_fktrace_args /* {
2177 		syscallarg(const int) fd;
2178 		syscallarg(int) ops;
2179 		syscallarg(int) facs;
2180 		syscallarg(int) pid;
2181 	} */ *uap = v;
2182 #if 0
2183 	struct sys_fktrace_args ua;
2184 #else
2185 	/* XXXX */
2186 	struct sys_fktrace_noconst_args {
2187 		syscallarg(int) fd;
2188 		syscallarg(int) ops;
2189 		syscallarg(int) facs;
2190 		syscallarg(int) pid;
2191 	} ua;
2192 #endif
2193 
2194 	NETBSD32TOX_UAP(fd, int);
2195 	NETBSD32TO64_UAP(ops);
2196 	NETBSD32TO64_UAP(facs);
2197 	NETBSD32TO64_UAP(pid);
2198 	return (sys_fktrace(l, &ua, retval));
2199 }
2200 #endif /* KTRACE */
2201 
2202 int netbsd32___sigpending14(l, v, retval)
2203 	struct lwp *l;
2204 	void   *v;
2205 	register_t *retval;
2206 {
2207 	struct netbsd32___sigpending14_args /* {
2208 		syscallarg(sigset_t *) set;
2209 	} */ *uap = v;
2210 	struct sys___sigpending14_args ua;
2211 
2212 	NETBSD32TOP_UAP(set, sigset_t);
2213 	return (sys___sigpending14(l, &ua, retval));
2214 }
2215 
2216 int netbsd32___sigprocmask14(l, v, retval)
2217 	struct lwp *l;
2218 	void   *v;
2219 	register_t *retval;
2220 {
2221 	struct netbsd32___sigprocmask14_args /* {
2222 		syscallarg(int) how;
2223 		syscallarg(const sigset_t *) set;
2224 		syscallarg(sigset_t *) oset;
2225 	} */ *uap = v;
2226 	struct sys___sigprocmask14_args ua;
2227 
2228 	NETBSD32TO64_UAP(how);
2229 	NETBSD32TOP_UAP(set, sigset_t);
2230 	NETBSD32TOP_UAP(oset, sigset_t);
2231 	return (sys___sigprocmask14(l, &ua, retval));
2232 }
2233 
2234 int netbsd32___sigsuspend14(l, v, retval)
2235 	struct lwp *l;
2236 	void   *v;
2237 	register_t *retval;
2238 {
2239 	struct netbsd32___sigsuspend14_args /* {
2240 		syscallarg(const sigset_t *) set;
2241 	} */ *uap = v;
2242 	struct sys___sigsuspend14_args ua;
2243 
2244 	NETBSD32TOP_UAP(set, sigset_t);
2245 	return (sys___sigsuspend14(l, &ua, retval));
2246 };
2247 
2248 int netbsd32_fchroot(l, v, retval)
2249 	struct lwp *l;
2250 	void *v;
2251 	register_t *retval;
2252 {
2253 	struct netbsd32_fchroot_args /* {
2254 		syscallarg(int) fd;
2255 	} */ *uap = v;
2256 	struct sys_fchroot_args ua;
2257 
2258 	NETBSD32TO64_UAP(fd);
2259 	return (sys_fchroot(l, &ua, retval));
2260 }
2261 
2262 /*
2263  * Open a file given a file handle.
2264  *
2265  * Check permissions, allocate an open file structure,
2266  * and call the device open routine if any.
2267  */
2268 int
2269 netbsd32___fhopen40(l, v, retval)
2270 	struct lwp *l;
2271 	void *v;
2272 	register_t *retval;
2273 {
2274 	struct netbsd32___fhopen40_args /* {
2275 		syscallarg(const netbsd32_pointer_t *) fhp;
2276 		syscallarg(netbsd32_size_t) fh_size;
2277 		syscallarg(int) flags;
2278 	} */ *uap = v;
2279 	struct sys___fhopen40_args ua;
2280 
2281 	NETBSD32TOP_UAP(fhp, fhandle_t);
2282 	NETBSD32TO64_UAP(fh_size);
2283 	NETBSD32TO64_UAP(flags);
2284 	return (sys___fhopen40(l, &ua, retval));
2285 }
2286 
2287 /* virtual memory syscalls */
2288 int
2289 netbsd32_ovadvise(l, v, retval)
2290 	struct lwp *l;
2291 	void *v;
2292 	register_t *retval;
2293 {
2294 	struct netbsd32_ovadvise_args /* {
2295 		syscallarg(int) anom;
2296 	} */ *uap = v;
2297 	struct sys_ovadvise_args ua;
2298 
2299 	NETBSD32TO64_UAP(anom);
2300 	return (sys_ovadvise(l, &ua, retval));
2301 }
2302 
2303 void
2304 netbsd32_adjust_limits(struct proc *p)
2305 {
2306 	static const struct {
2307 		int id;
2308 		rlim_t lim;
2309 	} lm[] = {
2310 		{ RLIMIT_DATA,	MAXDSIZ32 },
2311 		{ RLIMIT_STACK, MAXSSIZ32 },
2312 	};
2313 	struct rlimit val[__arraycount(lm)];
2314 	size_t i;
2315 	int needcopy = 0;
2316 
2317 	mutex_enter(&p->p_mutex);
2318 	for (i = 0; i < __arraycount(val); i++) {
2319 		val[i] = p->p_rlimit[lm[i].id];
2320 		if (LIMITCHECK(val[i].rlim_cur, lm[i].lim)) {
2321 			val[i].rlim_cur = lm[i].lim;
2322 			needcopy++;
2323 		}
2324 		if (LIMITCHECK(val[i].rlim_max, lm[i].lim)) {
2325 			val[i].rlim_max = lm[i].lim;
2326 			needcopy++;
2327 		}
2328 	}
2329 
2330 	if (needcopy == 0) {
2331 		mutex_exit(&p->p_mutex);
2332 		return;
2333 	}
2334 
2335 	if (p->p_limit->p_refcnt > 1 &&
2336 	    (p->p_limit->p_lflags & PL_SHAREMOD) == 0) {
2337 		struct plimit *oldplim;
2338 		oldplim = p->p_limit;
2339 		p->p_limit = limcopy(p);
2340 		limfree(oldplim);
2341 	}
2342 
2343 	for (i = 0; i < __arraycount(val); i++)
2344 		p->p_rlimit[lm[i].id] = val[i];
2345 
2346 	mutex_exit(&p->p_mutex);
2347 }
2348 
2349 int
2350 netbsd32_uuidgen(struct lwp *l, void *v, register_t *retval)
2351 {
2352 	struct netbsd32_uuidgen_args /* {
2353 		syscallarg(netbsd32_uuidp_t) store;
2354 		syscallarg(int) count;
2355 	} */ *uap = v;
2356 	struct sys_uuidgen_args ua;
2357 
2358 	NETBSD32TOP_UAP(store, struct uuid);
2359 	NETBSD32TO64_UAP(count);
2360 	return (sys_uuidgen(l, &ua, retval));
2361 }
2362 
2363 int
2364 netbsd32_extattrctl(struct lwp *l, void *v, register_t *retval)
2365 {
2366 	struct netbsd32_extattrctl_args /* {
2367 		syscallarg(const netbsd32_charp) path;
2368 		syscallarg(int) cmd;
2369 		syscallarg(const netbsd32_charp) filename;
2370 		syscallarg(int) attrnamespace;
2371 		syscallarg(const netbsd32_charp) attrname;
2372 	} */ *uap = v;
2373 	struct sys_extattrctl_args ua;
2374 
2375 	NETBSD32TOP_UAP(path, const char);
2376 	NETBSD32TO64_UAP(cmd);
2377 	NETBSD32TOP_UAP(filename, const char);
2378 	NETBSD32TO64_UAP(attrnamespace);
2379 	NETBSD32TOP_UAP(attrname, const char);
2380 	return sys_extattrctl(l, &ua, retval);
2381 }
2382 
2383 int
2384 netbsd32_extattr_set_fd(struct lwp *l, void *v, register_t *retval)
2385 {
2386 	struct netbsd32_extattr_set_fd_args /* {
2387 		syscallarg(int) fd;
2388 		syscallarg(int) attrnamespace;
2389 		syscallarg(const netbsd32_charp) attrname;
2390 		syscallarg(const netbsd32_voidp) data;
2391 		syscallarg(netbsd32_size_t) nbytes;
2392 	} */ *uap = v;
2393 	struct sys_extattr_set_fd_args ua;
2394 
2395 	NETBSD32TO64_UAP(fd);
2396 	NETBSD32TO64_UAP(attrnamespace);
2397 	NETBSD32TOP_UAP(attrname, const char);
2398 	NETBSD32TOP_UAP(data, const void);
2399 	NETBSD32TOX_UAP(nbytes, size_t);
2400 	return sys_extattr_set_fd(l, &ua, retval);
2401 }
2402 
2403 int
2404 netbsd32_extattr_set_file(struct lwp *l, void *v, register_t *retval)
2405 {
2406 	struct netbsd32_extattr_set_file_args /* {
2407 		syscallarg(const netbsd32_charp) path;
2408 		syscallarg(int) attrnamespace;
2409 		syscallarg(const netbsd32_charp) attrname;
2410 		syscallarg(const netbsd32_voidp) data;
2411 		syscallarg(netbsd32_size_t) nbytes;
2412 	} */ *uap = v;
2413 	struct sys_extattr_set_file_args ua;
2414 
2415 	NETBSD32TOP_UAP(path, const char);
2416 	NETBSD32TO64_UAP(attrnamespace);
2417 	NETBSD32TOP_UAP(attrname, const char);
2418 	NETBSD32TOP_UAP(data, const void);
2419 	NETBSD32TOX_UAP(nbytes, size_t);
2420 	return sys_extattr_set_file(l, &ua, retval);
2421 }
2422 
2423 int
2424 netbsd32_extattr_set_link(struct lwp *l, void *v, register_t *retval)
2425 {
2426 	struct netbsd32_extattr_set_link_args /* {
2427 		syscallarg(const netbsd32_charp) path;
2428 		syscallarg(int) attrnamespace;
2429 		syscallarg(const netbsd32_charp) attrname;
2430 		syscallarg(const netbsd32_voidp) data;
2431 		syscallarg(netbsd32_size_t) nbytes;
2432 	} */ *uap = v;
2433 	struct sys_extattr_set_link_args ua;
2434 
2435 	NETBSD32TOP_UAP(path, const char);
2436 	NETBSD32TO64_UAP(attrnamespace);
2437 	NETBSD32TOP_UAP(attrname, const char);
2438 	NETBSD32TOP_UAP(data, const void);
2439 	NETBSD32TOX_UAP(nbytes, size_t);
2440 	return sys_extattr_set_link(l, &ua, retval);
2441 }
2442 
2443 int
2444 netbsd32_extattr_get_fd(struct lwp *l, void *v, register_t *retval)
2445 {
2446 	struct netbsd32_extattr_get_fd_args /* {
2447 		syscallarg(int) fd;
2448 		syscallarg(int) attrnamespace;
2449 		syscallarg(const netbsd32_charp) attrname;
2450 		syscallarg(netbsd32_voidp) data;
2451 		syscallarg(netbsd32_size_t) nbytes;
2452 	} */ *uap = v;
2453 	struct sys_extattr_get_fd_args ua;
2454 
2455 	NETBSD32TO64_UAP(fd);
2456 	NETBSD32TO64_UAP(attrnamespace);
2457 	NETBSD32TOP_UAP(attrname, const char);
2458 	NETBSD32TOP_UAP(data, void);
2459 	NETBSD32TOX_UAP(nbytes, size_t);
2460 	return sys_extattr_get_fd(l, &ua, retval);
2461 }
2462 
2463 int
2464 netbsd32_extattr_get_file(struct lwp *l, void *v, register_t *retval)
2465 {
2466 	struct netbsd32_extattr_get_file_args /* {
2467 		syscallarg(const netbsd32_charp) path;
2468 		syscallarg(int) attrnamespace;
2469 		syscallarg(const netbsd32_charp) attrname;
2470 		syscallarg(netbsd32_voidp) data;
2471 		syscallarg(netbsd32_size_t) nbytes;
2472 	} */ *uap = v;
2473 	struct sys_extattr_get_file_args ua;
2474 
2475 	NETBSD32TOP_UAP(path, const char);
2476 	NETBSD32TO64_UAP(attrnamespace);
2477 	NETBSD32TOP_UAP(attrname, const char);
2478 	NETBSD32TOP_UAP(data, void);
2479 	NETBSD32TOX_UAP(nbytes, size_t);
2480 	return sys_extattr_get_file(l, &ua, retval);
2481 }
2482 
2483 int
2484 netbsd32_extattr_get_link(struct lwp *l, void *v, register_t *retval)
2485 {
2486 	struct netbsd32_extattr_get_link_args /* {
2487 		syscallarg(const netbsd32_charp) path;
2488 		syscallarg(int) attrnamespace;
2489 		syscallarg(const netbsd32_charp) attrname;
2490 		syscallarg(netbsd32_voidp) data;
2491 		syscallarg(netbsd32_size_t) nbytes;
2492 	} */ *uap = v;
2493 	struct sys_extattr_get_link_args ua;
2494 
2495 	NETBSD32TOP_UAP(path, const char);
2496 	NETBSD32TO64_UAP(attrnamespace);
2497 	NETBSD32TOP_UAP(attrname, const char);
2498 	NETBSD32TOP_UAP(data, void);
2499 	NETBSD32TOX_UAP(nbytes, size_t);
2500 	return sys_extattr_get_link(l, &ua, retval);
2501 }
2502 
2503 int
2504 netbsd32_extattr_delete_fd(struct lwp *l, void *v, register_t *retval)
2505 {
2506 	struct netbsd32_extattr_delete_fd_args /* {
2507 		syscallarg(int) fd;
2508 		syscallarg(int) attrnamespace;
2509 		syscallarg(const netbsd32_charp) attrname;
2510 	} */ *uap = v;
2511 	struct sys_extattr_delete_fd_args ua;
2512 
2513 	NETBSD32TO64_UAP(fd);
2514 	NETBSD32TO64_UAP(attrnamespace);
2515 	NETBSD32TOP_UAP(attrname, const char);
2516 	return sys_extattr_delete_fd(l, &ua, retval);
2517 }
2518 
2519 int
2520 netbsd32_extattr_delete_file(struct lwp *l, void *v, register_t *retval)
2521 {
2522 	struct netbsd32_extattr_delete_file_args /* {
2523 		syscallarg(const netbsd32_charp) path;
2524 		syscallarg(int) attrnamespace;
2525 		syscallarg(const netbsd32_charp) attrname;
2526 	} */ *uap = v;
2527 	struct sys_extattr_delete_file_args ua;
2528 
2529 	NETBSD32TOP_UAP(path, const char);
2530 	NETBSD32TO64_UAP(attrnamespace);
2531 	NETBSD32TOP_UAP(attrname, const char);
2532 	return sys_extattr_delete_file(l, &ua, retval);
2533 }
2534 
2535 int
2536 netbsd32_extattr_delete_link(struct lwp *l, void *v, register_t *retval)
2537 {
2538 	struct netbsd32_extattr_delete_link_args /* {
2539 		syscallarg(const netbsd32_charp) path;
2540 		syscallarg(int) attrnamespace;
2541 		syscallarg(const netbsd32_charp) attrname;
2542 	} */ *uap = v;
2543 	struct sys_extattr_delete_link_args ua;
2544 
2545 	NETBSD32TOP_UAP(path, const char);
2546 	NETBSD32TO64_UAP(attrnamespace);
2547 	NETBSD32TOP_UAP(attrname, const char);
2548 	return sys_extattr_delete_link(l, &ua, retval);
2549 }
2550 
2551 int
2552 netbsd32_extattr_list_fd(struct lwp *l, void *v, register_t *retval)
2553 {
2554 	struct netbsd32_extattr_list_fd_args /* {
2555 		syscallarg(int) fd;
2556 		syscallarg(int) attrnamespace;
2557 		syscallarg(netbsd32_voidp) data;
2558 		syscallarg(netbsd32_size_t) nbytes;
2559 	} */ *uap = v;
2560 	struct sys_extattr_list_fd_args ua;
2561 
2562 	NETBSD32TO64_UAP(fd);
2563 	NETBSD32TO64_UAP(attrnamespace);
2564 	NETBSD32TOP_UAP(data, void);
2565 	NETBSD32TOX_UAP(nbytes, size_t);
2566 	return sys_extattr_list_fd(l, &ua, retval);
2567 }
2568 
2569 int
2570 netbsd32_extattr_list_file(struct lwp *l, void *v, register_t *retval)
2571 {
2572 	struct netbsd32_extattr_list_file_args /* {
2573 		syscallarg(const netbsd32_charp) path;
2574 		syscallarg(int) attrnamespace;
2575 		syscallarg(netbsd32_voidp) data;
2576 		syscallarg(netbsd32_size_t) nbytes;
2577 	} */ *uap = v;
2578 	struct sys_extattr_list_file_args ua;
2579 
2580 	NETBSD32TOP_UAP(path, const char);
2581 	NETBSD32TO64_UAP(attrnamespace);
2582 	NETBSD32TOP_UAP(data, void);
2583 	NETBSD32TOX_UAP(nbytes, size_t);
2584 	return sys_extattr_list_file(l, &ua, retval);
2585 }
2586 
2587 int
2588 netbsd32_extattr_list_link(struct lwp *l, void *v, register_t *retval)
2589 {
2590 	struct netbsd32_extattr_list_link_args /* {
2591 		syscallarg(const netbsd32_charp) path;
2592 		syscallarg(int) attrnamespace;
2593 		syscallarg(netbsd32_voidp) data;
2594 		syscallarg(netbsd32_size_t) nbytes;
2595 	} */ *uap = v;
2596 	struct sys_extattr_list_link_args ua;
2597 
2598 	NETBSD32TOP_UAP(path, const char);
2599 	NETBSD32TO64_UAP(attrnamespace);
2600 	NETBSD32TOP_UAP(data, void);
2601 	NETBSD32TOX_UAP(nbytes, size_t);
2602 	return sys_extattr_list_link(l, &ua, retval);
2603 }
2604 
2605 int
2606 netbsd32_mlockall(l, v, retval)
2607 	struct lwp *l;
2608 	void *v;
2609 	register_t *retval;
2610 {
2611 	struct netbsd32_mlockall_args /* {
2612 		syscallarg(int) flags;
2613 	} */ *uap = v;
2614 	struct sys_mlockall_args ua;
2615 
2616 	NETBSD32TO64_UAP(flags);
2617 	return (sys_mlockall(l, &ua, retval));
2618 }
2619 
2620 int
2621 netbsd32___clone(struct lwp *l, void *v, register_t *retval)
2622 {
2623 	struct netbsd32___clone_args /*  {
2624 		syscallarg(int) flags;
2625 		syscallarg(netbsd32_voidp) stack;
2626 	} */ *uap = v;
2627 	struct sys___clone_args ua;
2628 
2629 	NETBSD32TO64_UAP(flags);
2630 	NETBSD32TOP_UAP(stack, void);
2631 	return sys___clone(l, &ua, retval);
2632 }
2633 
2634 int
2635 netbsd32_fsync_range(struct lwp *l, void *v, register_t *retval)
2636 {
2637 	struct netbsd32_fsync_range_args /* {
2638 		syscallarg(int) fd;
2639 		syscallarg(int) flags;
2640 		syscallarg(off_t) start;
2641 		syscallarg(off_t) length;
2642 	} */ *uap = v;
2643 	struct sys_fsync_range_args ua;
2644 
2645 	NETBSD32TO64_UAP(fd);
2646 	NETBSD32TO64_UAP(flags);
2647 	NETBSD32TO64_UAP(start);
2648 	NETBSD32TO64_UAP(length);
2649 	return (sys_fsync_range(l, &ua, retval));
2650 }
2651 
2652 int
2653 netbsd32_rasctl(struct lwp *l, void *v, register_t *retval)
2654 {
2655 	struct netbsd32_rasctl_args /* {
2656 		syscallarg(netbsd32_caddr_t) addr;
2657 		syscallarg(netbsd32_size_t) len;
2658 		syscallarg(int) op;
2659 	} */ *uap = v;
2660 	struct sys_rasctl_args ua;
2661 
2662 	NETBSD32TOX64_UAP(addr, caddr_t);
2663 	NETBSD32TOX_UAP(len, size_t);
2664 	NETBSD32TO64_UAP(op);
2665 	return sys_rasctl(l, &ua, retval);
2666 }
2667 
2668 int
2669 netbsd32_setxattr(struct lwp *l, void *v, register_t *retval)
2670 {
2671 	struct netbsd32_setxattr_args /* {
2672 		syscallarg(const netbsd32_charp) path;
2673 		syscallarg(const netbsd32_charp) name;
2674 		syscallarg(netbsd32_voidp) value;
2675 		syscallarg(netbsd32_size_t) size;
2676 		syscallarg(int) flags;
2677 	} */ *uap = v;
2678 	struct sys_setxattr_args ua;
2679 	NETBSD32TOP_UAP(path, const char);
2680 	NETBSD32TOP_UAP(name, const char);
2681 	NETBSD32TOP_UAP(value, void);
2682 	NETBSD32TOX_UAP(size, size_t);
2683 	NETBSD32TO64_UAP(flags);
2684 	return sys_setxattr(l, &ua, retval);
2685 }
2686 
2687 int
2688 netbsd32_lsetxattr(struct lwp *l, void *v, register_t *retval)
2689 {
2690 	struct netbsd32_lsetxattr_args /* {
2691 		syscallarg(const netbsd32_charp) path;
2692 		syscallarg(const netbsd32_charp) name;
2693 		syscallarg(netbsd32_voidp) value;
2694 		syscallarg(netbsd32_size_t) size;
2695 		syscallarg(int) flags;
2696 	} */ *uap = v;
2697 	struct sys_lsetxattr_args ua;
2698 	NETBSD32TOP_UAP(path, const char);
2699 	NETBSD32TOP_UAP(name, const char);
2700 	NETBSD32TOP_UAP(value, void);
2701 	NETBSD32TOX_UAP(size, size_t);
2702 	NETBSD32TO64_UAP(flags);
2703 	return sys_lsetxattr(l, &ua, retval);
2704 }
2705 
2706 int
2707 netbsd32_fsetxattr(struct lwp *l, void *v, register_t *retval)
2708 {
2709 	struct netbsd32_fsetxattr_args /* {
2710 		syscallarg(int) fd;
2711 		syscallarg(const netbsd32_charp) name;
2712 		syscallarg(netbsd32_voidp) value;
2713 		syscallarg(netbsd32_size_t) size;
2714 		syscallarg(int) flags;
2715 	} */ *uap = v;
2716 	struct sys_fsetxattr_args ua;
2717 	NETBSD32TO64_UAP(fd);
2718 	NETBSD32TOP_UAP(name, const char);
2719 	NETBSD32TOP_UAP(value, void);
2720 	NETBSD32TOX_UAP(size, size_t);
2721 	NETBSD32TO64_UAP(flags);
2722 	return sys_fsetxattr(l, &ua, retval);
2723 }
2724 
2725 int
2726 netbsd32_getxattr(struct lwp *l, void *v, register_t *retval)
2727 {
2728 	struct netbsd32_getxattr_args /* {
2729 		syscallarg(const netbsd32_charp) path;
2730 		syscallarg(const netbsd32_charp) name;
2731 		syscallarg(netbsd32_voidp) value;
2732 		syscallarg(netbsd32_size_t) size;
2733 	} */ *uap = v;
2734 	struct sys_getxattr_args ua;
2735 	NETBSD32TOP_UAP(path, const char);
2736 	NETBSD32TOP_UAP(name, const char);
2737 	NETBSD32TOP_UAP(value, void);
2738 	NETBSD32TOX_UAP(size, size_t);
2739 	return sys_getxattr(l, &ua, retval);
2740 }
2741 
2742 int
2743 netbsd32_lgetxattr(struct lwp *l, void *v, register_t *retval)
2744 {
2745 	struct netbsd32_lgetxattr_args /* {
2746 		syscallarg(const netbsd32_charp) path;
2747 		syscallarg(const netbsd32_charp) name;
2748 		syscallarg(netbsd32_voidp) value;
2749 		syscallarg(netbsd32_size_t) size;
2750 	} */ *uap = v;
2751 	struct sys_lgetxattr_args ua;
2752 	NETBSD32TOP_UAP(path, const char);
2753 	NETBSD32TOP_UAP(name, const char);
2754 	NETBSD32TOP_UAP(value, void);
2755 	NETBSD32TOX_UAP(size, size_t);
2756 	return sys_lgetxattr(l, &ua, retval);
2757 }
2758 
2759 int
2760 netbsd32_fgetxattr(struct lwp *l, void *v, register_t *retval)
2761 {
2762 	struct netbsd32_fgetxattr_args /* {
2763 		syscallarg(int) fd;
2764 		syscallarg(const netbsd32_charp) name;
2765 		syscallarg(netbsd32_voidp) value;
2766 		syscallarg(netbsd32_size_t) size;
2767 	} */ *uap = v;
2768 	struct sys_fgetxattr_args ua;
2769 	NETBSD32TO64_UAP(fd);
2770 	NETBSD32TOP_UAP(name, const char);
2771 	NETBSD32TOP_UAP(value, void);
2772 	NETBSD32TOX_UAP(size, size_t);
2773 	return sys_fgetxattr(l, &ua, retval);
2774 }
2775 
2776 int
2777 netbsd32_listxattr(struct lwp *l, void *v, register_t *retval)
2778 {
2779 	struct netbsd32_listxattr_args /* {
2780 		syscallarg(const netbsd32_charp) path;
2781 		syscallarg(netbsd32_charp) list;
2782 		syscallarg(netbsd32_size_t) size;
2783 	} */ *uap = v;
2784 	struct sys_listxattr_args ua;
2785 	NETBSD32TOP_UAP(path, const char);
2786 	NETBSD32TOP_UAP(list, char);
2787 	NETBSD32TOX_UAP(size, size_t);
2788 	return sys_listxattr(l, &ua, retval);
2789 }
2790 
2791 int
2792 netbsd32_llistxattr(struct lwp *l, void *v, register_t *retval)
2793 {
2794 	struct netbsd32_llistxattr_args /* {
2795 		syscallarg(const netbsd32_charp) path;
2796 		syscallarg(netbsd32_charp) list;
2797 		syscallarg(netbsd32_size_t) size;
2798 	} */ *uap = v;
2799 	struct sys_llistxattr_args ua;
2800 	NETBSD32TOP_UAP(path, const char);
2801 	NETBSD32TOP_UAP(list, char);
2802 	NETBSD32TOX_UAP(size, size_t);
2803 	return sys_llistxattr(l, &ua, retval);
2804 }
2805 
2806 int
2807 netbsd32_flistxattr(struct lwp *l, void *v, register_t *retval)
2808 {
2809 	struct netbsd32_flistxattr_args /* {
2810 		syscallarg(int) fd;
2811 		syscallarg(netbsd32_charp) list;
2812 		syscallarg(netbsd32_size_t) size;
2813 	} */ *uap = v;
2814 	struct sys_flistxattr_args ua;
2815 	NETBSD32TO64_UAP(fd);
2816 	NETBSD32TOP_UAP(list, char);
2817 	NETBSD32TOX_UAP(size, size_t);
2818 	return sys_flistxattr(l, &ua, retval);
2819 }
2820 
2821 int
2822 netbsd32_removexattr(struct lwp *l, void *v, register_t *retval)
2823 {
2824 	struct netbsd32_removexattr_args /* {
2825 		syscallarg(const netbsd32_charp) path;
2826 		syscallarg(const netbsd32_charp) name;
2827 	} */ *uap = v;
2828 	struct sys_removexattr_args ua;
2829 	NETBSD32TOP_UAP(path, const char);
2830 	NETBSD32TOP_UAP(name, const char);
2831 	return sys_removexattr(l, &ua, retval);
2832 }
2833 
2834 int
2835 netbsd32_lremovexattr(struct lwp *l, void *v, register_t *retval)
2836 {
2837 	struct netbsd32_lremovexattr_args /* {
2838 		syscallarg(const netbsd32_charp) path;
2839 		syscallarg(const netbsd32_charp) name;
2840 	} */ *uap = v;
2841 	struct sys_lremovexattr_args ua;
2842 	NETBSD32TOP_UAP(path, const char);
2843 	NETBSD32TOP_UAP(name, const char);
2844 	return sys_lremovexattr(l, &ua, retval);
2845 }
2846 
2847 int
2848 netbsd32_fremovexattr(struct lwp *l, void *v, register_t *retval)
2849 {
2850 	struct netbsd32_fremovexattr_args /* {
2851 		syscallarg(int) fd;
2852 		syscallarg(const netbsd32_charp) name;
2853 	} */ *uap = v;
2854 	struct sys_fremovexattr_args ua;
2855 	NETBSD32TO64_UAP(fd);
2856 	NETBSD32TOP_UAP(name, const char);
2857 	return sys_fremovexattr(l, &ua, retval);
2858 }
2859