[Midnightbsd-cvs] src [8763] trunk/sys/fs/msdosfs/msdosfs_fat.c: Backup FATs were sometimes marked dirty by copying their first block from the primary FAT, and then not marked clean.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sun Sep 25 22:43:05 EDT 2016
Revision: 8763
http://svnweb.midnightbsd.org/src/?rev=8763
Author: laffer1
Date: 2016-09-25 22:43:05 -0400 (Sun, 25 Sep 2016)
Log Message:
-----------
Backup FATs were sometimes marked dirty by copying their first block from the primary FAT, and then not marked clean. Force them to be clean
Modified Paths:
--------------
trunk/sys/fs/msdosfs/msdosfs_fat.c
Modified: trunk/sys/fs/msdosfs/msdosfs_fat.c
===================================================================
--- trunk/sys/fs/msdosfs/msdosfs_fat.c 2016-09-26 02:42:07 UTC (rev 8762)
+++ trunk/sys/fs/msdosfs/msdosfs_fat.c 2016-09-26 02:43:05 UTC (rev 8763)
@@ -321,8 +321,8 @@
struct buf *bp;
u_long fatbn;
{
- int i;
struct buf *bpn;
+ int cleanfat, i;
#ifdef MSDOSFS_DEBUG
printf("updatefats(pmp %p, bp %p, fatbn %lu)\n", pmp, bp, fatbn);
@@ -362,6 +362,12 @@
* filesystem was mounted. If synch is asked for then use
* bwrite()'s and really slow things down.
*/
+ if (fatbn != pmp->pm_fatblk || FAT12(pmp))
+ cleanfat = 0;
+ else if (FAT16(pmp))
+ cleanfat = 16;
+ else
+ cleanfat = 32;
for (i = 1; i < pmp->pm_FATs; i++) {
fatbn += pmp->pm_FATsecs;
/* getblk() never fails */
@@ -368,6 +374,11 @@
bpn = getblk(pmp->pm_devvp, fatbn, bp->b_bcount,
0, 0, 0);
bcopy(bp->b_data, bpn->b_data, bp->b_bcount);
+ /* Force the clean bit on in the other copies. */
+ if (cleanfat == 16)
+ ((u_int8_t *)bpn->b_data)[3] |= 0x80;
+ else if (cleanfat == 32)
+ ((u_int8_t *)bpn->b_data)[7] |= 0x08;
if (pmp->pm_flags & MSDOSFSMNT_WAITONFAT)
bwrite(bpn);
else
More information about the Midnightbsd-cvs
mailing list