Skip to content

Commit

Permalink
wip: correct partition CRC
Browse files Browse the repository at this point in the history
The partition name wasn't being padded to 72 bytes.
Now the alignments need fixing.
  • Loading branch information
swysocki committed Jan 16, 2022
1 parent 73a6973 commit 6809e4e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gpt_image/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ def __init__(
self.partition_guid.data = uuid.uuid4().bytes_le
else:
self.partition_guid.data = partition_guid.bytes_le
self.partition_name.data = bytes(name, encoding="utf_16_le")
b_name = bytes(name, encoding="utf_16_le")
# ensure the partition name is padded
self.partition_name.data = b_name + bytes(72 - len(b_name))

self.alignment = alignment
self.size = size
Expand Down Expand Up @@ -294,6 +296,7 @@ def _first_lba(self) -> bytes:
last_lba = last_lba_int
if last_lba == 0:
return (34).to_bytes(8, "little")
# @NOTE: this is NOT proper alignment
return (last_lba + 1).to_bytes(8, "little")

def _partition_entries_as_bytes(self):
Expand Down

0 comments on commit 6809e4e

Please sign in to comment.