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