netbsd32_netbsd.c revision 1.132.2.1 1 /* $NetBSD: netbsd32_netbsd.c,v 1.132.2.1 2007/12/11 15:22:22 yamt 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.132.2.1 2007/12/11 15:22:22 yamt 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, void *v, register_t *retval)
176 {
177 struct netbsd32_exit_args /* {
178 syscallarg(int) rval;
179 } */ *uap = v;
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, void *v, register_t *retval)
188 {
189 struct netbsd32_read_args /* {
190 syscallarg(int) fd;
191 syscallarg(netbsd32_voidp) buf;
192 syscallarg(netbsd32_size_t) nbyte;
193 } */ *uap = v;
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, void *v, register_t *retval)
204 {
205 struct netbsd32_write_args /* {
206 syscallarg(int) fd;
207 syscallarg(const netbsd32_voidp) buf;
208 syscallarg(netbsd32_size_t) nbyte;
209 } */ *uap = v;
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, void *v, register_t *retval)
220 {
221 struct netbsd32_close_args /* {
222 syscallarg(int) fd;
223 } */ *uap = v;
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, void *v, register_t *retval)
232 {
233 struct netbsd32_open_args /* {
234 syscallarg(const netbsd32_charp) path;
235 syscallarg(int) flags;
236 syscallarg(mode_t) mode;
237 } */ *uap = v;
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, void *v, register_t *retval)
249 {
250 struct netbsd32_link_args /* {
251 syscallarg(const netbsd32_charp) path;
252 syscallarg(const netbsd32_charp) link;
253 } */ *uap = v;
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, void *v, register_t *retval)
263 {
264 struct netbsd32_unlink_args /* {
265 syscallarg(const netbsd32_charp) path;
266 } */ *uap = v;
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, void *v, register_t *retval)
276 {
277 struct netbsd32_chdir_args /* {
278 syscallarg(const netbsd32_charp) path;
279 } */ *uap = v;
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, void *v, register_t *retval)
289 {
290 struct netbsd32_fchdir_args /* {
291 syscallarg(int) fd;
292 } */ *uap = v;
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, void *v, register_t *retval)
302 {
303 struct netbsd32_mknod_args /* {
304 syscallarg(const netbsd32_charp) path;
305 syscallarg(mode_t) mode;
306 syscallarg(dev_t) dev;
307 } */ *uap = v;
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, void *v, register_t *retval)
319 {
320 struct netbsd32_chmod_args /* {
321 syscallarg(const netbsd32_charp) path;
322 syscallarg(mode_t) mode;
323 } */ *uap = v;
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, void *v, register_t *retval)
334 {
335 struct netbsd32_chown_args /* {
336 syscallarg(const netbsd32_charp) path;
337 syscallarg(uid_t) uid;
338 syscallarg(gid_t) gid;
339 } */ *uap = v;
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, void *v, register_t *retval)
351 {
352 struct netbsd32_break_args /* {
353 syscallarg(netbsd32_charp) nsize;
354 } */ *uap = v;
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, void *v, register_t *retval)
364 {
365 struct netbsd32_mount_args /* {
366 syscallarg(const netbsd32_charp) type;
367 syscallarg(const netbsd32_charp) path;
368 syscallarg(int) flags;
369 syscallarg(netbsd32_voidp) data;
370 } */ *uap = v;
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, void *v, register_t *retval)
382 {
383 struct netbsd32_unmount_args /* {
384 syscallarg(const netbsd32_charp) path;
385 syscallarg(int) flags;
386 } */ *uap = v;
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, void *v, register_t *retval)
396 {
397 struct netbsd32_setuid_args /* {
398 syscallarg(uid_t) uid;
399 } */ *uap = v;
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, void *v, register_t *retval)
408 {
409 #if defined(PTRACE) || defined(_LKM)
410 struct netbsd32_ptrace_args /* {
411 syscallarg(int) req;
412 syscallarg(pid_t) pid;
413 syscallarg(netbsd32_caddr_t) addr;
414 syscallarg(int) data;
415 } */ *uap = v;
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, void *v, register_t *retval)
434 {
435 struct netbsd32_accept_args /* {
436 syscallarg(int) s;
437 syscallarg(netbsd32_sockaddrp_t) name;
438 syscallarg(netbsd32_intp) anamelen;
439 } */ *uap = v;
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, void *v, register_t *retval)
450 {
451 struct netbsd32_getpeername_args /* {
452 syscallarg(int) fdes;
453 syscallarg(netbsd32_sockaddrp_t) asa;
454 syscallarg(netbsd32_intp) alen;
455 } */ *uap = v;
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, void *v, register_t *retval)
467 {
468 struct netbsd32_getsockname_args /* {
469 syscallarg(int) fdes;
470 syscallarg(netbsd32_sockaddrp_t) asa;
471 syscallarg(netbsd32_intp) alen;
472 } */ *uap = v;
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, void *v, register_t *retval)
483 {
484 struct netbsd32_access_args /* {
485 syscallarg(const netbsd32_charp) path;
486 syscallarg(int) flags;
487 } */ *uap = v;
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, void *v, register_t *retval)
498 {
499 struct netbsd32_chflags_args /* {
500 syscallarg(const netbsd32_charp) path;
501 syscallarg(netbsd32_u_long) flags;
502 } */ *uap = v;
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, void *v, register_t *retval)
513 {
514 struct netbsd32_fchflags_args /* {
515 syscallarg(int) fd;
516 syscallarg(netbsd32_u_long) flags;
517 } */ *uap = v;
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, void *v, register_t *retval)
528 {
529 struct netbsd32_lchflags_args /* {
530 syscallarg(const char *) path;
531 syscallarg(netbsd32_u_long) flags;
532 } */ *uap = v;
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, void *v, register_t *retval)
543 {
544 struct netbsd32_kill_args /* {
545 syscallarg(int) pid;
546 syscallarg(int) signum;
547 } */ *uap = v;
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, void *v, register_t *retval)
558 {
559 struct netbsd32_dup_args /* {
560 syscallarg(int) fd;
561 } */ *uap = v;
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, void *v, register_t *retval)
571 {
572 struct netbsd32_profil_args /* {
573 syscallarg(netbsd32_caddr_t) samples;
574 syscallarg(netbsd32_size_t) size;
575 syscallarg(netbsd32_u_long) offset;
576 syscallarg(u_int) scale;
577 } */ *uap = v;
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, void *v, register_t *retval)
589 {
590 struct netbsd32_ktrace_args /* {
591 syscallarg(const netbsd32_charp) fname;
592 syscallarg(int) ops;
593 syscallarg(int) facs;
594 syscallarg(int) pid;
595 } */ *uap = v;
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, void *v, register_t *retval)
607 {
608 struct netbsd32_utrace_args /* {
609 syscallarg(const netbsd32_charp) label;
610 syscallarg(netbsd32_voidp) addr;
611 syscallarg(netbsd32_size_t) len;
612 } */ *uap = v;
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, void *v, register_t *retval)
623 {
624 struct netbsd32___getlogin_args /* {
625 syscallarg(netbsd32_charp) namebuf;
626 syscallarg(u_int) namelen;
627 } */ *uap = v;
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, void *v, register_t *retval)
637 {
638 struct netbsd32_setlogin_args /* {
639 syscallarg(const netbsd32_charp) namebuf;
640 } */ *uap = v;
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, void *v, register_t *retval)
649 {
650 struct netbsd32_acct_args /* {
651 syscallarg(const netbsd32_charp) path;
652 } */ *uap = v;
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, void *v, register_t *retval)
661 {
662 struct netbsd32_revoke_args /* {
663 syscallarg(const netbsd32_charp) path;
664 } */ *uap = v;
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, void *v, register_t *retval)
674 {
675 struct netbsd32_symlink_args /* {
676 syscallarg(const netbsd32_charp) path;
677 syscallarg(const netbsd32_charp) link;
678 } */ *uap = v;
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, void *v, register_t *retval)
689 {
690 struct netbsd32_readlink_args /* {
691 syscallarg(const netbsd32_charp) path;
692 syscallarg(netbsd32_charp) buf;
693 syscallarg(netbsd32_size_t) count;
694 } */ *uap = v;
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, void *v, register_t *retval)
706 {
707 struct netbsd32_umask_args /* {
708 syscallarg(mode_t) newmask;
709 } */ *uap = v;
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, void *v, register_t *retval)
718 {
719 struct netbsd32_chroot_args /* {
720 syscallarg(const netbsd32_charp) path;
721 } */ *uap = v;
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, void *v, register_t *retval)
730 {
731 struct netbsd32_sbrk_args /* {
732 syscallarg(int) incr;
733 } */ *uap = v;
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, void *v, register_t *retval)
742 {
743 struct netbsd32_sstk_args /* {
744 syscallarg(int) incr;
745 } */ *uap = v;
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, void *v, register_t *retval)
754 {
755 struct netbsd32_munmap_args /* {
756 syscallarg(netbsd32_voidp) addr;
757 syscallarg(netbsd32_size_t) len;
758 } */ *uap = v;
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, void *v, register_t *retval)
768 {
769 struct netbsd32_mprotect_args /* {
770 syscallarg(netbsd32_voidp) addr;
771 syscallarg(netbsd32_size_t) len;
772 syscallarg(int) prot;
773 } */ *uap = v;
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, void *v, register_t *retval)
784 {
785 struct netbsd32_madvise_args /* {
786 syscallarg(netbsd32_voidp) addr;
787 syscallarg(netbsd32_size_t) len;
788 syscallarg(int) behav;
789 } */ *uap = v;
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, void *v, register_t *retval)
800 {
801 struct netbsd32_mincore_args /* {
802 syscallarg(netbsd32_caddr_t) addr;
803 syscallarg(netbsd32_size_t) len;
804 syscallarg(netbsd32_charp) vec;
805 } */ *uap = v;
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, void *v, register_t *retval)
817 {
818 struct netbsd32_getgroups_args /* {
819 syscallarg(int) gidsetsize;
820 syscallarg(netbsd32_gid_tp) gidset;
821 } */ *uap = v;
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, void *v, register_t *retval)
833 {
834 struct netbsd32_setgroups_args /* {
835 syscallarg(int) gidsetsize;
836 syscallarg(const netbsd32_gid_tp) gidset;
837 } */ *uap = v;
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, void *v, register_t *retval)
847 {
848 struct netbsd32_setpgid_args /* {
849 syscallarg(int) pid;
850 syscallarg(int) pgid;
851 } */ *uap = v;
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, void *v, register_t *retval)
861 {
862 struct netbsd32_fcntl_args /* {
863 syscallarg(int) fd;
864 syscallarg(int) cmd;
865 syscallarg(netbsd32_voidp) arg;
866 } */ *uap = v;
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, void *v, register_t *retval)
878 {
879 struct netbsd32_dup2_args /* {
880 syscallarg(int) from;
881 syscallarg(int) to;
882 } */ *uap = v;
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, void *v, register_t *retval)
892 {
893 struct netbsd32_fsync_args /* {
894 syscallarg(int) fd;
895 } */ *uap = v;
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, void *v, register_t *retval)
904 {
905 struct netbsd32_setpriority_args /* {
906 syscallarg(int) which;
907 syscallarg(int) who;
908 syscallarg(int) prio;
909 } */ *uap = v;
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, void *v, register_t *retval)
920 {
921 struct netbsd32_sys___socket30_args /* {
922 syscallarg(int) domain;
923 syscallarg(int) type;
924 syscallarg(int) protocol;
925 } */ *uap = v;
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, void *v, register_t *retval)
936 {
937 struct netbsd32_connect_args /* {
938 syscallarg(int) s;
939 syscallarg(const netbsd32_sockaddrp_t) name;
940 syscallarg(int) namelen;
941 } */ *uap = v;
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, void *v, register_t *retval)
952 {
953 struct netbsd32_getpriority_args /* {
954 syscallarg(int) which;
955 syscallarg(int) who;
956 } */ *uap = v;
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, void *v, register_t *retval)
966 {
967 struct netbsd32_bind_args /* {
968 syscallarg(int) s;
969 syscallarg(const netbsd32_sockaddrp_t) name;
970 syscallarg(int) namelen;
971 } */ *uap = v;
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, void *v, register_t *retval)
982 {
983 struct netbsd32_setsockopt_args /* {
984 syscallarg(int) s;
985 syscallarg(int) level;
986 syscallarg(int) name;
987 syscallarg(const netbsd32_voidp) val;
988 syscallarg(int) valsize;
989 } */ *uap = v;
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, void *v, register_t *retval)
1003 {
1004 struct netbsd32_listen_args /* {
1005 syscallarg(int) s;
1006 syscallarg(int) backlog;
1007 } */ *uap = v;
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, void *v, register_t *retval)
1017 {
1018 struct netbsd32_fchown_args /* {
1019 syscallarg(int) fd;
1020 syscallarg(uid_t) uid;
1021 syscallarg(gid_t) gid;
1022 } */ *uap = v;
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, void *v, register_t *retval)
1033 {
1034 struct netbsd32_fchmod_args /* {
1035 syscallarg(int) fd;
1036 syscallarg(mode_t) mode;
1037 } */ *uap = v;
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, void *v, register_t *retval)
1047 {
1048 struct netbsd32_setreuid_args /* {
1049 syscallarg(uid_t) ruid;
1050 syscallarg(uid_t) euid;
1051 } */ *uap = v;
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, void *v, register_t *retval)
1061 {
1062 struct netbsd32_setregid_args /* {
1063 syscallarg(gid_t) rgid;
1064 syscallarg(gid_t) egid;
1065 } */ *uap = v;
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, void *v, register_t *retval)
1075 {
1076 struct netbsd32_getsockopt_args /* {
1077 syscallarg(int) s;
1078 syscallarg(int) level;
1079 syscallarg(int) name;
1080 syscallarg(netbsd32_voidp) val;
1081 syscallarg(netbsd32_intp) avalsize;
1082 } */ *uap = v;
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, void *v, register_t *retval)
1095 {
1096 struct netbsd32_rename_args /* {
1097 syscallarg(const netbsd32_charp) from;
1098 syscallarg(const netbsd32_charp) to;
1099 } */ *uap = v;
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, void *v, register_t *retval)
1110 {
1111 struct netbsd32_flock_args /* {
1112 syscallarg(int) fd;
1113 syscallarg(int) how;
1114 } */ *uap = v;
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, void *v, register_t *retval)
1125 {
1126 struct netbsd32_mkfifo_args /* {
1127 syscallarg(const netbsd32_charp) path;
1128 syscallarg(mode_t) mode;
1129 } */ *uap = v;
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, void *v, register_t *retval)
1139 {
1140 struct netbsd32_shutdown_args /* {
1141 syscallarg(int) s;
1142 syscallarg(int) how;
1143 } */ *uap = v;
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, void *v, register_t *retval)
1153 {
1154 struct netbsd32_socketpair_args /* {
1155 syscallarg(int) domain;
1156 syscallarg(int) type;
1157 syscallarg(int) protocol;
1158 syscallarg(netbsd32_intp) rsv;
1159 } */ *uap = v;
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, void *v, register_t *retval)
1172 {
1173 struct netbsd32_mkdir_args /* {
1174 syscallarg(const netbsd32_charp) path;
1175 syscallarg(mode_t) mode;
1176 } */ *uap = v;
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, void *v, register_t *retval)
1186 {
1187 struct netbsd32_rmdir_args /* {
1188 syscallarg(const netbsd32_charp) path;
1189 } */ *uap = v;
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, void *v, register_t *retval)
1198 {
1199 struct netbsd32_quotactl_args /* {
1200 syscallarg(const netbsd32_charp) path;
1201 syscallarg(int) cmd;
1202 syscallarg(int) uid;
1203 syscallarg(netbsd32_caddr_t) arg;
1204 } */ *uap = v;
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, void *v, register_t *retval)
1217 {
1218 #if 0
1219 struct netbsd32_nfssvc_args /* {
1220 syscallarg(int) flag;
1221 syscallarg(netbsd32_voidp) argp;
1222 } */ *uap = v;
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, void *v, register_t *retval)
1237 {
1238 struct netbsd32___getfh30_args /* {
1239 syscallarg(const netbsd32_charp) fname;
1240 syscallarg(netbsd32_fhandlep_t) fhp;
1241 syscallarg(netbsd32_size_tp) fh_size;
1242 } */ *uap = v;
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, void *v, register_t *retval)
1289 {
1290 struct netbsd32_pread_args /* {
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 } */ *uap = v;
1297 struct sys_pread_args ua;
1298 ssize_t rt;
1299 int error;
1300
1301 NETBSD32TO64_UAP(fd);
1302 NETBSD32TOP_UAP(buf, void);
1303 NETBSD32TOX_UAP(nbyte, size_t);
1304 NETBSD32TO64_UAP(pad);
1305 NETBSD32TO64_UAP(offset);
1306 error = sys_pread(l, &ua, (register_t *)&rt);
1307 *retval = rt;
1308 return (error);
1309 }
1310
1311 int
1312 netbsd32_pwrite(struct lwp *l, void *v, register_t *retval)
1313 {
1314 struct netbsd32_pwrite_args /* {
1315 syscallarg(int) fd;
1316 syscallarg(const netbsd32_voidp) buf;
1317 syscallarg(netbsd32_size_t) nbyte;
1318 syscallarg(int) pad;
1319 syscallarg(off_t) offset;
1320 } */ *uap = v;
1321 struct sys_pwrite_args ua;
1322 ssize_t rt;
1323 int error;
1324
1325 NETBSD32TO64_UAP(fd);
1326 NETBSD32TOP_UAP(buf, void);
1327 NETBSD32TOX_UAP(nbyte, size_t);
1328 NETBSD32TO64_UAP(pad);
1329 NETBSD32TO64_UAP(offset);
1330 error = sys_pwrite(l, &ua, (register_t *)&rt);
1331 *retval = rt;
1332 return (error);
1333 }
1334
1335 int
1336 netbsd32_setgid(struct lwp *l, void *v, register_t *retval)
1337 {
1338 struct netbsd32_setgid_args /* {
1339 syscallarg(gid_t) gid;
1340 } */ *uap = v;
1341 struct sys_setgid_args ua;
1342
1343 NETBSD32TO64_UAP(gid);
1344 return (sys_setgid(l, v, retval));
1345 }
1346
1347 int
1348 netbsd32_setegid(struct lwp *l, void *v, register_t *retval)
1349 {
1350 struct netbsd32_setegid_args /* {
1351 syscallarg(gid_t) egid;
1352 } */ *uap = v;
1353 struct sys_setegid_args ua;
1354
1355 NETBSD32TO64_UAP(egid);
1356 return (sys_setegid(l, v, retval));
1357 }
1358
1359 int
1360 netbsd32_seteuid(struct lwp *l, void *v, register_t *retval)
1361 {
1362 struct netbsd32_seteuid_args /* {
1363 syscallarg(gid_t) euid;
1364 } */ *uap = v;
1365 struct sys_seteuid_args ua;
1366
1367 NETBSD32TO64_UAP(euid);
1368 return (sys_seteuid(l, v, retval));
1369 }
1370
1371 #ifdef LFS
1372 int
1373 netbsd32_sys_lfs_bmapv(struct lwp *l, void *v, register_t *retval)
1374 {
1375
1376 return (ENOSYS); /* XXX */
1377 }
1378
1379 int
1380 netbsd32_sys_lfs_markv(struct lwp *l, void *v, register_t *retval)
1381 {
1382
1383 return (ENOSYS); /* XXX */
1384 }
1385
1386 int
1387 netbsd32_sys_lfs_segclean(struct lwp *l, void *v, register_t *retval)
1388 {
1389
1390 return (ENOSYS); /* XXX */
1391 }
1392
1393 int
1394 netbsd32_sys_lfs_segwait(struct lwp *l, void *v, register_t *retval)
1395 {
1396
1397 return (ENOSYS); /* XXX */
1398 }
1399 #endif
1400
1401 int
1402 netbsd32_pathconf(struct lwp *l, void *v, register_t *retval)
1403 {
1404 struct netbsd32_pathconf_args /* {
1405 syscallarg(int) fd;
1406 syscallarg(int) name;
1407 } */ *uap = v;
1408 struct sys_pathconf_args ua;
1409 long rt;
1410 int error;
1411
1412 NETBSD32TOP_UAP(path, const char);
1413 NETBSD32TO64_UAP(name);
1414 error = sys_pathconf(l, &ua, (register_t *)&rt);
1415 *retval = rt;
1416 return (error);
1417 }
1418
1419 int
1420 netbsd32_fpathconf(struct lwp *l, void *v, register_t *retval)
1421 {
1422 struct netbsd32_fpathconf_args /* {
1423 syscallarg(int) fd;
1424 syscallarg(int) name;
1425 } */ *uap = v;
1426 struct sys_fpathconf_args ua;
1427 long rt;
1428 int error;
1429
1430 NETBSD32TO64_UAP(fd);
1431 NETBSD32TO64_UAP(name);
1432 error = sys_fpathconf(l, &ua, (register_t *)&rt);
1433 *retval = rt;
1434 return (error);
1435 }
1436
1437 int
1438 netbsd32_getrlimit(struct lwp *l, void *v, register_t *retval)
1439 {
1440 struct netbsd32_getrlimit_args /* {
1441 syscallarg(int) which;
1442 syscallarg(netbsd32_rlimitp_t) rlp;
1443 } */ *uap = v;
1444 int which = SCARG(uap, which);
1445
1446 if ((u_int)which >= RLIM_NLIMITS)
1447 return (EINVAL);
1448 return (copyout(&l->l_proc->p_rlimit[which],
1449 SCARG_P32(uap, rlp), sizeof(struct rlimit)));
1450 }
1451
1452 int
1453 netbsd32_setrlimit(struct lwp *l, void *v, register_t *retval)
1454 {
1455 struct netbsd32_setrlimit_args /* {
1456 syscallarg(int) which;
1457 syscallarg(const netbsd32_rlimitp_t) rlp;
1458 } */ *uap = v;
1459 int which = SCARG(uap, which);
1460 struct rlimit alim;
1461 int error;
1462
1463 error = copyin(SCARG_P32(uap, rlp), &alim, sizeof(struct rlimit));
1464 if (error)
1465 return (error);
1466
1467 switch (which) {
1468 case RLIMIT_DATA:
1469 if (LIMITCHECK(alim.rlim_cur, MAXDSIZ32))
1470 alim.rlim_cur = MAXDSIZ32;
1471 if (LIMITCHECK(alim.rlim_max, MAXDSIZ32))
1472 alim.rlim_max = MAXDSIZ32;
1473 break;
1474
1475 case RLIMIT_STACK:
1476 if (LIMITCHECK(alim.rlim_cur, MAXSSIZ32))
1477 alim.rlim_cur = MAXSSIZ32;
1478 if (LIMITCHECK(alim.rlim_max, MAXSSIZ32))
1479 alim.rlim_max = MAXSSIZ32;
1480 default:
1481 break;
1482 }
1483
1484 return (dosetrlimit(l, l->l_proc, which, &alim));
1485 }
1486
1487 int
1488 netbsd32_mmap(struct lwp *l, void *v, register_t *retval)
1489 {
1490 struct netbsd32_mmap_args /* {
1491 syscallarg(netbsd32_voidp) addr;
1492 syscallarg(netbsd32_size_t) len;
1493 syscallarg(int) prot;
1494 syscallarg(int) flags;
1495 syscallarg(int) fd;
1496 syscallarg(netbsd32_long) pad;
1497 syscallarg(off_t) pos;
1498 } */ *uap = v;
1499 struct sys_mmap_args ua;
1500 int error;
1501
1502 NETBSD32TOP_UAP(addr, void);
1503 NETBSD32TOX_UAP(len, size_t);
1504 NETBSD32TO64_UAP(prot);
1505 NETBSD32TO64_UAP(flags);
1506 NETBSD32TO64_UAP(fd);
1507 NETBSD32TOX_UAP(pad, long);
1508 NETBSD32TOX_UAP(pos, off_t);
1509 error = sys_mmap(l, &ua, retval);
1510 if ((u_long)*retval > (u_long)UINT_MAX) {
1511 printf("netbsd32_mmap: retval out of range: 0x%lx",
1512 (u_long)*retval);
1513 /* Should try to recover and return an error here. */
1514 }
1515 return (error);
1516 }
1517
1518 int
1519 netbsd32_lseek(struct lwp *l, void *v, register_t *retval)
1520 {
1521 struct netbsd32_lseek_args /* {
1522 syscallarg(int) fd;
1523 syscallarg(int) pad;
1524 syscallarg(off_t) offset;
1525 syscallarg(int) whence;
1526 } */ *uap = v;
1527 struct sys_lseek_args ua;
1528 int rv;
1529
1530 NETBSD32TO64_UAP(fd);
1531 NETBSD32TO64_UAP(pad);
1532 NETBSD32TO64_UAP(offset);
1533 NETBSD32TO64_UAP(whence);
1534 rv = sys_lseek(l, &ua, retval);
1535 #ifdef NETBSD32_OFF_T_RETURN
1536 if (rv == 0)
1537 NETBSD32_OFF_T_RETURN(retval);
1538 #endif
1539 return rv;
1540 }
1541
1542 int
1543 netbsd32_truncate(struct lwp *l, void *v, register_t *retval)
1544 {
1545 struct netbsd32_truncate_args /* {
1546 syscallarg(const netbsd32_charp) path;
1547 syscallarg(int) pad;
1548 syscallarg(off_t) length;
1549 } */ *uap = v;
1550 struct sys_truncate_args ua;
1551
1552 NETBSD32TOP_UAP(path, const char);
1553 NETBSD32TO64_UAP(pad);
1554 NETBSD32TO64_UAP(length);
1555 return (sys_truncate(l, &ua, retval));
1556 }
1557
1558 int
1559 netbsd32_ftruncate(struct lwp *l, void *v, register_t *retval)
1560 {
1561 struct netbsd32_ftruncate_args /* {
1562 syscallarg(int) fd;
1563 syscallarg(int) pad;
1564 syscallarg(off_t) length;
1565 } */ *uap = v;
1566 struct sys_ftruncate_args ua;
1567
1568 NETBSD32TO64_UAP(fd);
1569 NETBSD32TO64_UAP(pad);
1570 NETBSD32TO64_UAP(length);
1571 return (sys_ftruncate(l, &ua, retval));
1572 }
1573
1574 int
1575 netbsd32_mlock(struct lwp *l, void *v, register_t *retval)
1576 {
1577 struct netbsd32_mlock_args /* {
1578 syscallarg(const netbsd32_voidp) addr;
1579 syscallarg(netbsd32_size_t) len;
1580 } */ *uap = v;
1581 struct sys_mlock_args ua;
1582
1583 NETBSD32TOP_UAP(addr, const void);
1584 NETBSD32TO64_UAP(len);
1585 return (sys_mlock(l, &ua, retval));
1586 }
1587
1588 int
1589 netbsd32_munlock(struct lwp *l, void *v, register_t *retval)
1590 {
1591 struct netbsd32_munlock_args /* {
1592 syscallarg(const netbsd32_voidp) addr;
1593 syscallarg(netbsd32_size_t) len;
1594 } */ *uap = v;
1595 struct sys_munlock_args ua;
1596
1597 NETBSD32TOP_UAP(addr, const void);
1598 NETBSD32TO64_UAP(len);
1599 return (sys_munlock(l, &ua, retval));
1600 }
1601
1602 int
1603 netbsd32_undelete(struct lwp *l, void *v, register_t *retval)
1604 {
1605 struct netbsd32_undelete_args /* {
1606 syscallarg(const netbsd32_charp) path;
1607 } */ *uap = v;
1608 struct sys_undelete_args ua;
1609
1610 NETBSD32TOP_UAP(path, const char);
1611 return (sys_undelete(l, &ua, retval));
1612 }
1613
1614 int
1615 netbsd32_getpgid(struct lwp *l, void *v, register_t *retval)
1616 {
1617 struct netbsd32_getpgid_args /* {
1618 syscallarg(pid_t) pid;
1619 } */ *uap = v;
1620 struct sys_getpgid_args ua;
1621
1622 NETBSD32TO64_UAP(pid);
1623 return (sys_getpgid(l, &ua, retval));
1624 }
1625
1626 int
1627 netbsd32_reboot(struct lwp *l, void *v, register_t *retval)
1628 {
1629 struct netbsd32_reboot_args /* {
1630 syscallarg(int) opt;
1631 syscallarg(netbsd32_charp) bootstr;
1632 } */ *uap = v;
1633 struct sys_reboot_args ua;
1634
1635 NETBSD32TO64_UAP(opt);
1636 NETBSD32TOP_UAP(bootstr, char);
1637 return (sys_reboot(l, &ua, retval));
1638 }
1639
1640 #include <sys/poll.h>
1641 int
1642 netbsd32_poll(struct lwp *l, void *v, register_t *retval)
1643 {
1644 struct netbsd32_poll_args /* {
1645 syscallarg(netbsd32_pollfdp_t) fds;
1646 syscallarg(u_int) nfds;
1647 syscallarg(int) timeout;
1648 } */ *uap = v;
1649 struct sys_poll_args ua;
1650
1651 NETBSD32TOP_UAP(fds, struct pollfd);
1652 NETBSD32TO64_UAP(nfds);
1653 NETBSD32TO64_UAP(timeout);
1654
1655 return (sys_poll(l, &ua, retval));
1656 }
1657
1658 int
1659 netbsd32_fdatasync(struct lwp *l, void *v, register_t *retval)
1660 {
1661 struct netbsd32_fdatasync_args /* {
1662 syscallarg(int) fd;
1663 } */ *uap = v;
1664 struct sys_fdatasync_args ua;
1665
1666 NETBSD32TO64_UAP(fd);
1667 return (sys_fdatasync(l, &ua, retval));
1668 }
1669
1670 int
1671 netbsd32___posix_rename(struct lwp *l, void *v, register_t *retval)
1672 {
1673 struct netbsd32___posix_rename_args /* {
1674 syscallarg(const netbsd32_charp) from;
1675 syscallarg(const netbsd32_charp) to;
1676 } */ *uap = v;
1677 struct sys___posix_rename_args ua;
1678
1679 NETBSD32TOP_UAP(from, const char);
1680 NETBSD32TOP_UAP(to, const char);
1681 return (sys___posix_rename(l, &ua, retval));
1682 }
1683
1684 int
1685 netbsd32_swapctl(struct lwp *l, void *v, register_t *retval)
1686 {
1687 struct netbsd32_swapctl_args /* {
1688 syscallarg(int) cmd;
1689 syscallarg(const netbsd32_voidp) arg;
1690 syscallarg(int) misc;
1691 } */ *uap = v;
1692 struct sys_swapctl_args ua;
1693
1694 NETBSD32TO64_UAP(cmd);
1695 NETBSD32TOP_UAP(arg, void);
1696 NETBSD32TO64_UAP(misc);
1697 return (sys_swapctl(l, &ua, retval));
1698 }
1699
1700 int
1701 netbsd32_minherit(struct lwp *l, void *v, register_t *retval)
1702 {
1703 struct netbsd32_minherit_args /* {
1704 syscallarg(netbsd32_voidp) addr;
1705 syscallarg(netbsd32_size_t) len;
1706 syscallarg(int) inherit;
1707 } */ *uap = v;
1708 struct sys_minherit_args ua;
1709
1710 NETBSD32TOP_UAP(addr, void);
1711 NETBSD32TOX_UAP(len, size_t);
1712 NETBSD32TO64_UAP(inherit);
1713 return (sys_minherit(l, &ua, retval));
1714 }
1715
1716 int
1717 netbsd32_lchmod(struct lwp *l, void *v, register_t *retval)
1718 {
1719 struct netbsd32_lchmod_args /* {
1720 syscallarg(const netbsd32_charp) path;
1721 syscallarg(mode_t) mode;
1722 } */ *uap = v;
1723 struct sys_lchmod_args ua;
1724
1725 NETBSD32TOP_UAP(path, const char);
1726 NETBSD32TO64_UAP(mode);
1727 return (sys_lchmod(l, &ua, retval));
1728 }
1729
1730 int
1731 netbsd32_lchown(struct lwp *l, void *v, register_t *retval)
1732 {
1733 struct netbsd32_lchown_args /* {
1734 syscallarg(const netbsd32_charp) path;
1735 syscallarg(uid_t) uid;
1736 syscallarg(gid_t) gid;
1737 } */ *uap = v;
1738 struct sys_lchown_args ua;
1739
1740 NETBSD32TOP_UAP(path, const char);
1741 NETBSD32TO64_UAP(uid);
1742 NETBSD32TO64_UAP(gid);
1743 return (sys_lchown(l, &ua, retval));
1744 }
1745
1746 int
1747 netbsd32___msync13(struct lwp *l, void *v, register_t *retval)
1748 {
1749 struct netbsd32___msync13_args /* {
1750 syscallarg(netbsd32_voidp) addr;
1751 syscallarg(netbsd32_size_t) len;
1752 syscallarg(int) flags;
1753 } */ *uap = v;
1754 struct sys___msync13_args ua;
1755
1756 NETBSD32TOP_UAP(addr, void);
1757 NETBSD32TOX_UAP(len, size_t);
1758 NETBSD32TO64_UAP(flags);
1759 return (sys___msync13(l, &ua, retval));
1760 }
1761
1762 int
1763 netbsd32___posix_chown(struct lwp *l, void *v, register_t *retval)
1764 {
1765 struct netbsd32___posix_chown_args /* {
1766 syscallarg(const netbsd32_charp) path;
1767 syscallarg(uid_t) uid;
1768 syscallarg(gid_t) gid;
1769 } */ *uap = v;
1770 struct sys___posix_chown_args ua;
1771
1772 NETBSD32TOP_UAP(path, const char);
1773 NETBSD32TO64_UAP(uid);
1774 NETBSD32TO64_UAP(gid);
1775 return (sys___posix_chown(l, &ua, retval));
1776 }
1777
1778 int
1779 netbsd32___posix_fchown(struct lwp *l, void *v, register_t *retval)
1780 {
1781 struct netbsd32___posix_fchown_args /* {
1782 syscallarg(int) fd;
1783 syscallarg(uid_t) uid;
1784 syscallarg(gid_t) gid;
1785 } */ *uap = v;
1786 struct sys___posix_fchown_args ua;
1787
1788 NETBSD32TO64_UAP(fd);
1789 NETBSD32TO64_UAP(uid);
1790 NETBSD32TO64_UAP(gid);
1791 return (sys___posix_fchown(l, &ua, retval));
1792 }
1793
1794 int
1795 netbsd32___posix_lchown(struct lwp *l, void *v, register_t *retval)
1796 {
1797 struct netbsd32___posix_lchown_args /* {
1798 syscallarg(const netbsd32_charp) path;
1799 syscallarg(uid_t) uid;
1800 syscallarg(gid_t) gid;
1801 } */ *uap = v;
1802 struct sys___posix_lchown_args ua;
1803
1804 NETBSD32TOP_UAP(path, const char);
1805 NETBSD32TO64_UAP(uid);
1806 NETBSD32TO64_UAP(gid);
1807 return (sys___posix_lchown(l, &ua, retval));
1808 }
1809
1810 int
1811 netbsd32_getsid(struct lwp *l, void *v, register_t *retval)
1812 {
1813 struct netbsd32_getsid_args /* {
1814 syscallarg(pid_t) pid;
1815 } */ *uap = v;
1816 struct sys_getsid_args ua;
1817
1818 NETBSD32TO64_UAP(pid);
1819 return (sys_getsid(l, &ua, retval));
1820 }
1821
1822 int
1823 netbsd32_fktrace(struct lwp *l, void *v, register_t *retval)
1824 {
1825 struct netbsd32_fktrace_args /* {
1826 syscallarg(const int) fd;
1827 syscallarg(int) ops;
1828 syscallarg(int) facs;
1829 syscallarg(int) pid;
1830 } */ *uap = v;
1831 #if 0
1832 struct sys_fktrace_args ua;
1833 #else
1834 /* XXXX */
1835 struct sys_fktrace_noconst_args {
1836 syscallarg(int) fd;
1837 syscallarg(int) ops;
1838 syscallarg(int) facs;
1839 syscallarg(int) pid;
1840 } ua;
1841 #endif
1842
1843 NETBSD32TOX_UAP(fd, int);
1844 NETBSD32TO64_UAP(ops);
1845 NETBSD32TO64_UAP(facs);
1846 NETBSD32TO64_UAP(pid);
1847 return (sys_fktrace(l, &ua, retval));
1848 }
1849
1850 int netbsd32___sigpending14(l, v, retval)
1851 struct lwp *l;
1852 void *v;
1853 register_t *retval;
1854 {
1855 struct netbsd32___sigpending14_args /* {
1856 syscallarg(sigset_t *) set;
1857 } */ *uap = v;
1858 struct sys___sigpending14_args ua;
1859
1860 NETBSD32TOP_UAP(set, sigset_t);
1861 return (sys___sigpending14(l, &ua, retval));
1862 }
1863
1864 int netbsd32___sigprocmask14(l, v, retval)
1865 struct lwp *l;
1866 void *v;
1867 register_t *retval;
1868 {
1869 struct netbsd32___sigprocmask14_args /* {
1870 syscallarg(int) how;
1871 syscallarg(const sigset_t *) set;
1872 syscallarg(sigset_t *) oset;
1873 } */ *uap = v;
1874 struct sys___sigprocmask14_args ua;
1875
1876 NETBSD32TO64_UAP(how);
1877 NETBSD32TOP_UAP(set, sigset_t);
1878 NETBSD32TOP_UAP(oset, sigset_t);
1879 return (sys___sigprocmask14(l, &ua, retval));
1880 }
1881
1882 int netbsd32___sigsuspend14(l, v, retval)
1883 struct lwp *l;
1884 void *v;
1885 register_t *retval;
1886 {
1887 struct netbsd32___sigsuspend14_args /* {
1888 syscallarg(const sigset_t *) set;
1889 } */ *uap = v;
1890 struct sys___sigsuspend14_args ua;
1891
1892 NETBSD32TOP_UAP(set, sigset_t);
1893 return (sys___sigsuspend14(l, &ua, retval));
1894 };
1895
1896 int netbsd32_fchroot(l, v, retval)
1897 struct lwp *l;
1898 void *v;
1899 register_t *retval;
1900 {
1901 struct netbsd32_fchroot_args /* {
1902 syscallarg(int) fd;
1903 } */ *uap = v;
1904 struct sys_fchroot_args ua;
1905
1906 NETBSD32TO64_UAP(fd);
1907 return (sys_fchroot(l, &ua, retval));
1908 }
1909
1910 /*
1911 * Open a file given a file handle.
1912 *
1913 * Check permissions, allocate an open file structure,
1914 * and call the device open routine if any.
1915 */
1916 int
1917 netbsd32___fhopen40(struct lwp *l, void *v, register_t *retval)
1918 {
1919 struct netbsd32___fhopen40_args /* {
1920 syscallarg(const netbsd32_pointer_t *) fhp;
1921 syscallarg(netbsd32_size_t) fh_size;
1922 syscallarg(int) flags;
1923 } */ *uap = v;
1924 struct sys___fhopen40_args ua;
1925
1926 NETBSD32TOP_UAP(fhp, fhandle_t);
1927 NETBSD32TO64_UAP(fh_size);
1928 NETBSD32TO64_UAP(flags);
1929 return (sys___fhopen40(l, &ua, retval));
1930 }
1931
1932 /* virtual memory syscalls */
1933 int
1934 netbsd32_ovadvise(struct lwp *l, void *v, register_t *retval)
1935 {
1936 struct netbsd32_ovadvise_args /* {
1937 syscallarg(int) anom;
1938 } */ *uap = v;
1939 struct sys_ovadvise_args ua;
1940
1941 NETBSD32TO64_UAP(anom);
1942 return (sys_ovadvise(l, &ua, retval));
1943 }
1944
1945 void
1946 netbsd32_adjust_limits(struct proc *p)
1947 {
1948 static const struct {
1949 int id;
1950 rlim_t lim;
1951 } lm[] = {
1952 { RLIMIT_DATA, MAXDSIZ32 },
1953 { RLIMIT_STACK, MAXSSIZ32 },
1954 };
1955 size_t i;
1956 struct plimit *lim;
1957 struct rlimit *rlim;
1958
1959 /*
1960 * We can only reduce the current limits, we cannot stop external
1961 * processes from changing them (eg via sysctl) later on.
1962 * So there is no point trying to lock out such changes here.
1963 *
1964 * If we assume that rlim_cur/max are accessed using atomic
1965 * operations, we don't need to lock against any other updates
1966 * that might happen if the plimit structure is shared writable
1967 * between multiple processes.
1968 */
1969
1970 /* Scan to determine is any limits are out of range */
1971 lim = p->p_limit;
1972 for (i = 0; ; i++) {
1973 if (i >= __arraycount(lm))
1974 /* All in range */
1975 return;
1976 rlim = lim->pl_rlimit + lm[i].id;
1977 if (LIMITCHECK(rlim->rlim_cur, lm[i].lim))
1978 break;
1979 if (LIMITCHECK(rlim->rlim_max, lm[i].lim))
1980 break;
1981 }
1982
1983 lim_privatise(p, false);
1984
1985 lim = p->p_limit;
1986 for (i = 0; i < __arraycount(lm); i++) {
1987 rlim = lim->pl_rlimit + lm[i].id;
1988 if (LIMITCHECK(rlim->rlim_cur, lm[i].lim))
1989 rlim->rlim_cur = lm[i].lim;
1990 if (LIMITCHECK(rlim->rlim_max, lm[i].lim))
1991 rlim->rlim_max = lm[i].lim;
1992 }
1993 }
1994
1995 int
1996 netbsd32_uuidgen(struct lwp *l, void *v, register_t *retval)
1997 {
1998 struct netbsd32_uuidgen_args /* {
1999 syscallarg(netbsd32_uuidp_t) store;
2000 syscallarg(int) count;
2001 } */ *uap = v;
2002 struct sys_uuidgen_args ua;
2003
2004 NETBSD32TOP_UAP(store, struct uuid);
2005 NETBSD32TO64_UAP(count);
2006 return (sys_uuidgen(l, &ua, retval));
2007 }
2008
2009 int
2010 netbsd32_extattrctl(struct lwp *l, void *v, register_t *retval)
2011 {
2012 struct netbsd32_extattrctl_args /* {
2013 syscallarg(const netbsd32_charp) path;
2014 syscallarg(int) cmd;
2015 syscallarg(const netbsd32_charp) filename;
2016 syscallarg(int) attrnamespace;
2017 syscallarg(const netbsd32_charp) attrname;
2018 } */ *uap = v;
2019 struct sys_extattrctl_args ua;
2020
2021 NETBSD32TOP_UAP(path, const char);
2022 NETBSD32TO64_UAP(cmd);
2023 NETBSD32TOP_UAP(filename, const char);
2024 NETBSD32TO64_UAP(attrnamespace);
2025 NETBSD32TOP_UAP(attrname, const char);
2026 return sys_extattrctl(l, &ua, retval);
2027 }
2028
2029 int
2030 netbsd32_extattr_set_fd(struct lwp *l, void *v, register_t *retval)
2031 {
2032 struct netbsd32_extattr_set_fd_args /* {
2033 syscallarg(int) fd;
2034 syscallarg(int) attrnamespace;
2035 syscallarg(const netbsd32_charp) attrname;
2036 syscallarg(const netbsd32_voidp) data;
2037 syscallarg(netbsd32_size_t) nbytes;
2038 } */ *uap = v;
2039 struct sys_extattr_set_fd_args ua;
2040
2041 NETBSD32TO64_UAP(fd);
2042 NETBSD32TO64_UAP(attrnamespace);
2043 NETBSD32TOP_UAP(attrname, const char);
2044 NETBSD32TOP_UAP(data, const void);
2045 NETBSD32TOX_UAP(nbytes, size_t);
2046 return sys_extattr_set_fd(l, &ua, retval);
2047 }
2048
2049 int
2050 netbsd32_extattr_set_file(struct lwp *l, void *v, register_t *retval)
2051 {
2052 struct netbsd32_extattr_set_file_args /* {
2053 syscallarg(const netbsd32_charp) path;
2054 syscallarg(int) attrnamespace;
2055 syscallarg(const netbsd32_charp) attrname;
2056 syscallarg(const netbsd32_voidp) data;
2057 syscallarg(netbsd32_size_t) nbytes;
2058 } */ *uap = v;
2059 struct sys_extattr_set_file_args ua;
2060
2061 NETBSD32TOP_UAP(path, const char);
2062 NETBSD32TO64_UAP(attrnamespace);
2063 NETBSD32TOP_UAP(attrname, const char);
2064 NETBSD32TOP_UAP(data, const void);
2065 NETBSD32TOX_UAP(nbytes, size_t);
2066 return sys_extattr_set_file(l, &ua, retval);
2067 }
2068
2069 int
2070 netbsd32_extattr_set_link(struct lwp *l, void *v, register_t *retval)
2071 {
2072 struct netbsd32_extattr_set_link_args /* {
2073 syscallarg(const netbsd32_charp) path;
2074 syscallarg(int) attrnamespace;
2075 syscallarg(const netbsd32_charp) attrname;
2076 syscallarg(const netbsd32_voidp) data;
2077 syscallarg(netbsd32_size_t) nbytes;
2078 } */ *uap = v;
2079 struct sys_extattr_set_link_args ua;
2080
2081 NETBSD32TOP_UAP(path, const char);
2082 NETBSD32TO64_UAP(attrnamespace);
2083 NETBSD32TOP_UAP(attrname, const char);
2084 NETBSD32TOP_UAP(data, const void);
2085 NETBSD32TOX_UAP(nbytes, size_t);
2086 return sys_extattr_set_link(l, &ua, retval);
2087 }
2088
2089 int
2090 netbsd32_extattr_get_fd(struct lwp *l, void *v, register_t *retval)
2091 {
2092 struct netbsd32_extattr_get_fd_args /* {
2093 syscallarg(int) fd;
2094 syscallarg(int) attrnamespace;
2095 syscallarg(const netbsd32_charp) attrname;
2096 syscallarg(netbsd32_voidp) data;
2097 syscallarg(netbsd32_size_t) nbytes;
2098 } */ *uap = v;
2099 struct sys_extattr_get_fd_args ua;
2100
2101 NETBSD32TO64_UAP(fd);
2102 NETBSD32TO64_UAP(attrnamespace);
2103 NETBSD32TOP_UAP(attrname, const char);
2104 NETBSD32TOP_UAP(data, void);
2105 NETBSD32TOX_UAP(nbytes, size_t);
2106 return sys_extattr_get_fd(l, &ua, retval);
2107 }
2108
2109 int
2110 netbsd32_extattr_get_file(struct lwp *l, void *v, register_t *retval)
2111 {
2112 struct netbsd32_extattr_get_file_args /* {
2113 syscallarg(const netbsd32_charp) path;
2114 syscallarg(int) attrnamespace;
2115 syscallarg(const netbsd32_charp) attrname;
2116 syscallarg(netbsd32_voidp) data;
2117 syscallarg(netbsd32_size_t) nbytes;
2118 } */ *uap = v;
2119 struct sys_extattr_get_file_args ua;
2120
2121 NETBSD32TOP_UAP(path, const char);
2122 NETBSD32TO64_UAP(attrnamespace);
2123 NETBSD32TOP_UAP(attrname, const char);
2124 NETBSD32TOP_UAP(data, void);
2125 NETBSD32TOX_UAP(nbytes, size_t);
2126 return sys_extattr_get_file(l, &ua, retval);
2127 }
2128
2129 int
2130 netbsd32_extattr_get_link(struct lwp *l, void *v, register_t *retval)
2131 {
2132 struct netbsd32_extattr_get_link_args /* {
2133 syscallarg(const netbsd32_charp) path;
2134 syscallarg(int) attrnamespace;
2135 syscallarg(const netbsd32_charp) attrname;
2136 syscallarg(netbsd32_voidp) data;
2137 syscallarg(netbsd32_size_t) nbytes;
2138 } */ *uap = v;
2139 struct sys_extattr_get_link_args ua;
2140
2141 NETBSD32TOP_UAP(path, const char);
2142 NETBSD32TO64_UAP(attrnamespace);
2143 NETBSD32TOP_UAP(attrname, const char);
2144 NETBSD32TOP_UAP(data, void);
2145 NETBSD32TOX_UAP(nbytes, size_t);
2146 return sys_extattr_get_link(l, &ua, retval);
2147 }
2148
2149 int
2150 netbsd32_extattr_delete_fd(struct lwp *l, void *v, register_t *retval)
2151 {
2152 struct netbsd32_extattr_delete_fd_args /* {
2153 syscallarg(int) fd;
2154 syscallarg(int) attrnamespace;
2155 syscallarg(const netbsd32_charp) attrname;
2156 } */ *uap = v;
2157 struct sys_extattr_delete_fd_args ua;
2158
2159 NETBSD32TO64_UAP(fd);
2160 NETBSD32TO64_UAP(attrnamespace);
2161 NETBSD32TOP_UAP(attrname, const char);
2162 return sys_extattr_delete_fd(l, &ua, retval);
2163 }
2164
2165 int
2166 netbsd32_extattr_delete_file(struct lwp *l, void *v, register_t *retval)
2167 {
2168 struct netbsd32_extattr_delete_file_args /* {
2169 syscallarg(const netbsd32_charp) path;
2170 syscallarg(int) attrnamespace;
2171 syscallarg(const netbsd32_charp) attrname;
2172 } */ *uap = v;
2173 struct sys_extattr_delete_file_args ua;
2174
2175 NETBSD32TOP_UAP(path, const char);
2176 NETBSD32TO64_UAP(attrnamespace);
2177 NETBSD32TOP_UAP(attrname, const char);
2178 return sys_extattr_delete_file(l, &ua, retval);
2179 }
2180
2181 int
2182 netbsd32_extattr_delete_link(struct lwp *l, void *v, register_t *retval)
2183 {
2184 struct netbsd32_extattr_delete_link_args /* {
2185 syscallarg(const netbsd32_charp) path;
2186 syscallarg(int) attrnamespace;
2187 syscallarg(const netbsd32_charp) attrname;
2188 } */ *uap = v;
2189 struct sys_extattr_delete_link_args ua;
2190
2191 NETBSD32TOP_UAP(path, const char);
2192 NETBSD32TO64_UAP(attrnamespace);
2193 NETBSD32TOP_UAP(attrname, const char);
2194 return sys_extattr_delete_link(l, &ua, retval);
2195 }
2196
2197 int
2198 netbsd32_extattr_list_fd(struct lwp *l, void *v, register_t *retval)
2199 {
2200 struct netbsd32_extattr_list_fd_args /* {
2201 syscallarg(int) fd;
2202 syscallarg(int) attrnamespace;
2203 syscallarg(netbsd32_voidp) data;
2204 syscallarg(netbsd32_size_t) nbytes;
2205 } */ *uap = v;
2206 struct sys_extattr_list_fd_args ua;
2207
2208 NETBSD32TO64_UAP(fd);
2209 NETBSD32TO64_UAP(attrnamespace);
2210 NETBSD32TOP_UAP(data, void);
2211 NETBSD32TOX_UAP(nbytes, size_t);
2212 return sys_extattr_list_fd(l, &ua, retval);
2213 }
2214
2215 int
2216 netbsd32_extattr_list_file(struct lwp *l, void *v, register_t *retval)
2217 {
2218 struct netbsd32_extattr_list_file_args /* {
2219 syscallarg(const netbsd32_charp) path;
2220 syscallarg(int) attrnamespace;
2221 syscallarg(netbsd32_voidp) data;
2222 syscallarg(netbsd32_size_t) nbytes;
2223 } */ *uap = v;
2224 struct sys_extattr_list_file_args ua;
2225
2226 NETBSD32TOP_UAP(path, const char);
2227 NETBSD32TO64_UAP(attrnamespace);
2228 NETBSD32TOP_UAP(data, void);
2229 NETBSD32TOX_UAP(nbytes, size_t);
2230 return sys_extattr_list_file(l, &ua, retval);
2231 }
2232
2233 int
2234 netbsd32_extattr_list_link(struct lwp *l, void *v, register_t *retval)
2235 {
2236 struct netbsd32_extattr_list_link_args /* {
2237 syscallarg(const netbsd32_charp) path;
2238 syscallarg(int) attrnamespace;
2239 syscallarg(netbsd32_voidp) data;
2240 syscallarg(netbsd32_size_t) nbytes;
2241 } */ *uap = v;
2242 struct sys_extattr_list_link_args ua;
2243
2244 NETBSD32TOP_UAP(path, const char);
2245 NETBSD32TO64_UAP(attrnamespace);
2246 NETBSD32TOP_UAP(data, void);
2247 NETBSD32TOX_UAP(nbytes, size_t);
2248 return sys_extattr_list_link(l, &ua, retval);
2249 }
2250
2251 int
2252 netbsd32_mlockall(struct lwp *l, void *v, register_t *retval)
2253 {
2254 struct netbsd32_mlockall_args /* {
2255 syscallarg(int) flags;
2256 } */ *uap = v;
2257 struct sys_mlockall_args ua;
2258
2259 NETBSD32TO64_UAP(flags);
2260 return (sys_mlockall(l, &ua, retval));
2261 }
2262
2263 int
2264 netbsd32___clone(struct lwp *l, void *v, register_t *retval)
2265 {
2266 struct netbsd32___clone_args /* {
2267 syscallarg(int) flags;
2268 syscallarg(netbsd32_voidp) stack;
2269 } */ *uap = v;
2270 struct sys___clone_args ua;
2271
2272 NETBSD32TO64_UAP(flags);
2273 NETBSD32TOP_UAP(stack, void);
2274 return sys___clone(l, &ua, retval);
2275 }
2276
2277 int
2278 netbsd32_fsync_range(struct lwp *l, void *v, register_t *retval)
2279 {
2280 struct netbsd32_fsync_range_args /* {
2281 syscallarg(int) fd;
2282 syscallarg(int) flags;
2283 syscallarg(off_t) start;
2284 syscallarg(off_t) length;
2285 } */ *uap = v;
2286 struct sys_fsync_range_args ua;
2287
2288 NETBSD32TO64_UAP(fd);
2289 NETBSD32TO64_UAP(flags);
2290 NETBSD32TO64_UAP(start);
2291 NETBSD32TO64_UAP(length);
2292 return (sys_fsync_range(l, &ua, retval));
2293 }
2294
2295 int
2296 netbsd32_rasctl(struct lwp *l, void *v, register_t *retval)
2297 {
2298 struct netbsd32_rasctl_args /* {
2299 syscallarg(netbsd32_caddr_t) addr;
2300 syscallarg(netbsd32_size_t) len;
2301 syscallarg(int) op;
2302 } */ *uap = v;
2303 struct sys_rasctl_args ua;
2304
2305 NETBSD32TOP_UAP(addr, void *);
2306 NETBSD32TOX_UAP(len, size_t);
2307 NETBSD32TO64_UAP(op);
2308 return sys_rasctl(l, &ua, retval);
2309 }
2310
2311 int
2312 netbsd32_setxattr(struct lwp *l, void *v, register_t *retval)
2313 {
2314 struct netbsd32_setxattr_args /* {
2315 syscallarg(const netbsd32_charp) path;
2316 syscallarg(const netbsd32_charp) name;
2317 syscallarg(netbsd32_voidp) value;
2318 syscallarg(netbsd32_size_t) size;
2319 syscallarg(int) flags;
2320 } */ *uap = v;
2321 struct sys_setxattr_args ua;
2322 NETBSD32TOP_UAP(path, const char);
2323 NETBSD32TOP_UAP(name, const char);
2324 NETBSD32TOP_UAP(value, void);
2325 NETBSD32TOX_UAP(size, size_t);
2326 NETBSD32TO64_UAP(flags);
2327 return sys_setxattr(l, &ua, retval);
2328 }
2329
2330 int
2331 netbsd32_lsetxattr(struct lwp *l, void *v, register_t *retval)
2332 {
2333 struct netbsd32_lsetxattr_args /* {
2334 syscallarg(const netbsd32_charp) path;
2335 syscallarg(const netbsd32_charp) name;
2336 syscallarg(netbsd32_voidp) value;
2337 syscallarg(netbsd32_size_t) size;
2338 syscallarg(int) flags;
2339 } */ *uap = v;
2340 struct sys_lsetxattr_args ua;
2341 NETBSD32TOP_UAP(path, const char);
2342 NETBSD32TOP_UAP(name, const char);
2343 NETBSD32TOP_UAP(value, void);
2344 NETBSD32TOX_UAP(size, size_t);
2345 NETBSD32TO64_UAP(flags);
2346 return sys_lsetxattr(l, &ua, retval);
2347 }
2348
2349 int
2350 netbsd32_fsetxattr(struct lwp *l, void *v, register_t *retval)
2351 {
2352 struct netbsd32_fsetxattr_args /* {
2353 syscallarg(int) fd;
2354 syscallarg(const netbsd32_charp) name;
2355 syscallarg(netbsd32_voidp) value;
2356 syscallarg(netbsd32_size_t) size;
2357 syscallarg(int) flags;
2358 } */ *uap = v;
2359 struct sys_fsetxattr_args ua;
2360 NETBSD32TO64_UAP(fd);
2361 NETBSD32TOP_UAP(name, const char);
2362 NETBSD32TOP_UAP(value, void);
2363 NETBSD32TOX_UAP(size, size_t);
2364 NETBSD32TO64_UAP(flags);
2365 return sys_fsetxattr(l, &ua, retval);
2366 }
2367
2368 int
2369 netbsd32_getxattr(struct lwp *l, void *v, register_t *retval)
2370 {
2371 struct netbsd32_getxattr_args /* {
2372 syscallarg(const netbsd32_charp) path;
2373 syscallarg(const netbsd32_charp) name;
2374 syscallarg(netbsd32_voidp) value;
2375 syscallarg(netbsd32_size_t) size;
2376 } */ *uap = v;
2377 struct sys_getxattr_args ua;
2378 NETBSD32TOP_UAP(path, const char);
2379 NETBSD32TOP_UAP(name, const char);
2380 NETBSD32TOP_UAP(value, void);
2381 NETBSD32TOX_UAP(size, size_t);
2382 return sys_getxattr(l, &ua, retval);
2383 }
2384
2385 int
2386 netbsd32_lgetxattr(struct lwp *l, void *v, register_t *retval)
2387 {
2388 struct netbsd32_lgetxattr_args /* {
2389 syscallarg(const netbsd32_charp) path;
2390 syscallarg(const netbsd32_charp) name;
2391 syscallarg(netbsd32_voidp) value;
2392 syscallarg(netbsd32_size_t) size;
2393 } */ *uap = v;
2394 struct sys_lgetxattr_args ua;
2395 NETBSD32TOP_UAP(path, const char);
2396 NETBSD32TOP_UAP(name, const char);
2397 NETBSD32TOP_UAP(value, void);
2398 NETBSD32TOX_UAP(size, size_t);
2399 return sys_lgetxattr(l, &ua, retval);
2400 }
2401
2402 int
2403 netbsd32_fgetxattr(struct lwp *l, void *v, register_t *retval)
2404 {
2405 struct netbsd32_fgetxattr_args /* {
2406 syscallarg(int) fd;
2407 syscallarg(const netbsd32_charp) name;
2408 syscallarg(netbsd32_voidp) value;
2409 syscallarg(netbsd32_size_t) size;
2410 } */ *uap = v;
2411 struct sys_fgetxattr_args ua;
2412 NETBSD32TO64_UAP(fd);
2413 NETBSD32TOP_UAP(name, const char);
2414 NETBSD32TOP_UAP(value, void);
2415 NETBSD32TOX_UAP(size, size_t);
2416 return sys_fgetxattr(l, &ua, retval);
2417 }
2418
2419 int
2420 netbsd32_listxattr(struct lwp *l, void *v, register_t *retval)
2421 {
2422 struct netbsd32_listxattr_args /* {
2423 syscallarg(const netbsd32_charp) path;
2424 syscallarg(netbsd32_charp) list;
2425 syscallarg(netbsd32_size_t) size;
2426 } */ *uap = v;
2427 struct sys_listxattr_args ua;
2428 NETBSD32TOP_UAP(path, const char);
2429 NETBSD32TOP_UAP(list, char);
2430 NETBSD32TOX_UAP(size, size_t);
2431 return sys_listxattr(l, &ua, retval);
2432 }
2433
2434 int
2435 netbsd32_llistxattr(struct lwp *l, void *v, register_t *retval)
2436 {
2437 struct netbsd32_llistxattr_args /* {
2438 syscallarg(const netbsd32_charp) path;
2439 syscallarg(netbsd32_charp) list;
2440 syscallarg(netbsd32_size_t) size;
2441 } */ *uap = v;
2442 struct sys_llistxattr_args ua;
2443 NETBSD32TOP_UAP(path, const char);
2444 NETBSD32TOP_UAP(list, char);
2445 NETBSD32TOX_UAP(size, size_t);
2446 return sys_llistxattr(l, &ua, retval);
2447 }
2448
2449 int
2450 netbsd32_flistxattr(struct lwp *l, void *v, register_t *retval)
2451 {
2452 struct netbsd32_flistxattr_args /* {
2453 syscallarg(int) fd;
2454 syscallarg(netbsd32_charp) list;
2455 syscallarg(netbsd32_size_t) size;
2456 } */ *uap = v;
2457 struct sys_flistxattr_args ua;
2458 NETBSD32TO64_UAP(fd);
2459 NETBSD32TOP_UAP(list, char);
2460 NETBSD32TOX_UAP(size, size_t);
2461 return sys_flistxattr(l, &ua, retval);
2462 }
2463
2464 int
2465 netbsd32_removexattr(struct lwp *l, void *v, register_t *retval)
2466 {
2467 struct netbsd32_removexattr_args /* {
2468 syscallarg(const netbsd32_charp) path;
2469 syscallarg(const netbsd32_charp) name;
2470 } */ *uap = v;
2471 struct sys_removexattr_args ua;
2472 NETBSD32TOP_UAP(path, const char);
2473 NETBSD32TOP_UAP(name, const char);
2474 return sys_removexattr(l, &ua, retval);
2475 }
2476
2477 int
2478 netbsd32_lremovexattr(struct lwp *l, void *v, register_t *retval)
2479 {
2480 struct netbsd32_lremovexattr_args /* {
2481 syscallarg(const netbsd32_charp) path;
2482 syscallarg(const netbsd32_charp) name;
2483 } */ *uap = v;
2484 struct sys_lremovexattr_args ua;
2485 NETBSD32TOP_UAP(path, const char);
2486 NETBSD32TOP_UAP(name, const char);
2487 return sys_lremovexattr(l, &ua, retval);
2488 }
2489
2490 int
2491 netbsd32_fremovexattr(struct lwp *l, void *v, register_t *retval)
2492 {
2493 struct netbsd32_fremovexattr_args /* {
2494 syscallarg(int) fd;
2495 syscallarg(const netbsd32_charp) name;
2496 } */ *uap = v;
2497 struct sys_fremovexattr_args ua;
2498 NETBSD32TO64_UAP(fd);
2499 NETBSD32TOP_UAP(name, const char);
2500 return sys_fremovexattr(l, &ua, retval);
2501 }
2502
2503 /*
2504 * MI indirect system call support.
2505 * Only used if the MD netbsd32_syscall.c doesn't intercept the calls.
2506 */
2507
2508 #define NETBSD32_SYSCALL
2509 #undef SYS_NSYSENT
2510 #define SYS_NSYSENT NETBSD32_SYS_NSYSENT
2511
2512 #define SYS_SYSCALL netbsd32_sys_syscall
2513 #include "../../kern/sys_syscall.c"
2514 #undef SYS_SYSCALL
2515
2516 #define SYS_SYSCALL netbsd32_sys___syscall
2517 #include "../../kern/sys_syscall.c"
2518 #undef SYS_SYSCALL
2519