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