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