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