flashjazzcat napisał/a:Found the bug. An extra (non-existent) entry from the table of LBA partition table sector numbers was being grabbed from the array when the last partition was at the end of a sector of the APT chain. Since the bug resulted in MBR corruption, it seemed a good idea to add debugging code which triggered a breakpoint if any attempt was made to write sector 0 when laying out the APT. The breakpoint was immediately triggered with 78 partitions...
Please try the version attached and let me know if it passes Pin's most extreme stress-tests. :)
17 partitions created
Reading MBR from example_disk.img starting at sector 0 (0) [0]
parent: 0 partition data: 446-462, type: FAT32, LBA
parent: 0 partition data: 462-478, type: APT, Atari Partition Table
Reading 512 bytes from sector 0x40003F (4194367) [0x80007e00 (2147515904)]
Found APT partition at sector 0x40003F (4194367)
Reading 512 bytes from sector 0x400690 (4195984) [0x800d2000 (2148343808)]
Found APT partition at sector 0x400690 (4195984)
55AA
b'APT' 0 32 0x400690 0x0
mapping_slots:
{}
partitions:
{0: 67, 0, 0x400041 ( 4194369 bytes), 0x64 ( 100 bytes), 0, 64
, 1: 67, 0, 0x4000a6 ( 4194470 bytes), 0x64 ( 100 bytes), 0, 64
, 2: 67, 0, 0x40010b ( 4194571 bytes), 0x64 ( 100 bytes), 0, 64
, 3: 67, 0, 0x400170 ( 4194672 bytes), 0x64 ( 100 bytes), 0, 64
, 4: 67, 0, 0x4001d5 ( 4194773 bytes), 0x64 ( 100 bytes), 0, 64
, 5: 67, 0, 0x40023a ( 4194874 bytes), 0x64 ( 100 bytes), 0, 64
, 6: 67, 0, 0x40029f ( 4194975 bytes), 0x64 ( 100 bytes), 0, 64
, 7: 67, 0, 0x400304 ( 4195076 bytes), 0x64 ( 100 bytes), 0, 64
, 8: 67, 0, 0x400369 ( 4195177 bytes), 0x64 ( 100 bytes), 0, 64
, 9: 67, 0, 0x4003ce ( 4195278 bytes), 0x64 ( 100 bytes), 0, 64
, 10: 67, 0, 0x400433 ( 4195379 bytes), 0x64 ( 100 bytes), 0, 64
, 11: 67, 0, 0x400498 ( 4195480 bytes), 0x64 ( 100 bytes), 0, 64
, 12: 67, 0, 0x4004fd ( 4195581 bytes), 0x64 ( 100 bytes), 0, 64
, 13: 67, 0, 0x400562 ( 4195682 bytes), 0x64 ( 100 bytes), 0, 64
, 14: 67, 0, 0x4005c7 ( 4195783 bytes), 0x64 ( 100 bytes), 0, 64
, 15: 67, 0, 0x40062c ( 4195884 bytes), 0x64 ( 100 bytes), 0, 64
}
b'APT' 0 2 0x0 0x40003f
mapping_slots:
{}
partitions:
{1: 67, 0, 0x400692 ( 4195986 bytes), 0x64 ( 100 bytes), 0, 64
}
one deleted and looks good
Reading MBR from example_disk.img starting at sector 0 (0) [0]
parent: 0 partition data: 446-462, type: FAT32, LBA
parent: 0 partition data: 462-478, type: APT, Atari Partition Table
Reading 512 bytes from sector 0x40003F (4194367) [0x80007e00 (2147515904)]
Found APT partition at sector 0x40003F (4194367)
55AA
b'APT' 0 32 0x0 0x0
mapping_slots:
{}
partitions:
{0: 67, 0, 0x400041 ( 4194369 bytes), 0x64 ( 100 bytes), 0, 64
, 1: 67, 0, 0x4000a6 ( 4194470 bytes), 0x64 ( 100 bytes), 0, 64
, 2: 67, 0, 0x40010b ( 4194571 bytes), 0x64 ( 100 bytes), 0, 64
, 3: 67, 0, 0x400170 ( 4194672 bytes), 0x64 ( 100 bytes), 0, 64
, 4: 67, 0, 0x4001d5 ( 4194773 bytes), 0x64 ( 100 bytes), 0, 64
, 5: 67, 0, 0x40023a ( 4194874 bytes), 0x64 ( 100 bytes), 0, 64
, 6: 67, 0, 0x40029f ( 4194975 bytes), 0x64 ( 100 bytes), 0, 64
, 7: 67, 0, 0x400304 ( 4195076 bytes), 0x64 ( 100 bytes), 0, 64
, 8: 67, 0, 0x400369 ( 4195177 bytes), 0x64 ( 100 bytes), 0, 64
, 9: 67, 0, 0x4003ce ( 4195278 bytes), 0x64 ( 100 bytes), 0, 64
, 10: 67, 0, 0x400433 ( 4195379 bytes), 0x64 ( 100 bytes), 0, 64
, 11: 67, 0, 0x400498 ( 4195480 bytes), 0x64 ( 100 bytes), 0, 64
, 12: 67, 0, 0x4004fd ( 4195581 bytes), 0x64 ( 100 bytes), 0, 64
, 13: 67, 0, 0x400562 ( 4195682 bytes), 0x64 ( 100 bytes), 0, 64
, 14: 67, 0, 0x4005c7 ( 4195783 bytes), 0x64 ( 100 bytes), 0, 64
, 15: 67, 0, 0x40062c ( 4195884 bytes), 0x64 ( 100 bytes), 0, 64
}