fifo_vnops.c (88739) | fifo_vnops.c (89306) |
---|---|
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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95 | 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 --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95 |
34 * $FreeBSD: head/sys/fs/fifofs/fifo_vnops.c 88739 2001-12-31 17:45:16Z rwatson $ | 34 * $FreeBSD: head/sys/fs/fifofs/fifo_vnops.c 89306 2002-01-13 11:58:06Z alfred $ |
35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/unistd.h> 40#include <sys/kernel.h> 41#include <sys/lock.h> 42#include <sys/malloc.h> --- 296 unchanged lines hidden (view full) --- 339 int a_command; 340 caddr_t a_data; 341 int a_fflag; 342 struct ucred *a_cred; 343 struct thread *a_td; 344 } */ *ap; 345{ 346 struct file filetmp; | 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/unistd.h> 40#include <sys/kernel.h> 41#include <sys/lock.h> 42#include <sys/malloc.h> --- 296 unchanged lines hidden (view full) --- 339 int a_command; 340 caddr_t a_data; 341 int a_fflag; 342 struct ucred *a_cred; 343 struct thread *a_td; 344 } */ *ap; 345{ 346 struct file filetmp; |
347 int error; | 347 int error = 0; |
348 349 if (ap->a_command == FIONBIO) 350 return (0); | 348 349 if (ap->a_command == FIONBIO) 350 return (0); |
351 mtx_init(&filetmp.f_mtx, "struct file", MTX_DEF); 352 filetmp.f_count = 1; |
|
351 if (ap->a_fflag & FREAD) { | 353 if (ap->a_fflag & FREAD) { |
354 /* filetmp is local, hence not need be locked. */ |
|
352 filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock; 353 error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_td); 354 if (error) | 355 filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock; 356 error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_td); 357 if (error) |
355 return (error); | 358 goto err; |
356 } 357 if (ap->a_fflag & FWRITE) { | 359 } 360 if (ap->a_fflag & FWRITE) { |
361 /* filetmp is local, hence not need be locked. */ |
|
358 filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock; 359 error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_td); 360 if (error) | 362 filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock; 363 error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_td); 364 if (error) |
361 return (error); | 365 goto err; |
362 } | 366 } |
363 return (0); | 367err: 368 mtx_destroy(&filetmp.f_mtx); 369 return (error); |
364} 365 366/* ARGSUSED */ 367static int 368fifo_kqfilter(ap) 369 struct vop_kqfilter_args /* { 370 struct vnode *a_vp; 371 struct knote *a_kn; --- 82 unchanged lines hidden (view full) --- 454 int a_events; 455 struct ucred *a_cred; 456 struct thread *a_td; 457 } */ *ap; 458{ 459 struct file filetmp; 460 int revents = 0; 461 | 370} 371 372/* ARGSUSED */ 373static int 374fifo_kqfilter(ap) 375 struct vop_kqfilter_args /* { 376 struct vnode *a_vp; 377 struct knote *a_kn; --- 82 unchanged lines hidden (view full) --- 460 int a_events; 461 struct ucred *a_cred; 462 struct thread *a_td; 463 } */ *ap; 464{ 465 struct file filetmp; 466 int revents = 0; 467 |
468 mtx_init(&filetmp.f_mtx, "struct file", MTX_DEF); 469 filetmp.f_count = 1; |
|
462 if (ap->a_events & (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) { 463 filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock; 464 if (filetmp.f_data) 465 revents |= soo_poll(&filetmp, ap->a_events, ap->a_cred, 466 ap->a_td); 467 } 468 if (ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND)) { 469 filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock; 470 if (filetmp.f_data) 471 revents |= soo_poll(&filetmp, ap->a_events, ap->a_cred, 472 ap->a_td); 473 } | 470 if (ap->a_events & (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) { 471 filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock; 472 if (filetmp.f_data) 473 revents |= soo_poll(&filetmp, ap->a_events, ap->a_cred, 474 ap->a_td); 475 } 476 if (ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND)) { 477 filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock; 478 if (filetmp.f_data) 479 revents |= soo_poll(&filetmp, ap->a_events, ap->a_cred, 480 ap->a_td); 481 } |
482 mtx_destroy(&filetmp.f_mtx); |
|
474 return (revents); 475} 476 477/* 478 * Device close routine 479 */ 480/* ARGSUSED */ 481static int --- 120 unchanged lines hidden --- | 483 return (revents); 484} 485 486/* 487 * Device close routine 488 */ 489/* ARGSUSED */ 490static int --- 120 unchanged lines hidden --- |