Skip to contentSkip to conversation

fat32 w/o parition table? (a.k.a VBR instead of MBR)

U-Boot-Users Brad Parker 2 participants 2 messages May 8, 2008 – Jun 4, 2008

lore
Share & tools
lore
#0 lore raw

After some user complaints about not being able to fatls micro sd cards which were formatted by Windows XP, I felt compelled to make the following change (to u-boot 1.1.6, which I know is ancient, but looking at the git tree, the latest doesn't handle it either near as I can tell.

Just curious if anyone has any thoughts.

In the latest code, it seems like checking the partition table first is dangerous as a VBR might looks like it has a partition table (but it would be bogus)

Some documents suggest checking the first 3 bytes of the block for the branch instructions. The idea being that an MBR with a valid partition table won't have the branch. voodoo, I know...

-brad

fat.c 2008-05-08 12:54:56.000000000 -0400 renamed from fat.c.orig 2008-05-08 16:18:40.000000000 -0400 +4 -1
@@ -52,6 +52,7 @@
 #define DOS_PART_TBL_OFFSET    0x1be
 #define DOS_PART_MAGIC_OFFSET  0x1fe
 #define DOS_FS_TYPE_OFFSET     0x36
+#define DOS_FS_FAT32_TYPE_OFFSET       0x52
 
 int disk_read (__u32 startblock, __u32 getsize, __u8 * bufptr)
 {
@@ -85,7 +86,9 @@
                return -1;
        }
 
-       if(!strncmp((char *)&buffer[DOS_FS_TYPE_OFFSET],"FAT",3)) {
+       if(!strncmp((char *)&buffer[DOS_FS_TYPE_OFFSET],"FAT",3) ||
+          !strncmp((char *)&buffer[DOS_FS_FAT32_TYPE_OFFSET],"FAT32",5))
+       {
                /* ok, we assume we are on a PBR only */
                cur_part = 1;
                part_offset=0;

This lets me fatls/fatload from the fat32 file systems created by windows.

I've done a little FAT hacking, and I think this falls under the category of "disk with VBR instead of MBR".

-brad

#1 lore raw

Hello,

Quoted 9 lines · in message <1998.1210278835@mini> you wrote:

After some user complaints about not being able to fatls micro sd cards which were formatted by Windows XP, I felt compelled to make the following change (to u-boot 1.1.6, which I know is ancient, but looking at the git tree, the latest doesn't handle it either near as I can tell.

Just curious if anyone has any thoughts.

Quoted 7 lines

In the latest code, it seems like checking the partition table first is dangerous as a VBR might looks like it has a partition table (but it would be bogus)

Some documents suggest checking the first 3 bytes of the block for the branch instructions. The idea being that an MBR with a valid partition table won't have the branch. voodoo, I know...

Strangely enough, this message seems to have received no feedback at all.

So what do we do about this?

Best regards,

Wolfgang Denk

Signature · 5 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
Leave bigotry in your quarters; there's no room for it on the bridge.
	-- Kirk, "Balance of Terror", stardate 1709.2