Skip to content

Commit

Permalink
fixed a bug in mkfat
Browse files Browse the repository at this point in the history
chPhysDriveNumber is set to 0x80 only for non-floppy media types (or floppy boot code could fail)
  • Loading branch information
maxpat78 committed Apr 13, 2024
1 parent 4ab72f9 commit 851a38b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions FATtools/FAT.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class boot_fat32(object):
0x30: ('wFSISector', '<H'), # usually 1
0x32: ('wBootCopySector', '<H'), # 0x0000 or 0xFFFF if unused, usually 6
0x34: ('chReserved', '12s'),
0x40: ('chPhysDriveNumber', 'B'),
0x40: ('chPhysDriveNumber', 'B'), # 00h=floppy, 80h=fixed (used by boot code)
0x41: ('chFlags', 'B'),
0x42: ('chExtBootSignature', 'B'), # 0x28 or 0x29 (zero if following id, label and FS type absent)
0x43: ('dwVolumeID', '<I'),
Expand Down Expand Up @@ -158,7 +158,7 @@ class boot_fat16(object):
0x1A: ('wHeads', '<H'),
0x1C: ('dwHiddenSectors', '<I'),
0x20: ('dwTotalSectors', '<I'),
0x24: ('chPhysDriveNumber', 'B'),
0x24: ('chPhysDriveNumber', 'B'), # 00h=floppy, 80h=fixed (used by boot code)
0x25: ('uchCurrentHead', 'B'), # unused
0x26: ('uchSignature', 'B'), # 0x28 or 0x29 (zero if following id, label and FS type absent)
0x27: ('dwVolumeID', '<I'),
Expand Down
3 changes: 2 additions & 1 deletion FATtools/mkfat.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,8 @@ def fat_mkfs(stream, size, sector=512, params={}):
boot.wSectorsPerFAT = fsinfo['fat_size']//sector
else:
boot.dwSectorsPerFAT = fsinfo['fat_size']//sector
boot.chPhysDriveNumber = 0x80
if media_byte != 0xF0: # if not floppy
boot.chPhysDriveNumber = 0x80
if fat_bits != 32:
boot.uchSignature = 0x29
else:
Expand Down
2 changes: 1 addition & 1 deletion FATtools/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.0.33'
__version__ = '1.0.34'

0 comments on commit 851a38b

Please sign in to comment.