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