(self)
| 129 | # Fix up a few numbers to ensure consistency between the different |
| 130 | # components. |
| 131 | def fixup(self): |
| 132 | # Align the bootblock to a whole number to LBA blocks |
| 133 | bootblock_size = (len(self.bootblock) + BLOCK_SIZE - 1) & ~BLOCK_MASK |
| 134 | self.bootblock = self.bootblock.ljust(bootblock_size) |
| 135 | |
| 136 | # Propagate the number of partition entries |
| 137 | self.header.part_entries_number = len(self.partitions) |
| 138 | self.header.first_usable_lba = 2 + self.header.part_entries_number // 4 |
| 139 | |
| 140 | # Create a partition entry for the bootblock |
| 141 | self.partitions[0].type = GUID_TYPE_FSBL |
| 142 | self.partitions[0].uniq = DUMMY_GUID_PART_UNIQUE |
| 143 | self.partitions[0].first_lba = self.header.first_usable_lba |
| 144 | self.partitions[0].last_lba = \ |
| 145 | self.header.first_usable_lba + bootblock_size // BLOCK_SIZE |
| 146 | |
| 147 | # Calculate the CRC32 checksum of the partitions array |
| 148 | partition_array = io.BytesIO() |
| 149 | for part in self.partitions: |
| 150 | part.generate(partition_array) |
| 151 | self.header.part_entries_crc32 = zlib.crc32(partition_array.getvalue()) |
| 152 | |
| 153 | |
| 154 | def generate(self, stream): |
no test coverage detected