1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-17 10:26:15 +00:00

Use the f_vnode field to tell which file descriptors have a vnode.

This commit is contained in:
Poul-Henning Kamp 2003-07-04 12:20:27 +00:00
parent b941a2beb7
commit 1226914c17
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=117222
3 changed files with 15 additions and 19 deletions

View File

@ -1016,28 +1016,22 @@ fpathconf(td, uap)
td->td_retval[0] = async_io_version; td->td_retval[0] = async_io_version;
goto out; goto out;
} }
switch (fp->f_type) { vp = fp->f_vnode;
case DTYPE_PIPE: if (vp != NULL) {
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;
mtx_lock(&Giant); mtx_lock(&Giant);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
error = VOP_PATHCONF(vp, uap->name, td->td_retval); error = VOP_PATHCONF(vp, uap->name, td->td_retval);
VOP_UNLOCK(vp, 0, td); VOP_UNLOCK(vp, 0, td);
mtx_unlock(&Giant); mtx_unlock(&Giant);
break; } else if (fp->f_type == DTYPE_PIPE || fp->f_type == DTYPE_SOCKET) {
default: if (uap->name != _PC_PIPE_BUF) {
error = EINVAL;
} else {
td->td_retval[0] = PIPE_BUF;
error = 0;
}
} else {
error = EOPNOTSUPP; error = EOPNOTSUPP;
break;
} }
out: out:
fdrop(fp, td); fdrop(fp, td);
@ -1917,7 +1911,7 @@ _fgetvp(struct thread *td, int fd, struct vnode **vpp, int flags)
*vpp = NULL; *vpp = NULL;
if ((error = _fget(td, fd, &fp, 0, 0)) != 0) if ((error = _fget(td, fd, &fp, 0, 0)) != 0)
return (error); return (error);
if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_FIFO) { if (fp->f_vnode == NULL) {
error = EINVAL; error = EINVAL;
} else { } else {
*vpp = fp->f_vnode; *vpp = fp->f_vnode;

View File

@ -3442,7 +3442,7 @@ getvnode(fdp, fd, fpp)
if ((u_int)fd >= fdp->fd_nfiles || if ((u_int)fd >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[fd]) == NULL) (fp = fdp->fd_ofiles[fd]) == NULL)
error = EBADF; error = EBADF;
else if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_FIFO) { else if (fp->f_vnode == NULL) {
fp = NULL; fp = NULL;
error = EINVAL; error = EINVAL;
} else { } else {
@ -3454,6 +3454,7 @@ getvnode(fdp, fd, fpp)
*fpp = fp; *fpp = fp;
return (error); return (error);
} }
/* /*
* Get (NFS) file handle * Get (NFS) file handle
*/ */

View File

@ -3442,7 +3442,7 @@ getvnode(fdp, fd, fpp)
if ((u_int)fd >= fdp->fd_nfiles || if ((u_int)fd >= fdp->fd_nfiles ||
(fp = fdp->fd_ofiles[fd]) == NULL) (fp = fdp->fd_ofiles[fd]) == NULL)
error = EBADF; error = EBADF;
else if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_FIFO) { else if (fp->f_vnode == NULL) {
fp = NULL; fp = NULL;
error = EINVAL; error = EINVAL;
} else { } else {
@ -3454,6 +3454,7 @@ getvnode(fdp, fd, fpp)
*fpp = fp; *fpp = fp;
return (error); return (error);
} }
/* /*
* Get (NFS) file handle * Get (NFS) file handle
*/ */