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