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