From 31ce367cd10087b532431c023e4a95513ecdee5d Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 20 Nov 2020 11:45:35 +0100 Subject: lib/uuid.c: change prototype of uuid_guid_get_str() There's no reason to require an appropriately sized output parameter for the string, that's error-prone should the table ever grow an element with a longer string. We can just return the const char* pointer directly. Update the only caller accordingly, and get rid of pointless ifdeffery in the header so that the compiler always sees a declaration and can thus do type-checking, whether or not PARTITION_TYPE_GUID is enabled or not. Signed-off-by: Rasmus Villemoes --- lib/uuid.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/uuid.c') diff --git a/lib/uuid.c b/lib/uuid.c index e62d5ca264..6cfb6cd449 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -122,20 +122,19 @@ int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin) * uuid_guid_get_str() - this function get string for GUID. * * @param guid_bin - pointer to string with partition type guid [16B] - * @param guid_str - pointer to allocated partition type string [7B] + * + * Returns NULL if the type GUID is not known. */ -int uuid_guid_get_str(const unsigned char *guid_bin, char *guid_str) +const char *uuid_guid_get_str(const unsigned char *guid_bin) { int i; - *guid_str = 0; for (i = 0; i < ARRAY_SIZE(list_guid); i++) { if (!memcmp(list_guid[i].guid.b, guid_bin, 16)) { - strcpy(guid_str, list_guid[i].string); - return 0; + return list_guid[i].string; } } - return -ENODEV; + return NULL; } #endif -- cgit v1.2.3 From c0364ce1c6957c5295e933b95802e6966e00b08f Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Fri, 20 Nov 2020 11:45:36 +0100 Subject: doc/README.gpt: define partition type GUID for U-Boot environment When setting aside a GPT partition for holding the U-Boot environment, having a partition type GUID [1] indicating "Linux filesystem" (as most tools default to) is somewhat misleading - and there's no other well-known type GUID that is better suited. So to have a canonical value to put into the type field, define 3de21764-95bd-54bd-a5c3-4abe786f38a8 to mean a partition holding a U-Boot environment. This is a v5 namespace-name GUID [2], generated [3] from a namespace of "25cbcde0-8642-47c6-a298-1a3a57cd256b" and name "U-Boot environment". Should future type GUIDs be defined in the context of U-Boot, it's sensible to use that same namespace GUID. [1] https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs [2] https://en.wikipedia.org/wiki/Universally_unique_identifier#Versions_3_and_5_(namespace_name-based) [3] https://www.uuidtools.com/v5 Signed-off-by: Rasmus Villemoes --- doc/README.gpt | 2 ++ include/part_efi.h | 3 +++ lib/uuid.c | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) (limited to 'lib/uuid.c') diff --git a/doc/README.gpt b/doc/README.gpt index facd7afc3a..9e0d2221ef 100644 --- a/doc/README.gpt +++ b/doc/README.gpt @@ -267,6 +267,8 @@ Some strings can be also used at the place of known 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) "uuid_disk=...;name=u-boot,size=60MiB,uuid=...; name=kernel,size=60MiB,uuid=...,type=linux;" diff --git a/include/part_efi.h b/include/part_efi.h index 1929e4400f..c68529b4da 100644 --- a/include/part_efi.h +++ b/include/part_efi.h @@ -56,6 +56,9 @@ #define PARTITION_LINUX_LVM_GUID \ EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \ 0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28) +#define PARTITION_U_BOOT_ENVIRONMENT \ + EFI_GUID( 0x3de21764, 0x95bd, 0x54bd, \ + 0xa5, 0xc3, 0x4a, 0xbe, 0x78, 0x6f, 0x38, 0xa8) /* linux/include/efi.h */ typedef u16 efi_char16_t; diff --git a/lib/uuid.c b/lib/uuid.c index 6cfb6cd449..54a93aacc9 100644 --- a/lib/uuid.c +++ b/lib/uuid.c @@ -96,7 +96,8 @@ static const struct { {"linux", PARTITION_LINUX_FILE_SYSTEM_DATA_GUID}, {"raid", PARTITION_LINUX_RAID_GUID}, {"swap", PARTITION_LINUX_SWAP_GUID}, - {"lvm", PARTITION_LINUX_LVM_GUID} + {"lvm", PARTITION_LINUX_LVM_GUID}, + {"u-boot-env", PARTITION_U_BOOT_ENVIRONMENT}, }; /* -- cgit v1.2.3