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