1 /*- 2 * Copyright (c) 1990, 1993, 1995 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 4. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95 30 * $FreeBSD$ 31 */ 32 33 #include <sys/param.h> 34 #include <sys/event.h> 35 #include <sys/file.h> 36 #include <sys/filedesc.h> 37 #include <sys/filio.h> 38 #include <sys/fcntl.h> 39 #include <sys/kernel.h> 40 #include <sys/lock.h> 41 #include <sys/mutex.h> 42 #include <sys/malloc.h> 43 #include <sys/poll.h> 44 #include <sys/proc.h> /* XXXKSE */ 45 #include <sys/signalvar.h> 46 #include <sys/socket.h> 47 #include <sys/socketvar.h> 48 #include <sys/sx.h> 49 #include <sys/systm.h> 50 #include <sys/un.h> 51 #include <sys/unistd.h> 52 #include <sys/vnode.h> 53 #include <fs/fifofs/fifo.h> 54 55 static fo_rdwr_t fifo_read_f; 56 static fo_rdwr_t fifo_write_f; 57 static fo_ioctl_t fifo_ioctl_f; 58 static fo_poll_t fifo_poll_f; 59 static fo_kqfilter_t fifo_kqfilter_f; 60 static fo_stat_t fifo_stat_f; 61 static fo_close_t fifo_close_f; 62 63 struct fileops fifo_ops_f = { 64 .fo_read = fifo_read_f, 65 .fo_write = fifo_write_f, 66 .fo_ioctl = fifo_ioctl_f, 67 .fo_poll = fifo_poll_f, 68 .fo_kqfilter = fifo_kqfilter_f, 69 .fo_stat = fifo_stat_f, 70 .fo_close = fifo_close_f, 71 .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE 72 }; 73 74 /* 75 * This structure is associated with the FIFO vnode and stores 76 * the state associated with the FIFO. 77 */ 78 struct fifoinfo { 79 struct socket *fi_readsock; 80 struct socket *fi_writesock; 81 long fi_readers; 82 long fi_writers; 83 }; 84 85 static vop_print_t fifo_print; 86 static vop_open_t fifo_open; 87 static vop_close_t fifo_close; 88 static vop_ioctl_t fifo_ioctl; 89 static vop_kqfilter_t fifo_kqfilter; 90 static vop_pathconf_t fifo_pathconf; 91 static vop_advlock_t fifo_advlock; 92 93 static void filt_fifordetach(struct knote *kn); 94 static int filt_fiforead(struct knote *kn, long hint); 95 static void filt_fifowdetach(struct knote *kn); 96 static int filt_fifowrite(struct knote *kn, long hint); 97 98 static struct filterops fiforead_filtops = 99 { 1, NULL, filt_fifordetach, filt_fiforead }; 100 static struct filterops fifowrite_filtops = 101 { 1, NULL, filt_fifowdetach, filt_fifowrite }; 102 103 struct vop_vector fifo_specops = { 104 .vop_default = &default_vnodeops, 105 106 .vop_access = VOP_EBADF, 107 .vop_advlock = fifo_advlock, 108 .vop_close = fifo_close, 109 .vop_create = VOP_PANIC, 110 .vop_getattr = VOP_EBADF, 111 .vop_ioctl = fifo_ioctl, 112 .vop_kqfilter = fifo_kqfilter, 113 .vop_lease = VOP_NULL, 114 .vop_link = VOP_PANIC, 115 .vop_mkdir = VOP_PANIC, 116 .vop_mknod = VOP_PANIC, 117 .vop_open = fifo_open, 118 .vop_pathconf = fifo_pathconf, 119 .vop_print = fifo_print, 120 .vop_read = VOP_PANIC, 121 .vop_readdir = VOP_PANIC, 122 .vop_readlink = VOP_PANIC, 123 .vop_reallocblks = VOP_PANIC, 124 .vop_reclaim = VOP_NULL, 125 .vop_remove = VOP_PANIC, 126 .vop_rename = VOP_PANIC, 127 .vop_rmdir = VOP_PANIC, 128 .vop_setattr = VOP_EBADF, 129 .vop_symlink = VOP_PANIC, 130 .vop_write = VOP_PANIC, 131 }; 132 133 struct mtx fifo_mtx; 134 MTX_SYSINIT(fifo, &fifo_mtx, "fifo mutex", MTX_DEF); 135 136 /* 137 * Dispose of fifo resources. 138 */ 139 static void 140 fifo_cleanup(struct vnode *vp) 141 { 142 struct fifoinfo *fip = vp->v_fifoinfo; 143 144 ASSERT_VOP_LOCKED(vp, "fifo_cleanup"); 145 if (fip->fi_readers == 0 && fip->fi_writers == 0) { 146 vp->v_fifoinfo = NULL; 147 (void)soclose(fip->fi_readsock); 148 (void)soclose(fip->fi_writesock); 149 FREE(fip, M_VNODE); 150 } 151 } 152 153 /* 154 * Open called to set up a new instance of a fifo or 155 * to find an active instance of a fifo. 156 */ 157 /* ARGSUSED */ 158 static int 159 fifo_open(ap) 160 struct vop_open_args /* { 161 struct vnode *a_vp; 162 int a_mode; 163 struct ucred *a_cred; 164 struct thread *a_td; 165 } */ *ap; 166 { 167 struct vnode *vp = ap->a_vp; 168 struct fifoinfo *fip; 169 struct thread *td = ap->a_td; 170 struct ucred *cred = ap->a_cred; 171 struct socket *rso, *wso; 172 struct file *fp; 173 int error; 174 175 if ((fip = vp->v_fifoinfo) == NULL) { 176 MALLOC(fip, struct fifoinfo *, sizeof(*fip), M_VNODE, M_WAITOK); 177 error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, cred, td); 178 if (error) 179 goto fail1; 180 fip->fi_readsock = rso; 181 error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0, cred, td); 182 if (error) 183 goto fail2; 184 fip->fi_writesock = wso; 185 error = uipc_connect2(wso, rso); 186 if (error) { 187 (void)soclose(wso); 188 fail2: 189 (void)soclose(rso); 190 fail1: 191 free(fip, M_VNODE); 192 return (error); 193 } 194 fip->fi_readers = fip->fi_writers = 0; 195 wso->so_snd.sb_lowat = PIPE_BUF; 196 SOCKBUF_LOCK(&rso->so_rcv); 197 rso->so_rcv.sb_state |= SBS_CANTRCVMORE; 198 SOCKBUF_UNLOCK(&rso->so_rcv); 199 vp->v_fifoinfo = fip; 200 } 201 202 /* 203 * General access to fi_readers and fi_writers is protected using 204 * the vnode lock. 205 * 206 * Protect the increment of fi_readers and fi_writers and the 207 * associated calls to wakeup() with the fifo mutex in addition 208 * to the vnode lock. This allows the vnode lock to be dropped 209 * for the msleep() calls below, and using the fifo mutex with 210 * msleep() prevents the wakeup from being missed. 211 */ 212 mtx_lock(&fifo_mtx); 213 if (ap->a_mode & FREAD) { 214 fip->fi_readers++; 215 if (fip->fi_readers == 1) { 216 SOCKBUF_LOCK(&fip->fi_writesock->so_snd); 217 fip->fi_writesock->so_snd.sb_state &= ~SBS_CANTSENDMORE; 218 SOCKBUF_UNLOCK(&fip->fi_writesock->so_snd); 219 if (fip->fi_writers > 0) { 220 wakeup(&fip->fi_writers); 221 sowwakeup(fip->fi_writesock); 222 } 223 } 224 } 225 if (ap->a_mode & FWRITE) { 226 if ((ap->a_mode & O_NONBLOCK) && fip->fi_readers == 0) { 227 mtx_unlock(&fifo_mtx); 228 return (ENXIO); 229 } 230 fip->fi_writers++; 231 if (fip->fi_writers == 1) { 232 SOCKBUF_LOCK(&fip->fi_writesock->so_rcv); 233 fip->fi_readsock->so_rcv.sb_state &= ~SBS_CANTRCVMORE; 234 SOCKBUF_UNLOCK(&fip->fi_writesock->so_rcv); 235 if (fip->fi_readers > 0) { 236 wakeup(&fip->fi_readers); 237 sorwakeup(fip->fi_writesock); 238 } 239 } 240 } 241 if ((ap->a_mode & O_NONBLOCK) == 0) { 242 if ((ap->a_mode & FREAD) && fip->fi_writers == 0) { 243 VOP_UNLOCK(vp, 0, td); 244 error = msleep(&fip->fi_readers, &fifo_mtx, 245 PDROP | PCATCH | PSOCK, "fifoor", 0); 246 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 247 if (error) { 248 fip->fi_readers--; 249 if (fip->fi_readers == 0) { 250 socantsendmore(fip->fi_writesock); 251 fifo_cleanup(vp); 252 } 253 return (error); 254 } 255 mtx_lock(&fifo_mtx); 256 /* 257 * We must have got woken up because we had a writer. 258 * That (and not still having one) is the condition 259 * that we must wait for. 260 */ 261 } 262 if ((ap->a_mode & FWRITE) && fip->fi_readers == 0) { 263 VOP_UNLOCK(vp, 0, td); 264 error = msleep(&fip->fi_writers, &fifo_mtx, 265 PDROP | PCATCH | PSOCK, "fifoow", 0); 266 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 267 if (error) { 268 fip->fi_writers--; 269 if (fip->fi_writers == 0) { 270 socantrcvmore(fip->fi_readsock); 271 fifo_cleanup(vp); 272 } 273 return (error); 274 } 275 /* 276 * We must have got woken up because we had 277 * a reader. That (and not still having one) 278 * is the condition that we must wait for. 279 */ 280 mtx_lock(&fifo_mtx); 281 } 282 } 283 mtx_unlock(&fifo_mtx); 284 KASSERT(ap->a_fdidx >= 0, ("can't fifo/vnode bypass %d", ap->a_fdidx)); 285 fp = ap->a_td->td_proc->p_fd->fd_ofiles[ap->a_fdidx]; 286 KASSERT(fp->f_ops == &badfileops, ("not badfileops in fifo_open")); 287 fp->f_ops = &fifo_ops_f; 288 fp->f_data = fip; 289 return (0); 290 } 291 292 /* 293 * Device ioctl operation. 294 */ 295 /* ARGSUSED */ 296 static int 297 fifo_ioctl(ap) 298 struct vop_ioctl_args /* { 299 struct vnode *a_vp; 300 u_long a_command; 301 caddr_t a_data; 302 int a_fflag; 303 struct ucred *a_cred; 304 struct thread *a_td; 305 } */ *ap; 306 { 307 struct file filetmp; /* Local, so need not be locked. */ 308 int error; 309 310 if (ap->a_command == FIONBIO) 311 return (0); 312 if (ap->a_fflag & FREAD) { 313 filetmp.f_data = ap->a_vp->v_fifoinfo->fi_readsock; 314 filetmp.f_cred = ap->a_cred; 315 error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, 316 ap->a_td->td_ucred, ap->a_td); 317 if (error) 318 return (error); 319 } 320 if (ap->a_fflag & FWRITE) { 321 filetmp.f_data = ap->a_vp->v_fifoinfo->fi_writesock; 322 filetmp.f_cred = ap->a_cred; 323 error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, 324 ap->a_td->td_ucred, ap->a_td); 325 if (error) 326 return (error); 327 } 328 return (0); 329 } 330 331 /* ARGSUSED */ 332 static int 333 fifo_kqfilter(ap) 334 struct vop_kqfilter_args /* { 335 struct vnode *a_vp; 336 struct knote *a_kn; 337 } */ *ap; 338 { 339 struct fifoinfo *fi = ap->a_vp->v_fifoinfo; 340 struct socket *so; 341 struct sockbuf *sb; 342 343 switch (ap->a_kn->kn_filter) { 344 case EVFILT_READ: 345 ap->a_kn->kn_fop = &fiforead_filtops; 346 so = fi->fi_readsock; 347 sb = &so->so_rcv; 348 break; 349 case EVFILT_WRITE: 350 ap->a_kn->kn_fop = &fifowrite_filtops; 351 so = fi->fi_writesock; 352 sb = &so->so_snd; 353 break; 354 default: 355 return (1); 356 } 357 358 ap->a_kn->kn_hook = (caddr_t)so; 359 360 SOCKBUF_LOCK(sb); 361 knlist_add(&sb->sb_sel.si_note, ap->a_kn, 1); 362 sb->sb_flags |= SB_KNOTE; 363 SOCKBUF_UNLOCK(sb); 364 365 return (0); 366 } 367 368 static void 369 filt_fifordetach(struct knote *kn) 370 { 371 struct socket *so = (struct socket *)kn->kn_hook; 372 373 SOCKBUF_LOCK(&so->so_rcv); 374 knlist_remove(&so->so_rcv.sb_sel.si_note, kn, 1); 375 if (knlist_empty(&so->so_rcv.sb_sel.si_note)) 376 so->so_rcv.sb_flags &= ~SB_KNOTE; 377 SOCKBUF_UNLOCK(&so->so_rcv); 378 } 379 380 static int 381 filt_fiforead(struct knote *kn, long hint) 382 { 383 struct socket *so = (struct socket *)kn->kn_hook; 384 int need_lock, result; 385 386 need_lock = !SOCKBUF_OWNED(&so->so_rcv); 387 if (need_lock) 388 SOCKBUF_LOCK(&so->so_rcv); 389 kn->kn_data = so->so_rcv.sb_cc; 390 if (so->so_rcv.sb_state & SBS_CANTRCVMORE) { 391 kn->kn_flags |= EV_EOF; 392 result = 1; 393 } else { 394 kn->kn_flags &= ~EV_EOF; 395 result = (kn->kn_data > 0); 396 } 397 if (need_lock) 398 SOCKBUF_UNLOCK(&so->so_rcv); 399 return (result); 400 } 401 402 static void 403 filt_fifowdetach(struct knote *kn) 404 { 405 struct socket *so = (struct socket *)kn->kn_hook; 406 407 SOCKBUF_LOCK(&so->so_snd); 408 knlist_remove(&so->so_snd.sb_sel.si_note, kn, 1); 409 if (knlist_empty(&so->so_snd.sb_sel.si_note)) 410 so->so_snd.sb_flags &= ~SB_KNOTE; 411 SOCKBUF_UNLOCK(&so->so_snd); 412 } 413 414 static int 415 filt_fifowrite(struct knote *kn, long hint) 416 { 417 struct socket *so = (struct socket *)kn->kn_hook; 418 int need_lock, result; 419 420 need_lock = !SOCKBUF_OWNED(&so->so_snd); 421 if (need_lock) 422 SOCKBUF_LOCK(&so->so_snd); 423 kn->kn_data = sbspace(&so->so_snd); 424 if (so->so_snd.sb_state & SBS_CANTSENDMORE) { 425 kn->kn_flags |= EV_EOF; 426 result = 1; 427 } else { 428 kn->kn_flags &= ~EV_EOF; 429 result = (kn->kn_data >= so->so_snd.sb_lowat); 430 } 431 if (need_lock) 432 SOCKBUF_UNLOCK(&so->so_snd); 433 return (result); 434 } 435 436 /* 437 * Device close routine 438 */ 439 /* ARGSUSED */ 440 static int 441 fifo_close(ap) 442 struct vop_close_args /* { 443 struct vnode *a_vp; 444 int a_fflag; 445 struct ucred *a_cred; 446 struct thread *a_td; 447 } */ *ap; 448 { 449 struct vnode *vp = ap->a_vp; 450 struct thread *td = ap->a_td; 451 struct fifoinfo *fip = vp->v_fifoinfo; 452 453 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); 454 455 if (ap->a_fflag & FREAD) { 456 fip->fi_readers--; 457 if (fip->fi_readers == 0) 458 socantsendmore(fip->fi_writesock); 459 } 460 if (ap->a_fflag & FWRITE) { 461 fip->fi_writers--; 462 if (fip->fi_writers == 0) 463 socantrcvmore(fip->fi_readsock); 464 } 465 fifo_cleanup(vp); 466 VOP_UNLOCK(vp, 0, td); 467 return (0); 468 } 469 470 /* 471 * Print out internal contents of a fifo vnode. 472 */ 473 int 474 fifo_printinfo(vp) 475 struct vnode *vp; 476 { 477 register struct fifoinfo *fip = vp->v_fifoinfo; 478 479 printf(", fifo with %ld readers and %ld writers", 480 fip->fi_readers, fip->fi_writers); 481 return (0); 482 } 483 484 /* 485 * Print out the contents of a fifo vnode. 486 */ 487 static int 488 fifo_print(ap) 489 struct vop_print_args /* { 490 struct vnode *a_vp; 491 } */ *ap; 492 { 493 fifo_printinfo(ap->a_vp); 494 printf("\n"); 495 return (0); 496 } 497 498 /* 499 * Return POSIX pathconf information applicable to fifo's. 500 */ 501 static int 502 fifo_pathconf(ap) 503 struct vop_pathconf_args /* { 504 struct vnode *a_vp; 505 int a_name; 506 int *a_retval; 507 } */ *ap; 508 { 509 510 switch (ap->a_name) { 511 case _PC_LINK_MAX: 512 *ap->a_retval = LINK_MAX; 513 return (0); 514 case _PC_PIPE_BUF: 515 *ap->a_retval = PIPE_BUF; 516 return (0); 517 case _PC_CHOWN_RESTRICTED: 518 *ap->a_retval = 1; 519 return (0); 520 default: 521 return (EINVAL); 522 } 523 /* NOTREACHED */ 524 } 525 526 /* 527 * Fifo advisory byte-level locks. 528 */ 529 /* ARGSUSED */ 530 static int 531 fifo_advlock(ap) 532 struct vop_advlock_args /* { 533 struct vnode *a_vp; 534 caddr_t a_id; 535 int a_op; 536 struct flock *a_fl; 537 int a_flags; 538 } */ *ap; 539 { 540 541 return (ap->a_flags & F_FLOCK ? EOPNOTSUPP : EINVAL); 542 } 543 544 static int 545 fifo_close_f(struct file *fp, struct thread *td) 546 { 547 548 return (vnops.fo_close(fp, td)); 549 } 550 551 static int 552 fifo_ioctl_f(struct file *fp, u_long com, void *data, struct ucred *cred, struct thread *td) 553 { 554 struct fifoinfo *fi; 555 struct file filetmp; /* Local, so need not be locked. */ 556 int error; 557 558 error = ENOTTY; 559 fi = fp->f_data; 560 if (com == FIONBIO) 561 return (0); 562 if (fp->f_flag & FREAD) { 563 filetmp.f_data = fi->fi_readsock; 564 filetmp.f_cred = cred; 565 error = soo_ioctl(&filetmp, com, data, cred, td); 566 if (error) 567 return (error); 568 } 569 if (fp->f_flag & FWRITE) { 570 filetmp.f_data = fi->fi_writesock; 571 filetmp.f_cred = cred; 572 error = soo_ioctl(&filetmp, com, data, cred, td); 573 } 574 return (error); 575 } 576 577 static int 578 fifo_kqfilter_f(struct file *fp, struct knote *kn) 579 { 580 struct fifoinfo *fi; 581 struct socket *so; 582 struct sockbuf *sb; 583 584 fi = fp->f_data; 585 switch (kn->kn_filter) { 586 case EVFILT_READ: 587 kn->kn_fop = &fiforead_filtops; 588 so = fi->fi_readsock; 589 sb = &so->so_rcv; 590 break; 591 case EVFILT_WRITE: 592 kn->kn_fop = &fifowrite_filtops; 593 so = fi->fi_writesock; 594 sb = &so->so_snd; 595 break; 596 default: 597 return (1); 598 } 599 600 kn->kn_hook = (caddr_t)so; 601 602 SOCKBUF_LOCK(sb); 603 knlist_add(&sb->sb_sel.si_note, kn, 1); 604 sb->sb_flags |= SB_KNOTE; 605 SOCKBUF_UNLOCK(sb); 606 607 return (0); 608 } 609 610 static int 611 fifo_poll_f(struct file *fp, int events, struct ucred *cred, struct thread *td) 612 { 613 struct fifoinfo *fip; 614 struct file filetmp; 615 int levents, revents = 0; 616 617 fip = fp->f_data; 618 levents = events & 619 (POLLIN | POLLINIGNEOF | POLLPRI | POLLRDNORM | POLLRDBAND); 620 if (levents) { 621 /* 622 * If POLLIN or POLLRDNORM is requested and POLLINIGNEOF is 623 * not, then convert the first two to the last one. This 624 * tells the socket poll function to ignore EOF so that we 625 * block if there is no writer (and no data). Callers can 626 * set POLLINIGNEOF to get non-blocking behavior. 627 */ 628 if (levents & (POLLIN | POLLRDNORM) && 629 !(levents & POLLINIGNEOF)) { 630 levents &= ~(POLLIN | POLLRDNORM); 631 levents |= POLLINIGNEOF; 632 } 633 634 filetmp.f_data = fip->fi_readsock; 635 filetmp.f_cred = cred; 636 if (filetmp.f_data) 637 revents |= soo_poll(&filetmp, levents, cred, td); 638 639 /* Reverse the above conversion. */ 640 if ((revents & POLLINIGNEOF) && !(events & POLLINIGNEOF)) { 641 revents |= (events & (POLLIN | POLLRDNORM)); 642 revents &= ~POLLINIGNEOF; 643 } 644 } 645 levents = events & (POLLOUT | POLLWRNORM | POLLWRBAND); 646 if (events) { 647 filetmp.f_data = fip->fi_writesock; 648 filetmp.f_cred = cred; 649 if (filetmp.f_data) { 650 revents |= soo_poll(&filetmp, events, cred, td); 651 } 652 } 653 return (revents); 654 } 655 656 static int 657 fifo_read_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td) 658 { 659 struct fifoinfo *fip; 660 int error, sflags; 661 662 fip = fp->f_data; 663 KASSERT(uio->uio_rw == UIO_READ,("fifo_read mode")); 664 if (uio->uio_resid == 0) 665 return (0); 666 sflags = (fp->f_flag & FNONBLOCK) ? MSG_NBIO : 0; 667 error = soreceive(fip->fi_readsock, NULL, uio, NULL, NULL, &sflags); 668 return (error); 669 } 670 671 static int 672 fifo_stat_f(struct file *fp, struct stat *sb, struct ucred *cred, struct thread *td) 673 { 674 675 return (vnops.fo_stat(fp, sb, cred, td)); 676 } 677 678 static int 679 fifo_write_f(struct file *fp, struct uio *uio, struct ucred *cred, int flags, struct thread *td) 680 { 681 struct fifoinfo *fip; 682 int error, sflags; 683 684 fip = fp->f_data; 685 KASSERT(uio->uio_rw == UIO_WRITE,("fifo_write mode")); 686 sflags = (fp->f_flag & FNONBLOCK) ? MSG_NBIO : 0; 687 error = sosend(fip->fi_writesock, NULL, uio, 0, NULL, sflags, td); 688 return (error); 689 } 690 691