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