Add a f_vnode field to struct file.

Several of the subtypes have an associated vnode which is used for
stuff like the f*() functions.

By giving the vnode a speparate field, a number of checks for the specific
subtype can be replaced simply with a check for f_vnode != NULL, and
we can later free f_data up to subtype specific use.

At this point in time, f_data still points to the vnode, so any code I
might have overlooked will still work.
This commit is contained in:
Poul-Henning Kamp 2003-06-22 08:41:43 +00:00
parent 93cdc37dbf
commit 3b6d965263
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=116678
29 changed files with 105 additions and 94 deletions

View File

@ -159,7 +159,7 @@ osf1_fstatfs(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)))
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
mp = fp->f_vnode->v_mount;
#ifdef MAC
error = mac_check_mount_stat(td->td_ucred, mp);
if (error) {

View File

@ -271,7 +271,7 @@ getdents_common(struct thread *td, struct linux_getdents64_args *args,
return (EBADF);
}
vp = fp->f_data;
vp = fp->f_vnode;
if (vp->v_type != VDIR) {
fdrop(fp, td);
return (EINVAL);

View File

@ -290,7 +290,7 @@ linux_fstatfs(struct thread *td, struct linux_fstatfs_args *args)
error = getvnode(td->td_proc->p_fd, args->fd, &fp);
if (error)
return error;
mp = ((struct vnode *)fp->f_data)->v_mount;
mp = fp->f_vnode->v_mount;
#ifdef MAC
error = mac_check_mount_stat(td->td_ucred, mp);
if (error) {

View File

@ -312,7 +312,7 @@ fd_truncate(td, fd, flp)
if ((error = fget(td, fd, &fp)) != 0)
return (error);
vp = fp->f_data;
vp = fp->f_vnode;
if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
fdrop(fp, td);

View File

@ -272,7 +272,7 @@ svr4_sys_getdents64(td, uap)
return (EBADF);
}
vp = fp->f_data;
vp = fp->f_vnode;
if (vp->v_type != VDIR) {
fdrop(fp, td);
@ -452,7 +452,7 @@ svr4_sys_getdents(td, uap)
return (EBADF);
}
vp = fp->f_data;
vp = fp->f_vnode;
if (vp->v_type != VDIR) {
fdrop(fp, td);
return (EINVAL);
@ -628,7 +628,7 @@ svr4_sys_fchroot(td, uap)
return error;
if ((error = getvnode(fdp, uap->fd, &fp)) != 0)
return error;
vp = fp->f_data;
vp = fp->f_vnode;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
if (vp->v_type != VDIR)
error = ENOTDIR;

View File

@ -395,7 +395,7 @@ fdesc_setattr(ap)
}
return (error);
}
vp = fp->f_data;
vp = fp->f_vnode;
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
fdrop(fp, ap->a_td);
return (error);

View File

@ -1349,6 +1349,7 @@ union_dircheck(struct thread *td, struct vnode **vp, struct file *fp)
}
VOP_UNLOCK(lvp, 0, td);
FILE_LOCK(fp);
fp->f_vnode = lvp;
fp->f_data = lvp;
fp->f_offset = 0;
FILE_UNLOCK(fp);

View File

