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