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