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