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
This commit is contained in:
Tom Rhodes 2003-06-27 15:46:38 +00:00
parent b712059588
commit c2f95f6688
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=116917

View File

@ -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);
}
/*