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