disk: part_efi: Fix backup GPT header placement for large sector sizes #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The gpt_fill_header() function was incorrectly calculating the last_usable_lba value using a hardcoded assumption about the partition table entry (PTE) area size. This caused incorrect backup GPT placement on disks with non-512-byte sector sizes.
The GPT specification requires 128 partition entries × 128 bytes = 16384 bytes for the partition entry array. For 512-byte sectors this requires 32 sectors, but for 4096-byte sectors only 4 sectors are needed.
Introduce a local pte_sectors variable that dynamically calculates the number of sectors required for the partition entries based on the actual block size:
This ensures:
The fix is essential for:
Change-Id: faf3cb2e-056d-458d-8abe-61edf2f40384