Commit 8fa77f3
committed
don't use BPB_TotSec16 to determine FAT type
Description for BPB_TotSec16:
> This field is the old 16-bit total count of sectors on the volume.
> This count includes the count of all sectors in all four regions of
> the volume. This field can be 0; if it is 0, then BPB_TotSec32 must
> be non-zero. For FAT32 volumes, this field must be 0. For FAT12 and
> FAT16 volumes, this field contains the sector count, and BPB_TotSec32
> is 0 if the total sector count “fits” (is less than 0x10000).
Source: https://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/fatgen103.doc
TL;DR: BPB_TotSec16 can be zero even for FAT12/FAT16 volumes if the
sector count exceeds 0x10000.
Instead, let's use BPB_FATSz16. Unlike BPB_TotSec16, BPB_FATSz16 must
be non-zero for FAT12/FAT16 volumes because BPB_FATSz32 only exists in
the FAT32 BPB. According to the document mentioned above, BPB_FATSz16
must be zero for FAT32 volumes.1 parent 0b04f53 commit 8fa77f3
1 file changed
Lines changed: 2 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
61 | 59 | | |
62 | 60 | | |
63 | 61 | | |
| |||
0 commit comments