1
0
mirror of https://xff.cz/git/u-boot/ synced 2025-09-01 08:42:12 +02:00

disk: part: implement generic function part_get_info_by_name()

So far partition search by name has been supported only on the EFI partition
table. This patch extends the search to all partition tables.

Rename part_get_info_efi_by_name() to part_get_info_by_name(), move it from
part_efi.c into part.c and make it a generic function which traverses all part
drivers and searches all partitions (in the order given by the linked list).

For this a new variable struct part_driver.max_entries is added, which limits
the number of partitions searched. For EFI this was GPT_ENTRY_NUMBERS.
Similarly the limit is defined for DOS, ISO, MAC and AMIGA partition tables.

Signed-off-by: Petr Kulhavy <brain@jikos.cz>
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Steve Rae <steve.rae@raedomain.com>
This commit is contained in:
Petr Kulhavy
2016-09-09 10:27:15 +02:00
committed by Tom Rini
parent ba07984068
commit 87b8530fe2
8 changed files with 53 additions and 33 deletions

View File

@@ -296,25 +296,6 @@ int part_get_info_efi(struct blk_desc *dev_desc, int part,
return 0;
}
int part_get_info_efi_by_name(struct blk_desc *dev_desc,
const char *name, disk_partition_t *info)
{
int ret;
int i;
for (i = 1; i < GPT_ENTRY_NUMBERS; i++) {
ret = part_get_info_efi(dev_desc, i, info);
if (ret != 0) {
/* no more entries in table */
return -1;
}
if (strcmp(name, (const char *)info->name) == 0) {
/* matched */
return 0;
}
}
return -2;
}
static int part_test_efi(struct blk_desc *dev_desc)
{
ALLOC_CACHE_ALIGN_BUFFER_PAD(legacy_mbr, legacymbr, 1, dev_desc->blksz);
@@ -958,6 +939,7 @@ static int is_pte_valid(gpt_entry * pte)
U_BOOT_PART_TYPE(a_efi) = {
.name = "EFI",
.part_type = PART_TYPE_EFI,
.max_entries = GPT_ENTRY_NUMBERS,
.get_info = part_get_info_ptr(part_get_info_efi),
.print = part_print_ptr(part_print_efi),
.test = part_test_efi,