Commit 60bf94169366acaf7dafeb30d7439af366f2c585
Committed by
Tom Rini
1 parent
e04350d299
Exists in
v2017.01-smarct4x
and in
40 other branches
disk: part_efi: add get_partition_info_efi_by_name()
Add function to find a GPT table entry by name. Tested on little endian ARMv7 and ARMv8 configurations Signed-off-by: Steve Rae <srae@broadcom.com>
Showing 2 changed files with 31 additions and 1 deletions Side-by-side Diff
disk/part_efi.c
... | ... | @@ -181,12 +181,31 @@ |
181 | 181 | UUID_STR_FORMAT_GUID); |
182 | 182 | #endif |
183 | 183 | |
184 | - debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s", __func__, | |
184 | + debug("%s: start 0x" LBAF ", size 0x" LBAF ", name %s\n", __func__, | |
185 | 185 | info->start, info->size, info->name); |
186 | 186 | |
187 | 187 | /* Remember to free pte */ |
188 | 188 | free(gpt_pte); |
189 | 189 | return 0; |
190 | +} | |
191 | + | |
192 | +int get_partition_info_efi_by_name(block_dev_desc_t *dev_desc, | |
193 | + const char *name, disk_partition_t *info) | |
194 | +{ | |
195 | + int ret; | |
196 | + int i; | |
197 | + for (i = 1; i < GPT_ENTRY_NUMBERS; i++) { | |
198 | + ret = get_partition_info_efi(dev_desc, i, info); | |
199 | + if (ret != 0) { | |
200 | + /* no more entries in table */ | |
201 | + return -1; | |
202 | + } | |
203 | + if (strcmp(name, (const char *)info->name) == 0) { | |
204 | + /* matched */ | |
205 | + return 0; | |
206 | + } | |
207 | + } | |
208 | + return -2; | |
190 | 209 | } |
191 | 210 | |
192 | 211 | int test_part_efi(block_dev_desc_t * dev_desc) |
include/part.h
... | ... | @@ -180,6 +180,17 @@ |
180 | 180 | #include <part_efi.h> |
181 | 181 | /* disk/part_efi.c */ |
182 | 182 | int get_partition_info_efi (block_dev_desc_t * dev_desc, int part, disk_partition_t *info); |
183 | +/** | |
184 | + * get_partition_info_efi_by_name() - Find the specified GPT partition table entry | |
185 | + * | |
186 | + * @param dev_desc - block device descriptor | |
187 | + * @param gpt_name - the specified table entry name | |
188 | + * @param info - returns the disk partition info | |
189 | + * | |
190 | + * @return - '0' on match, '-1' on no match, otherwise error | |
191 | + */ | |
192 | +int get_partition_info_efi_by_name(block_dev_desc_t *dev_desc, | |
193 | + const char *name, disk_partition_t *info); | |
183 | 194 | void print_part_efi (block_dev_desc_t *dev_desc); |
184 | 195 | int test_part_efi (block_dev_desc_t *dev_desc); |
185 | 196 |