netbsd32_netbsd.c revision 1.105 1 /* $NetBSD: netbsd32_netbsd.c,v 1.105 2006/06/26 21:23:57 mrg 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.105 2006/06/26 21:23:57 mrg 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 compat_30_netbsd32_socket(l, v, retval)
1103 struct lwp *l;
1104 void *v;
1105 register_t *retval;
1106 {
1107 struct compat_30_netbsd32_socket_args /* {
1108 syscallarg(int) domain;
1109 syscallarg(int) type;
1110 syscallarg(int) protocol;
1111 } */ *uap = v;
1112 struct compat_30_sys_socket_args ua;
1113
1114 NETBSD32TO64_UAP(domain);
1115 NETBSD32TO64_UAP(type);
1116 NETBSD32TO64_UAP(protocol);
1117 return (compat_30_sys_socket(l, &ua, retval));
1118 }
1119
1120 int
1121 netbsd32_sys___socket30(l, v, retval)
1122 struct lwp *l;
1123 void *v;
1124 register_t *retval;
1125 {
1126 struct netbsd32_sys___socket30_args /* {
1127 syscallarg(int) domain;
1128 syscallarg(int) type;
1129 syscallarg(int) protocol;
1130 } */ *uap = v;
1131 struct sys___socket30_args ua;
1132
1133 NETBSD32TO64_UAP(domain);
1134 NETBSD32TO64_UAP(type);
1135 NETBSD32TO64_UAP(protocol);
1136 return (sys___socket30(l, &ua, retval));
1137 }
1138
1139 int
1140 netbsd32_connect(l, v, retval)
1141 struct lwp *l;
1142 void *v;
1143 register_t *retval;
1144 {
1145 struct netbsd32_connect_args /* {
1146 syscallarg(int) s;
1147 syscallarg(const netbsd32_sockaddrp_t) name;
1148 syscallarg(int) namelen;
1149 } */ *uap = v;
1150 struct sys_connect_args ua;
1151
1152 NETBSD32TO64_UAP(s);
1153 NETBSD32TOP_UAP(name, struct sockaddr);
1154 NETBSD32TO64_UAP(namelen);
1155 return (sys_connect(l, &ua, retval));
1156 }
1157
1158 int
1159 netbsd32_getpriority(l, v, retval)
1160 struct lwp *l;
1161 void *v;
1162 register_t *retval;
1163 {
1164 struct netbsd32_getpriority_args /* {
1165 syscallarg(int) which;
1166 syscallarg(int) who;
1167 } */ *uap = v;
1168 struct sys_getpriority_args ua;
1169
1170 NETBSD32TO64_UAP(which);
1171 NETBSD32TO64_UAP(who);
1172 return (sys_getpriority(l, &ua, retval));
1173 }
1174
1175 int
1176 netbsd32_bind(l, v, retval)
1177 struct lwp *l;
1178 void *v;
1179 register_t *retval;
1180 {
1181 struct netbsd32_bind_args /* {
1182 syscallarg(int) s;
1183 syscallarg(const netbsd32_sockaddrp_t) name;
1184 syscallarg(int) namelen;
1185 } */ *uap = v;
1186 struct sys_bind_args ua;
1187
1188 NETBSD32TO64_UAP(s);
1189 NETBSD32TOP_UAP(name, struct sockaddr);
1190 NETBSD32TO64_UAP(namelen);
1191 return (sys_bind(l, &ua, retval));
1192 }
1193
1194 int
1195 netbsd32_setsockopt(l, v, retval)
1196 struct lwp *l;
1197 void *v;
1198 register_t *retval;
1199 {
1200 struct netbsd32_setsockopt_args /* {
1201 syscallarg(int) s;
1202 syscallarg(int) level;
1203 syscallarg(int) name;
1204 syscallarg(const netbsd32_voidp) val;
1205 syscallarg(int) valsize;
1206 } */ *uap = v;
1207 struct sys_setsockopt_args ua;
1208
1209 NETBSD32TO64_UAP(s);
1210 NETBSD32TO64_UAP(level);
1211 NETBSD32TO64_UAP(name);
1212 NETBSD32TOP_UAP(val, void);
1213 NETBSD32TO64_UAP(valsize);
1214 /* may be more efficient to do this inline. */
1215 return (sys_setsockopt(l, &ua, retval));
1216 }
1217
1218 int
1219 netbsd32_listen(l, v, retval)
1220 struct lwp *l;
1221 void *v;
1222 register_t *retval;
1223 {
1224 struct netbsd32_listen_args /* {
1225 syscallarg(int) s;
1226 syscallarg(int) backlog;
1227 } */ *uap = v;
1228 struct sys_listen_args ua;
1229
1230 NETBSD32TO64_UAP(s);
1231 NETBSD32TO64_UAP(backlog);
1232 return (sys_listen(l, &ua, retval));
1233 }
1234
1235 int
1236 netbsd32_fchown(l, v, retval)
1237 struct lwp *l;
1238 void *v;
1239 register_t *retval;
1240 {
1241 struct netbsd32_fchown_args /* {
1242 syscallarg(int) fd;
1243 syscallarg(uid_t) uid;
1244 syscallarg(gid_t) gid;
1245 } */ *uap = v;
1246 struct sys_fchown_args ua;
1247
1248 NETBSD32TO64_UAP(fd);
1249 NETBSD32TO64_UAP(uid);
1250 NETBSD32TO64_UAP(gid);
1251 return (sys_fchown(l, &ua, retval));
1252 }
1253
1254 int
1255 netbsd32_fchmod(l, v, retval)
1256 struct lwp *l;
1257 void *v;
1258 register_t *retval;
1259 {
1260 struct netbsd32_fchmod_args /* {
1261 syscallarg(int) fd;
1262 syscallarg(mode_t) mode;
1263 } */ *uap = v;
1264 struct sys_fchmod_args ua;
1265
1266 NETBSD32TO64_UAP(fd);
1267 NETBSD32TO64_UAP(mode);
1268 return (sys_fchmod(l, &ua, retval));
1269 }
1270
1271 int
1272 netbsd32_setreuid(l, v, retval)
1273 struct lwp *l;
1274 void *v;
1275 register_t *retval;
1276 {
1277 struct netbsd32_setreuid_args /* {
1278 syscallarg(uid_t) ruid;
1279 syscallarg(uid_t) euid;
1280 } */ *uap = v;
1281 struct sys_setreuid_args ua;
1282
1283 NETBSD32TO64_UAP(ruid);
1284 NETBSD32TO64_UAP(euid);
1285 return (sys_setreuid(l, &ua, retval));
1286 }
1287
1288 int
1289 netbsd32_setregid(l, v, retval)
1290 struct lwp *l;
1291 void *v;
1292 register_t *retval;
1293 {
1294 struct netbsd32_setregid_args /* {
1295 syscallarg(gid_t) rgid;
1296 syscallarg(gid_t) egid;
1297 } */ *uap = v;
1298 struct sys_setregid_args ua;
1299
1300 NETBSD32TO64_UAP(rgid);
1301 NETBSD32TO64_UAP(egid);
1302 return (sys_setregid(l, &ua, retval));
1303 }
1304
1305 int
1306 netbsd32_getsockopt(l, v, retval)
1307 struct lwp *l;
1308 void *v;
1309 register_t *retval;
1310 {
1311 struct netbsd32_getsockopt_args /* {
1312 syscallarg(int) s;
1313 syscallarg(int) level;
1314 syscallarg(int) name;
1315 syscallarg(netbsd32_voidp) val;
1316 syscallarg(netbsd32_intp) avalsize;
1317 } */ *uap = v;
1318 struct sys_getsockopt_args ua;
1319
1320 NETBSD32TO64_UAP(s);
1321 NETBSD32TO64_UAP(level);
1322 NETBSD32TO64_UAP(name);
1323 NETBSD32TOP_UAP(val, void);
1324 NETBSD32TOP_UAP(avalsize, socklen_t);
1325 return (sys_getsockopt(l, &ua, retval));
1326 }
1327
1328 int
1329 netbsd32_rename(l, v, retval)
1330 struct lwp *l;
1331 void *v;
1332 register_t *retval;
1333 {
1334 struct netbsd32_rename_args /* {
1335 syscallarg(const netbsd32_charp) from;
1336 syscallarg(const netbsd32_charp) to;
1337 } */ *uap = v;
1338 struct sys_rename_args ua;
1339
1340 NETBSD32TOP_UAP(from, const char);
1341 NETBSD32TOP_UAP(to, const char)
1342
1343 return (sys_rename(l, &ua, retval));
1344 }
1345
1346 int
1347 netbsd32_flock(l, v, retval)
1348 struct lwp *l;
1349 void *v;
1350 register_t *retval;
1351 {
1352 struct netbsd32_flock_args /* {
1353 syscallarg(int) fd;
1354 syscallarg(int) how;
1355 } */ *uap = v;
1356 struct sys_flock_args ua;
1357
1358 NETBSD32TO64_UAP(fd);
1359 NETBSD32TO64_UAP(how)
1360
1361 return (sys_flock(l, &ua, retval));
1362 }
1363
1364 int
1365 netbsd32_mkfifo(l, v, retval)
1366 struct lwp *l;
1367 void *v;
1368 register_t *retval;
1369 {
1370 struct netbsd32_mkfifo_args /* {
1371 syscallarg(const netbsd32_charp) path;
1372 syscallarg(mode_t) mode;
1373 } */ *uap = v;
1374 struct sys_mkfifo_args ua;
1375
1376 NETBSD32TOP_UAP(path, const char)
1377 NETBSD32TO64_UAP(mode);
1378 return (sys_mkfifo(l, &ua, retval));
1379 }
1380
1381 int
1382 netbsd32_shutdown(l, v, retval)
1383 struct lwp *l;
1384 void *v;
1385 register_t *retval;
1386 {
1387 struct netbsd32_shutdown_args /* {
1388 syscallarg(int) s;
1389 syscallarg(int) how;
1390 } */ *uap = v;
1391 struct sys_shutdown_args ua;
1392
1393 NETBSD32TO64_UAP(s)
1394 NETBSD32TO64_UAP(how);
1395 return (sys_shutdown(l, &ua, retval));
1396 }
1397
1398 int
1399 netbsd32_socketpair(l, v, retval)
1400 struct lwp *l;
1401 void *v;
1402 register_t *retval;
1403 {
1404 struct netbsd32_socketpair_args /* {
1405 syscallarg(int) domain;
1406 syscallarg(int) type;
1407 syscallarg(int) protocol;
1408 syscallarg(netbsd32_intp) rsv;
1409 } */ *uap = v;
1410 struct sys_socketpair_args ua;
1411
1412 NETBSD32TO64_UAP(domain);
1413 NETBSD32TO64_UAP(type);
1414 NETBSD32TO64_UAP(protocol);
1415 NETBSD32TOP_UAP(rsv, int);
1416 /* Since we're just copying out two `int's we can do this */
1417 return (sys_socketpair(l, &ua, retval));
1418 }
1419
1420 int
1421 netbsd32_mkdir(l, v, retval)
1422 struct lwp *l;
1423 void *v;
1424 register_t *retval;
1425 {
1426 struct netbsd32_mkdir_args /* {
1427 syscallarg(const netbsd32_charp) path;
1428 syscallarg(mode_t) mode;
1429 } */ *uap = v;
1430 struct sys_mkdir_args ua;
1431
1432 NETBSD32TOP_UAP(path, const char)
1433 NETBSD32TO64_UAP(mode);
1434 return (sys_mkdir(l, &ua, retval));
1435 }
1436
1437 int
1438 netbsd32_rmdir(l, v, retval)
1439 struct lwp *l;
1440 void *v;
1441 register_t *retval;
1442 {
1443 struct netbsd32_rmdir_args /* {
1444 syscallarg(const netbsd32_charp) path;
1445 } */ *uap = v;
1446 struct sys_rmdir_args ua;
1447
1448 NETBSD32TOP_UAP(path, const char);
1449 return (sys_rmdir(l, &ua, retval));
1450 }
1451
1452 int
1453 netbsd32_quotactl(l, v, retval)
1454 struct lwp *l;
1455 void *v;
1456 register_t *retval;
1457 {
1458 struct netbsd32_quotactl_args /* {
1459 syscallarg(const netbsd32_charp) path;
1460 syscallarg(int) cmd;
1461 syscallarg(int) uid;
1462 syscallarg(netbsd32_caddr_t) arg;
1463 } */ *uap = v;
1464 struct sys_quotactl_args ua;
1465
1466 NETBSD32TOP_UAP(path, const char);
1467 NETBSD32TO64_UAP(cmd);
1468 NETBSD32TO64_UAP(uid);
1469 NETBSD32TOX64_UAP(arg, caddr_t);
1470 return (sys_quotactl(l, &ua, retval));
1471 }
1472
1473 #if defined(NFS) || defined(NFSSERVER)
1474 int
1475 netbsd32_nfssvc(l, v, retval)
1476 struct lwp *l;
1477 void *v;
1478 register_t *retval;
1479 {
1480 #if 0
1481 struct netbsd32_nfssvc_args /* {
1482 syscallarg(int) flag;
1483 syscallarg(netbsd32_voidp) argp;
1484 } */ *uap = v;
1485 struct sys_nfssvc_args ua;
1486
1487 NETBSD32TO64_UAP(flag);
1488 NETBSD32TOP_UAP(argp, void);
1489 return (sys_nfssvc(l, &ua, retval));
1490 #else
1491 /* Why would we want to support a 32-bit nfsd? */
1492 return (ENOSYS);
1493 #endif
1494 }
1495 #endif
1496
1497 #if defined(NFS) || defined(NFSSERVER)
1498 int
1499 netbsd32_getfh(l, v, retval)
1500 struct lwp *l;
1501 void *v;
1502 register_t *retval;
1503 {
1504 struct netbsd32_getfh_args /* {
1505 syscallarg(const netbsd32_charp) fname;
1506 syscallarg(netbsd32_fhandlep_t) fhp;
1507 } */ *uap = v;
1508 struct sys_getfh_args ua;
1509
1510 NETBSD32TOP_UAP(fname, const char);
1511 NETBSD32TOP_UAP(fhp, struct fhandle);
1512 /* Lucky for us a fhandlep_t doesn't change sizes */
1513 return (sys_getfh(l, &ua, retval));
1514 }
1515 #endif
1516
1517 int
1518 netbsd32_pread(l, v, retval)
1519 struct lwp *l;
1520 void *v;
1521 register_t *retval;
1522 {
1523 struct netbsd32_pread_args /* {
1524 syscallarg(int) fd;
1525 syscallarg(netbsd32_voidp) buf;
1526 syscallarg(netbsd32_size_t) nbyte;
1527 syscallarg(int) pad;
1528 syscallarg(off_t) offset;
1529 } */ *uap = v;
1530 struct sys_pread_args ua;
1531 ssize_t rt;
1532 int error;
1533
1534 NETBSD32TO64_UAP(fd);
1535 NETBSD32TOP_UAP(buf, void);
1536 NETBSD32TOX_UAP(nbyte, size_t);
1537 NETBSD32TO64_UAP(pad);
1538 NETBSD32TO64_UAP(offset);
1539 error = sys_pread(l, &ua, (register_t *)&rt);
1540 *retval = rt;
1541 return (error);
1542 }
1543
1544 int
1545 netbsd32_pwrite(l, v, retval)
1546 struct lwp *l;
1547 void *v;
1548 register_t *retval;
1549 {
1550 struct netbsd32_pwrite_args /* {
1551 syscallarg(int) fd;
1552 syscallarg(const netbsd32_voidp) buf;
1553 syscallarg(netbsd32_size_t) nbyte;
1554 syscallarg(int) pad;
1555 syscallarg(off_t) offset;
1556 } */ *uap = v;
1557 struct sys_pwrite_args ua;
1558 ssize_t rt;
1559 int error;
1560
1561 NETBSD32TO64_UAP(fd);
1562 NETBSD32TOP_UAP(buf, void);
1563 NETBSD32TOX_UAP(nbyte, size_t);
1564 NETBSD32TO64_UAP(pad);
1565 NETBSD32TO64_UAP(offset);
1566 error = sys_pwrite(l, &ua, (register_t *)&rt);
1567 *retval = rt;
1568 return (error);
1569 }
1570
1571 int
1572 netbsd32_setgid(l, v, retval)
1573 struct lwp *l;
1574 void *v;
1575 register_t *retval;
1576 {
1577 struct netbsd32_setgid_args /* {
1578 syscallarg(gid_t) gid;
1579 } */ *uap = v;
1580 struct sys_setgid_args ua;
1581
1582 NETBSD32TO64_UAP(gid);
1583 return (sys_setgid(l, v, retval));
1584 }
1585
1586 int
1587 netbsd32_setegid(l, v, retval)
1588 struct lwp *l;
1589 void *v;
1590 register_t *retval;
1591 {
1592 struct netbsd32_setegid_args /* {
1593 syscallarg(gid_t) egid;
1594 } */ *uap = v;
1595 struct sys_setegid_args ua;
1596
1597 NETBSD32TO64_UAP(egid);
1598 return (sys_setegid(l, v, retval));
1599 }
1600
1601 int
1602 netbsd32_seteuid(l, v, retval)
1603 struct lwp *l;
1604 void *v;
1605 register_t *retval;
1606 {
1607 struct netbsd32_seteuid_args /* {
1608 syscallarg(gid_t) euid;
1609 } */ *uap = v;
1610 struct sys_seteuid_args ua;
1611
1612 NETBSD32TO64_UAP(euid);
1613 return (sys_seteuid(l, v, retval));
1614 }
1615
1616 #ifdef LFS
1617 int
1618 netbsd32_sys_lfs_bmapv(l, v, retval)
1619 struct lwp *l;
1620 void *v;
1621 register_t *retval;
1622 {
1623
1624 return (ENOSYS); /* XXX */
1625 }
1626
1627 int
1628 netbsd32_sys_lfs_markv(l, v, retval)
1629 struct lwp *l;
1630 void *v;
1631 register_t *retval;
1632 {
1633
1634 return (ENOSYS); /* XXX */
1635 }
1636
1637 int
1638 netbsd32_sys_lfs_segclean(l, v, retval)
1639 struct lwp *l;
1640 void *v;
1641 register_t *retval;
1642 {
1643
1644 return (ENOSYS); /* XXX */
1645 }
1646
1647 int
1648 netbsd32_sys_lfs_segwait(l, v, retval)
1649 struct lwp *l;
1650 void *v;
1651 register_t *retval;
1652 {
1653
1654 return (ENOSYS); /* XXX */
1655 }
1656 #endif
1657
1658 int
1659 netbsd32_pathconf(l, v, retval)
1660 struct lwp *l;
1661 void *v;
1662 register_t *retval;
1663 {
1664 struct netbsd32_pathconf_args /* {
1665 syscallarg(int) fd;
1666 syscallarg(int) name;
1667 } */ *uap = v;
1668 struct sys_pathconf_args ua;
1669 long rt;
1670 int error;
1671
1672 NETBSD32TOP_UAP(path, const char);
1673 NETBSD32TO64_UAP(name);
1674 error = sys_pathconf(l, &ua, (register_t *)&rt);
1675 *retval = rt;
1676 return (error);
1677 }
1678
1679 int
1680 netbsd32_fpathconf(l, v, retval)
1681 struct lwp *l;
1682 void *v;
1683 register_t *retval;
1684 {
1685 struct netbsd32_fpathconf_args /* {
1686 syscallarg(int) fd;
1687 syscallarg(int) name;
1688 } */ *uap = v;
1689 struct sys_fpathconf_args ua;
1690 long rt;
1691 int error;
1692
1693 NETBSD32TO64_UAP(fd);
1694 NETBSD32TO64_UAP(name);
1695 error = sys_fpathconf(l, &ua, (register_t *)&rt);
1696 *retval = rt;
1697 return (error);
1698 }
1699
1700 int
1701 netbsd32_getrlimit(l, v, retval)
1702 struct lwp *l;
1703 void *v;
1704 register_t *retval;
1705 {
1706 struct netbsd32_getrlimit_args /* {
1707 syscallarg(int) which;
1708 syscallarg(netbsd32_rlimitp_t) rlp;
1709 } */ *uap = v;
1710 int which = SCARG(uap, which);
1711
1712 if ((u_int)which >= RLIM_NLIMITS)
1713 return (EINVAL);
1714 return (copyout(&l->l_proc->p_rlimit[which],
1715 (caddr_t)NETBSD32PTR64(SCARG(uap, rlp)), sizeof(struct rlimit)));
1716 }
1717
1718 int
1719 netbsd32_setrlimit(l, v, retval)
1720 struct lwp *l;
1721 void *v;
1722 register_t *retval;
1723 {
1724 struct netbsd32_setrlimit_args /* {
1725 syscallarg(int) which;
1726 syscallarg(const netbsd32_rlimitp_t) rlp;
1727 } */ *uap = v;
1728 int which = SCARG(uap, which);
1729 struct rlimit alim;
1730 int error;
1731 struct proc *p = l->l_proc;
1732
1733 error = copyin((caddr_t)NETBSD32PTR64(SCARG(uap, rlp)), &alim,
1734 sizeof(struct rlimit));
1735 if (error)
1736 return (error);
1737
1738 switch (which) {
1739 case RLIMIT_DATA:
1740 if (alim.rlim_cur > MAXDSIZ32)
1741 alim.rlim_cur = MAXDSIZ32;
1742 if (alim.rlim_max > MAXDSIZ32)
1743 alim.rlim_max = MAXDSIZ32;
1744 break;
1745
1746 case RLIMIT_STACK:
1747 if (alim.rlim_cur > MAXSSIZ32)
1748 alim.rlim_cur = MAXSSIZ32;
1749 if (alim.rlim_max > MAXSSIZ32)
1750 alim.rlim_max = MAXSSIZ32;
1751 default:
1752 break;
1753 }
1754
1755 return (dosetrlimit(p, p->p_cred, which, &alim));
1756 }
1757
1758 int
1759 netbsd32_mmap(l, v, retval)
1760 struct lwp *l;
1761 void *v;
1762 register_t *retval;
1763 {
1764 struct netbsd32_mmap_args /* {
1765 syscallarg(netbsd32_voidp) addr;
1766 syscallarg(netbsd32_size_t) len;
1767 syscallarg(int) prot;
1768 syscallarg(int) flags;
1769 syscallarg(int) fd;
1770 syscallarg(netbsd32_long) pad;
1771 syscallarg(off_t) pos;
1772 } */ *uap = v;
1773 struct sys_mmap_args ua;
1774 int error;
1775
1776 NETBSD32TOP_UAP(addr, void);
1777 NETBSD32TOX_UAP(len, size_t);
1778 NETBSD32TO64_UAP(prot);
1779 NETBSD32TO64_UAP(flags);
1780 NETBSD32TO64_UAP(fd);
1781 NETBSD32TOX_UAP(pad, long);
1782 NETBSD32TOX_UAP(pos, off_t);
1783 error = sys_mmap(l, &ua, retval);
1784 if ((u_long)*retval > (u_long)UINT_MAX) {
1785 printf("netbsd32_mmap: retval out of range: 0x%lx",
1786 (u_long)*retval);
1787 /* Should try to recover and return an error here. */
1788 }
1789 return (error);
1790 }
1791
1792 int
1793 netbsd32_lseek(l, v, retval)
1794 struct lwp *l;
1795 void *v;
1796 register_t *retval;
1797 {
1798 struct netbsd32_lseek_args /* {
1799 syscallarg(int) fd;
1800 syscallarg(int) pad;
1801 syscallarg(off_t) offset;
1802 syscallarg(int) whence;
1803 } */ *uap = v;
1804 struct sys_lseek_args ua;
1805 int rv;
1806
1807 NETBSD32TO64_UAP(fd);
1808 NETBSD32TO64_UAP(pad);
1809 NETBSD32TO64_UAP(offset);
1810 NETBSD32TO64_UAP(whence);
1811 rv = sys_lseek(l, &ua, retval);
1812 #ifdef NETBSD32_OFF_T_RETURN
1813 if (rv == 0)
1814 NETBSD32_OFF_T_RETURN(retval);
1815 #endif
1816 return rv;
1817 }
1818
1819 int
1820 netbsd32_truncate(l, v, retval)
1821 struct lwp *l;
1822 void *v;
1823 register_t *retval;
1824 {
1825 struct netbsd32_truncate_args /* {
1826 syscallarg(const netbsd32_charp) path;
1827 syscallarg(int) pad;
1828 syscallarg(off_t) length;
1829 } */ *uap = v;
1830 struct sys_truncate_args ua;
1831
1832 NETBSD32TOP_UAP(path, const char);
1833 NETBSD32TO64_UAP(pad);
1834 NETBSD32TO64_UAP(length);
1835 return (sys_truncate(l, &ua, retval));
1836 }
1837
1838 int
1839 netbsd32_ftruncate(l, v, retval)
1840 struct lwp *l;
1841 void *v;
1842 register_t *retval;
1843 {
1844 struct netbsd32_ftruncate_args /* {
1845 syscallarg(int) fd;
1846 syscallarg(int) pad;
1847 syscallarg(off_t) length;
1848 } */ *uap = v;
1849 struct sys_ftruncate_args ua;
1850
1851 NETBSD32TO64_UAP(fd);
1852 NETBSD32TO64_UAP(pad);
1853 NETBSD32TO64_UAP(length);
1854 return (sys_ftruncate(l, &ua, retval));
1855 }
1856
1857 int
1858 netbsd32_mlock(l, v, retval)
1859 struct lwp *l;
1860 void *v;
1861 register_t *retval;
1862 {
1863 struct netbsd32_mlock_args /* {
1864 syscallarg(const netbsd32_voidp) addr;
1865 syscallarg(netbsd32_size_t) len;
1866 } */ *uap = v;
1867 struct sys_mlock_args ua;
1868
1869 NETBSD32TOP_UAP(addr, const void);
1870 NETBSD32TO64_UAP(len);
1871 return (sys_mlock(l, &ua, retval));
1872 }
1873
1874 int
1875 netbsd32_munlock(l, v, retval)
1876 struct lwp *l;
1877 void *v;
1878 register_t *retval;
1879 {
1880 struct netbsd32_munlock_args /* {
1881 syscallarg(const netbsd32_voidp) addr;
1882 syscallarg(netbsd32_size_t) len;
1883 } */ *uap = v;
1884 struct sys_munlock_args ua;
1885
1886 NETBSD32TOP_UAP(addr, const void);
1887 NETBSD32TO64_UAP(len);
1888 return (sys_munlock(l, &ua, retval));
1889 }
1890
1891 int
1892 netbsd32_undelete(l, v, retval)
1893 struct lwp *l;
1894 void *v;
1895 register_t *retval;
1896 {
1897 struct netbsd32_undelete_args /* {
1898 syscallarg(const netbsd32_charp) path;
1899 } */ *uap = v;
1900 struct sys_undelete_args ua;
1901
1902 NETBSD32TOP_UAP(path, const char);
1903 return (sys_undelete(l, &ua, retval));
1904 }
1905
1906 int
1907 netbsd32_getpgid(l, v, retval)
1908 struct lwp *l;
1909 void *v;
1910 register_t *retval;
1911 {
1912 struct netbsd32_getpgid_args /* {
1913 syscallarg(pid_t) pid;
1914 } */ *uap = v;
1915 struct sys_getpgid_args ua;
1916
1917 NETBSD32TO64_UAP(pid);
1918 return (sys_getpgid(l, &ua, retval));
1919 }
1920
1921 int
1922 netbsd32_reboot(l, v, retval)
1923 struct lwp *l;
1924 void *v;
1925 register_t *retval;
1926 {
1927 struct netbsd32_reboot_args /* {
1928 syscallarg(int) opt;
1929 syscallarg(netbsd32_charp) bootstr;
1930 } */ *uap = v;
1931 struct sys_reboot_args ua;
1932
1933 NETBSD32TO64_UAP(opt);
1934 NETBSD32TOP_UAP(bootstr, char);
1935 return (sys_reboot(l, &ua, retval));
1936 }
1937
1938 #include <sys/poll.h>
1939 int
1940 netbsd32_poll(l, v, retval)
1941 struct lwp *l;
1942 void *v;
1943 register_t *retval;
1944 {
1945 struct netbsd32_poll_args /* {
1946 syscallarg(netbsd32_pollfdp_t) fds;
1947 syscallarg(u_int) nfds;
1948 syscallarg(int) timeout;
1949 } */ *uap = v;
1950 struct sys_poll_args ua;
1951
1952 NETBSD32TOP_UAP(fds, struct pollfd);
1953 NETBSD32TO64_UAP(nfds);
1954 NETBSD32TO64_UAP(timeout);
1955
1956 return (sys_poll(l, &ua, retval));
1957 }
1958
1959 int
1960 netbsd32_fdatasync(l, v, retval)
1961 struct lwp *l;
1962 void *v;
1963 register_t *retval;
1964 {
1965 struct netbsd32_fdatasync_args /* {
1966 syscallarg(int) fd;
1967 } */ *uap = v;
1968 struct sys_fdatasync_args ua;
1969
1970 NETBSD32TO64_UAP(fd);
1971 return (sys_fdatasync(l, &ua, retval));
1972 }
1973
1974 int
1975 netbsd32___posix_rename(l, v, retval)
1976 struct lwp *l;
1977 void *v;
1978 register_t *retval;
1979 {
1980 struct netbsd32___posix_rename_args /* {
1981 syscallarg(const netbsd32_charp) from;
1982 syscallarg(const netbsd32_charp) to;
1983 } */ *uap = v;
1984 struct sys___posix_rename_args ua;
1985
1986 NETBSD32TOP_UAP(from, const char);
1987 NETBSD32TOP_UAP(to, const char);
1988 return (sys___posix_rename(l, &ua, retval));
1989 }
1990
1991 int
1992 netbsd32_swapctl(l, v, retval)
1993 struct lwp *l;
1994 void *v;
1995 register_t *retval;
1996 {
1997 struct netbsd32_swapctl_args /* {
1998 syscallarg(int) cmd;
1999 syscallarg(const netbsd32_voidp) arg;
2000 syscallarg(int) misc;
2001 } */ *uap = v;
2002 struct sys_swapctl_args ua;
2003
2004 NETBSD32TO64_UAP(cmd);
2005 NETBSD32TOP_UAP(arg, void);
2006 NETBSD32TO64_UAP(misc);
2007 return (sys_swapctl(l, &ua, retval));
2008 }
2009
2010 int
2011 netbsd32_minherit(l, v, retval)
2012 struct lwp *l;
2013 void *v;
2014 register_t *retval;
2015 {
2016 struct netbsd32_minherit_args /* {
2017 syscallarg(netbsd32_voidp) addr;
2018 syscallarg(netbsd32_size_t) len;
2019 syscallarg(int) inherit;
2020 } */ *uap = v;
2021 struct sys_minherit_args ua;
2022
2023 NETBSD32TOP_UAP(addr, void);
2024 NETBSD32TOX_UAP(len, size_t);
2025 NETBSD32TO64_UAP(inherit);
2026 return (sys_minherit(l, &ua, retval));
2027 }
2028
2029 int
2030 netbsd32_lchmod(l, v, retval)
2031 struct lwp *l;
2032 void *v;
2033 register_t *retval;
2034 {
2035 struct netbsd32_lchmod_args /* {
2036 syscallarg(const netbsd32_charp) path;
2037 syscallarg(mode_t) mode;
2038 } */ *uap = v;
2039 struct sys_lchmod_args ua;
2040
2041 NETBSD32TOP_UAP(path, const char);
2042 NETBSD32TO64_UAP(mode);
2043 return (sys_lchmod(l, &ua, retval));
2044 }
2045
2046 int
2047 netbsd32_lchown(l, v, retval)
2048 struct lwp *l;
2049 void *v;
2050 register_t *retval;
2051 {
2052 struct netbsd32_lchown_args /* {
2053 syscallarg(const netbsd32_charp) path;
2054 syscallarg(uid_t) uid;
2055 syscallarg(gid_t) gid;
2056 } */ *uap = v;
2057 struct sys_lchown_args ua;
2058
2059 NETBSD32TOP_UAP(path, const char);
2060 NETBSD32TO64_UAP(uid);
2061 NETBSD32TO64_UAP(gid);
2062 return (sys_lchown(l, &ua, retval));
2063 }
2064
2065 int
2066 netbsd32___msync13(l, v, retval)
2067 struct lwp *l;
2068 void *v;
2069 register_t *retval;
2070 {
2071 struct netbsd32___msync13_args /* {
2072 syscallarg(netbsd32_voidp) addr;
2073 syscallarg(netbsd32_size_t) len;
2074 syscallarg(int) flags;
2075 } */ *uap = v;
2076 struct sys___msync13_args ua;
2077
2078 NETBSD32TOP_UAP(addr, void);
2079 NETBSD32TOX_UAP(len, size_t);
2080 NETBSD32TO64_UAP(flags);
2081 return (sys___msync13(l, &ua, retval));
2082 }
2083
2084 int
2085 netbsd32___posix_chown(l, v, retval)
2086 struct lwp *l;
2087 void *v;
2088 register_t *retval;
2089 {
2090 struct netbsd32___posix_chown_args /* {
2091 syscallarg(const netbsd32_charp) path;
2092 syscallarg(uid_t) uid;
2093 syscallarg(gid_t) gid;
2094 } */ *uap = v;
2095 struct sys___posix_chown_args ua;
2096
2097 NETBSD32TOP_UAP(path, const char);
2098 NETBSD32TO64_UAP(uid);
2099 NETBSD32TO64_UAP(gid);
2100 return (sys___posix_chown(l, &ua, retval));
2101 }
2102
2103 int
2104 netbsd32___posix_fchown(l, v, retval)
2105 struct lwp *l;
2106 void *v;
2107 register_t *retval;
2108 {
2109 struct netbsd32___posix_fchown_args /* {
2110 syscallarg(int) fd;
2111 syscallarg(uid_t) uid;
2112 syscallarg(gid_t) gid;
2113 } */ *uap = v;
2114 struct sys___posix_fchown_args ua;
2115
2116 NETBSD32TO64_UAP(fd);
2117 NETBSD32TO64_UAP(uid);
2118 NETBSD32TO64_UAP(gid);
2119 return (sys___posix_fchown(l, &ua, retval));
2120 }
2121
2122 int
2123 netbsd32___posix_lchown(l, v, retval)
2124 struct lwp *l;
2125 void *v;
2126 register_t *retval;
2127 {
2128 struct netbsd32___posix_lchown_args /* {
2129 syscallarg(const netbsd32_charp) path;
2130 syscallarg(uid_t) uid;
2131 syscallarg(gid_t) gid;
2132 } */ *uap = v;
2133 struct sys___posix_lchown_args ua;
2134
2135 NETBSD32TOP_UAP(path, const char);
2136 NETBSD32TO64_UAP(uid);
2137 NETBSD32TO64_UAP(gid);
2138 return (sys___posix_lchown(l, &ua, retval));
2139 }
2140
2141 int
2142 netbsd32_getsid(l, v, retval)
2143 struct lwp *l;
2144 void *v;
2145 register_t *retval;
2146 {
2147 struct netbsd32_getsid_args /* {
2148 syscallarg(pid_t) pid;
2149 } */ *uap = v;
2150 struct sys_getsid_args ua;
2151
2152 NETBSD32TO64_UAP(pid);
2153 return (sys_getsid(l, &ua, retval));
2154 }
2155
2156 #ifdef KTRACE
2157 int
2158 netbsd32_fktrace(l, v, retval)
2159 struct lwp *l;
2160 void *v;
2161 register_t *retval;
2162 {
2163 struct netbsd32_fktrace_args /* {
2164 syscallarg(const int) fd;
2165 syscallarg(int) ops;
2166 syscallarg(int) facs;
2167 syscallarg(int) pid;
2168 } */ *uap = v;
2169 #if 0
2170 struct sys_fktrace_args ua;
2171 #else
2172 /* XXXX */
2173 struct sys_fktrace_noconst_args {
2174 syscallarg(int) fd;
2175 syscallarg(int) ops;
2176 syscallarg(int) facs;
2177 syscallarg(int) pid;
2178 } ua;
2179 #endif
2180
2181 NETBSD32TOX_UAP(fd, int);
2182 NETBSD32TO64_UAP(ops);
2183 NETBSD32TO64_UAP(facs);
2184 NETBSD32TO64_UAP(pid);
2185 return (sys_fktrace(l, &ua, retval));
2186 }
2187 #endif /* KTRACE */
2188
2189 int netbsd32___sigpending14(l, v, retval)
2190 struct lwp *l;
2191 void *v;
2192 register_t *retval;
2193 {
2194 struct netbsd32___sigpending14_args /* {
2195 syscallarg(sigset_t *) set;
2196 } */ *uap = v;
2197 struct sys___sigpending14_args ua;
2198
2199 NETBSD32TOP_UAP(set, sigset_t);
2200 return (sys___sigpending14(l, &ua, retval));
2201 }
2202
2203 int netbsd32___sigprocmask14(l, v, retval)
2204 struct lwp *l;
2205 void *v;
2206 register_t *retval;
2207 {
2208 struct netbsd32___sigprocmask14_args /* {
2209 syscallarg(int) how;
2210 syscallarg(const sigset_t *) set;
2211 syscallarg(sigset_t *) oset;
2212 } */ *uap = v;
2213 struct sys___sigprocmask14_args ua;
2214
2215 NETBSD32TO64_UAP(how);
2216 NETBSD32TOP_UAP(set, sigset_t);
2217 NETBSD32TOP_UAP(oset, sigset_t);
2218 return (sys___sigprocmask14(l, &ua, retval));
2219 }
2220
2221 int netbsd32___sigsuspend14(l, v, retval)
2222 struct lwp *l;
2223 void *v;
2224 register_t *retval;
2225 {
2226 struct netbsd32___sigsuspend14_args /* {
2227 syscallarg(const sigset_t *) set;
2228 } */ *uap = v;
2229 struct sys___sigsuspend14_args ua;
2230
2231 NETBSD32TOP_UAP(set, sigset_t);
2232 return (sys___sigsuspend14(l, &ua, retval));
2233 };
2234
2235 int netbsd32_fchroot(l, v, retval)
2236 struct lwp *l;
2237 void *v;
2238 register_t *retval;
2239 {
2240 struct netbsd32_fchroot_args /* {
2241 syscallarg(int) fd;
2242 } */ *uap = v;
2243 struct sys_fchroot_args ua;
2244
2245 NETBSD32TO64_UAP(fd);
2246 return (sys_fchroot(l, &ua, retval));
2247 }
2248
2249 /*
2250 * Open a file given a file handle.
2251 *
2252 * Check permissions, allocate an open file structure,
2253 * and call the device open routine if any.
2254 */
2255 int
2256 netbsd32_fhopen(l, v, retval)
2257 struct lwp *l;
2258 void *v;
2259 register_t *retval;
2260 {
2261 struct netbsd32_fhopen_args /* {
2262 syscallarg(const fhandle_t *) fhp;
2263 syscallarg(int) flags;
2264 } */ *uap = v;
2265 struct sys_fhopen_args ua;
2266
2267 NETBSD32TOP_UAP(fhp, fhandle_t);
2268 NETBSD32TO64_UAP(flags);
2269 return (sys_fhopen(l, &ua, retval));
2270 }
2271
2272 /* virtual memory syscalls */
2273 int
2274 netbsd32_ovadvise(l, v, retval)
2275 struct lwp *l;
2276 void *v;
2277 register_t *retval;
2278 {
2279 struct netbsd32_ovadvise_args /* {
2280 syscallarg(int) anom;
2281 } */ *uap = v;
2282 struct sys_ovadvise_args ua;
2283
2284 NETBSD32TO64_UAP(anom);
2285 return (sys_ovadvise(l, &ua, retval));
2286 }
2287
2288 void
2289 netbsd32_adjust_limits(struct proc *p)
2290 {
2291 rlim_t *valp;
2292
2293 valp = &p->p_rlimit[RLIMIT_DATA].rlim_cur;
2294 if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
2295 *valp = MAXDSIZ32;
2296 valp = &p->p_rlimit[RLIMIT_DATA].rlim_max;
2297 if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
2298 *valp = MAXDSIZ32;
2299
2300 valp = &p->p_rlimit[RLIMIT_STACK].rlim_cur;
2301 if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
2302 *valp = MAXSSIZ32;
2303 valp = &p->p_rlimit[RLIMIT_STACK].rlim_max;
2304 if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
2305 *valp = MAXSSIZ32;
2306 }
2307
2308 int
2309 netbsd32_uuidgen(struct lwp *l, void *v, register_t *retval)
2310 {
2311 struct netbsd32_uuidgen_args /* {
2312 syscallarg(netbsd32_uuidp_t) store;
2313 syscallarg(int) count;
2314 } */ *uap = v;
2315 struct sys_uuidgen_args ua;
2316
2317 NETBSD32TOP_UAP(store, struct uuid);
2318 NETBSD32TO64_UAP(count);
2319 return (sys_uuidgen(l, &ua, retval));
2320 }
2321
2322 int
2323 netbsd32_extattrctl(struct lwp *l, void *v, register_t *retval)
2324 {
2325 struct netbsd32_extattrctl_args /* {
2326 syscallarg(const netbsd32_charp) path;
2327 syscallarg(int) cmd;
2328 syscallarg(const netbsd32_charp) filename;
2329 syscallarg(int) attrnamespace;
2330 syscallarg(const netbsd32_charp) attrname;
2331 } */ *uap = v;
2332 struct sys_extattrctl_args ua;
2333
2334 NETBSD32TOP_UAP(path, const char);
2335 NETBSD32TO64_UAP(cmd);
2336 NETBSD32TOP_UAP(filename, const char);
2337 NETBSD32TO64_UAP(attrnamespace);
2338 NETBSD32TOP_UAP(attrname, const char);
2339 return sys_extattrctl(l, &ua, retval);
2340 }
2341
2342 int
2343 netbsd32_extattr_set_fd(struct lwp *l, void *v, register_t *retval)
2344 {
2345 struct netbsd32_extattr_set_fd_args /* {
2346 syscallarg(int) fd;
2347 syscallarg(int) attrnamespace;
2348 syscallarg(const netbsd32_charp) attrname;
2349 syscallarg(const netbsd32_voidp) data;
2350 syscallarg(netbsd32_size_t) nbytes;
2351 } */ *uap = v;
2352 struct sys_extattr_set_fd_args ua;
2353
2354 NETBSD32TO64_UAP(fd);
2355 NETBSD32TO64_UAP(attrnamespace);
2356 NETBSD32TOP_UAP(attrname, const char);
2357 NETBSD32TOP_UAP(data, const void);
2358 NETBSD32TOX_UAP(nbytes, size_t);
2359 return sys_extattr_set_fd(l, &ua, retval);
2360 }
2361
2362 int
2363 netbsd32_extattr_set_file(struct lwp *l, void *v, register_t *retval)
2364 {
2365 struct netbsd32_extattr_set_file_args /* {
2366 syscallarg(const netbsd32_charp) path;
2367 syscallarg(int) attrnamespace;
2368 syscallarg(const netbsd32_charp) attrname;
2369 syscallarg(const netbsd32_voidp) data;
2370 syscallarg(netbsd32_size_t) nbytes;
2371 } */ *uap = v;
2372 struct sys_extattr_set_file_args ua;
2373
2374 NETBSD32TOP_UAP(path, const char);
2375 NETBSD32TO64_UAP(attrnamespace);
2376 NETBSD32TOP_UAP(attrname, const char);
2377 NETBSD32TOP_UAP(data, const void);
2378 NETBSD32TOX_UAP(nbytes, size_t);
2379 return sys_extattr_set_file(l, &ua, retval);
2380 }
2381
2382 int
2383 netbsd32_extattr_set_link(struct lwp *l, void *v, register_t *retval)
2384 {
2385 struct netbsd32_extattr_set_link_args /* {
2386 syscallarg(const netbsd32_charp) path;
2387 syscallarg(int) attrnamespace;
2388 syscallarg(const netbsd32_charp) attrname;
2389 syscallarg(const netbsd32_voidp) data;
2390 syscallarg(netbsd32_size_t) nbytes;
2391 } */ *uap = v;
2392 struct sys_extattr_set_link_args ua;
2393
2394 NETBSD32TOP_UAP(path, const char);
2395 NETBSD32TO64_UAP(attrnamespace);
2396 NETBSD32TOP_UAP(attrname, const char);
2397 NETBSD32TOP_UAP(data, const void);
2398 NETBSD32TOX_UAP(nbytes, size_t);
2399 return sys_extattr_set_link(l, &ua, retval);
2400 }
2401
2402 int
2403 netbsd32_extattr_get_fd(struct lwp *l, void *v, register_t *retval)
2404 {
2405 struct netbsd32_extattr_get_fd_args /* {
2406 syscallarg(int) fd;
2407 syscallarg(int) attrnamespace;
2408 syscallarg(const netbsd32_charp) attrname;
2409 syscallarg(netbsd32_voidp) data;
2410 syscallarg(netbsd32_size_t) nbytes;
2411 } */ *uap = v;
2412 struct sys_extattr_get_fd_args ua;
2413
2414 NETBSD32TO64_UAP(fd);
2415 NETBSD32TO64_UAP(attrnamespace);
2416 NETBSD32TOP_UAP(attrname, const char);
2417 NETBSD32TOP_UAP(data, void);
2418 NETBSD32TOX_UAP(nbytes, size_t);
2419 return sys_extattr_get_fd(l, &ua, retval);
2420 }
2421
2422 int
2423 netbsd32_extattr_get_file(struct lwp *l, void *v, register_t *retval)
2424 {
2425 struct netbsd32_extattr_get_file_args /* {
2426 syscallarg(const netbsd32_charp) path;
2427 syscallarg(int) attrnamespace;
2428 syscallarg(const netbsd32_charp) attrname;
2429 syscallarg(netbsd32_voidp) data;
2430 syscallarg(netbsd32_size_t) nbytes;
2431 } */ *uap = v;
2432 struct sys_extattr_get_file_args ua;
2433
2434 NETBSD32TOP_UAP(path, const char);
2435 NETBSD32TO64_UAP(attrnamespace);
2436 NETBSD32TOP_UAP(attrname, const char);
2437 NETBSD32TOP_UAP(data, void);
2438 NETBSD32TOX_UAP(nbytes, size_t);
2439 return sys_extattr_get_file(l, &ua, retval);
2440 }
2441
2442 int
2443 netbsd32_extattr_get_link(struct lwp *l, void *v, register_t *retval)
2444 {
2445 struct netbsd32_extattr_get_link_args /* {
2446 syscallarg(const netbsd32_charp) path;
2447 syscallarg(int) attrnamespace;
2448 syscallarg(const netbsd32_charp) attrname;
2449 syscallarg(netbsd32_voidp) data;
2450 syscallarg(netbsd32_size_t) nbytes;
2451 } */ *uap = v;
2452 struct sys_extattr_get_link_args ua;
2453
2454 NETBSD32TOP_UAP(path, const char);
2455 NETBSD32TO64_UAP(attrnamespace);
2456 NETBSD32TOP_UAP(attrname, const char);
2457 NETBSD32TOP_UAP(data, void);
2458 NETBSD32TOX_UAP(nbytes, size_t);
2459 return sys_extattr_get_link(l, &ua, retval);
2460 }
2461
2462 int
2463 netbsd32_extattr_delete_fd(struct lwp *l, void *v, register_t *retval)
2464 {
2465 struct netbsd32_extattr_delete_fd_args /* {
2466 syscallarg(int) fd;
2467 syscallarg(int) attrnamespace;
2468 syscallarg(const netbsd32_charp) attrname;
2469 } */ *uap = v;
2470 struct sys_extattr_delete_fd_args ua;
2471
2472 NETBSD32TO64_UAP(fd);
2473 NETBSD32TO64_UAP(attrnamespace);
2474 NETBSD32TOP_UAP(attrname, const char);
2475 return sys_extattr_delete_fd(l, &ua, retval);
2476 }
2477
2478 int
2479 netbsd32_extattr_delete_file(struct lwp *l, void *v, register_t *retval)
2480 {
2481 struct netbsd32_extattr_delete_file_args /* {
2482 syscallarg(const netbsd32_charp) path;
2483 syscallarg(int) attrnamespace;
2484 syscallarg(const netbsd32_charp) attrname;
2485 } */ *uap = v;
2486 struct sys_extattr_delete_file_args ua;
2487
2488 NETBSD32TOP_UAP(path, const char);
2489 NETBSD32TO64_UAP(attrnamespace);
2490 NETBSD32TOP_UAP(attrname, const char);
2491 return sys_extattr_delete_file(l, &ua, retval);
2492 }
2493
2494 int
2495 netbsd32_extattr_delete_link(struct lwp *l, void *v, register_t *retval)
2496 {
2497 struct netbsd32_extattr_delete_link_args /* {
2498 syscallarg(const netbsd32_charp) path;
2499 syscallarg(int) attrnamespace;
2500 syscallarg(const netbsd32_charp) attrname;
2501 } */ *uap = v;
2502 struct sys_extattr_delete_link_args ua;
2503
2504 NETBSD32TOP_UAP(path, const char);
2505 NETBSD32TO64_UAP(attrnamespace);
2506 NETBSD32TOP_UAP(attrname, const char);
2507 return sys_extattr_delete_link(l, &ua, retval);
2508 }
2509
2510 int
2511 netbsd32_extattr_list_fd(struct lwp *l, void *v, register_t *retval)
2512 {
2513 struct netbsd32_extattr_list_fd_args /* {
2514 syscallarg(int) fd;
2515 syscallarg(int) attrnamespace;
2516 syscallarg(netbsd32_voidp) data;
2517 syscallarg(netbsd32_size_t) nbytes;
2518 } */ *uap = v;
2519 struct sys_extattr_list_fd_args ua;
2520
2521 NETBSD32TO64_UAP(fd);
2522 NETBSD32TO64_UAP(attrnamespace);
2523 NETBSD32TOP_UAP(data, void);
2524 NETBSD32TOX_UAP(nbytes, size_t);
2525 return sys_extattr_list_fd(l, &ua, retval);
2526 }
2527
2528 int
2529 netbsd32_extattr_list_file(struct lwp *l, void *v, register_t *retval)
2530 {
2531 struct netbsd32_extattr_list_file_args /* {
2532 syscallarg(const netbsd32_charp) path;
2533 syscallarg(int) attrnamespace;
2534 syscallarg(netbsd32_voidp) data;
2535 syscallarg(netbsd32_size_t) nbytes;
2536 } */ *uap = v;
2537 struct sys_extattr_list_file_args ua;
2538
2539 NETBSD32TOP_UAP(path, const char);
2540 NETBSD32TO64_UAP(attrnamespace);
2541 NETBSD32TOP_UAP(data, void);
2542 NETBSD32TOX_UAP(nbytes, size_t);
2543 return sys_extattr_list_file(l, &ua, retval);
2544 }
2545
2546 int
2547 netbsd32_extattr_list_link(struct lwp *l, void *v, register_t *retval)
2548 {
2549 struct netbsd32_extattr_list_link_args /* {
2550 syscallarg(const netbsd32_charp) path;
2551 syscallarg(int) attrnamespace;
2552 syscallarg(netbsd32_voidp) data;
2553 syscallarg(netbsd32_size_t) nbytes;
2554 } */ *uap = v;
2555 struct sys_extattr_list_link_args ua;
2556
2557 NETBSD32TOP_UAP(path, const char);
2558 NETBSD32TO64_UAP(attrnamespace);
2559 NETBSD32TOP_UAP(data, void);
2560 NETBSD32TOX_UAP(nbytes, size_t);
2561 return sys_extattr_list_link(l, &ua, retval);
2562 }
2563
2564 int
2565 netbsd32_mlockall(l, v, retval)
2566 struct lwp *l;
2567 void *v;
2568 register_t *retval;
2569 {
2570 struct netbsd32_mlockall_args /* {
2571 syscallarg(int) flags;
2572 } */ *uap = v;
2573 struct sys_mlockall_args ua;
2574
2575 NETBSD32TO64_UAP(flags);
2576 return (sys_mlockall(l, &ua, retval));
2577 }
2578
2579 int
2580 netbsd32___clone(struct lwp *l, void *v, register_t *retval)
2581 {
2582 struct netbsd32___clone_args /* {
2583 syscallarg(int) flags;
2584 syscallarg(netbsd32_voidp) stack;
2585 } */ *uap = v;
2586 struct sys___clone_args ua;
2587
2588 NETBSD32TO64_UAP(flags);
2589 NETBSD32TOP_UAP(stack, void);
2590 return sys___clone(l, &ua, retval);
2591 }
2592
2593 int
2594 netbsd32_fsync_range(struct lwp *l, void *v, register_t *retval)
2595 {
2596 struct netbsd32_fsync_range_args /* {
2597 syscallarg(int) fd;
2598 syscallarg(int) flags;
2599 syscallarg(off_t) start;
2600 syscallarg(off_t) length;
2601 } */ *uap = v;
2602 struct sys_fsync_range_args ua;
2603
2604 NETBSD32TO64_UAP(fd);
2605 NETBSD32TO64_UAP(flags);
2606 NETBSD32TO64_UAP(start);
2607 NETBSD32TO64_UAP(length);
2608 return (sys_fsync_range(l, &ua, retval));
2609 }
2610
2611 int
2612 netbsd32_rasctl(struct lwp *l, void *v, register_t *retval)
2613 {
2614 struct netbsd32_rasctl_args /* {
2615 syscallarg(netbsd32_caddr_t) addr;
2616 syscallarg(netbsd32_size_t) len;
2617 syscallarg(int) op;
2618 } */ *uap = v;
2619 struct sys_rasctl_args ua;
2620
2621 NETBSD32TOX64_UAP(addr, caddr_t);
2622 NETBSD32TOX_UAP(len, size_t);
2623 NETBSD32TO64_UAP(op);
2624 return sys_rasctl(l, &ua, retval);
2625 }
2626
2627 int
2628 netbsd32_setxattr(struct lwp *l, void *v, register_t *retval)
2629 {
2630 struct netbsd32_setxattr_args /* {
2631 syscallarg(const netbsd32_charp) path;
2632 syscallarg(const netbsd32_charp) name;
2633 syscallarg(netbsd32_voidp) value;
2634 syscallarg(netbsd32_size_t) size;
2635 syscallarg(int) flags;
2636 } */ *uap = v;
2637 struct sys_setxattr_args ua;
2638 NETBSD32TOP_UAP(path, const char);
2639 NETBSD32TOP_UAP(name, const char);
2640 NETBSD32TOP_UAP(value, void);
2641 NETBSD32TOX_UAP(size, size_t);
2642 NETBSD32TO64_UAP(flags);
2643 return sys_setxattr(l, &ua, retval);
2644 }
2645
2646 int
2647 netbsd32_lsetxattr(struct lwp *l, void *v, register_t *retval)
2648 {
2649 struct netbsd32_lsetxattr_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_lsetxattr_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_lsetxattr(l, &ua, retval);
2663 }
2664
2665 int
2666 netbsd32_fsetxattr(struct lwp *l, void *v, register_t *retval)
2667 {
2668 struct netbsd32_fsetxattr_args /* {
2669 syscallarg(int) fd;
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_fsetxattr_args ua;
2676 NETBSD32TO64_UAP(fd);
2677 NETBSD32TOP_UAP(name, const char);
2678 NETBSD32TOP_UAP(value, void);
2679 NETBSD32TOX_UAP(size, size_t);
2680 NETBSD32TO64_UAP(flags);
2681 return sys_fsetxattr(l, &ua, retval);
2682 }
2683
2684 int
2685 netbsd32_getxattr(struct lwp *l, void *v, register_t *retval)
2686 {
2687 struct netbsd32_getxattr_args /* {
2688 syscallarg(const netbsd32_charp) path;
2689 syscallarg(const netbsd32_charp) name;
2690 syscallarg(netbsd32_voidp) value;
2691 syscallarg(netbsd32_size_t) size;
2692 } */ *uap = v;
2693 struct sys_getxattr_args ua;
2694 NETBSD32TOP_UAP(path, const char);
2695 NETBSD32TOP_UAP(name, const char);
2696 NETBSD32TOP_UAP(value, void);
2697 NETBSD32TOX_UAP(size, size_t);
2698 return sys_getxattr(l, &ua, retval);
2699 }
2700
2701 int
2702 netbsd32_lgetxattr(struct lwp *l, void *v, register_t *retval)
2703 {
2704 struct netbsd32_lgetxattr_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_lgetxattr_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_lgetxattr(l, &ua, retval);
2716 }
2717
2718 int
2719 netbsd32_fgetxattr(struct lwp *l, void *v, register_t *retval)
2720 {
2721 struct netbsd32_fgetxattr_args /* {
2722 syscallarg(int) fd;
2723 syscallarg(const netbsd32_charp) name;
2724 syscallarg(netbsd32_voidp) value;
2725 syscallarg(netbsd32_size_t) size;
2726 } */ *uap = v;
2727 struct sys_fgetxattr_args ua;
2728 NETBSD32TO64_UAP(fd);
2729 NETBSD32TOP_UAP(name, const char);
2730 NETBSD32TOP_UAP(value, void);
2731 NETBSD32TOX_UAP(size, size_t);
2732 return sys_fgetxattr(l, &ua, retval);
2733 }
2734
2735 int
2736 netbsd32_listxattr(struct lwp *l, void *v, register_t *retval)
2737 {
2738 struct netbsd32_listxattr_args /* {
2739 syscallarg(const netbsd32_charp) path;
2740 syscallarg(netbsd32_charp) list;
2741 syscallarg(netbsd32_size_t) size;
2742 } */ *uap = v;
2743 struct sys_listxattr_args ua;
2744 NETBSD32TOP_UAP(path, const char);
2745 NETBSD32TOP_UAP(list, char);
2746 NETBSD32TOX_UAP(size, size_t);
2747 return sys_listxattr(l, &ua, retval);
2748 }
2749
2750 int
2751 netbsd32_llistxattr(struct lwp *l, void *v, register_t *retval)
2752 {
2753 struct netbsd32_llistxattr_args /* {
2754 syscallarg(const netbsd32_charp) path;
2755 syscallarg(netbsd32_charp) list;
2756 syscallarg(netbsd32_size_t) size;
2757 } */ *uap = v;
2758 struct sys_llistxattr_args ua;
2759 NETBSD32TOP_UAP(path, const char);
2760 NETBSD32TOP_UAP(list, char);
2761 NETBSD32TOX_UAP(size, size_t);
2762 return sys_llistxattr(l, &ua, retval);
2763 }
2764
2765 int
2766 netbsd32_flistxattr(struct lwp *l, void *v, register_t *retval)
2767 {
2768 struct netbsd32_flistxattr_args /* {
2769 syscallarg(int) fd;
2770 syscallarg(netbsd32_charp) list;
2771 syscallarg(netbsd32_size_t) size;
2772 } */ *uap = v;
2773 struct sys_flistxattr_args ua;
2774 NETBSD32TO64_UAP(fd);
2775 NETBSD32TOP_UAP(list, char);
2776 NETBSD32TOX_UAP(size, size_t);
2777 return sys_flistxattr(l, &ua, retval);
2778 }
2779
2780 int
2781 netbsd32_removexattr(struct lwp *l, void *v, register_t *retval)
2782 {
2783 struct netbsd32_removexattr_args /* {
2784 syscallarg(const netbsd32_charp) path;
2785 syscallarg(const netbsd32_charp) name;
2786 } */ *uap = v;
2787 struct sys_removexattr_args ua;
2788 NETBSD32TOP_UAP(path, const char);
2789 NETBSD32TOP_UAP(name, const char);
2790 return sys_removexattr(l, &ua, retval);
2791 }
2792
2793 int
2794 netbsd32_lremovexattr(struct lwp *l, void *v, register_t *retval)
2795 {
2796 struct netbsd32_lremovexattr_args /* {
2797 syscallarg(const netbsd32_charp) path;
2798 syscallarg(const netbsd32_charp) name;
2799 } */ *uap = v;
2800 struct sys_lremovexattr_args ua;
2801 NETBSD32TOP_UAP(path, const char);
2802 NETBSD32TOP_UAP(name, const char);
2803 return sys_lremovexattr(l, &ua, retval);
2804 }
2805
2806 int
2807 netbsd32_fremovexattr(struct lwp *l, void *v, register_t *retval)
2808 {
2809 struct netbsd32_fremovexattr_args /* {
2810 syscallarg(int) fd;
2811 syscallarg(const netbsd32_charp) name;
2812 } */ *uap = v;
2813 struct sys_fremovexattr_args ua;
2814 NETBSD32TO64_UAP(fd);
2815 NETBSD32TOP_UAP(name, const char);
2816 return sys_fremovexattr(l, &ua, retval);
2817 }
2818