diff options
| author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2020-03-19 13:49:34 +0100 | 
|---|---|---|
| committer | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2020-04-30 10:25:07 +0200 | 
| commit | 25801acc1fd64b284d250e8cee7c5ea0c5186f1c (patch) | |
| tree | 11aa991de56aeb05cf0fea959c97ef6b70b1b7ed /disk/part_efi.c | |
| parent | 4fe050e65f61cc5e7734aee0637a18ac16b10061 (diff) | |
part: detect EFI system partition
Up to now for MBR and GPT partitions the info field 'bootable' was set to 1
if either the partition was an EFI system partition or the bootable flag
was set.
Turn info field 'bootable' into a bit mask with separate bits for bootable
and EFI system partition.
This will allow us to identify the EFI system partition in the UEFI
sub-system.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'disk/part_efi.c')
| -rw-r--r-- | disk/part_efi.c | 16 | 
1 files changed, 10 insertions, 6 deletions
| diff --git a/disk/part_efi.c b/disk/part_efi.c index b2e157d9c1e..83876a7bd97 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -71,11 +71,15 @@ static char *print_efiname(gpt_entry *pte)  static const efi_guid_t system_guid = PARTITION_SYSTEM_GUID; -static inline int is_bootable(gpt_entry *p) +static int get_bootable(gpt_entry *p)  { -	return p->attributes.fields.legacy_bios_bootable || -		!memcmp(&(p->partition_type_guid), &system_guid, -			sizeof(efi_guid_t)); +	int ret = 0; + +	if (!memcmp(&p->partition_type_guid, &system_guid, sizeof(efi_guid_t))) +		ret |=  PART_EFI_SYSTEM_PARTITION; +	if (p->attributes.fields.legacy_bios_bootable) +		ret |=  PART_BOOTABLE; +	return ret;  }  static int validate_gpt_header(gpt_header *gpt_h, lbaint_t lba, @@ -286,7 +290,7 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,  	snprintf((char *)info->name, sizeof(info->name), "%s",  		 print_efiname(&gpt_pte[part - 1]));  	strcpy((char *)info->type, "U-Boot"); -	info->bootable = is_bootable(&gpt_pte[part - 1]); +	info->bootable = get_bootable(&gpt_pte[part - 1]);  #if CONFIG_IS_ENABLED(PARTITION_UUIDS)  	uuid_bin_to_str(gpt_pte[part - 1].unique_partition_guid.b, info->uuid,  			UUID_STR_FORMAT_GUID); @@ -501,7 +505,7 @@ int gpt_fill_pte(struct blk_desc *dev_desc,  		memset(&gpt_e[i].attributes, 0,  		       sizeof(gpt_entry_attributes)); -		if (partitions[i].bootable) +		if (partitions[i].bootable & PART_BOOTABLE)  			gpt_e[i].attributes.fields.legacy_bios_bootable = 1;  		/* partition name */ | 
