Merge patch series "Restore support of short name for type UUID parameter"

Patrick Delaunay <patrick.delaunay@foss.st.com> says:

Fix and add documentation/tests for selection by string for known
partition type GUID introduced by bcb41dcaef ("uuid: add
selection by string for known partition type GUID"):

- split list_guid for short name (used also for partiton
  description with type parameter) and full name to display
  information

- as the function are uuid_str_to_bin() / uuid_guid_get_str()
  are no more under CONFIG_PARTITION_TYPE_GUID,  since commit
  31ce367cd1 ("lib/uuid.c: change prototype of uuid_guid_get_str()")
  and commit c1528f324c ("lib: compile uuid_guid_get_str if
  CONFIG_LIB_UUID=y") move the content of array under EFI_PARTITION
  and linker will remove it is not used it (in SPL)

- Add and fix documentation for gpt command

- Add test test_gpt_write_part_type to test "type=" parameters

This first patch solves an issue for the "system" shortcut for ESP,
removed by commit d54V3 version solve issue for "ESP" support when
CONFIG_CMD_EFIDEBUG and CONFIG_EFI is not activated
for example for test with qemu-arm-sbsa defconfige1004b8b1 ("lib/uuid.c: use unique name
for PARTITION_SYSTEM_GUID") but used in 2 location (at least):

1- board/samsung/e850-96/e850-96.env:10:

partitions=name=esp,start=512K,size=128M,bootable,type=system;
partitions+=name=rootfs,size=-,bootable,type=linux

2- arch/arm/mach-stm32mp/cmd_stm32prog/stm32prog.c:1151

			case PART_ESP:
				/* EFI System Partition */
			459219	type_str = "system"
....
			offset += snprintf(buf + offset,
					   buflen - offset,
					   ",type=%s", type_str);

CI: https://source.denx.de/u-boot/custodians/u-boot-stm/-/pipelines/26699

Link: https://lore.kernel.org/r/20250616112749.17311-1-patrick.delaunay@foss.st.com
This commit is contained in:
Tom Rini
2025-06-17 17:21:42 -06:00
4 changed files with 201 additions and 84 deletions

View File

@@ -54,7 +54,7 @@ partition string
* name=<NAME> - The partition name, required * name=<NAME> - The partition name, required
* start=<BYTES> - The partition start offset in bytes, required * start=<BYTES> - The partition start offset in bytes, required
* size=<BYTES> - The partition size in bytes or "-" to expand it to the whole free area * size=<BYTES> - The partition size in bytes or "-" for the last partition to expand it to the whole free area
* bootable - Set the legacy bootable flag * bootable - Set the legacy bootable flag
* uuid=<UUID> - The partition UUID, optional if CONFIG_RANDOM_UUID=y is enabled * uuid=<UUID> - The partition UUID, optional if CONFIG_RANDOM_UUID=y is enabled
* type=<UUID> - The partition type GUID, requires CONFIG_PARTITION_TYPE_GUID=y * type=<UUID> - The partition type GUID, requires CONFIG_PARTITION_TYPE_GUID=y
@@ -63,6 +63,23 @@ partition string
If 'uuid' is not specified, but CONFIG_RANDOM_UUID is enabled, a random UUID If 'uuid' is not specified, but CONFIG_RANDOM_UUID is enabled, a random UUID
will be generated for the partition will be generated for the partition
If 'type' is not specified or without CONFIG_PARTITION_TYPE_GUID=y,
the used partition type GUID is PARTITION_BASIC_DATA_GUID.
Some strings can be also used at the place of the known partition type GUID:
* "mbr" = LEGACY_MBR_PARTITION_GUID (024DEE41-33E7-11D3-9D69-0008C781F39F)
* "msft" = PARTITION_MSFT_RESERVED_GUID (E3C9E316-0B5C-4DB8-817D-F92DF00215AE)
* "data" = PARTITION_BASIC_DATA_GUID (EBD0A0A2-B9E5-4433-87C0-68B6B72699C7)
* "linux" = PARTITION_LINUX_FILE_SYSTEM_DATA_GUID (0FC63DAF-8483-4772-8E79-3D69D8477DE4)
* "raid" = PARTITION_LINUX_RAID_GUID (A19D880F-05FC-4D3B-A006-743F0F84911E)
* "swap" = PARTITION_LINUX_SWAP_GUID (0657FD6D-A4AB-43C4-84E5-0933C84B4F4F)
* "lvm" = PARTITION_LINUX_LVM_GUID (E6D6D379-F507-44C2-A23C-238F2A3DF928)
* "u-boot-env" = PARTITION_U_BOOT_ENVIRONMENT(3DE21764-95BD-54BD-A5C3-4ABE786F38A8)
* "system" = PARTITION_SYSTEM_GUID (C12A7328-F81F-11D2-BA4B-00A0C93EC93B)
The GPT partitions layout and associated 'type' are also printed with the
:doc:`part command <part>` command by typing "part list".
gpt enumerate gpt enumerate
~~~~~~~~~~~~~ ~~~~~~~~~~~~~
@@ -162,16 +179,17 @@ Examples
Create 6 partitions on a disk:: Create 6 partitions on a disk::
=> setenv gpt_parts 'uuid_disk=bec9fc2a-86c1-483d-8a0e-0109732277d7; => setenv gpt_parts 'uuid_disk=bec9fc2a-86c1-483d-8a0e-0109732277d7;\
name=boot,start=4M,size=128M,bootable,type=ebd0a0a2-b9e5-4433-87c0-68b6b72699c7, name=boot,start=4M,size=128M,bootable,type=ebd0a0a2-b9e5-4433-87c0-68b6b72699c7;\
name=rootfs,size=3072M,type=0fc63daf-8483-4772-8e79-3d69d8477de4; name=rootfs,size=3072M,type=0fc63daf-8483-4772-8e79-3d69d8477de4;\
name=system-data,size=512M,type=0fc63daf-8483-4772-8e79-3d69d8477de4; name=system-data,size=512M,type=0fc63daf-8483-4772-8e79-3d69d8477de4;\
name=[ext],size=-,type=0fc63daf-8483-4772-8e79-3d69d8477de4; name=user,size=512M,type=0fc63daf-8483-4772-8e79-3d69d8477de4;\
name=user,size=-,type=0fc63daf-8483-4772-8e79-3d69d8477de4; name=modules,size=100M,type=0fc63daf-8483-4772-8e79-3d69d8477de4;\
name=modules,size=100M,type=0fc63daf-8483-4772-8e79-3d69d8477de4; name=ramdisk,size=8M,type=0fc63daf-8483-4772-8e79-3d69d8477de4;\
name=ramdisk,size=8M,type=0fc63daf-8483-4772-8e79-3d69d8477de4 name=[ext],size=-,type=0fc63daf-8483-4772-8e79-3d69d8477de4'
=> gpt write mmc 0 $gpt_parts => gpt write mmc 0 $gpt_parts
Last partition "[ext]" with '-' is extended up to the end of the disk
Verify that the device matches the partition layout described in the variable Verify that the device matches the partition layout described in the variable
$gpt_parts:: $gpt_parts::
@@ -228,3 +246,60 @@ Swap the order of the 'boot' and 'rootfs' partition table entries::
=> gpt setenv mmc 0 boot => gpt setenv mmc 0 boot
=> echo ${gpt_partition_entry} => echo ${gpt_partition_entry}
2 2
Other example: a disk with known partition types::
=> setenv gpt_parts 'name=u-boot,size=32M,type=data;\
name=env,size=1M,type=u-boot-env;
name=ESP,size=128M,type=system;
name=rootfs,size=3072M,type=linux;
name=swap,size=100M,type=swap;
name=user,size=-,type=linux'
=> gpt write mmc 0 $gpt_parts
=> part list mmc 0
Partition Map for mmc device 0 -- Partition Type: EFI
Part Start LBA End LBA Name
Attributes
Type GUID
Partition GUID
1 0x00000022 0x00010021 "u-boot"
attrs: 0x0000000000000000
type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
(data)
guid: 502d48f6-81c0-488f-bdc0-ad602498f3ce
2 0x00010022 0x00010821 "env"
attrs: 0x0000000000000000
type: 3de21764-95bd-54bd-a5c3-4abe786f38a8
(u-boot-env)
guid: 9dc62338-459a-485e-bd8f-b3fbf728d9c0
3 0x00010822 0x00050821 "ESP"
attrs: 0x0000000000000000
type: c12a7328-f81f-11d2-ba4b-00a0c93ec93b
(EFI System Partition)
guid: 8a3a1168-6af8-4ba7-a95d-9cd0d14e1b3d
4 0x00050822 0x00650821 "rootfs"
attrs: 0x0000000000000000
type: 0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid: 411ffebc-8a19-469d-99a9-0982409a6851
5 0x00650822 0x00682821 "swap"
attrs: 0x0000000000000000
type: 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f
(swap)
guid: f8ec0410-95ec-4e3e-8b98-fb8cf271a201
6 0x00682822 0x01dacbde "user"
attrs: 0x0000000000000000
type: 0fc63daf-8483-4772-8e79-3d69d8477de4
(linux)
guid: c5543e1c-566d-4502-99ad-20545007e673
Modifying GPT partition layout from U-Boot::
=> gpt read mmc 0 current_partitions
=> env edit current_partitions
edit: uuid_disk=[...];name=part1,start=0x4000,size=0x4000,uuid=[...];
name=part2,start=0xc000,size=0xc000,uuid=[...];[ . . . ]
=> gpt write mmc 0 $current_partitions
=> gpt verify mmc 0 $current_partitions

View File

@@ -62,184 +62,197 @@ int uuid_str_valid(const char *uuid)
return 1; return 1;
} }
/*
* Array of string (short and long) for known GUID of GPT partition type
* at least one string must be present, @type or @description
*
* @type : short name for the parameter 'type' of gpt command (max size UUID_STR_LEN = 36,
* no space), also used as fallback description when the next field is absent
* @description : long description associated to type GUID, used for %pUs
* @guid : known type GUID value
*/
static const struct { static const struct {
const char *string; const char *type;
const char *description;
efi_guid_t guid; efi_guid_t guid;
} list_guid[] = { } list_guid[] = {
#ifndef USE_HOSTCC #ifndef USE_HOSTCC
#if defined(CONFIG_PARTITION_TYPE_GUID) || defined(CONFIG_CMD_EFIDEBUG) || \ #if CONFIG_IS_ENABLED(EFI_PARTITION)
defined(CONFIG_EFI) {"mbr", NULL, LEGACY_MBR_PARTITION_GUID},
{"EFI System Partition", PARTITION_SYSTEM_GUID}, {"msft", NULL, PARTITION_MSFT_RESERVED_GUID},
#endif {"data", NULL, PARTITION_BASIC_DATA_GUID},
#ifdef CONFIG_PARTITION_TYPE_GUID {"linux", NULL, PARTITION_LINUX_FILE_SYSTEM_DATA_GUID},
{"mbr", LEGACY_MBR_PARTITION_GUID}, {"raid", NULL, PARTITION_LINUX_RAID_GUID},
{"msft", PARTITION_MSFT_RESERVED_GUID}, {"swap", NULL, PARTITION_LINUX_SWAP_GUID},
{"data", PARTITION_BASIC_DATA_GUID}, {"lvm", NULL, PARTITION_LINUX_LVM_GUID},
{"linux", PARTITION_LINUX_FILE_SYSTEM_DATA_GUID}, {"u-boot-env", NULL, PARTITION_U_BOOT_ENVIRONMENT},
{"raid", PARTITION_LINUX_RAID_GUID}, {"cros-kern", NULL, PARTITION_CROS_KERNEL},
{"swap", PARTITION_LINUX_SWAP_GUID}, {"cros-root", NULL, PARTITION_CROS_ROOT},
{"lvm", PARTITION_LINUX_LVM_GUID}, {"cros-fw", NULL, PARTITION_CROS_FIRMWARE},
{"u-boot-env", PARTITION_U_BOOT_ENVIRONMENT}, {"cros-rsrv", NULL, PARTITION_CROS_RESERVED},
{"cros-kern", PARTITION_CROS_KERNEL}, {
{"cros-root", PARTITION_CROS_ROOT}, "system", "EFI System Partition",
{"cros-fw", PARTITION_CROS_FIRMWARE}, PARTITION_SYSTEM_GUID,
{"cros-rsrv", PARTITION_CROS_RESERVED}, },
#endif
#if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI) #if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI)
{ {
"Device Path", NULL, "Device Path",
PARTITION_SYSTEM_GUID,
},
{
NULL, "Device Path",
EFI_DEVICE_PATH_PROTOCOL_GUID, EFI_DEVICE_PATH_PROTOCOL_GUID,
}, },
{ {
"Device Path To Text", NULL, "Device Path To Text",
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID, EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID,
}, },
{ {
"Device Path Utilities", NULL, "Device Path Utilities",
EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID, EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID,
}, },
{ {
"Unicode Collation 2", NULL, "Unicode Collation 2",
EFI_UNICODE_COLLATION_PROTOCOL2_GUID, EFI_UNICODE_COLLATION_PROTOCOL2_GUID,
}, },
{ {
"Driver Binding", NULL, "Driver Binding",
EFI_DRIVER_BINDING_PROTOCOL_GUID, EFI_DRIVER_BINDING_PROTOCOL_GUID,
}, },
{ {
"Simple Text Input", NULL, "Simple Text Input",
EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID, EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID,
}, },
{ {
"Simple Text Input Ex", NULL, "Simple Text Input Ex",
EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID, EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID,
}, },
{ {
"Simple Text Output", NULL, "Simple Text Output",
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID, EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID,
}, },
{ {
"Block IO", NULL, "Block IO",
EFI_BLOCK_IO_PROTOCOL_GUID, EFI_BLOCK_IO_PROTOCOL_GUID,
}, },
{ {
"Disk IO", NULL, "Disk IO",
EFI_DISK_IO_PROTOCOL_GUID, EFI_DISK_IO_PROTOCOL_GUID,
}, },
{ {
"Simple File System", NULL, "Simple File System",
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID,
}, },
{ {
"Loaded Image", NULL, "Loaded Image",
EFI_LOADED_IMAGE_PROTOCOL_GUID, EFI_LOADED_IMAGE_PROTOCOL_GUID,
}, },
{ {
"Loaded Image Device Path", NULL, "Loaded Image Device Path",
EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID, EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID,
}, },
{ {
"Graphics Output", NULL, "Graphics Output",
EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID, EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID,
}, },
{ {
"HII String", NULL, "HII String",
EFI_HII_STRING_PROTOCOL_GUID, EFI_HII_STRING_PROTOCOL_GUID,
}, },
{ {
"HII Database", NULL, "HII Database",
EFI_HII_DATABASE_PROTOCOL_GUID, EFI_HII_DATABASE_PROTOCOL_GUID,
}, },
{ {
"HII Config Access", NULL, "HII Config Access",
EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID, EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID,
}, },
{ {
"HII Config Routing", NULL, "HII Config Routing",
EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID, EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID,
}, },
{ {
"Load File", NULL, "Load File",
EFI_LOAD_FILE_PROTOCOL_GUID, EFI_LOAD_FILE_PROTOCOL_GUID,
}, },
{ {
"Load File2", NULL, "Load File2",
EFI_LOAD_FILE2_PROTOCOL_GUID, EFI_LOAD_FILE2_PROTOCOL_GUID,
}, },
{ {
"Random Number Generator", NULL, "Random Number Generator",
EFI_RNG_PROTOCOL_GUID, EFI_RNG_PROTOCOL_GUID,
}, },
{ {
"Simple Network", NULL, "Simple Network",
EFI_SIMPLE_NETWORK_PROTOCOL_GUID, EFI_SIMPLE_NETWORK_PROTOCOL_GUID,
}, },
{ {
"PXE Base Code", NULL, "PXE Base Code",
EFI_PXE_BASE_CODE_PROTOCOL_GUID, EFI_PXE_BASE_CODE_PROTOCOL_GUID,
}, },
{ {
"Device-Tree Fixup", NULL, "Device-Tree Fixup",
EFI_DT_FIXUP_PROTOCOL_GUID, EFI_DT_FIXUP_PROTOCOL_GUID,
}, },
{ {
"TCG2", NULL, "TCG2",
EFI_TCG2_PROTOCOL_GUID, EFI_TCG2_PROTOCOL_GUID,
}, },
{ {
"Firmware Management", NULL, "Firmware Management",
EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID
}, },
#if IS_ENABLED(CONFIG_EFI_HTTP_PROTOCOL) #if IS_ENABLED(CONFIG_EFI_HTTP_PROTOCOL)
{ {
"HTTP", NULL, "HTTP",
EFI_HTTP_PROTOCOL_GUID, EFI_HTTP_PROTOCOL_GUID,
}, },
{ {
"HTTP Service Binding", NULL, "HTTP Service Binding",
EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID, EFI_HTTP_SERVICE_BINDING_PROTOCOL_GUID,
}, },
{ {
"IPv4 Config2", NULL, "IPv4 Config2",
EFI_IP4_CONFIG2_PROTOCOL_GUID, EFI_IP4_CONFIG2_PROTOCOL_GUID,
}, },
#endif #endif
/* Configuration table GUIDs */ /* Configuration table GUIDs */
{ {
"ACPI table", NULL, "ACPI table",
EFI_ACPI_TABLE_GUID, EFI_ACPI_TABLE_GUID,
}, },
{ {
"EFI System Resource Table", NULL, "EFI System Resource Table",
EFI_SYSTEM_RESOURCE_TABLE_GUID, EFI_SYSTEM_RESOURCE_TABLE_GUID,
}, },
{ {
"device tree", NULL, "device tree",
EFI_FDT_GUID, EFI_FDT_GUID,
}, },
{ {
"SMBIOS table", NULL, "SMBIOS table",
SMBIOS_TABLE_GUID, SMBIOS_TABLE_GUID,
}, },
{ {
"SMBIOS3 table", NULL, "SMBIOS3 table",
SMBIOS3_TABLE_GUID, SMBIOS3_TABLE_GUID,
}, },
{ {
"Runtime properties", NULL, "Runtime properties",
EFI_RT_PROPERTIES_TABLE_GUID, EFI_RT_PROPERTIES_TABLE_GUID,
}, },
{ {
"TCG2 Final Events Table", NULL, "TCG2 Final Events Table",
EFI_TCG2_FINAL_EVENTS_TABLE_GUID, EFI_TCG2_FINAL_EVENTS_TABLE_GUID,
}, },
{ {
"EFI Conformance Profiles Table", NULL, "EFI Conformance Profiles Table",
EFI_CONFORMANCE_PROFILES_TABLE_GUID, EFI_CONFORMANCE_PROFILES_TABLE_GUID,
}, },
#ifdef CONFIG_EFI_RISCV_BOOT_PROTOCOL #ifdef CONFIG_EFI_RISCV_BOOT_PROTOCOL
{ {
"RISC-V Boot", NULL, "RISC-V Boot",
RISCV_EFI_BOOT_PROTOCOL_GUID, RISCV_EFI_BOOT_PROTOCOL_GUID,
}, },
#endif #endif
@@ -247,35 +260,36 @@ static const struct {
#ifdef CONFIG_CMD_NVEDIT_EFI #ifdef CONFIG_CMD_NVEDIT_EFI
/* signature database */ /* signature database */
{ {
"EFI_GLOBAL_VARIABLE_GUID", "EFI_GLOBAL_VARIABLE_GUID", NULL,
EFI_GLOBAL_VARIABLE_GUID, EFI_GLOBAL_VARIABLE_GUID,
}, },
{ {
"EFI_IMAGE_SECURITY_DATABASE_GUID", "EFI_IMAGE_SECURITY_DATABASE_GUID", NULL,
EFI_IMAGE_SECURITY_DATABASE_GUID, EFI_IMAGE_SECURITY_DATABASE_GUID,
}, },
/* certificate types */ /* certificate types */
{ {
"EFI_CERT_SHA256_GUID", "EFI_CERT_SHA256_GUID", NULL,
EFI_CERT_SHA256_GUID, EFI_CERT_SHA256_GUID,
}, },
{ {
"EFI_CERT_X509_GUID", "EFI_CERT_X509_GUID", NULL,
EFI_CERT_X509_GUID, EFI_CERT_X509_GUID,
}, },
{ {
"EFI_CERT_TYPE_PKCS7_GUID", "EFI_CERT_TYPE_PKCS7_GUID", NULL,
EFI_CERT_TYPE_PKCS7_GUID, EFI_CERT_TYPE_PKCS7_GUID,
}, },
#endif #endif
#if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI) #if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI)
{ "EFI_LZMA_COMPRESSED", EFI_LZMA_COMPRESSED }, { "EFI_LZMA_COMPRESSED", NULL, EFI_LZMA_COMPRESSED },
{ "EFI_DXE_SERVICES", EFI_DXE_SERVICES }, { "EFI_DXE_SERVICES", NULL, EFI_DXE_SERVICES },
{ "EFI_HOB_LIST", EFI_HOB_LIST }, { "EFI_HOB_LIST", NULL, EFI_HOB_LIST },
{ "EFI_MEMORY_TYPE", EFI_MEMORY_TYPE }, { "EFI_MEMORY_TYPE", NULL, EFI_MEMORY_TYPE },
{ "EFI_MEM_STATUS_CODE_REC", EFI_MEM_STATUS_CODE_REC }, { "EFI_MEM_STATUS_CODE_REC", NULL, EFI_MEM_STATUS_CODE_REC },
{ "EFI_GUID_EFI_ACPI1", EFI_GUID_EFI_ACPI1 }, { "EFI_GUID_EFI_ACPI1", NULL, EFI_GUID_EFI_ACPI1 },
#endif #endif
#endif /* EFI_PARTITION */
#endif /* !USE_HOSTCC */ #endif /* !USE_HOSTCC */
}; };
@@ -284,7 +298,8 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin)
int i; int i;
for (i = 0; i < ARRAY_SIZE(list_guid); i++) { for (i = 0; i < ARRAY_SIZE(list_guid); i++) {
if (!strcmp(list_guid[i].string, guid_str)) { if (list_guid[i].type &&
!strcmp(list_guid[i].type, guid_str)) {
memcpy(guid_bin, &list_guid[i].guid, 16); memcpy(guid_bin, &list_guid[i].guid, 16);
return 0; return 0;
} }
@@ -298,7 +313,9 @@ const char *uuid_guid_get_str(const unsigned char *guid_bin)
for (i = 0; i < ARRAY_SIZE(list_guid); i++) { for (i = 0; i < ARRAY_SIZE(list_guid); i++) {
if (!memcmp(list_guid[i].guid.b, guid_bin, 16)) { if (!memcmp(list_guid[i].guid.b, guid_bin, 16)) {
return list_guid[i].string; if (list_guid[i].description)
return list_guid[i].description;
return list_guid[i].type;
} }
} }
return NULL; return NULL;
@@ -312,10 +329,9 @@ int uuid_str_to_bin(const char *uuid_str, unsigned char *uuid_bin,
uint64_t tmp64; uint64_t tmp64;
if (!uuid_str_valid(uuid_str)) { if (!uuid_str_valid(uuid_str)) {
#ifdef CONFIG_PARTITION_TYPE_GUID if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID) &&
if (!uuid_guid_get_bin(uuid_str, uuid_bin)) !uuid_guid_get_bin(uuid_str, uuid_bin))
return 0; return 0;
#endif
return -EINVAL; return -EINVAL;
} }

View File

@@ -45,8 +45,7 @@ static int print_guid(struct unit_test_state *uts)
sprintf(str, "%pUL", guid); sprintf(str, "%pUL", guid);
ut_asserteq_str("04030201-0605-0807-090A-0B0C0D0E0F10", str); ut_asserteq_str("04030201-0605-0807-090A-0B0C0D0E0F10", str);
sprintf(str, "%pUs", guid_esp); sprintf(str, "%pUs", guid_esp);
if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID) || if (IS_ENABLED(CONFIG_EFI_PARTITION))
IS_ENABLED(CONFIG_CMD_EFIDEBUG) || IS_ENABLED(CONFIG_EFI))
ut_asserteq_str("EFI System Partition", str); ut_asserteq_str("EFI System Partition", str);
else else
ut_asserteq_str("c12a7328-f81f-11d2-ba4b-00a0c93ec93b", str); ut_asserteq_str("c12a7328-f81f-11d2-ba4b-00a0c93ec93b", str);

View File

@@ -330,6 +330,33 @@ def test_gpt_write(state_disk_image, ubman):
output = ubman.run_command('gpt guid host 0') output = ubman.run_command('gpt guid host 0')
assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_gpt')
@pytest.mark.buildconfigspec('cmd_part')
@pytest.mark.buildconfigspec('partition_type_guid')
@pytest.mark.requiredtool('sgdisk')
def test_gpt_write_part_type(state_disk_image, ubman):
"""Test the gpt command with part type uuid."""
output = ubman.run_command('gpt write host 0 "name=part1,type=data,size=1M;name=part2,size=512K,type=system;name=part3,size=65536,type=u-boot-env;name=part4,size=65536,type=375a56f7-d6c9-4e81-b5f0-09d41ca89efe;name=part5,size=-,type=linux"')
assert 'Writing GPT: success!' in output
output = ubman.run_command('part list host 0')
assert '1\t0x00000022\t0x00000821\t"part1"' in output
assert 'ebd0a0a2-b9e5-4433-87c0-68b6b72699c7' in output
assert '(data)' in output
assert '2\t0x00000822\t0x00000c21\t"part2"' in output
assert 'c12a7328-f81f-11d2-ba4b-00a0c93ec93b' in output
assert '(EFI System Partition)' in output
assert '3\t0x00000c22\t0x00000ca1\t"part3"' in output
assert '3de21764-95bd-54bd-a5c3-4abe786f38a8' in output
assert '(u-boot-env)' in output
assert '4\t0x00000ca2\t0x00000d21\t"part4"' in output
assert 'ebd0a0a2-b9e5-4433-87c0-68b6b72699c7' in output
assert '(375a56f7-d6c9-4e81-b5f0-09d41ca89efe)' in output
assert '5\t0x00000d22\t0x00001fde\t"part5"' in output
assert '0fc63daf-8483-4772-8e79-3d69d8477de4' in output
assert '(linux)' in output
@pytest.mark.buildconfigspec('cmd_gpt') @pytest.mark.buildconfigspec('cmd_gpt')
@pytest.mark.buildconfigspec('cmd_gpt_rename') @pytest.mark.buildconfigspec('cmd_gpt_rename')
@pytest.mark.buildconfigspec('cmd_part') @pytest.mark.buildconfigspec('cmd_part')