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