summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2002-01-19 03:45:14 +0000
committeralfred <alfred@FreeBSD.org>2002-01-19 03:45:14 +0000
commit3bdb474052eac0079514ac913ada23af7551e4b6 (patch)
treece4fc16a60d6d8157da3e5ff8f1fb2ea50292e15
parentb925ae8d873f0a7b0055928493a00f221568178e (diff)
downloadFreeBSD-src-3bdb474052eac0079514ac913ada23af7551e4b6.zip
FreeBSD-src-3bdb474052eac0079514ac913ada23af7551e4b6.tar.gz
Semi-backout previous fgetvp change, we need the struct file pointer
to perform relative offset calculations, so use fget instead.
-rw-r--r--sys/compat/svr4/svr4_fcntl.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/sys/compat/svr4/svr4_fcntl.c b/sys/compat/svr4/svr4_fcntl.c
index f444c4b..12c956c 100644
--- a/sys/compat/svr4/svr4_fcntl.c
+++ b/sys/compat/svr4/svr4_fcntl.c
@@ -285,6 +285,7 @@ fd_truncate(td, fd, flp)
struct flock *flp;
{
off_t start, length;
+ struct file *fp;
struct vnode *vp;
struct vattr vattr;
int error, *retval;
@@ -295,16 +296,18 @@ fd_truncate(td, fd, flp)
/*
* We only support truncating the file.
*/
- if ((error = fgetvp(td, fd, &vp)) != 0)
+ if ((error = fget(td, fd, &fp)) != 0)
return (error);
- if (vp->v_type == VFIFO) {
- vrele(vp);
+ vp = (struct vnode *) fp->f_data;
+
+ if (fp->f_type != DTYPE_VNODE || vp->v_type == VFIFO) {
+ fdrop(fp, td);
return ESPIPE;
}
- if ((error = VOP_GETATTR(vp, &vattr, td->td_proc->p_ucred, td)) != 0)
- vrele(vp);
+ if ((error = VOP_GETATTR(vp, &vattr, td->td_proc->p_ucred, td)) != 0) {
+ fdrop(fp, td);
return error;
}
@@ -324,12 +327,13 @@ fd_truncate(td, fd, flp)
break;
default:
- vrele(vp);
+ fdrop(fp, td);
return EINVAL;
}
if (start + flp->l_len < length) {
/* We don't support free'ing in the middle of the file */
+ fdrop(fp, td);
return EINVAL;
}
@@ -338,7 +342,7 @@ fd_truncate(td, fd, flp)
error = ftruncate(td, &ft);
- vrele(vp);
+ fdrop(fp, td);
return (error);
}
OpenPOWER on IntegriCloud