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