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