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