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