| Message ID | 1345158942-31512-1-git-send-email-swarren@wwwdotorg.org |
|---|---|
| State | Superseded |
| Delegated to: | Tom Rini |
| Headers | show |
Dear Stephen Warren, In message <1345158942-31512-1-git-send-email-swarren@wwwdotorg.org> you wrote: > From: Stephen Warren <swarren@nvidia.com> > > 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 stolen from the Linux kernel. > > Signed-off-by: Stephen Warren <swarren@nvidia.com> Can we please make this addition dependent on EFI support being enabled? Otherwise the increased memory footprint will hit all users, even if they never use EFI at all. Best regards, Wolfgang Denk
On 09/02/2012 10:45 AM, Wolfgang Denk wrote: > Dear Stephen Warren, > > In message <1345158942-31512-1-git-send-email-swarren@wwwdotorg.org> you wrote: >> From: Stephen Warren <swarren@nvidia.com> >> >> 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 stolen from the Linux kernel. >> >> Signed-off-by: Stephen Warren <swarren@nvidia.com> > > Can we please make this addition dependent on EFI support being > enabled? Otherwise the increased memory footprint will hit all users, > even if they never use EFI at all. (I assume you're talking about the change to the partition info structure, since IIRC all the other code was already in either the EFI partition code already, or a new command under its own ifdef). I'm also planning a patch that fills in this UUID field for MBR/DOS partition tables too. That'd require the ifdef to check 2 different config symbols, and perhaps more in the future. It seems a little messy to ifdef this just to save 4 bytes. Are you sure you want to do this?
diff --git a/disk/part.c b/disk/part.c index 76f3939..266d77e 100644 --- a/disk/part.c +++ b/disk/part.c @@ -294,6 +294,9 @@ void init_part (block_dev_desc_t * dev_desc) int get_partition_info (block_dev_desc_t *dev_desc, int part , disk_partition_t *info) { + /* The common case is no UUID support */ + info->uuid[0] = 0; + switch (dev_desc->part_type) { #ifdef CONFIG_MAC_PARTITION case PART_TYPE_MAC: diff --git a/disk/part_efi.c b/disk/part_efi.c index 02927a0..199c054 100644 --- a/disk/part_efi.c +++ b/disk/part_efi.c @@ -154,6 +154,26 @@ void print_part_efi(block_dev_desc_t * dev_desc) return; } +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; + } + } +} + int get_partition_info_efi(block_dev_desc_t * dev_desc, int part, disk_partition_t * info) { @@ -183,6 +203,7 @@ 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"); + uuid_string(gpt_pte[part - 1].unique_partition_guid.b, info->uuid); debug("%s: start 0x%lX, size 0x%lX, name %s", __func__, info->start, info->size, info->name); diff --git a/include/part.h b/include/part.h index e1478f4..52002f5 100644 --- a/include/part.h +++ b/include/part.h @@ -93,6 +93,7 @@ typedef struct disk_partition { ulong blksz; /* block size in bytes */ uchar name[32]; /* partition name */ uchar type[32]; /* string type description */ + char uuid[37]; /* filesystem UUID as string, if exists */ } disk_partition_t; /* Misc _get_dev functions */