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