Removable media such as sd cards do not have a boot sector. I think this is what I was looking for with 0xEB
Matt. On Oct 10, 2:44 am, Oliver Seitz <[email protected]> wrote: > Hi Matt and all, > > finaly I started digging into your FAT32 code. > > In fat32_read_boot_sector() you're comparing byte 0 with 0xEB. I presume this > should indicate a non-partitioned medium, i.e. one with the filesystem > starting at sector 0? > > Well, unfortunately it does not. A MBR can start with 0xEB, 0xEB stands for > nothing more than a long jump in intel assembly. Here's a dump of one of my > disks: > > 0000: EB 48 90 8E C0 8E D8 8E D0 BC 00 7C BE 1A 7C BF .H.........|..|. > 0010: 1A 06 B9 E6 01 F3 A4 E9 00 8A 31 F6 BB BE 07 B1 ..........1..... > 0020: 04 38 2F 74 08 7F 75 85 F6 75 71 89 DE 80 C3 10 .8/t. u..uq..... > 0030: E2 EF 85 F6 75 02 CD 18 80 FA 80 72 0B 8A 03 02 ....u......r.... > 0040: FF 00 00 20 01 00 00 00 00 02 FA 90 90 F6 C2 80 ... ............ > 0050: 75 02 B2 80 EA 59 7C 00 00 31 C0 8E D8 8E D0 BC u....Y|..1...... > 0060: 00 20 FB A0 40 7C 3C FF 74 02 88 C2 52 BE 81 7D . ..@|<.t...R..} > 0070: E8 36 01 F6 C2 80 74 56 B4 41 BB AA 55 CD 13 5A .6....tV.A..U..Z > 0080: 52 72 4B 81 FB 55 AA 75 45 A0 41 7C 84 C0 78 3E RrK..U.uE.A|..x> > 0090: 75 05 83 E1 01 74 37 66 8B 4C 10 BE 05 7C C6 44 u....t7f.L...|.D > 00A0: FF 01 66 8B 1E 44 7C C7 04 10 00 C7 44 02 01 00 ..f..D|.....D... > 00B0: 66 89 5C 08 C7 44 06 00 70 66 31 C0 89 44 04 66 f.\..D..pf1..D.f > 00C0: 89 44 0C B4 42 CD 13 72 05 BB 00 70 EB 7D B4 08 .D..B..r...p.}.. > 00D0: CD 13 73 0A F6 C2 80 0F 84 E8 00 E9 8D 00 BE 05 ..s............. > 00E0: 7C C6 44 FF 00 66 31 C0 88 F0 40 66 89 44 04 31 |[email protected] > 00F0: D2 88 CA C1 E2 02 88 E8 88 F4 40 89 44 08 31 C0 [email protected]. > 0100: 88 D0 C0 E8 02 66 89 04 66 A1 44 7C 66 31 D2 66 .....f..f.D|f1.f > 0110: F7 34 88 54 0A 66 31 D2 66 F7 74 04 88 54 0B 89 .4.T.f1.f.t..T.. > 0120: 44 0C 3B 44 08 7D 3C 8A 54 0D C0 E2 06 8A 4C 0A D.;D.}<.T.....L. > 0130: FE C1 08 D1 8A 6C 0C 5A 8A 74 0B BB 00 70 8E C3 .....l.Z.t...p.. > 0140: 31 DB B8 01 02 CD 13 72 2A 8C C3 8E 06 48 7C 60 1......r*....H|` > 0150: 1E B9 00 01 8E DB 31 F6 31 FF FC F3 A5 1F 61 FF ......1.1.....a. > 0160: 26 42 7C BE 87 7D E8 40 00 EB 0E BE 8C 7D E8 38 &B|....@.....}.8 > 0170: 00 EB 06 BE 96 7D E8 30 00 BE 9B 7D E8 2A 00 EB .....}.0...}.*.. > 0180: FE 47 52 55 42 20 00 47 65 6F 6D 00 48 61 72 64 .GRUB .Geom.Hard > 0190: 20 44 69 73 6B 00 52 65 61 64 00 20 45 72 72 6F Disk.Read. Erro > 01A0: 72 00 BB 01 00 B4 0E CD 10 AC 3C 00 75 F4 C3 00 r.........<.u... > 01B0: 00 00 00 00 00 00 00 00 43 0B 47 99 90 80 00 01 ........C.G..... > 01C0: 01 00 0B 0F FF FF 3F 00 00 00 A1 3B 2E 01 00 00 ......?....;.... > 01D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > 01E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ > 01F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 AA ..............U. > > Unfortunately, there seems to be no safe way to distinct a master boot record > from a volume boot record within sector 0. There is a signature (0x41615252, > note little-endianess, so the values are LSB first) at the beginning of the > FSInfo sector. The volume boot sector has a pointer to this sector, so to > find out if a medium is non-partitioned, you would have to (untested) > > fat32_raw_read_sector2(0) > fat32_raw_read_sector2(fat32_sector_buffer[48]+fat32_sector_buffer[49]*256) > > if ( > (fat32_sector_buffer[0] = 0x52) & > (fat32_sector_buffer[1] = 0x52) & > (fat32_sector_buffer[2] = 0x61) & > (fat32_sector_buffer[3] = 0x41) > ) > then -- Medium is identified as unpartitioned FAT32 filesystem > fat32_raw_read_sector2(0) > fat32_init_ok = TRUE > else -- Medium is partitioned or contains no FAT32 filesystem > fat32_raw_read_sector2(0) > [...] > end if > > This is only executed once when a new medium is accessed, so execution speed > is of no importance at all. It's OK to read sectors twice even if we only > need a byte from it. > > Greets, > Kiste -- You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
