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