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