[U-Boot] [PATCH] disk: part_efi: add support for the Alternate GPT

Przemyslaw Marczak p.marczak at samsung.com
Mon May 5 12:50:30 CEST 2014


Hello Steve,

On 04/30/2014 12:31 AM, Steve Rae wrote:
> Check the Alternate GPT table if the Primary GPT table is invalid.
>
> Signed-off-by: Steve Rae <srae at broadcom.com>
> ---
>
>   disk/part_efi.c | 20 ++++++++++++++++++--
>   1 file changed, 18 insertions(+), 2 deletions(-)
>
> diff --git a/disk/part_efi.c b/disk/part_efi.c
> index 216a292..ad899fa 100644
> --- a/disk/part_efi.c
> +++ b/disk/part_efi.c
> @@ -93,7 +93,15 @@ void print_part_efi(block_dev_desc_t * dev_desc)
>   	if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
>   			 gpt_head, &gpt_pte) != 1) {
>   		printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
> -		return;
> +		if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
> +				 gpt_head, &gpt_pte) != 1) {
> +			printf("%s: *** ERROR: Invalid Alternate GPT ***\n",
> +			       __func__);
> +			return;
> +		} else {
> +			printf("%s: ***        Using Alternate GPT ***\n",
> +			       __func__);
> +		}
>   	}
>
>   	debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
> @@ -142,7 +150,15 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
>   	if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
>   			gpt_head, &gpt_pte) != 1) {
>   		printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
> -		return -1;
> +		if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
> +				 gpt_head, &gpt_pte) != 1) {
> +			printf("%s: *** ERROR: Invalid Alternate GPT ***\n",
> +			       __func__);
> +			return -1;
> +		} else {
> +			printf("%s: ***        Using Alternate GPT ***\n",
> +			       __func__);
> +		}
>   	}
>
>   	if (part > le32_to_cpu(gpt_head->num_partition_entries) ||
>

This looks ok, we can still use u-boot filesystem commands after gpt 
header block corruption, but the gpt is still...corrupted.

Maybe we need additional gpt subcommand for restore gpt in case when 
backup of gpt header is valid?

Actually we have only "gpt write" command but it needs proper 
environment variables. So I think that "gpt restore" is welcome.

Thank you,
-- 
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com


More information about the U-Boot mailing list