netbsd32_netbsd.c revision 1.73.2.7 1 /* $NetBSD: netbsd32_netbsd.c,v 1.73.2.7 2005/11/10 14:01:21 skrll 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.73.2.7 2005/11/10 14:01:21 skrll 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 int
1900 netbsd32_poll(l, v, retval)
1901 struct lwp *l;
1902 void *v;
1903 register_t *retval;
1904 {
1905 struct netbsd32_poll_args /* {
1906 syscallarg(netbsd32_pollfdp_t) fds;
1907 syscallarg(u_int) nfds;
1908 syscallarg(int) timeout;
1909 } */ *uap = v;
1910 struct sys_poll_args ua;
1911
1912 NETBSD32TOP_UAP(fds, struct pollfd);
1913 NETBSD32TO64_UAP(nfds);
1914 NETBSD32TO64_UAP(timeout);
1915 return (sys_poll(l, &ua, retval));
1916 }
1917
1918 int
1919 netbsd32_fdatasync(l, v, retval)
1920 struct lwp *l;
1921 void *v;
1922 register_t *retval;
1923 {
1924 struct netbsd32_fdatasync_args /* {
1925 syscallarg(int) fd;
1926 } */ *uap = v;
1927 struct sys_fdatasync_args ua;
1928
1929 NETBSD32TO64_UAP(fd);
1930 return (sys_fdatasync(l, &ua, retval));
1931 }
1932
1933 int
1934 netbsd32___posix_rename(l, v, retval)
1935 struct lwp *l;
1936 void *v;
1937 register_t *retval;
1938 {
1939 struct netbsd32___posix_rename_args /* {
1940 syscallarg(const netbsd32_charp) from;
1941 syscallarg(const netbsd32_charp) to;
1942 } */ *uap = v;
1943 struct sys___posix_rename_args ua;
1944
1945 NETBSD32TOP_UAP(from, const char);
1946 NETBSD32TOP_UAP(to, const char);
1947 return (sys___posix_rename(l, &ua, retval));
1948 }
1949
1950 int
1951 netbsd32_swapctl(l, v, retval)
1952 struct lwp *l;
1953 void *v;
1954 register_t *retval;
1955 {
1956 struct netbsd32_swapctl_args /* {
1957 syscallarg(int) cmd;
1958 syscallarg(const netbsd32_voidp) arg;
1959 syscallarg(int) misc;
1960 } */ *uap = v;
1961 struct sys_swapctl_args ua;
1962
1963 NETBSD32TO64_UAP(cmd);
1964 NETBSD32TOP_UAP(arg, void);
1965 NETBSD32TO64_UAP(misc);
1966 return (sys_swapctl(l, &ua, retval));
1967 }
1968
1969 int
1970 netbsd32_minherit(l, v, retval)
1971 struct lwp *l;
1972 void *v;
1973 register_t *retval;
1974 {
1975 struct netbsd32_minherit_args /* {
1976 syscallarg(netbsd32_voidp) addr;
1977 syscallarg(netbsd32_size_t) len;
1978 syscallarg(int) inherit;
1979 } */ *uap = v;
1980 struct sys_minherit_args ua;
1981
1982 NETBSD32TOP_UAP(addr, void);
1983 NETBSD32TOX_UAP(len, size_t);
1984 NETBSD32TO64_UAP(inherit);
1985 return (sys_minherit(l, &ua, retval));
1986 }
1987
1988 int
1989 netbsd32_lchmod(l, v, retval)
1990 struct lwp *l;
1991 void *v;
1992 register_t *retval;
1993 {
1994 struct netbsd32_lchmod_args /* {
1995 syscallarg(const netbsd32_charp) path;
1996 syscallarg(mode_t) mode;
1997 } */ *uap = v;
1998 struct sys_lchmod_args ua;
1999
2000 NETBSD32TOP_UAP(path, const char);
2001 NETBSD32TO64_UAP(mode);
2002 return (sys_lchmod(l, &ua, retval));
2003 }
2004
2005 int
2006 netbsd32_lchown(l, v, retval)
2007 struct lwp *l;
2008 void *v;
2009 register_t *retval;
2010 {
2011 struct netbsd32_lchown_args /* {
2012 syscallarg(const netbsd32_charp) path;
2013 syscallarg(uid_t) uid;
2014 syscallarg(gid_t) gid;
2015 } */ *uap = v;
2016 struct sys_lchown_args ua;
2017
2018 NETBSD32TOP_UAP(path, const char);
2019 NETBSD32TO64_UAP(uid);
2020 NETBSD32TO64_UAP(gid);
2021 return (sys_lchown(l, &ua, retval));
2022 }
2023
2024 int
2025 netbsd32___msync13(l, v, retval)
2026 struct lwp *l;
2027 void *v;
2028 register_t *retval;
2029 {
2030 struct netbsd32___msync13_args /* {
2031 syscallarg(netbsd32_voidp) addr;
2032 syscallarg(netbsd32_size_t) len;
2033 syscallarg(int) flags;
2034 } */ *uap = v;
2035 struct sys___msync13_args ua;
2036
2037 NETBSD32TOP_UAP(addr, void);
2038 NETBSD32TOX_UAP(len, size_t);
2039 NETBSD32TO64_UAP(flags);
2040 return (sys___msync13(l, &ua, retval));
2041 }
2042
2043 int
2044 netbsd32___posix_chown(l, v, retval)
2045 struct lwp *l;
2046 void *v;
2047 register_t *retval;
2048 {
2049 struct netbsd32___posix_chown_args /* {
2050 syscallarg(const netbsd32_charp) path;
2051 syscallarg(uid_t) uid;
2052 syscallarg(gid_t) gid;
2053 } */ *uap = v;
2054 struct sys___posix_chown_args ua;
2055
2056 NETBSD32TOP_UAP(path, const char);
2057 NETBSD32TO64_UAP(uid);
2058 NETBSD32TO64_UAP(gid);
2059 return (sys___posix_chown(l, &ua, retval));
2060 }
2061
2062 int
2063 netbsd32___posix_fchown(l, v, retval)
2064 struct lwp *l;
2065 void *v;
2066 register_t *retval;
2067 {
2068 struct netbsd32___posix_fchown_args /* {
2069 syscallarg(int) fd;
2070 syscallarg(uid_t) uid;
2071 syscallarg(gid_t) gid;
2072 } */ *uap = v;
2073 struct sys___posix_fchown_args ua;
2074
2075 NETBSD32TO64_UAP(fd);
2076 NETBSD32TO64_UAP(uid);
2077 NETBSD32TO64_UAP(gid);
2078 return (sys___posix_fchown(l, &ua, retval));
2079 }
2080
2081 int
2082 netbsd32___posix_lchown(l, v, retval)
2083 struct lwp *l;
2084 void *v;
2085 register_t *retval;
2086 {
2087 struct netbsd32___posix_lchown_args /* {
2088 syscallarg(const netbsd32_charp) path;
2089 syscallarg(uid_t) uid;
2090 syscallarg(gid_t) gid;
2091 } */ *uap = v;
2092 struct sys___posix_lchown_args ua;
2093
2094 NETBSD32TOP_UAP(path, const char);
2095 NETBSD32TO64_UAP(uid);
2096 NETBSD32TO64_UAP(gid);
2097 return (sys___posix_lchown(l, &ua, retval));
2098 }
2099
2100 int
2101 netbsd32_getsid(l, v, retval)
2102 struct lwp *l;
2103 void *v;
2104 register_t *retval;
2105 {
2106 struct netbsd32_getsid_args /* {
2107 syscallarg(pid_t) pid;
2108 } */ *uap = v;
2109 struct sys_getsid_args ua;
2110
2111 NETBSD32TO64_UAP(pid);
2112 return (sys_getsid(l, &ua, retval));
2113 }
2114
2115 #ifdef KTRACE
2116 int
2117 netbsd32_fktrace(l, v, retval)
2118 struct lwp *l;
2119 void *v;
2120 register_t *retval;
2121 {
2122 struct netbsd32_fktrace_args /* {
2123 syscallarg(const int) fd;
2124 syscallarg(int) ops;
2125 syscallarg(int) facs;
2126 syscallarg(int) pid;
2127 } */ *uap = v;
2128 #if 0
2129 struct sys_fktrace_args ua;
2130 #else
2131 /* XXXX */
2132 struct sys_fktrace_noconst_args {
2133 syscallarg(int) fd;
2134 syscallarg(int) ops;
2135 syscallarg(int) facs;
2136 syscallarg(int) pid;
2137 } ua;
2138 #endif
2139
2140 NETBSD32TOX_UAP(fd, int);
2141 NETBSD32TO64_UAP(ops);
2142 NETBSD32TO64_UAP(facs);
2143 NETBSD32TO64_UAP(pid);
2144 return (sys_fktrace(l, &ua, retval));
2145 }
2146 #endif /* KTRACE */
2147
2148 int netbsd32___sigpending14(l, v, retval)
2149 struct lwp *l;
2150 void *v;
2151 register_t *retval;
2152 {
2153 struct netbsd32___sigpending14_args /* {
2154 syscallarg(sigset_t *) set;
2155 } */ *uap = v;
2156 struct sys___sigpending14_args ua;
2157
2158 NETBSD32TOP_UAP(set, sigset_t);
2159 return (sys___sigpending14(l, &ua, retval));
2160 }
2161
2162 int netbsd32___sigprocmask14(l, v, retval)
2163 struct lwp *l;
2164 void *v;
2165 register_t *retval;
2166 {
2167 struct netbsd32___sigprocmask14_args /* {
2168 syscallarg(int) how;
2169 syscallarg(const sigset_t *) set;
2170 syscallarg(sigset_t *) oset;
2171 } */ *uap = v;
2172 struct sys___sigprocmask14_args ua;
2173
2174 NETBSD32TO64_UAP(how);
2175 NETBSD32TOP_UAP(set, sigset_t);
2176 NETBSD32TOP_UAP(oset, sigset_t);
2177 return (sys___sigprocmask14(l, &ua, retval));
2178 }
2179
2180 int netbsd32___sigsuspend14(l, v, retval)
2181 struct lwp *l;
2182 void *v;
2183 register_t *retval;
2184 {
2185 struct netbsd32___sigsuspend14_args /* {
2186 syscallarg(const sigset_t *) set;
2187 } */ *uap = v;
2188 struct sys___sigsuspend14_args ua;
2189
2190 NETBSD32TOP_UAP(set, sigset_t);
2191 return (sys___sigsuspend14(l, &ua, retval));
2192 };
2193
2194 int netbsd32_fchroot(l, v, retval)
2195 struct lwp *l;
2196 void *v;
2197 register_t *retval;
2198 {
2199 struct netbsd32_fchroot_args /* {
2200 syscallarg(int) fd;
2201 } */ *uap = v;
2202 struct sys_fchroot_args ua;
2203
2204 NETBSD32TO64_UAP(fd);
2205 return (sys_fchroot(l, &ua, retval));
2206 }
2207
2208 /*
2209 * Open a file given a file handle.
2210 *
2211 * Check permissions, allocate an open file structure,
2212 * and call the device open routine if any.
2213 */
2214 int
2215 netbsd32_fhopen(l, v, retval)
2216 struct lwp *l;
2217 void *v;
2218 register_t *retval;
2219 {
2220 struct netbsd32_fhopen_args /* {
2221 syscallarg(const fhandle_t *) fhp;
2222 syscallarg(int) flags;
2223 } */ *uap = v;
2224 struct sys_fhopen_args ua;
2225
2226 NETBSD32TOP_UAP(fhp, fhandle_t);
2227 NETBSD32TO64_UAP(flags);
2228 return (sys_fhopen(l, &ua, retval));
2229 }
2230
2231 int netbsd32_fhstat(l, v, retval)
2232 struct lwp *l;
2233 void *v;
2234 register_t *retval;
2235 {
2236 struct netbsd32_fhstat_args /* {
2237 syscallarg(const netbsd32_fhandlep_t) fhp;
2238 syscallarg(struct stat *) sb;
2239 } */ *uap = v;
2240 struct sys_fhstat_args ua;
2241
2242 NETBSD32TOP_UAP(fhp, const fhandle_t);
2243 NETBSD32TOP_UAP(sb, struct stat);
2244 return (sys_fhstat(l, &ua, retval));
2245 }
2246
2247 /* virtual memory syscalls */
2248 int
2249 netbsd32_ovadvise(l, v, retval)
2250 struct lwp *l;
2251 void *v;
2252 register_t *retval;
2253 {
2254 struct netbsd32_ovadvise_args /* {
2255 syscallarg(int) anom;
2256 } */ *uap = v;
2257 struct sys_ovadvise_args ua;
2258
2259 NETBSD32TO64_UAP(anom);
2260 return (sys_ovadvise(l, &ua, retval));
2261 }
2262
2263 void
2264 netbsd32_adjust_limits(struct proc *p)
2265 {
2266 rlim_t *valp;
2267
2268 valp = &p->p_rlimit[RLIMIT_DATA].rlim_cur;
2269 if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
2270 *valp = MAXDSIZ32;
2271 valp = &p->p_rlimit[RLIMIT_DATA].rlim_max;
2272 if (*valp != RLIM_INFINITY && *valp > MAXDSIZ32)
2273 *valp = MAXDSIZ32;
2274
2275 valp = &p->p_rlimit[RLIMIT_STACK].rlim_cur;
2276 if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
2277 *valp = MAXSSIZ32;
2278 valp = &p->p_rlimit[RLIMIT_STACK].rlim_max;
2279 if (*valp != RLIM_INFINITY && *valp > MAXSSIZ32)
2280 *valp = MAXSSIZ32;
2281 }
2282
2283 int
2284 netbsd32_uuidgen(struct lwp *l, void *v, register_t *retval)
2285 {
2286 struct netbsd32_uuidgen_args /* {
2287 syscallarg(netbsd32_uuidp_t) store;
2288 syscallarg(int) count;
2289 } */ *uap = v;
2290 struct sys_uuidgen_args ua;
2291
2292 NETBSD32TOP_UAP(store, struct uuid);
2293 NETBSD32TO64_UAP(count);
2294 return (sys_uuidgen(l, &ua, retval));
2295 }
2296
2297 int
2298 netbsd32_extattrctl(struct lwp *l, void *v, register_t *retval)
2299 {
2300 struct netbsd32_extattrctl_args /* {
2301 syscallarg(const netbsd32_charp) path;
2302 syscallarg(int) cmd;
2303 syscallarg(const netbsd32_charp) filename;
2304 syscallarg(int) attrnamespace;
2305 syscallarg(const netbsd32_charp) attrname;
2306 } */ *uap = v;
2307 struct sys_extattrctl_args ua;
2308
2309 NETBSD32TOP_UAP(path, const char);
2310 NETBSD32TO64_UAP(cmd);
2311 NETBSD32TOP_UAP(filename, const char);
2312 NETBSD32TO64_UAP(attrnamespace);
2313 NETBSD32TOP_UAP(attrname, const char);
2314 return sys_extattrctl(l, &ua, retval);
2315 }
2316
2317 int
2318 netbsd32_extattr_set_fd(struct lwp *l, void *v, register_t *retval)
2319 {
2320 struct netbsd32_extattr_set_fd_args /* {
2321 syscallarg(int) fd;
2322 syscallarg(int) attrnamespace;
2323 syscallarg(const netbsd32_charp) attrname;
2324 syscallarg(const netbsd32_voidp) data;
2325 syscallarg(netbsd32_size_t) nbytes;
2326 } */ *uap = v;
2327 struct sys_extattr_set_fd_args ua;
2328
2329 NETBSD32TO64_UAP(fd);
2330 NETBSD32TO64_UAP(attrnamespace);
2331 NETBSD32TOP_UAP(attrname, const char);
2332 NETBSD32TOP_UAP(data, const void);
2333 NETBSD32TOX_UAP(nbytes, size_t);
2334 return sys_extattr_set_fd(l, &ua, retval);
2335 }
2336
2337 int
2338 netbsd32_extattr_set_file(struct lwp *l, void *v, register_t *retval)
2339 {
2340 struct netbsd32_extattr_set_file_args /* {
2341 syscallarg(const netbsd32_charp) path;
2342 syscallarg(int) attrnamespace;
2343 syscallarg(const netbsd32_charp) attrname;
2344 syscallarg(const netbsd32_voidp) data;
2345 syscallarg(netbsd32_size_t) nbytes;
2346 } */ *uap = v;
2347 struct sys_extattr_set_file_args ua;
2348
2349 NETBSD32TOP_UAP(path, const char);
2350 NETBSD32TO64_UAP(attrnamespace);
2351 NETBSD32TOP_UAP(attrname, const char);
2352 NETBSD32TOP_UAP(data, const void);
2353 NETBSD32TOX_UAP(nbytes, size_t);
2354 return sys_extattr_set_file(l, &ua, retval);
2355 }
2356
2357 int
2358 netbsd32_extattr_set_link(struct lwp *l, void *v, register_t *retval)
2359 {
2360 struct netbsd32_extattr_set_link_args /* {
2361 syscallarg(const netbsd32_charp) path;
2362 syscallarg(int) attrnamespace;
2363 syscallarg(const netbsd32_charp) attrname;
2364 syscallarg(const netbsd32_voidp) data;
2365 syscallarg(netbsd32_size_t) nbytes;
2366 } */ *uap = v;
2367 struct sys_extattr_set_link_args ua;
2368
2369 NETBSD32TOP_UAP(path, const char);
2370 NETBSD32TO64_UAP(attrnamespace);
2371 NETBSD32TOP_UAP(attrname, const char);
2372 NETBSD32TOP_UAP(data, const void);
2373 NETBSD32TOX_UAP(nbytes, size_t);
2374 return sys_extattr_set_link(l, &ua, retval);
2375 }
2376
2377 int
2378 netbsd32_extattr_get_fd(struct lwp *l, void *v, register_t *retval)
2379 {
2380 struct netbsd32_extattr_get_fd_args /* {
2381 syscallarg(int) fd;
2382 syscallarg(int) attrnamespace;
2383 syscallarg(const netbsd32_charp) attrname;
2384 syscallarg(netbsd32_voidp) data;
2385 syscallarg(netbsd32_size_t) nbytes;
2386 } */ *uap = v;
2387 struct sys_extattr_get_fd_args ua;
2388
2389 NETBSD32TO64_UAP(fd);
2390 NETBSD32TO64_UAP(attrnamespace);
2391 NETBSD32TOP_UAP(attrname, const char);
2392 NETBSD32TOP_UAP(data, void);
2393 NETBSD32TOX_UAP(nbytes, size_t);
2394 return sys_extattr_get_fd(l, &ua, retval);
2395 }
2396
2397 int
2398 netbsd32_extattr_get_file(struct lwp *l, void *v, register_t *retval)
2399 {
2400 struct netbsd32_extattr_get_file_args /* {
2401 syscallarg(const netbsd32_charp) path;
2402 syscallarg(int) attrnamespace;
2403 syscallarg(const netbsd32_charp) attrname;
2404 syscallarg(netbsd32_voidp) data;
2405 syscallarg(netbsd32_size_t) nbytes;
2406 } */ *uap = v;
2407 struct sys_extattr_get_file_args ua;
2408
2409 NETBSD32TOP_UAP(path, const char);
2410 NETBSD32TO64_UAP(attrnamespace);
2411 NETBSD32TOP_UAP(attrname, const char);
2412 NETBSD32TOP_UAP(data, void);
2413 NETBSD32TOX_UAP(nbytes, size_t);
2414 return sys_extattr_get_file(l, &ua, retval);
2415 }
2416
2417 int
2418 netbsd32_extattr_get_link(struct lwp *l, void *v, register_t *retval)
2419 {
2420 struct netbsd32_extattr_get_link_args /* {
2421 syscallarg(const netbsd32_charp) path;
2422 syscallarg(int) attrnamespace;
2423 syscallarg(const netbsd32_charp) attrname;
2424 syscallarg(netbsd32_voidp) data;
2425 syscallarg(netbsd32_size_t) nbytes;
2426 } */ *uap = v;
2427 struct sys_extattr_get_link_args ua;
2428
2429 NETBSD32TOP_UAP(path, const char);
2430 NETBSD32TO64_UAP(attrnamespace);
2431 NETBSD32TOP_UAP(attrname, const char);
2432 NETBSD32TOP_UAP(data, void);
2433 NETBSD32TOX_UAP(nbytes, size_t);
2434 return sys_extattr_get_link(l, &ua, retval);
2435 }
2436
2437 int
2438 netbsd32_extattr_delete_fd(struct lwp *l, void *v, register_t *retval)
2439 {
2440 struct netbsd32_extattr_delete_fd_args /* {
2441 syscallarg(int) fd;
2442 syscallarg(int) attrnamespace;
2443 syscallarg(const netbsd32_charp) attrname;
2444 } */ *uap = v;
2445 struct sys_extattr_delete_fd_args ua;
2446
2447 NETBSD32TO64_UAP(fd);
2448 NETBSD32TO64_UAP(attrnamespace);
2449 NETBSD32TOP_UAP(attrname, const char);
2450 return sys_extattr_delete_fd(l, &ua, retval);
2451 }
2452
2453 int
2454 netbsd32_extattr_delete_file(struct lwp *l, void *v, register_t *retval)
2455 {
2456 struct netbsd32_extattr_delete_file_args /* {
2457 syscallarg(const netbsd32_charp) path;
2458 syscallarg(int) attrnamespace;
2459 syscallarg(const netbsd32_charp) attrname;
2460 } */ *uap = v;
2461 struct sys_extattr_delete_file_args ua;
2462
2463 NETBSD32TOP_UAP(path, const char);
2464 NETBSD32TO64_UAP(attrnamespace);
2465 NETBSD32TOP_UAP(attrname, const char);
2466 return sys_extattr_delete_file(l, &ua, retval);
2467 }
2468
2469 int
2470 netbsd32_extattr_delete_link(struct lwp *l, void *v, register_t *retval)
2471 {
2472 struct netbsd32_extattr_delete_link_args /* {
2473 syscallarg(const netbsd32_charp) path;
2474 syscallarg(int) attrnamespace;
2475 syscallarg(const netbsd32_charp) attrname;
2476 } */ *uap = v;
2477 struct sys_extattr_delete_link_args ua;
2478
2479 NETBSD32TOP_UAP(path, const char);
2480 NETBSD32TO64_UAP(attrnamespace);
2481 NETBSD32TOP_UAP(attrname, const char);
2482 return sys_extattr_delete_link(l, &ua, retval);
2483 }
2484
2485 int
2486 netbsd32_extattr_list_fd(struct lwp *l, void *v, register_t *retval)
2487 {
2488 struct netbsd32_extattr_list_fd_args /* {
2489 syscallarg(int) fd;
2490 syscallarg(int) attrnamespace;
2491 syscallarg(netbsd32_voidp) data;
2492 syscallarg(netbsd32_size_t) nbytes;
2493 } */ *uap = v;
2494 struct sys_extattr_list_fd_args ua;
2495
2496 NETBSD32TO64_UAP(fd);
2497 NETBSD32TO64_UAP(attrnamespace);
2498 NETBSD32TOP_UAP(data, void);
2499 NETBSD32TOX_UAP(nbytes, size_t);
2500 return sys_extattr_list_fd(l, &ua, retval);
2501 }
2502
2503 int
2504 netbsd32_extattr_list_file(struct lwp *l, void *v, register_t *retval)
2505 {
2506 struct netbsd32_extattr_list_file_args /* {
2507 syscallarg(const netbsd32_charp) path;
2508 syscallarg(int) attrnamespace;
2509 syscallarg(netbsd32_voidp) data;
2510 syscallarg(netbsd32_size_t) nbytes;
2511 } */ *uap = v;
2512 struct sys_extattr_list_file_args ua;
2513
2514 NETBSD32TOP_UAP(path, const char);
2515 NETBSD32TO64_UAP(attrnamespace);
2516 NETBSD32TOP_UAP(data, void);
2517 NETBSD32TOX_UAP(nbytes, size_t);
2518 return sys_extattr_list_file(l, &ua, retval);
2519 }
2520
2521 int
2522 netbsd32_extattr_list_link(struct lwp *l, void *v, register_t *retval)
2523 {
2524 struct netbsd32_extattr_list_link_args /* {
2525 syscallarg(const netbsd32_charp) path;
2526 syscallarg(int) attrnamespace;
2527 syscallarg(netbsd32_voidp) data;
2528 syscallarg(netbsd32_size_t) nbytes;
2529 } */ *uap = v;
2530 struct sys_extattr_list_link_args ua;
2531
2532 NETBSD32TOP_UAP(path, const char);
2533 NETBSD32TO64_UAP(attrnamespace);
2534 NETBSD32TOP_UAP(data, void);
2535 NETBSD32TOX_UAP(nbytes, size_t);
2536 return sys_extattr_list_link(l, &ua, retval);
2537 }
2538
2539 int
2540 netbsd32_mlockall(l, v, retval)
2541 struct lwp *l;
2542 void *v;
2543 register_t *retval;
2544 {
2545 struct netbsd32_mlockall_args /* {
2546 syscallarg(int) flags;
2547 } */ *uap = v;
2548 struct sys_mlockall_args ua;
2549
2550 NETBSD32TO64_UAP(flags);
2551 return (sys_mlockall(l, &ua, retval));
2552 }
2553
2554 int
2555 netbsd32___clone(struct lwp *l, void *v, register_t *retval)
2556 {
2557 struct netbsd32___clone_args /* {
2558 syscallarg(int) flags;
2559 syscallarg(netbsd32_voidp) stack;
2560 } */ *uap = v;
2561 struct sys___clone_args ua;
2562
2563 NETBSD32TO64_UAP(flags);
2564 NETBSD32TOP_UAP(stack, void);
2565 return sys___clone(l, &ua, retval);
2566 }
2567
2568 int
2569 netbsd32_fsync_range(struct lwp *l, void *v, register_t *retval)
2570 {
2571 struct netbsd32_fsync_range_args /* {
2572 syscallarg(int) fd;
2573 syscallarg(int) flags;
2574 syscallarg(off_t) start;
2575 syscallarg(off_t) length;
2576 } */ *uap = v;
2577 struct sys_fsync_range_args ua;
2578
2579 NETBSD32TO64_UAP(fd);
2580 NETBSD32TO64_UAP(flags);
2581 NETBSD32TO64_UAP(start);
2582 NETBSD32TO64_UAP(length);
2583 return (sys_fsync_range(l, &ua, retval));
2584 }
2585
2586 int
2587 netbsd32_rasctl(struct lwp *l, void *v, register_t *retval)
2588 {
2589 struct netbsd32_rasctl_args /* {
2590 syscallarg(netbsd32_caddr_t) addr;
2591 syscallarg(netbsd32_size_t) len;
2592 syscallarg(int) op;
2593 } */ *uap = v;
2594 struct sys_rasctl_args ua;
2595
2596 NETBSD32TOX64_UAP(addr, caddr_t);
2597 NETBSD32TOX_UAP(len, size_t);
2598 NETBSD32TO64_UAP(op);
2599 return sys_rasctl(l, &ua, retval);
2600 }
2601
2602 int
2603 netbsd32_setxattr(struct lwp *l, void *v, register_t *retval)
2604 {
2605 struct netbsd32_setxattr_args /* {
2606 syscallarg(const netbsd32_charp) path;
2607 syscallarg(const netbsd32_charp) name;
2608 syscallarg(netbsd32_voidp) value;
2609 syscallarg(netbsd32_size_t) size;
2610 syscallarg(int) flags;
2611 } */ *uap = v;
2612 struct sys_setxattr_args ua;
2613 NETBSD32TOP_UAP(path, const char);
2614 NETBSD32TOP_UAP(name, const char);
2615 NETBSD32TOP_UAP(value, void);
2616 NETBSD32TOX_UAP(size, size_t);
2617 NETBSD32TO64_UAP(flags);
2618 return sys_setxattr(l, &ua, retval);
2619 }
2620
2621 int
2622 netbsd32_lsetxattr(struct lwp *l, void *v, register_t *retval)
2623 {
2624 struct netbsd32_lsetxattr_args /* {
2625 syscallarg(const netbsd32_charp) path;
2626 syscallarg(const netbsd32_charp) name;
2627 syscallarg(netbsd32_voidp) value;
2628 syscallarg(netbsd32_size_t) size;
2629 syscallarg(int) flags;
2630 } */ *uap = v;
2631 struct sys_lsetxattr_args ua;
2632 NETBSD32TOP_UAP(path, const char);
2633 NETBSD32TOP_UAP(name, const char);
2634 NETBSD32TOP_UAP(value, void);
2635 NETBSD32TOX_UAP(size, size_t);
2636 NETBSD32TO64_UAP(flags);
2637 return sys_lsetxattr(l, &ua, retval);
2638 }
2639
2640 int
2641 netbsd32_fsetxattr(struct lwp *l, void *v, register_t *retval)
2642 {
2643 struct netbsd32_fsetxattr_args /* {
2644 syscallarg(int) fd;
2645 syscallarg(const netbsd32_charp) name;
2646 syscallarg(netbsd32_voidp) value;
2647 syscallarg(netbsd32_size_t) size;
2648 syscallarg(int) flags;
2649 } */ *uap = v;
2650 struct sys_fsetxattr_args ua;
2651 NETBSD32TO64_UAP(fd);
2652 NETBSD32TOP_UAP(name, const char);
2653 NETBSD32TOP_UAP(value, void);
2654 NETBSD32TOX_UAP(size, size_t);
2655 NETBSD32TO64_UAP(flags);
2656 return sys_fsetxattr(l, &ua, retval);
2657 }
2658
2659 int
2660 netbsd32_getxattr(struct lwp *l, void *v, register_t *retval)
2661 {
2662 struct netbsd32_getxattr_args /* {
2663 syscallarg(const netbsd32_charp) path;
2664 syscallarg(const netbsd32_charp) name;
2665 syscallarg(netbsd32_voidp) value;
2666 syscallarg(netbsd32_size_t) size;
2667 } */ *uap = v;
2668 struct sys_getxattr_args ua;
2669 NETBSD32TOP_UAP(path, const char);
2670 NETBSD32TOP_UAP(name, const char);
2671 NETBSD32TOP_UAP(value, void);
2672 NETBSD32TOX_UAP(size, size_t);
2673 return sys_getxattr(l, &ua, retval);
2674 }
2675
2676 int
2677 netbsd32_lgetxattr(struct lwp *l, void *v, register_t *retval)
2678 {
2679 struct netbsd32_lgetxattr_args /* {
2680 syscallarg(const netbsd32_charp) path;
2681 syscallarg(const netbsd32_charp) name;
2682 syscallarg(netbsd32_voidp) value;
2683 syscallarg(netbsd32_size_t) size;
2684 } */ *uap = v;
2685 struct sys_lgetxattr_args ua;
2686 NETBSD32TOP_UAP(path, const char);
2687 NETBSD32TOP_UAP(name, const char);
2688 NETBSD32TOP_UAP(value, void);
2689 NETBSD32TOX_UAP(size, size_t);
2690 return sys_lgetxattr(l, &ua, retval);
2691 }
2692
2693 int
2694 netbsd32_fgetxattr(struct lwp *l, void *v, register_t *retval)
2695 {
2696 struct netbsd32_fgetxattr_args /* {
2697 syscallarg(int) fd;
2698 syscallarg(const netbsd32_charp) name;
2699 syscallarg(netbsd32_voidp) value;
2700 syscallarg(netbsd32_size_t) size;
2701 } */ *uap = v;
2702 struct sys_fgetxattr_args ua;
2703 NETBSD32TO64_UAP(fd);
2704 NETBSD32TOP_UAP(name, const char);
2705 NETBSD32TOP_UAP(value, void);
2706 NETBSD32TOX_UAP(size, size_t);
2707 return sys_fgetxattr(l, &ua, retval);
2708 }
2709
2710 int
2711 netbsd32_listxattr(struct lwp *l, void *v, register_t *retval)
2712 {
2713 struct netbsd32_listxattr_args /* {
2714 syscallarg(const netbsd32_charp) path;
2715 syscallarg(netbsd32_charp) list;
2716 syscallarg(netbsd32_size_t) size;
2717 } */ *uap = v;
2718 struct sys_listxattr_args ua;
2719 NETBSD32TOP_UAP(path, const char);
2720 NETBSD32TOP_UAP(list, char);
2721 NETBSD32TOX_UAP(size, size_t);
2722 return sys_listxattr(l, &ua, retval);
2723 }
2724
2725 int
2726 netbsd32_llistxattr(struct lwp *l, void *v, register_t *retval)
2727 {
2728 struct netbsd32_llistxattr_args /* {
2729 syscallarg(const netbsd32_charp) path;
2730 syscallarg(netbsd32_charp) list;
2731 syscallarg(netbsd32_size_t) size;
2732 } */ *uap = v;
2733 struct sys_llistxattr_args ua;
2734 NETBSD32TOP_UAP(path, const char);
2735 NETBSD32TOP_UAP(list, char);
2736 NETBSD32TOX_UAP(size, size_t);
2737 return sys_llistxattr(l, &ua, retval);
2738 }
2739
2740 int
2741 netbsd32_flistxattr(struct lwp *l, void *v, register_t *retval)
2742 {
2743 struct netbsd32_flistxattr_args /* {
2744 syscallarg(int) fd;
2745 syscallarg(netbsd32_charp) list;
2746 syscallarg(netbsd32_size_t) size;
2747 } */ *uap = v;
2748 struct sys_flistxattr_args ua;
2749 NETBSD32TO64_UAP(fd);
2750 NETBSD32TOP_UAP(list, char);
2751 NETBSD32TOX_UAP(size, size_t);
2752 return sys_flistxattr(l, &ua, retval);
2753 }
2754
2755 int
2756 netbsd32_removexattr(struct lwp *l, void *v, register_t *retval)
2757 {
2758 struct netbsd32_removexattr_args /* {
2759 syscallarg(const netbsd32_charp) path;
2760 syscallarg(const netbsd32_charp) name;
2761 } */ *uap = v;
2762 struct sys_removexattr_args ua;
2763 NETBSD32TOP_UAP(path, const char);
2764 NETBSD32TOP_UAP(name, const char);
2765 return sys_removexattr(l, &ua, retval);
2766 }
2767
2768 int
2769 netbsd32_lremovexattr(struct lwp *l, void *v, register_t *retval)
2770 {
2771 struct netbsd32_lremovexattr_args /* {
2772 syscallarg(const netbsd32_charp) path;
2773 syscallarg(const netbsd32_charp) name;
2774 } */ *uap = v;
2775 struct sys_lremovexattr_args ua;
2776 NETBSD32TOP_UAP(path, const char);
2777 NETBSD32TOP_UAP(name, const char);
2778 return sys_lremovexattr(l, &ua, retval);
2779 }
2780
2781 int
2782 netbsd32_fremovexattr(struct lwp *l, void *v, register_t *retval)
2783 {
2784 struct netbsd32_fremovexattr_args /* {
2785 syscallarg(int) fd;
2786 syscallarg(const netbsd32_charp) name;
2787 } */ *uap = v;
2788 struct sys_fremovexattr_args ua;
2789 NETBSD32TO64_UAP(fd);
2790 NETBSD32TOP_UAP(name, const char);
2791 return sys_fremovexattr(l, &ua, retval);
2792 }
2793