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