From fd2c264aad0217a7999dbc41f25356133e2cab8d Mon Sep 17 00:00:00 2001 From: Christian Vogelgsang Date: Tue, 16 May 2023 20:38:28 +0200 Subject: [PATCH] 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. --- amitools/fs/block/rdb/PartitionBlock.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/amitools/fs/block/rdb/PartitionBlock.py b/amitools/fs/block/rdb/PartitionBlock.py index f142d2f..f4ce57b 100644 --- a/amitools/fs/block/rdb/PartitionBlock.py +++ b/amitools/fs/block/rdb/PartitionBlock.py @@ -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