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