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