Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/msdosfs When extending a file, either by truncating o...



details:   https://anonhg.NetBSD.org/src/rev/d5020a1fe094
branches:  trunk
changeset: 763447:d5020a1fe094
user:      hannken <hannken%NetBSD.org@localhost>
date:      Sun Mar 20 12:21:28 2011 +0000

description:
When extending a file, either by truncating or by writing past EOF make
sure the unallocated remainder of the last page gets zeroed.

Detected by fsx.

diffstat:

 sys/fs/msdosfs/msdosfs_denode.c |  6 +++---
 sys/fs/msdosfs/msdosfs_vnops.c  |  9 +++++++--
 2 files changed, 10 insertions(+), 5 deletions(-)

diffs (64 lines):

diff -r 5fffb9199ad3 -r d5020a1fe094 sys/fs/msdosfs/msdosfs_denode.c
--- a/sys/fs/msdosfs/msdosfs_denode.c   Sun Mar 20 11:41:24 2011 +0000
+++ b/sys/fs/msdosfs/msdosfs_denode.c   Sun Mar 20 12:21:28 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_denode.c,v 1.40 2010/07/21 17:52:10 hannken Exp $      */
+/*     $NetBSD: msdosfs_denode.c,v 1.41 2011/03/20 12:21:28 hannken Exp $      */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.40 2010/07/21 17:52:10 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.41 2011/03/20 12:21:28 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -583,7 +583,7 @@
        uvm_vnp_setwritesize(DETOV(dep), (voff_t)dep->de_FileSize);
        dep->de_flag |= DE_UPDATE|DE_MODIFIED;
        uvm_vnp_zerorange(DETOV(dep), (off_t)osize,
-           (size_t)(dep->de_FileSize - osize));
+           (size_t)(round_page(dep->de_FileSize) - osize));
        uvm_vnp_setsize(DETOV(dep), (voff_t)dep->de_FileSize);
        return (deupdat(dep, 1));
 }
diff -r 5fffb9199ad3 -r d5020a1fe094 sys/fs/msdosfs/msdosfs_vnops.c
--- a/sys/fs/msdosfs/msdosfs_vnops.c    Sun Mar 20 11:41:24 2011 +0000
+++ b/sys/fs/msdosfs/msdosfs_vnops.c    Sun Mar 20 12:21:28 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_vnops.c,v 1.73 2011/03/19 20:05:21 hannken Exp $       */
+/*     $NetBSD: msdosfs_vnops.c,v 1.74 2011/03/20 12:21:28 hannken Exp $       */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.73 2011/03/19 20:05:21 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.74 2011/03/20 12:21:28 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -554,6 +554,7 @@
        u_long count;
        vsize_t bytelen;
        off_t oldoff;
+       size_t rem;
        struct uio *uio = ap->a_uio;
        struct vnode *vp = ap->a_vp;
        struct denode *dep = VTODE(vp);
@@ -623,6 +624,10 @@
                dep->de_FileSize = uio->uio_offset + resid;
                /* hint uvm to not read in extended part */
                uvm_vnp_setwritesize(vp, dep->de_FileSize);
+               /* zero out the remainder of the last page */
+               rem = round_page(dep->de_FileSize) - dep->de_FileSize;
+               if (rem > 0)
+                       uvm_vnp_zerorange(vp, (off_t)dep->de_FileSize, rem);
                extended = 1;
        }
 



Home | Main Index | Thread Index | Old Index