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