1 /* $NetBSD: linux32_unistd.c,v 1.42 2019/11/09 23:44:31 jdolecek Exp $ */ 2 3 /*- 4 * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed by Emmanuel Dreyfus 17 * 4. The name of the author may not be used to endorse or promote 18 * products derived from this software without specific prior written 19 * permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE THE AUTHOR AND CONTRIBUTORS ``AS IS'' 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #include <sys/cdefs.h> 35 36 __KERNEL_RCSID(0, "$NetBSD: linux32_unistd.c,v 1.42 2019/11/09 23:44:31 jdolecek Exp $"); 37 38 #include <sys/types.h> 39 #include <sys/param.h> 40 #include <sys/fstypes.h> 41 #include <sys/signal.h> 42 #include <sys/dirent.h> 43 #include <sys/kernel.h> 44 #include <sys/fcntl.h> 45 #include <sys/select.h> 46 #include <sys/proc.h> 47 #include <sys/ucred.h> 48 #include <sys/swap.h> 49 #include <sys/kauth.h> 50 #include <sys/filedesc.h> 51 #include <sys/vfs_syscalls.h> 52 53 #include <machine/types.h> 54 55 #include <sys/syscallargs.h> 56 57 #include <compat/netbsd32/netbsd32.h> 58 #include <compat/netbsd32/netbsd32_conv.h> 59 60 #include <compat/linux/common/linux_types.h> 61 #include <compat/linux/common/linux_signal.h> 62 #include <compat/linux/common/linux_machdep.h> 63 #include <compat/linux/common/linux_misc.h> 64 #include <compat/linux/common/linux_oldolduname.h> 65 #include <compat/linux/common/linux_ipc.h> 66 #include <compat/linux/common/linux_sem.h> 67 #include <compat/linux/common/linux_fcntl.h> 68 #include <compat/linux/linux_syscallargs.h> 69 70 #include <compat/linux32/common/linux32_types.h> 71 #include <compat/linux32/common/linux32_signal.h> 72 #include <compat/linux32/common/linux32_machdep.h> 73 #include <compat/linux32/common/linux32_sched.h> 74 #include <compat/linux32/common/linux32_sysctl.h> 75 #include <compat/linux32/common/linux32_socketcall.h> 76 #include <compat/linux32/linux32_syscallargs.h> 77 78 static int linux32_select1(struct lwp *, register_t *, 79 int, fd_set *, fd_set *, fd_set *, struct timeval *); 80 81 int 82 linux32_sys_brk(struct lwp *l, const struct linux32_sys_brk_args *uap, register_t *retval) 83 { 84 /* { 85 syscallarg(netbsd32_charp) nsize; 86 } */ 87 struct linux_sys_brk_args ua; 88 89 NETBSD32TOP_UAP(nsize, char); 90 return linux_sys_brk(l, &ua, retval); 91 } 92 93 int 94 linux32_sys_llseek(struct lwp *l, const struct linux32_sys_llseek_args *uap, register_t *retval) 95 { 96 /* { 97 syscallarg(int) fd; 98 syscallarg(u_int32_t) ohigh; 99 syscallarg(u_int32_t) olow; 100 syscallarg(netbsd32_voidp) res; 101 syscallarg(int) whence; 102 } */ 103 struct linux_sys_llseek_args ua; 104 105 NETBSD32TO64_UAP(fd); 106 NETBSD32TO64_UAP(ohigh); 107 NETBSD32TO64_UAP(olow); 108 NETBSD32TOP_UAP(res, void); 109 NETBSD32TO64_UAP(whence); 110 111 return linux_sys_llseek(l, &ua, retval); 112 } 113 114 int 115 linux32_sys_select(struct lwp *l, const struct linux32_sys_select_args *uap, register_t *retval) 116 { 117 /* { 118 syscallarg(int) nfds; 119 syscallarg(netbsd32_fd_setp_t) readfds; 120 syscallarg(netbsd32_fd_setp_t) writefds; 121 syscallarg(netbsd32_fd_setp_t) exceptfds; 122 syscallarg(netbsd32_timeval50p_t) timeout; 123 } */ 124 125 return linux32_select1(l, retval, SCARG(uap, nfds), 126 SCARG_P32(uap, readfds), 127 SCARG_P32(uap, writefds), 128 SCARG_P32(uap, exceptfds), 129 SCARG_P32(uap, timeout)); 130 } 131 132 int 133 linux32_sys_oldselect(struct lwp *l, const struct linux32_sys_oldselect_args *uap, register_t *retval) 134 { 135 /* { 136 syscallarg(linux32_oldselectp_t) lsp; 137 } */ 138 struct linux32_oldselect lsp32; 139 int error; 140 141 if ((error = copyin(SCARG_P32(uap, lsp), &lsp32, sizeof(lsp32))) != 0) 142 return error; 143 144 return linux32_select1(l, retval, lsp32.nfds, 145 NETBSD32PTR64(lsp32.readfds), NETBSD32PTR64(lsp32.writefds), 146 NETBSD32PTR64(lsp32.exceptfds), NETBSD32PTR64(lsp32.timeout)); 147 } 148 149 static int 150 linux32_select1(struct lwp *l, register_t *retval, int nfds, 151 fd_set *readfds, fd_set *writefds, fd_set *exceptfds, 152 struct timeval *timeout) 153 { 154 struct timespec ts0, ts1, uts, *ts = NULL; 155 struct netbsd32_timeval50 utv32; 156 int error; 157 158 159 /* 160 * Store current time for computation of the amount of 161 * time left. 162 */ 163 if (timeout) { 164 if ((error = copyin(timeout, &utv32, sizeof(utv32)))) 165 return error; 166 167 uts.tv_sec = utv32.tv_sec; 168 uts.tv_nsec = (long)((unsigned long)utv32.tv_usec * 1000); 169 170 if (itimespecfix(&uts)) { 171 /* 172 * The timeval was invalid. Convert it to something 173 * valid that will act as it does under Linux. 174 */ 175 uts.tv_sec += uts.tv_nsec / 1000000000; 176 uts.tv_nsec %= 1000000000; 177 if (uts.tv_nsec < 0) { 178 uts.tv_sec -= 1; 179 uts.tv_nsec += 1000000000; 180 } 181 if (uts.tv_sec < 0) 182 timespecclear(&uts); 183 } 184 nanotime(&ts0); 185 ts = &uts; 186 } else 187 timespecclear(&uts); /* XXX GCC4 */ 188 189 error = selcommon(retval, nfds, readfds, writefds, exceptfds, ts, NULL); 190 191 if (error) { 192 /* 193 * See fs/select.c in the Linux kernel. Without this, 194 * Maelstrom doesn't work. 195 */ 196 if (error == ERESTART) 197 error = EINTR; 198 return error; 199 } 200 201 if (timeout) { 202 if (*retval) { 203 /* 204 * Compute how much time was left of the timeout, 205 * by subtracting the current time and the time 206 * before we started the call, and subtracting 207 * that result from the user-supplied value. 208 */ 209 nanotime(&ts1); 210 timespecsub(&ts1, &ts0, &ts1); 211 timespecsub(&uts, &ts1, &uts); 212 if (uts.tv_sec < 0) 213 timespecclear(&uts); 214 } else { 215 timespecclear(&uts); 216 } 217 218 utv32.tv_sec = uts.tv_sec; 219 utv32.tv_usec = uts.tv_nsec / 1000; 220 221 if ((error = copyout(&utv32, timeout, sizeof(utv32)))) 222 return error; 223 } 224 225 return 0; 226 } 227 228 int 229 linux32_sys_pipe(struct lwp *l, const struct linux32_sys_pipe_args *uap, 230 register_t *retval) 231 { 232 /* { 233 syscallarg(netbsd32_intp) fd; 234 } */ 235 int f[2], error; 236 237 if ((error = pipe1(l, f, 0))) 238 return error; 239 240 if ((error = copyout(f, SCARG_P32(uap, fd), sizeof(f))) != 0) 241 return error; 242 retval[0] = 0; 243 return 0; 244 } 245 246 int 247 linux32_sys_pipe2(struct lwp *l, const struct linux32_sys_pipe2_args *uap, 248 register_t *retval) 249 { 250 /* { 251 syscallarg(netbsd32_intp) fd; 252 } */ 253 int f[2], flags, error; 254 255 flags = linux_to_bsd_ioflags(SCARG(uap, flags)); 256 if ((flags & ~(O_CLOEXEC|O_NONBLOCK)) != 0) 257 return EINVAL; 258 259 if ((error = pipe1(l, f, flags))) 260 return error; 261 262 if ((error = copyout(f, SCARG_P32(uap, fd), sizeof(f))) != 0) 263 return error; 264 retval[0] = 0; 265 return 0; 266 } 267 268 int 269 linux32_sys_dup3(struct lwp *l, const struct linux32_sys_dup3_args *uap, 270 register_t *retval) 271 { 272 /* { 273 syscallarg(int) from; 274 syscallarg(int) to; 275 syscallarg(int) flags; 276 } */ 277 struct linux_sys_dup3_args ua; 278 279 NETBSD32TO64_UAP(from); 280 NETBSD32TO64_UAP(to); 281 NETBSD32TO64_UAP(flags); 282 283 return linux_sys_dup3(l, &ua, retval); 284 } 285 286 287 int 288 linux32_sys_openat(struct lwp *l, const struct linux32_sys_openat_args *uap, register_t *retval) 289 { 290 /* { 291 syscallarg(int) fd; 292 syscallarg(const netbsd32_charp) path; 293 syscallarg(int) flags; 294 syscallarg(int) mode; 295 } */ 296 struct linux_sys_openat_args ua; 297 298 NETBSD32TO64_UAP(fd); 299 NETBSD32TOP_UAP(path, const char); 300 NETBSD32TO64_UAP(flags); 301 NETBSD32TO64_UAP(mode); 302 303 return linux_sys_openat(l, &ua, retval); 304 } 305 306 int 307 linux32_sys_mknodat(struct lwp *l, const struct linux32_sys_mknodat_args *uap, register_t *retval) 308 { 309 /* { 310 syscallarg(int) fd; 311 syscallarg(const netbsd32_charp) path; 312 syscallarg(linux_umode_t) mode; 313 syscallarg(unsigned) dev; 314 } */ 315 struct linux_sys_mknodat_args ua; 316 317 NETBSD32TO64_UAP(fd); 318 NETBSD32TOP_UAP(path, const char); 319 NETBSD32TO64_UAP(mode); 320 NETBSD32TO64_UAP(dev); 321 322 return linux_sys_mknodat(l, &ua, retval); 323 } 324 325 int 326 linux32_sys_linkat(struct lwp *l, const struct linux32_sys_linkat_args *uap, register_t *retval) 327 { 328 /* { 329 syscallarg(int) fd1; 330 syscallarg(netbsd32_charp) name1; 331 syscallarg(int) fd2; 332 syscallarg(netbsd32_charp) name2; 333 syscallarg(int) flags; 334 } */ 335 int fd1 = SCARG(uap, fd1); 336 const char *name1 = SCARG_P32(uap, name1); 337 int fd2 = SCARG(uap, fd2); 338 const char *name2 = SCARG_P32(uap, name2); 339 int follow; 340 341 follow = SCARG(uap, flags) & LINUX_AT_SYMLINK_FOLLOW; 342 343 return do_sys_linkat(l, fd1, name1, fd2, name2, follow, retval); 344 } 345 346 int 347 linux32_sys_unlink(struct lwp *l, const struct linux32_sys_unlink_args *uap, register_t *retval) 348 { 349 /* { 350 syscallarg(const netbsd32_charp) path; 351 } */ 352 struct linux_sys_unlink_args ua; 353 354 NETBSD32TOP_UAP(path, const char); 355 356 return linux_sys_unlink(l, &ua, retval); 357 } 358 359 int 360 linux32_sys_unlinkat(struct lwp *l, const struct linux32_sys_unlinkat_args *uap, register_t *retval) 361 { 362 /* { 363 syscallarg(int) fd; 364 syscallarg(const netbsd32_charp) path; 365 syscallarg(int) flag; 366 } */ 367 struct linux_sys_unlinkat_args ua; 368 369 NETBSD32TO64_UAP(fd); 370 NETBSD32TOP_UAP(path, const char); 371 NETBSD32TO64_UAP(flag); 372 373 return linux_sys_unlinkat(l, &ua, retval); 374 } 375 376 int 377 linux32_sys_fchmodat(struct lwp *l, const struct linux32_sys_fchmodat_args *uap, register_t *retval) 378 { 379 /* { 380 syscallarg(int) fd; 381 syscallarg(netbsd_charp) path; 382 syscallarg(linux_umode_t) mode; 383 } */ 384 385 return do_sys_chmodat(l, SCARG(uap, fd), SCARG_P32(uap, path), 386 SCARG(uap, mode), AT_SYMLINK_FOLLOW); 387 } 388 389 int 390 linux32_sys_fchownat(struct lwp *l, const struct linux32_sys_fchownat_args *uap, register_t *retval) 391 { 392 /* { 393 syscallarg(int) fd; 394 syscallarg(netbsd_charp) path; 395 syscallarg(uid_t) owner; 396 syscallarg(gid_t) group; 397 syscallarg(int) flag; 398 } */ 399 int flag; 400 401 flag = linux_to_bsd_atflags(SCARG(uap, flag)); 402 return do_sys_chownat(l, SCARG(uap, fd), SCARG_P32(uap, path), 403 SCARG(uap, owner), SCARG(uap, group), flag); 404 } 405 406 int 407 linux32_sys_faccessat(struct lwp *l, const struct linux32_sys_faccessat_args *uap, register_t *retval) 408 { 409 /* { 410 syscallarg(int) fd; 411 syscallarg(netbsd_charp) path; 412 syscallarg(int) amode; 413 } */ 414 415 return do_sys_accessat(l, SCARG(uap, fd), SCARG_P32(uap, path), 416 SCARG(uap, amode), AT_SYMLINK_FOLLOW); 417 } 418 419 int 420 linux32_sys_utimensat(struct lwp *l, const struct linux32_sys_utimensat_args *uap, register_t *retval) 421 { 422 /* { 423 syscallarg(int) fd; 424 syscallarg(const netbsd32_charp) path; 425 syscallarg(const linux32_timespecp_t) times; 426 syscallarg(int) flags; 427 } */ 428 int error; 429 struct linux32_timespec lts[2]; 430 struct timespec *tsp = NULL, ts[2]; 431 432 if (SCARG_P32(uap, times)) { 433 error = copyin(SCARG_P32(uap, times), <s, sizeof(lts)); 434 if (error != 0) 435 return error; 436 linux32_to_native_timespec(&ts[0], <s[0]); 437 linux32_to_native_timespec(&ts[1], <s[1]); 438 tsp = ts; 439 } 440 441 return linux_do_sys_utimensat(l, SCARG(uap, fd), SCARG_P32(uap, path), 442 tsp, SCARG(uap, flag), retval); 443 } 444 445 int 446 linux32_sys_creat(struct lwp *l, const struct linux32_sys_creat_args *uap, register_t *retval) 447 { 448 /* { 449 syscallarg(const netbsd32_charp) path; 450 syscallarg(int) mode; 451 } */ 452 struct sys_open_args ua; 453 454 NETBSD32TOP_UAP(path, const char); 455 SCARG(&ua, flags) = O_CREAT | O_TRUNC | O_WRONLY; 456 NETBSD32TO64_UAP(mode); 457 458 return sys_open(l, &ua, retval); 459 } 460 461 int 462 linux32_sys_mknod(struct lwp *l, const struct linux32_sys_mknod_args *uap, register_t *retval) 463 { 464 /* { 465 syscallarg(const netbsd32_charp) path; 466 syscallarg(int) mode; 467 syscallarg(int) dev; 468 } */ 469 struct linux_sys_mknod_args ua; 470 471 NETBSD32TOP_UAP(path, const char); 472 NETBSD32TO64_UAP(mode); 473 NETBSD32TO64_UAP(dev); 474 475 return linux_sys_mknod(l, &ua, retval); 476 } 477 478 int 479 linux32_sys_break(struct lwp *l, const struct linux32_sys_break_args *uap, register_t *retval) 480 { 481 #if 0 482 /* { 483 syscallarg(const netbsd32_charp) nsize; 484 } */ 485 #endif 486 487 return ENOSYS; 488 } 489 490 int 491 linux32_sys_swapon(struct lwp *l, const struct linux32_sys_swapon_args *uap, register_t *retval) 492 { 493 /* { 494 syscallarg(const netbsd32_charp) name; 495 } */ 496 struct sys_swapctl_args ua; 497 498 SCARG(&ua, cmd) = SWAP_ON; 499 SCARG(&ua, arg) = SCARG_P32(uap, name); 500 SCARG(&ua, misc) = 0; /* priority */ 501 return (sys_swapctl(l, &ua, retval)); 502 } 503 504 int 505 linux32_sys_swapoff(struct lwp *l, const struct linux32_sys_swapoff_args *uap, register_t *retval) 506 { 507 /* { 508 syscallarg(const netbsd32_charp) path; 509 } */ 510 struct sys_swapctl_args ua; 511 512 SCARG(&ua, cmd) = SWAP_OFF; 513 SCARG(&ua, arg) = SCARG_P32(uap, path); 514 SCARG(&ua, misc) = 0; /* priority */ 515 return (sys_swapctl(l, &ua, retval)); 516 } 517 518 519 int 520 linux32_sys_reboot(struct lwp *l, const struct linux32_sys_reboot_args *uap, register_t *retval) 521 { 522 /* { 523 syscallarg(int) magic1; 524 syscallarg(int) magic2; 525 syscallarg(int) cmd; 526 syscallarg(netbsd32_voidp) arg; 527 } */ 528 struct linux_sys_reboot_args ua; 529 530 NETBSD32TO64_UAP(magic1); 531 NETBSD32TO64_UAP(magic2); 532 NETBSD32TO64_UAP(cmd); 533 NETBSD32TOP_UAP(arg, void); 534 535 return linux_sys_reboot(l, &ua, retval); 536 } 537 538 int 539 linux32_sys_setresuid(struct lwp *l, const struct linux32_sys_setresuid_args *uap, register_t *retval) 540 { 541 /* { 542 syscallarg(uid_t) ruid; 543 syscallarg(uid_t) euid; 544 syscallarg(uid_t) suid; 545 } */ 546 struct linux_sys_setresuid_args ua; 547 548 NETBSD32TO64_UAP(ruid); 549 NETBSD32TO64_UAP(euid); 550 NETBSD32TO64_UAP(suid); 551 552 return linux_sys_setresuid(l, &ua, retval); 553 } 554 555 int 556 linux32_sys_getresuid(struct lwp *l, const struct linux32_sys_getresuid_args *uap, register_t *retval) 557 { 558 /* { 559 syscallarg(linux32_uidp_t) ruid; 560 syscallarg(linux32_uidp_t) euid; 561 syscallarg(linux32_uidp_t) suid; 562 } */ 563 kauth_cred_t pc = l->l_cred; 564 int error; 565 uid_t uid; 566 567 uid = kauth_cred_getuid(pc); 568 if ((error = copyout(&uid, SCARG_P32(uap, ruid), sizeof(uid_t))) != 0) 569 return error; 570 571 uid = kauth_cred_geteuid(pc); 572 if ((error = copyout(&uid, SCARG_P32(uap, euid), sizeof(uid_t))) != 0) 573 return error; 574 575 uid = kauth_cred_getsvuid(pc); 576 return copyout(&uid, SCARG_P32(uap, suid), sizeof(uid_t)); 577 } 578 579 int 580 linux32_sys_setresgid(struct lwp *l, const struct linux32_sys_setresgid_args *uap, register_t *retval) 581 { 582 /* { 583 syscallarg(gid_t) rgid; 584 syscallarg(gid_t) egid; 585 syscallarg(gid_t) sgid; 586 } */ 587 struct linux_sys_setresgid_args ua; 588 589 NETBSD32TO64_UAP(rgid); 590 NETBSD32TO64_UAP(egid); 591 NETBSD32TO64_UAP(sgid); 592 593 return linux_sys_setresgid(l, &ua, retval); 594 } 595 596 int 597 linux32_sys_getresgid(struct lwp *l, const struct linux32_sys_getresgid_args *uap, register_t *retval) 598 { 599 /* { 600 syscallarg(linux32_gidp_t) rgid; 601 syscallarg(linux32_gidp_t) egid; 602 syscallarg(linux32_gidp_t) sgid; 603 } */ 604 kauth_cred_t pc = l->l_cred; 605 int error; 606 gid_t gid; 607 608 gid = kauth_cred_getgid(pc); 609 if ((error = copyout(&gid, SCARG_P32(uap, rgid), sizeof(gid_t))) != 0) 610 return error; 611 612 gid = kauth_cred_getegid(pc); 613 if ((error = copyout(&gid, SCARG_P32(uap, egid), sizeof(gid_t))) != 0) 614 return error; 615 616 gid = kauth_cred_getsvgid(pc); 617 return copyout(&gid, SCARG_P32(uap, sgid), sizeof(gid_t)); 618 } 619 620 int 621 linux32_sys_nice(struct lwp *l, const struct linux32_sys_nice_args *uap, register_t *retval) 622 { 623 /* { 624 syscallarg(int) incr; 625 } */ 626 struct proc *p = l->l_proc; 627 struct sys_setpriority_args bsa; 628 int error; 629 630 SCARG(&bsa, which) = PRIO_PROCESS; 631 SCARG(&bsa, who) = 0; 632 SCARG(&bsa, prio) = p->p_nice - NZERO + SCARG(uap, incr); 633 634 error = sys_setpriority(l, &bsa, retval); 635 return (error) ? EPERM : 0; 636 } 637 638 int 639 linux32_sys_alarm(struct lwp *l, const struct linux32_sys_alarm_args *uap, register_t *retval) 640 { 641 /* { 642 syscallarg(unsigned int) secs; 643 } */ 644 struct linux_sys_alarm_args ua; 645 646 NETBSD32TO64_UAP(secs); 647 648 return linux_sys_alarm(l, &ua, retval); 649 } 650 651 int 652 linux32_sys_fdatasync(struct lwp *l, const struct linux32_sys_fdatasync_args *uap, register_t *retval) 653 { 654 /* { 655 syscallarg(int) fd; 656 } */ 657 struct linux_sys_fdatasync_args ua; 658 659 NETBSD32TO64_UAP(fd); 660 661 return linux_sys_fdatasync(l, &ua, retval); 662 } 663 664 int 665 linux32_sys_setfsuid(struct lwp *l, const struct linux32_sys_setfsuid_args *uap, register_t *retval) 666 { 667 /* { 668 syscallarg(uid_t) uid; 669 } */ 670 struct linux_sys_setfsuid_args ua; 671 672 NETBSD32TO64_UAP(uid); 673 674 return linux_sys_setfsuid(l, &ua, retval); 675 } 676 677 int 678 linux32_sys_setfsgid(struct lwp *l, const struct linux32_sys_setfsgid_args *uap, register_t *retval) 679 { 680 /* { 681 syscallarg(gid_t) gid; 682 } */ 683 struct linux_sys_setfsgid_args ua; 684 685 NETBSD32TO64_UAP(gid); 686 687 return linux_sys_setfsgid(l, &ua, retval); 688 } 689 690 /* 691 * pread(2). 692 */ 693 int 694 linux32_sys_pread(struct lwp *l, 695 const struct linux32_sys_pread_args *uap, register_t *retval) 696 { 697 /* { 698 syscallarg(int) fd; 699 syscallarg(netbsd32_voidp) buf; 700 syscallarg(netbsd32_size_t) nbyte; 701 syscallarg(netbsd32_off_t) offset; 702 } */ 703 struct sys_pread_args pra; 704 705 SCARG(&pra, fd) = SCARG(uap, fd); 706 SCARG(&pra, buf) = SCARG_P32(uap, buf); 707 SCARG(&pra, nbyte) = SCARG(uap, nbyte); 708 SCARG(&pra, PAD) = 0; 709 SCARG(&pra, offset) = SCARG(uap, offset); 710 711 return sys_pread(l, &pra, retval); 712 } 713 714 /* 715 * pwrite(2). 716 */ 717 int 718 linux32_sys_pwrite(struct lwp *l, 719 const struct linux32_sys_pwrite_args *uap, register_t *retval) 720 { 721 /* { 722 syscallarg(int) fd; 723 syscallarg(const netbsd32_voidp) buf; 724 syscallarg(netbsd32_size_t) nbyte; 725 syscallarg(netbsd32_off_t) offset; 726 } */ 727 struct sys_pwrite_args pra; 728 729 SCARG(&pra, fd) = SCARG(uap, fd); 730 SCARG(&pra, buf) = SCARG_P32(uap, buf); 731 SCARG(&pra, nbyte) = SCARG(uap, nbyte); 732 SCARG(&pra, PAD) = 0; 733 SCARG(&pra, offset) = SCARG(uap, offset); 734 735 return sys_pwrite(l, &pra, retval); 736 } 737 738 /* 739 * fallocate(2) 740 */ 741 int 742 linux32_sys_fallocate(struct lwp *l, 743 const struct linux32_sys_fallocate_args *uap, register_t *retval) 744 { 745 /* 746 * For now just return EOPNOTSUPP, this makes glibc posix_fallocate() 747 * to fallback to emulation. 748 * XXX Right now no filesystem actually implements fallocate support, 749 * so no need for mapping. 750 */ 751 return EOPNOTSUPP; 752 } 753