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