netbsd32_netbsd.c revision 1.99.2.1 1 /* $NetBSD: netbsd32_netbsd.c,v 1.99.2.1 2006/02/18 15:39:02 yamt Exp $ */
2
3 /*
4 * Copyright (c) 1998, 2001 Matthew R. Green
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 */
30
31 #include <sys/cdefs.h>
32 __KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.99.2.1 2006/02/18 15:39:02 yamt 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 struct pcred *pc = l->l_proc->p_cred;
956 int ngrp;
957 int error;
958
959 ngrp = SCARG(uap, gidsetsize);
960 if (ngrp == 0) {
961 *retval = pc->pc_ucred->cr_ngroups;
962 return (0);
963 }
964 if (ngrp < pc->pc_ucred->cr_ngroups)
965 return (EINVAL);
966 ngrp = pc->pc_ucred->cr_ngroups;
967 /* Should convert gid_t to netbsd32_gid_t, but they're the same */
968 error = copyout((caddr_t)pc->pc_ucred->cr_groups,
969 (caddr_t)NETBSD32PTR64(SCARG(uap, gidset)), ngrp * sizeof(gid_t));
970 if (error)
971 return (error);
972 *retval = ngrp;
973 return (0);
974 }
975
976 int
977 netbsd32_setgroups(l, v, retval)
978 struct lwp *l;
979 void *v;
980 register_t *retval;
981 {
982 struct netbsd32_setgroups_args /* {
983 syscallarg(int) gidsetsize;
984 syscallarg(const netbsd32_gid_tp) gidset;
985 } */ *uap = v;
986 struct sys_setgroups_args ua;
987
988 NETBSD32TO64_UAP(gidsetsize);
989 NETBSD32TOP_UAP(gidset, gid_t);
990 return (sys_setgroups(l, &ua, retval));
991 }
992
993 int
994 netbsd32_setpgid(l, v, retval)
995 struct lwp *l;
996 void *v;
997 register_t *retval;
998 {
999 struct netbsd32_setpgid_args /* {
1000 syscallarg(int) pid;
1001 syscallarg(int) pgid;
1002 } */ *uap = v;
1003 struct sys_setpgid_args ua;
1004
1005 NETBSD32TO64_UAP(pid);
1006 NETBSD32TO64_UAP(pgid);
1007 return (sys_setpgid(l, &ua, retval));
1008 }
1009
1010 int
1011 netbsd32_fcntl(l, v, retval)
1012 struct lwp *l;
1013 void *v;
1014 register_t *retval;
1015 {
1016 struct netbsd32_fcntl_args /* {
1017 syscallarg(int) fd;
1018 syscallarg(int) cmd;
1019 syscallarg(netbsd32_voidp) arg;
1020 } */ *uap = v;
1021 struct sys_fcntl_args ua;
1022
1023 NETBSD32TO64_UAP(fd);
1024 NETBSD32TO64_UAP(cmd);
1025 NETBSD32TOP_UAP(arg, void);
1026 /* we can do this because `struct flock' doesn't change */
1027 return (sys_fcntl(l, &ua, retval));
1028 }
1029
1030 int
1031 netbsd32_dup2(l, v, retval)
1032 struct lwp *l;
1033 void *v;
1034 register_t *retval;
1035 {
1036 struct netbsd32_dup2_args /* {
1037 syscallarg(int) from;
1038 syscallarg(int) to;
1039 } */ *uap = v;
1040 struct sys_dup2_args ua;
1041
1042 NETBSD32TO64_UAP(from);
1043 NETBSD32TO64_UAP(to);
1044 return (sys_dup2(l, &ua, retval));
1045 }
1046
1047 int
1048 netbsd32_fsync(l, v, retval)
1049 struct lwp *l;
1050 void *v;
1051 register_t *retval;
1052 {
1053 struct netbsd32_fsync_args /* {
1054 syscallarg(int) fd;
1055 } */ *uap = v;
1056 struct sys_fsync_args ua;
1057
1058 NETBSD32TO64_UAP(fd);
1059 return (sys_fsync(l, &ua, retval));
1060 }
1061
1062 int
1063 netbsd32_setpriority(l, v, retval)
1064 struct lwp *l;
1065 void *v;
1066 register_t *retval;
1067 {
1068 struct netbsd32_setpriority_args /* {
1069 syscallarg(int) which;
1070 syscallarg(int) who;
1071 syscallarg(int) prio;
1072 } */ *uap = v;
1073 struct sys_setpriority_args ua;
1074
1075 NETBSD32TO64_UAP(which);
1076 NETBSD32TO64_UAP(who);
1077 NETBSD32TO64_UAP(prio);
1078 return (sys_setpriority(l, &ua, retval));
1079 }
1080
1081 int
1082 netbsd32_socket(l, v, retval)
1083 struct lwp *l;
1084 void *v;
1085 register_t *retval;
1086 {
1087 struct netbsd32_socket_args /* {
1088 syscallarg(int) domain;
1089 syscallarg(int) type;
1090 syscallarg(int) protocol;
1091 } */ *uap = v;
1092 struct sys_socket_args ua;
1093
1094 NETBSD32TO64_UAP(domain);
1095 NETBSD32TO64_UAP(type);
1096 NETBSD32TO64_UAP(protocol);
1097 return (sys_socket(l, &ua, retval));
1098 }
1099
1100 int
1101 netbsd32_connect(l, v, retval)
1102 struct lwp *l;
1103 void *v;
1104 register_t *retval;
1105 {
1106 struct netbsd32_connect_args /* {
1107 syscallarg(int) s;
1108 syscallarg(const netbsd32_sockaddrp_t) name;
1109 syscallarg(int) namelen;
1110 } */ *uap = v;
1111 struct sys_connect_args ua;
1112
1113 NETBSD32TO64_UAP(s);
1114 NETBSD32TOP_UAP(name, struct sockaddr);
1115 NETBSD32TO64_UAP(namelen);
1116 return (sys_connect(l, &ua, retval));
1117 }
1118
1119 int
1120 netbsd32_getpriority(l, v, retval)
1121 struct lwp *l;
1122 void *v;
1123 register_t *retval;
1124 {
1125 struct netbsd32_getpriority_args /* {
1126 syscallarg(int) which;
1127 syscallarg(int) who;
1128 } */ *uap = v;
1129 struct sys_getpriority_args ua;
1130
1131 NETBSD32TO64_UAP(which);
1132 NETBSD32TO64_UAP(who);
1133 return (sys_getpriority(l, &ua, retval));
1134 }
1135
1136 int
1137 netbsd32_bind(l, v, retval)
1138 struct lwp *l;
1139 void *v;
1140 register_t *retval;
1141 {
1142 struct netbsd32_bind_args /* {
1143 syscallarg(int) s;
1144 syscallarg(const netbsd32_sockaddrp_t) name;
1145 syscallarg(int) namelen;
1146 } */ *uap = v;
1147 struct sys_bind_args ua;
1148
1149 NETBSD32TO64_UAP(s);
1150 NETBSD32TOP_UAP(name, struct sockaddr);
1151 NETBSD32TO64_UAP(namelen);
1152 return (sys_bind(l, &ua, retval));
1153 }
1154
1155 int
1156 netbsd32_setsockopt(l, v, retval)
1157 struct lwp *l;
1158 void *v;
1159 register_t *retval;
1160 {
1161 struct netbsd32_setsockopt_args /* {
1162 syscallarg(int) s;
1163 syscallarg(int) level;
1164 syscallarg(int) name;
1165 syscallarg(const netbsd32_voidp) val;
1166 syscallarg(int) valsize;
1167 } */ *uap = v;
1168 struct sys_setsockopt_args ua;
1169
1170 NETBSD32TO64_UAP(s);
1171 NETBSD32TO64_UAP(level);
1172 NETBSD32TO64_UAP(name);
1173 NETBSD32TOP_UAP(val, void);
1174 NETBSD32TO64_UAP(valsize);
1175 /* may be more efficient to do this inline. */
1176 return (sys_setsockopt(l, &ua, retval));
1177 }
1178
1179 int
1180 netbsd32_listen(l, v, retval)
1181 struct lwp *l;
1182 void *v;
1183 register_t *retval;
1184 {
1185 struct netbsd32_listen_args /* {
1186 syscallarg(int) s;
1187 syscallarg(int) backlog;
1188 } */ *uap = v;
1189 struct sys_listen_args ua;
1190
1191 NETBSD32TO64_UAP(s);
1192 NETBSD32TO64_UAP(backlog);
1193 return (sys_listen(l, &ua, retval));
1194 }
1195
1196 int
1197 netbsd32_fchown(l, v, retval)
1198 struct lwp *l;
1199 void *v;
1200 register_t *retval;
1201 {
1202 struct netbsd32_fchown_args /* {
1203 syscallarg(int) fd;
1204 syscallarg(uid_t) uid;
1205 syscallarg(gid_t) gid;
1206 } */ *uap = v;
1207 struct sys_fchown_args ua;
1208
1209 NETBSD32TO64_UAP(fd);
1210 NETBSD32TO64_UAP(uid);
1211 NETBSD32TO64_UAP(gid);
1212 return (sys_fchown(l, &ua, retval));
1213 }
1214
1215 int
1216 netbsd32_fchmod(l, v, retval)
1217 struct lwp *l;
1218 void *v;
1219 register_t *retval;
1220 {
1221 struct netbsd32_fchmod_args /* {
1222 syscallarg(int) fd;
1223 syscallarg(mode_t) mode;
1224 } */ *uap = v;
1225 struct sys_fchmod_args ua;
1226
1227 NETBSD32TO64_UAP(fd);
1228 NETBSD32TO64_UAP(mode);
1229 return (sys_fchmod(l, &ua, retval));
1230 }
1231
1232 int
1233 netbsd32_setreuid(l, v, retval)
1234 struct lwp *l;
1235 void *v;
1236 register_t *retval;
1237 {
1238 struct netbsd32_setreuid_args /* {
1239 syscallarg(uid_t) ruid;
1240 syscallarg(uid_t) euid;
1241 } */ *uap = v;
1242 struct sys_setreuid_args ua;
1243
1244 NETBSD32TO64_UAP(ruid);
1245 NETBSD32TO64_UAP(euid);
1246 return (sys_setreuid(l, &ua, retval));
1247 }
1248
1249 int
1250 netbsd32_setregid(l, v, retval)
1251 struct lwp *l;
1252 void *v;
1253 register_t *retval;
1254 {
1255 struct netbsd32_setregid_args /* {
1256 syscallarg(gid_t) rgid;
1257 syscallarg(gid_t) egid;
1258 } */ *uap = v;
1259 struct sys_setregid_args ua;
1260
1261 NETBSD32TO64_UAP(rgid);
1262 NETBSD32TO64_UAP(egid);
1263 return (sys_setregid(l, &ua, retval));
1264 }
1265
1266 int
1267 netbsd32_getsockopt(l, v, retval)
1268 struct lwp *l;
1269 void *v;
1270 register_t *retval;
1271 {
1272 struct netbsd32_getsockopt_args /* {
1273 syscallarg(int) s;
1274 syscallarg(int) level;
1275 syscallarg(int) name;
1276 syscallarg(netbsd32_voidp) val;
1277 syscallarg(netbsd32_intp) avalsize;
1278 } */ *uap = v;
1279 struct sys_getsockopt_args ua;
1280
1281 NETBSD32TO64_UAP(s);
1282 NETBSD32TO64_UAP(level);
1283 NETBSD32TO64_UAP(name);
1284 NETBSD32TOP_UAP(val, void);
1285 NETBSD32TOP_UAP(avalsize, int);
1286 return (sys_getsockopt(l, &ua, retval));
1287 }
1288
1289 int
1290 netbsd32_rename(l, v, retval)
1291 struct lwp *l;
1292 void *v;
1293 register_t *retval;
1294 {
1295 struct netbsd32_rename_args /* {
1296 syscallarg(const netbsd32_charp) from;
1297 syscallarg(const netbsd32_charp) to;
1298 } */ *uap = v;
1299 struct sys_rename_args ua;
1300
1301 NETBSD32TOP_UAP(from, const char);
1302 NETBSD32TOP_UAP(to, const char)
1303
1304 return (sys_rename(l, &ua, retval));
1305 }
1306
1307 int
1308 netbsd32_flock(l, v, retval)
1309 struct lwp *l;
1310 void *v;
1311 register_t *retval;
1312 {
1313 struct netbsd32_flock_args /* {
1314 syscallarg(int) fd;
1315 syscallarg(int) how;
1316 } */ *uap = v;
1317 struct sys_flock_args ua;
1318
1319 NETBSD32TO64_UAP(fd);
1320 NETBSD32TO64_UAP(how)
1321
1322 return (sys_flock(l, &ua, retval));
1323 }
1324
1325 int
1326 netbsd32_mkfifo(l, v, retval)
1327 struct lwp *l;
1328 void *v;
1329 register_t *retval;
1330 {
1331 struct netbsd32_mkfifo_args /* {
1332 syscallarg(const netbsd32_charp) path;
1333 syscallarg(mode_t) mode;
1334 } */ *uap = v;
1335 struct sys_mkfifo_args ua;
1336
1337 NETBSD32TOP_UAP(path, const char)
1338 NETBSD32TO64_UAP(mode);
1339 return (sys_mkfifo(l, &ua, retval));
1340 }
1341
1342 int
1343 netbsd32_shutdown(l, v, retval)
1344 struct lwp *l;
1345 void *v;
1346 register_t *retval;
1347 {
1348 struct netbsd32_shutdown_args /* {
1349 syscallarg(int) s;
1350 syscallarg(int) how;
1351 } */ *uap = v;
1352 struct sys_shutdown_args ua;
1353
1354 NETBSD32TO64_UAP(s)
1355 NETBSD32TO64_UAP(how);
1356 return (sys_shutdown(l, &ua, retval));
1357 }
1358
1359 int
1360 netbsd32_socketpair(l, v, retval)
1361 struct lwp *l;
1362 void *v;
1363 register_t *retval;
1364 {
1365 struct netbsd32_socketpair_args /* {
1366 syscallarg(int) domain;
1367 syscallarg(int) type;
1368 syscallarg(int) protocol;
1369 syscallarg(netbsd32_intp) rsv;
1370 } */ *uap = v;
1371 struct sys_socketpair_args ua;
1372
1373 NETBSD32TO64_UAP(domain);
1374 NETBSD32TO64_UAP(type);
1375 NETBSD32TO64_UAP(protocol);
1376 NETBSD32TOP_UAP(rsv, int);
1377 /* Since we're just copying out two `int's we can do this */
1378 return (sys_socketpair(l, &ua, retval));
1379 }
1380
1381 int
1382 netbsd32_mkdir(l, v, retval)
1383 struct lwp *l;
1384 void *v;
1385 register_t *retval;
1386 {
1387 struct netbsd32_mkdir_args /* {
1388 syscallarg(const netbsd32_charp) path;
1389 syscallarg(mode_t) mode;
1390 } */ *uap = v;
1391 struct sys_mkdir_args ua;
1392
1393 NETBSD32TOP_UAP(path, const char)
1394 NETBSD32TO64_UAP(mode);
1395 return (sys_mkdir(l, &ua, retval));
1396 }
1397
1398 int
1399 netbsd32_rmdir(l, v, retval)
1400 struct lwp *l;
1401 void *v;
1402 register_t *retval;
1403 {
1404 struct netbsd32_rmdir_args /* {
1405 syscallarg(const netbsd32_charp) path;
1406 } */ *uap = v;
1407 struct sys_rmdir_args ua;
1408
1409 NETBSD32TOP_UAP(path, const char);
1410 return (sys_rmdir(l, &ua, retval));
1411 }
1412
1413 int
1414 netbsd32_quotactl(l, v, retval)
1415 struct lwp *l;
1416 void *v;
1417 register_t *retval;
1418 {
1419 struct netbsd32_quotactl_args /* {
1420 syscallarg(const netbsd32_charp) path;
1421 syscallarg(int) cmd;
1422 syscallarg(int) uid;
1423 syscallarg(netbsd32_caddr_t) arg;
1424 } */ *uap = v;
1425 struct sys_quotactl_args ua;
1426
1427 NETBSD32TOP_UAP(path, const char);
1428 NETBSD32TO64_UAP(cmd);
1429 NETBSD32TO64_UAP(uid);
1430 NETBSD32TOX64_UAP(arg, caddr_t);
1431 return (sys_quotactl(l, &ua, retval));
1432 }
1433
1434 #if defined(NFS) || defined(NFSSERVER)
1435 int
1436 netbsd32_nfssvc(l, v, retval)
1437 struct lwp *l;
1438 void *v;
1439 register_t *retval;
1440 {
1441 #if 0
1442 struct netbsd32_nfssvc_args /* {
1443 syscallarg(int) flag;
1444 syscallarg(netbsd32_voidp) argp;
1445 } */ *uap = v;
1446 struct sys_nfssvc_args ua;
1447
1448 NETBSD32TO64_UAP(flag);
1449 NETBSD32TOP_UAP(argp, void);
1450 return (sys_nfssvc(l, &ua, retval));
1451 #else
1452 /* Why would we want to support a 32-bit nfsd? */
1453 return (ENOSYS);
1454 #endif
1455 }
1456 #endif
1457
1458 #if defined(NFS) || defined(NFSSERVER)
1459 int
1460 netbsd32_getfh(l, v, retval)
1461 struct lwp *l;
1462 void *v;
1463 register_t *retval;
1464 {
1465 struct netbsd32_getfh_args /* {
1466 syscallarg(const netbsd32_charp) fname;
1467 syscallarg(netbsd32_fhandlep_t) fhp;
1468 } */ *uap = v;
1469 struct sys_getfh_args ua;
1470
1471 NETBSD32TOP_UAP(fname, const char);
1472 NETBSD32TOP_UAP(fhp, struct fhandle);
1473 /* Lucky for us a fhandlep_t doesn't change sizes */
1474 return (sys_getfh(l, &ua, retval));
1475 }
1476 #endif
1477
1478 int
1479 netbsd32_pread(l, v, retval)
1480 struct lwp *l;
1481 void *v;
1482 register_t *retval;
1483 {
1484 struct netbsd32_pread_args /* {
1485 syscallarg(int) fd;
1486 syscallarg(netbsd32_voidp) buf;
1487 syscallarg(netbsd32_size_t) nbyte;
1488 syscallarg(int) pad;
1489 syscallarg(off_t) offset;
1490 } */ *uap = v;
1491 struct sys_pread_args ua;
1492 ssize_t rt;
1493 int error;
1494
1495 NETBSD32TO64_UAP(fd);
1496 NETBSD32TOP_UAP(buf, void);
1497 NETBSD32TOX_UAP(nbyte, size_t);
1498 NETBSD32TO64_UAP(pad);
1499 NETBSD32TO64_UAP(offset);
1500 error = sys_pread(l, &ua, (register_t *)&rt);
1501 *retval = rt;
1502 return (error);
1503 }
1504
1505 int
1506 netbsd32_pwrite(l, v, retval)
1507 struct lwp *l;
1508 void *v;
1509 register_t *retval;
1510 {
1511 struct netbsd32_pwrite_args /* {
1512 syscallarg(int) fd;
1513 syscallarg(const netbsd32_voidp) buf;
1514 syscallarg(netbsd32_size_t) nbyte;
1515 syscallarg(int) pad;
1516 syscallarg(off_t) offset;
1517 } */ *uap = v;
1518 struct sys_pwrite_args ua;
1519 ssize_t rt;
1520 int error;
1521
1522 NETBSD32TO64_UAP(fd);
1523 NETBSD32TOP_UAP(buf, void);
1524 NETBSD32TOX_UAP(nbyte, size_t);
1525 NETBSD32TO64_UAP(pad);
1526 NETBSD32TO64_UAP(offset);
1527 error = sys_pwrite(l, &ua, (register_t *)&rt);
1528 *retval = rt;
1529 return (error);
1530 }
1531
1532 int
1533 netbsd32_setgid(l, v, retval)
1534 struct lwp *l;
1535 void *v;
1536 register_t *retval;
1537 {
1538 struct netbsd32_setgid_args /* {
1539 syscallarg(gid_t) gid;
1540 } */ *uap = v;
1541 struct sys_setgid_args ua;
1542
1543 NETBSD32TO64_UAP(gid);
1544 return (sys_setgid(l, v, retval));
1545 }
1546
1547 int
1548 netbsd32_setegid(l, v, retval)
1549 struct lwp *l;
1550 void *v;
1551 register_t *retval;
1552 {
1553 struct netbsd32_setegid_args /* {
1554 syscallarg(gid_t) egid;
1555 } */ *uap = v;
1556 struct sys_setegid_args ua;
1557
1558 NETBSD32TO64_UAP(egid);
1559 return (sys_setegid(l, v, retval));
1560 }
1561
1562 int
1563 netbsd32_seteuid(l, v, retval)
1564 struct lwp *l;
1565 void *v;
1566 register_t *retval;
1567 {
1568 struct netbsd32_seteuid_args /* {
1569 syscallarg(gid_t) euid;
1570 } */ *uap = v;
1571 struct sys_seteuid_args ua;
1572
1573 NETBSD32TO64_UAP(euid);
1574 return (sys_seteuid(l, v, retval));
1575 }
1576
1577 #ifdef LFS
1578 int
1579 netbsd32_sys_lfs_bmapv(l, v, retval)
1580 struct lwp *l;
1581 void *v;
1582 register_t *retval;
1583 {
1584
1585 return (ENOSYS); /* XXX */
1586 }
1587
1588 int
1589 netbsd32_sys_lfs_markv(l, v, retval)
1590 struct lwp *l;
1591 void *v;
1592 register_t *retval;
1593 {
1594
1595 return (ENOSYS); /* XXX */
1596 }
1597
1598 int
1599 netbsd32_sys_lfs_segclean(l, v, retval)
1600 struct lwp *l;
1601 void *v;
1602 register_t *retval;
1603 {
1604
1605 return (ENOSYS); /* XXX */
1606 }
1607
1608 int
1609 netbsd32_sys_lfs_segwait(l, v, retval)
1610 struct lwp *l;
1611 void *v;
1612 register_t *retval;
1613 {
1614
1615 return (ENOSYS); /* XXX */
1616 }
1617 #endif
1618
1619 int
1620 netbsd32_pathconf(l, v, retval)
1621 struct lwp *l;
1622 void *v;
1623 register_t *retval;
1624 {
1625 struct netbsd32_pathconf_args /* {
1626 syscallarg(int) fd;
1627 syscallarg(int) name;
1628 } */ *uap = v;
1629 struct sys_pathconf_args ua;
1630 long rt;
1631 int error;
1632
1633 NETBSD32TOP_UAP(path, const char);
1634 NETBSD32TO64_UAP(name);
1635 error = sys_pathconf(l, &ua, (register_t *)&rt);
1636 *retval = rt;
1637 return (error);
1638 }
1639
1640 int
1641 netbsd32_fpathconf(l, v, retval)
1642 struct lwp *l;
1643 void *v;
1644 register_t *retval;
1645 {
1646 struct netbsd32_fpathconf_args /* {
1647 syscallarg(int) fd;
1648 syscallarg(int) name;
1649 } */ *uap = v;
1650 struct sys_fpathconf_args ua;
1651 long rt;
1652 int error;
1653
1654 NETBSD32TO64_UAP(fd);
1655 NETBSD32TO64_UAP(name);
1656 error = sys_fpathconf(l, &ua, (register_t *)&rt);
1657 *retval = rt;
1658 return (error);
1659 }
1660
1661 int
1662 netbsd32_getrlimit(l, v, retval)
1663 struct lwp *l;
1664 void *v;
1665 register_t *retval;
1666 {
1667 struct netbsd32_getrlimit_args /* {
1668 syscallarg(int) which;
1669 syscallarg(netbsd32_rlimitp_t) rlp;
1670 } */ *uap = v;
1671 int which = SCARG(uap, which);
1672
1673 if ((u_int)which >= RLIM_NLIMITS)
1674 return (EINVAL);
1675 return (copyout(&l->l_proc->p_rlimit[which],
1676 (caddr_t)NETBSD32PTR64(SCARG(uap, rlp)), sizeof(struct rlimit)));
1677 }
1678
1679 int
1680 netbsd32_setrlimit(l, v, retval)
1681 struct lwp *l;
1682 void *v;
1683 register_t *retval;
1684 {
1685 struct netbsd32_setrlimit_args /* {
1686 syscallarg(int) which;
1687 syscallarg(const netbsd32_rlimitp_t) rlp;
1688 } */ *uap = v;
1689 int which = SCARG(uap, which);
1690 struct rlimit alim;
1691 int error;
1692 struct proc *p = l->l_proc;
1693
1694 error = copyin((caddr_t)NETBSD32PTR64(SCARG(uap, rlp)), &alim,
1695 sizeof(struct rlimit));
1696 if (error)
1697 return (error);
1698
1699 switch (which) {
1700 case RLIMIT_DATA:
1701 if (alim.rlim_cur > MAXDSIZ32)
1702 alim.rlim_cur = MAXDSIZ32;
1703 if (alim.rlim_max > MAXDSIZ32)
1704 alim.rlim_max = MAXDSIZ32;
1705 break;
1706
1707 case RLIMIT_STACK:
1708 if (alim.rlim_cur > MAXSSIZ32)
1709 alim.rlim_cur = MAXSSIZ32;
1710 if (alim.rlim_max > MAXSSIZ32)
1711 alim.rlim_max = MAXSSIZ32;
1712 default:
1713 break;
1714 }
1715
1716 return (dosetrlimit(p, p->p_cred, which, &alim));
1717 }
1718
1719 int
1720 netbsd32_mmap(l, v, retval)
1721 struct lwp *l;
1722 void *v;
1723 register_t *retval;
1724 {
1725 struct netbsd32_mmap_args /* {
1726 syscallarg(netbsd32_voidp) addr;
1727 syscallarg(netbsd32_size_t) len;
1728 syscallarg(int) prot;
1729 syscallarg(int) flags;
1730 syscallarg(int) fd;
1731 syscallarg(netbsd32_long) pad;
1732 syscallarg(off_t) pos;
1733 } */ *uap = v;
1734 struct sys_mmap_args ua;
1735 int error;
1736
1737 NETBSD32TOP_UAP(addr, void);
1738 NETBSD32TOX_UAP(len, size_t);
1739 NETBSD32TO64_UAP(prot);
1740 NETBSD32TO64_UAP(flags);
1741 NETBSD32TO64_UAP(fd);
1742 NETBSD32TOX_UAP(pad, long);
1743 NETBSD32TOX_UAP(pos, off_t);
1744 error = sys_mmap(l, &ua, retval);
1745 if ((u_long)*retval > (u_long)UINT_MAX) {
1746 printf("netbsd32_mmap: retval out of range: 0x%lx",
1747 (u_long)*retval);
1748 /* Should try to recover and return an error here. */
1749 }
1750 return (error);
1751 }
1752
1753 int
1754 netbsd32_lseek(l, v, retval)
1755 struct lwp *l;
1756 void *v;
1757 register_t *retval;
1758 {
1759 struct netbsd32_lseek_args /* {
1760 syscallarg(int) fd;
1761 syscallarg(int) pad;
1762 syscallarg(off_t) offset;
1763 syscallarg(int) whence;
1764 } */ *uap = v;
1765 struct sys_lseek_args ua;
1766 int rv;
1767
1768 NETBSD32TO64_UAP(fd);
1769 NETBSD32TO64_UAP(pad);
1770 NETBSD32TO64_UAP(offset);
1771 NETBSD32TO64_UAP(whence);
1772 rv = sys_lseek(l, &ua, retval);
1773 #ifdef NETBSD32_OFF_T_RETURN
1774 if (rv == 0)
1775 NETBSD32_OFF_T_RETURN(retval);
1776 #endif
1777 return rv;
1778 }
1779
1780 int
1781 netbsd32_truncate(l, v, retval)
1782 struct lwp *l;
1783 void *v;
1784 register_t *retval;
1785 {
1786 struct netbsd32_truncate_args /* {
1787 syscallarg(const netbsd32_charp) path;
1788 syscallarg(int) pad;
1789 syscallarg(off_t) length;
1790 } */ *uap = v;
1791 struct sys_truncate_args ua;
1792
1793 NETBSD32TOP_UAP(path, const char);
1794 NETBSD32TO64_UAP(pad);
1795 NETBSD32TO64_UAP(length);
1796 return (sys_truncate(l, &ua, retval));
1797 }
1798
1799 int
1800 netbsd32_ftruncate(l, v, retval)
1801 struct lwp *l;
1802 void *v;
1803 register_t *retval;
1804 {
1805 struct netbsd32_ftruncate_args /* {
1806 syscallarg(int) fd;
1807 syscallarg(int) pad;
1808 syscallarg(off_t) length;
1809 } */ *uap = v;
1810 struct sys_ftruncate_args ua;
1811
1812 NETBSD32TO64_UAP(fd);
1813 NETBSD32TO64_UAP(pad);
1814 NETBSD32TO64_UAP(length);
1815 return (sys_ftruncate(l, &ua, retval));
1816 }
1817
1818 int
1819 netbsd32_mlock(l, v, retval)
1820 struct lwp *l;
1821 void *v;
1822 register_t *retval;
1823 {
1824 struct netbsd32_mlock_args /* {
1825 syscallarg(const netbsd32_voidp) addr;
1826 syscallarg(netbsd32_size_t) len;
1827 } */ *uap = v;
1828 struct sys_mlock_args ua;
1829
1830 NETBSD32TOP_UAP(addr, const void);
1831 NETBSD32TO64_UAP(len);
1832 return (sys_mlock(l, &ua, retval));
1833 }
1834
1835 int
1836 netbsd32_munlock(l, v, retval)
1837 struct lwp *l;
1838 void *v;
1839 register_t *retval;
1840 {
1841 struct netbsd32_munlock_args /* {
1842 syscallarg(const netbsd32_voidp) addr;
1843 syscallarg(netbsd32_size_t) len;
1844 } */ *uap = v;
1845 struct sys_munlock_args ua;
1846
1847 NETBSD32TOP_UAP(addr, const void);
1848 NETBSD32TO64_UAP(len);
1849 return (sys_munlock(l, &ua, retval));
1850 }
1851
1852 int
1853 netbsd32_undelete(l, v, retval)
1854 struct lwp *l;
1855 void *v;
1856 register_t *retval;
1857 {
1858 struct netbsd32_undelete_args /* {
1859 syscallarg(const netbsd32_charp) path;
1860 } */ *uap = v;
1861 struct sys_undelete_args ua;
1862
1863 NETBSD32TOP_UAP(path, const char);
1864 return (sys_undelete(l, &ua, retval));
1865 }
1866
1867 int
1868 netbsd32_getpgid(l, v, retval)
1869 struct lwp *l;
1870 void *v;
1871 register_t *retval;
1872 {
1873 struct netbsd32_getpgid_args /* {
1874 syscallarg(pid_t) pid;
1875 } */ *uap = v;
1876 struct sys_getpgid_args ua;
1877
1878 NETBSD32TO64_UAP(pid);
1879 return (sys_getpgid(l, &ua, retval));
1880 }
1881
1882 int
1883 netbsd32_reboot(l, v, retval)
1884 struct lwp *l;
1885 void *v;
1886 register_t *retval;
1887 {
1888 struct netbsd32_reboot_args /* {
1889 syscallarg(int) opt;
1890 syscallarg(netbsd32_charp) bootstr;
1891 } */ *uap = v;
1892 struct sys_reboot_args ua;
1893
1894 NETBSD32TO64_UAP(opt);
1895 NETBSD32TOP_UAP(bootstr, char);
1896 return (sys_reboot(l, &ua, retval));
1897 }
1898
1899 #include <sys/poll.h>
1900 int
1901 netbsd32_poll(l, v, retval)
1902 struct lwp *l;
1903 void *v;
1904 register_t *retval;
1905 {
1906 struct netbsd32_poll_args /* {
1907 syscallarg(netbsd32_pollfdp_t) fds;
1908 syscallarg(u_int) nfds;
1909 syscallarg(int) timeout;
1910 } */ *uap = v;
1911 struct sys_poll_args ua;
1912
1913 NETBSD32TOP_UAP(fds, struct pollfd);
1914 NETBSD32TO64_UAP(nfds);
1915 NETBSD32TO64_UAP(timeout);
1916
1917 return (sys_poll(l, &ua, retval));
1918 }
1919
1920 int
1921 netbsd32_fdatasync(l, v, retval)
1922 struct lwp *l;
1923 void *v;
1924 register_t *retval;
1925 {
1926 struct netbsd32_fdatasync_args /* {
1927 syscallarg(int) fd;
1928 } */ *uap = v;
1929 struct sys_fdatasync_args ua;
1930
1931 NETBSD32TO64_UAP(fd);
1932 return (sys_fdatasync(l, &ua, retval));
1933 }
1934
1935 int
1936 netbsd32___posix_rename(l, v, retval)
1937 struct lwp *l;
1938 void *v;
1939 register_t *retval;
1940 {
1941 struct netbsd32___posix_rename_args /* {
1942 syscallarg(const netbsd32_charp) from;
1943 syscallarg(const netbsd32_charp) to;
1944 } */ *uap = v;
1945 struct sys___posix_rename_args ua;
1946
1947 NETBSD32TOP_UAP(from, const char);
1948 NETBSD32TOP_UAP(to, const char);
1949 return (sys___posix_rename(l, &ua, retval));
1950 }
1951
1952 int
1953 netbsd32_swapctl(l, v, retval)
1954 struct lwp *l;
1955 void *v;
1956 register_t *retval;
1957 {
1958 struct netbsd32_swapctl_args /* {
1959 syscallarg(int) cmd;
1960 syscallarg(const netbsd32_voidp) arg;
1961 syscallarg(int) misc;
1962 } */ *uap = v;
1963 struct sys_swapctl_args ua;
1964
1965 NETBSD32TO64_UAP(cmd);
1966 NETBSD32TOP_UAP(arg, void);
1967 NETBSD32TO64_UAP(misc);
1968 return (sys_swapctl(l, &ua, retval));
1969 }
1970
1971 int
1972 netbsd32_minherit(l, v, retval)
1973 struct lwp *l;
1974 void *v;
1975 register_t *retval;
1976 {
1977 struct netbsd32_minherit_args /* {
1978 syscallarg(netbsd32_voidp) addr;
1979 syscallarg(netbsd32_size_t) len;
1980 syscallarg(int) inherit;
1981 } */ *uap = v;
1982 struct sys_minherit_args ua;
1983
1984 NETBSD32TOP_UAP(addr, void);
1985 NETBSD32TOX_UAP(len, size_t);
1986 NETBSD32TO64_UAP(inherit);
1987 return (sys_minherit(l, &ua, retval));
1988 }
1989
1990 int
1991 netbsd32_lchmod(l, v, retval)
1992 struct lwp *l;
1993 void *v;
1994 register_t *retval;
1995 {
1996 struct netbsd32_lchmod_args /* {
1997 syscallarg(const netbsd32_charp) path;
1998 syscallarg(mode_t) mode;
1999 } */ *uap = v;
2000 struct sys_lchmod_args ua;
2001
2002 NETBSD32TOP_UAP(path, const char);
2003 NETBSD32TO64_UAP(mode);
2004 return (sys_lchmod(l, &ua, retval));
2005 }
2006
2007 int
2008 netbsd32_lchown(l, v, retval)
2009 struct lwp *l;
2010 void *v;
2011 register_t *retval;
2012 {
2013 struct netbsd32_lchown_args /* {
2014 syscallarg(const netbsd32_charp) path;
2015 syscallarg(uid_t) uid;
2016 syscallarg(gid_t) gid;
2017 } */ *uap = v;
2018 struct sys_lchown_args ua;
2019
2020 NETBSD32TOP_UAP(path, const char);
2021 NETBSD32TO64_UAP(uid);
2022 NETBSD32TO64_UAP(gid);
2023 return (sys_lchown(l, &ua, retval));
2024 }
2025
2026 int
2027 netbsd32___msync13(l, v, retval)
2028 struct lwp *l;
2029 void *v;
2030 register_t *retval;
2031 {
2032 struct netbsd32___msync13_args /* {
2033 syscallarg(netbsd32_voidp) addr;
2034 syscallarg(netbsd32_size_t) len;
2035 syscallarg(int) flags;
2036 } */ *uap = v;
2037 struct sys___msync13_args ua;
2038
2039 NETBSD32TOP_UAP(addr, void);
2040 NETBSD32TOX_UAP(len, size_t);
2041 NETBSD32TO64_UAP(flags);
2042 return (sys___msync13(l, &ua, retval));
2043 }
2044
2045 int
2046 netbsd32___posix_chown(l, v, retval)
2047 struct lwp *l;
2048 void *v;
2049 register_t *retval;
2050 {
2051 struct netbsd32___posix_chown_args /* {
2052 syscallarg(const netbsd32_charp) path;
2053 syscallarg(uid_t) uid;
2054 syscallarg(gid_t) gid;
2055 } */ *uap = v;
2056 struct sys___posix_chown_args ua;
2057
2058 NETBSD32TOP_UAP(path, const char);
2059 NETBSD32TO64_UAP(uid);
2060 NETBSD32TO64_UAP(gid);
2061 return (sys___posix_chown(l, &ua, retval));
2062 }
2063
2064 int
2065 netbsd32___posix_fchown(l, v, retval)
2066 struct lwp *l;
2067 void *v;
2068 register_t *retval;
2069 {
2070 struct netbsd32___posix_fchown_args /* {
2071 syscallarg(int) fd;
2072 syscallarg(uid_t) uid;
2073 syscallarg(gid_t) gid;
2074 } */ *uap = v;
2075 struct sys___posix_fchown_args ua;
2076
2077 NETBSD32TO64_UAP(fd);
2078 NETBSD32TO64_UAP(uid);
2079 NETBSD32TO64_UAP(gid);
2080 return (sys___posix_fchown(l, &ua, retval));
2081 }
2082
2083 int
2084 netbsd32___posix_lchown(l, v, retval)
2085 struct lwp *l;
2086 void *v;
2087 register_t *retval;
2088 {
2089 struct netbsd32___posix_lchown_args /* {
2090 syscallarg(const netbsd32_charp) path;
2091 syscallarg(uid_t) uid;
2092 syscallarg(gid_t) gid;
2093 } */ *uap = v;
2094 struct sys___posix_lchown_args ua;
2095
2096 NETBSD32TOP_UAP(path, const char);
2097 NETBSD32TO64_UAP(uid);
2098 NETBSD32TO64_UAP(gid);
2099 return (sys___posix_lchown(l, &ua, retval));
2100 }
2101
2102 int
2103 netbsd32_getsid(l, v, retval)
2104 struct lwp *l;
2105 void *v;
2106 register_t *retval;
2107 {
2108 struct netbsd32_getsid_args /* {
2109 syscallarg(pid_t) pid;
2110 } */ *uap = v;
2111 struct sys_getsid_args ua;
2112
2113 NETBSD32TO64_UAP(pid);
2114 return (sys_getsid(l, &ua, retval));
2115 }
2116
2117 #ifdef KTRACE
2118 int
2119 netbsd32_fktrace(l, v, retval)
2120 struct lwp *l;
2121 void *v;
2122 register_t *retval;
2123 {
2124 struct netbsd32_fktrace_args /* {
2125 syscallarg(const int) fd;
2126 syscallarg(int) ops;
2127 syscallarg(int) facs;
2128 syscallarg(int) pid;
2129 } */ *uap = v;
2130 #if 0
2131 struct sys_fktrace_args ua;
2132 #else
2133 /* XXXX */
2134 struct sys_fktrace_noconst_args {
2135 syscallarg(int) fd;
2136 syscallarg(int) ops;
2137 syscallarg(int) facs;
2138 syscallarg(int) pid;
2139 } ua;
2140 #endif
2141
2142 NETBSD32TOX_UAP(fd, int);
2143 NETBSD32TO64_UAP(ops);
2144 NETBSD32TO64_UAP(facs);
2145 NETBSD32TO64_UAP(pid);
2146 return (sys_fktrace(l, &ua, retval));
2147 }
2148 #endif /* KTRACE */
2149
2150 int netbsd32___sigpending14(l, v, retval)
2151 struct lwp *l;
2152 void *v;
2153 register_t *retval;
2154 {
2155 struct netbsd32___sigpending14_args /* {
2156 syscallarg(sigset_t *) set;
2157 } */ *uap = v;
2158 struct sys___sigpending14_args ua;
2159
2160 NETBSD32TOP_UAP(set, sigset_t);
2161 return (sys___sigpending14(l, &ua, retval));
2162 }
2163
2164 int netbsd32___sigprocmask14(l, v, retval)
2165 struct lwp *l;
2166 void *v;
2167 register_t *retval;
2168 {
2169 struct netbsd32___sigprocmask14_args /* {
2170 syscallarg(int) how;
2171 syscallarg(const sigset_t *) set;
2172 syscallarg(sigset_t *) oset;
2173 } */ *uap = v;
2174 struct sys___sigprocmask14_args ua;
2175
2176 NETBSD32TO64_UAP(how);
2177 NETBSD32TOP_UAP(set, sigset_t);
2178 NETBSD32TOP_UAP(oset, sigset_t);
2179 return (sys___sigprocmask14(l, &ua, retval));
2180 }
2181
2182 int netbsd32___sigsuspend14(l, v, retval)
2183 struct lwp *l;
2184 void *v;
2185 register_t *retval;
2186 {
2187 struct netbsd32___sigsuspend14_args /* {
2188 syscallarg(const sigset_t *) set;
2189 } */ *uap = v;
2190 struct sys___sigsuspend14_args ua;
2191
2192 NETBSD32TOP_UAP(set, sigset_t);
2193 return (sys___sigsuspend14(l, &ua, retval));
2194 };
2195
2196 int netbsd32_fchroot(l, v, retval)
2197 struct lwp *l;
2198 void *v;
2199 register_t *retval;
2200 {
2201 struct netbsd32_fchroot_args /* {
2202 syscallarg(int) fd;
2203 } */ *uap = v;
2204 struct sys_fchroot_args ua;
2205
2206 NETBSD32TO64_UAP(fd);
2207 return (sys_fchroot(l, &ua, retval));
2208 }
2209
2210 /*
2211 * Open a file given a file handle.
2212 *
2213 * Check permissions, allocate an open file structure,
2214 * and call the device open routine if any.
2215 */
2216 int
2217 netbsd32_fhopen(l, v, retval)
2218 struct lwp *l;
2219 void *v;
2220 register_t *retval;
2221 {
2222 struct netbsd32_fhopen_args /* {
2223 syscallarg(const fhandle_t *) fhp;
2224 syscallarg(int) flags;
2225 } */ *uap = v;
2226 struct sys_fhopen_args ua;
2227
2228 NETBSD32TOP_UAP(fhp, fhandle_t);
2229 NETBSD32TO64_UAP(flags);
2230 return (sys_fhopen(l, &ua, retval));
2231 }
2232
2233 int netbsd32_fhstat(l, v, retval)
2234 struct lwp *l;
2235 void *v;
2236 register_t *retval;
2237 {
2238 struct netbsd32_fhstat_args /* {
2239 syscallarg(const netbsd32_fhandlep_t) fhp;
2240 syscallarg(struct stat *) sb;
2241 } */ *uap = v;
2242 struct sys_fhstat_args ua;
2243
2244 NETBSD32TOP_UAP(fhp, const fhandle_t);
2245 NETBSD32TOP_UAP(sb, struct stat);
2246 return (sys_fhstat(l, &ua, retval));
2247 }
2248
2249 /* virtual memory syscalls */
2250 int
2251 netbsd32_ovadvise(l, v, retval)
2252 struct lwp *l;
2253 void *v;
2254 register_t *retval;
2255 {
2256 struct netbsd32_ovadvise_args /* {
2257 syscallarg(int) anom;
2258 } */ *uap = v;
2259 struct sys_ovadvise_args ua;
2260
2261 NETBSD32TO64_UAP(anom);
2262 return (sys_ovadvise(l, &ua, retval));
2263 }
2264
2265 void
2266 netbsd32_adjust_limits(struct proc *p)
2267 {
2268 rlim_t *valp;
2269
2270 valp = &p->p_rlimit[RLIMIT_DATA].rlim_cur;
2271 if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
2272 *valp = MAXDSIZ32;
2273 valp = &p->p_rlimit[RLIMIT_DATA].rlim_max;
2274 if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
2275 *valp = MAXDSIZ32;
2276
2277 valp = &p->p_rlimit[RLIMIT_STACK].rlim_cur;
2278 if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
2279 *valp = MAXSSIZ32;
2280 valp = &p->p_rlimit[RLIMIT_STACK].rlim_max;
2281 if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
2282 *valp = MAXSSIZ32;
2283 }
2284
2285 int
2286 netbsd32_uuidgen(struct lwp *l, void *v, register_t *retval)
2287 {
2288 struct netbsd32_uuidgen_args /* {
2289 syscallarg(netbsd32_uuidp_t) store;
2290 syscallarg(int) count;
2291 } */ *uap = v;
2292 struct sys_uuidgen_args ua;
2293
2294 NETBSD32TOP_UAP(store, struct uuid);
2295 NETBSD32TO64_UAP(count);
2296 return (sys_uuidgen(l, &ua, retval));
2297 }
2298
2299 int
2300 netbsd32_extattrctl(struct lwp *l, void *v, register_t *retval)
2301 {
2302 struct netbsd32_extattrctl_args /* {
2303 syscallarg(const netbsd32_charp) path;
2304 syscallarg(int) cmd;
2305 syscallarg(const netbsd32_charp) filename;
2306 syscallarg(int) attrnamespace;
2307 syscallarg(const netbsd32_charp) attrname;
2308 } */ *uap = v;
2309 struct sys_extattrctl_args ua;
2310
2311 NETBSD32TOP_UAP(path, const char);
2312 NETBSD32TO64_UAP(cmd);
2313 NETBSD32TOP_UAP(filename, const char);
2314 NETBSD32TO64_UAP(attrnamespace);
2315 NETBSD32TOP_UAP(attrname, const char);
2316 return sys_extattrctl(l, &ua, retval);
2317 }
2318
2319 int
2320 netbsd32_extattr_set_fd(struct lwp *l, void *v, register_t *retval)
2321 {
2322 struct netbsd32_extattr_set_fd_args /* {
2323 syscallarg(int) fd;
2324 syscallarg(int) attrnamespace;
2325 syscallarg(const netbsd32_charp) attrname;
2326 syscallarg(const netbsd32_voidp) data;
2327 syscallarg(netbsd32_size_t) nbytes;
2328 } */ *uap = v;
2329 struct sys_extattr_set_fd_args ua;
2330
2331 NETBSD32TO64_UAP(fd);
2332 NETBSD32TO64_UAP(attrnamespace);
2333 NETBSD32TOP_UAP(attrname, const char);
2334 NETBSD32TOP_UAP(data, const void);
2335 NETBSD32TOX_UAP(nbytes, size_t);
2336 return sys_extattr_set_fd(l, &ua, retval);
2337 }
2338
2339 int
2340 netbsd32_extattr_set_file(struct lwp *l, void *v, register_t *retval)
2341 {
2342 struct netbsd32_extattr_set_file_args /* {
2343 syscallarg(const netbsd32_charp) path;
2344 syscallarg(int) attrnamespace;
2345 syscallarg(const netbsd32_charp) attrname;
2346 syscallarg(const netbsd32_voidp) data;
2347 syscallarg(netbsd32_size_t) nbytes;
2348 } */ *uap = v;
2349 struct sys_extattr_set_file_args ua;
2350
2351 NETBSD32TOP_UAP(path, const char);
2352 NETBSD32TO64_UAP(attrnamespace);
2353 NETBSD32TOP_UAP(attrname, const char);
2354 NETBSD32TOP_UAP(data, const void);
2355 NETBSD32TOX_UAP(nbytes, size_t);
2356 return sys_extattr_set_file(l, &ua, retval);
2357 }
2358
2359 int
2360 netbsd32_extattr_set_link(struct lwp *l, void *v, register_t *retval)
2361 {
2362 struct netbsd32_extattr_set_link_args /* {
2363 syscallarg(const netbsd32_charp) path;
2364 syscallarg(int) attrnamespace;
2365 syscallarg(const netbsd32_charp) attrname;
2366 syscallarg(const netbsd32_voidp) data;
2367 syscallarg(netbsd32_size_t) nbytes;
2368 } */ *uap = v;
2369 struct sys_extattr_set_link_args ua;
2370
2371 NETBSD32TOP_UAP(path, const char);
2372 NETBSD32TO64_UAP(attrnamespace);
2373 NETBSD32TOP_UAP(attrname, const char);
2374 NETBSD32TOP_UAP(data, const void);
2375 NETBSD32TOX_UAP(nbytes, size_t);
2376 return sys_extattr_set_link(l, &ua, retval);
2377 }
2378
2379 int
2380 netbsd32_extattr_get_fd(struct lwp *l, void *v, register_t *retval)
2381 {
2382 struct netbsd32_extattr_get_fd_args /* {
2383 syscallarg(int) fd;
2384 syscallarg(int) attrnamespace;
2385 syscallarg(const netbsd32_charp) attrname;
2386 syscallarg(netbsd32_voidp) data;
2387 syscallarg(netbsd32_size_t) nbytes;
2388 } */ *uap = v;
2389 struct sys_extattr_get_fd_args ua;
2390
2391 NETBSD32TO64_UAP(fd);
2392 NETBSD32TO64_UAP(attrnamespace);
2393 NETBSD32TOP_UAP(attrname, const char);
2394 NETBSD32TOP_UAP(data, void);
2395 NETBSD32TOX_UAP(nbytes, size_t);
2396 return sys_extattr_get_fd(l, &ua, retval);
2397 }
2398
2399 int
2400 netbsd32_extattr_get_file(struct lwp *l, void *v, register_t *retval)
2401 {
2402 struct netbsd32_extattr_get_file_args /* {
2403 syscallarg(const netbsd32_charp) path;
2404 syscallarg(int) attrnamespace;
2405 syscallarg(const netbsd32_charp) attrname;
2406 syscallarg(netbsd32_voidp) data;
2407 syscallarg(netbsd32_size_t) nbytes;
2408 } */ *uap = v;
2409 struct sys_extattr_get_file_args ua;
2410
2411 NETBSD32TOP_UAP(path, const char);
2412 NETBSD32TO64_UAP(attrnamespace);
2413 NETBSD32TOP_UAP(attrname, const char);
2414 NETBSD32TOP_UAP(data, void);
2415 NETBSD32TOX_UAP(nbytes, size_t);
2416 return sys_extattr_get_file(l, &ua, retval);
2417 }
2418
2419 int
2420 netbsd32_extattr_get_link(struct lwp *l, void *v, register_t *retval)
2421 {
2422 struct netbsd32_extattr_get_link_args /* {
2423 syscallarg(const netbsd32_charp) path;
2424 syscallarg(int) attrnamespace;
2425 syscallarg(const netbsd32_charp) attrname;
2426 syscallarg(netbsd32_voidp) data;
2427 syscallarg(netbsd32_size_t) nbytes;
2428 } */ *uap = v;
2429 struct sys_extattr_get_link_args ua;
2430
2431 NETBSD32TOP_UAP(path, const char);
2432 NETBSD32TO64_UAP(attrnamespace);
2433 NETBSD32TOP_UAP(attrname, const char);
2434 NETBSD32TOP_UAP(data, void);
2435 NETBSD32TOX_UAP(nbytes, size_t);
2436 return sys_extattr_get_link(l, &ua, retval);
2437 }
2438
2439 int
2440 netbsd32_extattr_delete_fd(struct lwp *l, void *v, register_t *retval)
2441 {
2442 struct netbsd32_extattr_delete_fd_args /* {
2443 syscallarg(int) fd;
2444 syscallarg(int) attrnamespace;
2445 syscallarg(const netbsd32_charp) attrname;
2446 } */ *uap = v;
2447 struct sys_extattr_delete_fd_args ua;
2448
2449 NETBSD32TO64_UAP(fd);
2450 NETBSD32TO64_UAP(attrnamespace);
2451 NETBSD32TOP_UAP(attrname, const char);
2452 return sys_extattr_delete_fd(l, &ua, retval);
2453 }
2454
2455 int
2456 netbsd32_extattr_delete_file(struct lwp *l, void *v, register_t *retval)
2457 {
2458 struct netbsd32_extattr_delete_file_args /* {
2459 syscallarg(const netbsd32_charp) path;
2460 syscallarg(int) attrnamespace;
2461 syscallarg(const netbsd32_charp) attrname;
2462 } */ *uap = v;
2463 struct sys_extattr_delete_file_args ua;
2464
2465 NETBSD32TOP_UAP(path, const char);
2466 NETBSD32TO64_UAP(attrnamespace);
2467 NETBSD32TOP_UAP(attrname, const char);
2468 return sys_extattr_delete_file(l, &ua, retval);
2469 }
2470
2471 int
2472 netbsd32_extattr_delete_link(struct lwp *l, void *v, register_t *retval)
2473 {
2474 struct netbsd32_extattr_delete_link_args /* {
2475 syscallarg(const netbsd32_charp) path;
2476 syscallarg(int) attrnamespace;
2477 syscallarg(const netbsd32_charp) attrname;
2478 } */ *uap = v;
2479 struct sys_extattr_delete_link_args ua;
2480
2481 NETBSD32TOP_UAP(path, const char);
2482 NETBSD32TO64_UAP(attrnamespace);
2483 NETBSD32TOP_UAP(attrname, const char);
2484 return sys_extattr_delete_link(l, &ua, retval);
2485 }
2486
2487 int
2488 netbsd32_extattr_list_fd(struct lwp *l, void *v, register_t *retval)
2489 {
2490 struct netbsd32_extattr_list_fd_args /* {
2491 syscallarg(int) fd;
2492 syscallarg(int) attrnamespace;
2493 syscallarg(netbsd32_voidp) data;
2494 syscallarg(netbsd32_size_t) nbytes;
2495 } */ *uap = v;
2496 struct sys_extattr_list_fd_args ua;
2497
2498 NETBSD32TO64_UAP(fd);
2499 NETBSD32TO64_UAP(attrnamespace);
2500 NETBSD32TOP_UAP(data, void);
2501 NETBSD32TOX_UAP(nbytes, size_t);
2502 return sys_extattr_list_fd(l, &ua, retval);
2503 }
2504
2505 int
2506 netbsd32_extattr_list_file(struct lwp *l, void *v, register_t *retval)
2507 {
2508 struct netbsd32_extattr_list_file_args /* {
2509 syscallarg(const netbsd32_charp) path;
2510 syscallarg(int) attrnamespace;
2511 syscallarg(netbsd32_voidp) data;
2512 syscallarg(netbsd32_size_t) nbytes;
2513 } */ *uap = v;
2514 struct sys_extattr_list_file_args ua;
2515
2516 NETBSD32TOP_UAP(path, const char);
2517 NETBSD32TO64_UAP(attrnamespace);
2518 NETBSD32TOP_UAP(data, void);
2519 NETBSD32TOX_UAP(nbytes, size_t);
2520 return sys_extattr_list_file(l, &ua, retval);
2521 }
2522
2523 int
2524 netbsd32_extattr_list_link(struct lwp *l, void *v, register_t *retval)
2525 {
2526 struct netbsd32_extattr_list_link_args /* {
2527 syscallarg(const netbsd32_charp) path;
2528 syscallarg(int) attrnamespace;
2529 syscallarg(netbsd32_voidp) data;
2530 syscallarg(netbsd32_size_t) nbytes;
2531 } */ *uap = v;
2532 struct sys_extattr_list_link_args ua;
2533
2534 NETBSD32TOP_UAP(path, const char);
2535 NETBSD32TO64_UAP(attrnamespace);
2536 NETBSD32TOP_UAP(data, void);
2537 NETBSD32TOX_UAP(nbytes, size_t);
2538 return sys_extattr_list_link(l, &ua, retval);
2539 }
2540
2541 int
2542 netbsd32_mlockall(l, v, retval)
2543 struct lwp *l;
2544 void *v;
2545 register_t *retval;
2546 {
2547 struct netbsd32_mlockall_args /* {
2548 syscallarg(int) flags;
2549 } */ *uap = v;
2550 struct sys_mlockall_args ua;
2551
2552 NETBSD32TO64_UAP(flags);
2553 return (sys_mlockall(l, &ua, retval));
2554 }
2555
2556 int
2557 netbsd32___clone(struct lwp *l, void *v, register_t *retval)
2558 {
2559 struct netbsd32___clone_args /* {
2560 syscallarg(int) flags;
2561 syscallarg(netbsd32_voidp) stack;
2562 } */ *uap = v;
2563 struct sys___clone_args ua;
2564
2565 NETBSD32TO64_UAP(flags);
2566 NETBSD32TOP_UAP(stack, void);
2567 return sys___clone(l, &ua, retval);
2568 }
2569
2570 int
2571 netbsd32_fsync_range(struct lwp *l, void *v, register_t *retval)
2572 {
2573 struct netbsd32_fsync_range_args /* {
2574 syscallarg(int) fd;
2575 syscallarg(int) flags;
2576 syscallarg(off_t) start;
2577 syscallarg(off_t) length;
2578 } */ *uap = v;
2579 struct sys_fsync_range_args ua;
2580
2581 NETBSD32TO64_UAP(fd);
2582 NETBSD32TO64_UAP(flags);
2583 NETBSD32TO64_UAP(start);
2584 NETBSD32TO64_UAP(length);
2585 return (sys_fsync_range(l, &ua, retval));
2586 }
2587
2588 int
2589 netbsd32_rasctl(struct lwp *l, void *v, register_t *retval)
2590 {
2591 struct netbsd32_rasctl_args /* {
2592 syscallarg(netbsd32_caddr_t) addr;
2593 syscallarg(netbsd32_size_t) len;
2594 syscallarg(int) op;
2595 } */ *uap = v;
2596 struct sys_rasctl_args ua;
2597
2598 NETBSD32TOX64_UAP(addr, caddr_t);
2599 NETBSD32TOX_UAP(len, size_t);
2600 NETBSD32TO64_UAP(op);
2601 return sys_rasctl(l, &ua, retval);
2602 }
2603
2604 int
2605 netbsd32_setxattr(struct lwp *l, void *v, register_t *retval)
2606 {
2607 struct netbsd32_setxattr_args /* {
2608 syscallarg(const netbsd32_charp) path;
2609 syscallarg(const netbsd32_charp) name;
2610 syscallarg(netbsd32_voidp) value;
2611 syscallarg(netbsd32_size_t) size;
2612 syscallarg(int) flags;
2613 } */ *uap = v;
2614 struct sys_setxattr_args ua;
2615 NETBSD32TOP_UAP(path, const char);
2616 NETBSD32TOP_UAP(name, const char);
2617 NETBSD32TOP_UAP(value, void);
2618 NETBSD32TOX_UAP(size, size_t);
2619 NETBSD32TO64_UAP(flags);
2620 return sys_setxattr(l, &ua, retval);
2621 }
2622
2623 int
2624 netbsd32_lsetxattr(struct lwp *l, void *v, register_t *retval)
2625 {
2626 struct netbsd32_lsetxattr_args /* {
2627 syscallarg(const netbsd32_charp) path;
2628 syscallarg(const netbsd32_charp) name;
2629 syscallarg(netbsd32_voidp) value;
2630 syscallarg(netbsd32_size_t) size;
2631 syscallarg(int) flags;
2632 } */ *uap = v;
2633 struct sys_lsetxattr_args ua;
2634 NETBSD32TOP_UAP(path, const char);
2635 NETBSD32TOP_UAP(name, const char);
2636 NETBSD32TOP_UAP(value, void);
2637 NETBSD32TOX_UAP(size, size_t);
2638 NETBSD32TO64_UAP(flags);
2639 return sys_lsetxattr(l, &ua, retval);
2640 }
2641
2642 int
2643 netbsd32_fsetxattr(struct lwp *l, void *v, register_t *retval)
2644 {
2645 struct netbsd32_fsetxattr_args /* {
2646 syscallarg(int) fd;
2647 syscallarg(const netbsd32_charp) name;
2648 syscallarg(netbsd32_voidp) value;
2649 syscallarg(netbsd32_size_t) size;
2650 syscallarg(int) flags;
2651 } */ *uap = v;
2652 struct sys_fsetxattr_args ua;
2653 NETBSD32TO64_UAP(fd);
2654 NETBSD32TOP_UAP(name, const char);
2655 NETBSD32TOP_UAP(value, void);
2656 NETBSD32TOX_UAP(size, size_t);
2657 NETBSD32TO64_UAP(flags);
2658 return sys_fsetxattr(l, &ua, retval);
2659 }
2660
2661 int
2662 netbsd32_getxattr(struct lwp *l, void *v, register_t *retval)
2663 {
2664 struct netbsd32_getxattr_args /* {
2665 syscallarg(const netbsd32_charp) path;
2666 syscallarg(const netbsd32_charp) name;
2667 syscallarg(netbsd32_voidp) value;
2668 syscallarg(netbsd32_size_t) size;
2669 } */ *uap = v;
2670 struct sys_getxattr_args ua;
2671 NETBSD32TOP_UAP(path, const char);
2672 NETBSD32TOP_UAP(name, const char);
2673 NETBSD32TOP_UAP(value, void);
2674 NETBSD32TOX_UAP(size, size_t);
2675 return sys_getxattr(l, &ua, retval);
2676 }
2677
2678 int
2679 netbsd32_lgetxattr(struct lwp *l, void *v, register_t *retval)
2680 {
2681 struct netbsd32_lgetxattr_args /* {
2682 syscallarg(const netbsd32_charp) path;
2683 syscallarg(const netbsd32_charp) name;
2684 syscallarg(netbsd32_voidp) value;
2685 syscallarg(netbsd32_size_t) size;
2686 } */ *uap = v;
2687 struct sys_lgetxattr_args ua;
2688 NETBSD32TOP_UAP(path, const char);
2689 NETBSD32TOP_UAP(name, const char);
2690 NETBSD32TOP_UAP(value, void);
2691 NETBSD32TOX_UAP(size, size_t);
2692 return sys_lgetxattr(l, &ua, retval);
2693 }
2694
2695 int
2696 netbsd32_fgetxattr(struct lwp *l, void *v, register_t *retval)
2697 {
2698 struct netbsd32_fgetxattr_args /* {
2699 syscallarg(int) fd;
2700 syscallarg(const netbsd32_charp) name;
2701 syscallarg(netbsd32_voidp) value;
2702 syscallarg(netbsd32_size_t) size;
2703 } */ *uap = v;
2704 struct sys_fgetxattr_args ua;
2705 NETBSD32TO64_UAP(fd);
2706 NETBSD32TOP_UAP(name, const char);
2707 NETBSD32TOP_UAP(value, void);
2708 NETBSD32TOX_UAP(size, size_t);
2709 return sys_fgetxattr(l, &ua, retval);
2710 }
2711
2712 int
2713 netbsd32_listxattr(struct lwp *l, void *v, register_t *retval)
2714 {
2715 struct netbsd32_listxattr_args /* {
2716 syscallarg(const netbsd32_charp) path;
2717 syscallarg(netbsd32_charp) list;
2718 syscallarg(netbsd32_size_t) size;
2719 } */ *uap = v;
2720 struct sys_listxattr_args ua;
2721 NETBSD32TOP_UAP(path, const char);
2722 NETBSD32TOP_UAP(list, char);
2723 NETBSD32TOX_UAP(size, size_t);
2724 return sys_listxattr(l, &ua, retval);
2725 }
2726
2727 int
2728 netbsd32_llistxattr(struct lwp *l, void *v, register_t *retval)
2729 {
2730 struct netbsd32_llistxattr_args /* {
2731 syscallarg(const netbsd32_charp) path;
2732 syscallarg(netbsd32_charp) list;
2733 syscallarg(netbsd32_size_t) size;
2734 } */ *uap = v;
2735 struct sys_llistxattr_args ua;
2736 NETBSD32TOP_UAP(path, const char);
2737 NETBSD32TOP_UAP(list, char);
2738 NETBSD32TOX_UAP(size, size_t);
2739 return sys_llistxattr(l, &ua, retval);
2740 }
2741
2742 int
2743 netbsd32_flistxattr(struct lwp *l, void *v, register_t *retval)
2744 {
2745 struct netbsd32_flistxattr_args /* {
2746 syscallarg(int) fd;
2747 syscallarg(netbsd32_charp) list;
2748 syscallarg(netbsd32_size_t) size;
2749 } */ *uap = v;
2750 struct sys_flistxattr_args ua;
2751 NETBSD32TO64_UAP(fd);
2752 NETBSD32TOP_UAP(list, char);
2753 NETBSD32TOX_UAP(size, size_t);
2754 return sys_flistxattr(l, &ua, retval);
2755 }
2756
2757 int
2758 netbsd32_removexattr(struct lwp *l, void *v, register_t *retval)
2759 {
2760 struct netbsd32_removexattr_args /* {
2761 syscallarg(const netbsd32_charp) path;
2762 syscallarg(const netbsd32_charp) name;
2763 } */ *uap = v;
2764 struct sys_removexattr_args ua;
2765 NETBSD32TOP_UAP(path, const char);
2766 NETBSD32TOP_UAP(name, const char);
2767 return sys_removexattr(l, &ua, retval);
2768 }
2769
2770 int
2771 netbsd32_lremovexattr(struct lwp *l, void *v, register_t *retval)
2772 {
2773 struct netbsd32_lremovexattr_args /* {
2774 syscallarg(const netbsd32_charp) path;
2775 syscallarg(const netbsd32_charp) name;
2776 } */ *uap = v;
2777 struct sys_lremovexattr_args ua;
2778 NETBSD32TOP_UAP(path, const char);
2779 NETBSD32TOP_UAP(name, const char);
2780 return sys_lremovexattr(l, &ua, retval);
2781 }
2782
2783 int
2784 netbsd32_fremovexattr(struct lwp *l, void *v, register_t *retval)
2785 {
2786 struct netbsd32_fremovexattr_args /* {
2787 syscallarg(int) fd;
2788 syscallarg(const netbsd32_charp) name;
2789 } */ *uap = v;
2790 struct sys_fremovexattr_args ua;
2791 NETBSD32TO64_UAP(fd);
2792 NETBSD32TOP_UAP(name, const char);
2793 return sys_fremovexattr(l, &ua, retval);
2794 }
2795