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