netbsd32_netbsd.c revision 1.99.6.1 1 /* $NetBSD: netbsd32_netbsd.c,v 1.99.6.1 2006/04/22 11:38:17 simonb 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.99.6.1 2006/04/22 11:38:17 simonb 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 #include <sys/dirent.h>
78
79 #include <uvm/uvm_extern.h>
80
81 #include <sys/sa.h>
82 #include <sys/savar.h>
83 #include <sys/syscallargs.h>
84 #include <sys/proc.h>
85 #include <sys/acct.h>
86 #include <sys/exec.h>
87
88 #include <net/if.h>
89
90 #include <compat/netbsd32/netbsd32.h>
91 #include <compat/netbsd32/netbsd32_exec.h>
92 #include <compat/netbsd32/netbsd32_syscall.h>
93 #include <compat/netbsd32/netbsd32_syscallargs.h>
94 #include <compat/netbsd32/netbsd32_conv.h>
95 #include <compat/netbsd32/netbsd32_sa.h>
96
97 #include <machine/frame.h>
98
99 #if defined(DDB)
100 #include <ddb/ddbvar.h>
101 #endif
102
103 extern struct sysent netbsd32_sysent[];
104 #ifdef SYSCALL_DEBUG
105 extern const char * const netbsd32_syscallnames[];
106 #endif
107 #ifdef __HAVE_SYSCALL_INTERN
108 void netbsd32_syscall_intern __P((struct proc *));
109 #else
110 void syscall __P((void));
111 #endif
112
113 #ifdef COMPAT_16
114 extern char netbsd32_sigcode[], netbsd32_esigcode[];
115 struct uvm_object *emul_netbsd32_object;
116 #endif
117
118 extern struct sysctlnode netbsd32_sysctl_root;
119
120 const struct sa_emul saemul_netbsd32 = {
121 sizeof(ucontext32_t),
122 sizeof(struct netbsd32_sa_t),
123 sizeof(netbsd32_sa_tp),
124 netbsd32_sacopyout,
125 netbsd32_upcallconv,
126 netbsd32_cpu_upcall,
127 (void (*)(struct lwp *, void *))getucontext32,
128 netbsd32_sa_ucsp
129 };
130
131 const struct emul emul_netbsd32 = {
132 "netbsd32",
133 "/emul/netbsd32",
134 #ifndef __HAVE_MINIMAL_EMUL
135 0,
136 NULL,
137 netbsd32_SYS_syscall,
138 netbsd32_SYS_NSYSENT,
139 #endif
140 netbsd32_sysent,
141 #ifdef SYSCALL_DEBUG
142 netbsd32_syscallnames,
143 #else
144 NULL,
145 #endif
146 netbsd32_sendsig,
147 trapsignal,
148 NULL,
149 #ifdef COMPAT_16
150 netbsd32_sigcode,
151 netbsd32_esigcode,
152 &emul_netbsd32_object,
153 #else
154 NULL,
155 NULL,
156 NULL,
157 #endif
158 netbsd32_setregs,
159 NULL,
160 NULL,
161 NULL,
162 NULL,
163 NULL,
164 #ifdef __HAVE_SYSCALL_INTERN
165 netbsd32_syscall_intern,
166 #else
167 syscall,
168 #endif
169 &netbsd32_sysctl_root,
170 NULL,
171
172 netbsd32_vm_default_addr,
173 NULL,
174 &saemul_netbsd32,
175 };
176
177 /*
178 * below are all the standard NetBSD system calls, in the 32bit
179 * environment, with the necessary conversions to 64bit before
180 * calling the real syscall. anything that needs special
181 * attention is handled elsewhere.
182 */
183
184 int
185 netbsd32_exit(l, v, retval)
186 struct lwp *l;
187 void *v;
188 register_t *retval;
189 {
190 struct netbsd32_exit_args /* {
191 syscallarg(int) rval;
192 } */ *uap = v;
193 struct sys_exit_args ua;
194
195 NETBSD32TO64_UAP(rval);
196 return sys_exit(l, &ua, retval);
197 }
198
199 int
200 netbsd32_read(l, v, retval)
201 struct lwp *l;
202 void *v;
203 register_t *retval;
204 {
205 struct netbsd32_read_args /* {
206 syscallarg(int) fd;
207 syscallarg(netbsd32_voidp) buf;
208 syscallarg(netbsd32_size_t) nbyte;
209 } */ *uap = v;
210 struct sys_read_args ua;
211
212 NETBSD32TO64_UAP(fd);
213 NETBSD32TOP_UAP(buf, void *);
214 NETBSD32TOX_UAP(nbyte, size_t);
215 return sys_read(l, &ua, retval);
216 }
217
218 int
219 netbsd32_write(l, v, retval)
220 struct lwp *l;
221 void *v;
222 register_t *retval;
223 {
224 struct netbsd32_write_args /* {
225 syscallarg(int) fd;
226 syscallarg(const netbsd32_voidp) buf;
227 syscallarg(netbsd32_size_t) nbyte;
228 } */ *uap = v;
229 struct sys_write_args ua;
230
231 NETBSD32TO64_UAP(fd);
232 NETBSD32TOP_UAP(buf, void *);
233 NETBSD32TOX_UAP(nbyte, size_t);
234 return sys_write(l, &ua, retval);
235 }
236
237 int
238 netbsd32_close(l, v, retval)
239 struct lwp *l;
240 void *v;
241 register_t *retval;
242 {
243 struct netbsd32_close_args /* {
244 syscallarg(int) fd;
245 } */ *uap = v;
246 struct sys_close_args ua;
247
248 NETBSD32TO64_UAP(fd);
249 return sys_close(l, &ua, retval);
250 }
251
252 int
253 netbsd32_open(l, v, retval)
254 struct lwp *l;
255 void *v;
256 register_t *retval;
257 {
258 struct netbsd32_open_args /* {
259 syscallarg(const netbsd32_charp) path;
260 syscallarg(int) flags;
261 syscallarg(mode_t) mode;
262 } */ *uap = v;
263 struct sys_open_args ua;
264 caddr_t sg;
265
266 NETBSD32TOP_UAP(path, const char);
267 NETBSD32TO64_UAP(flags);
268 NETBSD32TO64_UAP(mode);
269 sg = stackgap_init(l->l_proc, 0);
270 CHECK_ALT_EXIST(l, &sg, SCARG(&ua, path));
271
272 return (sys_open(l, &ua, retval));
273 }
274
275 int
276 netbsd32_link(l, v, retval)
277 struct lwp *l;
278 void *v;
279 register_t *retval;
280 {
281 struct netbsd32_link_args /* {
282 syscallarg(const netbsd32_charp) path;
283 syscallarg(const netbsd32_charp) link;
284 } */ *uap = v;
285 struct sys_link_args ua;
286
287 NETBSD32TOP_UAP(path, const char);
288 NETBSD32TOP_UAP(link, const char);
289 return (sys_link(l, &ua, retval));
290 }
291
292 int
293 netbsd32_unlink(l, v, retval)
294 struct lwp *l;
295 void *v;
296 register_t *retval;
297 {
298 struct netbsd32_unlink_args /* {
299 syscallarg(const netbsd32_charp) path;
300 } */ *uap = v;
301 struct sys_unlink_args ua;
302
303 NETBSD32TOP_UAP(path, const char);
304
305 return (sys_unlink(l, &ua, retval));
306 }
307
308 int
309 netbsd32_chdir(l, v, retval)
310 struct lwp *l;
311 void *v;
312 register_t *retval;
313 {
314 struct netbsd32_chdir_args /* {
315 syscallarg(const netbsd32_charp) path;
316 } */ *uap = v;
317 struct sys_chdir_args ua;
318
319 NETBSD32TOP_UAP(path, const char);
320
321 return (sys_chdir(l, &ua, retval));
322 }
323
324 int
325 netbsd32_fchdir(l, v, retval)
326 struct lwp *l;
327 void *v;
328 register_t *retval;
329 {
330 struct netbsd32_fchdir_args /* {
331 syscallarg(int) fd;
332 } */ *uap = v;
333 struct sys_fchdir_args ua;
334
335 NETBSD32TO64_UAP(fd);
336
337 return (sys_fchdir(l, &ua, retval));
338 }
339
340 int
341 netbsd32_mknod(l, v, retval)
342 struct lwp *l;
343 void *v;
344 register_t *retval;
345 {
346 struct netbsd32_mknod_args /* {
347 syscallarg(const netbsd32_charp) path;
348 syscallarg(mode_t) mode;
349 syscallarg(dev_t) dev;
350 } */ *uap = v;
351 struct sys_mknod_args ua;
352
353 NETBSD32TOP_UAP(path, const char);
354 NETBSD32TO64_UAP(dev);
355 NETBSD32TO64_UAP(mode);
356
357 return (sys_mknod(l, &ua, retval));
358 }
359
360 int
361 netbsd32_chmod(l, v, retval)
362 struct lwp *l;
363 void *v;
364 register_t *retval;
365 {
366 struct netbsd32_chmod_args /* {
367 syscallarg(const netbsd32_charp) path;
368 syscallarg(mode_t) mode;
369 } */ *uap = v;
370 struct sys_chmod_args ua;
371
372 NETBSD32TOP_UAP(path, const char);
373 NETBSD32TO64_UAP(mode);
374
375 return (sys_chmod(l, &ua, retval));
376 }
377
378 int
379 netbsd32_chown(l, v, retval)
380 struct lwp *l;
381 void *v;
382 register_t *retval;
383 {
384 struct netbsd32_chown_args /* {
385 syscallarg(const netbsd32_charp) path;
386 syscallarg(uid_t) uid;
387 syscallarg(gid_t) gid;
388 } */ *uap = v;
389 struct sys_chown_args ua;
390
391 NETBSD32TOP_UAP(path, const char);
392 NETBSD32TO64_UAP(uid);
393 NETBSD32TO64_UAP(gid);
394
395 return (sys_chown(l, &ua, retval));
396 }
397
398 int
399 netbsd32_break(l, v, retval)
400 struct lwp *l;
401 void *v;
402 register_t *retval;
403 {
404 struct netbsd32_break_args /* {
405 syscallarg(netbsd32_charp) nsize;
406 } */ *uap = v;
407 struct sys_obreak_args ua;
408
409 SCARG(&ua, nsize) = (char *)NETBSD32PTR64(SCARG(uap, nsize));
410 NETBSD32TOP_UAP(nsize, char);
411 return (sys_obreak(l, &ua, retval));
412 }
413
414 int
415 netbsd32_mount(l, v, retval)
416 struct lwp *l;
417 void *v;
418 register_t *retval;
419 {
420 struct netbsd32_mount_args /* {
421 syscallarg(const netbsd32_charp) type;
422 syscallarg(const netbsd32_charp) path;
423 syscallarg(int) flags;
424 syscallarg(netbsd32_voidp) data;
425 } */ *uap = v;
426 struct sys_mount_args ua;
427
428 NETBSD32TOP_UAP(type, const char);
429 NETBSD32TOP_UAP(path, const char);
430 NETBSD32TO64_UAP(flags);
431 NETBSD32TOP_UAP(data, void);
432 return (sys_mount(l, &ua, retval));
433 }
434
435 int
436 netbsd32_unmount(l, v, retval)
437 struct lwp *l;
438 void *v;
439 register_t *retval;
440 {
441 struct netbsd32_unmount_args /* {
442 syscallarg(const netbsd32_charp) path;
443 syscallarg(int) flags;
444 } */ *uap = v;
445 struct sys_unmount_args ua;
446
447 NETBSD32TOP_UAP(path, const char);
448 NETBSD32TO64_UAP(flags);
449 return (sys_unmount(l, &ua, retval));
450 }
451
452 int
453 netbsd32_setuid(l, v, retval)
454 struct lwp *l;
455 void *v;
456 register_t *retval;
457 {
458 struct netbsd32_setuid_args /* {
459 syscallarg(uid_t) uid;
460 } */ *uap = v;
461 struct sys_setuid_args ua;
462
463 NETBSD32TO64_UAP(uid);
464 return (sys_setuid(l, &ua, retval));
465 }
466
467 int
468 netbsd32_ptrace(l, v, retval)
469 struct lwp *l;
470 void *v;
471 register_t *retval;
472 {
473 struct netbsd32_ptrace_args /* {
474 syscallarg(int) req;
475 syscallarg(pid_t) pid;
476 syscallarg(netbsd32_caddr_t) addr;
477 syscallarg(int) data;
478 } */ *uap = v;
479 struct sys_ptrace_args ua;
480
481 NETBSD32TO64_UAP(req);
482 NETBSD32TO64_UAP(pid);
483 NETBSD32TOX64_UAP(addr, caddr_t);
484 NETBSD32TO64_UAP(data);
485 return (sys_ptrace(l, &ua, retval));
486 }
487
488 int
489 netbsd32_accept(l, v, retval)
490 struct lwp *l;
491 void *v;
492 register_t *retval;
493 {
494 struct netbsd32_accept_args /* {
495 syscallarg(int) s;
496 syscallarg(netbsd32_sockaddrp_t) name;
497 syscallarg(netbsd32_intp) anamelen;
498 } */ *uap = v;
499 struct sys_accept_args ua;
500
501 NETBSD32TO64_UAP(s);
502 NETBSD32TOP_UAP(name, struct sockaddr);
503 NETBSD32TOP_UAP(anamelen, int);
504 return (sys_accept(l, &ua, retval));
505 }
506
507 int
508 netbsd32_getpeername(l, v, retval)
509 struct lwp *l;
510 void *v;
511 register_t *retval;
512 {
513 struct netbsd32_getpeername_args /* {
514 syscallarg(int) fdes;
515 syscallarg(netbsd32_sockaddrp_t) asa;
516 syscallarg(netbsd32_intp) alen;
517 } */ *uap = v;
518 struct sys_getpeername_args ua;
519
520 NETBSD32TO64_UAP(fdes);
521 NETBSD32TOP_UAP(asa, struct sockaddr);
522 NETBSD32TOP_UAP(alen, int);
523 /* NB: do the protocol specific sockaddrs need to be converted? */
524 return (sys_getpeername(l, &ua, retval));
525 }
526
527 int
528 netbsd32_getsockname(l, v, retval)
529 struct lwp *l;
530 void *v;
531 register_t *retval;
532 {
533 struct netbsd32_getsockname_args /* {
534 syscallarg(int) fdes;
535 syscallarg(netbsd32_sockaddrp_t) asa;
536 syscallarg(netbsd32_intp) alen;
537 } */ *uap = v;
538 struct sys_getsockname_args ua;
539
540 NETBSD32TO64_UAP(fdes);
541 NETBSD32TOP_UAP(asa, struct sockaddr);
542 NETBSD32TOP_UAP(alen, int);
543 return (sys_getsockname(l, &ua, retval));
544 }
545
546 int
547 netbsd32_access(l, v, retval)
548 struct lwp *l;
549 void *v;
550 register_t *retval;
551 {
552 struct netbsd32_access_args /* {
553 syscallarg(const netbsd32_charp) path;
554 syscallarg(int) flags;
555 } */ *uap = v;
556 struct sys_access_args ua;
557 caddr_t sg;
558
559 NETBSD32TOP_UAP(path, const char);
560 NETBSD32TO64_UAP(flags);
561 sg = stackgap_init(l->l_proc, 0);
562 CHECK_ALT_EXIST(l, &sg, SCARG(&ua, path));
563
564 return (sys_access(l, &ua, retval));
565 }
566
567 int
568 netbsd32_chflags(l, v, retval)
569 struct lwp *l;
570 void *v;
571 register_t *retval;
572 {
573 struct netbsd32_chflags_args /* {
574 syscallarg(const netbsd32_charp) path;
575 syscallarg(netbsd32_u_long) flags;
576 } */ *uap = v;
577 struct sys_chflags_args ua;
578
579 NETBSD32TOP_UAP(path, const char);
580 NETBSD32TO64_UAP(flags);
581
582 return (sys_chflags(l, &ua, retval));
583 }
584
585 int
586 netbsd32_fchflags(l, v, retval)
587 struct lwp *l;
588 void *v;
589 register_t *retval;
590 {
591 struct netbsd32_fchflags_args /* {
592 syscallarg(int) fd;
593 syscallarg(netbsd32_u_long) flags;
594 } */ *uap = v;
595 struct sys_fchflags_args ua;
596
597 NETBSD32TO64_UAP(fd);
598 NETBSD32TO64_UAP(flags);
599
600 return (sys_fchflags(l, &ua, retval));
601 }
602
603 int
604 netbsd32_lchflags(l, v, retval)
605 struct lwp *l;
606 void *v;
607 register_t *retval;
608 {
609 struct netbsd32_lchflags_args /* {
610 syscallarg(const char *) path;
611 syscallarg(netbsd32_u_long) flags;
612 } */ *uap = v;
613 struct sys_lchflags_args ua;
614
615 NETBSD32TOP_UAP(path, const char);
616 NETBSD32TO64_UAP(flags);
617
618 return (sys_lchflags(l, &ua, retval));
619 }
620
621 int
622 netbsd32_kill(l, v, retval)
623 struct lwp *l;
624 void *v;
625 register_t *retval;
626 {
627 struct netbsd32_kill_args /* {
628 syscallarg(int) pid;
629 syscallarg(int) signum;
630 } */ *uap = v;
631 struct sys_kill_args ua;
632
633 NETBSD32TO64_UAP(pid);
634 NETBSD32TO64_UAP(signum);
635
636 return (sys_kill(l, &ua, retval));
637 }
638
639 int
640 netbsd32_dup(l, v, retval)
641 struct lwp *l;
642 void *v;
643 register_t *retval;
644 {
645 struct netbsd32_dup_args /* {
646 syscallarg(int) fd;
647 } */ *uap = v;
648 struct sys_dup_args ua;
649
650 NETBSD32TO64_UAP(fd);
651
652 return (sys_dup(l, &ua, retval));
653 }
654
655 int
656 netbsd32_profil(l, v, retval)
657 struct lwp *l;
658 void *v;
659 register_t *retval;
660 {
661 struct netbsd32_profil_args /* {
662 syscallarg(netbsd32_caddr_t) samples;
663 syscallarg(netbsd32_size_t) size;
664 syscallarg(netbsd32_u_long) offset;
665 syscallarg(u_int) scale;
666 } */ *uap = v;
667 struct sys_profil_args ua;
668
669 NETBSD32TOX64_UAP(samples, caddr_t);
670 NETBSD32TOX_UAP(size, size_t);
671 NETBSD32TOX_UAP(offset, u_long);
672 NETBSD32TO64_UAP(scale);
673 return (sys_profil(l, &ua, retval));
674 }
675
676 #ifdef KTRACE
677 int
678 netbsd32_ktrace(l, v, retval)
679 struct lwp *l;
680 void *v;
681 register_t *retval;
682 {
683 struct netbsd32_ktrace_args /* {
684 syscallarg(const netbsd32_charp) fname;
685 syscallarg(int) ops;
686 syscallarg(int) facs;
687 syscallarg(int) pid;
688 } */ *uap = v;
689 struct sys_ktrace_args ua;
690
691 NETBSD32TOP_UAP(fname, const char);
692 NETBSD32TO64_UAP(ops);
693 NETBSD32TO64_UAP(facs);
694 NETBSD32TO64_UAP(pid);
695 return (sys_ktrace(l, &ua, retval));
696 }
697 #endif /* KTRACE */
698
699 int
700 netbsd32_utrace(l, v, retval)
701 struct lwp *l;
702 void *v;
703 register_t *retval;
704 {
705 struct netbsd32_utrace_args /* {
706 syscallarg(const netbsd32_charp) label;
707 syscallarg(netbsd32_voidp) addr;
708 syscallarg(netbsd32_size_t) len;
709 } */ *uap = v;
710 struct sys_utrace_args ua;
711
712 NETBSD32TOP_UAP(label, const char);
713 NETBSD32TOP_UAP(addr, void);
714 NETBSD32TO64_UAP(len);
715 return (sys_utrace(l, &ua, retval));
716 }
717
718 int
719 netbsd32___getlogin(l, v, retval)
720 struct lwp *l;
721 void *v;
722 register_t *retval;
723 {
724 struct netbsd32___getlogin_args /* {
725 syscallarg(netbsd32_charp) namebuf;
726 syscallarg(u_int) namelen;
727 } */ *uap = v;
728 struct sys___getlogin_args ua;
729
730 NETBSD32TOP_UAP(namebuf, char);
731 NETBSD32TO64_UAP(namelen);
732 return (sys___getlogin(l, &ua, retval));
733 }
734
735 int
736 netbsd32_setlogin(l, v, retval)
737 struct lwp *l;
738 void *v;
739 register_t *retval;
740 {
741 struct netbsd32_setlogin_args /* {
742 syscallarg(const netbsd32_charp) namebuf;
743 } */ *uap = v;
744 struct sys___setlogin_args ua;
745
746 NETBSD32TOP_UAP(namebuf, char);
747 return (sys___setlogin(l, &ua, retval));
748 }
749
750 int
751 netbsd32_acct(l, v, retval)
752 struct lwp *l;
753 void *v;
754 register_t *retval;
755 {
756 struct netbsd32_acct_args /* {
757 syscallarg(const netbsd32_charp) path;
758 } */ *uap = v;
759 struct sys_acct_args ua;
760
761 NETBSD32TOP_UAP(path, const char);
762 return (sys_acct(l, &ua, retval));
763 }
764
765 int
766 netbsd32_revoke(l, v, retval)
767 struct lwp *l;
768 void *v;
769 register_t *retval;
770 {
771 struct netbsd32_revoke_args /* {
772 syscallarg(const netbsd32_charp) path;
773 } */ *uap = v;
774 struct sys_revoke_args ua;
775 caddr_t sg;
776
777 NETBSD32TOP_UAP(path, const char);
778 sg = stackgap_init(l->l_proc, 0);
779 CHECK_ALT_EXIST(l, &sg, SCARG(&ua, path));
780
781 return (sys_revoke(l, &ua, retval));
782 }
783
784 int
785 netbsd32_symlink(l, v, retval)
786 struct lwp *l;
787 void *v;
788 register_t *retval;
789 {
790 struct netbsd32_symlink_args /* {
791 syscallarg(const netbsd32_charp) path;
792 syscallarg(const netbsd32_charp) link;
793 } */ *uap = v;
794 struct sys_symlink_args ua;
795
796 NETBSD32TOP_UAP(path, const char);
797 NETBSD32TOP_UAP(link, const char);
798
799 return (sys_symlink(l, &ua, retval));
800 }
801
802 int
803 netbsd32_readlink(l, v, retval)
804 struct lwp *l;
805 void *v;
806 register_t *retval;
807 {
808 struct netbsd32_readlink_args /* {
809 syscallarg(const netbsd32_charp) path;
810 syscallarg(netbsd32_charp) buf;
811 syscallarg(netbsd32_size_t) count;
812 } */ *uap = v;
813 struct sys_readlink_args ua;
814 caddr_t sg;
815
816 NETBSD32TOP_UAP(path, const char);
817 NETBSD32TOP_UAP(buf, char);
818 NETBSD32TOX_UAP(count, size_t);
819 sg = stackgap_init(l->l_proc, 0);
820 CHECK_ALT_SYMLINK(l, &sg, SCARG(&ua, path));
821
822 return (sys_readlink(l, &ua, retval));
823 }
824
825 int
826 netbsd32_umask(l, v, retval)
827 struct lwp *l;
828 void *v;
829 register_t *retval;
830 {
831 struct netbsd32_umask_args /* {
832 syscallarg(mode_t) newmask;
833 } */ *uap = v;
834 struct sys_umask_args ua;
835
836 NETBSD32TO64_UAP(newmask);
837 return (sys_umask(l, &ua, retval));
838 }
839
840 int
841 netbsd32_chroot(l, v, retval)
842 struct lwp *l;
843 void *v;
844 register_t *retval;
845 {
846 struct netbsd32_chroot_args /* {
847 syscallarg(const netbsd32_charp) path;
848 } */ *uap = v;
849 struct sys_chroot_args ua;
850
851 NETBSD32TOP_UAP(path, const char);
852 return (sys_chroot(l, &ua, retval));
853 }
854
855 int
856 netbsd32_sbrk(l, v, retval)
857 struct lwp *l;
858 void *v;
859 register_t *retval;
860 {
861 struct netbsd32_sbrk_args /* {
862 syscallarg(int) incr;
863 } */ *uap = v;
864 struct sys_sbrk_args ua;
865
866 NETBSD32TO64_UAP(incr);
867 return (sys_sbrk(l, &ua, retval));
868 }
869
870 int
871 netbsd32_sstk(l, v, retval)
872 struct lwp *l;
873 void *v;
874 register_t *retval;
875 {
876 struct netbsd32_sstk_args /* {
877 syscallarg(int) incr;
878 } */ *uap = v;
879 struct sys_sstk_args ua;
880
881 NETBSD32TO64_UAP(incr);
882 return (sys_sstk(l, &ua, retval));
883 }
884
885 int
886 netbsd32_munmap(l, v, retval)
887 struct lwp *l;
888 void *v;
889 register_t *retval;
890 {
891 struct netbsd32_munmap_args /* {
892 syscallarg(netbsd32_voidp) addr;
893 syscallarg(netbsd32_size_t) len;
894 } */ *uap = v;
895 struct sys_munmap_args ua;
896
897 NETBSD32TOP_UAP(addr, void);
898 NETBSD32TOX_UAP(len, size_t);
899 return (sys_munmap(l, &ua, retval));
900 }
901
902 int
903 netbsd32_mprotect(l, v, retval)
904 struct lwp *l;
905 void *v;
906 register_t *retval;
907 {
908 struct netbsd32_mprotect_args /* {
909 syscallarg(netbsd32_voidp) addr;
910 syscallarg(netbsd32_size_t) len;
911 syscallarg(int) prot;
912 } */ *uap = v;
913 struct sys_mprotect_args ua;
914
915 NETBSD32TOP_UAP(addr, void);
916 NETBSD32TOX_UAP(len, size_t);
917 NETBSD32TO64_UAP(prot);
918 return (sys_mprotect(l, &ua, retval));
919 }
920
921 int
922 netbsd32_madvise(l, v, retval)
923 struct lwp *l;
924 void *v;
925 register_t *retval;
926 {
927 struct netbsd32_madvise_args /* {
928 syscallarg(netbsd32_voidp) addr;
929 syscallarg(netbsd32_size_t) len;
930 syscallarg(int) behav;
931 } */ *uap = v;
932 struct sys_madvise_args ua;
933
934 NETBSD32TOP_UAP(addr, void);
935 NETBSD32TOX_UAP(len, size_t);
936 NETBSD32TO64_UAP(behav);
937 return (sys_madvise(l, &ua, retval));
938 }
939
940 int
941 netbsd32_mincore(l, v, retval)
942 struct lwp *l;
943 void *v;
944 register_t *retval;
945 {
946 struct netbsd32_mincore_args /* {
947 syscallarg(netbsd32_caddr_t) addr;
948 syscallarg(netbsd32_size_t) len;
949 syscallarg(netbsd32_charp) vec;
950 } */ *uap = v;
951 struct sys_mincore_args ua;
952
953 NETBSD32TOX64_UAP(addr, caddr_t);
954 NETBSD32TOX_UAP(len, size_t);
955 NETBSD32TOP_UAP(vec, char);
956 return (sys_mincore(l, &ua, retval));
957 }
958
959 /* XXX MOVE ME XXX ? */
960 int
961 netbsd32_getgroups(l, v, retval)
962 struct lwp *l;
963 void *v;
964 register_t *retval;
965 {
966 struct netbsd32_getgroups_args /* {
967 syscallarg(int) gidsetsize;
968 syscallarg(netbsd32_gid_tp) gidset;
969 } */ *uap = v;
970 struct pcred *pc = l->l_proc->p_cred;
971 int ngrp;
972 int error;
973
974 ngrp = SCARG(uap, gidsetsize);
975 if (ngrp == 0) {
976 *retval = pc->pc_ucred->cr_ngroups;
977 return (0);
978 }
979 if (ngrp < pc->pc_ucred->cr_ngroups)
980 return (EINVAL);
981 ngrp = pc->pc_ucred->cr_ngroups;
982 /* Should convert gid_t to netbsd32_gid_t, but they're the same */
983 error = copyout((caddr_t)pc->pc_ucred->cr_groups,
984 (caddr_t)NETBSD32PTR64(SCARG(uap, gidset)), ngrp * sizeof(gid_t));
985 if (error)
986 return (error);
987 *retval = ngrp;
988 return (0);
989 }
990
991 int
992 netbsd32_setgroups(l, v, retval)
993 struct lwp *l;
994 void *v;
995 register_t *retval;
996 {
997 struct netbsd32_setgroups_args /* {
998 syscallarg(int) gidsetsize;
999 syscallarg(const netbsd32_gid_tp) gidset;
1000 } */ *uap = v;
1001 struct sys_setgroups_args ua;
1002
1003 NETBSD32TO64_UAP(gidsetsize);
1004 NETBSD32TOP_UAP(gidset, gid_t);
1005 return (sys_setgroups(l, &ua, retval));
1006 }
1007
1008 int
1009 netbsd32_setpgid(l, v, retval)
1010 struct lwp *l;
1011 void *v;
1012 register_t *retval;
1013 {
1014 struct netbsd32_setpgid_args /* {
1015 syscallarg(int) pid;
1016 syscallarg(int) pgid;
1017 } */ *uap = v;
1018 struct sys_setpgid_args ua;
1019
1020 NETBSD32TO64_UAP(pid);
1021 NETBSD32TO64_UAP(pgid);
1022 return (sys_setpgid(l, &ua, retval));
1023 }
1024
1025 int
1026 netbsd32_fcntl(l, v, retval)
1027 struct lwp *l;
1028 void *v;
1029 register_t *retval;
1030 {
1031 struct netbsd32_fcntl_args /* {
1032 syscallarg(int) fd;
1033 syscallarg(int) cmd;
1034 syscallarg(netbsd32_voidp) arg;
1035 } */ *uap = v;
1036 struct sys_fcntl_args ua;
1037
1038 NETBSD32TO64_UAP(fd);
1039 NETBSD32TO64_UAP(cmd);
1040 NETBSD32TOP_UAP(arg, void);
1041 /* we can do this because `struct flock' doesn't change */
1042 return (sys_fcntl(l, &ua, retval));
1043 }
1044
1045 int
1046 netbsd32_dup2(l, v, retval)
1047 struct lwp *l;
1048 void *v;
1049 register_t *retval;
1050 {
1051 struct netbsd32_dup2_args /* {
1052 syscallarg(int) from;
1053 syscallarg(int) to;
1054 } */ *uap = v;
1055 struct sys_dup2_args ua;
1056
1057 NETBSD32TO64_UAP(from);
1058 NETBSD32TO64_UAP(to);
1059 return (sys_dup2(l, &ua, retval));
1060 }
1061
1062 int
1063 netbsd32_fsync(l, v, retval)
1064 struct lwp *l;
1065 void *v;
1066 register_t *retval;
1067 {
1068 struct netbsd32_fsync_args /* {
1069 syscallarg(int) fd;
1070 } */ *uap = v;
1071 struct sys_fsync_args ua;
1072
1073 NETBSD32TO64_UAP(fd);
1074 return (sys_fsync(l, &ua, retval));
1075 }
1076
1077 int
1078 netbsd32_setpriority(l, v, retval)
1079 struct lwp *l;
1080 void *v;
1081 register_t *retval;
1082 {
1083 struct netbsd32_setpriority_args /* {
1084 syscallarg(int) which;
1085 syscallarg(int) who;
1086 syscallarg(int) prio;
1087 } */ *uap = v;
1088 struct sys_setpriority_args ua;
1089
1090 NETBSD32TO64_UAP(which);
1091 NETBSD32TO64_UAP(who);
1092 NETBSD32TO64_UAP(prio);
1093 return (sys_setpriority(l, &ua, retval));
1094 }
1095
1096 int
1097 netbsd32_socket(l, v, retval)
1098 struct lwp *l;
1099 void *v;
1100 register_t *retval;
1101 {
1102 struct netbsd32_socket_args /* {
1103 syscallarg(int) domain;
1104 syscallarg(int) type;
1105 syscallarg(int) protocol;
1106 } */ *uap = v;
1107 struct sys_socket_args ua;
1108
1109 NETBSD32TO64_UAP(domain);
1110 NETBSD32TO64_UAP(type);
1111 NETBSD32TO64_UAP(protocol);
1112 return (sys_socket(l, &ua, retval));
1113 }
1114
1115 int
1116 netbsd32_connect(l, v, retval)
1117 struct lwp *l;
1118 void *v;
1119 register_t *retval;
1120 {
1121 struct netbsd32_connect_args /* {
1122 syscallarg(int) s;
1123 syscallarg(const netbsd32_sockaddrp_t) name;
1124 syscallarg(int) namelen;
1125 } */ *uap = v;
1126 struct sys_connect_args ua;
1127
1128 NETBSD32TO64_UAP(s);
1129 NETBSD32TOP_UAP(name, struct sockaddr);
1130 NETBSD32TO64_UAP(namelen);
1131 return (sys_connect(l, &ua, retval));
1132 }
1133
1134 int
1135 netbsd32_getpriority(l, v, retval)
1136 struct lwp *l;
1137 void *v;
1138 register_t *retval;
1139 {
1140 struct netbsd32_getpriority_args /* {
1141 syscallarg(int) which;
1142 syscallarg(int) who;
1143 } */ *uap = v;
1144 struct sys_getpriority_args ua;
1145
1146 NETBSD32TO64_UAP(which);
1147 NETBSD32TO64_UAP(who);
1148 return (sys_getpriority(l, &ua, retval));
1149 }
1150
1151 int
1152 netbsd32_bind(l, v, retval)
1153 struct lwp *l;
1154 void *v;
1155 register_t *retval;
1156 {
1157 struct netbsd32_bind_args /* {
1158 syscallarg(int) s;
1159 syscallarg(const netbsd32_sockaddrp_t) name;
1160 syscallarg(int) namelen;
1161 } */ *uap = v;
1162 struct sys_bind_args ua;
1163
1164 NETBSD32TO64_UAP(s);
1165 NETBSD32TOP_UAP(name, struct sockaddr);
1166 NETBSD32TO64_UAP(namelen);
1167 return (sys_bind(l, &ua, retval));
1168 }
1169
1170 int
1171 netbsd32_setsockopt(l, v, retval)
1172 struct lwp *l;
1173 void *v;
1174 register_t *retval;
1175 {
1176 struct netbsd32_setsockopt_args /* {
1177 syscallarg(int) s;
1178 syscallarg(int) level;
1179 syscallarg(int) name;
1180 syscallarg(const netbsd32_voidp) val;
1181 syscallarg(int) valsize;
1182 } */ *uap = v;
1183 struct sys_setsockopt_args ua;
1184
1185 NETBSD32TO64_UAP(s);
1186 NETBSD32TO64_UAP(level);
1187 NETBSD32TO64_UAP(name);
1188 NETBSD32TOP_UAP(val, void);
1189 NETBSD32TO64_UAP(valsize);
1190 /* may be more efficient to do this inline. */
1191 return (sys_setsockopt(l, &ua, retval));
1192 }
1193
1194 int
1195 netbsd32_listen(l, v, retval)
1196 struct lwp *l;
1197 void *v;
1198 register_t *retval;
1199 {
1200 struct netbsd32_listen_args /* {
1201 syscallarg(int) s;
1202 syscallarg(int) backlog;
1203 } */ *uap = v;
1204 struct sys_listen_args ua;
1205
1206 NETBSD32TO64_UAP(s);
1207 NETBSD32TO64_UAP(backlog);
1208 return (sys_listen(l, &ua, retval));
1209 }
1210
1211 int
1212 netbsd32_fchown(l, v, retval)
1213 struct lwp *l;
1214 void *v;
1215 register_t *retval;
1216 {
1217 struct netbsd32_fchown_args /* {
1218 syscallarg(int) fd;
1219 syscallarg(uid_t) uid;
1220 syscallarg(gid_t) gid;
1221 } */ *uap = v;
1222 struct sys_fchown_args ua;
1223
1224 NETBSD32TO64_UAP(fd);
1225 NETBSD32TO64_UAP(uid);
1226 NETBSD32TO64_UAP(gid);
1227 return (sys_fchown(l, &ua, retval));
1228 }
1229
1230 int
1231 netbsd32_fchmod(l, v, retval)
1232 struct lwp *l;
1233 void *v;
1234 register_t *retval;
1235 {
1236 struct netbsd32_fchmod_args /* {
1237 syscallarg(int) fd;
1238 syscallarg(mode_t) mode;
1239 } */ *uap = v;
1240 struct sys_fchmod_args ua;
1241
1242 NETBSD32TO64_UAP(fd);
1243 NETBSD32TO64_UAP(mode);
1244 return (sys_fchmod(l, &ua, retval));
1245 }
1246
1247 int
1248 netbsd32_setreuid(l, v, retval)
1249 struct lwp *l;
1250 void *v;
1251 register_t *retval;
1252 {
1253 struct netbsd32_setreuid_args /* {
1254 syscallarg(uid_t) ruid;
1255 syscallarg(uid_t) euid;
1256 } */ *uap = v;
1257 struct sys_setreuid_args ua;
1258
1259 NETBSD32TO64_UAP(ruid);
1260 NETBSD32TO64_UAP(euid);
1261 return (sys_setreuid(l, &ua, retval));
1262 }
1263
1264 int
1265 netbsd32_setregid(l, v, retval)
1266 struct lwp *l;
1267 void *v;
1268 register_t *retval;
1269 {
1270 struct netbsd32_setregid_args /* {
1271 syscallarg(gid_t) rgid;
1272 syscallarg(gid_t) egid;
1273 } */ *uap = v;
1274 struct sys_setregid_args ua;
1275
1276 NETBSD32TO64_UAP(rgid);
1277 NETBSD32TO64_UAP(egid);
1278 return (sys_setregid(l, &ua, retval));
1279 }
1280
1281 int
1282 netbsd32_getsockopt(l, v, retval)
1283 struct lwp *l;
1284 void *v;
1285 register_t *retval;
1286 {
1287 struct netbsd32_getsockopt_args /* {
1288 syscallarg(int) s;
1289 syscallarg(int) level;
1290 syscallarg(int) name;
1291 syscallarg(netbsd32_voidp) val;
1292 syscallarg(netbsd32_intp) avalsize;
1293 } */ *uap = v;
1294 struct sys_getsockopt_args ua;
1295
1296 NETBSD32TO64_UAP(s);
1297 NETBSD32TO64_UAP(level);
1298 NETBSD32TO64_UAP(name);
1299 NETBSD32TOP_UAP(val, void);
1300 NETBSD32TOP_UAP(avalsize, int);
1301 return (sys_getsockopt(l, &ua, retval));
1302 }
1303
1304 int
1305 netbsd32_rename(l, v, retval)
1306 struct lwp *l;
1307 void *v;
1308 register_t *retval;
1309 {
1310 struct netbsd32_rename_args /* {
1311 syscallarg(const netbsd32_charp) from;
1312 syscallarg(const netbsd32_charp) to;
1313 } */ *uap = v;
1314 struct sys_rename_args ua;
1315
1316 NETBSD32TOP_UAP(from, const char);
1317 NETBSD32TOP_UAP(to, const char)
1318
1319 return (sys_rename(l, &ua, retval));
1320 }
1321
1322 int
1323 netbsd32_flock(l, v, retval)
1324 struct lwp *l;
1325 void *v;
1326 register_t *retval;
1327 {
1328 struct netbsd32_flock_args /* {
1329 syscallarg(int) fd;
1330 syscallarg(int) how;
1331 } */ *uap = v;
1332 struct sys_flock_args ua;
1333
1334 NETBSD32TO64_UAP(fd);
1335 NETBSD32TO64_UAP(how)
1336
1337 return (sys_flock(l, &ua, retval));
1338 }
1339
1340 int
1341 netbsd32_mkfifo(l, v, retval)
1342 struct lwp *l;
1343 void *v;
1344 register_t *retval;
1345 {
1346 struct netbsd32_mkfifo_args /* {
1347 syscallarg(const netbsd32_charp) path;
1348 syscallarg(mode_t) mode;
1349 } */ *uap = v;
1350 struct sys_mkfifo_args ua;
1351
1352 NETBSD32TOP_UAP(path, const char)
1353 NETBSD32TO64_UAP(mode);
1354 return (sys_mkfifo(l, &ua, retval));
1355 }
1356
1357 int
1358 netbsd32_shutdown(l, v, retval)
1359 struct lwp *l;
1360 void *v;
1361 register_t *retval;
1362 {
1363 struct netbsd32_shutdown_args /* {
1364 syscallarg(int) s;
1365 syscallarg(int) how;
1366 } */ *uap = v;
1367 struct sys_shutdown_args ua;
1368
1369 NETBSD32TO64_UAP(s)
1370 NETBSD32TO64_UAP(how);
1371 return (sys_shutdown(l, &ua, retval));
1372 }
1373
1374 int
1375 netbsd32_socketpair(l, v, retval)
1376 struct lwp *l;
1377 void *v;
1378 register_t *retval;
1379 {
1380 struct netbsd32_socketpair_args /* {
1381 syscallarg(int) domain;
1382 syscallarg(int) type;
1383 syscallarg(int) protocol;
1384 syscallarg(netbsd32_intp) rsv;
1385 } */ *uap = v;
1386 struct sys_socketpair_args ua;
1387
1388 NETBSD32TO64_UAP(domain);
1389 NETBSD32TO64_UAP(type);
1390 NETBSD32TO64_UAP(protocol);
1391 NETBSD32TOP_UAP(rsv, int);
1392 /* Since we're just copying out two `int's we can do this */
1393 return (sys_socketpair(l, &ua, retval));
1394 }
1395
1396 int
1397 netbsd32_mkdir(l, v, retval)
1398 struct lwp *l;
1399 void *v;
1400 register_t *retval;
1401 {
1402 struct netbsd32_mkdir_args /* {
1403 syscallarg(const netbsd32_charp) path;
1404 syscallarg(mode_t) mode;
1405 } */ *uap = v;
1406 struct sys_mkdir_args ua;
1407
1408 NETBSD32TOP_UAP(path, const char)
1409 NETBSD32TO64_UAP(mode);
1410 return (sys_mkdir(l, &ua, retval));
1411 }
1412
1413 int
1414 netbsd32_rmdir(l, v, retval)
1415 struct lwp *l;
1416 void *v;
1417 register_t *retval;
1418 {
1419 struct netbsd32_rmdir_args /* {
1420 syscallarg(const netbsd32_charp) path;
1421 } */ *uap = v;
1422 struct sys_rmdir_args ua;
1423
1424 NETBSD32TOP_UAP(path, const char);
1425 return (sys_rmdir(l, &ua, retval));
1426 }
1427
1428 int
1429 netbsd32_quotactl(l, v, retval)
1430 struct lwp *l;
1431 void *v;
1432 register_t *retval;
1433 {
1434 struct netbsd32_quotactl_args /* {
1435 syscallarg(const netbsd32_charp) path;
1436 syscallarg(int) cmd;
1437 syscallarg(int) uid;
1438 syscallarg(netbsd32_caddr_t) arg;
1439 } */ *uap = v;
1440 struct sys_quotactl_args ua;
1441
1442 NETBSD32TOP_UAP(path, const char);
1443 NETBSD32TO64_UAP(cmd);
1444 NETBSD32TO64_UAP(uid);
1445 NETBSD32TOX64_UAP(arg, caddr_t);
1446 return (sys_quotactl(l, &ua, retval));
1447 }
1448
1449 #if defined(NFS) || defined(NFSSERVER)
1450 int
1451 netbsd32_nfssvc(l, v, retval)
1452 struct lwp *l;
1453 void *v;
1454 register_t *retval;
1455 {
1456 #if 0
1457 struct netbsd32_nfssvc_args /* {
1458 syscallarg(int) flag;
1459 syscallarg(netbsd32_voidp) argp;
1460 } */ *uap = v;
1461 struct sys_nfssvc_args ua;
1462
1463 NETBSD32TO64_UAP(flag);
1464 NETBSD32TOP_UAP(argp, void);
1465 return (sys_nfssvc(l, &ua, retval));
1466 #else
1467 /* Why would we want to support a 32-bit nfsd? */
1468 return (ENOSYS);
1469 #endif
1470 }
1471 #endif
1472
1473 #if defined(NFS) || defined(NFSSERVER)
1474 int
1475 netbsd32_getfh(l, v, retval)
1476 struct lwp *l;
1477 void *v;
1478 register_t *retval;
1479 {
1480 struct netbsd32_getfh_args /* {
1481 syscallarg(const netbsd32_charp) fname;
1482 syscallarg(netbsd32_fhandlep_t) fhp;
1483 } */ *uap = v;
1484 struct sys_getfh_args ua;
1485
1486 NETBSD32TOP_UAP(fname, const char);
1487 NETBSD32TOP_UAP(fhp, struct fhandle);
1488 /* Lucky for us a fhandlep_t doesn't change sizes */
1489 return (sys_getfh(l, &ua, retval));
1490 }
1491 #endif
1492
1493 int
1494 netbsd32_pread(l, v, retval)
1495 struct lwp *l;
1496 void *v;
1497 register_t *retval;
1498 {
1499 struct netbsd32_pread_args /* {
1500 syscallarg(int) fd;
1501 syscallarg(netbsd32_voidp) buf;
1502 syscallarg(netbsd32_size_t) nbyte;
1503 syscallarg(int) pad;
1504 syscallarg(off_t) offset;
1505 } */ *uap = v;
1506 struct sys_pread_args ua;
1507 ssize_t rt;
1508 int error;
1509
1510 NETBSD32TO64_UAP(fd);
1511 NETBSD32TOP_UAP(buf, void);
1512 NETBSD32TOX_UAP(nbyte, size_t);
1513 NETBSD32TO64_UAP(pad);
1514 NETBSD32TO64_UAP(offset);
1515 error = sys_pread(l, &ua, (register_t *)&rt);
1516 *retval = rt;
1517 return (error);
1518 }
1519
1520 int
1521 netbsd32_pwrite(l, v, retval)
1522 struct lwp *l;
1523 void *v;
1524 register_t *retval;
1525 {
1526 struct netbsd32_pwrite_args /* {
1527 syscallarg(int) fd;
1528 syscallarg(const netbsd32_voidp) buf;
1529 syscallarg(netbsd32_size_t) nbyte;
1530 syscallarg(int) pad;
1531 syscallarg(off_t) offset;
1532 } */ *uap = v;
1533 struct sys_pwrite_args ua;
1534 ssize_t rt;
1535 int error;
1536
1537 NETBSD32TO64_UAP(fd);
1538 NETBSD32TOP_UAP(buf, void);
1539 NETBSD32TOX_UAP(nbyte, size_t);
1540 NETBSD32TO64_UAP(pad);
1541 NETBSD32TO64_UAP(offset);
1542 error = sys_pwrite(l, &ua, (register_t *)&rt);
1543 *retval = rt;
1544 return (error);
1545 }
1546
1547 int
1548 netbsd32_setgid(l, v, retval)
1549 struct lwp *l;
1550 void *v;
1551 register_t *retval;
1552 {
1553 struct netbsd32_setgid_args /* {
1554 syscallarg(gid_t) gid;
1555 } */ *uap = v;
1556 struct sys_setgid_args ua;
1557
1558 NETBSD32TO64_UAP(gid);
1559 return (sys_setgid(l, v, retval));
1560 }
1561
1562 int
1563 netbsd32_setegid(l, v, retval)
1564 struct lwp *l;
1565 void *v;
1566 register_t *retval;
1567 {
1568 struct netbsd32_setegid_args /* {
1569 syscallarg(gid_t) egid;
1570 } */ *uap = v;
1571 struct sys_setegid_args ua;
1572
1573 NETBSD32TO64_UAP(egid);
1574 return (sys_setegid(l, v, retval));
1575 }
1576
1577 int
1578 netbsd32_seteuid(l, v, retval)
1579 struct lwp *l;
1580 void *v;
1581 register_t *retval;
1582 {
1583 struct netbsd32_seteuid_args /* {
1584 syscallarg(gid_t) euid;
1585 } */ *uap = v;
1586 struct sys_seteuid_args ua;
1587
1588 NETBSD32TO64_UAP(euid);
1589 return (sys_seteuid(l, v, retval));
1590 }
1591
1592 #ifdef LFS
1593 int
1594 netbsd32_sys_lfs_bmapv(l, v, retval)
1595 struct lwp *l;
1596 void *v;
1597 register_t *retval;
1598 {
1599
1600 return (ENOSYS); /* XXX */
1601 }
1602
1603 int
1604 netbsd32_sys_lfs_markv(l, v, retval)
1605 struct lwp *l;
1606 void *v;
1607 register_t *retval;
1608 {
1609
1610 return (ENOSYS); /* XXX */
1611 }
1612
1613 int
1614 netbsd32_sys_lfs_segclean(l, v, retval)
1615 struct lwp *l;
1616 void *v;
1617 register_t *retval;
1618 {
1619
1620 return (ENOSYS); /* XXX */
1621 }
1622
1623 int
1624 netbsd32_sys_lfs_segwait(l, v, retval)
1625 struct lwp *l;
1626 void *v;
1627 register_t *retval;
1628 {
1629
1630 return (ENOSYS); /* XXX */
1631 }
1632 #endif
1633
1634 int
1635 netbsd32_pathconf(l, v, retval)
1636 struct lwp *l;
1637 void *v;
1638 register_t *retval;
1639 {
1640 struct netbsd32_pathconf_args /* {
1641 syscallarg(int) fd;
1642 syscallarg(int) name;
1643 } */ *uap = v;
1644 struct sys_pathconf_args ua;
1645 long rt;
1646 int error;
1647
1648 NETBSD32TOP_UAP(path, const char);
1649 NETBSD32TO64_UAP(name);
1650 error = sys_pathconf(l, &ua, (register_t *)&rt);
1651 *retval = rt;
1652 return (error);
1653 }
1654
1655 int
1656 netbsd32_fpathconf(l, v, retval)
1657 struct lwp *l;
1658 void *v;
1659 register_t *retval;
1660 {
1661 struct netbsd32_fpathconf_args /* {
1662 syscallarg(int) fd;
1663 syscallarg(int) name;
1664 } */ *uap = v;
1665 struct sys_fpathconf_args ua;
1666 long rt;
1667 int error;
1668
1669 NETBSD32TO64_UAP(fd);
1670 NETBSD32TO64_UAP(name);
1671 error = sys_fpathconf(l, &ua, (register_t *)&rt);
1672 *retval = rt;
1673 return (error);
1674 }
1675
1676 int
1677 netbsd32_getrlimit(l, v, retval)
1678 struct lwp *l;
1679 void *v;
1680 register_t *retval;
1681 {
1682 struct netbsd32_getrlimit_args /* {
1683 syscallarg(int) which;
1684 syscallarg(netbsd32_rlimitp_t) rlp;
1685 } */ *uap = v;
1686 int which = SCARG(uap, which);
1687
1688 if ((u_int)which >= RLIM_NLIMITS)
1689 return (EINVAL);
1690 return (copyout(&l->l_proc->p_rlimit[which],
1691 (caddr_t)NETBSD32PTR64(SCARG(uap, rlp)), sizeof(struct rlimit)));
1692 }
1693
1694 int
1695 netbsd32_setrlimit(l, v, retval)
1696 struct lwp *l;
1697 void *v;
1698 register_t *retval;
1699 {
1700 struct netbsd32_setrlimit_args /* {
1701 syscallarg(int) which;
1702 syscallarg(const netbsd32_rlimitp_t) rlp;
1703 } */ *uap = v;
1704 int which = SCARG(uap, which);
1705 struct rlimit alim;
1706 int error;
1707 struct proc *p = l->l_proc;
1708
1709 error = copyin((caddr_t)NETBSD32PTR64(SCARG(uap, rlp)), &alim,
1710 sizeof(struct rlimit));
1711 if (error)
1712 return (error);
1713
1714 switch (which) {
1715 case RLIMIT_DATA:
1716 if (alim.rlim_cur > MAXDSIZ32)
1717 alim.rlim_cur = MAXDSIZ32;
1718 if (alim.rlim_max > MAXDSIZ32)
1719 alim.rlim_max = MAXDSIZ32;
1720 break;
1721
1722 case RLIMIT_STACK:
1723 if (alim.rlim_cur > MAXSSIZ32)
1724 alim.rlim_cur = MAXSSIZ32;
1725 if (alim.rlim_max > MAXSSIZ32)
1726 alim.rlim_max = MAXSSIZ32;
1727 default:
1728 break;
1729 }
1730
1731 return (dosetrlimit(p, p->p_cred, which, &alim));
1732 }
1733
1734 int
1735 netbsd32_mmap(l, v, retval)
1736 struct lwp *l;
1737 void *v;
1738 register_t *retval;
1739 {
1740 struct netbsd32_mmap_args /* {
1741 syscallarg(netbsd32_voidp) addr;
1742 syscallarg(netbsd32_size_t) len;
1743 syscallarg(int) prot;
1744 syscallarg(int) flags;
1745 syscallarg(int) fd;
1746 syscallarg(netbsd32_long) pad;
1747 syscallarg(off_t) pos;
1748 } */ *uap = v;
1749 struct sys_mmap_args ua;
1750 int error;
1751
1752 NETBSD32TOP_UAP(addr, void);
1753 NETBSD32TOX_UAP(len, size_t);
1754 NETBSD32TO64_UAP(prot);
1755 NETBSD32TO64_UAP(flags);
1756 NETBSD32TO64_UAP(fd);
1757 NETBSD32TOX_UAP(pad, long);
1758 NETBSD32TOX_UAP(pos, off_t);
1759 error = sys_mmap(l, &ua, retval);
1760 if ((u_long)*retval > (u_long)UINT_MAX) {
1761 printf("netbsd32_mmap: retval out of range: 0x%lx",
1762 (u_long)*retval);
1763 /* Should try to recover and return an error here. */
1764 }
1765 return (error);
1766 }
1767
1768 int
1769 netbsd32_lseek(l, v, retval)
1770 struct lwp *l;
1771 void *v;
1772 register_t *retval;
1773 {
1774 struct netbsd32_lseek_args /* {
1775 syscallarg(int) fd;
1776 syscallarg(int) pad;
1777 syscallarg(off_t) offset;
1778 syscallarg(int) whence;
1779 } */ *uap = v;
1780 struct sys_lseek_args ua;
1781 int rv;
1782
1783 NETBSD32TO64_UAP(fd);
1784 NETBSD32TO64_UAP(pad);
1785 NETBSD32TO64_UAP(offset);
1786 NETBSD32TO64_UAP(whence);
1787 rv = sys_lseek(l, &ua, retval);
1788 #ifdef NETBSD32_OFF_T_RETURN
1789 if (rv == 0)
1790 NETBSD32_OFF_T_RETURN(retval);
1791 #endif
1792 return rv;
1793 }
1794
1795 int
1796 netbsd32_truncate(l, v, retval)
1797 struct lwp *l;
1798 void *v;
1799 register_t *retval;
1800 {
1801 struct netbsd32_truncate_args /* {
1802 syscallarg(const netbsd32_charp) path;
1803 syscallarg(int) pad;
1804 syscallarg(off_t) length;
1805 } */ *uap = v;
1806 struct sys_truncate_args ua;
1807
1808 NETBSD32TOP_UAP(path, const char);
1809 NETBSD32TO64_UAP(pad);
1810 NETBSD32TO64_UAP(length);
1811 return (sys_truncate(l, &ua, retval));
1812 }
1813
1814 int
1815 netbsd32_ftruncate(l, v, retval)
1816 struct lwp *l;
1817 void *v;
1818 register_t *retval;
1819 {
1820 struct netbsd32_ftruncate_args /* {
1821 syscallarg(int) fd;
1822 syscallarg(int) pad;
1823 syscallarg(off_t) length;
1824 } */ *uap = v;
1825 struct sys_ftruncate_args ua;
1826
1827 NETBSD32TO64_UAP(fd);
1828 NETBSD32TO64_UAP(pad);
1829 NETBSD32TO64_UAP(length);
1830 return (sys_ftruncate(l, &ua, retval));
1831 }
1832
1833 int
1834 netbsd32_mlock(l, v, retval)
1835 struct lwp *l;
1836 void *v;
1837 register_t *retval;
1838 {
1839 struct netbsd32_mlock_args /* {
1840 syscallarg(const netbsd32_voidp) addr;
1841 syscallarg(netbsd32_size_t) len;
1842 } */ *uap = v;
1843 struct sys_mlock_args ua;
1844
1845 NETBSD32TOP_UAP(addr, const void);
1846 NETBSD32TO64_UAP(len);
1847 return (sys_mlock(l, &ua, retval));
1848 }
1849
1850 int
1851 netbsd32_munlock(l, v, retval)
1852 struct lwp *l;
1853 void *v;
1854 register_t *retval;
1855 {
1856 struct netbsd32_munlock_args /* {
1857 syscallarg(const netbsd32_voidp) addr;
1858 syscallarg(netbsd32_size_t) len;
1859 } */ *uap = v;
1860 struct sys_munlock_args ua;
1861
1862 NETBSD32TOP_UAP(addr, const void);
1863 NETBSD32TO64_UAP(len);
1864 return (sys_munlock(l, &ua, retval));
1865 }
1866
1867 int
1868 netbsd32_undelete(l, v, retval)
1869 struct lwp *l;
1870 void *v;
1871 register_t *retval;
1872 {
1873 struct netbsd32_undelete_args /* {
1874 syscallarg(const netbsd32_charp) path;
1875 } */ *uap = v;
1876 struct sys_undelete_args ua;
1877
1878 NETBSD32TOP_UAP(path, const char);
1879 return (sys_undelete(l, &ua, retval));
1880 }
1881
1882 int
1883 netbsd32_getpgid(l, v, retval)
1884 struct lwp *l;
1885 void *v;
1886 register_t *retval;
1887 {
1888 struct netbsd32_getpgid_args /* {
1889 syscallarg(pid_t) pid;
1890 } */ *uap = v;
1891 struct sys_getpgid_args ua;
1892
1893 NETBSD32TO64_UAP(pid);
1894 return (sys_getpgid(l, &ua, retval));
1895 }
1896
1897 int
1898 netbsd32_reboot(l, v, retval)
1899 struct lwp *l;
1900 void *v;
1901 register_t *retval;
1902 {
1903 struct netbsd32_reboot_args /* {
1904 syscallarg(int) opt;
1905 syscallarg(netbsd32_charp) bootstr;
1906 } */ *uap = v;
1907 struct sys_reboot_args ua;
1908
1909 NETBSD32TO64_UAP(opt);
1910 NETBSD32TOP_UAP(bootstr, char);
1911 return (sys_reboot(l, &ua, retval));
1912 }
1913
1914 #include <sys/poll.h>
1915 int
1916 netbsd32_poll(l, v, retval)
1917 struct lwp *l;
1918 void *v;
1919 register_t *retval;
1920 {
1921 struct netbsd32_poll_args /* {
1922 syscallarg(netbsd32_pollfdp_t) fds;
1923 syscallarg(u_int) nfds;
1924 syscallarg(int) timeout;
1925 } */ *uap = v;
1926 struct sys_poll_args ua;
1927
1928 NETBSD32TOP_UAP(fds, struct pollfd);
1929 NETBSD32TO64_UAP(nfds);
1930 NETBSD32TO64_UAP(timeout);
1931
1932 return (sys_poll(l, &ua, retval));
1933 }
1934
1935 int
1936 netbsd32_fdatasync(l, v, retval)
1937 struct lwp *l;
1938 void *v;
1939 register_t *retval;
1940 {
1941 struct netbsd32_fdatasync_args /* {
1942 syscallarg(int) fd;
1943 } */ *uap = v;
1944 struct sys_fdatasync_args ua;
1945
1946 NETBSD32TO64_UAP(fd);
1947 return (sys_fdatasync(l, &ua, retval));
1948 }
1949
1950 int
1951 netbsd32___posix_rename(l, v, retval)
1952 struct lwp *l;
1953 void *v;
1954 register_t *retval;
1955 {
1956 struct netbsd32___posix_rename_args /* {
1957 syscallarg(const netbsd32_charp) from;
1958 syscallarg(const netbsd32_charp) to;
1959 } */ *uap = v;
1960 struct sys___posix_rename_args ua;
1961
1962 NETBSD32TOP_UAP(from, const char);
1963 NETBSD32TOP_UAP(to, const char);
1964 return (sys___posix_rename(l, &ua, retval));
1965 }
1966
1967 int
1968 netbsd32_swapctl(l, v, retval)
1969 struct lwp *l;
1970 void *v;
1971 register_t *retval;
1972 {
1973 struct netbsd32_swapctl_args /* {
1974 syscallarg(int) cmd;
1975 syscallarg(const netbsd32_voidp) arg;
1976 syscallarg(int) misc;
1977 } */ *uap = v;
1978 struct sys_swapctl_args ua;
1979
1980 NETBSD32TO64_UAP(cmd);
1981 NETBSD32TOP_UAP(arg, void);
1982 NETBSD32TO64_UAP(misc);
1983 return (sys_swapctl(l, &ua, retval));
1984 }
1985
1986 int
1987 netbsd32_minherit(l, v, retval)
1988 struct lwp *l;
1989 void *v;
1990 register_t *retval;
1991 {
1992 struct netbsd32_minherit_args /* {
1993 syscallarg(netbsd32_voidp) addr;
1994 syscallarg(netbsd32_size_t) len;
1995 syscallarg(int) inherit;
1996 } */ *uap = v;
1997 struct sys_minherit_args ua;
1998
1999 NETBSD32TOP_UAP(addr, void);
2000 NETBSD32TOX_UAP(len, size_t);
2001 NETBSD32TO64_UAP(inherit);
2002 return (sys_minherit(l, &ua, retval));
2003 }
2004
2005 int
2006 netbsd32_lchmod(l, v, retval)
2007 struct lwp *l;
2008 void *v;
2009 register_t *retval;
2010 {
2011 struct netbsd32_lchmod_args /* {
2012 syscallarg(const netbsd32_charp) path;
2013 syscallarg(mode_t) mode;
2014 } */ *uap = v;
2015 struct sys_lchmod_args ua;
2016
2017 NETBSD32TOP_UAP(path, const char);
2018 NETBSD32TO64_UAP(mode);
2019 return (sys_lchmod(l, &ua, retval));
2020 }
2021
2022 int
2023 netbsd32_lchown(l, v, retval)
2024 struct lwp *l;
2025 void *v;
2026 register_t *retval;
2027 {
2028 struct netbsd32_lchown_args /* {
2029 syscallarg(const netbsd32_charp) path;
2030 syscallarg(uid_t) uid;
2031 syscallarg(gid_t) gid;
2032 } */ *uap = v;
2033 struct sys_lchown_args ua;
2034
2035 NETBSD32TOP_UAP(path, const char);
2036 NETBSD32TO64_UAP(uid);
2037 NETBSD32TO64_UAP(gid);
2038 return (sys_lchown(l, &ua, retval));
2039 }
2040
2041 int
2042 netbsd32___msync13(l, v, retval)
2043 struct lwp *l;
2044 void *v;
2045 register_t *retval;
2046 {
2047 struct netbsd32___msync13_args /* {
2048 syscallarg(netbsd32_voidp) addr;
2049 syscallarg(netbsd32_size_t) len;
2050 syscallarg(int) flags;
2051 } */ *uap = v;
2052 struct sys___msync13_args ua;
2053
2054 NETBSD32TOP_UAP(addr, void);
2055 NETBSD32TOX_UAP(len, size_t);
2056 NETBSD32TO64_UAP(flags);
2057 return (sys___msync13(l, &ua, retval));
2058 }
2059
2060 int
2061 netbsd32___posix_chown(l, v, retval)
2062 struct lwp *l;
2063 void *v;
2064 register_t *retval;
2065 {
2066 struct netbsd32___posix_chown_args /* {
2067 syscallarg(const netbsd32_charp) path;
2068 syscallarg(uid_t) uid;
2069 syscallarg(gid_t) gid;
2070 } */ *uap = v;
2071 struct sys___posix_chown_args ua;
2072
2073 NETBSD32TOP_UAP(path, const char);
2074 NETBSD32TO64_UAP(uid);
2075 NETBSD32TO64_UAP(gid);
2076 return (sys___posix_chown(l, &ua, retval));
2077 }
2078
2079 int
2080 netbsd32___posix_fchown(l, v, retval)
2081 struct lwp *l;
2082 void *v;
2083 register_t *retval;
2084 {
2085 struct netbsd32___posix_fchown_args /* {
2086 syscallarg(int) fd;
2087 syscallarg(uid_t) uid;
2088 syscallarg(gid_t) gid;
2089 } */ *uap = v;
2090 struct sys___posix_fchown_args ua;
2091
2092 NETBSD32TO64_UAP(fd);
2093 NETBSD32TO64_UAP(uid);
2094 NETBSD32TO64_UAP(gid);
2095 return (sys___posix_fchown(l, &ua, retval));
2096 }
2097
2098 int
2099 netbsd32___posix_lchown(l, v, retval)
2100 struct lwp *l;
2101 void *v;
2102 register_t *retval;
2103 {
2104 struct netbsd32___posix_lchown_args /* {
2105 syscallarg(const netbsd32_charp) path;
2106 syscallarg(uid_t) uid;
2107 syscallarg(gid_t) gid;
2108 } */ *uap = v;
2109 struct sys___posix_lchown_args ua;
2110
2111 NETBSD32TOP_UAP(path, const char);
2112 NETBSD32TO64_UAP(uid);
2113 NETBSD32TO64_UAP(gid);
2114 return (sys___posix_lchown(l, &ua, retval));
2115 }
2116
2117 int
2118 netbsd32_getsid(l, v, retval)
2119 struct lwp *l;
2120 void *v;
2121 register_t *retval;
2122 {
2123 struct netbsd32_getsid_args /* {
2124 syscallarg(pid_t) pid;
2125 } */ *uap = v;
2126 struct sys_getsid_args ua;
2127
2128 NETBSD32TO64_UAP(pid);
2129 return (sys_getsid(l, &ua, retval));
2130 }
2131
2132 #ifdef KTRACE
2133 int
2134 netbsd32_fktrace(l, v, retval)
2135 struct lwp *l;
2136 void *v;
2137 register_t *retval;
2138 {
2139 struct netbsd32_fktrace_args /* {
2140 syscallarg(const int) fd;
2141 syscallarg(int) ops;
2142 syscallarg(int) facs;
2143 syscallarg(int) pid;
2144 } */ *uap = v;
2145 #if 0
2146 struct sys_fktrace_args ua;
2147 #else
2148 /* XXXX */
2149 struct sys_fktrace_noconst_args {
2150 syscallarg(int) fd;
2151 syscallarg(int) ops;
2152 syscallarg(int) facs;
2153 syscallarg(int) pid;
2154 } ua;
2155 #endif
2156
2157 NETBSD32TOX_UAP(fd, int);
2158 NETBSD32TO64_UAP(ops);
2159 NETBSD32TO64_UAP(facs);
2160 NETBSD32TO64_UAP(pid);
2161 return (sys_fktrace(l, &ua, retval));
2162 }
2163 #endif /* KTRACE */
2164
2165 int netbsd32___sigpending14(l, v, retval)
2166 struct lwp *l;
2167 void *v;
2168 register_t *retval;
2169 {
2170 struct netbsd32___sigpending14_args /* {
2171 syscallarg(sigset_t *) set;
2172 } */ *uap = v;
2173 struct sys___sigpending14_args ua;
2174
2175 NETBSD32TOP_UAP(set, sigset_t);
2176 return (sys___sigpending14(l, &ua, retval));
2177 }
2178
2179 int netbsd32___sigprocmask14(l, v, retval)
2180 struct lwp *l;
2181 void *v;
2182 register_t *retval;
2183 {
2184 struct netbsd32___sigprocmask14_args /* {
2185 syscallarg(int) how;
2186 syscallarg(const sigset_t *) set;
2187 syscallarg(sigset_t *) oset;
2188 } */ *uap = v;
2189 struct sys___sigprocmask14_args ua;
2190
2191 NETBSD32TO64_UAP(how);
2192 NETBSD32TOP_UAP(set, sigset_t);
2193 NETBSD32TOP_UAP(oset, sigset_t);
2194 return (sys___sigprocmask14(l, &ua, retval));
2195 }
2196
2197 int netbsd32___sigsuspend14(l, v, retval)
2198 struct lwp *l;
2199 void *v;
2200 register_t *retval;
2201 {
2202 struct netbsd32___sigsuspend14_args /* {
2203 syscallarg(const sigset_t *) set;
2204 } */ *uap = v;
2205 struct sys___sigsuspend14_args ua;
2206
2207 NETBSD32TOP_UAP(set, sigset_t);
2208 return (sys___sigsuspend14(l, &ua, retval));
2209 };
2210
2211 int netbsd32_fchroot(l, v, retval)
2212 struct lwp *l;
2213 void *v;
2214 register_t *retval;
2215 {
2216 struct netbsd32_fchroot_args /* {
2217 syscallarg(int) fd;
2218 } */ *uap = v;
2219 struct sys_fchroot_args ua;
2220
2221 NETBSD32TO64_UAP(fd);
2222 return (sys_fchroot(l, &ua, retval));
2223 }
2224
2225 /*
2226 * Open a file given a file handle.
2227 *
2228 * Check permissions, allocate an open file structure,
2229 * and call the device open routine if any.
2230 */
2231 int
2232 netbsd32_fhopen(l, v, retval)
2233 struct lwp *l;
2234 void *v;
2235 register_t *retval;
2236 {
2237 struct netbsd32_fhopen_args /* {
2238 syscallarg(const fhandle_t *) fhp;
2239 syscallarg(int) flags;
2240 } */ *uap = v;
2241 struct sys_fhopen_args ua;
2242
2243 NETBSD32TOP_UAP(fhp, fhandle_t);
2244 NETBSD32TO64_UAP(flags);
2245 return (sys_fhopen(l, &ua, retval));
2246 }
2247
2248 int netbsd32_fhstat(l, v, retval)
2249 struct lwp *l;
2250 void *v;
2251 register_t *retval;
2252 {
2253 struct netbsd32_fhstat_args /* {
2254 syscallarg(const netbsd32_fhandlep_t) fhp;
2255 syscallarg(struct stat *) sb;
2256 } */ *uap = v;
2257 struct sys_fhstat_args ua;
2258
2259 NETBSD32TOP_UAP(fhp, const fhandle_t);
2260 NETBSD32TOP_UAP(sb, struct stat);
2261 return (sys_fhstat(l, &ua, retval));
2262 }
2263
2264 /* virtual memory syscalls */
2265 int
2266 netbsd32_ovadvise(l, v, retval)
2267 struct lwp *l;
2268 void *v;
2269 register_t *retval;
2270 {
2271 struct netbsd32_ovadvise_args /* {
2272 syscallarg(int) anom;
2273 } */ *uap = v;
2274 struct sys_ovadvise_args ua;
2275
2276 NETBSD32TO64_UAP(anom);
2277 return (sys_ovadvise(l, &ua, retval));
2278 }
2279
2280 void
2281 netbsd32_adjust_limits(struct proc *p)
2282 {
2283 rlim_t *valp;
2284
2285 valp = &p->p_rlimit[RLIMIT_DATA].rlim_cur;
2286 if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
2287 *valp = MAXDSIZ32;
2288 valp = &p->p_rlimit[RLIMIT_DATA].rlim_max;
2289 if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
2290 *valp = MAXDSIZ32;
2291
2292 valp = &p->p_rlimit[RLIMIT_STACK].rlim_cur;
2293 if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
2294 *valp = MAXSSIZ32;
2295 valp = &p->p_rlimit[RLIMIT_STACK].rlim_max;
2296 if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
2297 *valp = MAXSSIZ32;
2298 }
2299
2300 int
2301 netbsd32_uuidgen(struct lwp *l, void *v, register_t *retval)
2302 {
2303 struct netbsd32_uuidgen_args /* {
2304 syscallarg(netbsd32_uuidp_t) store;
2305 syscallarg(int) count;
2306 } */ *uap = v;
2307 struct sys_uuidgen_args ua;
2308
2309 NETBSD32TOP_UAP(store, struct uuid);
2310 NETBSD32TO64_UAP(count);
2311 return (sys_uuidgen(l, &ua, retval));
2312 }
2313
2314 int
2315 netbsd32_extattrctl(struct lwp *l, void *v, register_t *retval)
2316 {
2317 struct netbsd32_extattrctl_args /* {
2318 syscallarg(const netbsd32_charp) path;
2319 syscallarg(int) cmd;
2320 syscallarg(const netbsd32_charp) filename;
2321 syscallarg(int) attrnamespace;
2322 syscallarg(const netbsd32_charp) attrname;
2323 } */ *uap = v;
2324 struct sys_extattrctl_args ua;
2325
2326 NETBSD32TOP_UAP(path, const char);
2327 NETBSD32TO64_UAP(cmd);
2328 NETBSD32TOP_UAP(filename, const char);
2329 NETBSD32TO64_UAP(attrnamespace);
2330 NETBSD32TOP_UAP(attrname, const char);
2331 return sys_extattrctl(l, &ua, retval);
2332 }
2333
2334 int
2335 netbsd32_extattr_set_fd(struct lwp *l, void *v, register_t *retval)
2336 {
2337 struct netbsd32_extattr_set_fd_args /* {
2338 syscallarg(int) fd;
2339 syscallarg(int) attrnamespace;
2340 syscallarg(const netbsd32_charp) attrname;
2341 syscallarg(const netbsd32_voidp) data;
2342 syscallarg(netbsd32_size_t) nbytes;
2343 } */ *uap = v;
2344 struct sys_extattr_set_fd_args ua;
2345
2346 NETBSD32TO64_UAP(fd);
2347 NETBSD32TO64_UAP(attrnamespace);
2348 NETBSD32TOP_UAP(attrname, const char);
2349 NETBSD32TOP_UAP(data, const void);
2350 NETBSD32TOX_UAP(nbytes, size_t);
2351 return sys_extattr_set_fd(l, &ua, retval);
2352 }
2353
2354 int
2355 netbsd32_extattr_set_file(struct lwp *l, void *v, register_t *retval)
2356 {
2357 struct netbsd32_extattr_set_file_args /* {
2358 syscallarg(const netbsd32_charp) path;
2359 syscallarg(int) attrnamespace;
2360 syscallarg(const netbsd32_charp) attrname;
2361 syscallarg(const netbsd32_voidp) data;
2362 syscallarg(netbsd32_size_t) nbytes;
2363 } */ *uap = v;
2364 struct sys_extattr_set_file_args ua;
2365
2366 NETBSD32TOP_UAP(path, const char);
2367 NETBSD32TO64_UAP(attrnamespace);
2368 NETBSD32TOP_UAP(attrname, const char);
2369 NETBSD32TOP_UAP(data, const void);
2370 NETBSD32TOX_UAP(nbytes, size_t);
2371 return sys_extattr_set_file(l, &ua, retval);
2372 }
2373
2374 int
2375 netbsd32_extattr_set_link(struct lwp *l, void *v, register_t *retval)
2376 {
2377 struct netbsd32_extattr_set_link_args /* {
2378 syscallarg(const netbsd32_charp) path;
2379 syscallarg(int) attrnamespace;
2380 syscallarg(const netbsd32_charp) attrname;
2381 syscallarg(const netbsd32_voidp) data;
2382 syscallarg(netbsd32_size_t) nbytes;
2383 } */ *uap = v;
2384 struct sys_extattr_set_link_args ua;
2385
2386 NETBSD32TOP_UAP(path, const char);
2387 NETBSD32TO64_UAP(attrnamespace);
2388 NETBSD32TOP_UAP(attrname, const char);
2389 NETBSD32TOP_UAP(data, const void);
2390 NETBSD32TOX_UAP(nbytes, size_t);
2391 return sys_extattr_set_link(l, &ua, retval);
2392 }
2393
2394 int
2395 netbsd32_extattr_get_fd(struct lwp *l, void *v, register_t *retval)
2396 {
2397 struct netbsd32_extattr_get_fd_args /* {
2398 syscallarg(int) fd;
2399 syscallarg(int) attrnamespace;
2400 syscallarg(const netbsd32_charp) attrname;
2401 syscallarg(netbsd32_voidp) data;
2402 syscallarg(netbsd32_size_t) nbytes;
2403 } */ *uap = v;
2404 struct sys_extattr_get_fd_args ua;
2405
2406 NETBSD32TO64_UAP(fd);
2407 NETBSD32TO64_UAP(attrnamespace);
2408 NETBSD32TOP_UAP(attrname, const char);
2409 NETBSD32TOP_UAP(data, void);
2410 NETBSD32TOX_UAP(nbytes, size_t);
2411 return sys_extattr_get_fd(l, &ua, retval);
2412 }
2413
2414 int
2415 netbsd32_extattr_get_file(struct lwp *l, void *v, register_t *retval)
2416 {
2417 struct netbsd32_extattr_get_file_args /* {
2418 syscallarg(const netbsd32_charp) path;
2419 syscallarg(int) attrnamespace;
2420 syscallarg(const netbsd32_charp) attrname;
2421 syscallarg(netbsd32_voidp) data;
2422 syscallarg(netbsd32_size_t) nbytes;
2423 } */ *uap = v;
2424 struct sys_extattr_get_file_args ua;
2425
2426 NETBSD32TOP_UAP(path, const char);
2427 NETBSD32TO64_UAP(attrnamespace);
2428 NETBSD32TOP_UAP(attrname, const char);
2429 NETBSD32TOP_UAP(data, void);
2430 NETBSD32TOX_UAP(nbytes, size_t);
2431 return sys_extattr_get_file(l, &ua, retval);
2432 }
2433
2434 int
2435 netbsd32_extattr_get_link(struct lwp *l, void *v, register_t *retval)
2436 {
2437 struct netbsd32_extattr_get_link_args /* {
2438 syscallarg(const netbsd32_charp) path;
2439 syscallarg(int) attrnamespace;
2440 syscallarg(const netbsd32_charp) attrname;
2441 syscallarg(netbsd32_voidp) data;
2442 syscallarg(netbsd32_size_t) nbytes;
2443 } */ *uap = v;
2444 struct sys_extattr_get_link_args ua;
2445
2446 NETBSD32TOP_UAP(path, const char);
2447 NETBSD32TO64_UAP(attrnamespace);
2448 NETBSD32TOP_UAP(attrname, const char);
2449 NETBSD32TOP_UAP(data, void);
2450 NETBSD32TOX_UAP(nbytes, size_t);
2451 return sys_extattr_get_link(l, &ua, retval);
2452 }
2453
2454 int
2455 netbsd32_extattr_delete_fd(struct lwp *l, void *v, register_t *retval)
2456 {
2457 struct netbsd32_extattr_delete_fd_args /* {
2458 syscallarg(int) fd;
2459 syscallarg(int) attrnamespace;
2460 syscallarg(const netbsd32_charp) attrname;
2461 } */ *uap = v;
2462 struct sys_extattr_delete_fd_args ua;
2463
2464 NETBSD32TO64_UAP(fd);
2465 NETBSD32TO64_UAP(attrnamespace);
2466 NETBSD32TOP_UAP(attrname, const char);
2467 return sys_extattr_delete_fd(l, &ua, retval);
2468 }
2469
2470 int
2471 netbsd32_extattr_delete_file(struct lwp *l, void *v, register_t *retval)
2472 {
2473 struct netbsd32_extattr_delete_file_args /* {
2474 syscallarg(const netbsd32_charp) path;
2475 syscallarg(int) attrnamespace;
2476 syscallarg(const netbsd32_charp) attrname;
2477 } */ *uap = v;
2478 struct sys_extattr_delete_file_args ua;
2479
2480 NETBSD32TOP_UAP(path, const char);
2481 NETBSD32TO64_UAP(attrnamespace);
2482 NETBSD32TOP_UAP(attrname, const char);
2483 return sys_extattr_delete_file(l, &ua, retval);
2484 }
2485
2486 int
2487 netbsd32_extattr_delete_link(struct lwp *l, void *v, register_t *retval)
2488 {
2489 struct netbsd32_extattr_delete_link_args /* {
2490 syscallarg(const netbsd32_charp) path;
2491 syscallarg(int) attrnamespace;
2492 syscallarg(const netbsd32_charp) attrname;
2493 } */ *uap = v;
2494 struct sys_extattr_delete_link_args ua;
2495
2496 NETBSD32TOP_UAP(path, const char);
2497 NETBSD32TO64_UAP(attrnamespace);
2498 NETBSD32TOP_UAP(attrname, const char);
2499 return sys_extattr_delete_link(l, &ua, retval);
2500 }
2501
2502 int
2503 netbsd32_extattr_list_fd(struct lwp *l, void *v, register_t *retval)
2504 {
2505 struct netbsd32_extattr_list_fd_args /* {
2506 syscallarg(int) fd;
2507 syscallarg(int) attrnamespace;
2508 syscallarg(netbsd32_voidp) data;
2509 syscallarg(netbsd32_size_t) nbytes;
2510 } */ *uap = v;
2511 struct sys_extattr_list_fd_args ua;
2512
2513 NETBSD32TO64_UAP(fd);
2514 NETBSD32TO64_UAP(attrnamespace);
2515 NETBSD32TOP_UAP(data, void);
2516 NETBSD32TOX_UAP(nbytes, size_t);
2517 return sys_extattr_list_fd(l, &ua, retval);
2518 }
2519
2520 int
2521 netbsd32_extattr_list_file(struct lwp *l, void *v, register_t *retval)
2522 {
2523 struct netbsd32_extattr_list_file_args /* {
2524 syscallarg(const netbsd32_charp) path;
2525 syscallarg(int) attrnamespace;
2526 syscallarg(netbsd32_voidp) data;
2527 syscallarg(netbsd32_size_t) nbytes;
2528 } */ *uap = v;
2529 struct sys_extattr_list_file_args ua;
2530
2531 NETBSD32TOP_UAP(path, const char);
2532 NETBSD32TO64_UAP(attrnamespace);
2533 NETBSD32TOP_UAP(data, void);
2534 NETBSD32TOX_UAP(nbytes, size_t);
2535 return sys_extattr_list_file(l, &ua, retval);
2536 }
2537
2538 int
2539 netbsd32_extattr_list_link(struct lwp *l, void *v, register_t *retval)
2540 {
2541 struct netbsd32_extattr_list_link_args /* {
2542 syscallarg(const netbsd32_charp) path;
2543 syscallarg(int) attrnamespace;
2544 syscallarg(netbsd32_voidp) data;
2545 syscallarg(netbsd32_size_t) nbytes;
2546 } */ *uap = v;
2547 struct sys_extattr_list_link_args ua;
2548
2549 NETBSD32TOP_UAP(path, const char);
2550 NETBSD32TO64_UAP(attrnamespace);
2551 NETBSD32TOP_UAP(data, void);
2552 NETBSD32TOX_UAP(nbytes, size_t);
2553 return sys_extattr_list_link(l, &ua, retval);
2554 }
2555
2556 int
2557 netbsd32_mlockall(l, v, retval)
2558 struct lwp *l;
2559 void *v;
2560 register_t *retval;
2561 {
2562 struct netbsd32_mlockall_args /* {
2563 syscallarg(int) flags;
2564 } */ *uap = v;
2565 struct sys_mlockall_args ua;
2566
2567 NETBSD32TO64_UAP(flags);
2568 return (sys_mlockall(l, &ua, retval));
2569 }
2570
2571 int
2572 netbsd32___clone(struct lwp *l, void *v, register_t *retval)
2573 {
2574 struct netbsd32___clone_args /* {
2575 syscallarg(int) flags;
2576 syscallarg(netbsd32_voidp) stack;
2577 } */ *uap = v;
2578 struct sys___clone_args ua;
2579
2580 NETBSD32TO64_UAP(flags);
2581 NETBSD32TOP_UAP(stack, void);
2582 return sys___clone(l, &ua, retval);
2583 }
2584
2585 int
2586 netbsd32_fsync_range(struct lwp *l, void *v, register_t *retval)
2587 {
2588 struct netbsd32_fsync_range_args /* {
2589 syscallarg(int) fd;
2590 syscallarg(int) flags;
2591 syscallarg(off_t) start;
2592 syscallarg(off_t) length;
2593 } */ *uap = v;
2594 struct sys_fsync_range_args ua;
2595
2596 NETBSD32TO64_UAP(fd);
2597 NETBSD32TO64_UAP(flags);
2598 NETBSD32TO64_UAP(start);
2599 NETBSD32TO64_UAP(length);
2600 return (sys_fsync_range(l, &ua, retval));
2601 }
2602
2603 int
2604 netbsd32_rasctl(struct lwp *l, void *v, register_t *retval)
2605 {
2606 struct netbsd32_rasctl_args /* {
2607 syscallarg(netbsd32_caddr_t) addr;
2608 syscallarg(netbsd32_size_t) len;
2609 syscallarg(int) op;
2610 } */ *uap = v;
2611 struct sys_rasctl_args ua;
2612
2613 NETBSD32TOX64_UAP(addr, caddr_t);
2614 NETBSD32TOX_UAP(len, size_t);
2615 NETBSD32TO64_UAP(op);
2616 return sys_rasctl(l, &ua, retval);
2617 }
2618
2619 int
2620 netbsd32_setxattr(struct lwp *l, void *v, register_t *retval)
2621 {
2622 struct netbsd32_setxattr_args /* {
2623 syscallarg(const netbsd32_charp) path;
2624 syscallarg(const netbsd32_charp) name;
2625 syscallarg(netbsd32_voidp) value;
2626 syscallarg(netbsd32_size_t) size;
2627 syscallarg(int) flags;
2628 } */ *uap = v;
2629 struct sys_setxattr_args ua;
2630 NETBSD32TOP_UAP(path, const char);
2631 NETBSD32TOP_UAP(name, const char);
2632 NETBSD32TOP_UAP(value, void);
2633 NETBSD32TOX_UAP(size, size_t);
2634 NETBSD32TO64_UAP(flags);
2635 return sys_setxattr(l, &ua, retval);
2636 }
2637
2638 int
2639 netbsd32_lsetxattr(struct lwp *l, void *v, register_t *retval)
2640 {
2641 struct netbsd32_lsetxattr_args /* {
2642 syscallarg(const netbsd32_charp) path;
2643 syscallarg(const netbsd32_charp) name;
2644 syscallarg(netbsd32_voidp) value;
2645 syscallarg(netbsd32_size_t) size;
2646 syscallarg(int) flags;
2647 } */ *uap = v;
2648 struct sys_lsetxattr_args ua;
2649 NETBSD32TOP_UAP(path, const char);
2650 NETBSD32TOP_UAP(name, const char);
2651 NETBSD32TOP_UAP(value, void);
2652 NETBSD32TOX_UAP(size, size_t);
2653 NETBSD32TO64_UAP(flags);
2654 return sys_lsetxattr(l, &ua, retval);
2655 }
2656
2657 int
2658 netbsd32_fsetxattr(struct lwp *l, void *v, register_t *retval)
2659 {
2660 struct netbsd32_fsetxattr_args /* {
2661 syscallarg(int) fd;
2662 syscallarg(const netbsd32_charp) name;
2663 syscallarg(netbsd32_voidp) value;
2664 syscallarg(netbsd32_size_t) size;
2665 syscallarg(int) flags;
2666 } */ *uap = v;
2667 struct sys_fsetxattr_args ua;
2668 NETBSD32TO64_UAP(fd);
2669 NETBSD32TOP_UAP(name, const char);
2670 NETBSD32TOP_UAP(value, void);
2671 NETBSD32TOX_UAP(size, size_t);
2672 NETBSD32TO64_UAP(flags);
2673 return sys_fsetxattr(l, &ua, retval);
2674 }
2675
2676 int
2677 netbsd32_getxattr(struct lwp *l, void *v, register_t *retval)
2678 {
2679 struct netbsd32_getxattr_args /* {
2680 syscallarg(const netbsd32_charp) path;
2681 syscallarg(const netbsd32_charp) name;
2682 syscallarg(netbsd32_voidp) value;
2683 syscallarg(netbsd32_size_t) size;
2684 } */ *uap = v;
2685 struct sys_getxattr_args ua;
2686 NETBSD32TOP_UAP(path, const char);
2687 NETBSD32TOP_UAP(name, const char);
2688 NETBSD32TOP_UAP(value, void);
2689 NETBSD32TOX_UAP(size, size_t);
2690 return sys_getxattr(l, &ua, retval);
2691 }
2692
2693 int
2694 netbsd32_lgetxattr(struct lwp *l, void *v, register_t *retval)
2695 {
2696 struct netbsd32_lgetxattr_args /* {
2697 syscallarg(const netbsd32_charp) path;
2698 syscallarg(const netbsd32_charp) name;
2699 syscallarg(netbsd32_voidp) value;
2700 syscallarg(netbsd32_size_t) size;
2701 } */ *uap = v;
2702 struct sys_lgetxattr_args ua;
2703 NETBSD32TOP_UAP(path, const char);
2704 NETBSD32TOP_UAP(name, const char);
2705 NETBSD32TOP_UAP(value, void);
2706 NETBSD32TOX_UAP(size, size_t);
2707 return sys_lgetxattr(l, &ua, retval);
2708 }
2709
2710 int
2711 netbsd32_fgetxattr(struct lwp *l, void *v, register_t *retval)
2712 {
2713 struct netbsd32_fgetxattr_args /* {
2714 syscallarg(int) fd;
2715 syscallarg(const netbsd32_charp) name;
2716 syscallarg(netbsd32_voidp) value;
2717 syscallarg(netbsd32_size_t) size;
2718 } */ *uap = v;
2719 struct sys_fgetxattr_args ua;
2720 NETBSD32TO64_UAP(fd);
2721 NETBSD32TOP_UAP(name, const char);
2722 NETBSD32TOP_UAP(value, void);
2723 NETBSD32TOX_UAP(size, size_t);
2724 return sys_fgetxattr(l, &ua, retval);
2725 }
2726
2727 int
2728 netbsd32_listxattr(struct lwp *l, void *v, register_t *retval)
2729 {
2730 struct netbsd32_listxattr_args /* {
2731 syscallarg(const netbsd32_charp) path;
2732 syscallarg(netbsd32_charp) list;
2733 syscallarg(netbsd32_size_t) size;
2734 } */ *uap = v;
2735 struct sys_listxattr_args ua;
2736 NETBSD32TOP_UAP(path, const char);
2737 NETBSD32TOP_UAP(list, char);
2738 NETBSD32TOX_UAP(size, size_t);
2739 return sys_listxattr(l, &ua, retval);
2740 }
2741
2742 int
2743 netbsd32_llistxattr(struct lwp *l, void *v, register_t *retval)
2744 {
2745 struct netbsd32_llistxattr_args /* {
2746 syscallarg(const netbsd32_charp) path;
2747 syscallarg(netbsd32_charp) list;
2748 syscallarg(netbsd32_size_t) size;
2749 } */ *uap = v;
2750 struct sys_llistxattr_args ua;
2751 NETBSD32TOP_UAP(path, const char);
2752 NETBSD32TOP_UAP(list, char);
2753 NETBSD32TOX_UAP(size, size_t);
2754 return sys_llistxattr(l, &ua, retval);
2755 }
2756
2757 int
2758 netbsd32_flistxattr(struct lwp *l, void *v, register_t *retval)
2759 {
2760 struct netbsd32_flistxattr_args /* {
2761 syscallarg(int) fd;
2762 syscallarg(netbsd32_charp) list;
2763 syscallarg(netbsd32_size_t) size;
2764 } */ *uap = v;
2765 struct sys_flistxattr_args ua;
2766 NETBSD32TO64_UAP(fd);
2767 NETBSD32TOP_UAP(list, char);
2768 NETBSD32TOX_UAP(size, size_t);
2769 return sys_flistxattr(l, &ua, retval);
2770 }
2771
2772 int
2773 netbsd32_removexattr(struct lwp *l, void *v, register_t *retval)
2774 {
2775 struct netbsd32_removexattr_args /* {
2776 syscallarg(const netbsd32_charp) path;
2777 syscallarg(const netbsd32_charp) name;
2778 } */ *uap = v;
2779 struct sys_removexattr_args ua;
2780 NETBSD32TOP_UAP(path, const char);
2781 NETBSD32TOP_UAP(name, const char);
2782 return sys_removexattr(l, &ua, retval);
2783 }
2784
2785 int
2786 netbsd32_lremovexattr(struct lwp *l, void *v, register_t *retval)
2787 {
2788 struct netbsd32_lremovexattr_args /* {
2789 syscallarg(const netbsd32_charp) path;
2790 syscallarg(const netbsd32_charp) name;
2791 } */ *uap = v;
2792 struct sys_lremovexattr_args ua;
2793 NETBSD32TOP_UAP(path, const char);
2794 NETBSD32TOP_UAP(name, const char);
2795 return sys_lremovexattr(l, &ua, retval);
2796 }
2797
2798 int
2799 netbsd32_fremovexattr(struct lwp *l, void *v, register_t *retval)
2800 {
2801 struct netbsd32_fremovexattr_args /* {
2802 syscallarg(int) fd;
2803 syscallarg(const netbsd32_charp) name;
2804 } */ *uap = v;
2805 struct sys_fremovexattr_args ua;
2806 NETBSD32TO64_UAP(fd);
2807 NETBSD32TOP_UAP(name, const char);
2808 return sys_fremovexattr(l, &ua, retval);
2809 }
2810