aboutsummaryrefslogtreecommitdiff
path: root/disk
diff options
context:
space:
mode:
authorSimon Glass2023-07-15 21:38:47 -0600
committerBin Meng2023-07-17 17:12:06 +0800
commit125194e6a136f2a3ef49d443f139b44a04e1bb9e (patch)
tree3c8948421454cfa9b2f1bfae919aa78fdc02ddfd /disk
parentb279f5170a807a87a5726bcbeb0bc98937102eee (diff)
part: Allow setting the partition-table type
Some devices have multiple partition types available on the same media. It is sometimes useful to see these to check that everything is working correctly. Provide a way to manually set the partition-table type, avoiding the auto-detection process. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'disk')
-rw-r--r--disk/part.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/disk/part.c b/disk/part.c
index 35300df5903..1d2117ab71e 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -54,6 +54,22 @@ static struct part_driver *part_driver_lookup_type(struct blk_desc *dev_desc)
return NULL;
}
+int part_get_type_by_name(const char *name)
+{
+ struct part_driver *drv =
+ ll_entry_start(struct part_driver, part_driver);
+ const int n_ents = ll_entry_count(struct part_driver, part_driver);
+ struct part_driver *entry;
+
+ for (entry = drv; entry != drv + n_ents; entry++) {
+ if (!strcasecmp(name, entry->name))
+ return entry->part_type;
+ }
+
+ /* Not found */
+ return PART_TYPE_UNKNOWN;
+}
+
static struct blk_desc *get_dev_hwpart(const char *ifname, int dev, int hwpart)
{
struct blk_desc *dev_desc;