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