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