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