diff options
author | dyson <dyson@FreeBSD.org> | 1996-10-02 05:01:17 +0000 |
---|---|---|
committer | dyson <dyson@FreeBSD.org> | 1996-10-02 05:01:17 +0000 |
commit | ef4cc3f18ca0f0e5fe294bc71a0fd57c64aa4788 (patch) | |
tree | ad7946a0d5aea119efbe9516ac07a9d0eac0c266 /sys/msdosfs | |
parent | 3a785907a312e66787aed7938e8814bf53c44477 (diff) | |
download | FreeBSD-src-ef4cc3f18ca0f0e5fe294bc71a0fd57c64aa4788.zip FreeBSD-src-ef4cc3f18ca0f0e5fe294bc71a0fd57c64aa4788.tar.gz |
MSDOS FS used to allocate a buffer before extending the VM object. In
certain error conditions, it is possible for pages to be left allocated
in the object beyond it's end. It is generally bad practice to allocate
pages beyond the end of an object.
Diffstat (limited to 'sys/msdosfs')
-rw-r--r-- | sys/msdosfs/msdosfs_vnops.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c index ae56e2b..6bd819a 100644 --- a/sys/msdosfs/msdosfs_vnops.c +++ b/sys/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_vnops.c,v 1.32 1996/09/03 14:23:33 bde Exp $ */ +/* $Id: msdosfs_vnops.c,v 1.33 1996/09/19 18:20:47 nate Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.20 1994/08/21 18:44:13 ws Exp $ */ /*- @@ -731,6 +731,14 @@ msdosfs_write(ap) break; } + croffset = uio->uio_offset & pmp->pm_crbomask; + n = min(uio->uio_resid, pmp->pm_bpcluster - croffset); + if (uio->uio_offset + n > dep->de_FileSize) { + dep->de_FileSize = uio->uio_offset + n; + /* The object size needs to be set before buffer is allocated */ + vnode_pager_setsize(vp, dep->de_FileSize); + } + if ((uio->uio_offset & pmp->pm_crbomask) == 0 && (de_blk(pmp, uio->uio_offset + uio->uio_resid) > de_blk(pmp, uio->uio_offset) || uio->uio_offset + uio->uio_resid >= dep->de_FileSize)) { @@ -768,12 +776,6 @@ msdosfs_write(ap) break; } - croffset = uio->uio_offset & pmp->pm_crbomask; - n = min(uio->uio_resid, pmp->pm_bpcluster - croffset); - if (uio->uio_offset + n > dep->de_FileSize) { - dep->de_FileSize = uio->uio_offset + n; - vnode_pager_setsize(vp, dep->de_FileSize); /* why? */ - } /* * Should these vnode_pager_* functions be done on dir * files? |