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