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