From 1e9246857202241772eba9f3150f907fb21e9458 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 4 Jul 2003 12:20:27 +0000 Subject: Use the f_vnode field to tell which file descriptors have a vnode. --- sys/kern/kern_descrip.c | 28 +++++++++++----------------- sys/kern/vfs_extattr.c | 3 ++- sys/kern/vfs_syscalls.c | 3 ++- 3 files changed, 15 insertions(+), 19 deletions(-) (limited to 'sys') diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index c61d08a..43cbe5c 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1016,28 +1016,22 @@ fpathconf(td, uap) td->td_retval[0] = async_io_version; goto out; } - switch (fp->f_type) { - case DTYPE_PIPE: - case DTYPE_SOCKET: - if (uap->name != _PC_PIPE_BUF) { - error = EINVAL; - } else { - td->td_retval[0] = PIPE_BUF; - error = 0; - } - break; - case DTYPE_FIFO: - case DTYPE_VNODE: - vp = fp->f_vnode; + vp = fp->f_vnode; + if (vp != NULL) { mtx_lock(&Giant); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); error = VOP_PATHCONF(vp, uap->name, td->td_retval); VOP_UNLOCK(vp, 0, td); mtx_unlock(&Giant); - break; - default: + } else if (fp->f_type == DTYPE_PIPE || fp->f_type == DTYPE_SOCKET) { + if (uap->name != _PC_PIPE_BUF) { + error = EINVAL; + } else { + td->td_retval[0] = PIPE_BUF; + error = 0; + } + } else { error = EOPNOTSUPP; - break; } out: fdrop(fp, td); @@ -1917,7 +1911,7 @@ _fgetvp(struct thread *td, int fd, struct vnode **vpp, int flags) *vpp = NULL; if ((error = _fget(td, fd, &fp, 0, 0)) != 0) return (error); - if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_FIFO) { + if (fp->f_vnode == NULL) { error = EINVAL; } else { *vpp = fp->f_vnode; diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 000fa0a..5d8b2d3 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -3442,7 +3442,7 @@ getvnode(fdp, fd, fpp) if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) error = EBADF; - else if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_FIFO) { + else if (fp->f_vnode == NULL) { fp = NULL; error = EINVAL; } else { @@ -3454,6 +3454,7 @@ getvnode(fdp, fd, fpp) *fpp = fp; return (error); } + /* * Get (NFS) file handle */ diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 000fa0a..5d8b2d3 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -3442,7 +3442,7 @@ getvnode(fdp, fd, fpp) if ((u_int)fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) error = EBADF; - else if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_FIFO) { + else if (fp->f_vnode == NULL) { fp = NULL; error = EINVAL; } else { @@ -3454,6 +3454,7 @@ getvnode(fdp, fd, fpp) *fpp = fp; return (error); } + /* * Get (NFS) file handle */ -- cgit v1.1