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