1 /* $NetBSD: netbsd32_netbsd.c,v 1.228 2019/06/20 03:31:54 kamil 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.228 2019/06/20 03:31:54 kamil 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_pathconf(struct lwp *l, const struct netbsd32_pathconf_args *uap, register_t *retval) 1257 { 1258 /* { 1259 syscallarg(netbsd32_charp) path; 1260 syscallarg(int) name; 1261 } */ 1262 struct sys_pathconf_args ua; 1263 1264 NETBSD32TOP_UAP(path, const char); 1265 NETBSD32TO64_UAP(name); 1266 1267 return sys_pathconf(l, &ua, retval); 1268 } 1269 1270 int 1271 netbsd32_fpathconf(struct lwp *l, const struct netbsd32_fpathconf_args *uap, register_t *retval) 1272 { 1273 /* { 1274 syscallarg(int) fd; 1275 syscallarg(int) name; 1276 } */ 1277 struct sys_fpathconf_args ua; 1278 1279 NETBSD32TO64_UAP(fd); 1280 NETBSD32TO64_UAP(name); 1281 1282 return sys_fpathconf(l, &ua, retval); 1283 } 1284 1285 int 1286 netbsd32_mremap(struct lwp *l, const struct netbsd32_mremap_args *uap, register_t *retval) 1287 { 1288 /* { 1289 syscallarg(void *) old_address; 1290 syscallarg(size_t) old_size; 1291 syscallarg(void *) new_address; 1292 syscallarg(size_t) new_size; 1293 syscallarg(int) flags; 1294 } */ 1295 struct sys_mremap_args ua; 1296 1297 NETBSD32TOP_UAP(old_address, void); 1298 NETBSD32TOX_UAP(old_size, size_t); 1299 NETBSD32TOP_UAP(new_address, void); 1300 NETBSD32TOX_UAP(new_size, size_t); 1301 NETBSD32TO64_UAP(flags); 1302 1303 return sys_mremap(l, &ua, retval); 1304 } 1305 1306 int 1307 netbsd32_lseek(struct lwp *l, const struct netbsd32_lseek_args *uap, register_t *retval) 1308 { 1309 /* { 1310 syscallarg(int) fd; 1311 syscallarg(int) PAD; 1312 syscallarg(netbsd32_off_t) offset; 1313 syscallarg(int) whence; 1314 } */ 1315 struct sys_lseek_args ua; 1316 union { 1317 register_t retval64[2]; 1318 register32_t retval32[4]; 1319 } newpos; 1320 int rv; 1321 1322 NETBSD32TO64_UAP(fd); 1323 NETBSD32TO64_UAP(PAD); 1324 NETBSD32TO64_UAP(offset); 1325 NETBSD32TO64_UAP(whence); 1326 rv = sys_lseek(l, &ua, newpos.retval64); 1327 1328 /* 1329 * We have to split the 64 bit value into 2 halves which will 1330 * end up in separate 32 bit registers. 1331 * This should DTRT on big and little-endian systems provided that 1332 * gcc's 'strict aliasing' tests don't decide that the retval32[] 1333 * entries can't have been assigned to, so need not be read! 1334 */ 1335 retval[0] = newpos.retval32[0]; 1336 retval[1] = newpos.retval32[1]; 1337 1338 return rv; 1339 } 1340 1341 int 1342 netbsd32_truncate(struct lwp *l, const struct netbsd32_truncate_args *uap, register_t *retval) 1343 { 1344 /* { 1345 syscallarg(const netbsd32_charp) path; 1346 syscallarg(int) PAD; 1347 syscallarg(netbsd32_off_t) length; 1348 } */ 1349 struct sys_truncate_args ua; 1350 1351 NETBSD32TOP_UAP(path, const char); 1352 NETBSD32TO64_UAP(PAD); 1353 NETBSD32TO64_UAP(length); 1354 1355 return sys_truncate(l, &ua, retval); 1356 } 1357 1358 int 1359 netbsd32_ftruncate(struct lwp *l, const struct netbsd32_ftruncate_args *uap, register_t *retval) 1360 { 1361 /* { 1362 syscallarg(int) fd; 1363 syscallarg(int) PAD; 1364 syscallarg(netbsd32_off_t) length; 1365 } */ 1366 struct sys_ftruncate_args ua; 1367 1368 NETBSD32TO64_UAP(fd); 1369 NETBSD32TO64_UAP(PAD); 1370 NETBSD32TO64_UAP(length); 1371 1372 return sys_ftruncate(l, &ua, retval); 1373 } 1374 1375 int 1376 netbsd32_mlock(struct lwp *l, const struct netbsd32_mlock_args *uap, register_t *retval) 1377 { 1378 /* { 1379 syscallarg(const netbsd32_voidp) addr; 1380 syscallarg(netbsd32_size_t) len; 1381 } */ 1382 struct sys_mlock_args ua; 1383 1384 NETBSD32TOP_UAP(addr, const void); 1385 NETBSD32TO64_UAP(len); 1386 1387 return sys_mlock(l, &ua, retval); 1388 } 1389 1390 int 1391 netbsd32_munlock(struct lwp *l, const struct netbsd32_munlock_args *uap, register_t *retval) 1392 { 1393 /* { 1394 syscallarg(const netbsd32_voidp) addr; 1395 syscallarg(netbsd32_size_t) len; 1396 } */ 1397 struct sys_munlock_args ua; 1398 1399 NETBSD32TOP_UAP(addr, const void); 1400 NETBSD32TO64_UAP(len); 1401 1402 return sys_munlock(l, &ua, retval); 1403 } 1404 1405 int 1406 netbsd32_undelete(struct lwp *l, const struct netbsd32_undelete_args *uap, register_t *retval) 1407 { 1408 /* { 1409 syscallarg(const netbsd32_charp) path; 1410 } */ 1411 struct sys_undelete_args ua; 1412 1413 NETBSD32TOP_UAP(path, const char); 1414 1415 return sys_undelete(l, &ua, retval); 1416 } 1417 1418 int 1419 netbsd32_getpgid(struct lwp *l, const struct netbsd32_getpgid_args *uap, register_t *retval) 1420 { 1421 /* { 1422 syscallarg(pid_t) pid; 1423 } */ 1424 struct sys_getpgid_args ua; 1425 1426 NETBSD32TO64_UAP(pid); 1427 1428 return sys_getpgid(l, &ua, retval); 1429 } 1430 1431 int 1432 netbsd32_reboot(struct lwp *l, const struct netbsd32_reboot_args *uap, register_t *retval) 1433 { 1434 /* { 1435 syscallarg(int) opt; 1436 syscallarg(netbsd32_charp) bootstr; 1437 } */ 1438 struct sys_reboot_args ua; 1439 1440 NETBSD32TO64_UAP(opt); 1441 NETBSD32TOP_UAP(bootstr, char); 1442 1443 return sys_reboot(l, &ua, retval); 1444 } 1445 1446 #include <sys/poll.h> 1447 int 1448 netbsd32_poll(struct lwp *l, const struct netbsd32_poll_args *uap, register_t *retval) 1449 { 1450 /* { 1451 syscallarg(netbsd32_pollfdp_t) fds; 1452 syscallarg(u_int) nfds; 1453 syscallarg(int) timeout; 1454 } */ 1455 struct sys_poll_args ua; 1456 1457 NETBSD32TOP_UAP(fds, struct pollfd); 1458 NETBSD32TO64_UAP(nfds); 1459 NETBSD32TO64_UAP(timeout); 1460 1461 return sys_poll(l, &ua, retval); 1462 } 1463 1464 int 1465 netbsd32_fdatasync(struct lwp *l, const struct netbsd32_fdatasync_args *uap, register_t *retval) 1466 { 1467 /* { 1468 syscallarg(int) fd; 1469 } */ 1470 struct sys_fdatasync_args ua; 1471 1472 NETBSD32TO64_UAP(fd); 1473 1474 return sys_fdatasync(l, &ua, retval); 1475 } 1476 1477 int 1478 netbsd32___posix_rename(struct lwp *l, const struct netbsd32___posix_rename_args *uap, register_t *retval) 1479 { 1480 /* { 1481 syscallarg(const netbsd32_charp) from; 1482 syscallarg(const netbsd32_charp) to; 1483 } */ 1484 struct sys___posix_rename_args ua; 1485 1486 NETBSD32TOP_UAP(from, const char); 1487 NETBSD32TOP_UAP(to, const char); 1488 1489 return sys___posix_rename(l, &ua, retval); 1490 } 1491 1492 static void 1493 swapent32_cvt(void *p, const struct swapent *se) 1494 { 1495 struct netbsd32_swapent *se32 = p; 1496 1497 se32->se_dev = se->se_dev; 1498 se32->se_flags = se->se_flags; 1499 se32->se_nblks = se->se_nblks; 1500 se32->se_inuse = se->se_inuse; 1501 se32->se_priority = se->se_priority; 1502 KASSERT(sizeof(se->se_path) <= sizeof(se32->se_path)); 1503 strcpy(se32->se_path, se->se_path); 1504 } 1505 1506 int 1507 netbsd32_swapctl(struct lwp *l, const struct netbsd32_swapctl_args *uap, 1508 register_t *retval) 1509 { 1510 /* { 1511 syscallarg(int) cmd; 1512 syscallarg(const netbsd32_voidp) arg; 1513 syscallarg(int) misc; 1514 } */ 1515 struct sys_swapctl_args ua; 1516 1517 NETBSD32TO64_UAP(cmd); 1518 NETBSD32TOP_UAP(arg, void); 1519 NETBSD32TO64_UAP(misc); 1520 1521 /* SWAP_STATS50 and SWAP_STATS13 structures need no translation */ 1522 if (SCARG(&ua, cmd) == SWAP_STATS) { 1523 swapsys_lock(RW_READER); 1524 int error = uvm_swap_stats(SCARG(&ua, arg), SCARG(&ua, misc), 1525 swapent32_cvt, sizeof(struct netbsd32_swapent), retval); 1526 swapsys_unlock(); 1527 return error; 1528 } 1529 1530 return sys_swapctl(l, &ua, retval); 1531 } 1532 1533 int 1534 netbsd32_minherit(struct lwp *l, const struct netbsd32_minherit_args *uap, register_t *retval) 1535 { 1536 /* { 1537 syscallarg(netbsd32_voidp) addr; 1538 syscallarg(netbsd32_size_t) len; 1539 syscallarg(int) inherit; 1540 } */ 1541 struct sys_minherit_args ua; 1542 1543 NETBSD32TOP_UAP(addr, void); 1544 NETBSD32TOX_UAP(len, size_t); 1545 NETBSD32TO64_UAP(inherit); 1546 1547 return sys_minherit(l, &ua, retval); 1548 } 1549 1550 int 1551 netbsd32_lchmod(struct lwp *l, const struct netbsd32_lchmod_args *uap, register_t *retval) 1552 { 1553 /* { 1554 syscallarg(const netbsd32_charp) path; 1555 syscallarg(mode_t) mode; 1556 } */ 1557 struct sys_lchmod_args ua; 1558 1559 NETBSD32TOP_UAP(path, const char); 1560 NETBSD32TO64_UAP(mode); 1561 1562 return sys_lchmod(l, &ua, retval); 1563 } 1564 1565 int 1566 netbsd32_lchown(struct lwp *l, const struct netbsd32_lchown_args *uap, register_t *retval) 1567 { 1568 /* { 1569 syscallarg(const netbsd32_charp) path; 1570 syscallarg(uid_t) uid; 1571 syscallarg(gid_t) gid; 1572 } */ 1573 struct sys_lchown_args ua; 1574 1575 NETBSD32TOP_UAP(path, const char); 1576 NETBSD32TO64_UAP(uid); 1577 NETBSD32TO64_UAP(gid); 1578 1579 return sys_lchown(l, &ua, retval); 1580 } 1581 1582 int 1583 netbsd32___msync13(struct lwp *l, const struct netbsd32___msync13_args *uap, register_t *retval) 1584 { 1585 /* { 1586 syscallarg(netbsd32_voidp) addr; 1587 syscallarg(netbsd32_size_t) len; 1588 syscallarg(int) flags; 1589 } */ 1590 struct sys___msync13_args ua; 1591 1592 NETBSD32TOP_UAP(addr, void); 1593 NETBSD32TOX_UAP(len, size_t); 1594 NETBSD32TO64_UAP(flags); 1595 1596 return sys___msync13(l, &ua, retval); 1597 } 1598 1599 int 1600 netbsd32___posix_chown(struct lwp *l, const struct netbsd32___posix_chown_args *uap, register_t *retval) 1601 { 1602 /* { 1603 syscallarg(const netbsd32_charp) path; 1604 syscallarg(uid_t) uid; 1605 syscallarg(gid_t) gid; 1606 } */ 1607 struct sys___posix_chown_args ua; 1608 1609 NETBSD32TOP_UAP(path, const char); 1610 NETBSD32TO64_UAP(uid); 1611 NETBSD32TO64_UAP(gid); 1612 1613 return sys___posix_chown(l, &ua, retval); 1614 } 1615 1616 int 1617 netbsd32___posix_fchown(struct lwp *l, const struct netbsd32___posix_fchown_args *uap, register_t *retval) 1618 { 1619 /* { 1620 syscallarg(int) fd; 1621 syscallarg(uid_t) uid; 1622 syscallarg(gid_t) gid; 1623 } */ 1624 struct sys___posix_fchown_args ua; 1625 1626 NETBSD32TO64_UAP(fd); 1627 NETBSD32TO64_UAP(uid); 1628 NETBSD32TO64_UAP(gid); 1629 1630 return sys___posix_fchown(l, &ua, retval); 1631 } 1632 1633 int 1634 netbsd32___posix_lchown(struct lwp *l, const struct netbsd32___posix_lchown_args *uap, register_t *retval) 1635 { 1636 /* { 1637 syscallarg(const netbsd32_charp) path; 1638 syscallarg(uid_t) uid; 1639 syscallarg(gid_t) gid; 1640 } */ 1641 struct sys___posix_lchown_args ua; 1642 1643 NETBSD32TOP_UAP(path, const char); 1644 NETBSD32TO64_UAP(uid); 1645 NETBSD32TO64_UAP(gid); 1646 1647 return sys___posix_lchown(l, &ua, retval); 1648 } 1649 1650 int 1651 netbsd32_getsid(struct lwp *l, const struct netbsd32_getsid_args *uap, register_t *retval) 1652 { 1653 /* { 1654 syscallarg(pid_t) pid; 1655 } */ 1656 struct sys_getsid_args ua; 1657 1658 NETBSD32TO64_UAP(pid); 1659 1660 return sys_getsid(l, &ua, retval); 1661 } 1662 1663 int 1664 netbsd32_fktrace(struct lwp *l, const struct netbsd32_fktrace_args *uap, register_t *retval) 1665 { 1666 /* { 1667 syscallarg(int) fd; 1668 syscallarg(int) ops; 1669 syscallarg(int) facs; 1670 syscallarg(int) pid; 1671 } */ 1672 struct sys_fktrace_args ua; 1673 1674 NETBSD32TOX_UAP(fd, int); 1675 NETBSD32TO64_UAP(ops); 1676 NETBSD32TO64_UAP(facs); 1677 NETBSD32TO64_UAP(pid); 1678 1679 return sys_fktrace(l, &ua, retval); 1680 } 1681 1682 int 1683 netbsd32___sigpending14(struct lwp *l, const struct netbsd32___sigpending14_args *uap, register_t *retval) 1684 { 1685 /* { 1686 syscallarg(sigset_t *) set; 1687 } */ 1688 struct sys___sigpending14_args ua; 1689 1690 NETBSD32TOP_UAP(set, sigset_t); 1691 1692 return sys___sigpending14(l, &ua, retval); 1693 } 1694 1695 int 1696 netbsd32___sigprocmask14(struct lwp *l, const struct netbsd32___sigprocmask14_args *uap, register_t *retval) 1697 { 1698 /* { 1699 syscallarg(int) how; 1700 syscallarg(const sigset_t *) set; 1701 syscallarg(sigset_t *) oset; 1702 } */ 1703 struct sys___sigprocmask14_args ua; 1704 1705 NETBSD32TO64_UAP(how); 1706 NETBSD32TOP_UAP(set, sigset_t); 1707 NETBSD32TOP_UAP(oset, sigset_t); 1708 1709 return sys___sigprocmask14(l, &ua, retval); 1710 } 1711 1712 int 1713 netbsd32___sigsuspend14(struct lwp *l, const struct netbsd32___sigsuspend14_args *uap, register_t *retval) 1714 { 1715 /* { 1716 syscallarg(const sigset_t *) set; 1717 } */ 1718 struct sys___sigsuspend14_args ua; 1719 1720 NETBSD32TOP_UAP(set, sigset_t); 1721 1722 return sys___sigsuspend14(l, &ua, retval); 1723 } 1724 1725 int 1726 netbsd32_fchroot(struct lwp *l, const struct netbsd32_fchroot_args *uap, register_t *retval) 1727 { 1728 /* { 1729 syscallarg(int) fd; 1730 } */ 1731 struct sys_fchroot_args ua; 1732 1733 NETBSD32TO64_UAP(fd); 1734 1735 return sys_fchroot(l, &ua, retval); 1736 } 1737 1738 /* 1739 * Open a file given a file handle. 1740 * 1741 * Check permissions, allocate an open file structure, 1742 * and call the device open routine if any. 1743 */ 1744 int 1745 netbsd32___fhopen40(struct lwp *l, const struct netbsd32___fhopen40_args *uap, register_t *retval) 1746 { 1747 /* { 1748 syscallarg(const netbsd32_pointer_t *) fhp; 1749 syscallarg(netbsd32_size_t) fh_size; 1750 syscallarg(int) flags; 1751 } */ 1752 struct sys___fhopen40_args ua; 1753 1754 NETBSD32TOP_UAP(fhp, fhandle_t); 1755 NETBSD32TO64_UAP(fh_size); 1756 NETBSD32TO64_UAP(flags); 1757 1758 return sys___fhopen40(l, &ua, retval); 1759 } 1760 1761 /* virtual memory syscalls */ 1762 int 1763 netbsd32_ovadvise(struct lwp *l, const struct netbsd32_ovadvise_args *uap, register_t *retval) 1764 { 1765 /* { 1766 syscallarg(int) anom; 1767 } */ 1768 struct sys_ovadvise_args ua; 1769 1770 NETBSD32TO64_UAP(anom); 1771 1772 return sys_ovadvise(l, &ua, retval); 1773 } 1774 1775 int 1776 netbsd32_uuidgen(struct lwp *l, const struct netbsd32_uuidgen_args *uap, register_t *retval) 1777 { 1778 /* { 1779 syscallarg(netbsd32_uuidp_t) store; 1780 syscallarg(int) count; 1781 } */ 1782 struct sys_uuidgen_args ua; 1783 1784 NETBSD32TOP_UAP(store, struct uuid); 1785 NETBSD32TO64_UAP(count); 1786 1787 return sys_uuidgen(l, &ua, retval); 1788 } 1789 1790 int 1791 netbsd32_extattrctl(struct lwp *l, const struct netbsd32_extattrctl_args *uap, register_t *retval) 1792 { 1793 /* { 1794 syscallarg(const netbsd32_charp) path; 1795 syscallarg(int) cmd; 1796 syscallarg(const netbsd32_charp) filename; 1797 syscallarg(int) attrnamespace; 1798 syscallarg(const netbsd32_charp) attrname; 1799 } */ 1800 struct sys_extattrctl_args ua; 1801 1802 NETBSD32TOP_UAP(path, const char); 1803 NETBSD32TO64_UAP(cmd); 1804 NETBSD32TOP_UAP(filename, const char); 1805 NETBSD32TO64_UAP(attrnamespace); 1806 NETBSD32TOP_UAP(attrname, const char); 1807 1808 return sys_extattrctl(l, &ua, retval); 1809 } 1810 1811 int 1812 netbsd32_extattr_set_fd(struct lwp *l, const struct netbsd32_extattr_set_fd_args *uap, register_t *retval) 1813 { 1814 /* { 1815 syscallarg(int) fd; 1816 syscallarg(int) attrnamespace; 1817 syscallarg(const netbsd32_charp) attrname; 1818 syscallarg(const netbsd32_voidp) data; 1819 syscallarg(netbsd32_size_t) nbytes; 1820 } */ 1821 struct sys_extattr_set_fd_args ua; 1822 1823 NETBSD32TO64_UAP(fd); 1824 NETBSD32TO64_UAP(attrnamespace); 1825 NETBSD32TOP_UAP(attrname, const char); 1826 NETBSD32TOP_UAP(data, const void); 1827 NETBSD32TOX_UAP(nbytes, size_t); 1828 1829 return sys_extattr_set_fd(l, &ua, retval); 1830 } 1831 1832 int 1833 netbsd32_extattr_set_file(struct lwp *l, const struct netbsd32_extattr_set_file_args *uap, register_t *retval) 1834 { 1835 /* { 1836 syscallarg(const netbsd32_charp) path; 1837 syscallarg(int) attrnamespace; 1838 syscallarg(const netbsd32_charp) attrname; 1839 syscallarg(const netbsd32_voidp) data; 1840 syscallarg(netbsd32_size_t) nbytes; 1841 } */ 1842 struct sys_extattr_set_file_args ua; 1843 1844 NETBSD32TOP_UAP(path, const char); 1845 NETBSD32TO64_UAP(attrnamespace); 1846 NETBSD32TOP_UAP(attrname, const char); 1847 NETBSD32TOP_UAP(data, const void); 1848 NETBSD32TOX_UAP(nbytes, size_t); 1849 1850 return sys_extattr_set_file(l, &ua, retval); 1851 } 1852 1853 int 1854 netbsd32_extattr_set_link(struct lwp *l, const struct netbsd32_extattr_set_link_args *uap, register_t *retval) 1855 { 1856 /* { 1857 syscallarg(const netbsd32_charp) path; 1858 syscallarg(int) attrnamespace; 1859 syscallarg(const netbsd32_charp) attrname; 1860 syscallarg(const netbsd32_voidp) data; 1861 syscallarg(netbsd32_size_t) nbytes; 1862 } */ 1863 struct sys_extattr_set_link_args ua; 1864 1865 NETBSD32TOP_UAP(path, const char); 1866 NETBSD32TO64_UAP(attrnamespace); 1867 NETBSD32TOP_UAP(attrname, const char); 1868 NETBSD32TOP_UAP(data, const void); 1869 NETBSD32TOX_UAP(nbytes, size_t); 1870 1871 return sys_extattr_set_link(l, &ua, retval); 1872 } 1873 1874 int 1875 netbsd32_extattr_get_fd(struct lwp *l, const struct netbsd32_extattr_get_fd_args *uap, register_t *retval) 1876 { 1877 /* { 1878 syscallarg(int) fd; 1879 syscallarg(int) attrnamespace; 1880 syscallarg(const netbsd32_charp) attrname; 1881 syscallarg(netbsd32_voidp) data; 1882 syscallarg(netbsd32_size_t) nbytes; 1883 } */ 1884 struct sys_extattr_get_fd_args ua; 1885 1886 NETBSD32TO64_UAP(fd); 1887 NETBSD32TO64_UAP(attrnamespace); 1888 NETBSD32TOP_UAP(attrname, const char); 1889 NETBSD32TOP_UAP(data, void); 1890 NETBSD32TOX_UAP(nbytes, size_t); 1891 1892 return sys_extattr_get_fd(l, &ua, retval); 1893 } 1894 1895 int 1896 netbsd32_extattr_get_file(struct lwp *l, const struct netbsd32_extattr_get_file_args *uap, register_t *retval) 1897 { 1898 /* { 1899 syscallarg(const netbsd32_charp) path; 1900 syscallarg(int) attrnamespace; 1901 syscallarg(const netbsd32_charp) attrname; 1902 syscallarg(netbsd32_voidp) data; 1903 syscallarg(netbsd32_size_t) nbytes; 1904 } */ 1905 struct sys_extattr_get_file_args ua; 1906 1907 NETBSD32TOP_UAP(path, const char); 1908 NETBSD32TO64_UAP(attrnamespace); 1909 NETBSD32TOP_UAP(attrname, const char); 1910 NETBSD32TOP_UAP(data, void); 1911 NETBSD32TOX_UAP(nbytes, size_t); 1912 1913 return sys_extattr_get_file(l, &ua, retval); 1914 } 1915 1916 int 1917 netbsd32_extattr_get_link(struct lwp *l, const struct netbsd32_extattr_get_link_args *uap, register_t *retval) 1918 { 1919 /* { 1920 syscallarg(const netbsd32_charp) path; 1921 syscallarg(int) attrnamespace; 1922 syscallarg(const netbsd32_charp) attrname; 1923 syscallarg(netbsd32_voidp) data; 1924 syscallarg(netbsd32_size_t) nbytes; 1925 } */ 1926 struct sys_extattr_get_link_args ua; 1927 1928 NETBSD32TOP_UAP(path, const char); 1929 NETBSD32TO64_UAP(attrnamespace); 1930 NETBSD32TOP_UAP(attrname, const char); 1931 NETBSD32TOP_UAP(data, void); 1932 NETBSD32TOX_UAP(nbytes, size_t); 1933 1934 return sys_extattr_get_link(l, &ua, retval); 1935 } 1936 1937 int 1938 netbsd32_extattr_delete_fd(struct lwp *l, const struct netbsd32_extattr_delete_fd_args *uap, register_t *retval) 1939 { 1940 /* { 1941 syscallarg(int) fd; 1942 syscallarg(int) attrnamespace; 1943 syscallarg(const netbsd32_charp) attrname; 1944 } */ 1945 struct sys_extattr_delete_fd_args ua; 1946 1947 NETBSD32TO64_UAP(fd); 1948 NETBSD32TO64_UAP(attrnamespace); 1949 NETBSD32TOP_UAP(attrname, const char); 1950 1951 return sys_extattr_delete_fd(l, &ua, retval); 1952 } 1953 1954 int 1955 netbsd32_extattr_delete_file(struct lwp *l, const struct netbsd32_extattr_delete_file_args *uap, register_t *retval) 1956 { 1957 /* { 1958 syscallarg(const netbsd32_charp) path; 1959 syscallarg(int) attrnamespace; 1960 syscallarg(const netbsd32_charp) attrname; 1961 } */ 1962 struct sys_extattr_delete_file_args ua; 1963 1964 NETBSD32TOP_UAP(path, const char); 1965 NETBSD32TO64_UAP(attrnamespace); 1966 NETBSD32TOP_UAP(attrname, const char); 1967 1968 return sys_extattr_delete_file(l, &ua, retval); 1969 } 1970 1971 int 1972 netbsd32_extattr_delete_link(struct lwp *l, const struct netbsd32_extattr_delete_link_args *uap, register_t *retval) 1973 { 1974 /* { 1975 syscallarg(const netbsd32_charp) path; 1976 syscallarg(int) attrnamespace; 1977 syscallarg(const netbsd32_charp) attrname; 1978 } */ 1979 struct sys_extattr_delete_link_args ua; 1980 1981 NETBSD32TOP_UAP(path, const char); 1982 NETBSD32TO64_UAP(attrnamespace); 1983 NETBSD32TOP_UAP(attrname, const char); 1984 1985 return sys_extattr_delete_link(l, &ua, retval); 1986 } 1987 1988 int 1989 netbsd32_extattr_list_fd(struct lwp *l, const struct netbsd32_extattr_list_fd_args *uap, register_t *retval) 1990 { 1991 /* { 1992 syscallarg(int) fd; 1993 syscallarg(int) attrnamespace; 1994 syscallarg(netbsd32_voidp) data; 1995 syscallarg(netbsd32_size_t) nbytes; 1996 } */ 1997 struct sys_extattr_list_fd_args ua; 1998 1999 NETBSD32TO64_UAP(fd); 2000 NETBSD32TO64_UAP(attrnamespace); 2001 NETBSD32TOP_UAP(data, void); 2002 NETBSD32TOX_UAP(nbytes, size_t); 2003 2004 return sys_extattr_list_fd(l, &ua, retval); 2005 } 2006 2007 int 2008 netbsd32_extattr_list_file(struct lwp *l, const struct netbsd32_extattr_list_file_args *uap, register_t *retval) 2009 { 2010 /* { 2011 syscallarg(const netbsd32_charp) path; 2012 syscallarg(int) attrnamespace; 2013 syscallarg(netbsd32_voidp) data; 2014 syscallarg(netbsd32_size_t) nbytes; 2015 } */ 2016 struct sys_extattr_list_file_args ua; 2017 2018 NETBSD32TOP_UAP(path, const char); 2019 NETBSD32TO64_UAP(attrnamespace); 2020 NETBSD32TOP_UAP(data, void); 2021 NETBSD32TOX_UAP(nbytes, size_t); 2022 2023 return sys_extattr_list_file(l, &ua, retval); 2024 } 2025 2026 int 2027 netbsd32_extattr_list_link(struct lwp *l, const struct netbsd32_extattr_list_link_args *uap, register_t *retval) 2028 { 2029 /* { 2030 syscallarg(const netbsd32_charp) path; 2031 syscallarg(int) attrnamespace; 2032 syscallarg(netbsd32_voidp) data; 2033 syscallarg(netbsd32_size_t) nbytes; 2034 } */ 2035 struct sys_extattr_list_link_args ua; 2036 2037 NETBSD32TOP_UAP(path, const char); 2038 NETBSD32TO64_UAP(attrnamespace); 2039 NETBSD32TOP_UAP(data, void); 2040 NETBSD32TOX_UAP(nbytes, size_t); 2041 2042 return sys_extattr_list_link(l, &ua, retval); 2043 } 2044 2045 int 2046 netbsd32_mlockall(struct lwp *l, const struct netbsd32_mlockall_args *uap, register_t *retval) 2047 { 2048 /* { 2049 syscallarg(int) flags; 2050 } */ 2051 struct sys_mlockall_args ua; 2052 2053 NETBSD32TO64_UAP(flags); 2054 2055 return sys_mlockall(l, &ua, retval); 2056 } 2057 2058 int 2059 netbsd32___clone(struct lwp *l, const struct netbsd32___clone_args *uap, register_t *retval) 2060 { 2061 /* { 2062 syscallarg(int) flags; 2063 syscallarg(netbsd32_voidp) stack; 2064 } */ 2065 struct sys___clone_args ua; 2066 2067 NETBSD32TO64_UAP(flags); 2068 NETBSD32TOP_UAP(stack, void); 2069 2070 return sys___clone(l, &ua, retval); 2071 } 2072 2073 int 2074 netbsd32_fsync_range(struct lwp *l, const struct netbsd32_fsync_range_args *uap, register_t *retval) 2075 { 2076 /* { 2077 syscallarg(int) fd; 2078 syscallarg(int) flags; 2079 syscallarg(off_t) start; 2080 syscallarg(off_t) length; 2081 } */ 2082 struct sys_fsync_range_args ua; 2083 2084 NETBSD32TO64_UAP(fd); 2085 NETBSD32TO64_UAP(flags); 2086 NETBSD32TO64_UAP(start); 2087 NETBSD32TO64_UAP(length); 2088 2089 return sys_fsync_range(l, &ua, retval); 2090 } 2091 2092 int 2093 netbsd32_rasctl(struct lwp *l, const struct netbsd32_rasctl_args *uap, register_t *retval) 2094 { 2095 /* { 2096 syscallarg(netbsd32_voidp) addr; 2097 syscallarg(netbsd32_size_t) len; 2098 syscallarg(int) op; 2099 } */ 2100 struct sys_rasctl_args ua; 2101 2102 NETBSD32TOP_UAP(addr, void *); 2103 NETBSD32TOX_UAP(len, size_t); 2104 NETBSD32TO64_UAP(op); 2105 2106 return sys_rasctl(l, &ua, retval); 2107 } 2108 2109 int 2110 netbsd32_setxattr(struct lwp *l, const struct netbsd32_setxattr_args *uap, register_t *retval) 2111 { 2112 /* { 2113 syscallarg(const netbsd32_charp) path; 2114 syscallarg(const netbsd32_charp) name; 2115 syscallarg(netbsd32_voidp) value; 2116 syscallarg(netbsd32_size_t) size; 2117 syscallarg(int) flags; 2118 } */ 2119 struct sys_setxattr_args ua; 2120 2121 NETBSD32TOP_UAP(path, const char); 2122 NETBSD32TOP_UAP(name, const char); 2123 NETBSD32TOP_UAP(value, void); 2124 NETBSD32TOX_UAP(size, size_t); 2125 NETBSD32TO64_UAP(flags); 2126 2127 return sys_setxattr(l, &ua, retval); 2128 } 2129 2130 int 2131 netbsd32_lsetxattr(struct lwp *l, const struct netbsd32_lsetxattr_args *uap, register_t *retval) 2132 { 2133 /* { 2134 syscallarg(const netbsd32_charp) path; 2135 syscallarg(const netbsd32_charp) name; 2136 syscallarg(netbsd32_voidp) value; 2137 syscallarg(netbsd32_size_t) size; 2138 syscallarg(int) flags; 2139 } */ 2140 struct sys_lsetxattr_args ua; 2141 2142 NETBSD32TOP_UAP(path, const char); 2143 NETBSD32TOP_UAP(name, const char); 2144 NETBSD32TOP_UAP(value, void); 2145 NETBSD32TOX_UAP(size, size_t); 2146 NETBSD32TO64_UAP(flags); 2147 2148 return sys_lsetxattr(l, &ua, retval); 2149 } 2150 2151 int 2152 netbsd32_fsetxattr(struct lwp *l, const struct netbsd32_fsetxattr_args *uap, register_t *retval) 2153 { 2154 /* { 2155 syscallarg(int) fd; 2156 syscallarg(const netbsd32_charp) name; 2157 syscallarg(netbsd32_voidp) value; 2158 syscallarg(netbsd32_size_t) size; 2159 syscallarg(int) flags; 2160 } */ 2161 struct sys_fsetxattr_args ua; 2162 2163 NETBSD32TO64_UAP(fd); 2164 NETBSD32TOP_UAP(name, const char); 2165 NETBSD32TOP_UAP(value, void); 2166 NETBSD32TOX_UAP(size, size_t); 2167 NETBSD32TO64_UAP(flags); 2168 2169 return sys_fsetxattr(l, &ua, retval); 2170 } 2171 2172 int 2173 netbsd32_getxattr(struct lwp *l, const struct netbsd32_getxattr_args *uap, register_t *retval) 2174 { 2175 /* { 2176 syscallarg(const netbsd32_charp) path; 2177 syscallarg(const netbsd32_charp) name; 2178 syscallarg(netbsd32_voidp) value; 2179 syscallarg(netbsd32_size_t) size; 2180 } */ 2181 struct sys_getxattr_args ua; 2182 2183 NETBSD32TOP_UAP(path, const char); 2184 NETBSD32TOP_UAP(name, const char); 2185 NETBSD32TOP_UAP(value, void); 2186 NETBSD32TOX_UAP(size, size_t); 2187 2188 return sys_getxattr(l, &ua, retval); 2189 } 2190 2191 int 2192 netbsd32_lgetxattr(struct lwp *l, const struct netbsd32_lgetxattr_args *uap, register_t *retval) 2193 { 2194 /* { 2195 syscallarg(const netbsd32_charp) path; 2196 syscallarg(const netbsd32_charp) name; 2197 syscallarg(netbsd32_voidp) value; 2198 syscallarg(netbsd32_size_t) size; 2199 } */ 2200 struct sys_lgetxattr_args ua; 2201 2202 NETBSD32TOP_UAP(path, const char); 2203 NETBSD32TOP_UAP(name, const char); 2204 NETBSD32TOP_UAP(value, void); 2205 NETBSD32TOX_UAP(size, size_t); 2206 2207 return sys_lgetxattr(l, &ua, retval); 2208 } 2209 2210 int 2211 netbsd32_fgetxattr(struct lwp *l, const struct netbsd32_fgetxattr_args *uap, register_t *retval) 2212 { 2213 /* { 2214 syscallarg(int) fd; 2215 syscallarg(const netbsd32_charp) name; 2216 syscallarg(netbsd32_voidp) value; 2217 syscallarg(netbsd32_size_t) size; 2218 } */ 2219 struct sys_fgetxattr_args ua; 2220 2221 NETBSD32TO64_UAP(fd); 2222 NETBSD32TOP_UAP(name, const char); 2223 NETBSD32TOP_UAP(value, void); 2224 NETBSD32TOX_UAP(size, size_t); 2225 2226 return sys_fgetxattr(l, &ua, retval); 2227 } 2228 2229 int 2230 netbsd32_listxattr(struct lwp *l, const struct netbsd32_listxattr_args *uap, register_t *retval) 2231 { 2232 /* { 2233 syscallarg(const netbsd32_charp) path; 2234 syscallarg(netbsd32_charp) list; 2235 syscallarg(netbsd32_size_t) size; 2236 } */ 2237 struct sys_listxattr_args ua; 2238 2239 NETBSD32TOP_UAP(path, const char); 2240 NETBSD32TOP_UAP(list, char); 2241 NETBSD32TOX_UAP(size, size_t); 2242 2243 return sys_listxattr(l, &ua, retval); 2244 } 2245 2246 int 2247 netbsd32_llistxattr(struct lwp *l, const struct netbsd32_llistxattr_args *uap, register_t *retval) 2248 { 2249 /* { 2250 syscallarg(const netbsd32_charp) path; 2251 syscallarg(netbsd32_charp) list; 2252 syscallarg(netbsd32_size_t) size; 2253 } */ 2254 struct sys_llistxattr_args ua; 2255 2256 NETBSD32TOP_UAP(path, const char); 2257 NETBSD32TOP_UAP(list, char); 2258 NETBSD32TOX_UAP(size, size_t); 2259 2260 return sys_llistxattr(l, &ua, retval); 2261 } 2262 2263 int 2264 netbsd32_flistxattr(struct lwp *l, const struct netbsd32_flistxattr_args *uap, register_t *retval) 2265 { 2266 /* { 2267 syscallarg(int) fd; 2268 syscallarg(netbsd32_charp) list; 2269 syscallarg(netbsd32_size_t) size; 2270 } */ 2271 struct sys_flistxattr_args ua; 2272 2273 NETBSD32TO64_UAP(fd); 2274 NETBSD32TOP_UAP(list, char); 2275 NETBSD32TOX_UAP(size, size_t); 2276 2277 return sys_flistxattr(l, &ua, retval); 2278 } 2279 2280 int 2281 netbsd32_removexattr(struct lwp *l, const struct netbsd32_removexattr_args *uap, register_t *retval) 2282 { 2283 /* { 2284 syscallarg(const netbsd32_charp) path; 2285 syscallarg(const netbsd32_charp) name; 2286 } */ 2287 struct sys_removexattr_args ua; 2288 2289 NETBSD32TOP_UAP(path, const char); 2290 NETBSD32TOP_UAP(name, const char); 2291 2292 return sys_removexattr(l, &ua, retval); 2293 } 2294 2295 int 2296 netbsd32_lremovexattr(struct lwp *l, const struct netbsd32_lremovexattr_args *uap, register_t *retval) 2297 { 2298 /* { 2299 syscallarg(const netbsd32_charp) path; 2300 syscallarg(const netbsd32_charp) name; 2301 } */ 2302 struct sys_lremovexattr_args ua; 2303 NETBSD32TOP_UAP(path, const char); 2304 NETBSD32TOP_UAP(name, const char); 2305 return sys_lremovexattr(l, &ua, retval); 2306 } 2307 2308 int 2309 netbsd32_fremovexattr(struct lwp *l, const struct netbsd32_fremovexattr_args *uap, register_t *retval) 2310 { 2311 /* { 2312 syscallarg(int) fd; 2313 syscallarg(const netbsd32_charp) name; 2314 } */ 2315 struct sys_fremovexattr_args ua; 2316 2317 NETBSD32TO64_UAP(fd); 2318 NETBSD32TOP_UAP(name, const char); 2319 2320 return sys_fremovexattr(l, &ua, retval); 2321 } 2322 2323 int 2324 netbsd32___posix_fadvise50(struct lwp *l, 2325 const struct netbsd32___posix_fadvise50_args *uap, register_t *retval) 2326 { 2327 /* { 2328 syscallarg(int) fd; 2329 syscallarg(int) PAD; 2330 syscallarg(netbsd32_off_t) offset; 2331 syscallarg(netbsd32_off_t) len; 2332 syscallarg(int) advice; 2333 } */ 2334 2335 *retval = do_posix_fadvise(SCARG(uap, fd), SCARG(uap, offset), 2336 SCARG(uap, len), SCARG(uap, advice)); 2337 2338 return 0; 2339 } 2340 2341 int 2342 netbsd32__sched_setparam(struct lwp *l, 2343 const struct netbsd32__sched_setparam_args *uap, 2344 register_t *retval) 2345 { 2346 /* { 2347 syscallarg(pid_t) pid; 2348 syscallarg(lwpid_t) lid; 2349 syscallarg(int) policy; 2350 syscallarg(const netbsd32_sched_paramp_t) params; 2351 } */ 2352 struct sys__sched_setparam_args ua; 2353 2354 NETBSD32TO64_UAP(pid); 2355 NETBSD32TO64_UAP(lid); 2356 NETBSD32TO64_UAP(policy); 2357 NETBSD32TOP_UAP(params, const struct sched_param *); 2358 2359 return sys__sched_setparam(l, &ua, retval); 2360 } 2361 2362 int 2363 netbsd32__sched_getparam(struct lwp *l, 2364 const struct netbsd32__sched_getparam_args *uap, 2365 register_t *retval) 2366 { 2367 /* { 2368 syscallarg(pid_t) pid; 2369 syscallarg(lwpid_t) lid; 2370 syscallarg(netbsd32_intp) policy; 2371 syscallarg(netbsd32_sched_paramp_t) params; 2372 } */ 2373 struct sys__sched_getparam_args ua; 2374 2375 NETBSD32TO64_UAP(pid); 2376 NETBSD32TO64_UAP(lid); 2377 NETBSD32TOP_UAP(policy, int *); 2378 NETBSD32TOP_UAP(params, struct sched_param *); 2379 2380 return sys__sched_getparam(l, &ua, retval); 2381 } 2382 2383 int 2384 netbsd32__sched_setaffinity(struct lwp *l, 2385 const struct netbsd32__sched_setaffinity_args *uap, 2386 register_t *retval) 2387 { 2388 /* { 2389 syscallarg(pid_t) pid; 2390 syscallarg(lwpid_t) lid; 2391 syscallarg(netbsd_size_t) size; 2392 syscallarg(const netbsd32_cpusetp_t) cpuset; 2393 } */ 2394 struct sys__sched_setaffinity_args ua; 2395 2396 NETBSD32TO64_UAP(pid); 2397 NETBSD32TO64_UAP(lid); 2398 NETBSD32TOX_UAP(size, size_t); 2399 NETBSD32TOP_UAP(cpuset, const cpuset_t *); 2400 2401 return sys__sched_setaffinity(l, &ua, retval); 2402 } 2403 2404 int 2405 netbsd32__sched_getaffinity(struct lwp *l, 2406 const struct netbsd32__sched_getaffinity_args *uap, 2407 register_t *retval) 2408 { 2409 /* { 2410 syscallarg(pid_t) pid; 2411 syscallarg(lwpid_t) lid; 2412 syscallarg(netbsd_size_t) size; 2413 syscallarg(netbsd32_cpusetp_t) cpuset; 2414 } */ 2415 struct sys__sched_getaffinity_args ua; 2416 2417 NETBSD32TO64_UAP(pid); 2418 NETBSD32TO64_UAP(lid); 2419 NETBSD32TOX_UAP(size, size_t); 2420 NETBSD32TOP_UAP(cpuset, cpuset_t *); 2421 2422 return sys__sched_getaffinity(l, &ua, retval); 2423 } 2424 2425 int 2426 netbsd32__sched_protect(struct lwp *l, 2427 const struct netbsd32__sched_protect_args *uap, 2428 register_t *retval) 2429 { 2430 /* { 2431 syscallarg(int) priority; 2432 } */ 2433 struct sys__sched_protect_args ua; 2434 2435 NETBSD32TO64_UAP(priority); 2436 2437 return sys__sched_protect(l, &ua, retval); 2438 } 2439 2440 int 2441 netbsd32_dup3(struct lwp *l, const struct netbsd32_dup3_args *uap, 2442 register_t *retval) 2443 { 2444 /* { 2445 syscallarg(int) from; 2446 syscallarg(int) to; 2447 syscallarg(int) flags; 2448 } */ 2449 struct sys_dup3_args ua; 2450 2451 NETBSD32TO64_UAP(from); 2452 NETBSD32TO64_UAP(to); 2453 NETBSD32TO64_UAP(flags); 2454 2455 return sys_dup3(l, &ua, retval); 2456 } 2457 2458 int 2459 netbsd32_kqueue1(struct lwp *l, const struct netbsd32_kqueue1_args *uap, 2460 register_t *retval) 2461 { 2462 /* { 2463 syscallarg(int) flags; 2464 } */ 2465 struct sys_kqueue1_args ua; 2466 2467 NETBSD32TO64_UAP(flags); 2468 2469 return sys_kqueue1(l, &ua, retval); 2470 } 2471 2472 int 2473 netbsd32_paccept(struct lwp *l, const struct netbsd32_paccept_args *uap, 2474 register_t *retval) 2475 { 2476 /* { 2477 syscallarg(int) s; 2478 syscallarg(netbsd32_sockaddrp_t) name; 2479 syscallarg(netbsd32_socklenp_t) anamelen; 2480 syscallarg(const netbsd32_sigsetp_t) mask; 2481 syscallarg(int) flags; 2482 } */ 2483 struct sys_paccept_args ua; 2484 2485 NETBSD32TO64_UAP(s); 2486 NETBSD32TOP_UAP(name, struct sockaddr *); 2487 NETBSD32TOP_UAP(anamelen, socklen_t *); 2488 NETBSD32TOP_UAP(mask, const sigset_t *); 2489 NETBSD32TO64_UAP(flags); 2490 2491 return sys_paccept(l, &ua, retval); 2492 } 2493 2494 int 2495 netbsd32_fdiscard(struct lwp *l, const struct netbsd32_fdiscard_args *uap, 2496 register_t *retval) 2497 { 2498 /* { 2499 syscallarg(int) fd; 2500 syscallarg(netbsd32_off_t) pos; 2501 syscallarg(netbsd32_off_t) len; 2502 } */ 2503 struct sys_fdiscard_args ua; 2504 2505 NETBSD32TO64_UAP(fd); 2506 NETBSD32TO64_UAP(pos); 2507 NETBSD32TO64_UAP(len); 2508 2509 return sys_fdiscard(l, &ua, retval); 2510 } 2511 2512 int 2513 netbsd32_posix_fallocate(struct lwp *l, const struct netbsd32_posix_fallocate_args *uap, 2514 register_t *retval) 2515 { 2516 /* { 2517 syscallarg(int) fd; 2518 syscallarg(netbsd32_off_t) pos; 2519 syscallarg(netbsd32_off_t) len; 2520 } */ 2521 struct sys_posix_fallocate_args ua; 2522 2523 NETBSD32TO64_UAP(fd); 2524 NETBSD32TO64_UAP(pos); 2525 NETBSD32TO64_UAP(len); 2526 2527 return sys_posix_fallocate(l, &ua, retval); 2528 } 2529 2530 int 2531 netbsd32_pset_create(struct lwp *l, 2532 const struct netbsd32_pset_create_args *uap, register_t *retval) 2533 { 2534 /* { 2535 syscallarg(netbsd32_psetidp_t) psid; 2536 }; */ 2537 struct sys_pset_create_args ua; 2538 2539 NETBSD32TOP_UAP(psid, psetid_t); 2540 2541 return sys_pset_create(l, &ua, retval); 2542 } 2543 2544 int 2545 netbsd32_pset_destroy(struct lwp *l, 2546 const struct netbsd32_pset_destroy_args *uap, register_t *retval) 2547 { 2548 /* { 2549 syscallarg(psetid_t) psid; 2550 }; */ 2551 2552 return sys_pset_destroy(l, (const void *)uap, retval); 2553 } 2554 2555 int 2556 netbsd32_pset_assign(struct lwp *l, 2557 const struct netbsd32_pset_assign_args *uap, register_t *retval) 2558 { 2559 /* { 2560 syscallarg(psetid_t) psid; 2561 syscallarg(cpuid_t) cpuid; 2562 syscallarg(netbsd32_psetidp_t) opsid; 2563 }; */ 2564 struct sys_pset_assign_args ua; 2565 2566 SCARG(&ua, psid) = SCARG(uap, psid); 2567 NETBSD32TO64_UAP(cpuid); 2568 NETBSD32TOP_UAP(opsid, psetid_t); 2569 2570 return sys_pset_assign(l, &ua, retval); 2571 } 2572 2573 int 2574 netbsd32__pset_bind(struct lwp *l, 2575 const struct netbsd32__pset_bind_args *uap, register_t *retval) 2576 { 2577 /* { 2578 syscallarg(idtype_t) idtype; 2579 syscallarg(id_t) first_id; 2580 syscallarg(id_t) second_id; 2581 syscallarg(psetid_t) psid; 2582 syscallarg(netbsd32_psetidp_t) opsid; 2583 }; */ 2584 struct sys__pset_bind_args ua; 2585 2586 SCARG(&ua, idtype) = SCARG(uap, idtype); 2587 SCARG(&ua, first_id) = SCARG(uap, first_id); 2588 SCARG(&ua, second_id) = SCARG(uap, second_id); 2589 SCARG(&ua, psid) = SCARG(uap, psid); 2590 NETBSD32TOP_UAP(opsid, psetid_t); 2591 2592 return sys__pset_bind(l, &ua, retval); 2593 } 2594 2595 2596 /* 2597 * MI indirect system call support. 2598 * Only used if the MD netbsd32_syscall.c doesn't intercept the calls. 2599 */ 2600 2601 #define NETBSD32_SYSCALL 2602 #undef SYS_NSYSENT 2603 #define SYS_NSYSENT NETBSD32_SYS_NSYSENT 2604 2605 #define SYS_SYSCALL netbsd32_syscall 2606 #include "../../kern/sys_syscall.c" 2607 #undef SYS_SYSCALL 2608 2609 #define SYS_SYSCALL netbsd32____syscall 2610 #include "../../kern/sys_syscall.c" 2611 #undef SYS_SYSCALL 2612