summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorart <art@openbsd.org>1999-12-06 07:23:21 +0000
committerart <art@openbsd.org>1999-12-06 07:23:21 +0000
commitab43bea2b660e4623b12ad507253aeb54a09f1c7 (patch)
tree2db20db14b5a3670355f22d5f143e5f75b54d119
parentNew ESP code that's v4 and v6 friendly. (diff)
downloadwireguard-openbsd-ab43bea2b660e4623b12ad507253aeb54a09f1c7.tar.xz
wireguard-openbsd-ab43bea2b660e4623b12ad507253aeb54a09f1c7.zip
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.c13
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);