Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 8 Feb 2013 11:17:48 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r246549 - stable/8/sys/fs/msdosfs
Message-ID:  <201302081117.r18BHms8065940@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Fri Feb  8 11:17:47 2013
New Revision: 246549
URL: http://svnweb.freebsd.org/changeset/base/246549

Log:
  MFC r246218:
  Backup FATs were sometimes marked dirty by copying their first block
  from the primary FAT, and then they were not marked clean on unmount.
  Force marking them clean when appropriate.

Modified:
  stable/8/sys/fs/msdosfs/msdosfs_fat.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/fs/   (props changed)

Modified: stable/8/sys/fs/msdosfs/msdosfs_fat.c
==============================================================================
--- stable/8/sys/fs/msdosfs/msdosfs_fat.c	Fri Feb  8 11:15:57 2013	(r246548)
+++ stable/8/sys/fs/msdosfs/msdosfs_fat.c	Fri Feb  8 11:17:47 2013	(r246549)
@@ -321,8 +321,8 @@ updatefats(pmp, bp, fatbn)
 	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,12 +362,23 @@ updatefats(pmp, bp, fatbn)
 		 * 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 */
 			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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201302081117.r18BHms8065940>