Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image-hd: do not use first partition offset for GPT's first usable LBA #270

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions image-hd.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ static int hdimage_insert_gpt(struct image *image, struct list_head *partitions)
const char *outfile = imageoutfile(image);
struct gpt_header header;
struct gpt_partition_entry table[GPT_ENTRIES];
unsigned long long smallest_offset = ~0ULL;
struct partition *part;
unsigned i, j;
int ret;
Expand All @@ -475,7 +474,7 @@ static int hdimage_insert_gpt(struct image *image, struct list_head *partitions)
header.header_size = htole32(sizeof(struct gpt_header));
header.current_lba = htole64(1);
header.backup_lba = htole64(hd->gpt_no_backup ? 1 :image->size/512 - 1);
header.first_usable_lba = htole64(~0ULL);
header.first_usable_lba = htole64(hd->gpt_location / 512 + GPT_SECTORS - 1);
header.last_usable_lba = htole64(image->size/512 - 1 - GPT_SECTORS);
uuid_parse(hd->disk_uuid, header.disk_uuid);
header.starting_lba = htole64(hd->gpt_location/512);
Expand All @@ -488,9 +487,6 @@ static int hdimage_insert_gpt(struct image *image, struct list_head *partitions)
if (!part->in_partition_table)
continue;

if (part->offset < smallest_offset)
smallest_offset = part->offset;

uuid_parse(part->partition_type_uuid, table[i].type_uuid);
uuid_parse(part->partition_uuid, table[i].uuid);
table[i].first_lba = htole64(part->offset/512);
Expand All @@ -505,10 +501,6 @@ static int hdimage_insert_gpt(struct image *image, struct list_head *partitions)

i++;
}
if (smallest_offset == ~0ULL)
smallest_offset = hd->gpt_location + (GPT_SECTORS - 1)*512;
header.first_usable_lba = htole64(smallest_offset / 512);


header.table_crc = htole32(crc32(table, sizeof(table)));

Expand Down
Loading