1 /* $NetBSD: netbsd32_netbsd.c,v 1.60 2001/06/19 00:36:21 fvdl Exp $ */ 2 3 /* 4 * Copyright (c) 1998, 2001 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 * 3. The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * SUCH DAMAGE. 29 */ 30 31 #if defined(_KERNEL_OPT) 32 #include "opt_ddb.h" 33 #include "opt_ktrace.h" 34 #include "opt_ntp.h" 35 #include "opt_compat_netbsd.h" 36 #include "opt_compat_43.h" 37 #include "opt_sysv.h" 38 39 #include "fs_lfs.h" 40 #include "fs_nfs.h" 41 #endif 42 43 /* 44 * Though COMPAT_OLDSOCK is needed only for COMPAT_43, SunOS, Linux, 45 * HP-UX, FreeBSD, Ultrix, OSF1, we define it unconditionally so that 46 * this would be LKM-safe. 47 */ 48 #define COMPAT_OLDSOCK /* used by <sys/socket.h> */ 49 50 #include <sys/param.h> 51 #include <sys/systm.h> 52 #include <sys/kernel.h> 53 //#define msg __msg /* Don't ask me! */ 54 #include <sys/malloc.h> 55 #include <sys/mount.h> 56 #include <sys/socket.h> 57 #include <sys/sockio.h> 58 #include <sys/socketvar.h> 59 #include <sys/mbuf.h> 60 #include <sys/stat.h> 61 #include <sys/time.h> 62 #include <sys/signalvar.h> 63 #include <sys/ptrace.h> 64 #include <sys/ktrace.h> 65 #include <sys/trace.h> 66 #include <sys/resourcevar.h> 67 #include <sys/pool.h> 68 #include <sys/vnode.h> 69 #include <sys/file.h> 70 #include <sys/filedesc.h> 71 #include <sys/namei.h> 72 73 #include <uvm/uvm_extern.h> 74 75 #include <sys/syscallargs.h> 76 #include <sys/proc.h> 77 #include <sys/acct.h> 78 #include <sys/exec.h> 79 80 #include <net/if.h> 81 82 #include <compat/netbsd32/netbsd32.h> 83 #include <compat/netbsd32/netbsd32_syscall.h> 84 #include <compat/netbsd32/netbsd32_syscallargs.h> 85 #include <compat/netbsd32/netbsd32_conv.h> 86 87 #include <machine/frame.h> 88 89 #if defined(DDB) 90 #include <ddb/ddbvar.h> 91 #endif 92 93 extern char netbsd32_sigcode[], netbsd32_esigcode[]; 94 extern struct sysent netbsd32_sysent[]; 95 #ifdef SYSCALL_DEBUG 96 extern const char * const netbsd32_syscallnames[]; 97 #endif 98 #ifdef __HAVE_SYSCALL_INTERN 99 void netbsd32_syscall_intern __P((struct proc *)); 100 #else 101 void syscall __P((void)); 102 #endif 103 104 const struct emul emul_netbsd32 = { 105 "netbsd32", 106 "/emul/netbsd32", 107 #ifndef __HAVE_MINIMAL_EMUL 108 0, 109 NULL, 110 netbsd32_SYS_syscall, 111 netbsd32_SYS_MAXSYSCALL, 112 #endif 113 netbsd32_sysent, 114 #ifdef SYSCALL_DEBUG 115 netbsd32_syscallnames, 116 #else 117 NULL, 118 #endif 119 netbsd32_sendsig, 120 trapsignal, 121 netbsd32_sigcode, 122 netbsd32_esigcode, 123 NULL, 124 NULL, 125 NULL, 126 #ifdef __HAVE_SYSCALL_INTERN 127 netbsd32_syscall_intern, 128 #else 129 syscall, 130 #endif 131 }; 132 133 /* 134 * below are all the standard NetBSD system calls, in the 32bit 135 * environment, with the necessary conversions to 64bit before 136 * calling the real syscall. anything that needs special 137 * attention is handled elsewhere. 138 */ 139 140 int 141 netbsd32_exit(p, v, retval) 142 struct proc *p; 143 void *v; 144 register_t *retval; 145 { 146 struct netbsd32_exit_args /* { 147 syscallarg(int) rval; 148 } */ *uap = v; 149 struct sys_exit_args ua; 150 151 NETBSD32TO64_UAP(rval); 152 return sys_exit(p, &ua, retval); 153 } 154 155 int 156 netbsd32_read(p, v, retval) 157 struct proc *p; 158 void *v; 159 register_t *retval; 160 { 161 struct netbsd32_read_args /* { 162 syscallarg(int) fd; 163 syscallarg(netbsd32_voidp) buf; 164 syscallarg(netbsd32_size_t) nbyte; 165 } */ *uap = v; 166 struct sys_read_args ua; 167 168 NETBSD32TO64_UAP(fd); 169 NETBSD32TOP_UAP(buf, void *); 170 NETBSD32TOX_UAP(nbyte, size_t); 171 return sys_read(p, &ua, retval); 172 } 173 174 int 175 netbsd32_write(p, v, retval) 176 struct proc *p; 177 void *v; 178 register_t *retval; 179 { 180 struct netbsd32_write_args /* { 181 syscallarg(int) fd; 182 syscallarg(const netbsd32_voidp) buf; 183 syscallarg(netbsd32_size_t) nbyte; 184 } */ *uap = v; 185 struct sys_write_args ua; 186 187 NETBSD32TO64_UAP(fd); 188 NETBSD32TOP_UAP(buf, void *); 189 NETBSD32TOX_UAP(nbyte, size_t); 190 return sys_write(p, &ua, retval); 191 } 192 193 int 194 netbsd32_close(p, v, retval) 195 struct proc *p; 196 void *v; 197 register_t *retval; 198 { 199 struct netbsd32_close_args /* { 200 syscallarg(int) fd; 201 } */ *uap = v; 202 struct sys_close_args ua; 203 204 NETBSD32TO64_UAP(fd); 205 return sys_close(p, &ua, retval); 206 } 207 208 int 209 netbsd32_open(p, v, retval) 210 struct proc *p; 211 void *v; 212 register_t *retval; 213 { 214 struct netbsd32_open_args /* { 215 syscallarg(const netbsd32_charp) path; 216 syscallarg(int) flags; 217 syscallarg(mode_t) mode; 218 } */ *uap = v; 219 struct sys_open_args ua; 220 caddr_t sg; 221 222 NETBSD32TOP_UAP(path, const char); 223 NETBSD32TO64_UAP(flags); 224 NETBSD32TO64_UAP(mode); 225 sg = stackgap_init(p->p_emul); 226 CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path)); 227 228 return (sys_open(p, &ua, retval)); 229 } 230 231 int 232 netbsd32_link(p, v, retval) 233 struct proc *p; 234 void *v; 235 register_t *retval; 236 { 237 struct netbsd32_link_args /* { 238 syscallarg(const netbsd32_charp) path; 239 syscallarg(const netbsd32_charp) link; 240 } */ *uap = v; 241 struct sys_link_args ua; 242 243 NETBSD32TOP_UAP(path, const char); 244 NETBSD32TOP_UAP(link, const char); 245 return (sys_link(p, &ua, retval)); 246 } 247 248 int 249 netbsd32_unlink(p, v, retval) 250 struct proc *p; 251 void *v; 252 register_t *retval; 253 { 254 struct netbsd32_unlink_args /* { 255 syscallarg(const netbsd32_charp) path; 256 } */ *uap = v; 257 struct sys_unlink_args ua; 258 259 NETBSD32TOP_UAP(path, const char); 260 261 return (sys_unlink(p, &ua, retval)); 262 } 263 264 int 265 netbsd32_chdir(p, v, retval) 266 struct proc *p; 267 void *v; 268 register_t *retval; 269 { 270 struct netbsd32_chdir_args /* { 271 syscallarg(const netbsd32_charp) path; 272 } */ *uap = v; 273 struct sys_chdir_args ua; 274 275 NETBSD32TOP_UAP(path, const char); 276 277 return (sys_chdir(p, &ua, retval)); 278 } 279 280 int 281 netbsd32_fchdir(p, v, retval) 282 struct proc *p; 283 void *v; 284 register_t *retval; 285 { 286 struct netbsd32_fchdir_args /* { 287 syscallarg(int) fd; 288 } */ *uap = v; 289 struct sys_fchdir_args ua; 290 291 NETBSD32TO64_UAP(fd); 292 293 return (sys_fchdir(p, &ua, retval)); 294 } 295 296 int 297 netbsd32_mknod(p, v, retval) 298 struct proc *p; 299 void *v; 300 register_t *retval; 301 { 302 struct netbsd32_mknod_args /* { 303 syscallarg(const netbsd32_charp) path; 304 syscallarg(mode_t) mode; 305 syscallarg(dev_t) dev; 306 } */ *uap = v; 307 struct sys_mknod_args ua; 308 309 NETBSD32TOP_UAP(path, const char); 310 NETBSD32TO64_UAP(dev); 311 NETBSD32TO64_UAP(mode); 312 313 return (sys_mknod(p, &ua, retval)); 314 } 315 316 int 317 netbsd32_chmod(p, v, retval) 318 struct proc *p; 319 void *v; 320 register_t *retval; 321 { 322 struct netbsd32_chmod_args /* { 323 syscallarg(const netbsd32_charp) path; 324 syscallarg(mode_t) mode; 325 } */ *uap = v; 326 struct sys_chmod_args ua; 327 328 NETBSD32TOP_UAP(path, const char); 329 NETBSD32TO64_UAP(mode); 330 331 return (sys_chmod(p, &ua, retval)); 332 } 333 334 int 335 netbsd32_chown(p, v, retval) 336 struct proc *p; 337 void *v; 338 register_t *retval; 339 { 340 struct netbsd32_chown_args /* { 341 syscallarg(const netbsd32_charp) path; 342 syscallarg(uid_t) uid; 343 syscallarg(gid_t) gid; 344 } */ *uap = v; 345 struct sys_chown_args ua; 346 347 NETBSD32TOP_UAP(path, const char); 348 NETBSD32TO64_UAP(uid); 349 NETBSD32TO64_UAP(gid); 350 351 return (sys_chown(p, &ua, retval)); 352 } 353 354 int 355 netbsd32_break(p, v, retval) 356 struct proc *p; 357 void *v; 358 register_t *retval; 359 { 360 struct netbsd32_break_args /* { 361 syscallarg(netbsd32_charp) nsize; 362 } */ *uap = v; 363 struct sys_obreak_args ua; 364 365 SCARG(&ua, nsize) = (char *)(u_long)SCARG(uap, nsize); 366 NETBSD32TOP_UAP(nsize, char); 367 return (sys_obreak(p, &ua, retval)); 368 } 369 370 int 371 netbsd32_mount(p, v, retval) 372 struct proc *p; 373 void *v; 374 register_t *retval; 375 { 376 struct netbsd32_mount_args /* { 377 syscallarg(const netbsd32_charp) type; 378 syscallarg(const netbsd32_charp) path; 379 syscallarg(int) flags; 380 syscallarg(netbsd32_voidp) data; 381 } */ *uap = v; 382 struct sys_mount_args ua; 383 384 NETBSD32TOP_UAP(type, const char); 385 NETBSD32TOP_UAP(path, const char); 386 NETBSD32TO64_UAP(flags); 387 NETBSD32TOP_UAP(data, void); 388 return (sys_mount(p, &ua, retval)); 389 } 390 391 int 392 netbsd32_unmount(p, v, retval) 393 struct proc *p; 394 void *v; 395 register_t *retval; 396 { 397 struct netbsd32_unmount_args /* { 398 syscallarg(const netbsd32_charp) path; 399 syscallarg(int) flags; 400 } */ *uap = v; 401 struct sys_unmount_args ua; 402 403 NETBSD32TOP_UAP(path, const char); 404 NETBSD32TO64_UAP(flags); 405 return (sys_unmount(p, &ua, retval)); 406 } 407 408 int 409 netbsd32_setuid(p, v, retval) 410 struct proc *p; 411 void *v; 412 register_t *retval; 413 { 414 struct netbsd32_setuid_args /* { 415 syscallarg(uid_t) uid; 416 } */ *uap = v; 417 struct sys_setuid_args ua; 418 419 NETBSD32TO64_UAP(uid); 420 return (sys_setuid(p, &ua, retval)); 421 } 422 423 int 424 netbsd32_ptrace(p, v, retval) 425 struct proc *p; 426 void *v; 427 register_t *retval; 428 { 429 struct netbsd32_ptrace_args /* { 430 syscallarg(int) req; 431 syscallarg(pid_t) pid; 432 syscallarg(netbsd32_caddr_t) addr; 433 syscallarg(int) data; 434 } */ *uap = v; 435 struct sys_ptrace_args ua; 436 437 NETBSD32TO64_UAP(req); 438 NETBSD32TO64_UAP(pid); 439 NETBSD32TOX64_UAP(addr, caddr_t); 440 NETBSD32TO64_UAP(data); 441 return (sys_ptrace(p, &ua, retval)); 442 } 443 444 int 445 netbsd32_accept(p, v, retval) 446 struct proc *p; 447 void *v; 448 register_t *retval; 449 { 450 struct netbsd32_accept_args /* { 451 syscallarg(int) s; 452 syscallarg(netbsd32_sockaddrp_t) name; 453 syscallarg(netbsd32_intp) anamelen; 454 } */ *uap = v; 455 struct sys_accept_args ua; 456 457 NETBSD32TO64_UAP(s); 458 NETBSD32TOP_UAP(name, struct sockaddr); 459 NETBSD32TOP_UAP(anamelen, int); 460 return (sys_accept(p, &ua, retval)); 461 } 462 463 int 464 netbsd32_getpeername(p, v, retval) 465 struct proc *p; 466 void *v; 467 register_t *retval; 468 { 469 struct netbsd32_getpeername_args /* { 470 syscallarg(int) fdes; 471 syscallarg(netbsd32_sockaddrp_t) asa; 472 syscallarg(netbsd32_intp) alen; 473 } */ *uap = v; 474 struct sys_getpeername_args ua; 475 476 NETBSD32TO64_UAP(fdes); 477 NETBSD32TOP_UAP(asa, struct sockaddr); 478 NETBSD32TOP_UAP(alen, int); 479 /* NB: do the protocol specific sockaddrs need to be converted? */ 480 return (sys_getpeername(p, &ua, retval)); 481 } 482 483 int 484 netbsd32_getsockname(p, v, retval) 485 struct proc *p; 486 void *v; 487 register_t *retval; 488 { 489 struct netbsd32_getsockname_args /* { 490 syscallarg(int) fdes; 491 syscallarg(netbsd32_sockaddrp_t) asa; 492 syscallarg(netbsd32_intp) alen; 493 } */ *uap = v; 494 struct sys_getsockname_args ua; 495 496 NETBSD32TO64_UAP(fdes); 497 NETBSD32TOP_UAP(asa, struct sockaddr); 498 NETBSD32TOP_UAP(alen, int); 499 return (sys_getsockname(p, &ua, retval)); 500 } 501 502 int 503 netbsd32_access(p, v, retval) 504 struct proc *p; 505 void *v; 506 register_t *retval; 507 { 508 struct netbsd32_access_args /* { 509 syscallarg(const netbsd32_charp) path; 510 syscallarg(int) flags; 511 } */ *uap = v; 512 struct sys_access_args ua; 513 caddr_t sg; 514 515 NETBSD32TOP_UAP(path, const char); 516 NETBSD32TO64_UAP(flags); 517 sg = stackgap_init(p->p_emul); 518 CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path)); 519 520 return (sys_access(p, &ua, retval)); 521 } 522 523 int 524 netbsd32_chflags(p, v, retval) 525 struct proc *p; 526 void *v; 527 register_t *retval; 528 { 529 struct netbsd32_chflags_args /* { 530 syscallarg(const netbsd32_charp) path; 531 syscallarg(netbsd32_u_long) flags; 532 } */ *uap = v; 533 struct sys_chflags_args ua; 534 535 NETBSD32TOP_UAP(path, const char); 536 NETBSD32TO64_UAP(flags); 537 538 return (sys_chflags(p, &ua, retval)); 539 } 540 541 int 542 netbsd32_fchflags(p, v, retval) 543 struct proc *p; 544 void *v; 545 register_t *retval; 546 { 547 struct netbsd32_fchflags_args /* { 548 syscallarg(int) fd; 549 syscallarg(netbsd32_u_long) flags; 550 } */ *uap = v; 551 struct sys_fchflags_args ua; 552 553 NETBSD32TO64_UAP(fd); 554 NETBSD32TO64_UAP(flags); 555 556 return (sys_fchflags(p, &ua, retval)); 557 } 558 559 int 560 netbsd32_lchflags(p, v, retval) 561 struct proc *p; 562 void *v; 563 register_t *retval; 564 { 565 struct netbsd32_lchflags_args /* { 566 syscallarg(int) fd; 567 syscallarg(netbsd32_u_long) flags; 568 } */ *uap = v; 569 struct sys_lchflags_args ua; 570 571 NETBSD32TOP_UAP(path, const char); 572 NETBSD32TO64_UAP(flags); 573 574 return (sys_lchflags(p, &ua, retval)); 575 } 576 577 int 578 netbsd32_kill(p, v, retval) 579 struct proc *p; 580 void *v; 581 register_t *retval; 582 { 583 struct netbsd32_kill_args /* { 584 syscallarg(int) pid; 585 syscallarg(int) signum; 586 } */ *uap = v; 587 struct sys_kill_args ua; 588 589 NETBSD32TO64_UAP(pid); 590 NETBSD32TO64_UAP(signum); 591 592 return (sys_kill(p, &ua, retval)); 593 } 594 595 int 596 netbsd32_dup(p, v, retval) 597 struct proc *p; 598 void *v; 599 register_t *retval; 600 { 601 struct netbsd32_dup_args /* { 602 syscallarg(int) fd; 603 } */ *uap = v; 604 struct sys_dup_args ua; 605 606 NETBSD32TO64_UAP(fd); 607 608 return (sys_dup(p, &ua, retval)); 609 } 610 611 int 612 netbsd32_profil(p, v, retval) 613 struct proc *p; 614 void *v; 615 register_t *retval; 616 { 617 struct netbsd32_profil_args /* { 618 syscallarg(netbsd32_caddr_t) samples; 619 syscallarg(netbsd32_size_t) size; 620 syscallarg(netbsd32_u_long) offset; 621 syscallarg(u_int) scale; 622 } */ *uap = v; 623 struct sys_profil_args ua; 624 625 NETBSD32TOX64_UAP(samples, caddr_t); 626 NETBSD32TOX_UAP(size, size_t); 627 NETBSD32TOX_UAP(offset, u_long); 628 NETBSD32TO64_UAP(scale); 629 return (sys_profil(p, &ua, retval)); 630 } 631 632 #ifdef KTRACE 633 int 634 netbsd32_ktrace(p, v, retval) 635 struct proc *p; 636 void *v; 637 register_t *retval; 638 { 639 struct netbsd32_ktrace_args /* { 640 syscallarg(const netbsd32_charp) fname; 641 syscallarg(int) ops; 642 syscallarg(int) facs; 643 syscallarg(int) pid; 644 } */ *uap = v; 645 struct sys_ktrace_args ua; 646 647 NETBSD32TOP_UAP(fname, const char); 648 NETBSD32TO64_UAP(ops); 649 NETBSD32TO64_UAP(facs); 650 NETBSD32TO64_UAP(pid); 651 return (sys_ktrace(p, &ua, retval)); 652 } 653 #endif /* KTRACE */ 654 655 int 656 netbsd32_utrace(p, v, retval) 657 struct proc *p; 658 void *v; 659 register_t *retval; 660 { 661 struct netbsd32_utrace_args /* { 662 syscallarg(const netbsd32_charp) label; 663 syscallarg(netbsd32_voidp) addr; 664 syscallarg(netbsd32_size_t) len; 665 } */ *uap = v; 666 struct sys_utrace_args ua; 667 668 NETBSD32TOP_UAP(label, const char); 669 NETBSD32TOP_UAP(addr, void); 670 NETBSD32TO64_UAP(len); 671 return (sys_utrace(p, &ua, retval)); 672 } 673 674 int 675 netbsd32___getlogin(p, v, retval) 676 struct proc *p; 677 void *v; 678 register_t *retval; 679 { 680 struct netbsd32___getlogin_args /* { 681 syscallarg(netbsd32_charp) namebuf; 682 syscallarg(u_int) namelen; 683 } */ *uap = v; 684 struct sys___getlogin_args ua; 685 686 NETBSD32TOP_UAP(namebuf, char); 687 NETBSD32TO64_UAP(namelen); 688 return (sys___getlogin(p, &ua, retval)); 689 } 690 691 int 692 netbsd32_setlogin(p, v, retval) 693 struct proc *p; 694 void *v; 695 register_t *retval; 696 { 697 struct netbsd32_setlogin_args /* { 698 syscallarg(const netbsd32_charp) namebuf; 699 } */ *uap = v; 700 struct sys_setlogin_args ua; 701 702 NETBSD32TOP_UAP(namebuf, char); 703 return (sys_setlogin(p, &ua, retval)); 704 } 705 706 int 707 netbsd32_acct(p, v, retval) 708 struct proc *p; 709 void *v; 710 register_t *retval; 711 { 712 struct netbsd32_acct_args /* { 713 syscallarg(const netbsd32_charp) path; 714 } */ *uap = v; 715 struct sys_acct_args ua; 716 717 NETBSD32TOP_UAP(path, const char); 718 return (sys_acct(p, &ua, retval)); 719 } 720 721 int 722 netbsd32_revoke(p, v, retval) 723 struct proc *p; 724 void *v; 725 register_t *retval; 726 { 727 struct netbsd32_revoke_args /* { 728 syscallarg(const netbsd32_charp) path; 729 } */ *uap = v; 730 struct sys_revoke_args ua; 731 caddr_t sg; 732 733 NETBSD32TOP_UAP(path, const char); 734 sg = stackgap_init(p->p_emul); 735 CHECK_ALT_EXIST(p, &sg, SCARG(&ua, path)); 736 737 return (sys_revoke(p, &ua, retval)); 738 } 739 740 int 741 netbsd32_symlink(p, v, retval) 742 struct proc *p; 743 void *v; 744 register_t *retval; 745 { 746 struct netbsd32_symlink_args /* { 747 syscallarg(const netbsd32_charp) path; 748 syscallarg(const netbsd32_charp) link; 749 } */ *uap = v; 750 struct sys_symlink_args ua; 751 752 NETBSD32TOP_UAP(path, const char); 753 NETBSD32TOP_UAP(link, const char); 754 755 return (sys_symlink(p, &ua, retval)); 756 } 757 758 int 759 netbsd32_readlink(p, v, retval) 760 struct proc *p; 761 void *v; 762 register_t *retval; 763 { 764 struct netbsd32_readlink_args /* { 765 syscallarg(const netbsd32_charp) path; 766 syscallarg(netbsd32_charp) buf; 767 syscallarg(netbsd32_size_t) count; 768 } */ *uap = v; 769 struct sys_readlink_args ua; 770 caddr_t sg; 771 772 NETBSD32TOP_UAP(path, const char); 773 NETBSD32TOP_UAP(buf, char); 774 NETBSD32TOX_UAP(count, size_t); 775 sg = stackgap_init(p->p_emul); 776 CHECK_ALT_SYMLINK(p, &sg, SCARG(&ua, path)); 777 778 return (sys_readlink(p, &ua, retval)); 779 } 780 781 int 782 netbsd32_umask(p, v, retval) 783 struct proc *p; 784 void *v; 785 register_t *retval; 786 { 787 struct netbsd32_umask_args /* { 788 syscallarg(mode_t) newmask; 789 } */ *uap = v; 790 struct sys_umask_args ua; 791 792 NETBSD32TO64_UAP(newmask); 793 return (sys_umask(p, &ua, retval)); 794 } 795 796 int 797 netbsd32_chroot(p, v, retval) 798 struct proc *p; 799 void *v; 800 register_t *retval; 801 { 802 struct netbsd32_chroot_args /* { 803 syscallarg(const netbsd32_charp) path; 804 } */ *uap = v; 805 struct sys_chroot_args ua; 806 807 NETBSD32TOP_UAP(path, const char); 808 return (sys_chroot(p, &ua, retval)); 809 } 810 811 int 812 netbsd32_sbrk(p, v, retval) 813 struct proc *p; 814 void *v; 815 register_t *retval; 816 { 817 struct netbsd32_sbrk_args /* { 818 syscallarg(int) incr; 819 } */ *uap = v; 820 struct sys_sbrk_args ua; 821 822 NETBSD32TO64_UAP(incr); 823 return (sys_sbrk(p, &ua, retval)); 824 } 825 826 int 827 netbsd32_sstk(p, v, retval) 828 struct proc *p; 829 void *v; 830 register_t *retval; 831 { 832 struct netbsd32_sstk_args /* { 833 syscallarg(int) incr; 834 } */ *uap = v; 835 struct sys_sstk_args ua; 836 837 NETBSD32TO64_UAP(incr); 838 return (sys_sstk(p, &ua, retval)); 839 } 840 841 int 842 netbsd32_munmap(p, v, retval) 843 struct proc *p; 844 void *v; 845 register_t *retval; 846 { 847 struct netbsd32_munmap_args /* { 848 syscallarg(netbsd32_voidp) addr; 849 syscallarg(netbsd32_size_t) len; 850 } */ *uap = v; 851 struct sys_munmap_args ua; 852 853 NETBSD32TOP_UAP(addr, void); 854 NETBSD32TOX_UAP(len, size_t); 855 return (sys_munmap(p, &ua, retval)); 856 } 857 858 int 859 netbsd32_mprotect(p, v, retval) 860 struct proc *p; 861 void *v; 862 register_t *retval; 863 { 864 struct netbsd32_mprotect_args /* { 865 syscallarg(netbsd32_voidp) addr; 866 syscallarg(netbsd32_size_t) len; 867 syscallarg(int) prot; 868 } */ *uap = v; 869 struct sys_mprotect_args ua; 870 871 NETBSD32TOP_UAP(addr, void); 872 NETBSD32TOX_UAP(len, size_t); 873 NETBSD32TO64_UAP(prot); 874 return (sys_mprotect(p, &ua, retval)); 875 } 876 877 int 878 netbsd32_madvise(p, v, retval) 879 struct proc *p; 880 void *v; 881 register_t *retval; 882 { 883 struct netbsd32_madvise_args /* { 884 syscallarg(netbsd32_voidp) addr; 885 syscallarg(netbsd32_size_t) len; 886 syscallarg(int) behav; 887 } */ *uap = v; 888 struct sys_madvise_args ua; 889 890 NETBSD32TOP_UAP(addr, void); 891 NETBSD32TOX_UAP(len, size_t); 892 NETBSD32TO64_UAP(behav); 893 return (sys_madvise(p, &ua, retval)); 894 } 895 896 int 897 netbsd32_mincore(p, v, retval) 898 struct proc *p; 899 void *v; 900 register_t *retval; 901 { 902 struct netbsd32_mincore_args /* { 903 syscallarg(netbsd32_caddr_t) addr; 904 syscallarg(netbsd32_size_t) len; 905 syscallarg(netbsd32_charp) vec; 906 } */ *uap = v; 907 struct sys_mincore_args ua; 908 909 NETBSD32TOX64_UAP(addr, caddr_t); 910 NETBSD32TOX_UAP(len, size_t); 911 NETBSD32TOP_UAP(vec, char); 912 return (sys_mincore(p, &ua, retval)); 913 } 914 915 /* XXX MOVE ME XXX ? */ 916 int 917 netbsd32_getgroups(p, v, retval) 918 struct proc *p; 919 void *v; 920 register_t *retval; 921 { 922 struct netbsd32_getgroups_args /* { 923 syscallarg(int) gidsetsize; 924 syscallarg(netbsd32_gid_tp) gidset; 925 } */ *uap = v; 926 struct pcred *pc = p->p_cred; 927 int ngrp; 928 int error; 929 930 ngrp = SCARG(uap, gidsetsize); 931 if (ngrp == 0) { 932 *retval = pc->pc_ucred->cr_ngroups; 933 return (0); 934 } 935 if (ngrp < pc->pc_ucred->cr_ngroups) 936 return (EINVAL); 937 ngrp = pc->pc_ucred->cr_ngroups; 938 /* Should convert gid_t to netbsd32_gid_t, but they're the same */ 939 error = copyout((caddr_t)pc->pc_ucred->cr_groups, 940 (caddr_t)(u_long)SCARG(uap, gidset), 941 ngrp * sizeof(gid_t)); 942 if (error) 943 return (error); 944 *retval = ngrp; 945 return (0); 946 } 947 948 int 949 netbsd32_setgroups(p, v, retval) 950 struct proc *p; 951 void *v; 952 register_t *retval; 953 { 954 struct netbsd32_setgroups_args /* { 955 syscallarg(int) gidsetsize; 956 syscallarg(const netbsd32_gid_tp) gidset; 957 } */ *uap = v; 958 struct sys_setgroups_args ua; 959 960 NETBSD32TO64_UAP(gidsetsize); 961 NETBSD32TOP_UAP(gidset, gid_t); 962 return (sys_setgroups(p, &ua, retval)); 963 } 964 965 int 966 netbsd32_setpgid(p, v, retval) 967 struct proc *p; 968 void *v; 969 register_t *retval; 970 { 971 struct netbsd32_setpgid_args /* { 972 syscallarg(int) pid; 973 syscallarg(int) pgid; 974 } */ *uap = v; 975 struct sys_setpgid_args ua; 976 977 NETBSD32TO64_UAP(pid); 978 NETBSD32TO64_UAP(pgid); 979 return (sys_setpgid(p, &ua, retval)); 980 } 981 982 int 983 netbsd32_fcntl(p, v, retval) 984 struct proc *p; 985 void *v; 986 register_t *retval; 987 { 988 struct netbsd32_fcntl_args /* { 989 syscallarg(int) fd; 990 syscallarg(int) cmd; 991 syscallarg(netbsd32_voidp) arg; 992 } */ *uap = v; 993 struct sys_fcntl_args ua; 994 995 NETBSD32TO64_UAP(fd); 996 NETBSD32TO64_UAP(cmd); 997 NETBSD32TOP_UAP(arg, void); 998 /* we can do this because `struct flock' doesn't change */ 999 return (sys_fcntl(p, &ua, retval)); 1000 } 1001 1002 int 1003 netbsd32_dup2(p, v, retval) 1004 struct proc *p; 1005 void *v; 1006 register_t *retval; 1007 { 1008 struct netbsd32_dup2_args /* { 1009 syscallarg(int) from; 1010 syscallarg(int) to; 1011 } */ *uap = v; 1012 struct sys_dup2_args ua; 1013 1014 NETBSD32TO64_UAP(from); 1015 NETBSD32TO64_UAP(to); 1016 return (sys_dup2(p, &ua, retval)); 1017 } 1018 1019 int 1020 netbsd32_fsync(p, v, retval) 1021 struct proc *p; 1022 void *v; 1023 register_t *retval; 1024 { 1025 struct netbsd32_fsync_args /* { 1026 syscallarg(int) fd; 1027 } */ *uap = v; 1028 struct sys_fsync_args ua; 1029 1030 NETBSD32TO64_UAP(fd); 1031 return (sys_fsync(p, &ua, retval)); 1032 } 1033 1034 int 1035 netbsd32_setpriority(p, v, retval) 1036 struct proc *p; 1037 void *v; 1038 register_t *retval; 1039 { 1040 struct netbsd32_setpriority_args /* { 1041 syscallarg(int) which; 1042 syscallarg(int) who; 1043 syscallarg(int) prio; 1044 } */ *uap = v; 1045 struct sys_setpriority_args ua; 1046 1047 NETBSD32TO64_UAP(which); 1048 NETBSD32TO64_UAP(who); 1049 NETBSD32TO64_UAP(prio); 1050 return (sys_setpriority(p, &ua, retval)); 1051 } 1052 1053 int 1054 netbsd32_socket(p, v, retval) 1055 struct proc *p; 1056 void *v; 1057 register_t *retval; 1058 { 1059 struct netbsd32_socket_args /* { 1060 syscallarg(int) domain; 1061 syscallarg(int) type; 1062 syscallarg(int) protocol; 1063 } */ *uap = v; 1064 struct sys_socket_args ua; 1065 1066 NETBSD32TO64_UAP(domain); 1067 NETBSD32TO64_UAP(type); 1068 NETBSD32TO64_UAP(protocol); 1069 return (sys_socket(p, &ua, retval)); 1070 } 1071 1072 int 1073 netbsd32_connect(p, v, retval) 1074 struct proc *p; 1075 void *v; 1076 register_t *retval; 1077 { 1078 struct netbsd32_connect_args /* { 1079 syscallarg(int) s; 1080 syscallarg(const netbsd32_sockaddrp_t) name; 1081 syscallarg(int) namelen; 1082 } */ *uap = v; 1083 struct sys_connect_args ua; 1084 1085 NETBSD32TO64_UAP(s); 1086 NETBSD32TOP_UAP(name, struct sockaddr); 1087 NETBSD32TO64_UAP(namelen); 1088 return (sys_connect(p, &ua, retval)); 1089 } 1090 1091 int 1092 netbsd32_getpriority(p, v, retval) 1093 struct proc *p; 1094 void *v; 1095 register_t *retval; 1096 { 1097 struct netbsd32_getpriority_args /* { 1098 syscallarg(int) which; 1099 syscallarg(int) who; 1100 } */ *uap = v; 1101 struct sys_getpriority_args ua; 1102 1103 NETBSD32TO64_UAP(which); 1104 NETBSD32TO64_UAP(who); 1105 return (sys_getpriority(p, &ua, retval)); 1106 } 1107 1108 int 1109 netbsd32_bind(p, v, retval) 1110 struct proc *p; 1111 void *v; 1112 register_t *retval; 1113 { 1114 struct netbsd32_bind_args /* { 1115 syscallarg(int) s; 1116 syscallarg(const netbsd32_sockaddrp_t) name; 1117 syscallarg(int) namelen; 1118 } */ *uap = v; 1119 struct sys_bind_args ua; 1120 1121 NETBSD32TO64_UAP(s); 1122 NETBSD32TOP_UAP(name, struct sockaddr); 1123 NETBSD32TO64_UAP(namelen); 1124 return (sys_bind(p, &ua, retval)); 1125 } 1126 1127 int 1128 netbsd32_setsockopt(p, v, retval) 1129 struct proc *p; 1130 void *v; 1131 register_t *retval; 1132 { 1133 struct netbsd32_setsockopt_args /* { 1134 syscallarg(int) s; 1135 syscallarg(int) level; 1136 syscallarg(int) name; 1137 syscallarg(const netbsd32_voidp) val; 1138 syscallarg(int) valsize; 1139 } */ *uap = v; 1140 struct sys_setsockopt_args ua; 1141 1142 NETBSD32TO64_UAP(s); 1143 NETBSD32TO64_UAP(level); 1144 NETBSD32TO64_UAP(name); 1145 NETBSD32TOP_UAP(val, void); 1146 NETBSD32TO64_UAP(valsize); 1147 /* may be more efficient to do this inline. */ 1148 return (sys_setsockopt(p, &ua, retval)); 1149 } 1150 1151 int 1152 netbsd32_listen(p, v, retval) 1153 struct proc *p; 1154 void *v; 1155 register_t *retval; 1156 { 1157 struct netbsd32_listen_args /* { 1158 syscallarg(int) s; 1159 syscallarg(int) backlog; 1160 } */ *uap = v; 1161 struct sys_listen_args ua; 1162 1163 NETBSD32TO64_UAP(s); 1164 NETBSD32TO64_UAP(backlog); 1165 return (sys_listen(p, &ua, retval)); 1166 } 1167 1168 int 1169 netbsd32_fchown(p, v, retval) 1170 struct proc *p; 1171 void *v; 1172 register_t *retval; 1173 { 1174 struct netbsd32_fchown_args /* { 1175 syscallarg(int) fd; 1176 syscallarg(uid_t) uid; 1177 syscallarg(gid_t) gid; 1178 } */ *uap = v; 1179 struct sys_fchown_args ua; 1180 1181 NETBSD32TO64_UAP(fd); 1182 NETBSD32TO64_UAP(uid); 1183 NETBSD32TO64_UAP(gid); 1184 return (sys_fchown(p, &ua, retval)); 1185 } 1186 1187 int 1188 netbsd32_fchmod(p, v, retval) 1189 struct proc *p; 1190 void *v; 1191 register_t *retval; 1192 { 1193 struct netbsd32_fchmod_args /* { 1194 syscallarg(int) fd; 1195 syscallarg(mode_t) mode; 1196 } */ *uap = v; 1197 struct sys_fchmod_args ua; 1198 1199 NETBSD32TO64_UAP(fd); 1200 NETBSD32TO64_UAP(mode); 1201 return (sys_fchmod(p, &ua, retval)); 1202 } 1203 1204 int 1205 netbsd32_setreuid(p, v, retval) 1206 struct proc *p; 1207 void *v; 1208 register_t *retval; 1209 { 1210 struct netbsd32_setreuid_args /* { 1211 syscallarg(uid_t) ruid; 1212 syscallarg(uid_t) euid; 1213 } */ *uap = v; 1214 struct sys_setreuid_args ua; 1215 1216 NETBSD32TO64_UAP(ruid); 1217 NETBSD32TO64_UAP(euid); 1218 return (sys_setreuid(p, &ua, retval)); 1219 } 1220 1221 int 1222 netbsd32_setregid(p, v, retval) 1223 struct proc *p; 1224 void *v; 1225 register_t *retval; 1226 { 1227 struct netbsd32_setregid_args /* { 1228 syscallarg(gid_t) rgid; 1229 syscallarg(gid_t) egid; 1230 } */ *uap = v; 1231 struct sys_setregid_args ua; 1232 1233 NETBSD32TO64_UAP(rgid); 1234 NETBSD32TO64_UAP(egid); 1235 return (sys_setregid(p, &ua, retval)); 1236 } 1237 1238 int 1239 netbsd32_getsockopt(p, v, retval) 1240 struct proc *p; 1241 void *v; 1242 register_t *retval; 1243 { 1244 struct netbsd32_getsockopt_args /* { 1245 syscallarg(int) s; 1246 syscallarg(int) level; 1247 syscallarg(int) name; 1248 syscallarg(netbsd32_voidp) val; 1249 syscallarg(netbsd32_intp) avalsize; 1250 } */ *uap = v; 1251 struct sys_getsockopt_args ua; 1252 1253 NETBSD32TO64_UAP(s); 1254 NETBSD32TO64_UAP(level); 1255 NETBSD32TO64_UAP(name); 1256 NETBSD32TOP_UAP(val, void); 1257 NETBSD32TOP_UAP(avalsize, int); 1258 return (sys_getsockopt(p, &ua, retval)); 1259 } 1260 1261 int 1262 netbsd32_rename(p, v, retval) 1263 struct proc *p; 1264 void *v; 1265 register_t *retval; 1266 { 1267 struct netbsd32_rename_args /* { 1268 syscallarg(const netbsd32_charp) from; 1269 syscallarg(const netbsd32_charp) to; 1270 } */ *uap = v; 1271 struct sys_rename_args ua; 1272 1273 NETBSD32TOP_UAP(from, const char); 1274 NETBSD32TOP_UAP(to, const char) 1275 1276 return (sys_rename(p, &ua, retval)); 1277 } 1278 1279 int 1280 netbsd32_flock(p, v, retval) 1281 struct proc *p; 1282 void *v; 1283 register_t *retval; 1284 { 1285 struct netbsd32_flock_args /* { 1286 syscallarg(int) fd; 1287 syscallarg(int) how; 1288 } */ *uap = v; 1289 struct sys_flock_args ua; 1290 1291 NETBSD32TO64_UAP(fd); 1292 NETBSD32TO64_UAP(how) 1293 1294 return (sys_flock(p, &ua, retval)); 1295 } 1296 1297 int 1298 netbsd32_mkfifo(p, v, retval) 1299 struct proc *p; 1300 void *v; 1301 register_t *retval; 1302 { 1303 struct netbsd32_mkfifo_args /* { 1304 syscallarg(const netbsd32_charp) path; 1305 syscallarg(mode_t) mode; 1306 } */ *uap = v; 1307 struct sys_mkfifo_args ua; 1308 1309 NETBSD32TOP_UAP(path, const char) 1310 NETBSD32TO64_UAP(mode); 1311 return (sys_mkfifo(p, &ua, retval)); 1312 } 1313 1314 int 1315 netbsd32_shutdown(p, v, retval) 1316 struct proc *p; 1317 void *v; 1318 register_t *retval; 1319 { 1320 struct netbsd32_shutdown_args /* { 1321 syscallarg(int) s; 1322 syscallarg(int) how; 1323 } */ *uap = v; 1324 struct sys_shutdown_args ua; 1325 1326 NETBSD32TO64_UAP(s) 1327 NETBSD32TO64_UAP(how); 1328 return (sys_shutdown(p, &ua, retval)); 1329 } 1330 1331 int 1332 netbsd32_socketpair(p, v, retval) 1333 struct proc *p; 1334 void *v; 1335 register_t *retval; 1336 { 1337 struct netbsd32_socketpair_args /* { 1338 syscallarg(int) domain; 1339 syscallarg(int) type; 1340 syscallarg(int) protocol; 1341 syscallarg(netbsd32_intp) rsv; 1342 } */ *uap = v; 1343 struct sys_socketpair_args ua; 1344 1345 NETBSD32TO64_UAP(domain); 1346 NETBSD32TO64_UAP(type); 1347 NETBSD32TO64_UAP(protocol); 1348 NETBSD32TOP_UAP(rsv, int); 1349 /* Since we're just copying out two `int's we can do this */ 1350 return (sys_socketpair(p, &ua, retval)); 1351 } 1352 1353 int 1354 netbsd32_mkdir(p, v, retval) 1355 struct proc *p; 1356 void *v; 1357 register_t *retval; 1358 { 1359 struct netbsd32_mkdir_args /* { 1360 syscallarg(const netbsd32_charp) path; 1361 syscallarg(mode_t) mode; 1362 } */ *uap = v; 1363 struct sys_mkdir_args ua; 1364 1365 NETBSD32TOP_UAP(path, const char) 1366 NETBSD32TO64_UAP(mode); 1367 return (sys_mkdir(p, &ua, retval)); 1368 } 1369 1370 int 1371 netbsd32_rmdir(p, v, retval) 1372 struct proc *p; 1373 void *v; 1374 register_t *retval; 1375 { 1376 struct netbsd32_rmdir_args /* { 1377 syscallarg(const netbsd32_charp) path; 1378 } */ *uap = v; 1379 struct sys_rmdir_args ua; 1380 1381 NETBSD32TOP_UAP(path, const char); 1382 return (sys_rmdir(p, &ua, retval)); 1383 } 1384 1385 int 1386 netbsd32_quotactl(p, v, retval) 1387 struct proc *p; 1388 void *v; 1389 register_t *retval; 1390 { 1391 struct netbsd32_quotactl_args /* { 1392 syscallarg(const netbsd32_charp) path; 1393 syscallarg(int) cmd; 1394 syscallarg(int) uid; 1395 syscallarg(netbsd32_caddr_t) arg; 1396 } */ *uap = v; 1397 struct sys_quotactl_args ua; 1398 1399 NETBSD32TOP_UAP(path, const char); 1400 NETBSD32TO64_UAP(cmd); 1401 NETBSD32TO64_UAP(uid); 1402 NETBSD32TOX64_UAP(arg, caddr_t); 1403 return (sys_quotactl(p, &ua, retval)); 1404 } 1405 1406 #if defined(NFS) || defined(NFSSERVER) 1407 int 1408 netbsd32_nfssvc(p, v, retval) 1409 struct proc *p; 1410 void *v; 1411 register_t *retval; 1412 { 1413 #if 0 1414 struct netbsd32_nfssvc_args /* { 1415 syscallarg(int) flag; 1416 syscallarg(netbsd32_voidp) argp; 1417 } */ *uap = v; 1418 struct sys_nfssvc_args ua; 1419 1420 NETBSD32TO64_UAP(flag); 1421 NETBSD32TOP_UAP(argp, void); 1422 return (sys_nfssvc(p, &ua, retval)); 1423 #else 1424 /* Why would we want to support a 32-bit nfsd? */ 1425 return (ENOSYS); 1426 #endif 1427 } 1428 #endif 1429 1430 #if defined(NFS) || defined(NFSSERVER) 1431 int 1432 netbsd32_getfh(p, v, retval) 1433 struct proc *p; 1434 void *v; 1435 register_t *retval; 1436 { 1437 struct netbsd32_getfh_args /* { 1438 syscallarg(const netbsd32_charp) fname; 1439 syscallarg(netbsd32_fhandlep_t) fhp; 1440 } */ *uap = v; 1441 struct sys_getfh_args ua; 1442 1443 NETBSD32TOP_UAP(fname, const char); 1444 NETBSD32TOP_UAP(fhp, struct fhandle); 1445 /* Lucky for us a fhandlep_t doesn't change sizes */ 1446 return (sys_getfh(p, &ua, retval)); 1447 } 1448 #endif 1449 1450 int 1451 netbsd32_sysarch(p, v, retval) 1452 struct proc *p; 1453 void *v; 1454 register_t *retval; 1455 { 1456 struct netbsd32_sysarch_args /* { 1457 syscallarg(int) op; 1458 syscallarg(netbsd32_voidp) parms; 1459 } */ *uap = v; 1460 1461 switch (SCARG(uap, op)) { 1462 default: 1463 printf("(%s) netbsd32_sysarch(%d)\n", MACHINE, SCARG(uap, op)); 1464 return EINVAL; 1465 } 1466 } 1467 1468 int 1469 netbsd32_pread(p, v, retval) 1470 struct proc *p; 1471 void *v; 1472 register_t *retval; 1473 { 1474 struct netbsd32_pread_args /* { 1475 syscallarg(int) fd; 1476 syscallarg(netbsd32_voidp) buf; 1477 syscallarg(netbsd32_size_t) nbyte; 1478 syscallarg(int) pad; 1479 syscallarg(off_t) offset; 1480 } */ *uap = v; 1481 struct sys_pread_args ua; 1482 ssize_t rt; 1483 int error; 1484 1485 NETBSD32TO64_UAP(fd); 1486 NETBSD32TOP_UAP(buf, void); 1487 NETBSD32TOX_UAP(nbyte, size_t); 1488 NETBSD32TO64_UAP(pad); 1489 NETBSD32TO64_UAP(offset); 1490 error = sys_pread(p, &ua, (register_t *)&rt); 1491 *retval = rt; 1492 return (error); 1493 } 1494 1495 int 1496 netbsd32_pwrite(p, v, retval) 1497 struct proc *p; 1498 void *v; 1499 register_t *retval; 1500 { 1501 struct netbsd32_pwrite_args /* { 1502 syscallarg(int) fd; 1503 syscallarg(const netbsd32_voidp) buf; 1504 syscallarg(netbsd32_size_t) nbyte; 1505 syscallarg(int) pad; 1506 syscallarg(off_t) offset; 1507 } */ *uap = v; 1508 struct sys_pwrite_args ua; 1509 ssize_t rt; 1510 int error; 1511 1512 NETBSD32TO64_UAP(fd); 1513 NETBSD32TOP_UAP(buf, void); 1514 NETBSD32TOX_UAP(nbyte, size_t); 1515 NETBSD32TO64_UAP(pad); 1516 NETBSD32TO64_UAP(offset); 1517 error = sys_pwrite(p, &ua, (register_t *)&rt); 1518 *retval = rt; 1519 return (error); 1520 } 1521 1522 int 1523 netbsd32_setgid(p, v, retval) 1524 struct proc *p; 1525 void *v; 1526 register_t *retval; 1527 { 1528 struct netbsd32_setgid_args /* { 1529 syscallarg(gid_t) gid; 1530 } */ *uap = v; 1531 struct sys_setgid_args ua; 1532 1533 NETBSD32TO64_UAP(gid); 1534 return (sys_setgid(p, v, retval)); 1535 } 1536 1537 int 1538 netbsd32_setegid(p, v, retval) 1539 struct proc *p; 1540 void *v; 1541 register_t *retval; 1542 { 1543 struct netbsd32_setegid_args /* { 1544 syscallarg(gid_t) egid; 1545 } */ *uap = v; 1546 struct sys_setegid_args ua; 1547 1548 NETBSD32TO64_UAP(egid); 1549 return (sys_setegid(p, v, retval)); 1550 } 1551 1552 int 1553 netbsd32_seteuid(p, v, retval) 1554 struct proc *p; 1555 void *v; 1556 register_t *retval; 1557 { 1558 struct netbsd32_seteuid_args /* { 1559 syscallarg(gid_t) euid; 1560 } */ *uap = v; 1561 struct sys_seteuid_args ua; 1562 1563 NETBSD32TO64_UAP(euid); 1564 return (sys_seteuid(p, v, retval)); 1565 } 1566 1567 #ifdef LFS 1568 int 1569 netbsd32_sys_lfs_bmapv(p, v, retval) 1570 struct proc *p; 1571 void *v; 1572 register_t *retval; 1573 { 1574 1575 return (ENOSYS); /* XXX */ 1576 } 1577 1578 int 1579 netbsd32_sys_lfs_markv(p, v, retval) 1580 struct proc *p; 1581 void *v; 1582 register_t *retval; 1583 { 1584 1585 return (ENOSYS); /* XXX */ 1586 } 1587 1588 int 1589 netbsd32_sys_lfs_segclean(p, v, retval) 1590 struct proc *p; 1591 void *v; 1592 register_t *retval; 1593 { 1594 1595 return (ENOSYS); /* XXX */ 1596 } 1597 1598 int 1599 netbsd32_sys_lfs_segwait(p, v, retval) 1600 struct proc *p; 1601 void *v; 1602 register_t *retval; 1603 { 1604 1605 return (ENOSYS); /* XXX */ 1606 } 1607 #endif 1608 1609 int 1610 netbsd32_pathconf(p, v, retval) 1611 struct proc *p; 1612 void *v; 1613 register_t *retval; 1614 { 1615 struct netbsd32_pathconf_args /* { 1616 syscallarg(int) fd; 1617 syscallarg(int) name; 1618 } */ *uap = v; 1619 struct sys_pathconf_args ua; 1620 long rt; 1621 int error; 1622 1623 NETBSD32TOP_UAP(path, const char); 1624 NETBSD32TO64_UAP(name); 1625 error = sys_pathconf(p, &ua, (register_t *)&rt); 1626 *retval = rt; 1627 return (error); 1628 } 1629 1630 int 1631 netbsd32_fpathconf(p, v, retval) 1632 struct proc *p; 1633 void *v; 1634 register_t *retval; 1635 { 1636 struct netbsd32_fpathconf_args /* { 1637 syscallarg(int) fd; 1638 syscallarg(int) name; 1639 } */ *uap = v; 1640 struct sys_fpathconf_args ua; 1641 long rt; 1642 int error; 1643 1644 NETBSD32TO64_UAP(fd); 1645 NETBSD32TO64_UAP(name); 1646 error = sys_fpathconf(p, &ua, (register_t *)&rt); 1647 *retval = rt; 1648 return (error); 1649 } 1650 1651 int 1652 netbsd32_getrlimit(p, v, retval) 1653 struct proc *p; 1654 void *v; 1655 register_t *retval; 1656 { 1657 struct netbsd32_getrlimit_args /* { 1658 syscallarg(int) which; 1659 syscallarg(netbsd32_rlimitp_t) rlp; 1660 } */ *uap = v; 1661 int which = SCARG(uap, which); 1662 1663 if ((u_int)which >= RLIM_NLIMITS) 1664 return (EINVAL); 1665 return (copyout(&p->p_rlimit[which], (caddr_t)(u_long)SCARG(uap, rlp), 1666 sizeof(struct rlimit))); 1667 } 1668 1669 int 1670 netbsd32_setrlimit(p, v, retval) 1671 struct proc *p; 1672 void *v; 1673 register_t *retval; 1674 { 1675 struct netbsd32_setrlimit_args /* { 1676 syscallarg(int) which; 1677 syscallarg(const netbsd32_rlimitp_t) rlp; 1678 } */ *uap = v; 1679 int which = SCARG(uap, which); 1680 struct rlimit alim; 1681 int error; 1682 1683 error = copyin((caddr_t)(u_long)SCARG(uap, rlp), &alim, sizeof(struct rlimit)); 1684 if (error) 1685 return (error); 1686 return (dosetrlimit(p, p->p_cred, which, &alim)); 1687 } 1688 1689 int 1690 netbsd32_mmap(p, v, retval) 1691 struct proc *p; 1692 void *v; 1693 register_t *retval; 1694 { 1695 struct netbsd32_mmap_args /* { 1696 syscallarg(netbsd32_voidp) addr; 1697 syscallarg(netbsd32_size_t) len; 1698 syscallarg(int) prot; 1699 syscallarg(int) flags; 1700 syscallarg(int) fd; 1701 syscallarg(netbsd32_long) pad; 1702 syscallarg(off_t) pos; 1703 } */ *uap = v; 1704 struct sys_mmap_args ua; 1705 void *rt; 1706 int error; 1707 1708 NETBSD32TOP_UAP(addr, void); 1709 NETBSD32TOX_UAP(len, size_t); 1710 NETBSD32TO64_UAP(prot); 1711 NETBSD32TO64_UAP(flags); 1712 NETBSD32TO64_UAP(fd); 1713 NETBSD32TOX_UAP(pad, long); 1714 NETBSD32TOX_UAP(pos, off_t); 1715 error = sys_mmap(p, &ua, (register_t *)&rt); 1716 if ((u_long)rt > (u_long)UINT_MAX) { 1717 printf("netbsd32_mmap: retval out of range: %p", rt); 1718 /* Should try to recover and return an error here. */ 1719 } 1720 *retval = (netbsd32_voidp)(u_long)rt; 1721 return (error); 1722 } 1723 1724 int 1725 netbsd32_lseek(p, v, retval) 1726 struct proc *p; 1727 void *v; 1728 register_t *retval; 1729 { 1730 struct netbsd32_lseek_args /* { 1731 syscallarg(int) fd; 1732 syscallarg(int) pad; 1733 syscallarg(off_t) offset; 1734 syscallarg(int) whence; 1735 } */ *uap = v; 1736 struct sys_lseek_args ua; 1737 1738 NETBSD32TO64_UAP(fd); 1739 NETBSD32TO64_UAP(pad); 1740 NETBSD32TO64_UAP(offset); 1741 NETBSD32TO64_UAP(whence); 1742 return (sys_lseek(p, &ua, retval)); 1743 } 1744 1745 int 1746 netbsd32_truncate(p, v, retval) 1747 struct proc *p; 1748 void *v; 1749 register_t *retval; 1750 { 1751 struct netbsd32_truncate_args /* { 1752 syscallarg(const netbsd32_charp) path; 1753 syscallarg(int) pad; 1754 syscallarg(off_t) length; 1755 } */ *uap = v; 1756 struct sys_truncate_args ua; 1757 1758 NETBSD32TOP_UAP(path, const char); 1759 NETBSD32TO64_UAP(pad); 1760 NETBSD32TO64_UAP(length); 1761 return (sys_truncate(p, &ua, retval)); 1762 } 1763 1764 int 1765 netbsd32_ftruncate(p, v, retval) 1766 struct proc *p; 1767 void *v; 1768 register_t *retval; 1769 { 1770 struct netbsd32_ftruncate_args /* { 1771 syscallarg(int) fd; 1772 syscallarg(int) pad; 1773 syscallarg(off_t) length; 1774 } */ *uap = v; 1775 struct sys_ftruncate_args ua; 1776 1777 NETBSD32TO64_UAP(fd); 1778 NETBSD32TO64_UAP(pad); 1779 NETBSD32TO64_UAP(length); 1780 return (sys_ftruncate(p, &ua, retval)); 1781 } 1782 1783 int 1784 netbsd32_mlock(p, v, retval) 1785 struct proc *p; 1786 void *v; 1787 register_t *retval; 1788 { 1789 struct netbsd32_mlock_args /* { 1790 syscallarg(const netbsd32_voidp) addr; 1791 syscallarg(netbsd32_size_t) len; 1792 } */ *uap = v; 1793 struct sys_mlock_args ua; 1794 1795 NETBSD32TOP_UAP(addr, const void); 1796 NETBSD32TO64_UAP(len); 1797 return (sys_mlock(p, &ua, retval)); 1798 } 1799 1800 int 1801 netbsd32_munlock(p, v, retval) 1802 struct proc *p; 1803 void *v; 1804 register_t *retval; 1805 { 1806 struct netbsd32_munlock_args /* { 1807 syscallarg(const netbsd32_voidp) addr; 1808 syscallarg(netbsd32_size_t) len; 1809 } */ *uap = v; 1810 struct sys_munlock_args ua; 1811 1812 NETBSD32TOP_UAP(addr, const void); 1813 NETBSD32TO64_UAP(len); 1814 return (sys_munlock(p, &ua, retval)); 1815 } 1816 1817 int 1818 netbsd32_undelete(p, v, retval) 1819 struct proc *p; 1820 void *v; 1821 register_t *retval; 1822 { 1823 struct netbsd32_undelete_args /* { 1824 syscallarg(const netbsd32_charp) path; 1825 } */ *uap = v; 1826 struct sys_undelete_args ua; 1827 1828 NETBSD32TOP_UAP(path, const char); 1829 return (sys_undelete(p, &ua, retval)); 1830 } 1831 1832 int 1833 netbsd32_getpgid(p, v, retval) 1834 struct proc *p; 1835 void *v; 1836 register_t *retval; 1837 { 1838 struct netbsd32_getpgid_args /* { 1839 syscallarg(pid_t) pid; 1840 } */ *uap = v; 1841 struct sys_getpgid_args ua; 1842 1843 NETBSD32TO64_UAP(pid); 1844 return (sys_getpgid(p, &ua, retval)); 1845 } 1846 1847 int 1848 netbsd32_reboot(p, v, retval) 1849 struct proc *p; 1850 void *v; 1851 register_t *retval; 1852 { 1853 struct netbsd32_reboot_args /* { 1854 syscallarg(int) opt; 1855 syscallarg(netbsd32_charp) bootstr; 1856 } */ *uap = v; 1857 struct sys_reboot_args ua; 1858 1859 NETBSD32TO64_UAP(opt); 1860 NETBSD32TOP_UAP(bootstr, char); 1861 return (sys_reboot(p, &ua, retval)); 1862 } 1863 1864 int 1865 netbsd32_poll(p, v, retval) 1866 struct proc *p; 1867 void *v; 1868 register_t *retval; 1869 { 1870 struct netbsd32_poll_args /* { 1871 syscallarg(netbsd32_pollfdp_t) fds; 1872 syscallarg(u_int) nfds; 1873 syscallarg(int) timeout; 1874 } */ *uap = v; 1875 struct sys_poll_args ua; 1876 1877 NETBSD32TOP_UAP(fds, struct pollfd); 1878 NETBSD32TO64_UAP(nfds); 1879 NETBSD32TO64_UAP(timeout); 1880 return (sys_poll(p, &ua, retval)); 1881 } 1882 1883 int 1884 netbsd32_fdatasync(p, v, retval) 1885 struct proc *p; 1886 void *v; 1887 register_t *retval; 1888 { 1889 struct netbsd32_fdatasync_args /* { 1890 syscallarg(int) fd; 1891 } */ *uap = v; 1892 struct sys_fdatasync_args ua; 1893 1894 NETBSD32TO64_UAP(fd); 1895 return (sys_fdatasync(p, &ua, retval)); 1896 } 1897 1898 int 1899 netbsd32___posix_rename(p, v, retval) 1900 struct proc *p; 1901 void *v; 1902 register_t *retval; 1903 { 1904 struct netbsd32___posix_rename_args /* { 1905 syscallarg(const netbsd32_charp) from; 1906 syscallarg(const netbsd32_charp) to; 1907 } */ *uap = v; 1908 struct sys___posix_rename_args ua; 1909 1910 NETBSD32TOP_UAP(from, const char); 1911 NETBSD32TOP_UAP(to, const char); 1912 return (sys___posix_rename(p, &ua, retval)); 1913 } 1914 1915 int 1916 netbsd32_swapctl(p, v, retval) 1917 struct proc *p; 1918 void *v; 1919 register_t *retval; 1920 { 1921 struct netbsd32_swapctl_args /* { 1922 syscallarg(int) cmd; 1923 syscallarg(const netbsd32_voidp) arg; 1924 syscallarg(int) misc; 1925 } */ *uap = v; 1926 struct sys_swapctl_args ua; 1927 1928 NETBSD32TO64_UAP(cmd); 1929 NETBSD32TOP_UAP(arg, const void); 1930 NETBSD32TO64_UAP(misc); 1931 return (sys_swapctl(p, &ua, retval)); 1932 } 1933 1934 int 1935 netbsd32_minherit(p, v, retval) 1936 struct proc *p; 1937 void *v; 1938 register_t *retval; 1939 { 1940 struct netbsd32_minherit_args /* { 1941 syscallarg(netbsd32_voidp) addr; 1942 syscallarg(netbsd32_size_t) len; 1943 syscallarg(int) inherit; 1944 } */ *uap = v; 1945 struct sys_minherit_args ua; 1946 1947 NETBSD32TOP_UAP(addr, void); 1948 NETBSD32TOX_UAP(len, size_t); 1949 NETBSD32TO64_UAP(inherit); 1950 return (sys_minherit(p, &ua, retval)); 1951 } 1952 1953 int 1954 netbsd32_lchmod(p, v, retval) 1955 struct proc *p; 1956 void *v; 1957 register_t *retval; 1958 { 1959 struct netbsd32_lchmod_args /* { 1960 syscallarg(const netbsd32_charp) path; 1961 syscallarg(mode_t) mode; 1962 } */ *uap = v; 1963 struct sys_lchmod_args ua; 1964 1965 NETBSD32TOP_UAP(path, const char); 1966 NETBSD32TO64_UAP(mode); 1967 return (sys_lchmod(p, &ua, retval)); 1968 } 1969 1970 int 1971 netbsd32_lchown(p, v, retval) 1972 struct proc *p; 1973 void *v; 1974 register_t *retval; 1975 { 1976 struct netbsd32_lchown_args /* { 1977 syscallarg(const netbsd32_charp) path; 1978 syscallarg(uid_t) uid; 1979 syscallarg(gid_t) gid; 1980 } */ *uap = v; 1981 struct sys_lchown_args ua; 1982 1983 NETBSD32TOP_UAP(path, const char); 1984 NETBSD32TO64_UAP(uid); 1985 NETBSD32TO64_UAP(gid); 1986 return (sys_lchown(p, &ua, retval)); 1987 } 1988 1989 int 1990 netbsd32___msync13(p, v, retval) 1991 struct proc *p; 1992 void *v; 1993 register_t *retval; 1994 { 1995 struct netbsd32___msync13_args /* { 1996 syscallarg(netbsd32_voidp) addr; 1997 syscallarg(netbsd32_size_t) len; 1998 syscallarg(int) flags; 1999 } */ *uap = v; 2000 struct sys___msync13_args ua; 2001 2002 NETBSD32TOP_UAP(addr, void); 2003 NETBSD32TOX_UAP(len, size_t); 2004 NETBSD32TO64_UAP(flags); 2005 return (sys___msync13(p, &ua, retval)); 2006 } 2007 2008 int 2009 netbsd32___posix_chown(p, v, retval) 2010 struct proc *p; 2011 void *v; 2012 register_t *retval; 2013 { 2014 struct netbsd32___posix_chown_args /* { 2015 syscallarg(const netbsd32_charp) path; 2016 syscallarg(uid_t) uid; 2017 syscallarg(gid_t) gid; 2018 } */ *uap = v; 2019 struct sys___posix_chown_args ua; 2020 2021 NETBSD32TOP_UAP(path, const char); 2022 NETBSD32TO64_UAP(uid); 2023 NETBSD32TO64_UAP(gid); 2024 return (sys___posix_chown(p, &ua, retval)); 2025 } 2026 2027 int 2028 netbsd32___posix_fchown(p, v, retval) 2029 struct proc *p; 2030 void *v; 2031 register_t *retval; 2032 { 2033 struct netbsd32___posix_fchown_args /* { 2034 syscallarg(int) fd; 2035 syscallarg(uid_t) uid; 2036 syscallarg(gid_t) gid; 2037 } */ *uap = v; 2038 struct sys___posix_fchown_args ua; 2039 2040 NETBSD32TO64_UAP(fd); 2041 NETBSD32TO64_UAP(uid); 2042 NETBSD32TO64_UAP(gid); 2043 return (sys___posix_fchown(p, &ua, retval)); 2044 } 2045 2046 int 2047 netbsd32___posix_lchown(p, v, retval) 2048 struct proc *p; 2049 void *v; 2050 register_t *retval; 2051 { 2052 struct netbsd32___posix_lchown_args /* { 2053 syscallarg(const netbsd32_charp) path; 2054 syscallarg(uid_t) uid; 2055 syscallarg(gid_t) gid; 2056 } */ *uap = v; 2057 struct sys___posix_lchown_args ua; 2058 2059 NETBSD32TOP_UAP(path, const char); 2060 NETBSD32TO64_UAP(uid); 2061 NETBSD32TO64_UAP(gid); 2062 return (sys___posix_lchown(p, &ua, retval)); 2063 } 2064 2065 int 2066 netbsd32_getsid(p, v, retval) 2067 struct proc *p; 2068 void *v; 2069 register_t *retval; 2070 { 2071 struct netbsd32_getsid_args /* { 2072 syscallarg(pid_t) pid; 2073 } */ *uap = v; 2074 struct sys_getsid_args ua; 2075 2076 NETBSD32TO64_UAP(pid); 2077 return (sys_getsid(p, &ua, retval)); 2078 } 2079 2080 #ifdef KTRACE 2081 int 2082 netbsd32_fktrace(p, v, retval) 2083 struct proc *p; 2084 void *v; 2085 register_t *retval; 2086 { 2087 struct netbsd32_fktrace_args /* { 2088 syscallarg(const int) fd; 2089 syscallarg(int) ops; 2090 syscallarg(int) facs; 2091 syscallarg(int) pid; 2092 } */ *uap = v; 2093 #if 0 2094 struct sys_fktrace_args ua; 2095 #else 2096 /* XXXX */ 2097 struct sys_fktrace_noconst_args { 2098 syscallarg(int) fd; 2099 syscallarg(int) ops; 2100 syscallarg(int) facs; 2101 syscallarg(int) pid; 2102 } ua; 2103 #endif 2104 2105 NETBSD32TOX_UAP(fd, int); 2106 NETBSD32TO64_UAP(ops); 2107 NETBSD32TO64_UAP(facs); 2108 NETBSD32TO64_UAP(pid); 2109 return (sys_fktrace(p, &ua, retval)); 2110 } 2111 #endif /* KTRACE */ 2112 2113 int netbsd32___sigpending14(p, v, retval) 2114 struct proc *p; 2115 void *v; 2116 register_t *retval; 2117 { 2118 struct netbsd32___sigpending14_args /* { 2119 syscallarg(sigset_t *) set; 2120 } */ *uap = v; 2121 struct sys___sigpending14_args ua; 2122 2123 NETBSD32TOP_UAP(set, sigset_t); 2124 return (sys___sigpending14(p, &ua, retval)); 2125 } 2126 2127 int netbsd32___sigprocmask14(p, v, retval) 2128 struct proc *p; 2129 void *v; 2130 register_t *retval; 2131 { 2132 struct netbsd32___sigprocmask14_args /* { 2133 syscallarg(int) how; 2134 syscallarg(const sigset_t *) set; 2135 syscallarg(sigset_t *) oset; 2136 } */ *uap = v; 2137 struct sys___sigprocmask14_args ua; 2138 2139 NETBSD32TO64_UAP(how); 2140 NETBSD32TOP_UAP(set, sigset_t); 2141 NETBSD32TOP_UAP(oset, sigset_t); 2142 return (sys___sigprocmask14(p, &ua, retval)); 2143 } 2144 2145 int netbsd32___sigsuspend14(p, v, retval) 2146 struct proc *p; 2147 void *v; 2148 register_t *retval; 2149 { 2150 struct netbsd32___sigsuspend14_args /* { 2151 syscallarg(const sigset_t *) set; 2152 } */ *uap = v; 2153 struct sys___sigsuspend14_args ua; 2154 2155 NETBSD32TOP_UAP(set, sigset_t); 2156 return (sys___sigsuspend14(p, &ua, retval)); 2157 }; 2158 2159 int netbsd32_fchroot(p, v, retval) 2160 struct proc *p; 2161 void *v; 2162 register_t *retval; 2163 { 2164 struct netbsd32_fchroot_args /* { 2165 syscallarg(int) fd; 2166 } */ *uap = v; 2167 struct sys_fchroot_args ua; 2168 2169 NETBSD32TO64_UAP(fd); 2170 return (sys_fchroot(p, &ua, retval)); 2171 } 2172 2173 /* 2174 * Open a file given a file handle. 2175 * 2176 * Check permissions, allocate an open file structure, 2177 * and call the device open routine if any. 2178 */ 2179 int 2180 netbsd32_fhopen(p, v, retval) 2181 struct proc *p; 2182 void *v; 2183 register_t *retval; 2184 { 2185 struct netbsd32_fhopen_args /* { 2186 syscallarg(const fhandle_t *) fhp; 2187 syscallarg(int) flags; 2188 } */ *uap = v; 2189 struct sys_fhopen_args ua; 2190 2191 NETBSD32TOP_UAP(fhp, fhandle_t); 2192 NETBSD32TO64_UAP(flags); 2193 return (sys_fhopen(p, &ua, retval)); 2194 } 2195 2196 int netbsd32_fhstat(p, v, retval) 2197 struct proc *p; 2198 void *v; 2199 register_t *retval; 2200 { 2201 struct netbsd32_fhstat_args /* { 2202 syscallarg(const netbsd32_fhandlep_t) fhp; 2203 syscallarg(struct stat *) sb; 2204 } */ *uap = v; 2205 struct sys_fhstat_args ua; 2206 2207 NETBSD32TOP_UAP(fhp, const fhandle_t); 2208 NETBSD32TOP_UAP(sb, struct stat); 2209 return (sys_fhstat(p, &ua, retval)); 2210 } 2211 2212 int netbsd32_fhstatfs(p, v, retval) 2213 struct proc *p; 2214 void *v; 2215 register_t *retval; 2216 { 2217 struct netbsd32_fhstatfs_args /* { 2218 syscallarg(const netbsd32_fhandlep_t) fhp; 2219 syscallarg(struct statfs *) buf; 2220 } */ *uap = v; 2221 struct sys_fhstatfs_args ua; 2222 2223 NETBSD32TOP_UAP(fhp, const fhandle_t); 2224 NETBSD32TOP_UAP(buf, struct statfs); 2225 return (sys_fhstatfs(p, &ua, retval)); 2226 } 2227 2228 /* virtual memory syscalls */ 2229 int 2230 netbsd32_ovadvise(p, v, retval) 2231 struct proc *p; 2232 void *v; 2233 register_t *retval; 2234 { 2235 struct netbsd32_ovadvise_args /* { 2236 syscallarg(int) anom; 2237 } */ *uap = v; 2238 struct sys_ovadvise_args ua; 2239 2240 NETBSD32TO64_UAP(anom); 2241 return (sys_ovadvise(p, &ua, retval)); 2242 } 2243 2244