diff options
author | trhodes <trhodes@FreeBSD.org> | 2003-06-27 15:46:38 +0000 |
---|---|---|
committer | trhodes <trhodes@FreeBSD.org> | 2003-06-27 15:46:38 +0000 |
commit | df35e60f9f9e72d96903368cf6c933be6f3ff720 (patch) | |
tree | ec896ab3fd83e2f3a3dae11ccebad780184478c7 /sys/fs/msdosfs | |
parent | af2693c2fbc79610453a2ac7c3523f25e51e6db9 (diff) | |
download | FreeBSD-src-df35e60f9f9e72d96903368cf6c933be6f3ff720.zip FreeBSD-src-df35e60f9f9e72d96903368cf6c933be6f3ff720.tar.gz |
Fix a bug where a truncate operation involving truncate() or ftruncate() on
an MSDOSFS file system either failed, silently corrupted the file, or
sometimes corrupted the neighboring file.
PR: 53695
Submitted by: Ariff Abdullah <skywizard@MyBSD.org.my> (original version)
MFC: 3 days
Diffstat (limited to 'sys/fs/msdosfs')
-rw-r--r-- | sys/fs/msdosfs/msdosfs_denode.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/sys/fs/msdosfs/msdosfs_denode.c b/sys/fs/msdosfs/msdosfs_denode.c index 72de748..b456832 100644 --- a/sys/fs/msdosfs/msdosfs_denode.c +++ b/sys/fs/msdosfs/msdosfs_denode.c @@ -512,26 +512,19 @@ detrunc(dep, length, flags, cred, td) bn = cntobn(pmp, eofentry); error = bread(pmp->pm_devvp, bn, pmp->pm_bpcluster, NOCRED, &bp); - } else { - bn = de_blk(pmp, length); - error = bread(DETOV(dep), bn, pmp->pm_bpcluster, - NOCRED, &bp); - } - if (error) { - brelse(bp); + if (error) { + brelse(bp); #ifdef MSDOSFS_DEBUG - printf("detrunc(): bread fails %d\n", error); + printf("detrunc(): bread fails %d\n", error); #endif - return (error); + return (error); + } + bzero(bp->b_data + boff, pmp->pm_bpcluster - boff); + if (flags & IO_SYNC) + bwrite(bp); + else + bdwrite(bp); } - /* - * is this the right place for it? - */ - bzero(bp->b_data + boff, pmp->pm_bpcluster - boff); - if (flags & IO_SYNC) - bwrite(bp); - else - bdwrite(bp); } /* |