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