summaryrefslogtreecommitdiff
path: root/disk/part.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2023-07-16 06:38:47 +0300
committerBin Meng <bmeng@tinylab.org>2023-07-17 12:12:06 +0300
commit125194e6a136f2a3ef49d443f139b44a04e1bb9e (patch)
tree3c8948421454cfa9b2f1bfae919aa78fdc02ddfd /disk/part.c
parentb279f5170a807a87a5726bcbeb0bc98937102eee (diff)
downloadu-boot-125194e6a136f2a3ef49d443f139b44a04e1bb9e.tar.xz
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/part.c')
-rw-r--r--disk/part.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/disk/part.c b/disk/part.c
index 35300df590..1d2117ab71 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;