diff options
author | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 2001-07-16 02:56:49 +0000 |
---|---|---|
committer | Constantine Sapuntzakis <csapuntz@cvs.openbsd.org> | 2001-07-16 02:56:49 +0000 |
commit | 67cbfeff543fa0a4aaf0cc1dd670ea78e54c302c (patch) | |
tree | 171acffa199af0e055ddf601708cebb058025166 /sys/ufs/ext2fs | |
parent | 90290729d4a4e905d96796442cd478bd4aef5915 (diff) |
Don't try to truncate anything except for symlinks, directories, and
regular files.
ftruncate and truncate that go through FFS/EXT2FS/MFS will now return
EINVAL when done on devices.
Bug introduced when VOP_TRUNCATE was removed, thus removing spec_truncate.
Thanks to millert@ for tracking this one down.
Diffstat (limited to 'sys/ufs/ext2fs')
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_inode.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sys/ufs/ext2fs/ext2fs_inode.c b/sys/ufs/ext2fs/ext2fs_inode.c index 311b0716640..bbd8c03ed8a 100644 --- a/sys/ufs/ext2fs/ext2fs_inode.c +++ b/sys/ufs/ext2fs/ext2fs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_inode.c,v 1.12 2001/06/27 04:58:47 art Exp $ */ +/* $OpenBSD: ext2fs_inode.c,v 1.13 2001/07/16 02:56:48 csapuntz Exp $ */ /* $NetBSD: ext2fs_inode.c,v 1.1 1997/06/11 09:33:56 bouyer Exp $ */ /* @@ -92,7 +92,7 @@ ext2fs_inactive(v) goto out; if (ip->i_e2fs_nlink == 0 && (vp->v_mount->mnt_flag & MNT_RDONLY) == 0) { - error = ext2fs_truncate(ip, (off_t)0, 0, NOCRED); + (void) ext2fs_truncate(ip, (off_t)0, 0, NOCRED); TIMEVAL_TO_TIMESPEC(&time, &ts); ip->i_e2fs_dtime = ts.tv_sec; ip->i_flag |= IN_CHANGE | IN_UPDATE; @@ -184,6 +184,11 @@ ext2fs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) if (length < 0) return (EINVAL); + if (ovp->v_type != VREG && + ovp->v_type != VDIR && + ovp->v_type != VLNK) + return (EINVAL); + if (ovp->v_type == VLNK && (oip->i_e2fs_size < ovp->v_mount->mnt_maxsymlinklen || (ovp->v_mount->mnt_maxsymlinklen == 0 && |