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