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