Skip to content

Commit fd711f3

Browse files
committed
Bugs fixed
- log message in vhdutils referred to non-existant dwBlockOffset - headers computation fixed in fat12_mkfs and fat16_mkfs - tries to account floppies while computating drive headers
1 parent a49f9e5 commit fd711f3

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ $RECYCLE.BIN/
2222
# Operating System Files
2323
# =========================
2424
BUGS.TXT
25+
26+
# PyPI related
27+
FATtools.egg-info/
28+
dist/

FATtools/mkfat.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ def fat12_mkfs(stream, size, sector=512, params={}):
118118
boot.chPhysDriveNumber = 0
119119
boot.uchSignature = 0x29
120120
boot.wBootSignature = 0xAA55
121-
boot.wSectorsPerTrack = 18
122-
boot.wHeads = 2
121+
boot.wSectorsPerTrack = 18 # CAVE! This is true with floppies, not little HDDs (20MB, 120MB etc.)
122+
#~ boot.wHeads = 2
123+
boot.wHeads = partutils.size2chs(size,1)[1] # not used with LBA
123124

124125
boot.pack()
125126
#~ print boot
@@ -277,7 +278,7 @@ def fat16_mkfs(stream, size, sector=512, params={}):
277278
boot.uchSignature = 0x29
278279
boot.wBootSignature = 0xAA55
279280
boot.wSectorsPerTrack = 63 # not used w/o disk geometry!
280-
boot.wHeads = partutils.size2chs(size)[1] # not used with LBA
281+
boot.wHeads = partutils.size2chs(size,1)[1] # not used with LBA
281282

282283
boot.pack()
283284
#~ print boot

FATtools/partutils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def lba2chs(lba, hpc=0):
5959

6060
def size2chs(n, getgeometry=0):
6161
lba = n//512
62-
for hpc in (16,32,64,128,255):
62+
for hpc in (2,16,32,64,128,255): # 2 is typical for 720K DS/DD and 1.44M DS/HD floppies
6363
c,h,s = lba2chs(lba,hpc)
6464
if c < 1024: break
6565
if DEBUG&1: log("size2chs: calculated Heads Per Cylinder: %d", hpc)

FATtools/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.0.10'
1+
__version__ = '1.0.11'

FATtools/vhdutils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def write(self, s):
540540
if s[i:i+put] == self.zero[:put]:
541541
i+=put
542542
self._pos+=put
543-
if DEBUG&16: log("block #%d @0x%X is zeroed, virtualizing write", self._pos//self.block, (block*self.block)+self.header.dwBlocksOffset)
543+
if DEBUG&16: log("block #%d @0x%X is zeroed, virtualizing write", self._pos//self.block, (block*self.block)+self.header.u64DataOffset)
544544
continue
545545
# allocates a new block at end before writing
546546
self.stream.seek(-512, 2) # overwrites old footer

0 commit comments

Comments
 (0)