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