Re: [PATCH v1] part: efi: use BOOT_PART_TYPE symbol

Heinrich Schuchardt via U-Boot <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
On 7/30/26 03:39, Denis Mukhin via U-Boot wrote:
> From: Denis Mukhin <[email protected]>
> 
> Use existing BOOT_PART_TYPE symbol instead of open-coded "U-Boot".
> 
> Signed-off-by: Denis Mukhin <[email protected]>
> ---
>   disk/part_efi.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/disk/part_efi.c b/disk/part_efi.c
> index d8b17ec2e91a..1efd2ea113f0 100644
> --- a/disk/part_efi.c
> +++ b/disk/part_efi.c
> @@ -304,7 +304,7 @@ static int __maybe_unused part_get_info_efi(struct blk_desc *desc, int part,
>   
>   	snprintf((char *)info->name, sizeof(info->name), "%s",
>   		 print_efiname(&gpt_pte));
> -	strcpy((char *)info->type, "U-Boot");
> +	strcpy((char *)info->type, BOOT_PART_TYPE);

Thank you for looking into the value of this field which unfortunately 
is not well described in include/part.h. It is used in print_gpt_info() 
to print a user readable description of the partition type.

=> gpt read host 0
Partition 1:
Start 1MiB, size 62MiB
Block size 512, name Linux filesystem
Type U-Boot, bootable 0
UUID d3f19932-f3fb-408a-81dc-fadb4438ed5a
Type GUID c12a7328-f81f-11d2-ba4b-00a0c93ec93b

The constant BOOT_PART_TYPE is unrelated to the field type. It is used 
to define a linker generated list.

The value "U-Boot" itself looks wrong:

For a Mac partition we would expect values like "Apple_HFS", "Apple_Driver".

For an Amiga partition we would see for example "DOS\0", "PDS\0", 
"SFS\0", "LNX\0", "MAC\0", "MDS\0".

For a GPT partition we should have a string representing the partition 
type depending on the partition type GUID.

If CONFIG_PARTITION_TYPE_GUID=y and CONFIG_LIB_UUID=y, we can use 
uuid_guid_get_str() to get the correct value, how about:

diff --git a/disk/part_efi.c b/disk/part_efi.c
index d8b17ec2e91..1385bdae577 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -304,7 +304,7 @@ static int __maybe_unused part_get_info_efi(struct 
blk_desc *desc, int part,

         snprintf((char *)info->name, sizeof(info->name), "%s",
                  print_efiname(&gpt_pte));
-       strcpy((char *)info->type, "U-Boot");
+       strcpy((char *)info->type, "gpt");
         info->bootable = get_bootable(&gpt_pte);
         info->type_flags = gpt_pte.attributes.fields.type_guid_specific;
         if (CONFIG_IS_ENABLED(PARTITION_UUIDS)) {
@@ -316,6 +316,8 @@ static int __maybe_unused part_get_info_efi(struct 
blk_desc *desc, int part,
                 uuid_bin_to_str(gpt_pte.partition_type_guid.b,
                                 (char *)disk_partition_type_guid(info),
                                 UUID_STR_FORMAT_GUID);
+               snprintf((char *)info->type, sizeof(info->type), "%pUs",
+                        gpt_pte.partition_type_guid.b);
         }

         log_debug("start 0x" LBAF ", size 0x" LBAF ", name %s\n", 
info->start,

test/py/tests/test_gpt.py might need to be adjusted too.

Best regards

Heinrich

>   	info->bootable = get_bootable(&gpt_pte);
>   	info->type_flags = gpt_pte.attributes.fields.type_guid_specific;
>   	if (CONFIG_IS_ENABLED(PARTITION_UUIDS)) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.