netbsd32_netbsd.c revision 1.100.2.3 1 /* $NetBSD: netbsd32_netbsd.c,v 1.100.2.3 2006/08/11 15:43:29 yamt 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.100.2.3 2006/08/11 15:43:29 yamt 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_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 int
1479 netbsd32___getfh30(l, v, retval)
1480 struct lwp *l;
1481 void *v;
1482 register_t *retval;
1483 {
1484 struct netbsd32___getfh30_args /* {
1485 syscallarg(const netbsd32_charp) fname;
1486 syscallarg(netbsd32_fhandlep_t) fhp;
1487 syscallarg(netbsd32_size_tp) fh_size;
1488 } */ *uap = v;
1489 struct vnode *vp;
1490 fhandle_t *fh;
1491 int error;
1492 struct nameidata nd;
1493 netbsd32_size_t sz32;
1494 size_t sz;
1495
1496 /*
1497 * Must be super user
1498 */
1499 error = kauth_authorize_generic(l->l_cred, KAUTH_GENERIC_ISSUSER,
1500 &l->l_acflag);
1501 if (error)
1502 return (error);
1503 fh = NULL;
1504 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE,
1505 (char *)NETBSD32PTR64(SCARG(uap, fname)), l);
1506 error = namei(&nd);
1507 if (error)
1508 return (error);
1509 vp = nd.ni_vp;
1510 error = copyin(NETBSD32PTR64(SCARG(uap, fh_size)), &sz32,
1511 sizeof(netbsd32_size_t));
1512 if (!error) {
1513 fh = malloc(sz32, M_TEMP, M_WAITOK);
1514 if (fh == NULL)
1515 return EINVAL;
1516 sz = sz32;
1517 error = vfs_composefh(vp, fh, &sz);
1518 sz32 = sz;
1519 }
1520 vput(vp);
1521 if (error == E2BIG)
1522 copyout(&sz, NETBSD32PTR64(SCARG(uap, fh_size)), sizeof(size_t));
1523 if (error == 0) {
1524 error = copyout(&sz32, NETBSD32PTR64(SCARG(uap, fh_size)),
1525 sizeof(netbsd32_size_t));
1526 if (!error)
1527 error = copyout(fh, NETBSD32PTR64(SCARG(uap, fhp)), sz);
1528 }
1529 free(fh, M_TEMP);
1530 return (error);
1531 }
1532
1533 int
1534 netbsd32_pread(l, v, retval)
1535 struct lwp *l;
1536 void *v;
1537 register_t *retval;
1538 {
1539 struct netbsd32_pread_args /* {
1540 syscallarg(int) fd;
1541 syscallarg(netbsd32_voidp) buf;
1542 syscallarg(netbsd32_size_t) nbyte;
1543 syscallarg(int) pad;
1544 syscallarg(off_t) offset;
1545 } */ *uap = v;
1546 struct sys_pread_args ua;
1547 ssize_t rt;
1548 int error;
1549
1550 NETBSD32TO64_UAP(fd);
1551 NETBSD32TOP_UAP(buf, void);
1552 NETBSD32TOX_UAP(nbyte, size_t);
1553 NETBSD32TO64_UAP(pad);
1554 NETBSD32TO64_UAP(offset);
1555 error = sys_pread(l, &ua, (register_t *)&rt);
1556 *retval = rt;
1557 return (error);
1558 }
1559
1560 int
1561 netbsd32_pwrite(l, v, retval)
1562 struct lwp *l;
1563 void *v;
1564 register_t *retval;
1565 {
1566 struct netbsd32_pwrite_args /* {
1567 syscallarg(int) fd;
1568 syscallarg(const netbsd32_voidp) buf;
1569 syscallarg(netbsd32_size_t) nbyte;
1570 syscallarg(int) pad;
1571 syscallarg(off_t) offset;
1572 } */ *uap = v;
1573 struct sys_pwrite_args ua;
1574 ssize_t rt;
1575 int error;
1576
1577 NETBSD32TO64_UAP(fd);
1578 NETBSD32TOP_UAP(buf, void);
1579 NETBSD32TOX_UAP(nbyte, size_t);
1580 NETBSD32TO64_UAP(pad);
1581 NETBSD32TO64_UAP(offset);
1582 error = sys_pwrite(l, &ua, (register_t *)&rt);
1583 *retval = rt;
1584 return (error);
1585 }
1586
1587 int
1588 netbsd32_setgid(l, v, retval)
1589 struct lwp *l;
1590 void *v;
1591 register_t *retval;
1592 {
1593 struct netbsd32_setgid_args /* {
1594 syscallarg(gid_t) gid;
1595 } */ *uap = v;
1596 struct sys_setgid_args ua;
1597
1598 NETBSD32TO64_UAP(gid);
1599 return (sys_setgid(l, v, retval));
1600 }
1601
1602 int
1603 netbsd32_setegid(l, v, retval)
1604 struct lwp *l;
1605 void *v;
1606 register_t *retval;
1607 {
1608 struct netbsd32_setegid_args /* {
1609 syscallarg(gid_t) egid;
1610 } */ *uap = v;
1611 struct sys_setegid_args ua;
1612
1613 NETBSD32TO64_UAP(egid);
1614 return (sys_setegid(l, v, retval));
1615 }
1616
1617 int
1618 netbsd32_seteuid(l, v, retval)
1619 struct lwp *l;
1620 void *v;
1621 register_t *retval;
1622 {
1623 struct netbsd32_seteuid_args /* {
1624 syscallarg(gid_t) euid;
1625 } */ *uap = v;
1626 struct sys_seteuid_args ua;
1627
1628 NETBSD32TO64_UAP(euid);
1629 return (sys_seteuid(l, v, retval));
1630 }
1631
1632 #ifdef LFS
1633 int
1634 netbsd32_sys_lfs_bmapv(l, v, retval)
1635 struct lwp *l;
1636 void *v;
1637 register_t *retval;
1638 {
1639
1640 return (ENOSYS); /* XXX */
1641 }
1642
1643 int
1644 netbsd32_sys_lfs_markv(l, v, retval)
1645 struct lwp *l;
1646 void *v;
1647 register_t *retval;
1648 {
1649
1650 return (ENOSYS); /* XXX */
1651 }
1652
1653 int
1654 netbsd32_sys_lfs_segclean(l, v, retval)
1655 struct lwp *l;
1656 void *v;
1657 register_t *retval;
1658 {
1659
1660 return (ENOSYS); /* XXX */
1661 }
1662
1663 int
1664 netbsd32_sys_lfs_segwait(l, v, retval)
1665 struct lwp *l;
1666 void *v;
1667 register_t *retval;
1668 {
1669
1670 return (ENOSYS); /* XXX */
1671 }
1672 #endif
1673
1674 int
1675 netbsd32_pathconf(l, v, retval)
1676 struct lwp *l;
1677 void *v;
1678 register_t *retval;
1679 {
1680 struct netbsd32_pathconf_args /* {
1681 syscallarg(int) fd;
1682 syscallarg(int) name;
1683 } */ *uap = v;
1684 struct sys_pathconf_args ua;
1685 long rt;
1686 int error;
1687
1688 NETBSD32TOP_UAP(path, const char);
1689 NETBSD32TO64_UAP(name);
1690 error = sys_pathconf(l, &ua, (register_t *)&rt);
1691 *retval = rt;
1692 return (error);
1693 }
1694
1695 int
1696 netbsd32_fpathconf(l, v, retval)
1697 struct lwp *l;
1698 void *v;
1699 register_t *retval;
1700 {
1701 struct netbsd32_fpathconf_args /* {
1702 syscallarg(int) fd;
1703 syscallarg(int) name;
1704 } */ *uap = v;
1705 struct sys_fpathconf_args ua;
1706 long rt;
1707 int error;
1708
1709 NETBSD32TO64_UAP(fd);
1710 NETBSD32TO64_UAP(name);
1711 error = sys_fpathconf(l, &ua, (register_t *)&rt);
1712 *retval = rt;
1713 return (error);
1714 }
1715
1716 int
1717 netbsd32_getrlimit(l, v, retval)
1718 struct lwp *l;
1719 void *v;
1720 register_t *retval;
1721 {
1722 struct netbsd32_getrlimit_args /* {
1723 syscallarg(int) which;
1724 syscallarg(netbsd32_rlimitp_t) rlp;
1725 } */ *uap = v;
1726 int which = SCARG(uap, which);
1727
1728 if ((u_int)which >= RLIM_NLIMITS)
1729 return (EINVAL);
1730 return (copyout(&l->l_proc->p_rlimit[which],
1731 (caddr_t)NETBSD32PTR64(SCARG(uap, rlp)), sizeof(struct rlimit)));
1732 }
1733
1734 int
1735 netbsd32_setrlimit(l, v, retval)
1736 struct lwp *l;
1737 void *v;
1738 register_t *retval;
1739 {
1740 struct netbsd32_setrlimit_args /* {
1741 syscallarg(int) which;
1742 syscallarg(const netbsd32_rlimitp_t) rlp;
1743 } */ *uap = v;
1744 int which = SCARG(uap, which);
1745 struct rlimit alim;
1746 int error;
1747
1748 error = copyin((caddr_t)NETBSD32PTR64(SCARG(uap, rlp)), &alim,
1749 sizeof(struct rlimit));
1750 if (error)
1751 return (error);
1752
1753 switch (which) {
1754 case RLIMIT_DATA:
1755 if (alim.rlim_cur > MAXDSIZ32)
1756 alim.rlim_cur = MAXDSIZ32;
1757 if (alim.rlim_max > MAXDSIZ32)
1758 alim.rlim_max = MAXDSIZ32;
1759 break;
1760
1761 case RLIMIT_STACK:
1762 if (alim.rlim_cur > MAXSSIZ32)
1763 alim.rlim_cur = MAXSSIZ32;
1764 if (alim.rlim_max > MAXSSIZ32)
1765 alim.rlim_max = MAXSSIZ32;
1766 default:
1767 break;
1768 }
1769
1770 return (dosetrlimit(l, l->l_proc, which, &alim));
1771 }
1772
1773 int
1774 netbsd32_mmap(l, v, retval)
1775 struct lwp *l;
1776 void *v;
1777 register_t *retval;
1778 {
1779 struct netbsd32_mmap_args /* {
1780 syscallarg(netbsd32_voidp) addr;
1781 syscallarg(netbsd32_size_t) len;
1782 syscallarg(int) prot;
1783 syscallarg(int) flags;
1784 syscallarg(int) fd;
1785 syscallarg(netbsd32_long) pad;
1786 syscallarg(off_t) pos;
1787 } */ *uap = v;
1788 struct sys_mmap_args ua;
1789 int error;
1790
1791 NETBSD32TOP_UAP(addr, void);
1792 NETBSD32TOX_UAP(len, size_t);
1793 NETBSD32TO64_UAP(prot);
1794 NETBSD32TO64_UAP(flags);
1795 NETBSD32TO64_UAP(fd);
1796 NETBSD32TOX_UAP(pad, long);
1797 NETBSD32TOX_UAP(pos, off_t);
1798 error = sys_mmap(l, &ua, retval);
1799 if ((u_long)*retval > (u_long)UINT_MAX) {
1800 printf("netbsd32_mmap: retval out of range: 0x%lx",
1801 (u_long)*retval);
1802 /* Should try to recover and return an error here. */
1803 }
1804 return (error);
1805 }
1806
1807 int
1808 netbsd32_lseek(l, v, retval)
1809 struct lwp *l;
1810 void *v;
1811 register_t *retval;
1812 {
1813 struct netbsd32_lseek_args /* {
1814 syscallarg(int) fd;
1815 syscallarg(int) pad;
1816 syscallarg(off_t) offset;
1817 syscallarg(int) whence;
1818 } */ *uap = v;
1819 struct sys_lseek_args ua;
1820 int rv;
1821
1822 NETBSD32TO64_UAP(fd);
1823 NETBSD32TO64_UAP(pad);
1824 NETBSD32TO64_UAP(offset);
1825 NETBSD32TO64_UAP(whence);
1826 rv = sys_lseek(l, &ua, retval);
1827 #ifdef NETBSD32_OFF_T_RETURN
1828 if (rv == 0)
1829 NETBSD32_OFF_T_RETURN(retval);
1830 #endif
1831 return rv;
1832 }
1833
1834 int
1835 netbsd32_truncate(l, v, retval)
1836 struct lwp *l;
1837 void *v;
1838 register_t *retval;
1839 {
1840 struct netbsd32_truncate_args /* {
1841 syscallarg(const netbsd32_charp) path;
1842 syscallarg(int) pad;
1843 syscallarg(off_t) length;
1844 } */ *uap = v;
1845 struct sys_truncate_args ua;
1846
1847 NETBSD32TOP_UAP(path, const char);
1848 NETBSD32TO64_UAP(pad);
1849 NETBSD32TO64_UAP(length);
1850 return (sys_truncate(l, &ua, retval));
1851 }
1852
1853 int
1854 netbsd32_ftruncate(l, v, retval)
1855 struct lwp *l;
1856 void *v;
1857 register_t *retval;
1858 {
1859 struct netbsd32_ftruncate_args /* {
1860 syscallarg(int) fd;
1861 syscallarg(int) pad;
1862 syscallarg(off_t) length;
1863 } */ *uap = v;
1864 struct sys_ftruncate_args ua;
1865
1866 NETBSD32TO64_UAP(fd);
1867 NETBSD32TO64_UAP(pad);
1868 NETBSD32TO64_UAP(length);
1869 return (sys_ftruncate(l, &ua, retval));
1870 }
1871
1872 int
1873 netbsd32_mlock(l, v, retval)
1874 struct lwp *l;
1875 void *v;
1876 register_t *retval;
1877 {
1878 struct netbsd32_mlock_args /* {
1879 syscallarg(const netbsd32_voidp) addr;
1880 syscallarg(netbsd32_size_t) len;
1881 } */ *uap = v;
1882 struct sys_mlock_args ua;
1883
1884 NETBSD32TOP_UAP(addr, const void);
1885 NETBSD32TO64_UAP(len);
1886 return (sys_mlock(l, &ua, retval));
1887 }
1888
1889 int
1890 netbsd32_munlock(l, v, retval)
1891 struct lwp *l;
1892 void *v;
1893 register_t *retval;
1894 {
1895 struct netbsd32_munlock_args /* {
1896 syscallarg(const netbsd32_voidp) addr;
1897 syscallarg(netbsd32_size_t) len;
1898 } */ *uap = v;
1899 struct sys_munlock_args ua;
1900
1901 NETBSD32TOP_UAP(addr, const void);
1902 NETBSD32TO64_UAP(len);
1903 return (sys_munlock(l, &ua, retval));
1904 }
1905
1906 int
1907 netbsd32_undelete(l, v, retval)
1908 struct lwp *l;
1909 void *v;
1910 register_t *retval;
1911 {
1912 struct netbsd32_undelete_args /* {
1913 syscallarg(const netbsd32_charp) path;
1914 } */ *uap = v;
1915 struct sys_undelete_args ua;
1916
1917 NETBSD32TOP_UAP(path, const char);
1918 return (sys_undelete(l, &ua, retval));
1919 }
1920
1921 int
1922 netbsd32_getpgid(l, v, retval)
1923 struct lwp *l;
1924 void *v;
1925 register_t *retval;
1926 {
1927 struct netbsd32_getpgid_args /* {
1928 syscallarg(pid_t) pid;
1929 } */ *uap = v;
1930 struct sys_getpgid_args ua;
1931
1932 NETBSD32TO64_UAP(pid);
1933 return (sys_getpgid(l, &ua, retval));
1934 }
1935
1936 int
1937 netbsd32_reboot(l, v, retval)
1938 struct lwp *l;
1939 void *v;
1940 register_t *retval;
1941 {
1942 struct netbsd32_reboot_args /* {
1943 syscallarg(int) opt;
1944 syscallarg(netbsd32_charp) bootstr;
1945 } */ *uap = v;
1946 struct sys_reboot_args ua;
1947
1948 NETBSD32TO64_UAP(opt);
1949 NETBSD32TOP_UAP(bootstr, char);
1950 return (sys_reboot(l, &ua, retval));
1951 }
1952
1953 #include <sys/poll.h>
1954 int
1955 netbsd32_poll(l, v, retval)
1956 struct lwp *l;
1957 void *v;
1958 register_t *retval;
1959 {
1960 struct netbsd32_poll_args /* {
1961 syscallarg(netbsd32_pollfdp_t) fds;
1962 syscallarg(u_int) nfds;
1963 syscallarg(int) timeout;
1964 } */ *uap = v;
1965 struct sys_poll_args ua;
1966
1967 NETBSD32TOP_UAP(fds, struct pollfd);
1968 NETBSD32TO64_UAP(nfds);
1969 NETBSD32TO64_UAP(timeout);
1970
1971 return (sys_poll(l, &ua, retval));
1972 }
1973
1974 int
1975 netbsd32_fdatasync(l, v, retval)
1976 struct lwp *l;
1977 void *v;
1978 register_t *retval;
1979 {
1980 struct netbsd32_fdatasync_args /* {
1981 syscallarg(int) fd;
1982 } */ *uap = v;
1983 struct sys_fdatasync_args ua;
1984
1985 NETBSD32TO64_UAP(fd);
1986 return (sys_fdatasync(l, &ua, retval));
1987 }
1988
1989 int
1990 netbsd32___posix_rename(l, v, retval)
1991 struct lwp *l;
1992 void *v;
1993 register_t *retval;
1994 {
1995 struct netbsd32___posix_rename_args /* {
1996 syscallarg(const netbsd32_charp) from;
1997 syscallarg(const netbsd32_charp) to;
1998 } */ *uap = v;
1999 struct sys___posix_rename_args ua;
2000
2001 NETBSD32TOP_UAP(from, const char);
2002 NETBSD32TOP_UAP(to, const char);
2003 return (sys___posix_rename(l, &ua, retval));
2004 }
2005
2006 int
2007 netbsd32_swapctl(l, v, retval)
2008 struct lwp *l;
2009 void *v;
2010 register_t *retval;
2011 {
2012 struct netbsd32_swapctl_args /* {
2013 syscallarg(int) cmd;
2014 syscallarg(const netbsd32_voidp) arg;
2015 syscallarg(int) misc;
2016 } */ *uap = v;
2017 struct sys_swapctl_args ua;
2018
2019 NETBSD32TO64_UAP(cmd);
2020 NETBSD32TOP_UAP(arg, void);
2021 NETBSD32TO64_UAP(misc);
2022 return (sys_swapctl(l, &ua, retval));
2023 }
2024
2025 int
2026 netbsd32_minherit(l, v, retval)
2027 struct lwp *l;
2028 void *v;
2029 register_t *retval;
2030 {
2031 struct netbsd32_minherit_args /* {
2032 syscallarg(netbsd32_voidp) addr;
2033 syscallarg(netbsd32_size_t) len;
2034 syscallarg(int) inherit;
2035 } */ *uap = v;
2036 struct sys_minherit_args ua;
2037
2038 NETBSD32TOP_UAP(addr, void);
2039 NETBSD32TOX_UAP(len, size_t);
2040 NETBSD32TO64_UAP(inherit);
2041 return (sys_minherit(l, &ua, retval));
2042 }
2043
2044 int
2045 netbsd32_lchmod(l, v, retval)
2046 struct lwp *l;
2047 void *v;
2048 register_t *retval;
2049 {
2050 struct netbsd32_lchmod_args /* {
2051 syscallarg(const netbsd32_charp) path;
2052 syscallarg(mode_t) mode;
2053 } */ *uap = v;
2054 struct sys_lchmod_args ua;
2055
2056 NETBSD32TOP_UAP(path, const char);
2057 NETBSD32TO64_UAP(mode);
2058 return (sys_lchmod(l, &ua, retval));
2059 }
2060
2061 int
2062 netbsd32_lchown(l, v, retval)
2063 struct lwp *l;
2064 void *v;
2065 register_t *retval;
2066 {
2067 struct netbsd32_lchown_args /* {
2068 syscallarg(const netbsd32_charp) path;
2069 syscallarg(uid_t) uid;
2070 syscallarg(gid_t) gid;
2071 } */ *uap = v;
2072 struct sys_lchown_args ua;
2073
2074 NETBSD32TOP_UAP(path, const char);
2075 NETBSD32TO64_UAP(uid);
2076 NETBSD32TO64_UAP(gid);
2077 return (sys_lchown(l, &ua, retval));
2078 }
2079
2080 int
2081 netbsd32___msync13(l, v, retval)
2082 struct lwp *l;
2083 void *v;
2084 register_t *retval;
2085 {
2086 struct netbsd32___msync13_args /* {
2087 syscallarg(netbsd32_voidp) addr;
2088 syscallarg(netbsd32_size_t) len;
2089 syscallarg(int) flags;
2090 } */ *uap = v;
2091 struct sys___msync13_args ua;
2092
2093 NETBSD32TOP_UAP(addr, void);
2094 NETBSD32TOX_UAP(len, size_t);
2095 NETBSD32TO64_UAP(flags);
2096 return (sys___msync13(l, &ua, retval));
2097 }
2098
2099 int
2100 netbsd32___posix_chown(l, v, retval)
2101 struct lwp *l;
2102 void *v;
2103 register_t *retval;
2104 {
2105 struct netbsd32___posix_chown_args /* {
2106 syscallarg(const netbsd32_charp) path;
2107 syscallarg(uid_t) uid;
2108 syscallarg(gid_t) gid;
2109 } */ *uap = v;
2110 struct sys___posix_chown_args ua;
2111
2112 NETBSD32TOP_UAP(path, const char);
2113 NETBSD32TO64_UAP(uid);
2114 NETBSD32TO64_UAP(gid);
2115 return (sys___posix_chown(l, &ua, retval));
2116 }
2117
2118 int
2119 netbsd32___posix_fchown(l, v, retval)
2120 struct lwp *l;
2121 void *v;
2122 register_t *retval;
2123 {
2124 struct netbsd32___posix_fchown_args /* {
2125 syscallarg(int) fd;
2126 syscallarg(uid_t) uid;
2127 syscallarg(gid_t) gid;
2128 } */ *uap = v;
2129 struct sys___posix_fchown_args ua;
2130
2131 NETBSD32TO64_UAP(fd);
2132 NETBSD32TO64_UAP(uid);
2133 NETBSD32TO64_UAP(gid);
2134 return (sys___posix_fchown(l, &ua, retval));
2135 }
2136
2137 int
2138 netbsd32___posix_lchown(l, v, retval)
2139 struct lwp *l;
2140 void *v;
2141 register_t *retval;
2142 {
2143 struct netbsd32___posix_lchown_args /* {
2144 syscallarg(const netbsd32_charp) path;
2145 syscallarg(uid_t) uid;
2146 syscallarg(gid_t) gid;
2147 } */ *uap = v;
2148 struct sys___posix_lchown_args ua;
2149
2150 NETBSD32TOP_UAP(path, const char);
2151 NETBSD32TO64_UAP(uid);
2152 NETBSD32TO64_UAP(gid);
2153 return (sys___posix_lchown(l, &ua, retval));
2154 }
2155
2156 int
2157 netbsd32_getsid(l, v, retval)
2158 struct lwp *l;
2159 void *v;
2160 register_t *retval;
2161 {
2162 struct netbsd32_getsid_args /* {
2163 syscallarg(pid_t) pid;
2164 } */ *uap = v;
2165 struct sys_getsid_args ua;
2166
2167 NETBSD32TO64_UAP(pid);
2168 return (sys_getsid(l, &ua, retval));
2169 }
2170
2171 #ifdef KTRACE
2172 int
2173 netbsd32_fktrace(l, v, retval)
2174 struct lwp *l;
2175 void *v;
2176 register_t *retval;
2177 {
2178 struct netbsd32_fktrace_args /* {
2179 syscallarg(const int) fd;
2180 syscallarg(int) ops;
2181 syscallarg(int) facs;
2182 syscallarg(int) pid;
2183 } */ *uap = v;
2184 #if 0
2185 struct sys_fktrace_args ua;
2186 #else
2187 /* XXXX */
2188 struct sys_fktrace_noconst_args {
2189 syscallarg(int) fd;
2190 syscallarg(int) ops;
2191 syscallarg(int) facs;
2192 syscallarg(int) pid;
2193 } ua;
2194 #endif
2195
2196 NETBSD32TOX_UAP(fd, int);
2197 NETBSD32TO64_UAP(ops);
2198 NETBSD32TO64_UAP(facs);
2199 NETBSD32TO64_UAP(pid);
2200 return (sys_fktrace(l, &ua, retval));
2201 }
2202 #endif /* KTRACE */
2203
2204 int netbsd32___sigpending14(l, v, retval)
2205 struct lwp *l;
2206 void *v;
2207 register_t *retval;
2208 {
2209 struct netbsd32___sigpending14_args /* {
2210 syscallarg(sigset_t *) set;
2211 } */ *uap = v;
2212 struct sys___sigpending14_args ua;
2213
2214 NETBSD32TOP_UAP(set, sigset_t);
2215 return (sys___sigpending14(l, &ua, retval));
2216 }
2217
2218 int netbsd32___sigprocmask14(l, v, retval)
2219 struct lwp *l;
2220 void *v;
2221 register_t *retval;
2222 {
2223 struct netbsd32___sigprocmask14_args /* {
2224 syscallarg(int) how;
2225 syscallarg(const sigset_t *) set;
2226 syscallarg(sigset_t *) oset;
2227 } */ *uap = v;
2228 struct sys___sigprocmask14_args ua;
2229
2230 NETBSD32TO64_UAP(how);
2231 NETBSD32TOP_UAP(set, sigset_t);
2232 NETBSD32TOP_UAP(oset, sigset_t);
2233 return (sys___sigprocmask14(l, &ua, retval));
2234 }
2235
2236 int netbsd32___sigsuspend14(l, v, retval)
2237 struct lwp *l;
2238 void *v;
2239 register_t *retval;
2240 {
2241 struct netbsd32___sigsuspend14_args /* {
2242 syscallarg(const sigset_t *) set;
2243 } */ *uap = v;
2244 struct sys___sigsuspend14_args ua;
2245
2246 NETBSD32TOP_UAP(set, sigset_t);
2247 return (sys___sigsuspend14(l, &ua, retval));
2248 };
2249
2250 int netbsd32_fchroot(l, v, retval)
2251 struct lwp *l;
2252 void *v;
2253 register_t *retval;
2254 {
2255 struct netbsd32_fchroot_args /* {
2256 syscallarg(int) fd;
2257 } */ *uap = v;
2258 struct sys_fchroot_args ua;
2259
2260 NETBSD32TO64_UAP(fd);
2261 return (sys_fchroot(l, &ua, retval));
2262 }
2263
2264 /*
2265 * Open a file given a file handle.
2266 *
2267 * Check permissions, allocate an open file structure,
2268 * and call the device open routine if any.
2269 */
2270 int
2271 netbsd32___fhopen40(l, v, retval)
2272 struct lwp *l;
2273 void *v;
2274 register_t *retval;
2275 {
2276 struct netbsd32___fhopen40_args /* {
2277 syscallarg(const netbsd32_pointer_t *) fhp;
2278 syscallarg(netbsd32_size_t) fh_size;
2279 syscallarg(int) flags;
2280 } */ *uap = v;
2281 struct sys___fhopen40_args ua;
2282
2283 NETBSD32TOP_UAP(fhp, fhandle_t);
2284 NETBSD32TO64_UAP(fh_size);
2285 NETBSD32TO64_UAP(flags);
2286 return (sys___fhopen40(l, &ua, retval));
2287 }
2288
2289 /* virtual memory syscalls */
2290 int
2291 netbsd32_ovadvise(l, v, retval)
2292 struct lwp *l;
2293 void *v;
2294 register_t *retval;
2295 {
2296 struct netbsd32_ovadvise_args /* {
2297 syscallarg(int) anom;
2298 } */ *uap = v;
2299 struct sys_ovadvise_args ua;
2300
2301 NETBSD32TO64_UAP(anom);
2302 return (sys_ovadvise(l, &ua, retval));
2303 }
2304
2305 void
2306 netbsd32_adjust_limits(struct proc *p)
2307 {
2308 rlim_t *valp;
2309
2310 valp = &p->p_rlimit[RLIMIT_DATA].rlim_cur;
2311 if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
2312 *valp = MAXDSIZ32;
2313 valp = &p->p_rlimit[RLIMIT_DATA].rlim_max;
2314 if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
2315 *valp = MAXDSIZ32;
2316
2317 valp = &p->p_rlimit[RLIMIT_STACK].rlim_cur;
2318 if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
2319 *valp = MAXSSIZ32;
2320 valp = &p->p_rlimit[RLIMIT_STACK].rlim_max;
2321 if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
2322 *valp = MAXSSIZ32;
2323 }
2324
2325 int
2326 netbsd32_uuidgen(struct lwp *l, void *v, register_t *retval)
2327 {
2328 struct netbsd32_uuidgen_args /* {
2329 syscallarg(netbsd32_uuidp_t) store;
2330 syscallarg(int) count;
2331 } */ *uap = v;
2332 struct sys_uuidgen_args ua;
2333
2334 NETBSD32TOP_UAP(store, struct uuid);
2335 NETBSD32TO64_UAP(count);
2336 return (sys_uuidgen(l, &ua, retval));
2337 }
2338
2339 int
2340 netbsd32_extattrctl(struct lwp *l, void *v, register_t *retval)
2341 {
2342 struct netbsd32_extattrctl_args /* {
2343 syscallarg(const netbsd32_charp) path;
2344 syscallarg(int) cmd;
2345 syscallarg(const netbsd32_charp) filename;
2346 syscallarg(int) attrnamespace;
2347 syscallarg(const netbsd32_charp) attrname;
2348 } */ *uap = v;
2349 struct sys_extattrctl_args ua;
2350
2351 NETBSD32TOP_UAP(path, const char);
2352 NETBSD32TO64_UAP(cmd);
2353 NETBSD32TOP_UAP(filename, const char);
2354 NETBSD32TO64_UAP(attrnamespace);
2355 NETBSD32TOP_UAP(attrname, const char);
2356 return sys_extattrctl(l, &ua, retval);
2357 }
2358
2359 int
2360 netbsd32_extattr_set_fd(struct lwp *l, void *v, register_t *retval)
2361 {
2362 struct netbsd32_extattr_set_fd_args /* {
2363 syscallarg(int) fd;
2364 syscallarg(int) attrnamespace;
2365 syscallarg(const netbsd32_charp) attrname;
2366 syscallarg(const netbsd32_voidp) data;
2367 syscallarg(netbsd32_size_t) nbytes;
2368 } */ *uap = v;
2369 struct sys_extattr_set_fd_args ua;
2370
2371 NETBSD32TO64_UAP(fd);
2372 NETBSD32TO64_UAP(attrnamespace);
2373 NETBSD32TOP_UAP(attrname, const char);
2374 NETBSD32TOP_UAP(data, const void);
2375 NETBSD32TOX_UAP(nbytes, size_t);
2376 return sys_extattr_set_fd(l, &ua, retval);
2377 }
2378
2379 int
2380 netbsd32_extattr_set_file(struct lwp *l, void *v, register_t *retval)
2381 {
2382 struct netbsd32_extattr_set_file_args /* {
2383 syscallarg(const netbsd32_charp) path;
2384 syscallarg(int) attrnamespace;
2385 syscallarg(const netbsd32_charp) attrname;
2386 syscallarg(const netbsd32_voidp) data;
2387 syscallarg(netbsd32_size_t) nbytes;
2388 } */ *uap = v;
2389 struct sys_extattr_set_file_args ua;
2390
2391 NETBSD32TOP_UAP(path, const char);
2392 NETBSD32TO64_UAP(attrnamespace);
2393 NETBSD32TOP_UAP(attrname, const char);
2394 NETBSD32TOP_UAP(data, const void);
2395 NETBSD32TOX_UAP(nbytes, size_t);
2396 return sys_extattr_set_file(l, &ua, retval);
2397 }
2398
2399 int
2400 netbsd32_extattr_set_link(struct lwp *l, void *v, register_t *retval)
2401 {
2402 struct netbsd32_extattr_set_link_args /* {
2403 syscallarg(const netbsd32_charp) path;
2404 syscallarg(int) attrnamespace;
2405 syscallarg(const netbsd32_charp) attrname;
2406 syscallarg(const netbsd32_voidp) data;
2407 syscallarg(netbsd32_size_t) nbytes;
2408 } */ *uap = v;
2409 struct sys_extattr_set_link_args ua;
2410
2411 NETBSD32TOP_UAP(path, const char);
2412 NETBSD32TO64_UAP(attrnamespace);
2413 NETBSD32TOP_UAP(attrname, const char);
2414 NETBSD32TOP_UAP(data, const void);
2415 NETBSD32TOX_UAP(nbytes, size_t);
2416 return sys_extattr_set_link(l, &ua, retval);
2417 }
2418
2419 int
2420 netbsd32_extattr_get_fd(struct lwp *l, void *v, register_t *retval)
2421 {
2422 struct netbsd32_extattr_get_fd_args /* {
2423 syscallarg(int) fd;
2424 syscallarg(int) attrnamespace;
2425 syscallarg(const netbsd32_charp) attrname;
2426 syscallarg(netbsd32_voidp) data;
2427 syscallarg(netbsd32_size_t) nbytes;
2428 } */ *uap = v;
2429 struct sys_extattr_get_fd_args ua;
2430
2431 NETBSD32TO64_UAP(fd);
2432 NETBSD32TO64_UAP(attrnamespace);
2433 NETBSD32TOP_UAP(attrname, const char);
2434 NETBSD32TOP_UAP(data, void);
2435 NETBSD32TOX_UAP(nbytes, size_t);
2436 return sys_extattr_get_fd(l, &ua, retval);
2437 }
2438
2439 int
2440 netbsd32_extattr_get_file(struct lwp *l, void *v, register_t *retval)
2441 {
2442 struct netbsd32_extattr_get_file_args /* {
2443 syscallarg(const netbsd32_charp) path;
2444 syscallarg(int) attrnamespace;
2445 syscallarg(const netbsd32_charp) attrname;
2446 syscallarg(netbsd32_voidp) data;
2447 syscallarg(netbsd32_size_t) nbytes;
2448 } */ *uap = v;
2449 struct sys_extattr_get_file_args ua;
2450
2451 NETBSD32TOP_UAP(path, const char);
2452 NETBSD32TO64_UAP(attrnamespace);
2453 NETBSD32TOP_UAP(attrname, const char);
2454 NETBSD32TOP_UAP(data, void);
2455 NETBSD32TOX_UAP(nbytes, size_t);
2456 return sys_extattr_get_file(l, &ua, retval);
2457 }
2458
2459 int
2460 netbsd32_extattr_get_link(struct lwp *l, void *v, register_t *retval)
2461 {
2462 struct netbsd32_extattr_get_link_args /* {
2463 syscallarg(const netbsd32_charp) path;
2464 syscallarg(int) attrnamespace;
2465 syscallarg(const netbsd32_charp) attrname;
2466 syscallarg(netbsd32_voidp) data;
2467 syscallarg(netbsd32_size_t) nbytes;
2468 } */ *uap = v;
2469 struct sys_extattr_get_link_args ua;
2470
2471 NETBSD32TOP_UAP(path, const char);
2472 NETBSD32TO64_UAP(attrnamespace);
2473 NETBSD32TOP_UAP(attrname, const char);
2474 NETBSD32TOP_UAP(data, void);
2475 NETBSD32TOX_UAP(nbytes, size_t);
2476 return sys_extattr_get_link(l, &ua, retval);
2477 }
2478
2479 int
2480 netbsd32_extattr_delete_fd(struct lwp *l, void *v, register_t *retval)
2481 {
2482 struct netbsd32_extattr_delete_fd_args /* {
2483 syscallarg(int) fd;
2484 syscallarg(int) attrnamespace;
2485 syscallarg(const netbsd32_charp) attrname;
2486 } */ *uap = v;
2487 struct sys_extattr_delete_fd_args ua;
2488
2489 NETBSD32TO64_UAP(fd);
2490 NETBSD32TO64_UAP(attrnamespace);
2491 NETBSD32TOP_UAP(attrname, const char);
2492 return sys_extattr_delete_fd(l, &ua, retval);
2493 }
2494
2495 int
2496 netbsd32_extattr_delete_file(struct lwp *l, void *v, register_t *retval)
2497 {
2498 struct netbsd32_extattr_delete_file_args /* {
2499 syscallarg(const netbsd32_charp) path;
2500 syscallarg(int) attrnamespace;
2501 syscallarg(const netbsd32_charp) attrname;
2502 } */ *uap = v;
2503 struct sys_extattr_delete_file_args ua;
2504
2505 NETBSD32TOP_UAP(path, const char);
2506 NETBSD32TO64_UAP(attrnamespace);
2507 NETBSD32TOP_UAP(attrname, const char);
2508 return sys_extattr_delete_file(l, &ua, retval);
2509 }
2510
2511 int
2512 netbsd32_extattr_delete_link(struct lwp *l, void *v, register_t *retval)
2513 {
2514 struct netbsd32_extattr_delete_link_args /* {
2515 syscallarg(const netbsd32_charp) path;
2516 syscallarg(int) attrnamespace;
2517 syscallarg(const netbsd32_charp) attrname;
2518 } */ *uap = v;
2519 struct sys_extattr_delete_link_args ua;
2520
2521 NETBSD32TOP_UAP(path, const char);
2522 NETBSD32TO64_UAP(attrnamespace);
2523 NETBSD32TOP_UAP(attrname, const char);
2524 return sys_extattr_delete_link(l, &ua, retval);
2525 }
2526
2527 int
2528 netbsd32_extattr_list_fd(struct lwp *l, void *v, register_t *retval)
2529 {
2530 struct netbsd32_extattr_list_fd_args /* {
2531 syscallarg(int) fd;
2532 syscallarg(int) attrnamespace;
2533 syscallarg(netbsd32_voidp) data;
2534 syscallarg(netbsd32_size_t) nbytes;
2535 } */ *uap = v;
2536 struct sys_extattr_list_fd_args ua;
2537
2538 NETBSD32TO64_UAP(fd);
2539 NETBSD32TO64_UAP(attrnamespace);
2540 NETBSD32TOP_UAP(data, void);
2541 NETBSD32TOX_UAP(nbytes, size_t);
2542 return sys_extattr_list_fd(l, &ua, retval);
2543 }
2544
2545 int
2546 netbsd32_extattr_list_file(struct lwp *l, void *v, register_t *retval)
2547 {
2548 struct netbsd32_extattr_list_file_args /* {
2549 syscallarg(const netbsd32_charp) path;
2550 syscallarg(int) attrnamespace;
2551 syscallarg(netbsd32_voidp) data;
2552 syscallarg(netbsd32_size_t) nbytes;
2553 } */ *uap = v;
2554 struct sys_extattr_list_file_args ua;
2555
2556 NETBSD32TOP_UAP(path, const char);
2557 NETBSD32TO64_UAP(attrnamespace);
2558 NETBSD32TOP_UAP(data, void);
2559 NETBSD32TOX_UAP(nbytes, size_t);
2560 return sys_extattr_list_file(l, &ua, retval);
2561 }
2562
2563 int
2564 netbsd32_extattr_list_link(struct lwp *l, void *v, register_t *retval)
2565 {
2566 struct netbsd32_extattr_list_link_args /* {
2567 syscallarg(const netbsd32_charp) path;
2568 syscallarg(int) attrnamespace;
2569 syscallarg(netbsd32_voidp) data;
2570 syscallarg(netbsd32_size_t) nbytes;
2571 } */ *uap = v;
2572 struct sys_extattr_list_link_args ua;
2573
2574 NETBSD32TOP_UAP(path, const char);
2575 NETBSD32TO64_UAP(attrnamespace);
2576 NETBSD32TOP_UAP(data, void);
2577 NETBSD32TOX_UAP(nbytes, size_t);
2578 return sys_extattr_list_link(l, &ua, retval);
2579 }
2580
2581 int
2582 netbsd32_mlockall(l, v, retval)
2583 struct lwp *l;
2584 void *v;
2585 register_t *retval;
2586 {
2587 struct netbsd32_mlockall_args /* {
2588 syscallarg(int) flags;
2589 } */ *uap = v;
2590 struct sys_mlockall_args ua;
2591
2592 NETBSD32TO64_UAP(flags);
2593 return (sys_mlockall(l, &ua, retval));
2594 }
2595
2596 int
2597 netbsd32___clone(struct lwp *l, void *v, register_t *retval)
2598 {
2599 struct netbsd32___clone_args /* {
2600 syscallarg(int) flags;
2601 syscallarg(netbsd32_voidp) stack;
2602 } */ *uap = v;
2603 struct sys___clone_args ua;
2604
2605 NETBSD32TO64_UAP(flags);
2606 NETBSD32TOP_UAP(stack, void);
2607 return sys___clone(l, &ua, retval);
2608 }
2609
2610 int
2611 netbsd32_fsync_range(struct lwp *l, void *v, register_t *retval)
2612 {
2613 struct netbsd32_fsync_range_args /* {
2614 syscallarg(int) fd;
2615 syscallarg(int) flags;
2616 syscallarg(off_t) start;
2617 syscallarg(off_t) length;
2618 } */ *uap = v;
2619 struct sys_fsync_range_args ua;
2620
2621 NETBSD32TO64_UAP(fd);
2622 NETBSD32TO64_UAP(flags);
2623 NETBSD32TO64_UAP(start);
2624 NETBSD32TO64_UAP(length);
2625 return (sys_fsync_range(l, &ua, retval));
2626 }
2627
2628 int
2629 netbsd32_rasctl(struct lwp *l, void *v, register_t *retval)
2630 {
2631 struct netbsd32_rasctl_args /* {
2632 syscallarg(netbsd32_caddr_t) addr;
2633 syscallarg(netbsd32_size_t) len;
2634 syscallarg(int) op;
2635 } */ *uap = v;
2636 struct sys_rasctl_args ua;
2637
2638 NETBSD32TOX64_UAP(addr, caddr_t);
2639 NETBSD32TOX_UAP(len, size_t);
2640 NETBSD32TO64_UAP(op);
2641 return sys_rasctl(l, &ua, retval);
2642 }
2643
2644 int
2645 netbsd32_setxattr(struct lwp *l, void *v, register_t *retval)
2646 {
2647 struct netbsd32_setxattr_args /* {
2648 syscallarg(const netbsd32_charp) path;
2649 syscallarg(const netbsd32_charp) name;
2650 syscallarg(netbsd32_voidp) value;
2651 syscallarg(netbsd32_size_t) size;
2652 syscallarg(int) flags;
2653 } */ *uap = v;
2654 struct sys_setxattr_args ua;
2655 NETBSD32TOP_UAP(path, const char);
2656 NETBSD32TOP_UAP(name, const char);
2657 NETBSD32TOP_UAP(value, void);
2658 NETBSD32TOX_UAP(size, size_t);
2659 NETBSD32TO64_UAP(flags);
2660 return sys_setxattr(l, &ua, retval);
2661 }
2662
2663 int
2664 netbsd32_lsetxattr(struct lwp *l, void *v, register_t *retval)
2665 {
2666 struct netbsd32_lsetxattr_args /* {
2667 syscallarg(const netbsd32_charp) path;
2668 syscallarg(const netbsd32_charp) name;
2669 syscallarg(netbsd32_voidp) value;
2670 syscallarg(netbsd32_size_t) size;
2671 syscallarg(int) flags;
2672 } */ *uap = v;
2673 struct sys_lsetxattr_args ua;
2674 NETBSD32TOP_UAP(path, const char);
2675 NETBSD32TOP_UAP(name, const char);
2676 NETBSD32TOP_UAP(value, void);
2677 NETBSD32TOX_UAP(size, size_t);
2678 NETBSD32TO64_UAP(flags);
2679 return sys_lsetxattr(l, &ua, retval);
2680 }
2681
2682 int
2683 netbsd32_fsetxattr(struct lwp *l, void *v, register_t *retval)
2684 {
2685 struct netbsd32_fsetxattr_args /* {
2686 syscallarg(int) fd;
2687 syscallarg(const netbsd32_charp) name;
2688 syscallarg(netbsd32_voidp) value;
2689 syscallarg(netbsd32_size_t) size;
2690 syscallarg(int) flags;
2691 } */ *uap = v;
2692 struct sys_fsetxattr_args ua;
2693 NETBSD32TO64_UAP(fd);
2694 NETBSD32TOP_UAP(name, const char);
2695 NETBSD32TOP_UAP(value, void);
2696 NETBSD32TOX_UAP(size, size_t);
2697 NETBSD32TO64_UAP(flags);
2698 return sys_fsetxattr(l, &ua, retval);
2699 }
2700
2701 int
2702 netbsd32_getxattr(struct lwp *l, void *v, register_t *retval)
2703 {
2704 struct netbsd32_getxattr_args /* {
2705 syscallarg(const netbsd32_charp) path;
2706 syscallarg(const netbsd32_charp) name;
2707 syscallarg(netbsd32_voidp) value;
2708 syscallarg(netbsd32_size_t) size;
2709 } */ *uap = v;
2710 struct sys_getxattr_args ua;
2711 NETBSD32TOP_UAP(path, const char);
2712 NETBSD32TOP_UAP(name, const char);
2713 NETBSD32TOP_UAP(value, void);
2714 NETBSD32TOX_UAP(size, size_t);
2715 return sys_getxattr(l, &ua, retval);
2716 }
2717
2718 int
2719 netbsd32_lgetxattr(struct lwp *l, void *v, register_t *retval)
2720 {
2721 struct netbsd32_lgetxattr_args /* {
2722 syscallarg(const netbsd32_charp) path;
2723 syscallarg(const netbsd32_charp) name;
2724 syscallarg(netbsd32_voidp) value;
2725 syscallarg(netbsd32_size_t) size;
2726 } */ *uap = v;
2727 struct sys_lgetxattr_args ua;
2728 NETBSD32TOP_UAP(path, const char);
2729 NETBSD32TOP_UAP(name, const char);
2730 NETBSD32TOP_UAP(value, void);
2731 NETBSD32TOX_UAP(size, size_t);
2732 return sys_lgetxattr(l, &ua, retval);
2733 }
2734
2735 int
2736 netbsd32_fgetxattr(struct lwp *l, void *v, register_t *retval)
2737 {
2738 struct netbsd32_fgetxattr_args /* {
2739 syscallarg(int) fd;
2740 syscallarg(const netbsd32_charp) name;
2741 syscallarg(netbsd32_voidp) value;
2742 syscallarg(netbsd32_size_t) size;
2743 } */ *uap = v;
2744 struct sys_fgetxattr_args ua;
2745 NETBSD32TO64_UAP(fd);
2746 NETBSD32TOP_UAP(name, const char);
2747 NETBSD32TOP_UAP(value, void);
2748 NETBSD32TOX_UAP(size, size_t);
2749 return sys_fgetxattr(l, &ua, retval);
2750 }
2751
2752 int
2753 netbsd32_listxattr(struct lwp *l, void *v, register_t *retval)
2754 {
2755 struct netbsd32_listxattr_args /* {
2756 syscallarg(const netbsd32_charp) path;
2757 syscallarg(netbsd32_charp) list;
2758 syscallarg(netbsd32_size_t) size;
2759 } */ *uap = v;
2760 struct sys_listxattr_args ua;
2761 NETBSD32TOP_UAP(path, const char);
2762 NETBSD32TOP_UAP(list, char);
2763 NETBSD32TOX_UAP(size, size_t);
2764 return sys_listxattr(l, &ua, retval);
2765 }
2766
2767 int
2768 netbsd32_llistxattr(struct lwp *l, void *v, register_t *retval)
2769 {
2770 struct netbsd32_llistxattr_args /* {
2771 syscallarg(const netbsd32_charp) path;
2772 syscallarg(netbsd32_charp) list;
2773 syscallarg(netbsd32_size_t) size;
2774 } */ *uap = v;
2775 struct sys_llistxattr_args ua;
2776 NETBSD32TOP_UAP(path, const char);
2777 NETBSD32TOP_UAP(list, char);
2778 NETBSD32TOX_UAP(size, size_t);
2779 return sys_llistxattr(l, &ua, retval);
2780 }
2781
2782 int
2783 netbsd32_flistxattr(struct lwp *l, void *v, register_t *retval)
2784 {
2785 struct netbsd32_flistxattr_args /* {
2786 syscallarg(int) fd;
2787 syscallarg(netbsd32_charp) list;
2788 syscallarg(netbsd32_size_t) size;
2789 } */ *uap = v;
2790 struct sys_flistxattr_args ua;
2791 NETBSD32TO64_UAP(fd);
2792 NETBSD32TOP_UAP(list, char);
2793 NETBSD32TOX_UAP(size, size_t);
2794 return sys_flistxattr(l, &ua, retval);
2795 }
2796
2797 int
2798 netbsd32_removexattr(struct lwp *l, void *v, register_t *retval)
2799 {
2800 struct netbsd32_removexattr_args /* {
2801 syscallarg(const netbsd32_charp) path;
2802 syscallarg(const netbsd32_charp) name;
2803 } */ *uap = v;
2804 struct sys_removexattr_args ua;
2805 NETBSD32TOP_UAP(path, const char);
2806 NETBSD32TOP_UAP(name, const char);
2807 return sys_removexattr(l, &ua, retval);
2808 }
2809
2810 int
2811 netbsd32_lremovexattr(struct lwp *l, void *v, register_t *retval)
2812 {
2813 struct netbsd32_lremovexattr_args /* {
2814 syscallarg(const netbsd32_charp) path;
2815 syscallarg(const netbsd32_charp) name;
2816 } */ *uap = v;
2817 struct sys_lremovexattr_args ua;
2818 NETBSD32TOP_UAP(path, const char);
2819 NETBSD32TOP_UAP(name, const char);
2820 return sys_lremovexattr(l, &ua, retval);
2821 }
2822
2823 int
2824 netbsd32_fremovexattr(struct lwp *l, void *v, register_t *retval)
2825 {
2826 struct netbsd32_fremovexattr_args /* {
2827 syscallarg(int) fd;
2828 syscallarg(const netbsd32_charp) name;
2829 } */ *uap = v;
2830 struct sys_fremovexattr_args ua;
2831 NETBSD32TO64_UAP(fd);
2832 NETBSD32TOP_UAP(name, const char);
2833 return sys_fremovexattr(l, &ua, retval);
2834 }
2835