image-hd: populate hd file size right after creating GPT header#324
Open
showier-drastic wants to merge 1 commit intopengutronix:masterfrom
Open
image-hd: populate hd file size right after creating GPT header#324showier-drastic wants to merge 1 commit intopengutronix:masterfrom
showier-drastic wants to merge 1 commit intopengutronix:masterfrom
Conversation
When gpt-no-backup = true and no partition has an image file, hd->file_size was never set from its initial value of 0. This makes it impossible to create an image with only GPT header. Fix: Initialize hd->file_size to now (= partition_end(gpt_array) = 17408) right after the primary GPT structures are set up. This ensures the file will always be at least large enough to hold the primary GPT header and partition array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 current code cannot handle config file like this (this is when I only want to create a GPT partition table without any content):
Error log:
ERROR: hdimage(partition.img): unexpected output file size: 0 != 17408Reason: When gpt-no-backup = true and no partition has an image file, hd->file_size was never set from its initial value of 0. This makes it impossible to create an image with only GPT header.
Fix: Initialize hd->file_size to now (= partition_end(gpt_array) = 17408) right after the primary GPT structures are set up. This ensures the file will always be at least large enough to hold the primary GPT header and partition array.