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