From f2be51489e45daeb2c91d227fa1691c74cc3ea97 Mon Sep 17 00:00:00 2001 From: szhou Date: Thu, 5 Oct 2006 11:31:43 -0700 Subject: PSARC 2006/340 Solaris Boot Support for EFI and LinuxBIOS 6434157 libefi sometimes gets the wrong gpt partition location 6475349 Boot Support for EFI and LinuxBIOS --- usr/src/lib/libefi/common/rdwr_efi.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'usr/src/lib') diff --git a/usr/src/lib/libefi/common/rdwr_efi.c b/usr/src/lib/libefi/common/rdwr_efi.c index 0ca4445b71..d366be1448 100644 --- a/usr/src/lib/libefi/common/rdwr_efi.c +++ b/usr/src/lib/libefi/common/rdwr_efi.c @@ -66,7 +66,9 @@ static struct uuid_to_ptag { { EFI_DELL_RAID }, { EFI_DELL_SWAP }, { EFI_DELL_LVM }, - { EFI_DELL_RESV } + { EFI_DELL_RESV }, + { EFI_AAPL_HFS }, + { EFI_AAPL_UFS } }; /* @@ -437,9 +439,9 @@ efi_read(int fd, struct dk_gpt *vtoc) return (rval); } - /* partitions start in the next block */ /* LINTED -- always longlong aligned */ - efi_parts = (efi_gpe_t *)(((char *)efi) + disk_info.dki_lbsize); + efi_parts = (efi_gpe_t *)(((char *)efi) + + LE_64(efi->efi_gpt_PartitionEntryLBA) * disk_info.dki_lbsize); /* * Assemble this into a "dk_gpt" struct for easier @@ -583,7 +585,10 @@ check_input(struct dk_gpt *vtoc) return (VT_EINVAL); } if (vtoc->efi_parts[i].p_tag == V_UNASSIGNED) { - continue; + if (uuid_is_null((uchar_t *)&vtoc->efi_parts[i].p_guid)) + continue; + /* we have encountered an unknown uuid */ + vtoc->efi_parts[i].p_tag = 0xff; } if (vtoc->efi_parts[i].p_tag == V_RESERVED) { if (resv_part != -1) { @@ -739,8 +744,21 @@ efi_write(int fd, struct dk_gpt *vtoc) UUID_LE_CONVERT( efi_parts[i].efi_gpe_PartitionTypeGUID, conversion_array[j].uuid); + break; } } + + if (j == sizeof (conversion_array) / sizeof (struct uuid_to_ptag)) { + /* + * If we didn't have a matching uuid match, bail here. + * Don't write a label with unknown uuid. + */ + if (efi_debug) + (void) fprintf(stderr, "Unknown uuid for p_tag %d\n", + vtoc->efi_parts[i].p_tag); + return (VT_EINVAL); + } + efi_parts[i].efi_gpe_StartingLBA = LE_64(vtoc->efi_parts[i].p_start); efi_parts[i].efi_gpe_EndingLBA = -- cgit v1.2.3