Skip to contentSkip to conversation

fat: root directory cluster only makes sense for FAT32

PATCH New Sergei Shtylyov 2 participants 2 messages Aug 19, 2011 – Oct 1, 2011 VFAT/FAT/msdos filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 fat: root directory cluster only makes sense for FAT32

The root directory cluster field only exists in a FAT32 boot sector, so the 'root_cluster' variable in do_fat_read() contains garbage in case of FAT12/16. Make it contain 0 instead as this is what is passed to get_vfatname() in that case anyway.

---
Slight optimization atop of commit 3831530dcb7b71329c272ccd6181f8038b6a6dd0 (VFAT: fix processing of scattered long file name entries).

The patch was generated atop of the below patches posted earlier:
http://marc.info/?l=u-boot&m=131283284822789
http://marc.info/?l=u-boot&m=131283289722891

 fs/fat/fat.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)
fs/fat/fat.c +6 -8
Index: u-boot/fs/fat/fat.c
===================================================================
@@ -788,7 +788,7 @@ do_fat_read (const char *filename, void 
 	int files = 0, dirs = 0;
 	long ret = -1;
 	int firsttime;
-	__u32 root_cluster;
+	__u32 root_cluster = 0;
 	int rootdir_size = 0;
 	int j;
 
@@ -797,12 +797,12 @@ do_fat_read (const char *filename, void 
 		return -1;
 	}
 
-	root_cluster = bs.root_cluster;
-
-	if (mydata->fatsize == 32)
+	if (mydata->fatsize == 32) {
+		root_cluster = bs.root_cluster;
 		mydata->fatlength = bs.fat32_length;
-	else
+	} else {
 		mydata->fatlength = bs.fat_length;
+	}
 
 	mydata->fat_sect = bs.reserved;
 
@@ -904,9 +904,7 @@ do_fat_read (const char *filename, void 
 						((dir_slot *)dentptr)->alias_checksum;
 
 					get_vfatname(mydata,
-						     (mydata->fatsize == 32) ?
-						     root_cluster :
-						     0,
+						     root_cluster,
 						     do_fat_read_block,
 						     dentptr, l_name);
 
#1 lore raw

PATCH 1/2 fat: root directory cluster only makes sense for FAT32

Dear Sergei Shtylyov,

Quoted 11 lines · In message <[email protected]> you wrote:

The root directory cluster field only exists in a FAT32 boot sector, so the 'root_cluster' variable in do_fat_read() contains garbage in case of FAT12/16. Make it contain 0 instead as this is what is passed to get_vfatname() in that case anyway.

---
Slight optimization atop of commit 3831530dcb7b71329c272ccd6181f8038b6a6dd0 (VFAT: fix processing of scattered long file name entries).

Quoted 6 lines

The patch was generated atop of the below patches posted earlier:
http://marc.info/?l=u-boot&m=131283284822789
http://marc.info/?l=u-boot&m=131283289722891

 fs/fat/fat.c |   14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 11 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Each team building another component has been using the  most  recent
tested  version  of the integrated system as a test bed for debugging
its piece. Their work will be set back by having that test bed change
under them. Of course it must. But the changes need to be  quantized.
Then  each  user  has periods of productive stability, interrupted by
bursts of test-bed change. This seems to be much less disruptive than
a constant rippling and trembling.
                     - Frederick Brooks Jr., "The Mythical Man Month"