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