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