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