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