netbsd32_netbsd.c revision 1.165 1 /* $NetBSD: netbsd32_netbsd.c,v 1.165 2010/03/02 16:08:15 pooka 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.165 2010/03/02 16:08:15 pooka 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_nfssvc(struct lwp *l, const struct netbsd32_nfssvc_args *uap, register_t *retval)
1208 {
1209 #if 0
1210 /* {
1211 syscallarg(int) flag;
1212 syscallarg(netbsd32_voidp) argp;
1213 } */
1214 struct sys_nfssvc_args ua;
1215
1216 NETBSD32TO64_UAP(flag);
1217 NETBSD32TOP_UAP(argp, void);
1218 return (sys_nfssvc(l, &ua, retval));
1219 #else
1220 /* Why would we want to support a 32-bit nfsd? */
1221 return (ENOSYS);
1222 #endif
1223 }
1224
1225 int
1226 netbsd32___getfh30(struct lwp *l, const struct netbsd32___getfh30_args *uap, register_t *retval)
1227 {
1228 /* {
1229 syscallarg(const netbsd32_charp) fname;
1230 syscallarg(netbsd32_fhandlep_t) fhp;
1231 syscallarg(netbsd32_size_tp) fh_size;
1232 } */
1233 struct vnode *vp;
1234 fhandle_t *fh;
1235 int error;
1236 struct nameidata nd;
1237 netbsd32_size_t sz32;
1238 size_t sz;
1239
1240 /*
1241 * Must be super user
1242 */
1243 error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FILEHANDLE,
1244 0, NULL, NULL, NULL);
1245 if (error)
1246 return (error);
1247 fh = NULL;
1248 NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | TRYEMULROOT, UIO_USERSPACE,
1249 SCARG_P32(uap, fname));
1250 error = namei(&nd);
1251 if (error)
1252 return (error);
1253 vp = nd.ni_vp;
1254 error = copyin(SCARG_P32(uap, fh_size), &sz32,
1255 sizeof(netbsd32_size_t));
1256 if (!error) {
1257 fh = malloc(sz32, M_TEMP, M_WAITOK);
1258 if (fh == NULL)
1259 return EINVAL;
1260 sz = sz32;
1261 error = vfs_composefh(vp, fh, &sz);
1262 sz32 = sz;
1263 }
1264 vput(vp);
1265 if (error == E2BIG)
1266 copyout(&sz, SCARG_P32(uap, fh_size), sizeof(size_t));
1267 if (error == 0) {
1268 error = copyout(&sz32, SCARG_P32(uap, fh_size),
1269 sizeof(netbsd32_size_t));
1270 if (!error)
1271 error = copyout(fh, SCARG_P32(uap, fhp), sz);
1272 }
1273 free(fh, M_TEMP);
1274 return (error);
1275 }
1276
1277 int
1278 netbsd32_pread(struct lwp *l, const struct netbsd32_pread_args *uap, register_t *retval)
1279 {
1280 /* {
1281 syscallarg(int) fd;
1282 syscallarg(netbsd32_voidp) buf;
1283 syscallarg(netbsd32_size_t) nbyte;
1284 syscallarg(int) PAD;
1285 syscallarg(off_t) offset;
1286 } */
1287 struct sys_pread_args ua;
1288
1289 NETBSD32TO64_UAP(fd);
1290 NETBSD32TOP_UAP(buf, void);
1291 NETBSD32TOX_UAP(nbyte, size_t);
1292 NETBSD32TO64_UAP(PAD);
1293 NETBSD32TO64_UAP(offset);
1294 return sys_pread(l, &ua, retval);
1295 }
1296
1297 int
1298 netbsd32_pwrite(struct lwp *l, const struct netbsd32_pwrite_args *uap, register_t *retval)
1299 {
1300 /* {
1301 syscallarg(int) fd;
1302 syscallarg(const netbsd32_voidp) buf;
1303 syscallarg(netbsd32_size_t) nbyte;
1304 syscallarg(int) PAD;
1305 syscallarg(off_t) offset;
1306 } */
1307 struct sys_pwrite_args ua;
1308
1309 NETBSD32TO64_UAP(fd);
1310 NETBSD32TOP_UAP(buf, void);
1311 NETBSD32TOX_UAP(nbyte, size_t);
1312 NETBSD32TO64_UAP(PAD);
1313 NETBSD32TO64_UAP(offset);
1314 return sys_pwrite(l, &ua, retval);
1315 }
1316
1317 int
1318 netbsd32_setgid(struct lwp *l, const struct netbsd32_setgid_args *uap, register_t *retval)
1319 {
1320 /* {
1321 syscallarg(gid_t) gid;
1322 } */
1323 struct sys_setgid_args ua;
1324
1325 NETBSD32TO64_UAP(gid);
1326 return (sys_setgid(l, &ua, retval));
1327 }
1328
1329 int
1330 netbsd32_setegid(struct lwp *l, const struct netbsd32_setegid_args *uap, register_t *retval)
1331 {
1332 /* {
1333 syscallarg(gid_t) egid;
1334 } */
1335 struct sys_setegid_args ua;
1336
1337 NETBSD32TO64_UAP(egid);
1338 return (sys_setegid(l, &ua, retval));
1339 }
1340
1341 int
1342 netbsd32_seteuid(struct lwp *l, const struct netbsd32_seteuid_args *uap, register_t *retval)
1343 {
1344 /* {
1345 syscallarg(gid_t) euid;
1346 } */
1347 struct sys_seteuid_args ua;
1348
1349 NETBSD32TO64_UAP(euid);
1350 return (sys_seteuid(l, &ua, retval));
1351 }
1352
1353 int
1354 netbsd32_pathconf(struct lwp *l, const struct netbsd32_pathconf_args *uap, register_t *retval)
1355 {
1356 /* {
1357 syscallarg(int) fd;
1358 syscallarg(int) name;
1359 } */
1360 struct sys_pathconf_args ua;
1361
1362 NETBSD32TOP_UAP(path, const char);
1363 NETBSD32TO64_UAP(name);
1364 return sys_pathconf(l, &ua, retval);
1365 }
1366
1367 int
1368 netbsd32_fpathconf(struct lwp *l, const struct netbsd32_fpathconf_args *uap, register_t *retval)
1369 {
1370 /* {
1371 syscallarg(int) fd;
1372 syscallarg(int) name;
1373 } */
1374 struct sys_fpathconf_args ua;
1375
1376 NETBSD32TO64_UAP(fd);
1377 NETBSD32TO64_UAP(name);
1378 return sys_fpathconf(l, &ua, retval);
1379 }
1380
1381 int
1382 netbsd32_getrlimit(struct lwp *l, const struct netbsd32_getrlimit_args *uap, register_t *retval)
1383 {
1384 /* {
1385 syscallarg(int) which;
1386 syscallarg(netbsd32_rlimitp_t) rlp;
1387 } */
1388 int which = SCARG(uap, which);
1389
1390 if ((u_int)which >= RLIM_NLIMITS)
1391 return (EINVAL);
1392 return (copyout(&l->l_proc->p_rlimit[which],
1393 SCARG_P32(uap, rlp), sizeof(struct rlimit)));
1394 }
1395
1396 int
1397 netbsd32_setrlimit(struct lwp *l, const struct netbsd32_setrlimit_args *uap, register_t *retval)
1398 {
1399 /* {
1400 syscallarg(int) which;
1401 syscallarg(const netbsd32_rlimitp_t) rlp;
1402 } */
1403 int which = SCARG(uap, which);
1404 struct rlimit alim;
1405 int error;
1406
1407 error = copyin(SCARG_P32(uap, rlp), &alim, sizeof(struct rlimit));
1408 if (error)
1409 return (error);
1410
1411 switch (which) {
1412 case RLIMIT_DATA:
1413 if (LIMITCHECK(alim.rlim_cur, MAXDSIZ32))
1414 alim.rlim_cur = MAXDSIZ32;
1415 if (LIMITCHECK(alim.rlim_max, MAXDSIZ32))
1416 alim.rlim_max = MAXDSIZ32;
1417 break;
1418
1419 case RLIMIT_STACK:
1420 if (LIMITCHECK(alim.rlim_cur, MAXSSIZ32))
1421 alim.rlim_cur = MAXSSIZ32;
1422 if (LIMITCHECK(alim.rlim_max, MAXSSIZ32))
1423 alim.rlim_max = MAXSSIZ32;
1424 default:
1425 break;
1426 }
1427
1428 return (dosetrlimit(l, l->l_proc, which, &alim));
1429 }
1430
1431 int
1432 netbsd32_mmap(struct lwp *l, const struct netbsd32_mmap_args *uap, register_t *retval)
1433 {
1434 /* {
1435 syscallarg(netbsd32_voidp) addr;
1436 syscallarg(netbsd32_size_t) len;
1437 syscallarg(int) prot;
1438 syscallarg(int) flags;
1439 syscallarg(int) fd;
1440 syscallarg(netbsd32_long) PAD;
1441 syscallarg(off_t) pos;
1442 } */
1443 struct sys_mmap_args ua;
1444 int error;
1445
1446 NETBSD32TOP_UAP(addr, void);
1447 NETBSD32TOX_UAP(len, size_t);
1448 NETBSD32TO64_UAP(prot);
1449 NETBSD32TO64_UAP(flags);
1450 NETBSD32TO64_UAP(fd);
1451 NETBSD32TOX_UAP(PAD, long);
1452 NETBSD32TOX_UAP(pos, off_t);
1453 error = sys_mmap(l, &ua, retval);
1454 if ((u_long)*retval > (u_long)UINT_MAX) {
1455 printf("netbsd32_mmap: retval out of range: 0x%lx",
1456 (u_long)*retval);
1457 /* Should try to recover and return an error here. */
1458 }
1459 return (error);
1460 }
1461
1462 int
1463 netbsd32_mremap(struct lwp *l, const struct netbsd32_mremap_args *uap, register_t *retval)
1464 {
1465 /* {
1466 syscallarg(void *) old_address;
1467 syscallarg(size_t) old_size;
1468 syscallarg(void *) new_address;
1469 syscallarg(size_t) new_size;
1470 syscallarg(int) flags;
1471 } */
1472 struct sys_mremap_args ua;
1473
1474 NETBSD32TOP_UAP(old_address, void);
1475 NETBSD32TOX_UAP(old_size, size_t);
1476 NETBSD32TOP_UAP(new_address, void);
1477 NETBSD32TOX_UAP(new_size, size_t);
1478 NETBSD32TO64_UAP(flags);
1479
1480 return sys_mremap(l, &ua, retval);
1481 }
1482
1483 int
1484 netbsd32_lseek(struct lwp *l, const struct netbsd32_lseek_args *uap, register_t *retval)
1485 {
1486 /* {
1487 syscallarg(int) fd;
1488 syscallarg(int) PAD;
1489 syscallarg(off_t) offset;
1490 syscallarg(int) whence;
1491 } */
1492 struct sys_lseek_args ua;
1493 union {
1494 register_t retval64[2];
1495 register32_t retval32[4];
1496 } newpos;
1497 int rv;
1498
1499 NETBSD32TO64_UAP(fd);
1500 NETBSD32TO64_UAP(PAD);
1501 NETBSD32TO64_UAP(offset);
1502 NETBSD32TO64_UAP(whence);
1503 rv = sys_lseek(l, &ua, newpos.retval64);
1504
1505 /*
1506 * We have to split the 64 bit value into 2 halves which will
1507 * end up in separate 32 bit registers.
1508 * This should DTRT on big and little-endian systems provided that
1509 * gcc's 'strict aliasing' tests don't decide that the retval32[]
1510 * entries can't have been assigned to, so need not be read!
1511 */
1512 retval[0] = newpos.retval32[0];
1513 retval[1] = newpos.retval32[1];
1514
1515 return rv;
1516 }
1517
1518 int
1519 netbsd32_truncate(struct lwp *l, const struct netbsd32_truncate_args *uap, register_t *retval)
1520 {
1521 /* {
1522 syscallarg(const netbsd32_charp) path;
1523 syscallarg(int) PAD;
1524 syscallarg(off_t) length;
1525 } */
1526 struct sys_truncate_args ua;
1527
1528 NETBSD32TOP_UAP(path, const char);
1529 NETBSD32TO64_UAP(PAD);
1530 NETBSD32TO64_UAP(length);
1531 return (sys_truncate(l, &ua, retval));
1532 }
1533
1534 int
1535 netbsd32_ftruncate(struct lwp *l, const struct netbsd32_ftruncate_args *uap, register_t *retval)
1536 {
1537 /* {
1538 syscallarg(int) fd;
1539 syscallarg(int) PAD;
1540 syscallarg(off_t) length;
1541 } */
1542 struct sys_ftruncate_args ua;
1543
1544 NETBSD32TO64_UAP(fd);
1545 NETBSD32TO64_UAP(PAD);
1546 NETBSD32TO64_UAP(length);
1547 return (sys_ftruncate(l, &ua, retval));
1548 }
1549
1550 int
1551 netbsd32_mlock(struct lwp *l, const struct netbsd32_mlock_args *uap, register_t *retval)
1552 {
1553 /* {
1554 syscallarg(const netbsd32_voidp) addr;
1555 syscallarg(netbsd32_size_t) len;
1556 } */
1557 struct sys_mlock_args ua;
1558
1559 NETBSD32TOP_UAP(addr, const void);
1560 NETBSD32TO64_UAP(len);
1561 return (sys_mlock(l, &ua, retval));
1562 }
1563
1564 int
1565 netbsd32_munlock(struct lwp *l, const struct netbsd32_munlock_args *uap, register_t *retval)
1566 {
1567 /* {
1568 syscallarg(const netbsd32_voidp) addr;
1569 syscallarg(netbsd32_size_t) len;
1570 } */
1571 struct sys_munlock_args ua;
1572
1573 NETBSD32TOP_UAP(addr, const void);
1574 NETBSD32TO64_UAP(len);
1575 return (sys_munlock(l, &ua, retval));
1576 }
1577
1578 int
1579 netbsd32_undelete(struct lwp *l, const struct netbsd32_undelete_args *uap, register_t *retval)
1580 {
1581 /* {
1582 syscallarg(const netbsd32_charp) path;
1583 } */
1584 struct sys_undelete_args ua;
1585
1586 NETBSD32TOP_UAP(path, const char);
1587 return (sys_undelete(l, &ua, retval));
1588 }
1589
1590 int
1591 netbsd32_getpgid(struct lwp *l, const struct netbsd32_getpgid_args *uap, register_t *retval)
1592 {
1593 /* {
1594 syscallarg(pid_t) pid;
1595 } */
1596 struct sys_getpgid_args ua;
1597
1598 NETBSD32TO64_UAP(pid);
1599 return (sys_getpgid(l, &ua, retval));
1600 }
1601
1602 int
1603 netbsd32_reboot(struct lwp *l, const struct netbsd32_reboot_args *uap, register_t *retval)
1604 {
1605 /* {
1606 syscallarg(int) opt;
1607 syscallarg(netbsd32_charp) bootstr;
1608 } */
1609 struct sys_reboot_args ua;
1610
1611 NETBSD32TO64_UAP(opt);
1612 NETBSD32TOP_UAP(bootstr, char);
1613 return (sys_reboot(l, &ua, retval));
1614 }
1615
1616 #include <sys/poll.h>
1617 int
1618 netbsd32_poll(struct lwp *l, const struct netbsd32_poll_args *uap, register_t *retval)
1619 {
1620 /* {
1621 syscallarg(netbsd32_pollfdp_t) fds;
1622 syscallarg(u_int) nfds;
1623 syscallarg(int) timeout;
1624 } */
1625 struct sys_poll_args ua;
1626
1627 NETBSD32TOP_UAP(fds, struct pollfd);
1628 NETBSD32TO64_UAP(nfds);
1629 NETBSD32TO64_UAP(timeout);
1630
1631 return (sys_poll(l, &ua, retval));
1632 }
1633
1634 int
1635 netbsd32_fdatasync(struct lwp *l, const struct netbsd32_fdatasync_args *uap, register_t *retval)
1636 {
1637 /* {
1638 syscallarg(int) fd;
1639 } */
1640 struct sys_fdatasync_args ua;
1641
1642 NETBSD32TO64_UAP(fd);
1643 return (sys_fdatasync(l, &ua, retval));
1644 }
1645
1646 int
1647 netbsd32___posix_rename(struct lwp *l, const struct netbsd32___posix_rename_args *uap, register_t *retval)
1648 {
1649 /* {
1650 syscallarg(const netbsd32_charp) from;
1651 syscallarg(const netbsd32_charp) to;
1652 } */
1653 struct sys___posix_rename_args ua;
1654
1655 NETBSD32TOP_UAP(from, const char);
1656 NETBSD32TOP_UAP(to, const char);
1657 return (sys___posix_rename(l, &ua, retval));
1658 }
1659
1660 int
1661 netbsd32_swapctl(struct lwp *l, const struct netbsd32_swapctl_args *uap, register_t *retval)
1662 {
1663 /* {
1664 syscallarg(int) cmd;
1665 syscallarg(const netbsd32_voidp) arg;
1666 syscallarg(int) misc;
1667 } */
1668 struct sys_swapctl_args ua;
1669
1670 NETBSD32TO64_UAP(cmd);
1671 NETBSD32TOP_UAP(arg, void);
1672 NETBSD32TO64_UAP(misc);
1673 return (sys_swapctl(l, &ua, retval));
1674 }
1675
1676 int
1677 netbsd32_minherit(struct lwp *l, const struct netbsd32_minherit_args *uap, register_t *retval)
1678 {
1679 /* {
1680 syscallarg(netbsd32_voidp) addr;
1681 syscallarg(netbsd32_size_t) len;
1682 syscallarg(int) inherit;
1683 } */
1684 struct sys_minherit_args ua;
1685
1686 NETBSD32TOP_UAP(addr, void);
1687 NETBSD32TOX_UAP(len, size_t);
1688 NETBSD32TO64_UAP(inherit);
1689 return (sys_minherit(l, &ua, retval));
1690 }
1691
1692 int
1693 netbsd32_lchmod(struct lwp *l, const struct netbsd32_lchmod_args *uap, register_t *retval)
1694 {
1695 /* {
1696 syscallarg(const netbsd32_charp) path;
1697 syscallarg(mode_t) mode;
1698 } */
1699 struct sys_lchmod_args ua;
1700
1701 NETBSD32TOP_UAP(path, const char);
1702 NETBSD32TO64_UAP(mode);
1703 return (sys_lchmod(l, &ua, retval));
1704 }
1705
1706 int
1707 netbsd32_lchown(struct lwp *l, const struct netbsd32_lchown_args *uap, register_t *retval)
1708 {
1709 /* {
1710 syscallarg(const netbsd32_charp) path;
1711 syscallarg(uid_t) uid;
1712 syscallarg(gid_t) gid;
1713 } */
1714 struct sys_lchown_args ua;
1715
1716 NETBSD32TOP_UAP(path, const char);
1717 NETBSD32TO64_UAP(uid);
1718 NETBSD32TO64_UAP(gid);
1719 return (sys_lchown(l, &ua, retval));
1720 }
1721
1722 int
1723 netbsd32___msync13(struct lwp *l, const struct netbsd32___msync13_args *uap, register_t *retval)
1724 {
1725 /* {
1726 syscallarg(netbsd32_voidp) addr;
1727 syscallarg(netbsd32_size_t) len;
1728 syscallarg(int) flags;
1729 } */
1730 struct sys___msync13_args ua;
1731
1732 NETBSD32TOP_UAP(addr, void);
1733 NETBSD32TOX_UAP(len, size_t);
1734 NETBSD32TO64_UAP(flags);
1735 return (sys___msync13(l, &ua, retval));
1736 }
1737
1738 int
1739 netbsd32___posix_chown(struct lwp *l, const struct netbsd32___posix_chown_args *uap, register_t *retval)
1740 {
1741 /* {
1742 syscallarg(const netbsd32_charp) path;
1743 syscallarg(uid_t) uid;
1744 syscallarg(gid_t) gid;
1745 } */
1746 struct sys___posix_chown_args ua;
1747
1748 NETBSD32TOP_UAP(path, const char);
1749 NETBSD32TO64_UAP(uid);
1750 NETBSD32TO64_UAP(gid);
1751 return (sys___posix_chown(l, &ua, retval));
1752 }
1753
1754 int
1755 netbsd32___posix_fchown(struct lwp *l, const struct netbsd32___posix_fchown_args *uap, register_t *retval)
1756 {
1757 /* {
1758 syscallarg(int) fd;
1759 syscallarg(uid_t) uid;
1760 syscallarg(gid_t) gid;
1761 } */
1762 struct sys___posix_fchown_args ua;
1763
1764 NETBSD32TO64_UAP(fd);
1765 NETBSD32TO64_UAP(uid);
1766 NETBSD32TO64_UAP(gid);
1767 return (sys___posix_fchown(l, &ua, retval));
1768 }
1769
1770 int
1771 netbsd32___posix_lchown(struct lwp *l, const struct netbsd32___posix_lchown_args *uap, register_t *retval)
1772 {
1773 /* {
1774 syscallarg(const netbsd32_charp) path;
1775 syscallarg(uid_t) uid;
1776 syscallarg(gid_t) gid;
1777 } */
1778 struct sys___posix_lchown_args ua;
1779
1780 NETBSD32TOP_UAP(path, const char);
1781 NETBSD32TO64_UAP(uid);
1782 NETBSD32TO64_UAP(gid);
1783 return (sys___posix_lchown(l, &ua, retval));
1784 }
1785
1786 int
1787 netbsd32_getsid(struct lwp *l, const struct netbsd32_getsid_args *uap, register_t *retval)
1788 {
1789 /* {
1790 syscallarg(pid_t) pid;
1791 } */
1792 struct sys_getsid_args ua;
1793
1794 NETBSD32TO64_UAP(pid);
1795 return (sys_getsid(l, &ua, retval));
1796 }
1797
1798 int
1799 netbsd32_fktrace(struct lwp *l, const struct netbsd32_fktrace_args *uap, register_t *retval)
1800 {
1801 /* {
1802 syscallarg(int) fd;
1803 syscallarg(int) ops;
1804 syscallarg(int) facs;
1805 syscallarg(int) pid;
1806 } */
1807 struct sys_fktrace_args ua;
1808
1809 NETBSD32TOX_UAP(fd, int);
1810 NETBSD32TO64_UAP(ops);
1811 NETBSD32TO64_UAP(facs);
1812 NETBSD32TO64_UAP(pid);
1813 return (sys_fktrace(l, &ua, retval));
1814 }
1815
1816 int
1817 netbsd32___sigpending14(struct lwp *l, const struct netbsd32___sigpending14_args *uap, register_t *retval)
1818 {
1819 /* {
1820 syscallarg(sigset_t *) set;
1821 } */
1822 struct sys___sigpending14_args ua;
1823
1824 NETBSD32TOP_UAP(set, sigset_t);
1825 return (sys___sigpending14(l, &ua, retval));
1826 }
1827
1828 int
1829 netbsd32___sigprocmask14(struct lwp *l, const struct netbsd32___sigprocmask14_args *uap, register_t *retval)
1830 {
1831 /* {
1832 syscallarg(int) how;
1833 syscallarg(const sigset_t *) set;
1834 syscallarg(sigset_t *) oset;
1835 } */
1836 struct sys___sigprocmask14_args ua;
1837
1838 NETBSD32TO64_UAP(how);
1839 NETBSD32TOP_UAP(set, sigset_t);
1840 NETBSD32TOP_UAP(oset, sigset_t);
1841 return (sys___sigprocmask14(l, &ua, retval));
1842 }
1843
1844 int
1845 netbsd32___sigsuspend14(struct lwp *l, const struct netbsd32___sigsuspend14_args *uap, register_t *retval)
1846 {
1847 /* {
1848 syscallarg(const sigset_t *) set;
1849 } */
1850 struct sys___sigsuspend14_args ua;
1851
1852 NETBSD32TOP_UAP(set, sigset_t);
1853 return (sys___sigsuspend14(l, &ua, retval));
1854 };
1855
1856 int
1857 netbsd32_fchroot(struct lwp *l, const struct netbsd32_fchroot_args *uap, register_t *retval)
1858 {
1859 /* {
1860 syscallarg(int) fd;
1861 } */
1862 struct sys_fchroot_args ua;
1863
1864 NETBSD32TO64_UAP(fd);
1865 return (sys_fchroot(l, &ua, retval));
1866 }
1867
1868 /*
1869 * Open a file given a file handle.
1870 *
1871 * Check permissions, allocate an open file structure,
1872 * and call the device open routine if any.
1873 */
1874 int
1875 netbsd32___fhopen40(struct lwp *l, const struct netbsd32___fhopen40_args *uap, register_t *retval)
1876 {
1877 /* {
1878 syscallarg(const netbsd32_pointer_t *) fhp;
1879 syscallarg(netbsd32_size_t) fh_size;
1880 syscallarg(int) flags;
1881 } */
1882 struct sys___fhopen40_args ua;
1883
1884 NETBSD32TOP_UAP(fhp, fhandle_t);
1885 NETBSD32TO64_UAP(fh_size);
1886 NETBSD32TO64_UAP(flags);
1887 return (sys___fhopen40(l, &ua, retval));
1888 }
1889
1890 /* virtual memory syscalls */
1891 int
1892 netbsd32_ovadvise(struct lwp *l, const struct netbsd32_ovadvise_args *uap, register_t *retval)
1893 {
1894 /* {
1895 syscallarg(int) anom;
1896 } */
1897 struct sys_ovadvise_args ua;
1898
1899 NETBSD32TO64_UAP(anom);
1900 return (sys_ovadvise(l, &ua, retval));
1901 }
1902
1903 void
1904 netbsd32_adjust_limits(struct proc *p)
1905 {
1906 static const struct {
1907 int id;
1908 rlim_t lim;
1909 } lm[] = {
1910 { RLIMIT_DATA, MAXDSIZ32 },
1911 { RLIMIT_STACK, MAXSSIZ32 },
1912 };
1913 size_t i;
1914 struct plimit *lim;
1915 struct rlimit *rlim;
1916
1917 /*
1918 * We can only reduce the current limits, we cannot stop external
1919 * processes from changing them (eg via sysctl) later on.
1920 * So there is no point trying to lock out such changes here.
1921 *
1922 * If we assume that rlim_cur/max are accessed using atomic
1923 * operations, we don't need to lock against any other updates
1924 * that might happen if the plimit structure is shared writable
1925 * between multiple processes.
1926 */
1927
1928 /* Scan to determine is any limits are out of range */
1929 lim = p->p_limit;
1930 for (i = 0; ; i++) {
1931 if (i >= __arraycount(lm))
1932 /* All in range */
1933 return;
1934 rlim = lim->pl_rlimit + lm[i].id;
1935 if (LIMITCHECK(rlim->rlim_cur, lm[i].lim))
1936 break;
1937 if (LIMITCHECK(rlim->rlim_max, lm[i].lim))
1938 break;
1939 }
1940
1941 lim_privatise(p, false);
1942
1943 lim = p->p_limit;
1944 for (i = 0; i < __arraycount(lm); i++) {
1945 rlim = lim->pl_rlimit + lm[i].id;
1946 if (LIMITCHECK(rlim->rlim_cur, lm[i].lim))
1947 rlim->rlim_cur = lm[i].lim;
1948 if (LIMITCHECK(rlim->rlim_max, lm[i].lim))
1949 rlim->rlim_max = lm[i].lim;
1950 }
1951 }
1952
1953 int
1954 netbsd32_uuidgen(struct lwp *l, const struct netbsd32_uuidgen_args *uap, register_t *retval)
1955 {
1956 /* {
1957 syscallarg(netbsd32_uuidp_t) store;
1958 syscallarg(int) count;
1959 } */
1960 struct sys_uuidgen_args ua;
1961
1962 NETBSD32TOP_UAP(store, struct uuid);
1963 NETBSD32TO64_UAP(count);
1964 return (sys_uuidgen(l, &ua, retval));
1965 }
1966
1967 int
1968 netbsd32_extattrctl(struct lwp *l, const struct netbsd32_extattrctl_args *uap, register_t *retval)
1969 {
1970 /* {
1971 syscallarg(const netbsd32_charp) path;
1972 syscallarg(int) cmd;
1973 syscallarg(const netbsd32_charp) filename;
1974 syscallarg(int) attrnamespace;
1975 syscallarg(const netbsd32_charp) attrname;
1976 } */
1977 struct sys_extattrctl_args ua;
1978
1979 NETBSD32TOP_UAP(path, const char);
1980 NETBSD32TO64_UAP(cmd);
1981 NETBSD32TOP_UAP(filename, const char);
1982 NETBSD32TO64_UAP(attrnamespace);
1983 NETBSD32TOP_UAP(attrname, const char);
1984 return sys_extattrctl(l, &ua, retval);
1985 }
1986
1987 int
1988 netbsd32_extattr_set_fd(struct lwp *l, const struct netbsd32_extattr_set_fd_args *uap, register_t *retval)
1989 {
1990 /* {
1991 syscallarg(int) fd;
1992 syscallarg(int) attrnamespace;
1993 syscallarg(const netbsd32_charp) attrname;
1994 syscallarg(const netbsd32_voidp) data;
1995 syscallarg(netbsd32_size_t) nbytes;
1996 } */
1997 struct sys_extattr_set_fd_args ua;
1998
1999 NETBSD32TO64_UAP(fd);
2000 NETBSD32TO64_UAP(attrnamespace);
2001 NETBSD32TOP_UAP(attrname, const char);
2002 NETBSD32TOP_UAP(data, const void);
2003 NETBSD32TOX_UAP(nbytes, size_t);
2004 return sys_extattr_set_fd(l, &ua, retval);
2005 }
2006
2007 int
2008 netbsd32_extattr_set_file(struct lwp *l, const struct netbsd32_extattr_set_file_args *uap, register_t *retval)
2009 {
2010 /* {
2011 syscallarg(const netbsd32_charp) path;
2012 syscallarg(int) attrnamespace;
2013 syscallarg(const netbsd32_charp) attrname;
2014 syscallarg(const netbsd32_voidp) data;
2015 syscallarg(netbsd32_size_t) nbytes;
2016 } */
2017 struct sys_extattr_set_file_args ua;
2018
2019 NETBSD32TOP_UAP(path, const char);
2020 NETBSD32TO64_UAP(attrnamespace);
2021 NETBSD32TOP_UAP(attrname, const char);
2022 NETBSD32TOP_UAP(data, const void);
2023 NETBSD32TOX_UAP(nbytes, size_t);
2024 return sys_extattr_set_file(l, &ua, retval);
2025 }
2026
2027 int
2028 netbsd32_extattr_set_link(struct lwp *l, const struct netbsd32_extattr_set_link_args *uap, register_t *retval)
2029 {
2030 /* {
2031 syscallarg(const netbsd32_charp) path;
2032 syscallarg(int) attrnamespace;
2033 syscallarg(const netbsd32_charp) attrname;
2034 syscallarg(const netbsd32_voidp) data;
2035 syscallarg(netbsd32_size_t) nbytes;
2036 } */
2037 struct sys_extattr_set_link_args ua;
2038
2039 NETBSD32TOP_UAP(path, const char);
2040 NETBSD32TO64_UAP(attrnamespace);
2041 NETBSD32TOP_UAP(attrname, const char);
2042 NETBSD32TOP_UAP(data, const void);
2043 NETBSD32TOX_UAP(nbytes, size_t);
2044 return sys_extattr_set_link(l, &ua, retval);
2045 }
2046
2047 int
2048 netbsd32_extattr_get_fd(struct lwp *l, const struct netbsd32_extattr_get_fd_args *uap, register_t *retval)
2049 {
2050 /* {
2051 syscallarg(int) fd;
2052 syscallarg(int) attrnamespace;
2053 syscallarg(const netbsd32_charp) attrname;
2054 syscallarg(netbsd32_voidp) data;
2055 syscallarg(netbsd32_size_t) nbytes;
2056 } */
2057 struct sys_extattr_get_fd_args ua;
2058
2059 NETBSD32TO64_UAP(fd);
2060 NETBSD32TO64_UAP(attrnamespace);
2061 NETBSD32TOP_UAP(attrname, const char);
2062 NETBSD32TOP_UAP(data, void);
2063 NETBSD32TOX_UAP(nbytes, size_t);
2064 return sys_extattr_get_fd(l, &ua, retval);
2065 }
2066
2067 int
2068 netbsd32_extattr_get_file(struct lwp *l, const struct netbsd32_extattr_get_file_args *uap, register_t *retval)
2069 {
2070 /* {
2071 syscallarg(const netbsd32_charp) path;
2072 syscallarg(int) attrnamespace;
2073 syscallarg(const netbsd32_charp) attrname;
2074 syscallarg(netbsd32_voidp) data;
2075 syscallarg(netbsd32_size_t) nbytes;
2076 } */
2077 struct sys_extattr_get_file_args ua;
2078
2079 NETBSD32TOP_UAP(path, const char);
2080 NETBSD32TO64_UAP(attrnamespace);
2081 NETBSD32TOP_UAP(attrname, const char);
2082 NETBSD32TOP_UAP(data, void);
2083 NETBSD32TOX_UAP(nbytes, size_t);
2084 return sys_extattr_get_file(l, &ua, retval);
2085 }
2086
2087 int
2088 netbsd32_extattr_get_link(struct lwp *l, const struct netbsd32_extattr_get_link_args *uap, register_t *retval)
2089 {
2090 /* {
2091 syscallarg(const netbsd32_charp) path;
2092 syscallarg(int) attrnamespace;
2093 syscallarg(const netbsd32_charp) attrname;
2094 syscallarg(netbsd32_voidp) data;
2095 syscallarg(netbsd32_size_t) nbytes;
2096 } */
2097 struct sys_extattr_get_link_args ua;
2098
2099 NETBSD32TOP_UAP(path, const char);
2100 NETBSD32TO64_UAP(attrnamespace);
2101 NETBSD32TOP_UAP(attrname, const char);
2102 NETBSD32TOP_UAP(data, void);
2103 NETBSD32TOX_UAP(nbytes, size_t);
2104 return sys_extattr_get_link(l, &ua, retval);
2105 }
2106
2107 int
2108 netbsd32_extattr_delete_fd(struct lwp *l, const struct netbsd32_extattr_delete_fd_args *uap, register_t *retval)
2109 {
2110 /* {
2111 syscallarg(int) fd;
2112 syscallarg(int) attrnamespace;
2113 syscallarg(const netbsd32_charp) attrname;
2114 } */
2115 struct sys_extattr_delete_fd_args ua;
2116
2117 NETBSD32TO64_UAP(fd);
2118 NETBSD32TO64_UAP(attrnamespace);
2119 NETBSD32TOP_UAP(attrname, const char);
2120 return sys_extattr_delete_fd(l, &ua, retval);
2121 }
2122
2123 int
2124 netbsd32_extattr_delete_file(struct lwp *l, const struct netbsd32_extattr_delete_file_args *uap, register_t *retval)
2125 {
2126 /* {
2127 syscallarg(const netbsd32_charp) path;
2128 syscallarg(int) attrnamespace;
2129 syscallarg(const netbsd32_charp) attrname;
2130 } */
2131 struct sys_extattr_delete_file_args ua;
2132
2133 NETBSD32TOP_UAP(path, const char);
2134 NETBSD32TO64_UAP(attrnamespace);
2135 NETBSD32TOP_UAP(attrname, const char);
2136 return sys_extattr_delete_file(l, &ua, retval);
2137 }
2138
2139 int
2140 netbsd32_extattr_delete_link(struct lwp *l, const struct netbsd32_extattr_delete_link_args *uap, register_t *retval)
2141 {
2142 /* {
2143 syscallarg(const netbsd32_charp) path;
2144 syscallarg(int) attrnamespace;
2145 syscallarg(const netbsd32_charp) attrname;
2146 } */
2147 struct sys_extattr_delete_link_args ua;
2148
2149 NETBSD32TOP_UAP(path, const char);
2150 NETBSD32TO64_UAP(attrnamespace);
2151 NETBSD32TOP_UAP(attrname, const char);
2152 return sys_extattr_delete_link(l, &ua, retval);
2153 }
2154
2155 int
2156 netbsd32_extattr_list_fd(struct lwp *l, const struct netbsd32_extattr_list_fd_args *uap, register_t *retval)
2157 {
2158 /* {
2159 syscallarg(int) fd;
2160 syscallarg(int) attrnamespace;
2161 syscallarg(netbsd32_voidp) data;
2162 syscallarg(netbsd32_size_t) nbytes;
2163 } */
2164 struct sys_extattr_list_fd_args ua;
2165
2166 NETBSD32TO64_UAP(fd);
2167 NETBSD32TO64_UAP(attrnamespace);
2168 NETBSD32TOP_UAP(data, void);
2169 NETBSD32TOX_UAP(nbytes, size_t);
2170 return sys_extattr_list_fd(l, &ua, retval);
2171 }
2172
2173 int
2174 netbsd32_extattr_list_file(struct lwp *l, const struct netbsd32_extattr_list_file_args *uap, register_t *retval)
2175 {
2176 /* {
2177 syscallarg(const netbsd32_charp) path;
2178 syscallarg(int) attrnamespace;
2179 syscallarg(netbsd32_voidp) data;
2180 syscallarg(netbsd32_size_t) nbytes;
2181 } */
2182 struct sys_extattr_list_file_args ua;
2183
2184 NETBSD32TOP_UAP(path, const char);
2185 NETBSD32TO64_UAP(attrnamespace);
2186 NETBSD32TOP_UAP(data, void);
2187 NETBSD32TOX_UAP(nbytes, size_t);
2188 return sys_extattr_list_file(l, &ua, retval);
2189 }
2190
2191 int
2192 netbsd32_extattr_list_link(struct lwp *l, const struct netbsd32_extattr_list_link_args *uap, register_t *retval)
2193 {
2194 /* {
2195 syscallarg(const netbsd32_charp) path;
2196 syscallarg(int) attrnamespace;
2197 syscallarg(netbsd32_voidp) data;
2198 syscallarg(netbsd32_size_t) nbytes;
2199 } */
2200 struct sys_extattr_list_link_args ua;
2201
2202 NETBSD32TOP_UAP(path, const char);
2203 NETBSD32TO64_UAP(attrnamespace);
2204 NETBSD32TOP_UAP(data, void);
2205 NETBSD32TOX_UAP(nbytes, size_t);
2206 return sys_extattr_list_link(l, &ua, retval);
2207 }
2208
2209 int
2210 netbsd32_mlockall(struct lwp *l, const struct netbsd32_mlockall_args *uap, register_t *retval)
2211 {
2212 /* {
2213 syscallarg(int) flags;
2214 } */
2215 struct sys_mlockall_args ua;
2216
2217 NETBSD32TO64_UAP(flags);
2218 return (sys_mlockall(l, &ua, retval));
2219 }
2220
2221 int
2222 netbsd32___clone(struct lwp *l, const struct netbsd32___clone_args *uap, register_t *retval)
2223 {
2224 /* {
2225 syscallarg(int) flags;
2226 syscallarg(netbsd32_voidp) stack;
2227 } */
2228 struct sys___clone_args ua;
2229
2230 NETBSD32TO64_UAP(flags);
2231 NETBSD32TOP_UAP(stack, void);
2232 return sys___clone(l, &ua, retval);
2233 }
2234
2235 int
2236 netbsd32_fsync_range(struct lwp *l, const struct netbsd32_fsync_range_args *uap, register_t *retval)
2237 {
2238 /* {
2239 syscallarg(int) fd;
2240 syscallarg(int) flags;
2241 syscallarg(off_t) start;
2242 syscallarg(off_t) length;
2243 } */
2244 struct sys_fsync_range_args ua;
2245
2246 NETBSD32TO64_UAP(fd);
2247 NETBSD32TO64_UAP(flags);
2248 NETBSD32TO64_UAP(start);
2249 NETBSD32TO64_UAP(length);
2250 return (sys_fsync_range(l, &ua, retval));
2251 }
2252
2253 int
2254 netbsd32_rasctl(struct lwp *l, const struct netbsd32_rasctl_args *uap, register_t *retval)
2255 {
2256 /* {
2257 syscallarg(netbsd32_voidp) addr;
2258 syscallarg(netbsd32_size_t) len;
2259 syscallarg(int) op;
2260 } */
2261 struct sys_rasctl_args ua;
2262
2263 NETBSD32TOP_UAP(addr, void *);
2264 NETBSD32TOX_UAP(len, size_t);
2265 NETBSD32TO64_UAP(op);
2266 return sys_rasctl(l, &ua, retval);
2267 }
2268
2269 int
2270 netbsd32_setxattr(struct lwp *l, const struct netbsd32_setxattr_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_setxattr_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_setxattr(l, &ua, retval);
2286 }
2287
2288 int
2289 netbsd32_lsetxattr(struct lwp *l, const struct netbsd32_lsetxattr_args *uap, register_t *retval)
2290 {
2291 /* {
2292 syscallarg(const netbsd32_charp) path;
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_lsetxattr_args ua;
2299 NETBSD32TOP_UAP(path, const char);
2300 NETBSD32TOP_UAP(name, const char);
2301 NETBSD32TOP_UAP(value, void);
2302 NETBSD32TOX_UAP(size, size_t);
2303 NETBSD32TO64_UAP(flags);
2304 return sys_lsetxattr(l, &ua, retval);
2305 }
2306
2307 int
2308 netbsd32_fsetxattr(struct lwp *l, const struct netbsd32_fsetxattr_args *uap, register_t *retval)
2309 {
2310 /* {
2311 syscallarg(int) fd;
2312 syscallarg(const netbsd32_charp) name;
2313 syscallarg(netbsd32_voidp) value;
2314 syscallarg(netbsd32_size_t) size;
2315 syscallarg(int) flags;
2316 } */
2317 struct sys_fsetxattr_args ua;
2318 NETBSD32TO64_UAP(fd);
2319 NETBSD32TOP_UAP(name, const char);
2320 NETBSD32TOP_UAP(value, void);
2321 NETBSD32TOX_UAP(size, size_t);
2322 NETBSD32TO64_UAP(flags);
2323 return sys_fsetxattr(l, &ua, retval);
2324 }
2325
2326 int
2327 netbsd32_getxattr(struct lwp *l, const struct netbsd32_getxattr_args *uap, register_t *retval)
2328 {
2329 /* {
2330 syscallarg(const netbsd32_charp) path;
2331 syscallarg(const netbsd32_charp) name;
2332 syscallarg(netbsd32_voidp) value;
2333 syscallarg(netbsd32_size_t) size;
2334 } */
2335 struct sys_getxattr_args ua;
2336 NETBSD32TOP_UAP(path, const char);
2337 NETBSD32TOP_UAP(name, const char);
2338 NETBSD32TOP_UAP(value, void);
2339 NETBSD32TOX_UAP(size, size_t);
2340 return sys_getxattr(l, &ua, retval);
2341 }
2342
2343 int
2344 netbsd32_lgetxattr(struct lwp *l, const struct netbsd32_lgetxattr_args *uap, register_t *retval)
2345 {
2346 /* {
2347 syscallarg(const netbsd32_charp) path;
2348 syscallarg(const netbsd32_charp) name;
2349 syscallarg(netbsd32_voidp) value;
2350 syscallarg(netbsd32_size_t) size;
2351 } */
2352 struct sys_lgetxattr_args ua;
2353 NETBSD32TOP_UAP(path, const char);
2354 NETBSD32TOP_UAP(name, const char);
2355 NETBSD32TOP_UAP(value, void);
2356 NETBSD32TOX_UAP(size, size_t);
2357 return sys_lgetxattr(l, &ua, retval);
2358 }
2359
2360 int
2361 netbsd32_fgetxattr(struct lwp *l, const struct netbsd32_fgetxattr_args *uap, register_t *retval)
2362 {
2363 /* {
2364 syscallarg(int) fd;
2365 syscallarg(const netbsd32_charp) name;
2366 syscallarg(netbsd32_voidp) value;
2367 syscallarg(netbsd32_size_t) size;
2368 } */
2369 struct sys_fgetxattr_args ua;
2370 NETBSD32TO64_UAP(fd);
2371 NETBSD32TOP_UAP(name, const char);
2372 NETBSD32TOP_UAP(value, void);
2373 NETBSD32TOX_UAP(size, size_t);
2374 return sys_fgetxattr(l, &ua, retval);
2375 }
2376
2377 int
2378 netbsd32_listxattr(struct lwp *l, const struct netbsd32_listxattr_args *uap, register_t *retval)
2379 {
2380 /* {
2381 syscallarg(const netbsd32_charp) path;
2382 syscallarg(netbsd32_charp) list;
2383 syscallarg(netbsd32_size_t) size;
2384 } */
2385 struct sys_listxattr_args ua;
2386 NETBSD32TOP_UAP(path, const char);
2387 NETBSD32TOP_UAP(list, char);
2388 NETBSD32TOX_UAP(size, size_t);
2389 return sys_listxattr(l, &ua, retval);
2390 }
2391
2392 int
2393 netbsd32_llistxattr(struct lwp *l, const struct netbsd32_llistxattr_args *uap, register_t *retval)
2394 {
2395 /* {
2396 syscallarg(const netbsd32_charp) path;
2397 syscallarg(netbsd32_charp) list;
2398 syscallarg(netbsd32_size_t) size;
2399 } */
2400 struct sys_llistxattr_args ua;
2401 NETBSD32TOP_UAP(path, const char);
2402 NETBSD32TOP_UAP(list, char);
2403 NETBSD32TOX_UAP(size, size_t);
2404 return sys_llistxattr(l, &ua, retval);
2405 }
2406
2407 int
2408 netbsd32_flistxattr(struct lwp *l, const struct netbsd32_flistxattr_args *uap, register_t *retval)
2409 {
2410 /* {
2411 syscallarg(int) fd;
2412 syscallarg(netbsd32_charp) list;
2413 syscallarg(netbsd32_size_t) size;
2414 } */
2415 struct sys_flistxattr_args ua;
2416 NETBSD32TO64_UAP(fd);
2417 NETBSD32TOP_UAP(list, char);
2418 NETBSD32TOX_UAP(size, size_t);
2419 return sys_flistxattr(l, &ua, retval);
2420 }
2421
2422 int
2423 netbsd32_removexattr(struct lwp *l, const struct netbsd32_removexattr_args *uap, register_t *retval)
2424 {
2425 /* {
2426 syscallarg(const netbsd32_charp) path;
2427 syscallarg(const netbsd32_charp) name;
2428 } */
2429 struct sys_removexattr_args ua;
2430 NETBSD32TOP_UAP(path, const char);
2431 NETBSD32TOP_UAP(name, const char);
2432 return sys_removexattr(l, &ua, retval);
2433 }
2434
2435 int
2436 netbsd32_lremovexattr(struct lwp *l, const struct netbsd32_lremovexattr_args *uap, register_t *retval)
2437 {
2438 /* {
2439 syscallarg(const netbsd32_charp) path;
2440 syscallarg(const netbsd32_charp) name;
2441 } */
2442 struct sys_lremovexattr_args ua;
2443 NETBSD32TOP_UAP(path, const char);
2444 NETBSD32TOP_UAP(name, const char);
2445 return sys_lremovexattr(l, &ua, retval);
2446 }
2447
2448 int
2449 netbsd32_fremovexattr(struct lwp *l, const struct netbsd32_fremovexattr_args *uap, register_t *retval)
2450 {
2451 /* {
2452 syscallarg(int) fd;
2453 syscallarg(const netbsd32_charp) name;
2454 } */
2455 struct sys_fremovexattr_args ua;
2456 NETBSD32TO64_UAP(fd);
2457 NETBSD32TOP_UAP(name, const char);
2458 return sys_fremovexattr(l, &ua, retval);
2459 }
2460
2461 int
2462 netbsd32___posix_fadvise50(struct lwp *l,
2463 const struct netbsd32___posix_fadvise50_args *uap, register_t *retval)
2464 {
2465 /* {
2466 syscallarg(int) fd;
2467 syscallarg(int) PAD;
2468 syscallarg(off_t) offset;
2469 syscallarg(off_t) len;
2470 syscallarg(int) advice;
2471 } */
2472
2473 *retval = do_posix_fadvise(SCARG(uap, fd), SCARG(uap, offset),
2474 SCARG(uap, len), SCARG(uap, advice));
2475
2476 return 0;
2477 }
2478
2479 int
2480 netbsd32__sched_setparam(struct lwp *l,
2481 const struct netbsd32__sched_setparam_args *uap,
2482 register_t *retval)
2483 {
2484 /* {
2485 syscallarg(pid_t) pid;
2486 syscallarg(lwpid_t) lid;
2487 syscallarg(int) policy;
2488 syscallarg(const netbsd32_sched_paramp_t) params;
2489 } */
2490 struct sys__sched_setparam_args ua;
2491
2492 NETBSD32TO64_UAP(pid);
2493 NETBSD32TO64_UAP(lid);
2494 NETBSD32TO64_UAP(policy);
2495 NETBSD32TOP_UAP(params, const struct sched_param *);
2496 return sys__sched_setparam(l, &ua, retval);
2497 }
2498
2499 int
2500 netbsd32__sched_getparam(struct lwp *l,
2501 const struct netbsd32__sched_getparam_args *uap,
2502 register_t *retval)
2503 {
2504 /* {
2505 syscallarg(pid_t) pid;
2506 syscallarg(lwpid_t) lid;
2507 syscallarg(netbsd32_intp) policy;
2508 syscallarg(netbsd32_sched_paramp_t) params;
2509 } */
2510 struct sys__sched_getparam_args ua;
2511
2512 NETBSD32TO64_UAP(pid);
2513 NETBSD32TO64_UAP(lid);
2514 NETBSD32TOP_UAP(policy, int *);
2515 NETBSD32TOP_UAP(params, struct sched_param *);
2516 return sys__sched_getparam(l, &ua, retval);
2517 }
2518
2519 int
2520 netbsd32__sched_setaffinity(struct lwp *l,
2521 const struct netbsd32__sched_setaffinity_args *uap,
2522 register_t *retval)
2523 {
2524 /* {
2525 syscallarg(pid_t) pid;
2526 syscallarg(lwpid_t) lid;
2527 syscallarg(netbsd_size_t) size;
2528 syscallarg(const netbsd32_cpusetp_t) cpuset;
2529 } */
2530 struct sys__sched_setaffinity_args ua;
2531
2532 NETBSD32TO64_UAP(pid);
2533 NETBSD32TO64_UAP(lid);
2534 NETBSD32TOX_UAP(size, size_t);
2535 NETBSD32TOP_UAP(cpuset, const cpuset_t *);
2536 return sys__sched_setaffinity(l, &ua, retval);
2537 }
2538
2539 int
2540 netbsd32__sched_getaffinity(struct lwp *l,
2541 const struct netbsd32__sched_getaffinity_args *uap,
2542 register_t *retval)
2543 {
2544 /* {
2545 syscallarg(pid_t) pid;
2546 syscallarg(lwpid_t) lid;
2547 syscallarg(netbsd_size_t) size;
2548 syscallarg(netbsd32_cpusetp_t) cpuset;
2549 } */
2550 struct sys__sched_getaffinity_args ua;
2551
2552 NETBSD32TO64_UAP(pid);
2553 NETBSD32TO64_UAP(lid);
2554 NETBSD32TOX_UAP(size, size_t);
2555 NETBSD32TOP_UAP(cpuset, cpuset_t *);
2556 return sys__sched_getaffinity(l, &ua, retval);
2557 }
2558
2559 /*
2560 * MI indirect system call support.
2561 * Only used if the MD netbsd32_syscall.c doesn't intercept the calls.
2562 */
2563
2564 #define NETBSD32_SYSCALL
2565 #undef SYS_NSYSENT
2566 #define SYS_NSYSENT NETBSD32_SYS_NSYSENT
2567
2568 #define SYS_SYSCALL netbsd32_syscall
2569 #include "../../kern/sys_syscall.c"
2570 #undef SYS_SYSCALL
2571
2572 #define SYS_SYSCALL netbsd32____syscall
2573 #include "../../kern/sys_syscall.c"
2574 #undef SYS_SYSCALL
2575