mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 02:05:01 +00:00
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>
This commit is contained in:
@@ -72,23 +72,35 @@ int AllocAndReadGptData(VbExDiskHandle_t disk_handle, GptData* gptdata) {
|
||||
* Returns 0 if successful, 1 if error. */
|
||||
int WriteAndFreeGptData(VbExDiskHandle_t disk_handle, GptData* gptdata) {
|
||||
|
||||
int legacy = 0;
|
||||
uint64_t entries_sectors = TOTAL_ENTRIES_SIZE / gptdata->sector_bytes;
|
||||
|
||||
if (gptdata->primary_header) {
|
||||
GptHeader* h = (GptHeader*)(gptdata->primary_header);
|
||||
legacy = !Memcmp(h->signature, GPT_HEADER_SIGNATURE2,
|
||||
GPT_HEADER_SIGNATURE_SIZE);
|
||||
if (gptdata->modified & GPT_MODIFIED_HEADER1) {
|
||||
VBDEBUG(("Updating GPT header 1\n"));
|
||||
if (0 != VbExDiskWrite(disk_handle, 1, 1, gptdata->primary_header))
|
||||
return 1;
|
||||
if (legacy) {
|
||||
VBDEBUG(("Not updating GPT header 1: legacy mode is enabled.\n"));
|
||||
} else {
|
||||
VBDEBUG(("Updating GPT header 1\n"));
|
||||
if (0 != VbExDiskWrite(disk_handle, 1, 1, gptdata->primary_header))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
VbExFree(gptdata->primary_header);
|
||||
}
|
||||
|
||||
if (gptdata->primary_entries) {
|
||||
if (gptdata->modified & GPT_MODIFIED_ENTRIES1) {
|
||||
VBDEBUG(("Updating GPT entries 1\n"));
|
||||
if (0 != VbExDiskWrite(disk_handle, 2, entries_sectors,
|
||||
gptdata->primary_entries))
|
||||
return 1;
|
||||
if (legacy) {
|
||||
VBDEBUG(("Not updating GPT entries 1: legacy mode is enabled.\n"));
|
||||
} else {
|
||||
VBDEBUG(("Updating GPT entries 1\n"));
|
||||
if (0 != VbExDiskWrite(disk_handle, 2, entries_sectors,
|
||||
gptdata->primary_entries))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
VbExFree(gptdata->primary_entries);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user