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