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