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