Commit 6eecc0307927fee1ff70151980b3a8c02ffeb947
Committed by
Wolfgang Denk
1 parent
9f87658054
Exists in
master
and in
54 other branches
part: show efi partition name when print out partition info
Previous output: Marvell>> mmc part Partition Map for MMC device 1 -- Partition Type: EFI Part Start LBA End LBA gpt1 0x8C00 0xCBFF gpt2 0xCC00 0x57BFF gpt3 0x57C00 0xA2BFF gpt4 0xA2C00 0xECBFDE With the patch, the output becomes: Marvell>> mmc part Partition Map for MMC device 1 -- Partition Type: EFI Part Name Start LBA End LBA 1 ramdisk 0x00008C00 0x0000CBFF 2 system 0x0000CC00 0x00057BFF 3 userdata 0x00057C00 0x000A2BFF 4 remaining 0x000A2C00 0x00ECBFDE Signed-off-by: Lei Wen <leiwen@marvell.com>
Showing 2 changed files with 22 additions and 5 deletions Side-by-side Diff
disk/part_efi.c
... | ... | @@ -35,6 +35,7 @@ |
35 | 35 | #include <ide.h> |
36 | 36 | #include <malloc.h> |
37 | 37 | #include "part_efi.h" |
38 | +#include <linux/ctype.h> | |
38 | 39 | |
39 | 40 | #if defined(CONFIG_CMD_IDE) || \ |
40 | 41 | defined(CONFIG_CMD_MG_DISK) || \ |
... | ... | @@ -99,6 +100,20 @@ |
99 | 100 | |
100 | 101 | static int is_pte_valid(gpt_entry * pte); |
101 | 102 | |
103 | +static char *print_efiname(gpt_entry *pte) | |
104 | +{ | |
105 | + static char name[PARTNAME_SZ + 1]; | |
106 | + int i; | |
107 | + for (i = 0; i < PARTNAME_SZ; i++) { | |
108 | + u8 c; | |
109 | + c = pte->partition_name[i] & 0xff; | |
110 | + c = (c && !isprint(c)) ? '.' : c; | |
111 | + name[i] = c; | |
112 | + } | |
113 | + name[PARTNAME_SZ] = 0; | |
114 | + return name; | |
115 | +} | |
116 | + | |
102 | 117 | /* |
103 | 118 | * Public Functions (include/part.h) |
104 | 119 | */ |
105 | 120 | |
... | ... | @@ -122,12 +137,12 @@ |
122 | 137 | |
123 | 138 | debug("%s: gpt-entry at 0x%08X\n", __FUNCTION__, (unsigned int)*pgpt_pte); |
124 | 139 | |
125 | - printf("Part Start LBA End LBA\n"); | |
140 | + printf("Part\tName\t\t\tStart LBA\tEnd LBA\n"); | |
126 | 141 | for (i = 0; i < le32_to_int(gpt_head.num_partition_entries); i++) { |
127 | 142 | |
128 | 143 | if (is_pte_valid(&(*pgpt_pte)[i])) { |
129 | - printf("%s%d 0x%llX 0x%llX\n", GPT_ENTRY_NAME, | |
130 | - (i + 1), | |
144 | + printf("%3d\t%-18s\t0x%08llX\t0x%08llX\n", (i + 1), | |
145 | + print_efiname(&(*pgpt_pte)[i]), | |
131 | 146 | le64_to_int((*pgpt_pte)[i].starting_lba), |
132 | 147 | le64_to_int((*pgpt_pte)[i].ending_lba)); |
133 | 148 | } else { |
... | ... | @@ -169,7 +184,8 @@ |
169 | 184 | - info->start; |
170 | 185 | info->blksz = GPT_BLOCK_SIZE; |
171 | 186 | |
172 | - sprintf((char *)info->name, "%s%d", GPT_ENTRY_NAME, part); | |
187 | + sprintf((char *)info->name, "%s", | |
188 | + print_efiname(&(*pgpt_pte)[part - 1])); | |
173 | 189 | sprintf((char *)info->type, "U-Boot"); |
174 | 190 | |
175 | 191 | debug("%s: start 0x%lX, size 0x%lX, name %s", __FUNCTION__, |
disk/part_efi.h
... | ... | @@ -117,13 +117,14 @@ |
117 | 117 | unsigned long long type_guid_specific:16; |
118 | 118 | } __attribute__ ((packed)) gpt_entry_attributes; |
119 | 119 | |
120 | +#define PARTNAME_SZ (72 / sizeof(efi_char16_t)) | |
120 | 121 | typedef struct _gpt_entry { |
121 | 122 | efi_guid_t partition_type_guid; |
122 | 123 | efi_guid_t unique_partition_guid; |
123 | 124 | unsigned char starting_lba[8]; |
124 | 125 | unsigned char ending_lba[8]; |
125 | 126 | gpt_entry_attributes attributes; |
126 | - efi_char16_t partition_name[72 / sizeof(efi_char16_t)]; | |
127 | + efi_char16_t partition_name[PARTNAME_SZ]; | |
127 | 128 | } |
128 | 129 | __attribute__ ((packed)) gpt_entry; |
129 | 130 |