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