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