]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
disk: part_efi: parse and store partition UUID
authorStephen Warren <swarren@nvidia.com>
Fri, 21 Sep 2012 09:50:59 +0000 (09:50 +0000)
committerTom Rini <trini@ti.com>
Tue, 25 Sep 2012 22:05:44 +0000 (15:05 -0700)
Each EFI partition table entry contains a UUID. Extend U-Boot's struct
disk_partition to be able to store this information, and modify
get_partition_info_efi() to fill it in.

The implementation of uuid_string() was derived from the Linux kernel,
tag v3.6-rc4 file lib/vsprintf.c function uuid_string().

Signed-off-by: Stephen Warren <swarren@nvidia.com>
disk/part.c
disk/part_efi.c
include/part.h

index 0dd4b0f0c63a2a0ce118ffc21de383b5fd1f325e..64d76e8380690fcc5f9ccb9409ed40a74d72a9d0 100644 (file)
@@ -391,6 +391,11 @@ int get_partition_info(block_dev_desc_t *dev_desc, int part
        defined(CONFIG_MMC) || \
        defined(CONFIG_SYSTEMACE)
 
+#ifdef CONFIG_PARTITION_UUIDS
+       /* The common case is no UUID support */
+       info->uuid[0] = 0;
+#endif
+
        switch (dev_desc->part_type) {
 #ifdef CONFIG_MAC_PARTITION
        case PART_TYPE_MAC:
index 2962fd8f67158889cf325fafb735484d50477a63..264ea9c77f6e24a2dcb87c9233cdc7de85460686 100644 (file)
@@ -154,6 +154,28 @@ void print_part_efi(block_dev_desc_t * dev_desc)
        return;
 }
 
+#ifdef CONFIG_PARTITION_UUIDS
+static void uuid_string(unsigned char *uuid, char *str)
+{
+       static const u8 le[16] = {3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11,
+                                 12, 13, 14, 15};
+       int i;
+
+       for (i = 0; i < 16; i++) {
+               sprintf(str, "%02x", uuid[le[i]]);
+               str += 2;
+               switch (i) {
+               case 3:
+               case 5:
+               case 7:
+               case 9:
+                       *str++ = '-';
+                       break;
+               }
+       }
+}
+#endif
+
 int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
                                disk_partition_t * info)
 {
@@ -190,6 +212,9 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
        sprintf((char *)info->name, "%s",
                        print_efiname(&gpt_pte[part - 1]));
        sprintf((char *)info->type, "U-Boot");
+#ifdef CONFIG_PARTITION_UUIDS
+       uuid_string(gpt_pte[part - 1].unique_partition_guid.b, info->uuid);
+#endif
 
        debug("%s: start 0x%lX, size 0x%lX, name %s", __func__,
                info->start, info->size, info->name);
index 3f780a1f92537e7ac003d746dffc0726ab25f23e..27ea283f1edc4e583c7d329f441f190f02e4b6f0 100644 (file)
@@ -94,6 +94,9 @@ typedef struct disk_partition {
        uchar   name[32];       /* partition name                       */
        uchar   type[32];       /* string type description              */
        int     bootable;       /* Active/Bootable flag is set          */
+#ifdef CONFIG_PARTITION_UUIDS
+       char    uuid[37];       /* filesystem UUID as string, if exists */
+#endif
 } disk_partition_t;
 
 /* Misc _get_dev functions */