netbsd32_netbsd.c revision 1.144.4.2 1 /* $NetBSD: netbsd32_netbsd.c,v 1.144.4.2 2008/12/13 01:14:03 haad 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.144.4.2 2008/12/13 01:14:03 haad Exp $");
31
32 #if defined(_KERNEL_OPT)
33 #include "opt_ddb.h"
34 #include "opt_ntp.h"
35 #include "opt_compat_netbsd.h"
36 #include "opt_compat_43.h"
37 #include "opt_sysv.h"
38 #include "opt_syscall_debug.h"
39 #include "opt_sa.h"
40
41 #include "fs_lfs.h"
42 #endif
43
44 /*
45 * Though COMPAT_OLDSOCK is needed only for COMPAT_43, SunOS, Linux,
46 * HP-UX, FreeBSD, Ultrix, OSF1, we define it unconditionally so that
47 * this would be module-safe.
48 */
49 #define COMPAT_OLDSOCK /* used by <sys/socket.h> */
50
51 #include <sys/param.h>
52 #include <sys/systm.h>
53 #include <sys/kernel.h>
54 //#define msg __msg /* Don't ask me! */
55 #include <sys/malloc.h>
56 #include <sys/mount.h>
57 #include <sys/socket.h>
58 #include <sys/sockio.h>
59 #include <sys/socketvar.h>
60 #include <sys/mbuf.h>
61 #include <sys/stat.h>
62 #include <sys/time.h>
63 #include <sys/signalvar.h>
64 #include <sys/ptrace.h>
65 #include <sys/ktrace.h>
66 #include <sys/trace.h>
67 #include <sys/resourcevar.h>
68 #include <sys/pool.h>
69 #include <sys/vnode.h>
70 #include <sys/file.h>
71 #include <sys/filedesc.h>
72 #include <sys/namei.h>
73 #include <sys/dirent.h>
74 #include <sys/kauth.h>
75
76 #include <uvm/uvm_extern.h>
77
78 #include <sys/sa.h>
79 #include <sys/savar.h>
80 #include <sys/syscallargs.h>
81 #include <sys/proc.h>
82 #include <sys/acct.h>
83 #include <sys/exec.h>
84
85 #include <net/if.h>
86
87 #include <compat/netbsd32/netbsd32.h>
88 #include <compat/netbsd32/netbsd32_exec.h>
89 #include <compat/netbsd32/netbsd32_syscall.h>
90 #include <compat/netbsd32/netbsd32_syscallargs.h>
91 #include <compat/netbsd32/netbsd32_conv.h>
92 #include <compat/netbsd32/netbsd32_sa.h>
93
94 #include <machine/frame.h>
95
96 #if defined(DDB)
97 #include <ddb/ddbvar.h>
98 #endif
99
100 extern struct sysent netbsd32_sysent[];
101 #ifdef SYSCALL_DEBUG
102 extern const char * const netbsd32_syscallnames[];
103 #endif
104 #ifdef __HAVE_SYSCALL_INTERN
105 void netbsd32_syscall_intern(struct proc *);
106 #else
107 void syscall(void);
108 #endif
109
110 #define LIMITCHECK(a, b) ((a) != RLIM_INFINITY && (a) > (b))
111
112 #ifdef COMPAT_16
113 extern char netbsd32_sigcode[], netbsd32_esigcode[];
114 struct uvm_object *emul_netbsd32_object;
115 #endif
116
117 extern struct sysctlnode netbsd32_sysctl_root;
118
119 const struct sa_emul saemul_netbsd32 = {
120 sizeof(ucontext32_t),
121 sizeof(struct netbsd32_sa_t),
122 sizeof(netbsd32_sa_tp),
123 netbsd32_sacopyout,
124 netbsd32_upcallconv,
125 netbsd32_cpu_upcall,
126 (void (*)(struct lwp *, void *))getucontext32_sa,
127 #ifdef KERN_SA
128 netbsd32_sa_ucsp
129 #else
130 NULL
131 #endif
132 };
133
134 struct emul emul_netbsd32 = {
135 "netbsd32",
136 "/emul/netbsd32",
137 #ifndef __HAVE_MINIMAL_EMUL
138 0,
139 NULL,
140 NETBSD32_SYS_syscall,
141 NETBSD32_SYS_NSYSENT,
142 #endif
143 netbsd32_sysent,
144 #ifdef SYSCALL_DEBUG
145 netbsd32_syscallnames,
146 #else
147 NULL,
148 #endif
149 netbsd32_sendsig,
150 trapsignal,
151 NULL,
152 #ifdef COMPAT_16
153 netbsd32_sigcode,
154 netbsd32_esigcode,
155 &emul_netbsd32_object,
156 #else
157 NULL,
158 NULL,
159 NULL,
160 #endif
161 netbsd32_setregs,
162 NULL,
163 NULL,
164 NULL,
165 NULL,
166 NULL,
167 #ifdef __HAVE_SYSCALL_INTERN
168 netbsd32_syscall_intern,
169 #else
170 syscall,
171 #endif
172 &netbsd32_sysctl_root,
173 NULL,
174
175 netbsd32_vm_default_addr,
176 NULL,
177 #ifdef COMPAT_40
178 &saemul_netbsd32,
179 #else
180 NULL,
181 #endif
182 sizeof(ucontext32_t),
183 startlwp32,
184 };
185
186 /*
187 * below are all the standard NetBSD system calls, in the 32bit
188 * environment, with the necessary conversions to 64bit before
189 * calling the real syscall. anything that needs special
190 * attention is handled elsewhere.
191 */
192
193 int
194 netbsd32_exit(struct lwp *l, const struct netbsd32_exit_args *uap, register_t *retval)
195 {
196 /* {
197 syscallarg(int) rval;
198 } */
199 struct sys_exit_args ua;
200
201 NETBSD32TO64_UAP(rval);
202 return sys_exit(l, &ua, retval);
203 }
204
205 int
206 netbsd32_read(struct lwp *l, const struct netbsd32_read_args *uap, register_t *retval)
207 {
208 /* {
209 syscallarg(int) fd;
210 syscallarg(netbsd32_voidp) buf;
211 syscallarg(netbsd32_size_t) nbyte;
212 } */
213 struct sys_read_args ua;
214
215 NETBSD32TO64_UAP(fd);
216 NETBSD32TOP_UAP(buf, void *);
217 NETBSD32TOX_UAP(nbyte, size_t);
218 return sys_read(l, &ua, retval);
219 }
220
221 int
222 netbsd32_write(struct lwp *l, const struct netbsd32_write_args *uap, register_t *retval)
223 {
224 /* {
225 syscallarg(int) fd;
226 syscallarg(const netbsd32_voidp) buf;
227 syscallarg(netbsd32_size_t) nbyte;
228 } */
229 struct sys_write_args ua;
230
231 NETBSD32TO64_UAP(fd);
232 NETBSD32TOP_UAP(buf, void *);
233 NETBSD32TOX_UAP(nbyte, size_t);
234 return sys_write(l, &ua, retval);
235 }
236
237 int
238 netbsd32_close(struct lwp *l, const struct netbsd32_close_args *uap, register_t *retval)
239 {
240 /* {
241 syscallarg(int) fd;
242 } */
243 struct sys_close_args ua;
244
245 NETBSD32TO64_UAP(fd);
246 return sys_close(l, &ua, retval);
247 }
248
249 int
250 netbsd32_open(struct lwp *l, const struct netbsd32_open_args *uap, register_t *retval)
251 {
252 /* {
253 syscallarg(const netbsd32_charp) path;
254 syscallarg(int) flags;
255 syscallarg(mode_t) mode;
256 } */
257 struct sys_open_args ua;
258
259 NETBSD32TOP_UAP(path, const char);
260 NETBSD32TO64_UAP(flags);
261 NETBSD32TO64_UAP(mode);
262
263 return (sys_open(l, &ua, retval));
264 }
265
266 int
267 netbsd32_link(struct lwp *l, const struct netbsd32_link_args *uap, register_t *retval)
268 {
269 /* {
270 syscallarg(const netbsd32_charp) path;
271 syscallarg(const netbsd32_charp) link;
272 } */
273 struct sys_link_args ua;
274
275 NETBSD32TOP_UAP(path, const char);
276 NETBSD32TOP_UAP(link, const char);
277 return (sys_link(l, &ua, retval));
278 }
279
280 int
281 netbsd32_unlink(struct lwp *l, const struct netbsd32_unlink_args *uap, register_t *retval)
282 {
283 /* {
284 syscallarg(const netbsd32_charp) path;
285 } */
286 struct sys_unlink_args ua;
287
288 NETBSD32TOP_UAP(path, const char);
289
290 return (sys_unlink(l, &ua, retval));
291 }
292
293 int
294 netbsd32_chdir(struct lwp *l, const struct netbsd32_chdir_args *uap, register_t *retval)
295 {
296 /* {
297 syscallarg(const netbsd32_charp) path;
298 } */
299 struct sys_chdir_args ua;
300
301 NETBSD32TOP_UAP(path, const char);
302
303 return (sys_chdir(l, &ua, retval));
304 }
305
306 int
307 netbsd32_fchdir(struct lwp *l, const struct netbsd32_fchdir_args *uap, register_t *retval)
308 {
309 /* {
310 syscallarg(int) fd;
311 } */
312 struct sys_fchdir_args ua;
313
314 NETBSD32TO64_UAP(fd);
315
316 return (sys_fchdir(l, &ua, retval));
317 }
318
319 int
320 netbsd32_mknod(struct lwp *l, const struct netbsd32_mknod_args *uap, register_t *retval)
321 {
322 /* {
323 syscallarg(const netbsd32_charp) path;
324 syscallarg(mode_t) mode;
325 syscallarg(dev_t) dev;
326 } */
327 struct sys_mknod_args ua;
328
329 NETBSD32TOP_UAP(path, const char);
330 NETBSD32TO64_UAP(dev);
331 NETBSD32TO64_UAP(mode);
332
333 return (sys_mknod(l, &ua, retval));
334 }
335
336 int
337 netbsd32_chmod(struct lwp *l, const struct netbsd32_chmod_args *uap, register_t *retval)
338 {
339 /* {
340 syscallarg(const netbsd32_charp) path;
341 syscallarg(mode_t) mode;
342 } */
343 struct sys_chmod_args ua;
344
345 NETBSD32TOP_UAP(path, const char);
346 NETBSD32TO64_UAP(mode);
347
348 return (sys_chmod(l, &ua, retval));
349 }
350
351 int
352 netbsd32_chown(struct lwp *l, const struct netbsd32_chown_args *uap, register_t *retval)
353 {
354 /* {
355 syscallarg(const netbsd32_charp) path;
356 syscallarg(uid_t) uid;
357 syscallarg(gid_t) gid;
358 } */
359 struct sys_chown_args ua;
360
361 NETBSD32TOP_UAP(path, const char);
362 NETBSD32TO64_UAP(uid);
363 NETBSD32TO64_UAP(gid);
364
365 return (sys_chown(l, &ua, retval));
366 }
367
368 int
369 netbsd32_break(struct lwp *l, const struct netbsd32_break_args *uap, register_t *retval)
370 {
371 /* {
372 syscallarg(netbsd32_charp) nsize;
373 } */
374 struct sys_obreak_args ua;
375
376 SCARG(&ua, nsize) = SCARG_P32(uap, nsize);
377 NETBSD32TOP_UAP(nsize, char);
378 return (sys_obreak(l, &ua, retval));
379 }
380
381 int
382 netbsd32_mount(struct lwp *l, const struct netbsd32_mount_args *uap, register_t *retval)
383 {
384 #ifdef COMPAT_40
385 /* {
386 syscallarg(const netbsd32_charp) type;
387 syscallarg(const netbsd32_charp) path;
388 syscallarg(int) flags;
389 syscallarg(netbsd32_voidp) data;
390 } */
391 struct compat_40_sys_mount_args ua;
392
393 NETBSD32TOP_UAP(type, const char);
394 NETBSD32TOP_UAP(path, const char);
395 NETBSD32TO64_UAP(flags);
396 NETBSD32TOP_UAP(data, void);
397 return (compat_40_sys_mount(l, &ua, retval));
398 #else
399 return ENOSYS;
400 #endif
401 }
402
403 int
404 netbsd32_unmount(struct lwp *l, const struct netbsd32_unmount_args *uap, register_t *retval)
405 {
406 /* {
407 syscallarg(const netbsd32_charp) path;
408 syscallarg(int) flags;
409 } */
410 struct sys_unmount_args ua;
411
412 NETBSD32TOP_UAP(path, const char);
413 NETBSD32TO64_UAP(flags);
414 return (sys_unmount(l, &ua, retval));
415 }
416
417 int
418 netbsd32_setuid(struct lwp *l, const struct netbsd32_setuid_args *uap, register_t *retval)
419 {
420 /* {
421 syscallarg(uid_t) uid;
422 } */
423 struct sys_setuid_args ua;
424
425 NETBSD32TO64_UAP(uid);
426 return (sys_setuid(l, &ua, retval));
427 }
428
429 int
430 netbsd32_ptrace(struct lwp *l, const struct netbsd32_ptrace_args *uap, register_t *retval)
431 {
432 /* {
433 syscallarg(int) req;
434 syscallarg(pid_t) pid;
435 syscallarg(netbsd32_caddr_t) addr;
436 syscallarg(int) data;
437 } */
438 struct sys_ptrace_args ua;
439
440 NETBSD32TO64_UAP(req);
441 NETBSD32TO64_UAP(pid);
442 NETBSD32TOP_UAP(addr, void *);
443 NETBSD32TO64_UAP(data);
444
445 return (*sysent[SYS_ptrace].sy_call)(l, &ua, retval);
446 }
447
448 int
449 netbsd32_accept(struct lwp *l, const struct netbsd32_accept_args *uap, register_t *retval)
450 {
451 /* {
452 syscallarg(int) s;
453 syscallarg(netbsd32_sockaddrp_t) name;
454 syscallarg(netbsd32_intp) anamelen;
455 } */
456 struct sys_accept_args ua;
457
458 NETBSD32TO64_UAP(s);
459 NETBSD32TOP_UAP(name, struct sockaddr);
460 NETBSD32TOP_UAP(anamelen, socklen_t);
461 return (sys_accept(l, &ua, retval));
462 }
463
464 int
465 netbsd32_getpeername(struct lwp *l, const struct netbsd32_getpeername_args *uap, register_t *retval)
466 {
467 /* {
468 syscallarg(int) fdes;
469 syscallarg(netbsd32_sockaddrp_t) asa;
470 syscallarg(netbsd32_intp) alen;
471 } */
472 struct sys_getpeername_args ua;
473
474 NETBSD32TO64_UAP(fdes);
475 NETBSD32TOP_UAP(asa, struct sockaddr);
476 NETBSD32TOP_UAP(alen, socklen_t);
477 /* NB: do the protocol specific sockaddrs need to be converted? */
478 return (sys_getpeername(l, &ua, retval));
479 }
480
481 int
482 netbsd32_getsockname(struct lwp *l, const struct netbsd32_getsockname_args *uap, register_t *retval)
483 {
484 /* {
485 syscallarg(int) fdes;
486 syscallarg(netbsd32_sockaddrp_t) asa;
487 syscallarg(netbsd32_intp) alen;
488 } */
489 struct sys_getsockname_args ua;
490
491 NETBSD32TO64_UAP(fdes);
492 NETBSD32TOP_UAP(asa, struct sockaddr);
493 NETBSD32TOP_UAP(alen, socklen_t);
494 return (sys_getsockname(l, &ua, retval));
495 }
496
497 int
498 netbsd32_access(struct lwp *l, const struct netbsd32_access_args *uap, register_t *retval)
499 {
500 /* {
501 syscallarg(const netbsd32_charp) path;
502 syscallarg(int) flags;
503 } */
504 struct sys_access_args ua;
505
506 NETBSD32TOP_UAP(path, const char);
507 NETBSD32TO64_UAP(flags);
508
509 return sys_access(l, &ua, retval);
510 }
511
512 int
513 netbsd32_chflags(struct lwp *l, const struct netbsd32_chflags_args *uap, register_t *retval)
514 {
515 /* {
516 syscallarg(const netbsd32_charp) path;
517 syscallarg(netbsd32_u_long) flags;
518 } */
519 struct sys_chflags_args ua;
520
521 NETBSD32TOP_UAP(path, const char);
522 NETBSD32TO64_UAP(flags);
523
524 return (sys_chflags(l, &ua, retval));
525 }
526
527 int
528 netbsd32_fchflags(struct lwp *l, const struct netbsd32_fchflags_args *uap, register_t *retval)
529 {
530 /* {
531 syscallarg(int) fd;
532 syscallarg(netbsd32_u_long) flags;
533 } */
534 struct sys_fchflags_args ua;
535
536 NETBSD32TO64_UAP(fd);
537 NETBSD32TO64_UAP(flags);
538
539 return (sys_fchflags(l, &ua, retval));
540 }
541
542 int
543 netbsd32_lchflags(struct lwp *l, const struct netbsd32_lchflags_args *uap, register_t *retval)
544 {
545 /* {
546 syscallarg(const char *) path;
547 syscallarg(netbsd32_u_long) flags;
548 } */
549 struct sys_lchflags_args ua;
550
551 NETBSD32TOP_UAP(path, const char);
552 NETBSD32TO64_UAP(flags);
553
554 return (sys_lchflags(l, &ua, retval));
555 }
556
557 int
558 netbsd32_kill(struct lwp *l, const struct netbsd32_kill_args *uap, register_t *retval)
559 {
560 /* {
561 syscallarg(int) pid;
562 syscallarg(int) signum;
563 } */
564 struct sys_kill_args ua;
565
566 NETBSD32TO64_UAP(pid);
567 NETBSD32TO64_UAP(signum);
568
569 return (sys_kill(l, &ua, retval));
570 }
571
572 int
573 netbsd32_dup(struct lwp *l, const struct netbsd32_dup_args *uap, register_t *retval)
574 {
575 /* {
576 syscallarg(int) fd;
577 } */
578 struct sys_dup_args ua;
579
580 NETBSD32TO64_UAP(fd);
581
582 return (sys_dup(l, &ua, retval));
583 }
584
585 int
586 netbsd32_profil(struct lwp *l, const struct netbsd32_profil_args *uap, register_t *retval)
587 {
588 /* {
589 syscallarg(netbsd32_caddr_t) samples;
590 syscallarg(netbsd32_size_t) size;
591 syscallarg(netbsd32_u_long) offset;
592 syscallarg(u_int) scale;
593 } */
594 struct sys_profil_args ua;
595
596 NETBSD32TOP_UAP(samples, void *);
597 NETBSD32TOX_UAP(size, size_t);
598 NETBSD32TOX_UAP(offset, u_long);
599 NETBSD32TO64_UAP(scale);
600 return (sys_profil(l, &ua, retval));
601 }
602
603 int
604 netbsd32_ktrace(struct lwp *l, const struct netbsd32_ktrace_args *uap, register_t *retval)
605 {
606 /* {
607 syscallarg(const netbsd32_charp) fname;
608 syscallarg(int) ops;
609 syscallarg(int) facs;
610 syscallarg(int) pid;
611 } */
612 struct sys_ktrace_args ua;
613
614 NETBSD32TOP_UAP(fname, const char);
615 NETBSD32TO64_UAP(ops);
616 NETBSD32TO64_UAP(facs);
617 NETBSD32TO64_UAP(pid);
618 return (sys_ktrace(l, &ua, retval));
619 }
620
621 int
622 netbsd32_utrace(struct lwp *l, const struct netbsd32_utrace_args *uap, register_t *retval)
623 {
624 /* {
625 syscallarg(const netbsd32_charp) label;
626 syscallarg(netbsd32_voidp) addr;
627 syscallarg(netbsd32_size_t) len;
628 } */
629 struct sys_utrace_args ua;
630
631 NETBSD32TOP_UAP(label, const char);
632 NETBSD32TOP_UAP(addr, void);
633 NETBSD32TO64_UAP(len);
634 return (sys_utrace(l, &ua, retval));
635 }
636
637 int
638 netbsd32___getlogin(struct lwp *l, const struct netbsd32___getlogin_args *uap, register_t *retval)
639 {
640 /* {
641 syscallarg(netbsd32_charp) namebuf;
642 syscallarg(u_int) namelen;
643 } */
644 struct sys___getlogin_args ua;
645
646 NETBSD32TOP_UAP(namebuf, char);
647 NETBSD32TO64_UAP(namelen);
648 return (sys___getlogin(l, &ua, retval));
649 }
650
651 int
652 netbsd32_setlogin(struct lwp *l, const struct netbsd32_setlogin_args *uap, register_t *retval)
653 {
654 /* {
655 syscallarg(const netbsd32_charp) namebuf;
656 } */
657 struct sys___setlogin_args ua;
658
659 NETBSD32TOP_UAP(namebuf, char);
660 return (sys___setlogin(l, &ua, retval));
661 }
662
663 int
664 netbsd32_acct(struct lwp *l, const struct netbsd32_acct_args *uap, register_t *retval)
665 {
666 /* {
667 syscallarg(const netbsd32_charp) path;
668 } */
669 struct sys_acct_args ua;
670
671 NETBSD32TOP_UAP(path, const char);
672 return (sys_acct(l, &ua, retval));
673 }
674
675 int
676 netbsd32_revoke(struct lwp *l, const struct netbsd32_revoke_args *uap, register_t *retval)
677 {
678 /* {
679 syscallarg(const netbsd32_charp) path;
680 } */
681 struct sys_revoke_args ua;
682
683 NETBSD32TOP_UAP(path, const char);
684
685 return (sys_revoke(l, &ua, retval));
686 }
687
688 int
689 netbsd32_symlink(struct lwp *l, const struct netbsd32_symlink_args *uap, register_t *retval)
690 {
691 /* {
692 syscallarg(const netbsd32_charp) path;
693 syscallarg(const netbsd32_charp) link;
694 } */
695 struct sys_symlink_args ua;
696
697 NETBSD32TOP_UAP(path, const char);
698 NETBSD32TOP_UAP(link, const char);
699
700 return (sys_symlink(l, &ua, retval));
701 }
702
703 int
704 netbsd32_readlink(struct lwp *l, const struct netbsd32_readlink_args *uap, register_t *retval)
705 {
706 /* {
707 syscallarg(const netbsd32_charp) path;
708 syscallarg(netbsd32_charp) buf;
709 syscallarg(netbsd32_size_t) count;
710 } */
711 struct sys_readlink_args ua;
712
713 NETBSD32TOP_UAP(path, const char);
714 NETBSD32TOP_UAP(buf, char);
715 NETBSD32TOX_UAP(count, size_t);
716
717 return (sys_readlink(l, &ua, retval));
718 }
719
720 int
721 netbsd32_umask(struct lwp *l, const struct netbsd32_umask_args *uap, register_t *retval)
722 {
723 /* {
724 syscallarg(mode_t) newmask;
725 } */
726 struct sys_umask_args ua;
727
728 NETBSD32TO64_UAP(newmask);
729 return (sys_umask(l, &ua, retval));
730 }
731
732 int
733 netbsd32_chroot(struct lwp *l, const struct netbsd32_chroot_args *uap, register_t *retval)
734 {
735 /* {
736 syscallarg(const netbsd32_charp) path;
737 } */
738 struct sys_chroot_args ua;
739
740 NETBSD32TOP_UAP(path, const char);
741 return (sys_chroot(l, &ua, retval));
742 }
743
744 int
745 netbsd32_sbrk(struct lwp *l, const struct netbsd32_sbrk_args *uap, register_t *retval)
746 {
747 /* {
748 syscallarg(int) incr;
749 } */
750 struct sys_sbrk_args ua;
751
752 NETBSD32TO64_UAP(incr);
753 return (sys_sbrk(l, &ua, retval));
754 }
755
756 int
757 netbsd32_sstk(struct lwp *l, const struct netbsd32_sstk_args *uap, register_t *retval)
758 {
759 /* {
760 syscallarg(int) incr;
761 } */
762 struct sys_sstk_args ua;
763
764 NETBSD32TO64_UAP(incr);
765 return (sys_sstk(l, &ua, retval));
766 }
767
768 int
769 netbsd32_munmap(struct lwp *l, const struct netbsd32_munmap_args *uap, register_t *retval)
770 {
771 /* {
772 syscallarg(netbsd32_voidp) addr;
773 syscallarg(netbsd32_size_t) len;
774 } */
775 struct sys_munmap_args ua;
776
777 NETBSD32TOP_UAP(addr, void);
778 NETBSD32TOX_UAP(len, size_t);
779 return (sys_munmap(l, &ua, retval));
780 }
781
782 int
783 netbsd32_mprotect(struct lwp *l, const struct netbsd32_mprotect_args *uap, register_t *retval)
784 {
785 /* {
786 syscallarg(netbsd32_voidp) addr;
787 syscallarg(netbsd32_size_t) len;
788 syscallarg(int) prot;
789 } */
790 struct sys_mprotect_args ua;
791
792 NETBSD32TOP_UAP(addr, void);
793 NETBSD32TOX_UAP(len, size_t);
794 NETBSD32TO64_UAP(prot);
795 return (sys_mprotect(l, &ua, retval));
796 }
797
798 int
799 netbsd32_madvise(struct lwp *l, const struct netbsd32_madvise_args *uap, register_t *retval)
800 {
801 /* {
802 syscallarg(netbsd32_voidp) addr;
803 syscallarg(netbsd32_size_t) len;
804 syscallarg(int) behav;
805 } */
806 struct sys_madvise_args ua;
807
808 NETBSD32TOP_UAP(addr, void);
809 NETBSD32TOX_UAP(len, size_t);
810 NETBSD32TO64_UAP(behav);
811 return (sys_madvise(l, &ua, retval));
812 }
813
814 int
815 netbsd32_mincore(struct lwp *l, const struct netbsd32_mincore_args *uap, register_t *retval)
816 {
817 /* {
818 syscallarg(netbsd32_caddr_t) addr;
819 syscallarg(netbsd32_size_t) len;
820 syscallarg(netbsd32_charp) vec;
821 } */
822 struct sys_mincore_args ua;
823
824 NETBSD32TOP_UAP(addr, void *);
825 NETBSD32TOX_UAP(len, size_t);
826 NETBSD32TOP_UAP(vec, char);
827 return (sys_mincore(l, &ua, retval));
828 }
829
830 /* XXX MOVE ME XXX ? */
831 int
832 netbsd32_getgroups(struct lwp *l, const struct netbsd32_getgroups_args *uap, register_t *retval)
833 {
834 /* {
835 syscallarg(int) gidsetsize;
836 syscallarg(netbsd32_gid_tp) gidset;
837 } */
838 struct sys_getgroups_args ua;
839
840 /* Since sizeof (gid_t) == sizeof (netbsd32_gid_t) ... */
841
842 NETBSD32TO64_UAP(gidsetsize);
843 NETBSD32TOP_UAP(gidset, gid_t);
844 return (sys_getgroups(l, &ua, retval));
845 }
846
847 int
848 netbsd32_setgroups(struct lwp *l, const struct netbsd32_setgroups_args *uap, register_t *retval)
849 {
850 /* {
851 syscallarg(int) gidsetsize;
852 syscallarg(const netbsd32_gid_tp) gidset;
853 } */
854 struct sys_setgroups_args ua;
855
856 NETBSD32TO64_UAP(gidsetsize);
857 NETBSD32TOP_UAP(gidset, gid_t);
858 return (sys_setgroups(l, &ua, retval));
859 }
860
861 int
862 netbsd32_setpgid(struct lwp *l, const struct netbsd32_setpgid_args *uap, register_t *retval)
863 {
864 /* {
865 syscallarg(int) pid;
866 syscallarg(int) pgid;
867 } */
868 struct sys_setpgid_args ua;
869
870 NETBSD32TO64_UAP(pid);
871 NETBSD32TO64_UAP(pgid);
872 return (sys_setpgid(l, &ua, retval));
873 }
874
875 int
876 netbsd32_fcntl(struct lwp *l, const struct netbsd32_fcntl_args *uap, register_t *retval)
877 {
878 /* {
879 syscallarg(int) fd;
880 syscallarg(int) cmd;
881 syscallarg(netbsd32_voidp) arg;
882 } */
883 struct sys_fcntl_args ua;
884
885 NETBSD32TO64_UAP(fd);
886 NETBSD32TO64_UAP(cmd);
887 NETBSD32TOP_UAP(arg, void);
888 /* we can do this because `struct flock' doesn't change */
889 return (sys_fcntl(l, &ua, retval));
890 }
891
892 int
893 netbsd32_dup2(struct lwp *l, const struct netbsd32_dup2_args *uap, register_t *retval)
894 {
895 /* {
896 syscallarg(int) from;
897 syscallarg(int) to;
898 } */
899 struct sys_dup2_args ua;
900
901 NETBSD32TO64_UAP(from);
902 NETBSD32TO64_UAP(to);
903 return (sys_dup2(l, &ua, retval));
904 }
905
906 int
907 netbsd32_fsync(struct lwp *l, const struct netbsd32_fsync_args *uap, register_t *retval)
908 {
909 /* {
910 syscallarg(int) fd;
911 } */
912 struct sys_fsync_args ua;
913
914 NETBSD32TO64_UAP(fd);
915 return (sys_fsync(l, &ua, retval));
916 }
917
918 int
919 netbsd32_setpriority(struct lwp *l, const struct netbsd32_setpriority_args *uap, register_t *retval)
920 {
921 /* {
922 syscallarg(int) which;
923 syscallarg(int) who;
924 syscallarg(int) prio;
925 } */
926 struct sys_setpriority_args ua;
927
928 NETBSD32TO64_UAP(which);
929 NETBSD32TO64_UAP(who);
930 NETBSD32TO64_UAP(prio);
931 return (sys_setpriority(l, &ua, retval));
932 }
933
934 int
935 netbsd32_sys___socket30(struct lwp *l, const struct netbsd32_sys___socket30_args *uap, register_t *retval)
936 {
937 /* {
938 syscallarg(int) domain;
939 syscallarg(int) type;
940 syscallarg(int) protocol;
941 } */
942 struct sys___socket30_args ua;
943
944 NETBSD32TO64_UAP(domain);
945 NETBSD32TO64_UAP(type);
946 NETBSD32TO64_UAP(protocol);
947 return (sys___socket30(l, &ua, retval));
948 }
949
950 int
951 netbsd32_connect(struct lwp *l, const struct netbsd32_connect_args *uap, register_t *retval)
952 {
953 /* {
954 syscallarg(int) s;
955 syscallarg(const netbsd32_sockaddrp_t) name;
956 syscallarg(int) namelen;
957 } */
958 struct sys_connect_args ua;
959
960 NETBSD32TO64_UAP(s);
961 NETBSD32TOP_UAP(name, struct sockaddr);
962 NETBSD32TO64_UAP(namelen);
963 return (sys_connect(l, &ua, retval));
964 }
965
966 int
967 netbsd32_getpriority(struct lwp *l, const struct netbsd32_getpriority_args *uap, register_t *retval)
968 {
969 /* {
970 syscallarg(int) which;
971 syscallarg(int) who;
972 } */
973 struct sys_getpriority_args ua;
974
975 NETBSD32TO64_UAP(which);
976 NETBSD32TO64_UAP(who);
977 return (sys_getpriority(l, &ua, retval));
978 }
979
980 int
981 netbsd32_bind(struct lwp *l, const struct netbsd32_bind_args *uap, register_t *retval)
982 {
983 /* {
984 syscallarg(int) s;
985 syscallarg(const netbsd32_sockaddrp_t) name;
986 syscallarg(int) namelen;
987 } */
988 struct sys_bind_args ua;
989
990 NETBSD32TO64_UAP(s);
991 NETBSD32TOP_UAP(name, struct sockaddr);
992 NETBSD32TO64_UAP(namelen);
993 return (sys_bind(l, &ua, retval));
994 }
995
996 int
997 netbsd32_setsockopt(struct lwp *l, const struct netbsd32_setsockopt_args *uap, register_t *retval)
998 {
999 /* {
1000 syscallarg(int) s;
1001 syscallarg(int) level;
1002 syscallarg(int) name;
1003 syscallarg(const netbsd32_voidp) val;
1004 syscallarg(int) valsize;
1005 } */
1006 struct sys_setsockopt_args ua;
1007
1008 NETBSD32TO64_UAP(s);
1009 NETBSD32TO64_UAP(level);
1010 NETBSD32TO64_UAP(name);
1011 NETBSD32TOP_UAP(val, void);
1012 NETBSD32TO64_UAP(valsize);
1013 /* may be more efficient to do this inline. */
1014 return (sys_setsockopt(l, &ua, retval));
1015 }
1016
1017 int
1018 netbsd32_listen(struct lwp *l, const struct netbsd32_listen_args *uap, register_t *retval)
1019 {
1020 /* {
1021 syscallarg(int) s;
1022 syscallarg(int) backlog;
1023 } */
1024 struct sys_listen_args ua;
1025
1026 NETBSD32TO64_UAP(s);
1027 NETBSD32TO64_UAP(backlog);
1028 return (sys_listen(l, &ua, retval));
1029 }
1030
1031 int
1032 netbsd32_fchown(struct lwp *l, const struct netbsd32_fchown_args *uap, register_t *retval)
1033 {
1034 /* {
1035 syscallarg(int) fd;
1036 syscallarg(uid_t) uid;
1037 syscallarg(gid_t) gid;
1038 } */
1039 struct sys_fchown_args ua;
1040
1041 NETBSD32TO64_UAP(fd);
1042 NETBSD32TO64_UAP(uid);
1043 NETBSD32TO64_UAP(gid);
1044 return (sys_fchown(l, &ua, retval));
1045 }
1046
1047 int
1048 netbsd32_fchmod(struct lwp *l, const struct netbsd32_fchmod_args *uap, register_t *retval)
1049 {
1050 /* {
1051 syscallarg(int) fd;
1052 syscallarg(mode_t) mode;
1053 } */
1054 struct sys_fchmod_args ua;
1055
1056 NETBSD32TO64_UAP(fd);
1057 NETBSD32TO64_UAP(mode);
1058 return (sys_fchmod(l, &ua, retval));
1059 }
1060
1061 int
1062 netbsd32_setreuid(struct lwp *l, const struct netbsd32_setreuid_args *uap, register_t *retval)
1063 {
1064 /* {
1065 syscallarg(uid_t) ruid;
1066 syscallarg(uid_t) euid;
1067 } */
1068 struct sys_setreuid_args ua;
1069
1070 NETBSD32TO64_UAP(ruid);
1071 NETBSD32TO64_UAP(euid);
1072 return (sys_setreuid(l, &ua, retval));
1073 }
1074
1075 int
1076 netbsd32_setregid(struct lwp *l, const struct netbsd32_setregid_args *uap, register_t *retval)
1077 {
1078 /* {
1079 syscallarg(gid_t) rgid;
1080 syscallarg(gid_t) egid;
1081 } */
1082 struct sys_setregid_args ua;
1083
1084 NETBSD32TO64_UAP(rgid);
1085 NETBSD32TO64_UAP(egid);
1086 return (sys_setregid(l, &ua, retval));
1087 }
1088
1089 int
1090 netbsd32_getsockopt(struct lwp *l, const struct netbsd32_getsockopt_args *uap, register_t *retval)
1091 {
1092 /* {
1093 syscallarg(int) s;
1094 syscallarg(int) level;
1095 syscallarg(int) name;
1096 syscallarg(netbsd32_voidp) val;
1097 syscallarg(netbsd32_intp) avalsize;
1098 } */
1099 struct sys_getsockopt_args ua;
1100
1101 NETBSD32TO64_UAP(s);
1102 NETBSD32TO64_UAP(level);
1103 NETBSD32TO64_UAP(name);
1104 NETBSD32TOP_UAP(val, void);
1105 NETBSD32TOP_UAP(avalsize, socklen_t);
1106 return (sys_getsockopt(l, &ua, retval));
1107 }
1108
1109 int
1110 netbsd32_rename(struct lwp *l, const struct netbsd32_rename_args *uap, register_t *retval)
1111 {
1112 /* {
1113 syscallarg(const netbsd32_charp) from;
1114 syscallarg(const netbsd32_charp) to;
1115 } */
1116 struct sys_rename_args ua;
1117
1118 NETBSD32TOP_UAP(from, const char);
1119 NETBSD32TOP_UAP(to, const char)
1120
1121 return (sys_rename(l, &ua, retval));
1122 }
1123
1124 int
1125 netbsd32_flock(struct lwp *l, const struct netbsd32_flock_args *uap, register_t *retval)
1126 {
1127 /* {
1128 syscallarg(int) fd;
1129 syscallarg(int) how;
1130 } */
1131 struct sys_flock_args ua;
1132
1133 NETBSD32TO64_UAP(fd);
1134 NETBSD32TO64_UAP(how)
1135
1136 return (sys_flock(l, &ua, retval));
1137 }
1138
1139 int
1140 netbsd32_mkfifo(struct lwp *l, const struct netbsd32_mkfifo_args *uap, register_t *retval)
1141 {
1142 /* {
1143 syscallarg(const netbsd32_charp) path;
1144 syscallarg(mode_t) mode;
1145 } */
1146 struct sys_mkfifo_args ua;
1147
1148 NETBSD32TOP_UAP(path, const char)
1149 NETBSD32TO64_UAP(mode);
1150 return (sys_mkfifo(l, &ua, retval));
1151 }
1152
1153 int
1154 netbsd32_shutdown(struct lwp *l, const struct netbsd32_shutdown_args *uap, register_t *retval)
1155 {
1156 /* {
1157 syscallarg(int) s;
1158 syscallarg(int) how;
1159 } */
1160 struct sys_shutdown_args ua;
1161
1162 NETBSD32TO64_UAP(s)
1163 NETBSD32TO64_UAP(how);
1164 return (sys_shutdown(l, &ua, retval));
1165 }
1166
1167 int
1168 netbsd32_socketpair(struct lwp *l, const struct netbsd32_socketpair_args *uap, register_t *retval)
1169 {
1170 /* {
1171 syscallarg(int) domain;
1172 syscallarg(int) type;
1173 syscallarg(int) protocol;
1174 syscallarg(netbsd32_intp) rsv;
1175 } */
1176 struct sys_socketpair_args ua;
1177
1178 NETBSD32TO64_UAP(domain);
1179 NETBSD32TO64_UAP(type);
1180 NETBSD32TO64_UAP(protocol);
1181 NETBSD32TOP_UAP(rsv, int);
1182 /* Since we're just copying out two `int's we can do this */
1183 return (sys_socketpair(l, &ua, retval));
1184 }
1185
1186 int
1187 netbsd32_mkdir(struct lwp *l, const struct netbsd32_mkdir_args *uap, register_t *retval)
1188 {
1189 /* {
1190 syscallarg(const netbsd32_charp) path;
1191 syscallarg(mode_t) mode;
1192 } */
1193 struct sys_mkdir_args ua;
1194
1195 NETBSD32TOP_UAP(path, const char)
1196 NETBSD32TO64_UAP(mode);
1197 return (sys_mkdir(l, &ua, retval));
1198 }
1199
1200 int
1201 netbsd32_rmdir(struct lwp *l, const struct netbsd32_rmdir_args *uap, register_t *retval)
1202 {
1203 /* {
1204 syscallarg(const netbsd32_charp) path;
1205 } */
1206 struct sys_rmdir_args ua;
1207
1208 NETBSD32TOP_UAP(path, const char);
1209 return (sys_rmdir(l, &ua, retval));
1210 }
1211
1212 int
1213 netbsd32_quotactl(struct lwp *l, const struct netbsd32_quotactl_args *uap, register_t *retval)
1214 {
1215 /* {
1216 syscallarg(const netbsd32_charp) path;
1217 syscallarg(int) cmd;
1218 syscallarg(int) uid;
1219 syscallarg(netbsd32_caddr_t) arg;
1220 } */
1221 struct sys_quotactl_args ua;
1222
1223 NETBSD32TOP_UAP(path, const char);
1224 NETBSD32TO64_UAP(cmd);
1225 NETBSD32TO64_UAP(uid);
1226 NETBSD32TOP_UAP(arg, void *);
1227 return (sys_quotactl(l, &ua, retval));
1228 }
1229
1230 int
1231 netbsd32_nfssvc(struct lwp *l, const struct netbsd32_nfssvc_args *uap, register_t *retval)
1232 {
1233 #if 0
1234 /* {
1235 syscallarg(int) flag;
1236 syscallarg(netbsd32_voidp) argp;
1237 } */
1238 struct sys_nfssvc_args ua;
1239
1240 NETBSD32TO64_UAP(flag);
1241 NETBSD32TOP_UAP(argp, void);
1242 return (sys_nfssvc(l, &ua, retval));
1243 #else
1244 /* Why would we want to support a 32-bit nfsd? */
1245 return (ENOSYS);
1246 #endif
1247 }
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 int
2532 netbsd32__sched_setparam(struct lwp *l,
2533 const struct netbsd32__sched_setparam_args *uap,
2534 register_t *retval)
2535 {
2536 /* {
2537 syscallarg(pid_t) pid;
2538 syscallarg(lwpid_t) lid;
2539 syscallarg(int) policy;
2540 syscallarg(const netbsd32_sched_paramp_t) params;
2541 } */
2542 struct sys__sched_setparam_args ua;
2543
2544 NETBSD32TO64_UAP(pid);
2545 NETBSD32TO64_UAP(lid);
2546 NETBSD32TO64_UAP(policy);
2547 NETBSD32TOP_UAP(params, const struct sched_param *);
2548 return sys__sched_setparam(l, &ua, retval);
2549 }
2550
2551 int
2552 netbsd32__sched_getparam(struct lwp *l,
2553 const struct netbsd32__sched_getparam_args *uap,
2554 register_t *retval)
2555 {
2556 /* {
2557 syscallarg(pid_t) pid;
2558 syscallarg(lwpid_t) lid;
2559 syscallarg(netbsd32_intp) policy;
2560 syscallarg(netbsd32_sched_paramp_t) params;
2561 } */
2562 struct sys__sched_getparam_args ua;
2563
2564 NETBSD32TO64_UAP(pid);
2565 NETBSD32TO64_UAP(lid);
2566 NETBSD32TOP_UAP(policy, int *);
2567 NETBSD32TOP_UAP(params, struct sched_param *);
2568 return sys__sched_getparam(l, &ua, retval);
2569 }
2570
2571 int
2572 netbsd32__sched_setaffinity(struct lwp *l,
2573 const struct netbsd32__sched_setaffinity_args *uap,
2574 register_t *retval)
2575 {
2576 /* {
2577 syscallarg(pid_t) pid;
2578 syscallarg(lwpid_t) lid;
2579 syscallarg(netbsd_size_t) size;
2580 syscallarg(const netbsd32_cpusetp_t) cpuset;
2581 } */
2582 struct sys__sched_setaffinity_args ua;
2583
2584 NETBSD32TO64_UAP(pid);
2585 NETBSD32TO64_UAP(lid);
2586 NETBSD32TOX_UAP(size, size_t);
2587 NETBSD32TOP_UAP(cpuset, const cpuset_t *);
2588 return sys__sched_setaffinity(l, &ua, retval);
2589 }
2590
2591 int
2592 netbsd32__sched_getaffinity(struct lwp *l,
2593 const struct netbsd32__sched_getaffinity_args *uap,
2594 register_t *retval)
2595 {
2596 /* {
2597 syscallarg(pid_t) pid;
2598 syscallarg(lwpid_t) lid;
2599 syscallarg(netbsd_size_t) size;
2600 syscallarg(netbsd32_cpusetp_t) cpuset;
2601 } */
2602 struct sys__sched_getaffinity_args ua;
2603
2604 NETBSD32TO64_UAP(pid);
2605 NETBSD32TO64_UAP(lid);
2606 NETBSD32TOX_UAP(size, size_t);
2607 NETBSD32TOP_UAP(cpuset, cpuset_t *);
2608 return sys__sched_getaffinity(l, &ua, retval);
2609 }
2610
2611 /*
2612 * MI indirect system call support.
2613 * Only used if the MD netbsd32_syscall.c doesn't intercept the calls.
2614 */
2615
2616 #define NETBSD32_SYSCALL
2617 #undef SYS_NSYSENT
2618 #define SYS_NSYSENT NETBSD32_SYS_NSYSENT
2619
2620 #define SYS_SYSCALL netbsd32_sys_syscall
2621 #include "../../kern/sys_syscall.c"
2622 #undef SYS_SYSCALL
2623
2624 #define SYS_SYSCALL netbsd32_sys___syscall
2625 #include "../../kern/sys_syscall.c"
2626 #undef SYS_SYSCALL
2627