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