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