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