netbsd32_netbsd.c revision 1.210 1 /* $NetBSD: netbsd32_netbsd.c,v 1.210 2017/12/19 18:34:47 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.210 2017/12/19 18:34:47 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 int
2010 netbsd32_ovadvise(struct lwp *l, const struct netbsd32_ovadvise_args *uap, register_t *retval)
2011 {
2012 /* {
2013 syscallarg(int) anom;
2014 } */
2015 struct sys_ovadvise_args ua;
2016
2017 NETBSD32TO64_UAP(anom);
2018 return (sys_ovadvise(l, &ua, retval));
2019 }
2020
2021 void
2022 netbsd32_adjust_limits(struct proc *p)
2023 {
2024 static const struct {
2025 int id;
2026 rlim_t lim;
2027 } lm[] = {
2028 { RLIMIT_DATA, MAXDSIZ32 },
2029 { RLIMIT_STACK, MAXSSIZ32 },
2030 };
2031 size_t i;
2032 struct plimit *lim;
2033 struct rlimit *rlim;
2034
2035 /*
2036 * We can only reduce the current limits, we cannot stop external
2037 * processes from changing them (eg via sysctl) later on.
2038 * So there is no point trying to lock out such changes here.
2039 *
2040 * If we assume that rlim_cur/max are accessed using atomic
2041 * operations, we don't need to lock against any other updates
2042 * that might happen if the plimit structure is shared writable
2043 * between multiple processes.
2044 */
2045
2046 /* Scan to determine is any limits are out of range */
2047 lim = p->p_limit;
2048 for (i = 0; ; i++) {
2049 if (i >= __arraycount(lm))
2050 /* All in range */
2051 return;
2052 rlim = lim->pl_rlimit + lm[i].id;
2053 if (LIMITCHECK(rlim->rlim_cur, lm[i].lim))
2054 break;
2055 if (LIMITCHECK(rlim->rlim_max, lm[i].lim))
2056 break;
2057 }
2058
2059 lim_privatise(p);
2060
2061 lim = p->p_limit;
2062 for (i = 0; i < __arraycount(lm); i++) {
2063 rlim = lim->pl_rlimit + lm[i].id;
2064 if (LIMITCHECK(rlim->rlim_cur, lm[i].lim))
2065 rlim->rlim_cur = lm[i].lim;
2066 if (LIMITCHECK(rlim->rlim_max, lm[i].lim))
2067 rlim->rlim_max = lm[i].lim;
2068 }
2069 }
2070
2071 int
2072 netbsd32_uuidgen(struct lwp *l, const struct netbsd32_uuidgen_args *uap, register_t *retval)
2073 {
2074 /* {
2075 syscallarg(netbsd32_uuidp_t) store;
2076 syscallarg(int) count;
2077 } */
2078 struct sys_uuidgen_args ua;
2079
2080 NETBSD32TOP_UAP(store, struct uuid);
2081 NETBSD32TO64_UAP(count);
2082 return (sys_uuidgen(l, &ua, retval));
2083 }
2084
2085 int
2086 netbsd32_extattrctl(struct lwp *l, const struct netbsd32_extattrctl_args *uap, register_t *retval)
2087 {
2088 /* {
2089 syscallarg(const netbsd32_charp) path;
2090 syscallarg(int) cmd;
2091 syscallarg(const netbsd32_charp) filename;
2092 syscallarg(int) attrnamespace;
2093 syscallarg(const netbsd32_charp) attrname;
2094 } */
2095 struct sys_extattrctl_args ua;
2096
2097 NETBSD32TOP_UAP(path, const char);
2098 NETBSD32TO64_UAP(cmd);
2099 NETBSD32TOP_UAP(filename, const char);
2100 NETBSD32TO64_UAP(attrnamespace);
2101 NETBSD32TOP_UAP(attrname, const char);
2102 return sys_extattrctl(l, &ua, retval);
2103 }
2104
2105 int
2106 netbsd32_extattr_set_fd(struct lwp *l, const struct netbsd32_extattr_set_fd_args *uap, register_t *retval)
2107 {
2108 /* {
2109 syscallarg(int) fd;
2110 syscallarg(int) attrnamespace;
2111 syscallarg(const netbsd32_charp) attrname;
2112 syscallarg(const netbsd32_voidp) data;
2113 syscallarg(netbsd32_size_t) nbytes;
2114 } */
2115 struct sys_extattr_set_fd_args ua;
2116
2117 NETBSD32TO64_UAP(fd);
2118 NETBSD32TO64_UAP(attrnamespace);
2119 NETBSD32TOP_UAP(attrname, const char);
2120 NETBSD32TOP_UAP(data, const void);
2121 NETBSD32TOX_UAP(nbytes, size_t);
2122 return sys_extattr_set_fd(l, &ua, retval);
2123 }
2124
2125 int
2126 netbsd32_extattr_set_file(struct lwp *l, const struct netbsd32_extattr_set_file_args *uap, register_t *retval)
2127 {
2128 /* {
2129 syscallarg(const netbsd32_charp) path;
2130 syscallarg(int) attrnamespace;
2131 syscallarg(const netbsd32_charp) attrname;
2132 syscallarg(const netbsd32_voidp) data;
2133 syscallarg(netbsd32_size_t) nbytes;
2134 } */
2135 struct sys_extattr_set_file_args ua;
2136
2137 NETBSD32TOP_UAP(path, const char);
2138 NETBSD32TO64_UAP(attrnamespace);
2139 NETBSD32TOP_UAP(attrname, const char);
2140 NETBSD32TOP_UAP(data, const void);
2141 NETBSD32TOX_UAP(nbytes, size_t);
2142 return sys_extattr_set_file(l, &ua, retval);
2143 }
2144
2145 int
2146 netbsd32_extattr_set_link(struct lwp *l, const struct netbsd32_extattr_set_link_args *uap, register_t *retval)
2147 {
2148 /* {
2149 syscallarg(const netbsd32_charp) path;
2150 syscallarg(int) attrnamespace;
2151 syscallarg(const netbsd32_charp) attrname;
2152 syscallarg(const netbsd32_voidp) data;
2153 syscallarg(netbsd32_size_t) nbytes;
2154 } */
2155 struct sys_extattr_set_link_args ua;
2156
2157 NETBSD32TOP_UAP(path, const char);
2158 NETBSD32TO64_UAP(attrnamespace);
2159 NETBSD32TOP_UAP(attrname, const char);
2160 NETBSD32TOP_UAP(data, const void);
2161 NETBSD32TOX_UAP(nbytes, size_t);
2162 return sys_extattr_set_link(l, &ua, retval);
2163 }
2164
2165 int
2166 netbsd32_extattr_get_fd(struct lwp *l, const struct netbsd32_extattr_get_fd_args *uap, register_t *retval)
2167 {
2168 /* {
2169 syscallarg(int) fd;
2170 syscallarg(int) attrnamespace;
2171 syscallarg(const netbsd32_charp) attrname;
2172 syscallarg(netbsd32_voidp) data;
2173 syscallarg(netbsd32_size_t) nbytes;
2174 } */
2175 struct sys_extattr_get_fd_args ua;
2176
2177 NETBSD32TO64_UAP(fd);
2178 NETBSD32TO64_UAP(attrnamespace);
2179 NETBSD32TOP_UAP(attrname, const char);
2180 NETBSD32TOP_UAP(data, void);
2181 NETBSD32TOX_UAP(nbytes, size_t);
2182 return sys_extattr_get_fd(l, &ua, retval);
2183 }
2184
2185 int
2186 netbsd32_extattr_get_file(struct lwp *l, const struct netbsd32_extattr_get_file_args *uap, register_t *retval)
2187 {
2188 /* {
2189 syscallarg(const netbsd32_charp) path;
2190 syscallarg(int) attrnamespace;
2191 syscallarg(const netbsd32_charp) attrname;
2192 syscallarg(netbsd32_voidp) data;
2193 syscallarg(netbsd32_size_t) nbytes;
2194 } */
2195 struct sys_extattr_get_file_args ua;
2196
2197 NETBSD32TOP_UAP(path, const char);
2198 NETBSD32TO64_UAP(attrnamespace);
2199 NETBSD32TOP_UAP(attrname, const char);
2200 NETBSD32TOP_UAP(data, void);
2201 NETBSD32TOX_UAP(nbytes, size_t);
2202 return sys_extattr_get_file(l, &ua, retval);
2203 }
2204
2205 int
2206 netbsd32_extattr_get_link(struct lwp *l, const struct netbsd32_extattr_get_link_args *uap, register_t *retval)
2207 {
2208 /* {
2209 syscallarg(const netbsd32_charp) path;
2210 syscallarg(int) attrnamespace;
2211 syscallarg(const netbsd32_charp) attrname;
2212 syscallarg(netbsd32_voidp) data;
2213 syscallarg(netbsd32_size_t) nbytes;
2214 } */
2215 struct sys_extattr_get_link_args ua;
2216
2217 NETBSD32TOP_UAP(path, const char);
2218 NETBSD32TO64_UAP(attrnamespace);
2219 NETBSD32TOP_UAP(attrname, const char);
2220 NETBSD32TOP_UAP(data, void);
2221 NETBSD32TOX_UAP(nbytes, size_t);
2222 return sys_extattr_get_link(l, &ua, retval);
2223 }
2224
2225 int
2226 netbsd32_extattr_delete_fd(struct lwp *l, const struct netbsd32_extattr_delete_fd_args *uap, register_t *retval)
2227 {
2228 /* {
2229 syscallarg(int) fd;
2230 syscallarg(int) attrnamespace;
2231 syscallarg(const netbsd32_charp) attrname;
2232 } */
2233 struct sys_extattr_delete_fd_args ua;
2234
2235 NETBSD32TO64_UAP(fd);
2236 NETBSD32TO64_UAP(attrnamespace);
2237 NETBSD32TOP_UAP(attrname, const char);
2238 return sys_extattr_delete_fd(l, &ua, retval);
2239 }
2240
2241 int
2242 netbsd32_extattr_delete_file(struct lwp *l, const struct netbsd32_extattr_delete_file_args *uap, register_t *retval)
2243 {
2244 /* {
2245 syscallarg(const netbsd32_charp) path;
2246 syscallarg(int) attrnamespace;
2247 syscallarg(const netbsd32_charp) attrname;
2248 } */
2249 struct sys_extattr_delete_file_args ua;
2250
2251 NETBSD32TOP_UAP(path, const char);
2252 NETBSD32TO64_UAP(attrnamespace);
2253 NETBSD32TOP_UAP(attrname, const char);
2254 return sys_extattr_delete_file(l, &ua, retval);
2255 }
2256
2257 int
2258 netbsd32_extattr_delete_link(struct lwp *l, const struct netbsd32_extattr_delete_link_args *uap, register_t *retval)
2259 {
2260 /* {
2261 syscallarg(const netbsd32_charp) path;
2262 syscallarg(int) attrnamespace;
2263 syscallarg(const netbsd32_charp) attrname;
2264 } */
2265 struct sys_extattr_delete_link_args ua;
2266
2267 NETBSD32TOP_UAP(path, const char);
2268 NETBSD32TO64_UAP(attrnamespace);
2269 NETBSD32TOP_UAP(attrname, const char);
2270 return sys_extattr_delete_link(l, &ua, retval);
2271 }
2272
2273 int
2274 netbsd32_extattr_list_fd(struct lwp *l, const struct netbsd32_extattr_list_fd_args *uap, register_t *retval)
2275 {
2276 /* {
2277 syscallarg(int) fd;
2278 syscallarg(int) attrnamespace;
2279 syscallarg(netbsd32_voidp) data;
2280 syscallarg(netbsd32_size_t) nbytes;
2281 } */
2282 struct sys_extattr_list_fd_args ua;
2283
2284 NETBSD32TO64_UAP(fd);
2285 NETBSD32TO64_UAP(attrnamespace);
2286 NETBSD32TOP_UAP(data, void);
2287 NETBSD32TOX_UAP(nbytes, size_t);
2288 return sys_extattr_list_fd(l, &ua, retval);
2289 }
2290
2291 int
2292 netbsd32_extattr_list_file(struct lwp *l, const struct netbsd32_extattr_list_file_args *uap, register_t *retval)
2293 {
2294 /* {
2295 syscallarg(const netbsd32_charp) path;
2296 syscallarg(int) attrnamespace;
2297 syscallarg(netbsd32_voidp) data;
2298 syscallarg(netbsd32_size_t) nbytes;
2299 } */
2300 struct sys_extattr_list_file_args ua;
2301
2302 NETBSD32TOP_UAP(path, const char);
2303 NETBSD32TO64_UAP(attrnamespace);
2304 NETBSD32TOP_UAP(data, void);
2305 NETBSD32TOX_UAP(nbytes, size_t);
2306 return sys_extattr_list_file(l, &ua, retval);
2307 }
2308
2309 int
2310 netbsd32_extattr_list_link(struct lwp *l, const struct netbsd32_extattr_list_link_args *uap, register_t *retval)
2311 {
2312 /* {
2313 syscallarg(const netbsd32_charp) path;
2314 syscallarg(int) attrnamespace;
2315 syscallarg(netbsd32_voidp) data;
2316 syscallarg(netbsd32_size_t) nbytes;
2317 } */
2318 struct sys_extattr_list_link_args ua;
2319
2320 NETBSD32TOP_UAP(path, const char);
2321 NETBSD32TO64_UAP(attrnamespace);
2322 NETBSD32TOP_UAP(data, void);
2323 NETBSD32TOX_UAP(nbytes, size_t);
2324 return sys_extattr_list_link(l, &ua, retval);
2325 }
2326
2327 int
2328 netbsd32_mlockall(struct lwp *l, const struct netbsd32_mlockall_args *uap, register_t *retval)
2329 {
2330 /* {
2331 syscallarg(int) flags;
2332 } */
2333 struct sys_mlockall_args ua;
2334
2335 NETBSD32TO64_UAP(flags);
2336 return (sys_mlockall(l, &ua, retval));
2337 }
2338
2339 int
2340 netbsd32___clone(struct lwp *l, const struct netbsd32___clone_args *uap, register_t *retval)
2341 {
2342 /* {
2343 syscallarg(int) flags;
2344 syscallarg(netbsd32_voidp) stack;
2345 } */
2346 struct sys___clone_args ua;
2347
2348 NETBSD32TO64_UAP(flags);
2349 NETBSD32TOP_UAP(stack, void);
2350 return sys___clone(l, &ua, retval);
2351 }
2352
2353 int
2354 netbsd32_fsync_range(struct lwp *l, const struct netbsd32_fsync_range_args *uap, register_t *retval)
2355 {
2356 /* {
2357 syscallarg(int) fd;
2358 syscallarg(int) flags;
2359 syscallarg(off_t) start;
2360 syscallarg(off_t) length;
2361 } */
2362 struct sys_fsync_range_args ua;
2363
2364 NETBSD32TO64_UAP(fd);
2365 NETBSD32TO64_UAP(flags);
2366 NETBSD32TO64_UAP(start);
2367 NETBSD32TO64_UAP(length);
2368 return (sys_fsync_range(l, &ua, retval));
2369 }
2370
2371 int
2372 netbsd32_rasctl(struct lwp *l, const struct netbsd32_rasctl_args *uap, register_t *retval)
2373 {
2374 /* {
2375 syscallarg(netbsd32_voidp) addr;
2376 syscallarg(netbsd32_size_t) len;
2377 syscallarg(int) op;
2378 } */
2379 struct sys_rasctl_args ua;
2380
2381 NETBSD32TOP_UAP(addr, void *);
2382 NETBSD32TOX_UAP(len, size_t);
2383 NETBSD32TO64_UAP(op);
2384 return sys_rasctl(l, &ua, retval);
2385 }
2386
2387 int
2388 netbsd32_setxattr(struct lwp *l, const struct netbsd32_setxattr_args *uap, register_t *retval)
2389 {
2390 /* {
2391 syscallarg(const netbsd32_charp) path;
2392 syscallarg(const netbsd32_charp) name;
2393 syscallarg(netbsd32_voidp) value;
2394 syscallarg(netbsd32_size_t) size;
2395 syscallarg(int) flags;
2396 } */
2397 struct sys_setxattr_args ua;
2398 NETBSD32TOP_UAP(path, const char);
2399 NETBSD32TOP_UAP(name, const char);
2400 NETBSD32TOP_UAP(value, void);
2401 NETBSD32TOX_UAP(size, size_t);
2402 NETBSD32TO64_UAP(flags);
2403 return sys_setxattr(l, &ua, retval);
2404 }
2405
2406 int
2407 netbsd32_lsetxattr(struct lwp *l, const struct netbsd32_lsetxattr_args *uap, register_t *retval)
2408 {
2409 /* {
2410 syscallarg(const netbsd32_charp) path;
2411 syscallarg(const netbsd32_charp) name;
2412 syscallarg(netbsd32_voidp) value;
2413 syscallarg(netbsd32_size_t) size;
2414 syscallarg(int) flags;
2415 } */
2416 struct sys_lsetxattr_args ua;
2417 NETBSD32TOP_UAP(path, const char);
2418 NETBSD32TOP_UAP(name, const char);
2419 NETBSD32TOP_UAP(value, void);
2420 NETBSD32TOX_UAP(size, size_t);
2421 NETBSD32TO64_UAP(flags);
2422 return sys_lsetxattr(l, &ua, retval);
2423 }
2424
2425 int
2426 netbsd32_fsetxattr(struct lwp *l, const struct netbsd32_fsetxattr_args *uap, register_t *retval)
2427 {
2428 /* {
2429 syscallarg(int) fd;
2430 syscallarg(const netbsd32_charp) name;
2431 syscallarg(netbsd32_voidp) value;
2432 syscallarg(netbsd32_size_t) size;
2433 syscallarg(int) flags;
2434 } */
2435 struct sys_fsetxattr_args ua;
2436 NETBSD32TO64_UAP(fd);
2437 NETBSD32TOP_UAP(name, const char);
2438 NETBSD32TOP_UAP(value, void);
2439 NETBSD32TOX_UAP(size, size_t);
2440 NETBSD32TO64_UAP(flags);
2441 return sys_fsetxattr(l, &ua, retval);
2442 }
2443
2444 int
2445 netbsd32_getxattr(struct lwp *l, const struct netbsd32_getxattr_args *uap, register_t *retval)
2446 {
2447 /* {
2448 syscallarg(const netbsd32_charp) path;
2449 syscallarg(const netbsd32_charp) name;
2450 syscallarg(netbsd32_voidp) value;
2451 syscallarg(netbsd32_size_t) size;
2452 } */
2453 struct sys_getxattr_args ua;
2454 NETBSD32TOP_UAP(path, const char);
2455 NETBSD32TOP_UAP(name, const char);
2456 NETBSD32TOP_UAP(value, void);
2457 NETBSD32TOX_UAP(size, size_t);
2458 return sys_getxattr(l, &ua, retval);
2459 }
2460
2461 int
2462 netbsd32_lgetxattr(struct lwp *l, const struct netbsd32_lgetxattr_args *uap, register_t *retval)
2463 {
2464 /* {
2465 syscallarg(const netbsd32_charp) path;
2466 syscallarg(const netbsd32_charp) name;
2467 syscallarg(netbsd32_voidp) value;
2468 syscallarg(netbsd32_size_t) size;
2469 } */
2470 struct sys_lgetxattr_args ua;
2471 NETBSD32TOP_UAP(path, const char);
2472 NETBSD32TOP_UAP(name, const char);
2473 NETBSD32TOP_UAP(value, void);
2474 NETBSD32TOX_UAP(size, size_t);
2475 return sys_lgetxattr(l, &ua, retval);
2476 }
2477
2478 int
2479 netbsd32_fgetxattr(struct lwp *l, const struct netbsd32_fgetxattr_args *uap, register_t *retval)
2480 {
2481 /* {
2482 syscallarg(int) fd;
2483 syscallarg(const netbsd32_charp) name;
2484 syscallarg(netbsd32_voidp) value;
2485 syscallarg(netbsd32_size_t) size;
2486 } */
2487 struct sys_fgetxattr_args ua;
2488 NETBSD32TO64_UAP(fd);
2489 NETBSD32TOP_UAP(name, const char);
2490 NETBSD32TOP_UAP(value, void);
2491 NETBSD32TOX_UAP(size, size_t);
2492 return sys_fgetxattr(l, &ua, retval);
2493 }
2494
2495 int
2496 netbsd32_listxattr(struct lwp *l, const struct netbsd32_listxattr_args *uap, register_t *retval)
2497 {
2498 /* {
2499 syscallarg(const netbsd32_charp) path;
2500 syscallarg(netbsd32_charp) list;
2501 syscallarg(netbsd32_size_t) size;
2502 } */
2503 struct sys_listxattr_args ua;
2504 NETBSD32TOP_UAP(path, const char);
2505 NETBSD32TOP_UAP(list, char);
2506 NETBSD32TOX_UAP(size, size_t);
2507 return sys_listxattr(l, &ua, retval);
2508 }
2509
2510 int
2511 netbsd32_llistxattr(struct lwp *l, const struct netbsd32_llistxattr_args *uap, register_t *retval)
2512 {
2513 /* {
2514 syscallarg(const netbsd32_charp) path;
2515 syscallarg(netbsd32_charp) list;
2516 syscallarg(netbsd32_size_t) size;
2517 } */
2518 struct sys_llistxattr_args ua;
2519 NETBSD32TOP_UAP(path, const char);
2520 NETBSD32TOP_UAP(list, char);
2521 NETBSD32TOX_UAP(size, size_t);
2522 return sys_llistxattr(l, &ua, retval);
2523 }
2524
2525 int
2526 netbsd32_flistxattr(struct lwp *l, const struct netbsd32_flistxattr_args *uap, register_t *retval)
2527 {
2528 /* {
2529 syscallarg(int) fd;
2530 syscallarg(netbsd32_charp) list;
2531 syscallarg(netbsd32_size_t) size;
2532 } */
2533 struct sys_flistxattr_args ua;
2534 NETBSD32TO64_UAP(fd);
2535 NETBSD32TOP_UAP(list, char);
2536 NETBSD32TOX_UAP(size, size_t);
2537 return sys_flistxattr(l, &ua, retval);
2538 }
2539
2540 int
2541 netbsd32_removexattr(struct lwp *l, const struct netbsd32_removexattr_args *uap, register_t *retval)
2542 {
2543 /* {
2544 syscallarg(const netbsd32_charp) path;
2545 syscallarg(const netbsd32_charp) name;
2546 } */
2547 struct sys_removexattr_args ua;
2548 NETBSD32TOP_UAP(path, const char);
2549 NETBSD32TOP_UAP(name, const char);
2550 return sys_removexattr(l, &ua, retval);
2551 }
2552
2553 int
2554 netbsd32_lremovexattr(struct lwp *l, const struct netbsd32_lremovexattr_args *uap, register_t *retval)
2555 {
2556 /* {
2557 syscallarg(const netbsd32_charp) path;
2558 syscallarg(const netbsd32_charp) name;
2559 } */
2560 struct sys_lremovexattr_args ua;
2561 NETBSD32TOP_UAP(path, const char);
2562 NETBSD32TOP_UAP(name, const char);
2563 return sys_lremovexattr(l, &ua, retval);
2564 }
2565
2566 int
2567 netbsd32_fremovexattr(struct lwp *l, const struct netbsd32_fremovexattr_args *uap, register_t *retval)
2568 {
2569 /* {
2570 syscallarg(int) fd;
2571 syscallarg(const netbsd32_charp) name;
2572 } */
2573 struct sys_fremovexattr_args ua;
2574 NETBSD32TO64_UAP(fd);
2575 NETBSD32TOP_UAP(name, const char);
2576 return sys_fremovexattr(l, &ua, retval);
2577 }
2578
2579 int
2580 netbsd32___posix_fadvise50(struct lwp *l,
2581 const struct netbsd32___posix_fadvise50_args *uap, register_t *retval)
2582 {
2583 /* {
2584 syscallarg(int) fd;
2585 syscallarg(int) PAD;
2586 syscallarg(netbsd32_off_t) offset;
2587 syscallarg(netbsd32_off_t) len;
2588 syscallarg(int) advice;
2589 } */
2590
2591 *retval = do_posix_fadvise(SCARG(uap, fd), SCARG(uap, offset),
2592 SCARG(uap, len), SCARG(uap, advice));
2593
2594 return 0;
2595 }
2596
2597 int
2598 netbsd32__sched_setparam(struct lwp *l,
2599 const struct netbsd32__sched_setparam_args *uap,
2600 register_t *retval)
2601 {
2602 /* {
2603 syscallarg(pid_t) pid;
2604 syscallarg(lwpid_t) lid;
2605 syscallarg(int) policy;
2606 syscallarg(const netbsd32_sched_paramp_t) params;
2607 } */
2608 struct sys__sched_setparam_args ua;
2609
2610 NETBSD32TO64_UAP(pid);
2611 NETBSD32TO64_UAP(lid);
2612 NETBSD32TO64_UAP(policy);
2613 NETBSD32TOP_UAP(params, const struct sched_param *);
2614 return sys__sched_setparam(l, &ua, retval);
2615 }
2616
2617 int
2618 netbsd32__sched_getparam(struct lwp *l,
2619 const struct netbsd32__sched_getparam_args *uap,
2620 register_t *retval)
2621 {
2622 /* {
2623 syscallarg(pid_t) pid;
2624 syscallarg(lwpid_t) lid;
2625 syscallarg(netbsd32_intp) policy;
2626 syscallarg(netbsd32_sched_paramp_t) params;
2627 } */
2628 struct sys__sched_getparam_args ua;
2629
2630 NETBSD32TO64_UAP(pid);
2631 NETBSD32TO64_UAP(lid);
2632 NETBSD32TOP_UAP(policy, int *);
2633 NETBSD32TOP_UAP(params, struct sched_param *);
2634 return sys__sched_getparam(l, &ua, retval);
2635 }
2636
2637 int
2638 netbsd32__sched_setaffinity(struct lwp *l,
2639 const struct netbsd32__sched_setaffinity_args *uap,
2640 register_t *retval)
2641 {
2642 /* {
2643 syscallarg(pid_t) pid;
2644 syscallarg(lwpid_t) lid;
2645 syscallarg(netbsd_size_t) size;
2646 syscallarg(const netbsd32_cpusetp_t) cpuset;
2647 } */
2648 struct sys__sched_setaffinity_args ua;
2649
2650 NETBSD32TO64_UAP(pid);
2651 NETBSD32TO64_UAP(lid);
2652 NETBSD32TOX_UAP(size, size_t);
2653 NETBSD32TOP_UAP(cpuset, const cpuset_t *);
2654 return sys__sched_setaffinity(l, &ua, retval);
2655 }
2656
2657 int
2658 netbsd32__sched_getaffinity(struct lwp *l,
2659 const struct netbsd32__sched_getaffinity_args *uap,
2660 register_t *retval)
2661 {
2662 /* {
2663 syscallarg(pid_t) pid;
2664 syscallarg(lwpid_t) lid;
2665 syscallarg(netbsd_size_t) size;
2666 syscallarg(netbsd32_cpusetp_t) cpuset;
2667 } */
2668 struct sys__sched_getaffinity_args ua;
2669
2670 NETBSD32TO64_UAP(pid);
2671 NETBSD32TO64_UAP(lid);
2672 NETBSD32TOX_UAP(size, size_t);
2673 NETBSD32TOP_UAP(cpuset, cpuset_t *);
2674 return sys__sched_getaffinity(l, &ua, retval);
2675 }
2676
2677 int
2678 netbsd32__sched_protect(struct lwp *l,
2679 const struct netbsd32__sched_protect_args *uap,
2680 register_t *retval)
2681 {
2682 /* {
2683 syscallarg(int) priority;
2684 } */
2685 struct sys__sched_protect_args ua;
2686
2687 NETBSD32TO64_UAP(priority);
2688 return sys__sched_protect(l, &ua, retval);
2689 }
2690
2691 int
2692 netbsd32_pipe2(struct lwp *l, const struct netbsd32_pipe2_args *uap,
2693 register_t *retval)
2694 {
2695 /* {
2696 syscallarg(netbsd32_intp) fildes;
2697 syscallarg(int) flags;
2698 } */
2699 int fd[2], error;
2700
2701 error = pipe1(l, retval, SCARG(uap, flags));
2702 if (error != 0)
2703 return error;
2704
2705 fd[0] = retval[0];
2706 fd[1] = retval[1];
2707
2708 error = copyout(fd, SCARG_P32(uap, fildes), sizeof(fd));
2709 if (error != 0)
2710 return error;
2711
2712 retval[0] = 0;
2713 return 0;
2714 }
2715
2716 int
2717 netbsd32_dup3(struct lwp *l, const struct netbsd32_dup3_args *uap,
2718 register_t *retval)
2719 {
2720 /* {
2721 syscallarg(int) from;
2722 syscallarg(int) to;
2723 syscallarg(int) flags;
2724 } */
2725 struct sys_dup3_args ua;
2726
2727 NETBSD32TO64_UAP(from);
2728 NETBSD32TO64_UAP(to);
2729 NETBSD32TO64_UAP(flags);
2730
2731 return sys_dup3(l, &ua, retval);
2732 }
2733
2734 int
2735 netbsd32_kqueue1(struct lwp *l, const struct netbsd32_kqueue1_args *uap,
2736 register_t *retval)
2737 {
2738 /* {
2739 syscallarg(int) flags;
2740 } */
2741 struct sys_kqueue1_args ua;
2742
2743 NETBSD32TO64_UAP(flags);
2744
2745 return sys_kqueue1(l, &ua, retval);
2746 }
2747
2748 int
2749 netbsd32_paccept(struct lwp *l, const struct netbsd32_paccept_args *uap,
2750 register_t *retval)
2751 {
2752 /* {
2753 syscallarg(int) s;
2754 syscallarg(netbsd32_sockaddrp_t) name;
2755 syscallarg(netbsd32_socklenp_t) anamelen;
2756 syscallarg(const netbsd32_sigsetp_t) mask;
2757 syscallarg(int) flags;
2758 } */
2759 struct sys_paccept_args ua;
2760
2761 NETBSD32TO64_UAP(s);
2762 NETBSD32TOP_UAP(name, struct sockaddr *);
2763 NETBSD32TOP_UAP(anamelen, socklen_t *);
2764 NETBSD32TOP_UAP(mask, const sigset_t *);
2765 NETBSD32TO64_UAP(flags);
2766
2767 return sys_paccept(l, &ua, retval);
2768 }
2769
2770 int
2771 netbsd32_fdiscard(struct lwp *l, const struct netbsd32_fdiscard_args *uap,
2772 register_t *retval)
2773 {
2774 /* {
2775 syscallarg(int) fd;
2776 syscallarg(netbsd32_off_t) pos;
2777 syscallarg(netbsd32_off_t) len;
2778 } */
2779 struct sys_fdiscard_args ua;
2780
2781 NETBSD32TO64_UAP(fd);
2782 NETBSD32TO64_UAP(pos);
2783 NETBSD32TO64_UAP(len);
2784
2785 return sys_fdiscard(l, &ua, retval);
2786 }
2787
2788 int
2789 netbsd32_posix_fallocate(struct lwp *l, const struct netbsd32_posix_fallocate_args *uap,
2790 register_t *retval)
2791 {
2792 /* {
2793 syscallarg(int) fd;
2794 syscallarg(netbsd32_off_t) pos;
2795 syscallarg(netbsd32_off_t) len;
2796 } */
2797 struct sys_posix_fallocate_args ua;
2798
2799 NETBSD32TO64_UAP(fd);
2800 NETBSD32TO64_UAP(pos);
2801 NETBSD32TO64_UAP(len);
2802
2803 return sys_posix_fallocate(l, &ua, retval);
2804 }
2805
2806 int
2807 netbsd32_pset_create(struct lwp *l,
2808 const struct netbsd32_pset_create_args *uap, register_t *retval)
2809 {
2810 /* {
2811 syscallarg(netbsd32_psetidp_t) psid;
2812 }; */
2813
2814 return sys_pset_create(l, (const void *)uap, retval);
2815 }
2816
2817 int
2818 netbsd32_pset_destroy(struct lwp *l,
2819 const struct netbsd32_pset_destroy_args *uap, register_t *retval)
2820 {
2821 /* {
2822 syscallarg(psetid_t) psid;
2823 }; */
2824
2825 return sys_pset_destroy(l, (const void *)uap, retval);
2826 }
2827
2828 int
2829 netbsd32_pset_assign(struct lwp *l,
2830 const struct netbsd32_pset_assign_args *uap, register_t *retval)
2831 {
2832 /* {
2833 syscallarg(psetid_t) psid;
2834 syscallarg(cpuid_t) cpuid;
2835 syscallarg(netbsd32_psetidp_t) opsid;
2836 }; */
2837 struct sys_pset_assign_args ua;
2838
2839 SCARG(&ua, psid) = SCARG(uap, psid);
2840 NETBSD32TO64_UAP(cpuid);
2841 NETBSD32TOP_UAP(opsid, psetid_t);
2842
2843 return sys_pset_assign(l, &ua, retval);
2844 }
2845
2846 int
2847 netbsd32__pset_bind(struct lwp *l,
2848 const struct netbsd32__pset_bind_args *uap, register_t *retval)
2849 {
2850 /* {
2851 syscallarg(idtype_t) idtype;
2852 syscallarg(id_t) first_id;
2853 syscallarg(id_t) second_id;
2854 syscallarg(psetid_t) psid;
2855 syscallarg(netbsd32_psetidp_t) opsid;
2856 }; */
2857 struct sys__pset_bind_args ua;
2858
2859 SCARG(&ua, idtype) = SCARG(uap, idtype);
2860 SCARG(&ua, first_id) = SCARG(uap, first_id);
2861 SCARG(&ua, second_id) = SCARG(uap, second_id);
2862 SCARG(&ua, psid) = SCARG(uap, psid);
2863 NETBSD32TOP_UAP(opsid, psetid_t);
2864
2865 return sys__pset_bind(l, &ua, retval);
2866 }
2867
2868
2869 /*
2870 * MI indirect system call support.
2871 * Only used if the MD netbsd32_syscall.c doesn't intercept the calls.
2872 */
2873
2874 #define NETBSD32_SYSCALL
2875 #undef SYS_NSYSENT
2876 #define SYS_NSYSENT NETBSD32_SYS_NSYSENT
2877
2878 #define SYS_SYSCALL netbsd32_syscall
2879 #include "../../kern/sys_syscall.c"
2880 #undef SYS_SYSCALL
2881
2882 #define SYS_SYSCALL netbsd32____syscall
2883 #include "../../kern/sys_syscall.c"
2884 #undef SYS_SYSCALL
2885