summaryrefslogtreecommitdiff
path: root/disk/part.c
diff options
context:
space:
mode:
Diffstat (limited to 'disk/part.c')
-rw-r--r--disk/part.c58
1 files changed, 58 insertions, 0 deletions
diff --git a/disk/part.c b/disk/part.c
index 6a1c02d9fa..9f51a07676 100644
--- a/disk/part.c
+++ b/disk/part.c
@@ -615,3 +615,61 @@ 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;
+}
+
+void part_set_generic_name(const struct blk_desc *dev_desc,
+ int part_num, char *name)
+{
+ char *devtype;
+
+ switch (dev_desc->if_type) {
+ case IF_TYPE_IDE:
+ case IF_TYPE_SATA:
+ case IF_TYPE_ATAPI:
+ devtype = "hd";
+ break;
+ case IF_TYPE_SCSI:
+ devtype = "sd";
+ break;
+ case IF_TYPE_USB:
+ devtype = "usbd";
+ break;
+ case IF_TYPE_DOC:
+ devtype = "docd";
+ break;
+ case IF_TYPE_MMC:
+ case IF_TYPE_SD:
+ devtype = "mmcsd";
+ break;
+ default:
+ devtype = "xx";
+ break;
+ }
+
+ sprintf(name, "%s%c%d", devtype, 'a' + dev_desc->devnum, part_num);
+}