Skip to content

Commit

Permalink
Bugs fixed in vhdutils and vdiutils
Browse files Browse the repository at this point in the history
- avoid infinite loop when searching for parent VDI
- VHD block bitmap is now flushed only when a "real" block is written to
- a virtual block in a Differencing VHD is now kept as such only if parent's block itself is virtual
  • Loading branch information
maxpat78 committed Oct 17, 2023
1 parent de1a611 commit 60bb258
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions FATtools/vdiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def __init__ (self, name, mode='rb'):
if self.header.dwImageType == 4: # Differencing VDI
parent=''
for vdi in glob.glob('./*.vdi'):
if vdi.lower() == name.lower(): continue
parent=vdi
o=Image(vdi, "rb")
if o.header.sUuidCreate == self.header.sUuidLinkage:
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.29'
__version__ = '1.0.30'
11 changes: 6 additions & 5 deletions FATtools/vhdutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,8 @@ def write1(self, s):
put=size
size=0
if block == 0xFFFFFFFF:
# we keep a block virtualized until we write zeros
if s[i:i+put] == self.zero[:put]:
# we can keep a block virtualized until PARENT'S IS VIRTUALIZED AND we write zeros
if self.Parent.bat[self._pos//self.block] == 0xFFFFFFFF and s[i:i+put] == self.zero[:put]:
i+=put
self._pos+=put
if DEBUG&16: log("block #%d @0x%X is zeroed, virtualizing write", self._pos//self.block, (block*self.block)+self.header.u64TableOffset)
Expand Down Expand Up @@ -632,9 +632,10 @@ def copysect(vpos, sec):
self.stream.write(s[i:i+put])
i+=put
self._pos+=put
if DEBUG&16: log("%s: flushing bitmap for block #%d at end", self.name, bmp.i)
self.stream.seek(bmp.i*512)
self.stream.write(bmp.bmp)
if bmp: # None if virtual writes only!
if DEBUG&16: log("%s: flushing bitmap for block #%d at end", self.name, bmp.i)
self.stream.seek(bmp.i*512)
self.stream.write(bmp.bmp)



Expand Down

0 comments on commit 60bb258

Please sign in to comment.