Home | History | Annotate | Line # | Download | only in netbsd32
netbsd32_netbsd.c revision 1.100.4.2
      1 /*	$NetBSD: netbsd32_netbsd.c,v 1.100.4.2 2006/03/14 02:52: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.2 2006/03/14 02:52: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 	int i;
    960 
    961 	ngrp = SCARG(uap, gidsetsize);
    962 	if (ngrp == 0) {
    963 		*retval = kauth_cred_ngroups(pc);
    964 		return (0);
    965 	}
    966 	if (ngrp < kauth_cred_ngroups(pc))
    967 		return (EINVAL);
    968 	ngrp = kauth_cred_ngroups(pc);
    969 	/* Should convert gid_t to netbsd32_gid_t, but they're the same */
    970 	grbuf = malloc(ngrp * sizeof(*grbuf), M_TEMP, M_WAITOK);
    971 	kauth_cred_getgroups(pc, grbuf, ngrp);
    972 	error = copyout(grbuf, (caddr_t)NETBSD32PTR64(SCARG(uap, gidset)),
    973 			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_socket(l, v, retval)
   1088 	struct lwp *l;
   1089 	void *v;
   1090 	register_t *retval;
   1091 {
   1092 	struct netbsd32_socket_args /* {
   1093 		syscallarg(int) domain;
   1094 		syscallarg(int) type;
   1095 		syscallarg(int) protocol;
   1096 	} */ *uap = v;
   1097 	struct sys_socket_args ua;
   1098 
   1099 	NETBSD32TO64_UAP(domain);
   1100 	NETBSD32TO64_UAP(type);
   1101 	NETBSD32TO64_UAP(protocol);
   1102 	return (sys_socket(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, int);
   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 	NETBSD32TOX64_UAP(arg, caddr_t);
   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 #if defined(NFS) || defined(NFSSERVER)
   1464 int
   1465 netbsd32_getfh(l, v, retval)
   1466 	struct lwp *l;
   1467 	void *v;
   1468 	register_t *retval;
   1469 {
   1470 	struct netbsd32_getfh_args /* {
   1471 		syscallarg(const netbsd32_charp) fname;
   1472 		syscallarg(netbsd32_fhandlep_t) fhp;
   1473 	} */ *uap = v;
   1474 	struct sys_getfh_args ua;
   1475 
   1476 	NETBSD32TOP_UAP(fname, const char);
   1477 	NETBSD32TOP_UAP(fhp, struct fhandle);
   1478 	/* Lucky for us a fhandlep_t doesn't change sizes */
   1479 	return (sys_getfh(l, &ua, retval));
   1480 }
   1481 #endif
   1482 
   1483 int
   1484 netbsd32_pread(l, v, retval)
   1485 	struct lwp *l;
   1486 	void *v;
   1487 	register_t *retval;
   1488 {
   1489 	struct netbsd32_pread_args /* {
   1490 		syscallarg(int) fd;
   1491 		syscallarg(netbsd32_voidp) buf;
   1492 		syscallarg(netbsd32_size_t) nbyte;
   1493 		syscallarg(int) pad;
   1494 		syscallarg(off_t) offset;
   1495 	} */ *uap = v;
   1496 	struct sys_pread_args ua;
   1497 	ssize_t rt;
   1498 	int error;
   1499 
   1500 	NETBSD32TO64_UAP(fd);
   1501 	NETBSD32TOP_UAP(buf, void);
   1502 	NETBSD32TOX_UAP(nbyte, size_t);
   1503 	NETBSD32TO64_UAP(pad);
   1504 	NETBSD32TO64_UAP(offset);
   1505 	error = sys_pread(l, &ua, (register_t *)&rt);
   1506 	*retval = rt;
   1507 	return (error);
   1508 }
   1509 
   1510 int
   1511 netbsd32_pwrite(l, v, retval)
   1512 	struct lwp *l;
   1513 	void *v;
   1514 	register_t *retval;
   1515 {
   1516 	struct netbsd32_pwrite_args /* {
   1517 		syscallarg(int) fd;
   1518 		syscallarg(const netbsd32_voidp) buf;
   1519 		syscallarg(netbsd32_size_t) nbyte;
   1520 		syscallarg(int) pad;
   1521 		syscallarg(off_t) offset;
   1522 	} */ *uap = v;
   1523 	struct sys_pwrite_args ua;
   1524 	ssize_t rt;
   1525 	int error;
   1526 
   1527 	NETBSD32TO64_UAP(fd);
   1528 	NETBSD32TOP_UAP(buf, void);
   1529 	NETBSD32TOX_UAP(nbyte, size_t);
   1530 	NETBSD32TO64_UAP(pad);
   1531 	NETBSD32TO64_UAP(offset);
   1532 	error = sys_pwrite(l, &ua, (register_t *)&rt);
   1533 	*retval = rt;
   1534 	return (error);
   1535 }
   1536 
   1537 int
   1538 netbsd32_setgid(l, v, retval)
   1539 	struct lwp *l;
   1540 	void *v;
   1541 	register_t *retval;
   1542 {
   1543 	struct netbsd32_setgid_args /* {
   1544 		syscallarg(gid_t) gid;
   1545 	} */ *uap = v;
   1546 	struct sys_setgid_args ua;
   1547 
   1548 	NETBSD32TO64_UAP(gid);
   1549 	return (sys_setgid(l, v, retval));
   1550 }
   1551 
   1552 int
   1553 netbsd32_setegid(l, v, retval)
   1554 	struct lwp *l;
   1555 	void *v;
   1556 	register_t *retval;
   1557 {
   1558 	struct netbsd32_setegid_args /* {
   1559 		syscallarg(gid_t) egid;
   1560 	} */ *uap = v;
   1561 	struct sys_setegid_args ua;
   1562 
   1563 	NETBSD32TO64_UAP(egid);
   1564 	return (sys_setegid(l, v, retval));
   1565 }
   1566 
   1567 int
   1568 netbsd32_seteuid(l, v, retval)
   1569 	struct lwp *l;
   1570 	void *v;
   1571 	register_t *retval;
   1572 {
   1573 	struct netbsd32_seteuid_args /* {
   1574 		syscallarg(gid_t) euid;
   1575 	} */ *uap = v;
   1576 	struct sys_seteuid_args ua;
   1577 
   1578 	NETBSD32TO64_UAP(euid);
   1579 	return (sys_seteuid(l, v, retval));
   1580 }
   1581 
   1582 #ifdef LFS
   1583 int
   1584 netbsd32_sys_lfs_bmapv(l, v, retval)
   1585 	struct lwp *l;
   1586 	void *v;
   1587 	register_t *retval;
   1588 {
   1589 
   1590 	return (ENOSYS);	/* XXX */
   1591 }
   1592 
   1593 int
   1594 netbsd32_sys_lfs_markv(l, v, retval)
   1595 	struct lwp *l;
   1596 	void *v;
   1597 	register_t *retval;
   1598 {
   1599 
   1600 	return (ENOSYS);	/* XXX */
   1601 }
   1602 
   1603 int
   1604 netbsd32_sys_lfs_segclean(l, v, retval)
   1605 	struct lwp *l;
   1606 	void *v;
   1607 	register_t *retval;
   1608 {
   1609 
   1610 	return (ENOSYS);	/* XXX */
   1611 }
   1612 
   1613 int
   1614 netbsd32_sys_lfs_segwait(l, v, retval)
   1615 	struct lwp *l;
   1616 	void *v;
   1617 	register_t *retval;
   1618 {
   1619 
   1620 	return (ENOSYS);	/* XXX */
   1621 }
   1622 #endif
   1623 
   1624 int
   1625 netbsd32_pathconf(l, v, retval)
   1626 	struct lwp *l;
   1627 	void *v;
   1628 	register_t *retval;
   1629 {
   1630 	struct netbsd32_pathconf_args /* {
   1631 		syscallarg(int) fd;
   1632 		syscallarg(int) name;
   1633 	} */ *uap = v;
   1634 	struct sys_pathconf_args ua;
   1635 	long rt;
   1636 	int error;
   1637 
   1638 	NETBSD32TOP_UAP(path, const char);
   1639 	NETBSD32TO64_UAP(name);
   1640 	error = sys_pathconf(l, &ua, (register_t *)&rt);
   1641 	*retval = rt;
   1642 	return (error);
   1643 }
   1644 
   1645 int
   1646 netbsd32_fpathconf(l, v, retval)
   1647 	struct lwp *l;
   1648 	void *v;
   1649 	register_t *retval;
   1650 {
   1651 	struct netbsd32_fpathconf_args /* {
   1652 		syscallarg(int) fd;
   1653 		syscallarg(int) name;
   1654 	} */ *uap = v;
   1655 	struct sys_fpathconf_args ua;
   1656 	long rt;
   1657 	int error;
   1658 
   1659 	NETBSD32TO64_UAP(fd);
   1660 	NETBSD32TO64_UAP(name);
   1661 	error = sys_fpathconf(l, &ua, (register_t *)&rt);
   1662 	*retval = rt;
   1663 	return (error);
   1664 }
   1665 
   1666 int
   1667 netbsd32_getrlimit(l, v, retval)
   1668 	struct lwp *l;
   1669 	void *v;
   1670 	register_t *retval;
   1671 {
   1672 	struct netbsd32_getrlimit_args /* {
   1673 		syscallarg(int) which;
   1674 		syscallarg(netbsd32_rlimitp_t) rlp;
   1675 	} */ *uap = v;
   1676 	int which = SCARG(uap, which);
   1677 
   1678 	if ((u_int)which >= RLIM_NLIMITS)
   1679 		return (EINVAL);
   1680 	return (copyout(&l->l_proc->p_rlimit[which],
   1681 	    (caddr_t)NETBSD32PTR64(SCARG(uap, rlp)), sizeof(struct rlimit)));
   1682 }
   1683 
   1684 int
   1685 netbsd32_setrlimit(l, v, retval)
   1686 	struct lwp *l;
   1687 	void *v;
   1688 	register_t *retval;
   1689 {
   1690 	struct netbsd32_setrlimit_args /* {
   1691 		syscallarg(int) which;
   1692 		syscallarg(const netbsd32_rlimitp_t) rlp;
   1693 	} */ *uap = v;
   1694 		int which = SCARG(uap, which);
   1695 	struct rlimit alim;
   1696 	int error;
   1697 	struct proc *p = l->l_proc;
   1698 
   1699 	error = copyin((caddr_t)NETBSD32PTR64(SCARG(uap, rlp)), &alim,
   1700 	    sizeof(struct rlimit));
   1701 	if (error)
   1702 		return (error);
   1703 
   1704 	switch (which) {
   1705 	case RLIMIT_DATA:
   1706 		if (alim.rlim_cur > MAXDSIZ32)
   1707 			alim.rlim_cur = MAXDSIZ32;
   1708 		if (alim.rlim_max > MAXDSIZ32)
   1709 			alim.rlim_max = MAXDSIZ32;
   1710 		break;
   1711 
   1712 	case RLIMIT_STACK:
   1713 		if (alim.rlim_cur > MAXSSIZ32)
   1714 			alim.rlim_cur = MAXSSIZ32;
   1715 		if (alim.rlim_max > MAXSSIZ32)
   1716 			alim.rlim_max = MAXSSIZ32;
   1717 	default:
   1718 		break;
   1719 	}
   1720 
   1721 	return (dosetrlimit(p, p->p_cred, which, &alim));
   1722 }
   1723 
   1724 int
   1725 netbsd32_mmap(l, v, retval)
   1726 	struct lwp *l;
   1727 	void *v;
   1728 	register_t *retval;
   1729 {
   1730 	struct netbsd32_mmap_args /* {
   1731 		syscallarg(netbsd32_voidp) addr;
   1732 		syscallarg(netbsd32_size_t) len;
   1733 		syscallarg(int) prot;
   1734 		syscallarg(int) flags;
   1735 		syscallarg(int) fd;
   1736 		syscallarg(netbsd32_long) pad;
   1737 		syscallarg(off_t) pos;
   1738 	} */ *uap = v;
   1739 	struct sys_mmap_args ua;
   1740 	int error;
   1741 
   1742 	NETBSD32TOP_UAP(addr, void);
   1743 	NETBSD32TOX_UAP(len, size_t);
   1744 	NETBSD32TO64_UAP(prot);
   1745 	NETBSD32TO64_UAP(flags);
   1746 	NETBSD32TO64_UAP(fd);
   1747 	NETBSD32TOX_UAP(pad, long);
   1748 	NETBSD32TOX_UAP(pos, off_t);
   1749 	error = sys_mmap(l, &ua, retval);
   1750 	if ((u_long)*retval > (u_long)UINT_MAX) {
   1751 		printf("netbsd32_mmap: retval out of range: 0x%lx",
   1752 		    (u_long)*retval);
   1753 		/* Should try to recover and return an error here. */
   1754 	}
   1755 	return (error);
   1756 }
   1757 
   1758 int
   1759 netbsd32_lseek(l, v, retval)
   1760 	struct lwp *l;
   1761 	void *v;
   1762 	register_t *retval;
   1763 {
   1764 	struct netbsd32_lseek_args /* {
   1765 		syscallarg(int) fd;
   1766 		syscallarg(int) pad;
   1767 		syscallarg(off_t) offset;
   1768 		syscallarg(int) whence;
   1769 	} */ *uap = v;
   1770 	struct sys_lseek_args ua;
   1771 	int rv;
   1772 
   1773 	NETBSD32TO64_UAP(fd);
   1774 	NETBSD32TO64_UAP(pad);
   1775 	NETBSD32TO64_UAP(offset);
   1776 	NETBSD32TO64_UAP(whence);
   1777 	rv = sys_lseek(l, &ua, retval);
   1778 #ifdef NETBSD32_OFF_T_RETURN
   1779 	if (rv == 0)
   1780 		NETBSD32_OFF_T_RETURN(retval);
   1781 #endif
   1782 	return rv;
   1783 }
   1784 
   1785 int
   1786 netbsd32_truncate(l, v, retval)
   1787 	struct lwp *l;
   1788 	void *v;
   1789 	register_t *retval;
   1790 {
   1791 	struct netbsd32_truncate_args /* {
   1792 		syscallarg(const netbsd32_charp) path;
   1793 		syscallarg(int) pad;
   1794 		syscallarg(off_t) length;
   1795 	} */ *uap = v;
   1796 	struct sys_truncate_args ua;
   1797 
   1798 	NETBSD32TOP_UAP(path, const char);
   1799 	NETBSD32TO64_UAP(pad);
   1800 	NETBSD32TO64_UAP(length);
   1801 	return (sys_truncate(l, &ua, retval));
   1802 }
   1803 
   1804 int
   1805 netbsd32_ftruncate(l, v, retval)
   1806 	struct lwp *l;
   1807 	void *v;
   1808 	register_t *retval;
   1809 {
   1810 	struct netbsd32_ftruncate_args /* {
   1811 		syscallarg(int) fd;
   1812 		syscallarg(int) pad;
   1813 		syscallarg(off_t) length;
   1814 	} */ *uap = v;
   1815 	struct sys_ftruncate_args ua;
   1816 
   1817 	NETBSD32TO64_UAP(fd);
   1818 	NETBSD32TO64_UAP(pad);
   1819 	NETBSD32TO64_UAP(length);
   1820 	return (sys_ftruncate(l, &ua, retval));
   1821 }
   1822 
   1823 int
   1824 netbsd32_mlock(l, v, retval)
   1825 	struct lwp *l;
   1826 	void *v;
   1827 	register_t *retval;
   1828 {
   1829 	struct netbsd32_mlock_args /* {
   1830 		syscallarg(const netbsd32_voidp) addr;
   1831 		syscallarg(netbsd32_size_t) len;
   1832 	} */ *uap = v;
   1833 	struct sys_mlock_args ua;
   1834 
   1835 	NETBSD32TOP_UAP(addr, const void);
   1836 	NETBSD32TO64_UAP(len);
   1837 	return (sys_mlock(l, &ua, retval));
   1838 }
   1839 
   1840 int
   1841 netbsd32_munlock(l, v, retval)
   1842 	struct lwp *l;
   1843 	void *v;
   1844 	register_t *retval;
   1845 {
   1846 	struct netbsd32_munlock_args /* {
   1847 		syscallarg(const netbsd32_voidp) addr;
   1848 		syscallarg(netbsd32_size_t) len;
   1849 	} */ *uap = v;
   1850 	struct sys_munlock_args ua;
   1851 
   1852 	NETBSD32TOP_UAP(addr, const void);
   1853 	NETBSD32TO64_UAP(len);
   1854 	return (sys_munlock(l, &ua, retval));
   1855 }
   1856 
   1857 int
   1858 netbsd32_undelete(l, v, retval)
   1859 	struct lwp *l;
   1860 	void *v;
   1861 	register_t *retval;
   1862 {
   1863 	struct netbsd32_undelete_args /* {
   1864 		syscallarg(const netbsd32_charp) path;
   1865 	} */ *uap = v;
   1866 	struct sys_undelete_args ua;
   1867 
   1868 	NETBSD32TOP_UAP(path, const char);
   1869 	return (sys_undelete(l, &ua, retval));
   1870 }
   1871 
   1872 int
   1873 netbsd32_getpgid(l, v, retval)
   1874 	struct lwp *l;
   1875 	void *v;
   1876 	register_t *retval;
   1877 {
   1878 	struct netbsd32_getpgid_args /* {
   1879 		syscallarg(pid_t) pid;
   1880 	} */ *uap = v;
   1881 	struct sys_getpgid_args ua;
   1882 
   1883 	NETBSD32TO64_UAP(pid);
   1884 	return (sys_getpgid(l, &ua, retval));
   1885 }
   1886 
   1887 int
   1888 netbsd32_reboot(l, v, retval)
   1889 	struct lwp *l;
   1890 	void *v;
   1891 	register_t *retval;
   1892 {
   1893 	struct netbsd32_reboot_args /* {
   1894 		syscallarg(int) opt;
   1895 		syscallarg(netbsd32_charp) bootstr;
   1896 	} */ *uap = v;
   1897 	struct sys_reboot_args ua;
   1898 
   1899 	NETBSD32TO64_UAP(opt);
   1900 	NETBSD32TOP_UAP(bootstr, char);
   1901 	return (sys_reboot(l, &ua, retval));
   1902 }
   1903 
   1904 #include <sys/poll.h>
   1905 int
   1906 netbsd32_poll(l, v, retval)
   1907 	struct lwp *l;
   1908 	void *v;
   1909 	register_t *retval;
   1910 {
   1911 	struct netbsd32_poll_args /* {
   1912 		syscallarg(netbsd32_pollfdp_t) fds;
   1913 		syscallarg(u_int) nfds;
   1914 		syscallarg(int) timeout;
   1915 	} */ *uap = v;
   1916 	struct sys_poll_args ua;
   1917 
   1918 	NETBSD32TOP_UAP(fds, struct pollfd);
   1919 	NETBSD32TO64_UAP(nfds);
   1920 	NETBSD32TO64_UAP(timeout);
   1921 
   1922 	return (sys_poll(l, &ua, retval));
   1923 }
   1924 
   1925 int
   1926 netbsd32_fdatasync(l, v, retval)
   1927 	struct lwp *l;
   1928 	void *v;
   1929 	register_t *retval;
   1930 {
   1931 	struct netbsd32_fdatasync_args /* {
   1932 		syscallarg(int) fd;
   1933 	} */ *uap = v;
   1934 	struct sys_fdatasync_args ua;
   1935 
   1936 	NETBSD32TO64_UAP(fd);
   1937 	return (sys_fdatasync(l, &ua, retval));
   1938 }
   1939 
   1940 int
   1941 netbsd32___posix_rename(l, v, retval)
   1942 	struct lwp *l;
   1943 	void *v;
   1944 	register_t *retval;
   1945 {
   1946 	struct netbsd32___posix_rename_args /* {
   1947 		syscallarg(const netbsd32_charp) from;
   1948 		syscallarg(const netbsd32_charp) to;
   1949 	} */ *uap = v;
   1950 	struct sys___posix_rename_args ua;
   1951 
   1952 	NETBSD32TOP_UAP(from, const char);
   1953 	NETBSD32TOP_UAP(to, const char);
   1954 	return (sys___posix_rename(l, &ua, retval));
   1955 }
   1956 
   1957 int
   1958 netbsd32_swapctl(l, v, retval)
   1959 	struct lwp *l;
   1960 	void *v;
   1961 	register_t *retval;
   1962 {
   1963 	struct netbsd32_swapctl_args /* {
   1964 		syscallarg(int) cmd;
   1965 		syscallarg(const netbsd32_voidp) arg;
   1966 		syscallarg(int) misc;
   1967 	} */ *uap = v;
   1968 	struct sys_swapctl_args ua;
   1969 
   1970 	NETBSD32TO64_UAP(cmd);
   1971 	NETBSD32TOP_UAP(arg, void);
   1972 	NETBSD32TO64_UAP(misc);
   1973 	return (sys_swapctl(l, &ua, retval));
   1974 }
   1975 
   1976 int
   1977 netbsd32_minherit(l, v, retval)
   1978 	struct lwp *l;
   1979 	void *v;
   1980 	register_t *retval;
   1981 {
   1982 	struct netbsd32_minherit_args /* {
   1983 		syscallarg(netbsd32_voidp) addr;
   1984 		syscallarg(netbsd32_size_t) len;
   1985 		syscallarg(int) inherit;
   1986 	} */ *uap = v;
   1987 	struct sys_minherit_args ua;
   1988 
   1989 	NETBSD32TOP_UAP(addr, void);
   1990 	NETBSD32TOX_UAP(len, size_t);
   1991 	NETBSD32TO64_UAP(inherit);
   1992 	return (sys_minherit(l, &ua, retval));
   1993 }
   1994 
   1995 int
   1996 netbsd32_lchmod(l, v, retval)
   1997 	struct lwp *l;
   1998 	void *v;
   1999 	register_t *retval;
   2000 {
   2001 	struct netbsd32_lchmod_args /* {
   2002 		syscallarg(const netbsd32_charp) path;
   2003 		syscallarg(mode_t) mode;
   2004 	} */ *uap = v;
   2005 	struct sys_lchmod_args ua;
   2006 
   2007 	NETBSD32TOP_UAP(path, const char);
   2008 	NETBSD32TO64_UAP(mode);
   2009 	return (sys_lchmod(l, &ua, retval));
   2010 }
   2011 
   2012 int
   2013 netbsd32_lchown(l, v, retval)
   2014 	struct lwp *l;
   2015 	void *v;
   2016 	register_t *retval;
   2017 {
   2018 	struct netbsd32_lchown_args /* {
   2019 		syscallarg(const netbsd32_charp) path;
   2020 		syscallarg(uid_t) uid;
   2021 		syscallarg(gid_t) gid;
   2022 	} */ *uap = v;
   2023 	struct sys_lchown_args ua;
   2024 
   2025 	NETBSD32TOP_UAP(path, const char);
   2026 	NETBSD32TO64_UAP(uid);
   2027 	NETBSD32TO64_UAP(gid);
   2028 	return (sys_lchown(l, &ua, retval));
   2029 }
   2030 
   2031 int
   2032 netbsd32___msync13(l, v, retval)
   2033 	struct lwp *l;
   2034 	void *v;
   2035 	register_t *retval;
   2036 {
   2037 	struct netbsd32___msync13_args /* {
   2038 		syscallarg(netbsd32_voidp) addr;
   2039 		syscallarg(netbsd32_size_t) len;
   2040 		syscallarg(int) flags;
   2041 	} */ *uap = v;
   2042 	struct sys___msync13_args ua;
   2043 
   2044 	NETBSD32TOP_UAP(addr, void);
   2045 	NETBSD32TOX_UAP(len, size_t);
   2046 	NETBSD32TO64_UAP(flags);
   2047 	return (sys___msync13(l, &ua, retval));
   2048 }
   2049 
   2050 int
   2051 netbsd32___posix_chown(l, v, retval)
   2052 	struct lwp *l;
   2053 	void *v;
   2054 	register_t *retval;
   2055 {
   2056 	struct netbsd32___posix_chown_args /* {
   2057 		syscallarg(const netbsd32_charp) path;
   2058 		syscallarg(uid_t) uid;
   2059 		syscallarg(gid_t) gid;
   2060 	} */ *uap = v;
   2061 	struct sys___posix_chown_args ua;
   2062 
   2063 	NETBSD32TOP_UAP(path, const char);
   2064 	NETBSD32TO64_UAP(uid);
   2065 	NETBSD32TO64_UAP(gid);
   2066 	return (sys___posix_chown(l, &ua, retval));
   2067 }
   2068 
   2069 int
   2070 netbsd32___posix_fchown(l, v, retval)
   2071 	struct lwp *l;
   2072 	void *v;
   2073 	register_t *retval;
   2074 {
   2075 	struct netbsd32___posix_fchown_args /* {
   2076 		syscallarg(int) fd;
   2077 		syscallarg(uid_t) uid;
   2078 		syscallarg(gid_t) gid;
   2079 	} */ *uap = v;
   2080 	struct sys___posix_fchown_args ua;
   2081 
   2082 	NETBSD32TO64_UAP(fd);
   2083 	NETBSD32TO64_UAP(uid);
   2084 	NETBSD32TO64_UAP(gid);
   2085 	return (sys___posix_fchown(l, &ua, retval));
   2086 }
   2087 
   2088 int
   2089 netbsd32___posix_lchown(l, v, retval)
   2090 	struct lwp *l;
   2091 	void *v;
   2092 	register_t *retval;
   2093 {
   2094 	struct netbsd32___posix_lchown_args /* {
   2095 		syscallarg(const netbsd32_charp) path;
   2096 		syscallarg(uid_t) uid;
   2097 		syscallarg(gid_t) gid;
   2098 	} */ *uap = v;
   2099 	struct sys___posix_lchown_args ua;
   2100 
   2101 	NETBSD32TOP_UAP(path, const char);
   2102 	NETBSD32TO64_UAP(uid);
   2103 	NETBSD32TO64_UAP(gid);
   2104 	return (sys___posix_lchown(l, &ua, retval));
   2105 }
   2106 
   2107 int
   2108 netbsd32_getsid(l, v, retval)
   2109 	struct lwp *l;
   2110 	void *v;
   2111 	register_t *retval;
   2112 {
   2113 	struct netbsd32_getsid_args /* {
   2114 		syscallarg(pid_t) pid;
   2115 	} */ *uap = v;
   2116 	struct sys_getsid_args ua;
   2117 
   2118 	NETBSD32TO64_UAP(pid);
   2119 	return (sys_getsid(l, &ua, retval));
   2120 }
   2121 
   2122 #ifdef KTRACE
   2123 int
   2124 netbsd32_fktrace(l, v, retval)
   2125 	struct lwp *l;
   2126 	void *v;
   2127 	register_t *retval;
   2128 {
   2129 	struct netbsd32_fktrace_args /* {
   2130 		syscallarg(const int) fd;
   2131 		syscallarg(int) ops;
   2132 		syscallarg(int) facs;
   2133 		syscallarg(int) pid;
   2134 	} */ *uap = v;
   2135 #if 0
   2136 	struct sys_fktrace_args ua;
   2137 #else
   2138 	/* XXXX */
   2139 	struct sys_fktrace_noconst_args {
   2140 		syscallarg(int) fd;
   2141 		syscallarg(int) ops;
   2142 		syscallarg(int) facs;
   2143 		syscallarg(int) pid;
   2144 	} ua;
   2145 #endif
   2146 
   2147 	NETBSD32TOX_UAP(fd, int);
   2148 	NETBSD32TO64_UAP(ops);
   2149 	NETBSD32TO64_UAP(facs);
   2150 	NETBSD32TO64_UAP(pid);
   2151 	return (sys_fktrace(l, &ua, retval));
   2152 }
   2153 #endif /* KTRACE */
   2154 
   2155 int netbsd32___sigpending14(l, v, retval)
   2156 	struct lwp *l;
   2157 	void   *v;
   2158 	register_t *retval;
   2159 {
   2160 	struct netbsd32___sigpending14_args /* {
   2161 		syscallarg(sigset_t *) set;
   2162 	} */ *uap = v;
   2163 	struct sys___sigpending14_args ua;
   2164 
   2165 	NETBSD32TOP_UAP(set, sigset_t);
   2166 	return (sys___sigpending14(l, &ua, retval));
   2167 }
   2168 
   2169 int netbsd32___sigprocmask14(l, v, retval)
   2170 	struct lwp *l;
   2171 	void   *v;
   2172 	register_t *retval;
   2173 {
   2174 	struct netbsd32___sigprocmask14_args /* {
   2175 		syscallarg(int) how;
   2176 		syscallarg(const sigset_t *) set;
   2177 		syscallarg(sigset_t *) oset;
   2178 	} */ *uap = v;
   2179 	struct sys___sigprocmask14_args ua;
   2180 
   2181 	NETBSD32TO64_UAP(how);
   2182 	NETBSD32TOP_UAP(set, sigset_t);
   2183 	NETBSD32TOP_UAP(oset, sigset_t);
   2184 	return (sys___sigprocmask14(l, &ua, retval));
   2185 }
   2186 
   2187 int netbsd32___sigsuspend14(l, v, retval)
   2188 	struct lwp *l;
   2189 	void   *v;
   2190 	register_t *retval;
   2191 {
   2192 	struct netbsd32___sigsuspend14_args /* {
   2193 		syscallarg(const sigset_t *) set;
   2194 	} */ *uap = v;
   2195 	struct sys___sigsuspend14_args ua;
   2196 
   2197 	NETBSD32TOP_UAP(set, sigset_t);
   2198 	return (sys___sigsuspend14(l, &ua, retval));
   2199 };
   2200 
   2201 int netbsd32_fchroot(l, v, retval)
   2202 	struct lwp *l;
   2203 	void *v;
   2204 	register_t *retval;
   2205 {
   2206 	struct netbsd32_fchroot_args /* {
   2207 		syscallarg(int) fd;
   2208 	} */ *uap = v;
   2209 	struct sys_fchroot_args ua;
   2210 
   2211 	NETBSD32TO64_UAP(fd);
   2212 	return (sys_fchroot(l, &ua, retval));
   2213 }
   2214 
   2215 /*
   2216  * Open a file given a file handle.
   2217  *
   2218  * Check permissions, allocate an open file structure,
   2219  * and call the device open routine if any.
   2220  */
   2221 int
   2222 netbsd32_fhopen(l, v, retval)
   2223 	struct lwp *l;
   2224 	void *v;
   2225 	register_t *retval;
   2226 {
   2227 	struct netbsd32_fhopen_args /* {
   2228 		syscallarg(const fhandle_t *) fhp;
   2229 		syscallarg(int) flags;
   2230 	} */ *uap = v;
   2231 	struct sys_fhopen_args ua;
   2232 
   2233 	NETBSD32TOP_UAP(fhp, fhandle_t);
   2234 	NETBSD32TO64_UAP(flags);
   2235 	return (sys_fhopen(l, &ua, retval));
   2236 }
   2237 
   2238 int netbsd32_fhstat(l, v, retval)
   2239 	struct lwp *l;
   2240 	void *v;
   2241 	register_t *retval;
   2242 {
   2243 	struct netbsd32_fhstat_args /* {
   2244 		syscallarg(const netbsd32_fhandlep_t) fhp;
   2245 		syscallarg(struct stat *) sb;
   2246 	} */ *uap = v;
   2247 	struct sys_fhstat_args ua;
   2248 
   2249 	NETBSD32TOP_UAP(fhp, const fhandle_t);
   2250 	NETBSD32TOP_UAP(sb, struct stat);
   2251 	return (sys_fhstat(l, &ua, retval));
   2252 }
   2253 
   2254 /* virtual memory syscalls */
   2255 int
   2256 netbsd32_ovadvise(l, v, retval)
   2257 	struct lwp *l;
   2258 	void *v;
   2259 	register_t *retval;
   2260 {
   2261 	struct netbsd32_ovadvise_args /* {
   2262 		syscallarg(int) anom;
   2263 	} */ *uap = v;
   2264 	struct sys_ovadvise_args ua;
   2265 
   2266 	NETBSD32TO64_UAP(anom);
   2267 	return (sys_ovadvise(l, &ua, retval));
   2268 }
   2269 
   2270 void
   2271 netbsd32_adjust_limits(struct proc *p)
   2272 {
   2273 	rlim_t *valp;
   2274 
   2275 	valp = &p->p_rlimit[RLIMIT_DATA].rlim_cur;
   2276 	if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
   2277 		*valp = MAXDSIZ32;
   2278 	valp = &p->p_rlimit[RLIMIT_DATA].rlim_max;
   2279 	if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
   2280 		*valp = MAXDSIZ32;
   2281 
   2282 	valp = &p->p_rlimit[RLIMIT_STACK].rlim_cur;
   2283 	if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
   2284 		*valp = MAXSSIZ32;
   2285 	valp = &p->p_rlimit[RLIMIT_STACK].rlim_max;
   2286 	if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
   2287 		*valp = MAXSSIZ32;
   2288 }
   2289 
   2290 int
   2291 netbsd32_uuidgen(struct lwp *l, void *v, register_t *retval)
   2292 {
   2293 	struct netbsd32_uuidgen_args /* {
   2294 		syscallarg(netbsd32_uuidp_t) store;
   2295 		syscallarg(int) count;
   2296 	} */ *uap = v;
   2297 	struct sys_uuidgen_args ua;
   2298 
   2299 	NETBSD32TOP_UAP(store, struct uuid);
   2300 	NETBSD32TO64_UAP(count);
   2301 	return (sys_uuidgen(l, &ua, retval));
   2302 }
   2303 
   2304 int
   2305 netbsd32_extattrctl(struct lwp *l, void *v, register_t *retval)
   2306 {
   2307 	struct netbsd32_extattrctl_args /* {
   2308 		syscallarg(const netbsd32_charp) path;
   2309 		syscallarg(int) cmd;
   2310 		syscallarg(const netbsd32_charp) filename;
   2311 		syscallarg(int) attrnamespace;
   2312 		syscallarg(const netbsd32_charp) attrname;
   2313 	} */ *uap = v;
   2314 	struct sys_extattrctl_args ua;
   2315 
   2316 	NETBSD32TOP_UAP(path, const char);
   2317 	NETBSD32TO64_UAP(cmd);
   2318 	NETBSD32TOP_UAP(filename, const char);
   2319 	NETBSD32TO64_UAP(attrnamespace);
   2320 	NETBSD32TOP_UAP(attrname, const char);
   2321 	return sys_extattrctl(l, &ua, retval);
   2322 }
   2323 
   2324 int
   2325 netbsd32_extattr_set_fd(struct lwp *l, void *v, register_t *retval)
   2326 {
   2327 	struct netbsd32_extattr_set_fd_args /* {
   2328 		syscallarg(int) fd;
   2329 		syscallarg(int) attrnamespace;
   2330 		syscallarg(const netbsd32_charp) attrname;
   2331 		syscallarg(const netbsd32_voidp) data;
   2332 		syscallarg(netbsd32_size_t) nbytes;
   2333 	} */ *uap = v;
   2334 	struct sys_extattr_set_fd_args ua;
   2335 
   2336 	NETBSD32TO64_UAP(fd);
   2337 	NETBSD32TO64_UAP(attrnamespace);
   2338 	NETBSD32TOP_UAP(attrname, const char);
   2339 	NETBSD32TOP_UAP(data, const void);
   2340 	NETBSD32TOX_UAP(nbytes, size_t);
   2341 	return sys_extattr_set_fd(l, &ua, retval);
   2342 }
   2343 
   2344 int
   2345 netbsd32_extattr_set_file(struct lwp *l, void *v, register_t *retval)
   2346 {
   2347 	struct netbsd32_extattr_set_file_args /* {
   2348 		syscallarg(const netbsd32_charp) path;
   2349 		syscallarg(int) attrnamespace;
   2350 		syscallarg(const netbsd32_charp) attrname;
   2351 		syscallarg(const netbsd32_voidp) data;
   2352 		syscallarg(netbsd32_size_t) nbytes;
   2353 	} */ *uap = v;
   2354 	struct sys_extattr_set_file_args ua;
   2355 
   2356 	NETBSD32TOP_UAP(path, const char);
   2357 	NETBSD32TO64_UAP(attrnamespace);
   2358 	NETBSD32TOP_UAP(attrname, const char);
   2359 	NETBSD32TOP_UAP(data, const void);
   2360 	NETBSD32TOX_UAP(nbytes, size_t);
   2361 	return sys_extattr_set_file(l, &ua, retval);
   2362 }
   2363 
   2364 int
   2365 netbsd32_extattr_set_link(struct lwp *l, void *v, register_t *retval)
   2366 {
   2367 	struct netbsd32_extattr_set_link_args /* {
   2368 		syscallarg(const netbsd32_charp) path;
   2369 		syscallarg(int) attrnamespace;
   2370 		syscallarg(const netbsd32_charp) attrname;
   2371 		syscallarg(const netbsd32_voidp) data;
   2372 		syscallarg(netbsd32_size_t) nbytes;
   2373 	} */ *uap = v;
   2374 	struct sys_extattr_set_link_args ua;
   2375 
   2376 	NETBSD32TOP_UAP(path, const char);
   2377 	NETBSD32TO64_UAP(attrnamespace);
   2378 	NETBSD32TOP_UAP(attrname, const char);
   2379 	NETBSD32TOP_UAP(data, const void);
   2380 	NETBSD32TOX_UAP(nbytes, size_t);
   2381 	return sys_extattr_set_link(l, &ua, retval);
   2382 }
   2383 
   2384 int
   2385 netbsd32_extattr_get_fd(struct lwp *l, void *v, register_t *retval)
   2386 {
   2387 	struct netbsd32_extattr_get_fd_args /* {
   2388 		syscallarg(int) fd;
   2389 		syscallarg(int) attrnamespace;
   2390 		syscallarg(const netbsd32_charp) attrname;
   2391 		syscallarg(netbsd32_voidp) data;
   2392 		syscallarg(netbsd32_size_t) nbytes;
   2393 	} */ *uap = v;
   2394 	struct sys_extattr_get_fd_args ua;
   2395 
   2396 	NETBSD32TO64_UAP(fd);
   2397 	NETBSD32TO64_UAP(attrnamespace);
   2398 	NETBSD32TOP_UAP(attrname, const char);
   2399 	NETBSD32TOP_UAP(data, void);
   2400 	NETBSD32TOX_UAP(nbytes, size_t);
   2401 	return sys_extattr_get_fd(l, &ua, retval);
   2402 }
   2403 
   2404 int
   2405 netbsd32_extattr_get_file(struct lwp *l, void *v, register_t *retval)
   2406 {
   2407 	struct netbsd32_extattr_get_file_args /* {
   2408 		syscallarg(const netbsd32_charp) path;
   2409 		syscallarg(int) attrnamespace;
   2410 		syscallarg(const netbsd32_charp) attrname;
   2411 		syscallarg(netbsd32_voidp) data;
   2412 		syscallarg(netbsd32_size_t) nbytes;
   2413 	} */ *uap = v;
   2414 	struct sys_extattr_get_file_args ua;
   2415 
   2416 	NETBSD32TOP_UAP(path, const char);
   2417 	NETBSD32TO64_UAP(attrnamespace);
   2418 	NETBSD32TOP_UAP(attrname, const char);
   2419 	NETBSD32TOP_UAP(data, void);
   2420 	NETBSD32TOX_UAP(nbytes, size_t);
   2421 	return sys_extattr_get_file(l, &ua, retval);
   2422 }
   2423 
   2424 int
   2425 netbsd32_extattr_get_link(struct lwp *l, void *v, register_t *retval)
   2426 {
   2427 	struct netbsd32_extattr_get_link_args /* {
   2428 		syscallarg(const netbsd32_charp) path;
   2429 		syscallarg(int) attrnamespace;
   2430 		syscallarg(const netbsd32_charp) attrname;
   2431 		syscallarg(netbsd32_voidp) data;
   2432 		syscallarg(netbsd32_size_t) nbytes;
   2433 	} */ *uap = v;
   2434 	struct sys_extattr_get_link_args ua;
   2435 
   2436 	NETBSD32TOP_UAP(path, const char);
   2437 	NETBSD32TO64_UAP(attrnamespace);
   2438 	NETBSD32TOP_UAP(attrname, const char);
   2439 	NETBSD32TOP_UAP(data, void);
   2440 	NETBSD32TOX_UAP(nbytes, size_t);
   2441 	return sys_extattr_get_link(l, &ua, retval);
   2442 }
   2443 
   2444 int
   2445 netbsd32_extattr_delete_fd(struct lwp *l, void *v, register_t *retval)
   2446 {
   2447 	struct netbsd32_extattr_delete_fd_args /* {
   2448 		syscallarg(int) fd;
   2449 		syscallarg(int) attrnamespace;
   2450 		syscallarg(const netbsd32_charp) attrname;
   2451 	} */ *uap = v;
   2452 	struct sys_extattr_delete_fd_args ua;
   2453 
   2454 	NETBSD32TO64_UAP(fd);
   2455 	NETBSD32TO64_UAP(attrnamespace);
   2456 	NETBSD32TOP_UAP(attrname, const char);
   2457 	return sys_extattr_delete_fd(l, &ua, retval);
   2458 }
   2459 
   2460 int
   2461 netbsd32_extattr_delete_file(struct lwp *l, void *v, register_t *retval)
   2462 {
   2463 	struct netbsd32_extattr_delete_file_args /* {
   2464 		syscallarg(const netbsd32_charp) path;
   2465 		syscallarg(int) attrnamespace;
   2466 		syscallarg(const netbsd32_charp) attrname;
   2467 	} */ *uap = v;
   2468 	struct sys_extattr_delete_file_args ua;
   2469 
   2470 	NETBSD32TOP_UAP(path, const char);
   2471 	NETBSD32TO64_UAP(attrnamespace);
   2472 	NETBSD32TOP_UAP(attrname, const char);
   2473 	return sys_extattr_delete_file(l, &ua, retval);
   2474 }
   2475 
   2476 int
   2477 netbsd32_extattr_delete_link(struct lwp *l, void *v, register_t *retval)
   2478 {
   2479 	struct netbsd32_extattr_delete_link_args /* {
   2480 		syscallarg(const netbsd32_charp) path;
   2481 		syscallarg(int) attrnamespace;
   2482 		syscallarg(const netbsd32_charp) attrname;
   2483 	} */ *uap = v;
   2484 	struct sys_extattr_delete_link_args ua;
   2485 
   2486 	NETBSD32TOP_UAP(path, const char);
   2487 	NETBSD32TO64_UAP(attrnamespace);
   2488 	NETBSD32TOP_UAP(attrname, const char);
   2489 	return sys_extattr_delete_link(l, &ua, retval);
   2490 }
   2491 
   2492 int
   2493 netbsd32_extattr_list_fd(struct lwp *l, void *v, register_t *retval)
   2494 {
   2495 	struct netbsd32_extattr_list_fd_args /* {
   2496 		syscallarg(int) fd;
   2497 		syscallarg(int) attrnamespace;
   2498 		syscallarg(netbsd32_voidp) data;
   2499 		syscallarg(netbsd32_size_t) nbytes;
   2500 	} */ *uap = v;
   2501 	struct sys_extattr_list_fd_args ua;
   2502 
   2503 	NETBSD32TO64_UAP(fd);
   2504 	NETBSD32TO64_UAP(attrnamespace);
   2505 	NETBSD32TOP_UAP(data, void);
   2506 	NETBSD32TOX_UAP(nbytes, size_t);
   2507 	return sys_extattr_list_fd(l, &ua, retval);
   2508 }
   2509 
   2510 int
   2511 netbsd32_extattr_list_file(struct lwp *l, void *v, register_t *retval)
   2512 {
   2513 	struct netbsd32_extattr_list_file_args /* {
   2514 		syscallarg(const netbsd32_charp) path;
   2515 		syscallarg(int) attrnamespace;
   2516 		syscallarg(netbsd32_voidp) data;
   2517 		syscallarg(netbsd32_size_t) nbytes;
   2518 	} */ *uap = v;
   2519 	struct sys_extattr_list_file_args ua;
   2520 
   2521 	NETBSD32TOP_UAP(path, const char);
   2522 	NETBSD32TO64_UAP(attrnamespace);
   2523 	NETBSD32TOP_UAP(data, void);
   2524 	NETBSD32TOX_UAP(nbytes, size_t);
   2525 	return sys_extattr_list_file(l, &ua, retval);
   2526 }
   2527 
   2528 int
   2529 netbsd32_extattr_list_link(struct lwp *l, void *v, register_t *retval)
   2530 {
   2531 	struct netbsd32_extattr_list_link_args /* {
   2532 		syscallarg(const netbsd32_charp) path;
   2533 		syscallarg(int) attrnamespace;
   2534 		syscallarg(netbsd32_voidp) data;
   2535 		syscallarg(netbsd32_size_t) nbytes;
   2536 	} */ *uap = v;
   2537 	struct sys_extattr_list_link_args ua;
   2538 
   2539 	NETBSD32TOP_UAP(path, const char);
   2540 	NETBSD32TO64_UAP(attrnamespace);
   2541 	NETBSD32TOP_UAP(data, void);
   2542 	NETBSD32TOX_UAP(nbytes, size_t);
   2543 	return sys_extattr_list_link(l, &ua, retval);
   2544 }
   2545 
   2546 int
   2547 netbsd32_mlockall(l, v, retval)
   2548 	struct lwp *l;
   2549 	void *v;
   2550 	register_t *retval;
   2551 {
   2552 	struct netbsd32_mlockall_args /* {
   2553 		syscallarg(int) flags;
   2554 	} */ *uap = v;
   2555 	struct sys_mlockall_args ua;
   2556 
   2557 	NETBSD32TO64_UAP(flags);
   2558 	return (sys_mlockall(l, &ua, retval));
   2559 }
   2560 
   2561 int
   2562 netbsd32___clone(struct lwp *l, void *v, register_t *retval)
   2563 {
   2564 	struct netbsd32___clone_args /*  {
   2565 		syscallarg(int) flags;
   2566 		syscallarg(netbsd32_voidp) stack;
   2567 	} */ *uap = v;
   2568 	struct sys___clone_args ua;
   2569 
   2570 	NETBSD32TO64_UAP(flags);
   2571 	NETBSD32TOP_UAP(stack, void);
   2572 	return sys___clone(l, &ua, retval);
   2573 }
   2574 
   2575 int
   2576 netbsd32_fsync_range(struct lwp *l, void *v, register_t *retval)
   2577 {
   2578 	struct netbsd32_fsync_range_args /* {
   2579 		syscallarg(int) fd;
   2580 		syscallarg(int) flags;
   2581 		syscallarg(off_t) start;
   2582 		syscallarg(off_t) length;
   2583 	} */ *uap = v;
   2584 	struct sys_fsync_range_args ua;
   2585 
   2586 	NETBSD32TO64_UAP(fd);
   2587 	NETBSD32TO64_UAP(flags);
   2588 	NETBSD32TO64_UAP(start);
   2589 	NETBSD32TO64_UAP(length);
   2590 	return (sys_fsync_range(l, &ua, retval));
   2591 }
   2592 
   2593 int
   2594 netbsd32_rasctl(struct lwp *l, void *v, register_t *retval)
   2595 {
   2596 	struct netbsd32_rasctl_args /* {
   2597 		syscallarg(netbsd32_caddr_t) addr;
   2598 		syscallarg(netbsd32_size_t) len;
   2599 		syscallarg(int) op;
   2600 	} */ *uap = v;
   2601 	struct sys_rasctl_args ua;
   2602 
   2603 	NETBSD32TOX64_UAP(addr, caddr_t);
   2604 	NETBSD32TOX_UAP(len, size_t);
   2605 	NETBSD32TO64_UAP(op);
   2606 	return sys_rasctl(l, &ua, retval);
   2607 }
   2608 
   2609 int
   2610 netbsd32_setxattr(struct lwp *l, void *v, register_t *retval)
   2611 {
   2612 	struct netbsd32_setxattr_args /* {
   2613 		syscallarg(const netbsd32_charp) path;
   2614 		syscallarg(const netbsd32_charp) name;
   2615 		syscallarg(netbsd32_voidp) value;
   2616 		syscallarg(netbsd32_size_t) size;
   2617 		syscallarg(int) flags;
   2618 	} */ *uap = v;
   2619 	struct sys_setxattr_args ua;
   2620 	NETBSD32TOP_UAP(path, const char);
   2621 	NETBSD32TOP_UAP(name, const char);
   2622 	NETBSD32TOP_UAP(value, void);
   2623 	NETBSD32TOX_UAP(size, size_t);
   2624 	NETBSD32TO64_UAP(flags);
   2625 	return sys_setxattr(l, &ua, retval);
   2626 }
   2627 
   2628 int
   2629 netbsd32_lsetxattr(struct lwp *l, void *v, register_t *retval)
   2630 {
   2631 	struct netbsd32_lsetxattr_args /* {
   2632 		syscallarg(const netbsd32_charp) path;
   2633 		syscallarg(const netbsd32_charp) name;
   2634 		syscallarg(netbsd32_voidp) value;
   2635 		syscallarg(netbsd32_size_t) size;
   2636 		syscallarg(int) flags;
   2637 	} */ *uap = v;
   2638 	struct sys_lsetxattr_args ua;
   2639 	NETBSD32TOP_UAP(path, const char);
   2640 	NETBSD32TOP_UAP(name, const char);
   2641 	NETBSD32TOP_UAP(value, void);
   2642 	NETBSD32TOX_UAP(size, size_t);
   2643 	NETBSD32TO64_UAP(flags);
   2644 	return sys_lsetxattr(l, &ua, retval);
   2645 }
   2646 
   2647 int
   2648 netbsd32_fsetxattr(struct lwp *l, void *v, register_t *retval)
   2649 {
   2650 	struct netbsd32_fsetxattr_args /* {
   2651 		syscallarg(int) fd;
   2652 		syscallarg(const netbsd32_charp) name;
   2653 		syscallarg(netbsd32_voidp) value;
   2654 		syscallarg(netbsd32_size_t) size;
   2655 		syscallarg(int) flags;
   2656 	} */ *uap = v;
   2657 	struct sys_fsetxattr_args ua;
   2658 	NETBSD32TO64_UAP(fd);
   2659 	NETBSD32TOP_UAP(name, const char);
   2660 	NETBSD32TOP_UAP(value, void);
   2661 	NETBSD32TOX_UAP(size, size_t);
   2662 	NETBSD32TO64_UAP(flags);
   2663 	return sys_fsetxattr(l, &ua, retval);
   2664 }
   2665 
   2666 int
   2667 netbsd32_getxattr(struct lwp *l, void *v, register_t *retval)
   2668 {
   2669 	struct netbsd32_getxattr_args /* {
   2670 		syscallarg(const netbsd32_charp) path;
   2671 		syscallarg(const netbsd32_charp) name;
   2672 		syscallarg(netbsd32_voidp) value;
   2673 		syscallarg(netbsd32_size_t) size;
   2674 	} */ *uap = v;
   2675 	struct sys_getxattr_args ua;
   2676 	NETBSD32TOP_UAP(path, const char);
   2677 	NETBSD32TOP_UAP(name, const char);
   2678 	NETBSD32TOP_UAP(value, void);
   2679 	NETBSD32TOX_UAP(size, size_t);
   2680 	return sys_getxattr(l, &ua, retval);
   2681 }
   2682 
   2683 int
   2684 netbsd32_lgetxattr(struct lwp *l, void *v, register_t *retval)
   2685 {
   2686 	struct netbsd32_lgetxattr_args /* {
   2687 		syscallarg(const netbsd32_charp) path;
   2688 		syscallarg(const netbsd32_charp) name;
   2689 		syscallarg(netbsd32_voidp) value;
   2690 		syscallarg(netbsd32_size_t) size;
   2691 	} */ *uap = v;
   2692 	struct sys_lgetxattr_args ua;
   2693 	NETBSD32TOP_UAP(path, const char);
   2694 	NETBSD32TOP_UAP(name, const char);
   2695 	NETBSD32TOP_UAP(value, void);
   2696 	NETBSD32TOX_UAP(size, size_t);
   2697 	return sys_lgetxattr(l, &ua, retval);
   2698 }
   2699 
   2700 int
   2701 netbsd32_fgetxattr(struct lwp *l, void *v, register_t *retval)
   2702 {
   2703 	struct netbsd32_fgetxattr_args /* {
   2704 		syscallarg(int) fd;
   2705 		syscallarg(const netbsd32_charp) name;
   2706 		syscallarg(netbsd32_voidp) value;
   2707 		syscallarg(netbsd32_size_t) size;
   2708 	} */ *uap = v;
   2709 	struct sys_fgetxattr_args ua;
   2710 	NETBSD32TO64_UAP(fd);
   2711 	NETBSD32TOP_UAP(name, const char);
   2712 	NETBSD32TOP_UAP(value, void);
   2713 	NETBSD32TOX_UAP(size, size_t);
   2714 	return sys_fgetxattr(l, &ua, retval);
   2715 }
   2716 
   2717 int
   2718 netbsd32_listxattr(struct lwp *l, void *v, register_t *retval)
   2719 {
   2720 	struct netbsd32_listxattr_args /* {
   2721 		syscallarg(const netbsd32_charp) path;
   2722 		syscallarg(netbsd32_charp) list;
   2723 		syscallarg(netbsd32_size_t) size;
   2724 	} */ *uap = v;
   2725 	struct sys_listxattr_args ua;
   2726 	NETBSD32TOP_UAP(path, const char);
   2727 	NETBSD32TOP_UAP(list, char);
   2728 	NETBSD32TOX_UAP(size, size_t);
   2729 	return sys_listxattr(l, &ua, retval);
   2730 }
   2731 
   2732 int
   2733 netbsd32_llistxattr(struct lwp *l, void *v, register_t *retval)
   2734 {
   2735 	struct netbsd32_llistxattr_args /* {
   2736 		syscallarg(const netbsd32_charp) path;
   2737 		syscallarg(netbsd32_charp) list;
   2738 		syscallarg(netbsd32_size_t) size;
   2739 	} */ *uap = v;
   2740 	struct sys_llistxattr_args ua;
   2741 	NETBSD32TOP_UAP(path, const char);
   2742 	NETBSD32TOP_UAP(list, char);
   2743 	NETBSD32TOX_UAP(size, size_t);
   2744 	return sys_llistxattr(l, &ua, retval);
   2745 }
   2746 
   2747 int
   2748 netbsd32_flistxattr(struct lwp *l, void *v, register_t *retval)
   2749 {
   2750 	struct netbsd32_flistxattr_args /* {
   2751 		syscallarg(int) fd;
   2752 		syscallarg(netbsd32_charp) list;
   2753 		syscallarg(netbsd32_size_t) size;
   2754 	} */ *uap = v;
   2755 	struct sys_flistxattr_args ua;
   2756 	NETBSD32TO64_UAP(fd);
   2757 	NETBSD32TOP_UAP(list, char);
   2758 	NETBSD32TOX_UAP(size, size_t);
   2759 	return sys_flistxattr(l, &ua, retval);
   2760 }
   2761 
   2762 int
   2763 netbsd32_removexattr(struct lwp *l, void *v, register_t *retval)
   2764 {
   2765 	struct netbsd32_removexattr_args /* {
   2766 		syscallarg(const netbsd32_charp) path;
   2767 		syscallarg(const netbsd32_charp) name;
   2768 	} */ *uap = v;
   2769 	struct sys_removexattr_args ua;
   2770 	NETBSD32TOP_UAP(path, const char);
   2771 	NETBSD32TOP_UAP(name, const char);
   2772 	return sys_removexattr(l, &ua, retval);
   2773 }
   2774 
   2775 int
   2776 netbsd32_lremovexattr(struct lwp *l, void *v, register_t *retval)
   2777 {
   2778 	struct netbsd32_lremovexattr_args /* {
   2779 		syscallarg(const netbsd32_charp) path;
   2780 		syscallarg(const netbsd32_charp) name;
   2781 	} */ *uap = v;
   2782 	struct sys_lremovexattr_args ua;
   2783 	NETBSD32TOP_UAP(path, const char);
   2784 	NETBSD32TOP_UAP(name, const char);
   2785 	return sys_lremovexattr(l, &ua, retval);
   2786 }
   2787 
   2788 int
   2789 netbsd32_fremovexattr(struct lwp *l, void *v, register_t *retval)
   2790 {
   2791 	struct netbsd32_fremovexattr_args /* {
   2792 		syscallarg(int) fd;
   2793 		syscallarg(const netbsd32_charp) name;
   2794 	} */ *uap = v;
   2795 	struct sys_fremovexattr_args ua;
   2796 	NETBSD32TO64_UAP(fd);
   2797 	NETBSD32TOP_UAP(name, const char);
   2798 	return sys_fremovexattr(l, &ua, retval);
   2799 }
   2800