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