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