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