Mercurial > illumos > git > illumos-gate
changeset 19388:75bd72db4d53
11974 loader: add support for hybrid PMBR for GPT partition table
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Approved by: Dan McDonald <danmcd@joyent.com>
author | Toomas Soome <tsoome@me.com> |
---|---|
date | Fri, 15 Nov 2019 21:18:31 +0200 |
parents | 34f16a04d10c |
children | 19051e96ceb7 |
files | usr/src/boot/Makefile.version usr/src/boot/sys/boot/common/part.c |
diffstat | 2 files changed, 10 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/boot/Makefile.version Sun Nov 25 23:34:48 2018 +0200 +++ b/usr/src/boot/Makefile.version Fri Nov 15 21:18:31 2019 +0200 @@ -33,4 +33,4 @@ # Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes. # The version is processed from left to right, the version number can only # be increased. -BOOT_VERSION = $(LOADER_VERSION)-2020.01.09.1 +BOOT_VERSION = $(LOADER_VERSION)-2020.01.15.1
--- a/usr/src/boot/sys/boot/common/part.c Sun Nov 25 23:34:48 2018 +0200 +++ b/usr/src/boot/sys/boot/common/part.c Fri Nov 15 21:18:31 2019 +0200 @@ -762,7 +762,7 @@ struct dos_partition *dp; struct ptable *table; uint8_t *buf; - int i, count; + int i; #ifdef LOADER_MBR_SUPPORT struct pentry *entry; uint32_t start, end; @@ -830,28 +830,23 @@ } /* Check that we have PMBR. Also do some validation. */ dp = (struct dos_partition *)(buf + DOSPARTOFF); - for (i = 0, count = 0; i < NDOSPART; i++) { + /* + * macOS can create PMBR partition in a hybrid MBR; that is, an MBR + * partition which has a DOSTYP_PMBR entry defined to start at sector 1. + * After the DOSTYP_PMBR, there may be other paritions. A UEFI + * compliant PMBR has no other partitions. + */ + for (i = 0; i < NDOSPART; i++) { if (dp[i].dp_flag != 0 && dp[i].dp_flag != 0x80) { DPRINTF("invalid partition flag %x", dp[i].dp_flag); goto out; } #ifdef LOADER_GPT_SUPPORT - if (dp[i].dp_typ == DOSPTYP_PMBR) { + if (dp[i].dp_typ == DOSPTYP_PMBR && dp[i].dp_start == 1) { table->type = PTABLE_GPT; DPRINTF("PMBR detected"); } #endif - if (dp[i].dp_typ != 0) - count++; - } - /* Do we have some invalid values? */ - if (table->type == PTABLE_GPT && count > 1) { - if (dp[1].dp_typ != DOSPTYP_HFS) { - table->type = PTABLE_NONE; - DPRINTF("Incorrect PMBR, ignore it"); - } else { - DPRINTF("Bootcamp detected"); - } } #ifdef LOADER_GPT_SUPPORT if (table->type == PTABLE_GPT) {