mirror of
https://xff.cz/git/u-boot/
synced 2025-10-22 10:31:56 +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:
26
disk/part.c
26
disk/part.c
@@ -615,3 +615,29 @@ cleanup:
|
||||
free(dup_str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
|
||||
disk_partition_t *info)
|
||||
{
|
||||
struct part_driver *first_drv =
|
||||
ll_entry_start(struct part_driver, part_driver);
|
||||
const int n_drvs = ll_entry_count(struct part_driver, part_driver);
|
||||
struct part_driver *part_drv;
|
||||
|
||||
for (part_drv = first_drv; part_drv != first_drv + n_drvs; part_drv++) {
|
||||
int ret;
|
||||
int i;
|
||||
for (i = 1; i < part_drv->max_entries; i++) {
|
||||
ret = part_drv->get_info(dev_desc, i, info);
|
||||
if (ret != 0) {
|
||||
/* no more entries in table */
|
||||
break;
|
||||
}
|
||||
if (strcmp(name, (const char *)info->name) == 0) {
|
||||
/* matched */
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user