diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 1999-12-06 07:23:22 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 1999-12-06 07:23:22 +0000 |
commit | b06f4c02a6583aef15b521f3457134bb302b987b (patch) | |
tree | c2b92302aa00c3c084414e1997a97eacc7e41a4e | |
parent | 14cd26d40a0951eaf4cfd5436ffce5c26fae0607 (diff) |
When truncating directories by less than a block we shouldn't zero the
part of the block that we're deallocating.
From NetBSD.
-rw-r--r-- | sys/ufs/ffs/ffs_inode.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 21978dbb82b..225ccc23acb 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ffs_inode.c,v 1.14 1999/12/06 07:03:04 art Exp $ */ +/* $OpenBSD: ffs_inode.c,v 1.15 1999/12/06 07:23:21 art Exp $ */ /* $NetBSD: ffs_inode.c,v 1.10 1996/05/11 18:27:19 mycroft Exp $ */ /* @@ -275,10 +275,11 @@ ffs_truncate(v) /* * Shorten the size of the file. If the file is not being - * truncated to a block boundry, the contents of the + * truncated to a block boundary, the contents of the * partial block following the end of the file must be - * zero'ed in case it ever become accessable again because - * of subsequent file growth. + * zero'ed in case it ever become accessible again because + * of subsequent file growth. Directories however are not + * zero'ed as they should grow back initialized to empty. */ offset = blkoff(fs, length); if (offset == 0) { @@ -299,7 +300,9 @@ ffs_truncate(v) #else (void) vnode_pager_uncache(ovp); #endif - bzero((char *)bp->b_data + offset, (u_int)(size - offset)); + if (ovp->v_type != VDIR) + bzero((char *)bp->b_data + offset, + (u_int)(size - offset)); allocbuf(bp, size); if (aflags & B_SYNC) bwrite(bp); |