image-hd: fix CHS addresses in EBR #249
Merged
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.
All CHS addresses in the EBR should point to absolute address in the image instead of the relative addresses, currently they are only LBA-to-CHS conversion of the relative offsets. If correct, output of
sfdisk -d
of the genimage-produced disk image piped back tosfdisk file.img
should produce binary identical (see note below) output. However, it is not true, because the CHS addresses differ. Even though the extended partition uses the 0xf type (LBA addressing) and CHS addressing is limited to 1023 sectors, the generated output should be comparable to other tools for easier debugging.With this change the calculation of CHS addresses of the next EBRs and logical partitions within the extended partition adds the proper offset, so the addresses are absolute within the image.
Note: At least with the version of sfdisk I have tested with (from util-linux 2.37.2), the image is not completely identical - there are one byte differences in the MBR and each MBR. This is because even if the partition type is set as 0xf, sfdisk produces the extended partition and all the logical partition with 0x5 type.