@ -324,7 +324,7 @@ ibcs2_getdents(td, uap)
fdrop(fp, td);
return (EBADF);
}
vp = fp->f_data;
vp = fp->f_vnode;
if (vp->v_type != VDIR) { /* XXX vnode readdir op should do this */
fdrop(fp, td);
return (EINVAL);
@ -481,7 +481,7 @@ ibcs2_read(td, uap)
fdrop(fp, td);
return (EBADF);
}
vp = fp->f_data;
vp = fp->f_vnode;
if (vp->v_type != VDIR) {
fdrop(fp, td);
return read(td, (struct read_args *)uap);

View File

@ -133,7 +133,7 @@ ibcs2_fstatfs(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
mp = fp->f_vnode->v_mount;
sp = &mp->mnt_stat;
error = VFS_STATFS(mp, sp, td);
fdrop(fp, td);

View File

@ -781,7 +781,7 @@ __acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
error = vacl_get_acl(td, fp->f_data, uap->type, uap->aclp);
error = vacl_get_acl(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
}
mtx_unlock(&Giant);
@ -802,7 +802,7 @@ __acl_set_fd(struct thread *td, struct __acl_set_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
error = vacl_set_acl(td, fp->f_data, uap->type, uap->aclp);
error = vacl_set_acl(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
}
mtx_unlock(&Giant);
@ -867,7 +867,7 @@ __acl_delete_fd(struct thread *td, struct __acl_delete_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
error = vacl_delete(td, fp->f_data, uap->type);
error = vacl_delete(td, fp->f_vnode, uap->type);
fdrop(fp, td);
}
mtx_unlock(&Giant);
@ -932,7 +932,7 @@ __acl_aclcheck_fd(struct thread *td, struct __acl_aclcheck_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
error = vacl_aclcheck(td, fp->f_data, uap->type, uap->aclp);
error = vacl_aclcheck(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
}
mtx_unlock(&Giant);

View File

@ -352,7 +352,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
*/
fhold(fp);
FILEDESC_UNLOCK(fdp);
vp = fp->f_data;
vp = fp->f_vnode;
switch (flp->l_type) {
case F_RDLCK:
@ -430,7 +430,7 @@ kern_fcntl(struct thread *td, int fd, int cmd, intptr_t arg)
*/
fhold(fp);
FILEDESC_UNLOCK(fdp);
vp = fp->f_data;
vp = fp->f_vnode;
error = VOP_ADVLOCK(vp, (caddr_t)p->p_leader, F_GETLK, flp,
F_POSIX);
fdrop(fp, td);
@ -1028,7 +1028,7 @@ fpathconf(td, uap)
break;
case DTYPE_FIFO:
case DTYPE_VNODE:
vp = fp->f_data;
vp = fp->f_vnode;
mtx_lock(&Giant);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
error = VOP_PATHCONF(vp, uap->name, td->td_retval);
@ -1465,7 +1465,7 @@ fdfree(td)
lf.l_start = 0;
lf.l_len = 0;
lf.l_type = F_UNLCK;
vp = fp->f_data;
vp = fp->f_vnode;
(void) VOP_ADVLOCK(vp,
(caddr_t)td->td_proc->
p_leader,
@ -1564,7 +1564,7 @@ static int
is_unsafe(struct file *fp)
{
if (fp->f_type == DTYPE_VNODE) {
struct vnode *vp = fp->f_data;
struct vnode *vp = fp->f_vnode;
if ((vp->v_vflag & VV_PROCDEP) != 0)
return (1);
@ -1722,6 +1722,7 @@ fdcheckstd(td)
break;
}
NDFREE(&nd, NDF_ONLY_PNBUF);
fp->f_vnode = nd.ni_vp;
fp->f_data = nd.ni_vp;
fp->f_flag = flags;
fp->f_ops = &vnops;
@ -1770,7 +1771,7 @@ closef(fp, td)
lf.l_start = 0;
lf.l_len = 0;
lf.l_type = F_UNLCK;
vp = fp->f_data;
vp = fp->f_vnode;
(void) VOP_ADVLOCK(vp, (caddr_t)td->td_proc->p_leader,
F_UNLCK, &lf, F_POSIX);
}
@ -1794,7 +1795,7 @@ closef(fp, td)
lf.l_start = 0;
lf.l_len = 0;
lf.l_type = F_UNLCK;
vp = fp->f_data;
vp = fp->f_vnode;
(void) VOP_ADVLOCK(vp,
(caddr_t)fdtol->fdl_leader,
F_UNLCK, &lf, F_POSIX);
@ -1919,7 +1920,7 @@ _fgetvp(struct thread *td, int fd, struct vnode **vpp, int flags)
if (fp->f_type != DTYPE_VNODE && fp->f_type != DTYPE_FIFO) {
error = EINVAL;
} else {
*vpp = fp->f_data;
*vpp = fp->f_vnode;
vref(*vpp);
}
FILEDESC_UNLOCK(td->td_proc->p_fd);
@ -2018,7 +2019,7 @@ fdrop_locked(fp, td)
lf.l_start = 0;
lf.l_len = 0;
lf.l_type = F_UNLCK;
vp = fp->f_data;
vp = fp->f_vnode;
(void) VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK);
}
if (fp->f_ops != &badfileops)
@ -2064,7 +2065,7 @@ flock(td, uap)
}
mtx_lock(&Giant);
vp = fp->f_data;
vp = fp->f_vnode;
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;

View File

@ -3496,7 +3496,7 @@ __mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
switch (fp->f_type) {
case DTYPE_FIFO:
case DTYPE_VNODE:
vp = fp->f_data;
vp = fp->f_vnode;
mac_init_vnode_label(&intlabel);
@ -3704,7 +3704,7 @@ __mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
break;
}
vp = fp->f_data;
vp = fp->f_vnode;
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error != 0) {
mac_destroy_vnode_label(&intlabel);

View File

@ -781,7 +781,7 @@ __acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
error = vacl_get_acl(td, fp->f_data, uap->type, uap->aclp);
error = vacl_get_acl(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
}
mtx_unlock(&Giant);
@ -802,7 +802,7 @@ __acl_set_fd(struct thread *td, struct __acl_set_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
error = vacl_set_acl(td, fp->f_data, uap->type, uap->aclp);
error = vacl_set_acl(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
}
mtx_unlock(&Giant);
@ -867,7 +867,7 @@ __acl_delete_fd(struct thread *td, struct __acl_delete_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
error = vacl_delete(td, fp->f_data, uap->type);
error = vacl_delete(td, fp->f_vnode, uap->type);
fdrop(fp, td);
}
mtx_unlock(&Giant);
@ -932,7 +932,7 @@ __acl_aclcheck_fd(struct thread *td, struct __acl_aclcheck_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
error = vacl_aclcheck(td, fp->f_data, uap->type, uap->aclp);
error = vacl_aclcheck(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
}
mtx_unlock(&Giant);

View File

@ -781,7 +781,7 @@ __acl_get_fd(struct thread *td, struct __acl_get_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
error = vacl_get_acl(td, fp->f_data, uap->type, uap->aclp);
error = vacl_get_acl(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
}
mtx_unlock(&Giant);
@ -802,7 +802,7 @@ __acl_set_fd(struct thread *td, struct __acl_set_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
error = vacl_set_acl(td, fp->f_data, uap->type, uap->aclp);
error = vacl_set_acl(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
}
mtx_unlock(&Giant);
@ -867,7 +867,7 @@ __acl_delete_fd(struct thread *td, struct __acl_delete_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
error = vacl_delete(td, fp->f_data, uap->type);
error = vacl_delete(td, fp->f_vnode, uap->type);
fdrop(fp, td);
}
mtx_unlock(&Giant);
@ -932,7 +932,7 @@ __acl_aclcheck_fd(struct thread *td, struct __acl_aclcheck_fd_args *uap)
mtx_lock(&Giant);
error = getvnode(td->td_proc->p_fd, uap->filedes, &fp);
if (error == 0) {
error = vacl_aclcheck(td, fp->f_data, uap->type, uap->aclp);
error = vacl_aclcheck(td, fp->f_vnode, uap->type, uap->aclp);
fdrop(fp, td);
}
mtx_unlock(&Giant);

View File

@ -1059,7 +1059,7 @@ aio_qphysio(struct proc *p, struct aiocblist *aiocbe)
if (fp->f_type != DTYPE_VNODE)
return (-1);
vp = fp->f_data;
vp = fp->f_vnode;
/*
* If its not a disk, we don't want to return a positive error.
@ -1723,7 +1723,7 @@ aio_cancel(struct thread *td, struct aio_cancel_args *uap)
return (EBADF);
if (fp->f_type == DTYPE_VNODE) {
vp = fp->f_data;
vp = fp->f_vnode;
if (vn_isdisk(vp,&error)) {
td->td_retval[0] = AIO_NOTCANCELED;

View File

@ -282,7 +282,7 @@ fstatfs(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
mp = fp->f_vnode->v_mount;
fdrop(fp, td);
if (mp == NULL)
return (EBADF);
@ -403,7 +403,7 @@ fchdir(td, uap)
if ((error = getvnode(fdp, uap->fd, &fp)) != 0)
return (error);
vp = fp->f_data;
vp = fp->f_vnode;
VREF(vp);
fdrop(fp, td);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
@ -502,7 +502,7 @@ chroot_refuse_vdir_fds(fdp)
if (fp == NULL)
continue;
if (fp->f_type == DTYPE_VNODE) {
vp = fp->f_data;
vp = fp->f_vnode;
if (vp->v_type == VDIR)
return (EPERM);
}
@ -745,6 +745,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
td->td_retval[0] = indx;
return 0;
}
fp->f_vnode = vp;
fp->f_data = vp;
fp->f_flag = flags & FMASK;
fp->f_ops = &vnops;
@ -1346,7 +1347,7 @@ lseek(td, uap)
fdrop(fp, td);
return (ESPIPE);
}
vp = fp->f_data;
vp = fp->f_vnode;
noneg = (vp->v_type != VCHR);
offset = uap->offset;
switch (uap->whence) {
@ -2056,7 +2057,7 @@ fchflags(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
error = setfflags(td, fp->f_data, uap->flags);
error = setfflags(td, fp->f_vnode, uap->flags);
fdrop(fp, td);
return (error);
}
@ -2180,7 +2181,7 @@ fchmod(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
error = setfmode(td, fp->f_data, uap->mode);
error = setfmode(td, fp->f_vnode, uap->mode);
fdrop(fp, td);
return (error);
}
@ -2322,7 +2323,7 @@ fchown(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
error = setfown(td, fp->f_data, uap->uid, uap->gid);
error = setfown(td, fp->f_vnode, uap->uid, uap->gid);
fdrop(fp, td);
return (error);
}
@ -2520,7 +2521,7 @@ kern_futimes(struct thread *td, int fd, struct timeval *tptr,
return (error);
if ((error = getvnode(td->td_proc->p_fd, fd, &fp)) != 0)
return (error);
error = setutimes(td, fp->f_data, ts, 2, tptr == NULL);
error = setutimes(td, fp->f_vnode, ts, 2, tptr == NULL);
fdrop(fp, td);
return (error);
}
@ -2622,7 +2623,7 @@ ftruncate(td, uap)
fdrop(fp, td);
return (EINVAL);
}
vp = fp->f_data;
vp = fp->f_vnode;
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
fdrop(fp, td);
return (error);
@ -2733,7 +2734,7 @@ fsync(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
vp = fp->f_data;
vp = fp->f_vnode;
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
fdrop(fp, td);
return (error);
@ -3096,7 +3097,7 @@ ogetdirentries(td, uap)
fdrop(fp, td);
return (EBADF);
}
vp = fp->f_data;
vp = fp->f_vnode;
unionread:
if (vp->v_type != VDIR) {
fdrop(fp, td);
@ -3196,6 +3197,7 @@ ogetdirentries(td, uap)
struct vnode *tvp = vp;
vp = vp->v_mount->mnt_vnodecovered;
VREF(vp);
fp->f_vnode = vp;
fp->f_data = vp;
fp->f_offset = 0;
vput(tvp);
@ -3244,7 +3246,7 @@ getdirentries(td, uap)
fdrop(fp, td);
return (EBADF);
}
vp = fp->f_data;
vp = fp->f_vnode;
unionread:
if (vp->v_type != VDIR) {
fdrop(fp, td);
@ -3293,6 +3295,7 @@ getdirentries(td, uap)
struct vnode *tvp = vp;
vp = vp->v_mount->mnt_vnodecovered;
VREF(vp);
fp->f_vnode = vp;
fp->f_data = vp;
fp->f_offset = 0;
vput(tvp);
@ -3646,6 +3649,7 @@ fhopen(td, uap)
* from under us while we block in the lock op
*/
fhold(fp);
nfp->f_vnode = vp;
nfp->f_data = vp;
nfp->f_flag = fmode & FMASK;
nfp->f_ops = &vnops;
@ -3967,7 +3971,7 @@ extattr_set_fd(td, uap)
if (error)
return (error);
error = extattr_set_vp(fp->f_data, uap->attrnamespace,
error = extattr_set_vp(fp->f_vnode, uap->attrnamespace,
attrname, uap->data, uap->nbytes, td);
fdrop(fp, td);
@ -4140,7 +4144,7 @@ extattr_get_fd(td, uap)
if (error)
return (error);
error = extattr_get_vp(fp->f_data, uap->attrnamespace,
error = extattr_get_vp(fp->f_vnode, uap->attrnamespace,
attrname, uap->data, uap->nbytes, td);
fdrop(fp, td);
@ -4272,7 +4276,7 @@ extattr_delete_fd(td, uap)
error = getvnode(td->td_proc->p_fd, uap->fd, &fp);
if (error)
return (error);
vp = fp->f_data;
vp = fp->f_vnode;
error = extattr_delete_vp(vp, uap->attrnamespace, attrname, td);
fdrop(fp, td);
@ -4418,7 +4422,7 @@ extattr_list_fd(td, uap)
if (error)
return (error);
error = extattr_list_vp(fp->f_data, uap->attrnamespace, uap->data,
error = extattr_list_vp(fp->f_vnode, uap->attrnamespace, uap->data,
uap->nbytes, td);
fdrop(fp, td);

View File

@ -282,7 +282,7 @@ fstatfs(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
mp = ((struct vnode *)fp->f_data)->v_mount;
mp = fp->f_vnode->v_mount;
fdrop(fp, td);
if (mp == NULL)
return (EBADF);
@ -403,7 +403,7 @@ fchdir(td, uap)
if ((error = getvnode(fdp, uap->fd, &fp)) != 0)
return (error);
vp = fp->f_data;
vp = fp->f_vnode;
VREF(vp);
fdrop(fp, td);
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
@ -502,7 +502,7 @@ chroot_refuse_vdir_fds(fdp)
if (fp == NULL)
continue;
if (fp->f_type == DTYPE_VNODE) {
vp = fp->f_data;
vp = fp->f_vnode;
if (vp->v_type == VDIR)
return (EPERM);
}
@ -745,6 +745,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
td->td_retval[0] = indx;
return 0;
}
fp->f_vnode = vp;
fp->f_data = vp;
fp->f_flag = flags & FMASK;
fp->f_ops = &vnops;
@ -1346,7 +1347,7 @@ lseek(td, uap)
fdrop(fp, td);
return (ESPIPE);
}
vp = fp->f_data;
vp = fp->f_vnode;
noneg = (vp->v_type != VCHR);
offset = uap->offset;
switch (uap->whence) {
@ -2056,7 +2057,7 @@ fchflags(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
error = setfflags(td, fp->f_data, uap->flags);
error = setfflags(td, fp->f_vnode, uap->flags);
fdrop(fp, td);
return (error);
}
@ -2180,7 +2181,7 @@ fchmod(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
error = setfmode(td, fp->f_data, uap->mode);
error = setfmode(td, fp->f_vnode, uap->mode);
fdrop(fp, td);
return (error);
}
@ -2322,7 +2323,7 @@ fchown(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
error = setfown(td, fp->f_data, uap->uid, uap->gid);
error = setfown(td, fp->f_vnode, uap->uid, uap->gid);
fdrop(fp, td);
return (error);
}
@ -2520,7 +2521,7 @@ kern_futimes(struct thread *td, int fd, struct timeval *tptr,
return (error);
if ((error = getvnode(td->td_proc->p_fd, fd, &fp)) != 0)
return (error);
error = setutimes(td, fp->f_data, ts, 2, tptr == NULL);
error = setutimes(td, fp->f_vnode, ts, 2, tptr == NULL);
fdrop(fp, td);
return (error);
}
@ -2622,7 +2623,7 @@ ftruncate(td, uap)
fdrop(fp, td);
return (EINVAL);
}
vp = fp->f_data;
vp = fp->f_vnode;
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
fdrop(fp, td);
return (error);
@ -2733,7 +2734,7 @@ fsync(td, uap)
if ((error = getvnode(td->td_proc->p_fd, uap->fd, &fp)) != 0)
return (error);
vp = fp->f_data;
vp = fp->f_vnode;
if ((error = vn_start_write(vp, &mp, V_WAIT | PCATCH)) != 0) {
fdrop(fp, td);
return (error);
@ -3096,7 +3097,7 @@ ogetdirentries(td, uap)
fdrop(fp, td);
return (EBADF);
}
vp = fp->f_data;
vp = fp->f_vnode;
unionread:
if (vp->v_type != VDIR) {
fdrop(fp, td);
@ -3196,6 +3197,7 @@ ogetdirentries(td, uap)
struct vnode *tvp = vp;
vp = vp->v_mount->mnt_vnodecovered;
VREF(vp);
fp->f_vnode = vp;
fp->f_data = vp;
fp->f_offset = 0;
vput(tvp);
@ -3244,7 +3246,7 @@ getdirentries(td, uap)
fdrop(fp, td);
return (EBADF);
}
vp = fp->f_data;
vp = fp->f_vnode;
unionread:
if (vp->v_type != VDIR) {
fdrop(fp, td);
@ -3293,6 +3295,7 @@ getdirentries(td, uap)
struct vnode *tvp = vp;
vp = vp->v_mount->mnt_vnodecovered;
VREF(vp);
fp->f_vnode = vp;
fp->f_data = vp;
fp->f_offset = 0;
vput(tvp);
@ -3646,6 +3649,7 @@ fhopen(td, uap)
* from under us while we block in the lock op
*/
fhold(fp);
nfp->f_vnode = vp;
nfp->f_data = vp;
nfp->f_flag = fmode & FMASK;
nfp->f_ops = &vnops;
@ -3967,7 +3971,7 @@ extattr_set_fd(td, uap)
if (error)
return (error);
error = extattr_set_vp(fp->f_data, uap->attrnamespace,
error = extattr_set_vp(fp->f_vnode, uap->attrnamespace,
attrname, uap->data, uap->nbytes, td);
fdrop(fp, td);
@ -4140,7 +4144,7 @@ extattr_get_fd(td, uap)
if (error)
return (error);
error = extattr_get_vp(fp->f_data, uap->attrnamespace,
error = extattr_get_vp(fp->f_vnode, uap->attrnamespace,
attrname, uap->data, uap->nbytes, td);
fdrop(fp, td);
@ -4272,7 +4276,7 @@ extattr_delete_fd(td, uap)
error = getvnode(td->td_proc->p_fd, uap->fd, &fp);
if (error)
return (error);
vp = fp->f_data;
vp = fp->f_vnode;
error = extattr_delete_vp(vp, uap->attrnamespace, attrname, td);
fdrop(fp, td);
@ -4418,7 +4422,7 @@ extattr_list_fd(td, uap)
if (error)
return (error);
error = extattr_list_vp(fp->f_data, uap->attrnamespace, uap->data,
error = extattr_list_vp(fp->f_vnode, uap->attrnamespace, uap->data,
uap->nbytes, td);
fdrop(fp, td);

View File

@ -510,7 +510,7 @@ vn_read(fp, uio, active_cred, flags, td)
mtx_lock(&Giant);
KASSERT(uio->uio_td == td, ("uio_td %p is not td %p",
uio->uio_td, td));
vp = fp->f_data;
vp = fp->f_vnode;
ioflag = 0;
if (fp->f_flag & FNONBLOCK)
ioflag |= IO_NDELAY;
@ -560,7 +560,7 @@ vn_write(fp, uio, active_cred, flags, td)
mtx_lock(&Giant);
KASSERT(uio->uio_td == td, ("uio_td %p is not td %p",
uio->uio_td, td));
vp = fp->f_data;
vp = fp->f_vnode;
if (vp->v_type == VREG)
bwillwrite();
ioflag = IO_UNIT;
@ -608,7 +608,7 @@ vn_statfile(fp, sb, active_cred, td)
struct ucred *active_cred;
struct thread *td;
{
struct vnode *vp = fp->f_data;
struct vnode *vp = fp->f_vnode;
int error;
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
@ -751,7 +751,7 @@ vn_ioctl(fp, com, data, active_cred, td)
struct ucred *active_cred;
struct thread *td;
{
struct vnode *vp = fp->f_data;
struct vnode *vp = fp->f_vnode;
struct vnode *vpold;
struct vattr vattr;
int error;
@ -833,7 +833,7 @@ vn_poll(fp, events, active_cred, td)
int error;
#endif
vp = fp->f_data;
vp = fp->f_vnode;
#ifdef MAC
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td);
error = mac_check_vnode_poll(active_cred, fp->f_cred, vp);
@ -901,7 +901,7 @@ vn_closefile(fp, td)
{
fp->f_ops = &badfileops;
return (vn_close(fp->f_data, fp->f_flag, fp->f_cred, td));
return (vn_close(fp->f_vnode, fp->f_flag, fp->f_cred, td));
}
/*
@ -1052,7 +1052,7 @@ static int
vn_kqfilter(struct file *fp, struct knote *kn)
{
return (VOP_KQFILTER(fp->f_data, kn));
return (VOP_KQFILTER(fp->f_vnode, kn));
}
/*

View File

@ -389,7 +389,7 @@ smb_dev2share(int fd, int mode, struct smb_cred *scred,
fp = nsmb_getfp(scred->scr_td->td_proc->p_fd, fd, FREAD | FWRITE);
if (fp == NULL)
return EBADF;
vp = fp->f_data;
vp = fp->f_vnode;
if (vp == NULL) {
fdrop(fp, curthread);
return EBADF;

View File

@ -3496,7 +3496,7 @@ __mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
switch (fp->f_type) {
case DTYPE_FIFO:
case DTYPE_VNODE:
vp = fp->f_data;
vp = fp->f_vnode;
mac_init_vnode_label(&intlabel);
@ -3704,7 +3704,7 @@ __mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
break;
}
vp = fp->f_data;
vp = fp->f_vnode;
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error != 0) {
mac_destroy_vnode_label(&intlabel);

View File

@ -3496,7 +3496,7 @@ __mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
switch (fp->f_type) {
case DTYPE_FIFO:
case DTYPE_VNODE:
vp = fp->f_data;
vp = fp->f_vnode;
mac_init_vnode_label(&intlabel);
@ -3704,7 +3704,7 @@ __mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
break;
}
vp = fp->f_data;
vp = fp->f_vnode;
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error != 0) {
mac_destroy_vnode_label(&intlabel);

View File

@ -3496,7 +3496,7 @@ __mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
switch (fp->f_type) {
case DTYPE_FIFO:
case DTYPE_VNODE:
vp = fp->f_data;
vp = fp->f_vnode;
mac_init_vnode_label(&intlabel);
@ -3704,7 +3704,7 @@ __mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
break;
}
vp = fp->f_data;
vp = fp->f_vnode;
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error != 0) {
mac_destroy_vnode_label(&intlabel);

View File

@ -3496,7 +3496,7 @@ __mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
switch (fp->f_type) {
case DTYPE_FIFO:
case DTYPE_VNODE:
vp = fp->f_data;
vp = fp->f_vnode;
mac_init_vnode_label(&intlabel);
@ -3704,7 +3704,7 @@ __mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
break;
}
vp = fp->f_data;
vp = fp->f_vnode;
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error != 0) {
mac_destroy_vnode_label(&intlabel);

View File

@ -3496,7 +3496,7 @@ __mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
switch (fp->f_type) {
case DTYPE_FIFO:
case DTYPE_VNODE:
vp = fp->f_data;
vp = fp->f_vnode;
mac_init_vnode_label(&intlabel);
@ -3704,7 +3704,7 @@ __mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
break;
}
vp = fp->f_data;
vp = fp->f_vnode;
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error != 0) {
mac_destroy_vnode_label(&intlabel);

View File

@ -3496,7 +3496,7 @@ __mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
switch (fp->f_type) {
case DTYPE_FIFO:
case DTYPE_VNODE:
vp = fp->f_data;
vp = fp->f_vnode;
mac_init_vnode_label(&intlabel);
@ -3704,7 +3704,7 @@ __mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
break;
}
vp = fp->f_data;
vp = fp->f_vnode;
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error != 0) {
mac_destroy_vnode_label(&intlabel);

View File

@ -3496,7 +3496,7 @@ __mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
switch (fp->f_type) {
case DTYPE_FIFO:
case DTYPE_VNODE:
vp = fp->f_data;
vp = fp->f_vnode;
mac_init_vnode_label(&intlabel);
@ -3704,7 +3704,7 @@ __mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
break;
}
vp = fp->f_data;
vp = fp->f_vnode;
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error != 0) {
mac_destroy_vnode_label(&intlabel);

View File

@ -3496,7 +3496,7 @@ __mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap)
switch (fp->f_type) {
case DTYPE_FIFO:
case DTYPE_VNODE:
vp = fp->f_data;
vp = fp->f_vnode;
mac_init_vnode_label(&intlabel);
@ -3704,7 +3704,7 @@ __mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap)
break;
}
vp = fp->f_data;
vp = fp->f_vnode;
error = vn_start_write(vp, &mp, V_WAIT | PCATCH);
if (error != 0) {
mac_destroy_vnode_label(&intlabel);

View File

@ -116,6 +116,7 @@ struct file {
struct fileops *f_ops; /* File operations */
struct ucred *f_cred; /* credentials associated with descriptor */
int f_count; /* (f) reference count */
struct vnode *f_vnode; /* NULL or applicable vnode */
/* DFLAG_SEEKABLE specific fields */
off_t f_offset;

View File

@ -313,7 +313,7 @@ mmap(td, uap)
*/
if (fp->f_flag & FPOSIXSHM)
flags |= MAP_NOSYNC;
vp = fp->f_data;
vp = fp->f_vnode;
error = vget(vp, LK_EXCLUSIVE, td);
if (error)
goto done;