rdbtool: only increase DosEnv size in PartitionBlock if needed

This reverts the current 0.7.0 behaviour of using always the
larger size for the DosEnv as it breaks poorly written drivers.
The DosEnv is only increased from default size of 16 to 19 if
one of the new fields is set.
This commit is contained in:
Christian Vogelgsang 2023-05-16 20:38:28 +02:00
parent bee62305e0
commit fd2c264aad

View File

@ -14,9 +14,14 @@ class PartitionDosEnv:
"boot_blocks",
)
# size of full dos env (with baud, control, boot_blocks)
SIZE_FULL_ENV = 19
# size of default dos env (without baud, control, boot_blocks)
SIZE_DEFAULT_ENV = 16
def __init__(
self,
size=19,
size=0,
block_size=128,
sec_org=0,
surfaces=0,
@ -58,6 +63,13 @@ class PartitionDosEnv:
self.control = control
self.boot_blocks = boot_blocks
def update_size(self):
# do we need the extended size?
if self.boot_blocks != 0 or self.control != 0 or self.baud != 0:
self.size = self.SIZE_FULL_ENV
else:
self.size = self.SIZE_DEFAULT_ENV
def dump(self):
print("DosEnv")
print(" size: %d" % self.size)
@ -107,6 +119,7 @@ class PartitionDosEnv:
self.boot_blocks = blk._get_long(51)
def write(self, blk):
assert self.size != 0
blk._put_long(32, self.size)
blk._put_long(33, self.block_size)
blk._put_long(34, self.sec_org)
@ -158,6 +171,7 @@ class PartitionBlock(Block):
if dos_env == None:
dos_env = PartitionDosEnv()
dos_env.update_size()
self.dos_env = dos_env
self.valid = True