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