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