diff options
author | Stefan Reinauer <reinauer@chromium.org> | 2012-08-23 15:06:25 -0700 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-09-19 15:33:30 -0700 |
commit | b7b865cfee68190babd971ab9a897bdabbab075f (patch) | |
tree | 8ad900ddff6a69f9a65cd0507857a6da2677592f /cgpt/cgpt_common.c | |
parent | 40d8651bb36048c9b5f07be97ff17b2cf503015e (diff) | |
download | vboot-b7b865cfee68190babd971ab9a897bdabbab075f.tar.gz |
Support alternative GPT header signature
In order to dual boot Windows and ChromeOS, Windows must
not find a GPT partition table on the disk. So change
ChromeOS to cope with an alternative signature "CHROMEOS"
instead of the standard "EFI PART"
BUG=chrome-os-partner:6108
TEST=rebuild chromeos, install it,
run cgpt legacy /dev/sda
dd if=/dev/sda of=/tmp/x bs=1k
hexdump -C /tmp/X
see the string CHROMEOS
BRANCH=link
Signed-off-by: Stefan Reinauer <reinauer@chromium.org>
Change-Id: Ia88eff33b9880bd73a78c1b8e026c1f8298c4557
Reviewed-on: https://gerrit.chromium.org/gerrit/31264
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Stefan Reinauer <reinauer@chromium.org>
Tested-by: Stefan Reinauer <reinauer@chromium.org>
Diffstat (limited to 'cgpt/cgpt_common.c')
-rw-r--r-- | cgpt/cgpt_common.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c index d69eb670..193f2e1e 100644 --- a/cgpt/cgpt_common.c +++ b/cgpt/cgpt_common.c @@ -733,7 +733,9 @@ void UpdateCrc(GptData *gpt) { primary_header = (GptHeader*)gpt->primary_header; secondary_header = (GptHeader*)gpt->secondary_header; - if (gpt->modified & GPT_MODIFIED_ENTRIES1) { + if (gpt->modified & GPT_MODIFIED_ENTRIES1 && + memcmp(primary_header, GPT_HEADER_SIGNATURE2, + GPT_HEADER_SIGNATURE_SIZE)) { primary_header->entries_crc32 = Crc32(gpt->primary_entries, TOTAL_ENTRIES_SIZE); } @@ -785,6 +787,14 @@ int IsSynonymous(const GptHeader* a, const GptHeader* b) { * Note that CRC is NOT re-computed in this function. */ uint8_t RepairEntries(GptData *gpt, const uint32_t valid_entries) { + /* If we have an alternate GPT header signature, don't overwrite + * the secondary GPT with the primary one as that might wipe the + * partition table. Also don't overwrite the primary one with the + * secondary one as that will stop Windows from booting. */ + GptHeader* h = (GptHeader*)(gpt->primary_header); + if (!memcmp(h->signature, GPT_HEADER_SIGNATURE2, GPT_HEADER_SIGNATURE_SIZE)) + return 0; + if (valid_entries == MASK_BOTH) { if (memcmp(gpt->primary_entries, gpt->secondary_entries, TOTAL_ENTRIES_SIZE)) { |