fifo_vnops.c (168355) | fifo_vnops.c (170152) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993, 1995 3 * The Regents of the University of California. 4 * Copyright (c) 2005 Robert N. M. Watson 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 --- 15 unchanged lines hidden (view full) --- 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95 | 1/*- 2 * Copyright (c) 1990, 1993, 1995 3 * The Regents of the University of California. 4 * Copyright (c) 2005 Robert N. M. Watson 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 --- 15 unchanged lines hidden (view full) --- 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 * 31 * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95 |
32 * $FreeBSD: head/sys/fs/fifofs/fifo_vnops.c 168355 2007-04-04 09:11:34Z rwatson $ | 32 * $FreeBSD: head/sys/fs/fifofs/fifo_vnops.c 170152 2007-05-31 11:51:53Z kib $ |
33 */ 34 35#include <sys/param.h> 36#include <sys/event.h> 37#include <sys/file.h> 38#include <sys/filedesc.h> 39#include <sys/filio.h> 40#include <sys/fcntl.h> --- 129 unchanged lines hidden (view full) --- 170 struct thread *a_td; 171 int a_fdidx; 172 } */ *ap; 173{ 174 struct vnode *vp = ap->a_vp; 175 struct fifoinfo *fip; 176 struct thread *td = ap->a_td; 177 struct ucred *cred = ap->a_cred; | 33 */ 34 35#include <sys/param.h> 36#include <sys/event.h> 37#include <sys/file.h> 38#include <sys/filedesc.h> 39#include <sys/filio.h> 40#include <sys/fcntl.h> --- 129 unchanged lines hidden (view full) --- 170 struct thread *a_td; 171 int a_fdidx; 172 } */ *ap; 173{ 174 struct vnode *vp = ap->a_vp; 175 struct fifoinfo *fip; 176 struct thread *td = ap->a_td; 177 struct ucred *cred = ap->a_cred; |
178 struct file *fp = ap->a_fp; |
|
178 struct socket *rso, *wso; | 179 struct socket *rso, *wso; |
179 struct file *fp; | |
180 int error; 181 182 ASSERT_VOP_LOCKED(vp, "fifo_open"); | 180 int error; 181 182 ASSERT_VOP_LOCKED(vp, "fifo_open"); |
183 if (ap->a_fdidx < 0) | 183 if (fp == NULL) |
184 return (EINVAL); 185 if ((fip = vp->v_fifoinfo) == NULL) { 186 MALLOC(fip, struct fifoinfo *, sizeof(*fip), M_VNODE, M_WAITOK); 187 error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, cred, td); 188 if (error) 189 goto fail1; 190 fip->fi_readsock = rso; 191 error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0, cred, td); --- 96 unchanged lines hidden (view full) --- 288 * We must have got woken up because we had 289 * a reader. That (and not still having one) 290 * is the condition that we must wait for. 291 */ 292 mtx_lock(&fifo_mtx); 293 } 294 } 295 mtx_unlock(&fifo_mtx); | 184 return (EINVAL); 185 if ((fip = vp->v_fifoinfo) == NULL) { 186 MALLOC(fip, struct fifoinfo *, sizeof(*fip), M_VNODE, M_WAITOK); 187 error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, cred, td); 188 if (error) 189 goto fail1; 190 fip->fi_readsock = rso; 191 error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0, cred, td); --- 96 unchanged lines hidden (view full) --- 288 * We must have got woken up because we had 289 * a reader. That (and not still having one) 290 * is the condition that we must wait for. 291 */ 292 mtx_lock(&fifo_mtx); 293 } 294 } 295 mtx_unlock(&fifo_mtx); |
296 KASSERT(ap->a_fdidx >= 0, ("can't fifo/vnode bypass %d", ap->a_fdidx)); 297 fp = ap->a_td->td_proc->p_fd->fd_ofiles[ap->a_fdidx]; | 296 KASSERT(fp != NULL, ("can't fifo/vnode bypass")); |
298 FILE_LOCK(fp); 299 KASSERT(fp->f_ops == &badfileops, ("not badfileops in fifo_open")); 300 fp->f_data = fip; 301 fp->f_ops = &fifo_ops_f; 302 FILE_UNLOCK(fp); 303 return (0); 304} 305 --- 438 unchanged lines hidden --- | 297 FILE_LOCK(fp); 298 KASSERT(fp->f_ops == &badfileops, ("not badfileops in fifo_open")); 299 fp->f_data = fip; 300 fp->f_ops = &fifo_ops_f; 301 FILE_UNLOCK(fp); 302 return (0); 303} 304 --- 438 unchanged lines hidden --- |