summaryrefslogtreecommitdiff
path: root/cgpt/cmd_show.c
diff options
context:
space:
mode:
authorBill Richardson <wfrichar@chromium.org>2010-06-15 21:07:18 -0700
committerBill Richardson <wfrichar@chromium.org>2010-06-15 21:07:18 -0700
commit962483c1e27627aad843a2c394f11b830dd1ce02 (patch)
tree1618da525389f46b646ceeb40237ac1ce8c6f0ba /cgpt/cmd_show.c
parentc5e5f4ef559418c1aa7a00bc12bd1a8523d95d95 (diff)
downloadvboot-962483c1e27627aad843a2c394f11b830dd1ce02.tar.gz
This fixes the EFI BIOS boot problems introduced with cgpt.
There were two changes. First, we need to pack the GPT header to make it match the spec (duh). Second, there's a subtle bug in how the BIOS recovers from corrupted headers. The EFI spec says that the primary GPT header must be at sector 1 (counting from zero) and the secondary GPT header must be at the last sector on the drive. The BIOS correctly looks in those locations to find the headers. However, if the secondary GPT header is invalid (as it usually is due to our build process), the BIOS is supposed to update it from the primary header. In this case, rather than write to the last sector on the drive where it just looked, the BIOS trusts the alternate_lba field of the primary header. That field is supposed to point to the secondary header location, but the BIOS just blindly uses it no matter where it points. The cgpt tool wasn't initializing that field, so it pointed to sector 0, which is the PMBR. The BIOS overwrote that, resulting in an unbootable drive. Review URL: http://codereview.chromium.org/2844006
Diffstat (limited to 'cgpt/cmd_show.c')
-rw-r--r--cgpt/cmd_show.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/cgpt/cmd_show.c b/cgpt/cmd_show.c
index 9f52cb1d..91461490 100644
--- a/cgpt/cmd_show.c
+++ b/cgpt/cmd_show.c
@@ -95,6 +95,7 @@ static void HeaderDetails(GptHeader *header, const char *indent, int raw) {
printf("%sSize: %d\n", indent, header->size);
printf("%sHeader CRC: 0x%08x\n", indent, header->header_crc32);
printf("%sMy LBA: %lld\n", indent, (long long)header->my_lba);
+ printf("%sAlternate LBA: %lld\n", indent, (long long)header->alternate_lba);
printf("%sFirst LBA: %lld\n", indent, (long long)header->first_usable_lba);
printf("%sLast LBA: %lld\n", indent, (long long)header->last_usable_lba);