summaryrefslogtreecommitdiff
path: root/include/part.h
diff options
context:
space:
mode:
authorRuslan Trofymenko <ruslan.trofymenko@linaro.org>2019-07-05 15:37:31 +0300
committerTom Rini <trini@konsulko.com>2019-07-24 13:16:29 -0400
commit6eccd1f740601f39796bace54c40cd785408e74e (patch)
tree170b30905f06317dc17b6412a2893a6522fe479c /include/part.h
parent37f1811a0b31005284e8514955e7bf7e174cc506 (diff)
downloadu-boot-6eccd1f740601f39796bace54c40cd785408e74e.tar.gz
disk: part: Extend API to get partition info
This patch adds part_get_info_by_dev_and_name_or_num() function which allows us to get partition info from its number or name. Partition of interest is specified by string like "device_num:partition_number" or "device_num#partition_name". The patch was extracted from [1]. [1] https://android-review.googlesource.com/c/platform/external/u-boot/+/729880/2 Signed-off-by: Ruslan Trofymenko <ruslan.trofymenko@linaro.org> Signed-off-by: Igor Opaniuk <igor.opaniuk@gmail.com> Reviewed-by: Alistair Strachan <astrachan@google.com> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/part.h')
-rw-r--r--include/part.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/part.h b/include/part.h
index ebca546db5..0b5cf3d5e8 100644
--- a/include/part.h
+++ b/include/part.h
@@ -202,6 +202,27 @@ int part_get_info_by_name(struct blk_desc *dev_desc,
const char *name, disk_partition_t *info);
/**
+ * Get partition info from dev number + part name, or dev number + part number.
+ *
+ * Parse a device number and partition description (either name or number)
+ * in the form of device number plus partition name separated by a "#"
+ * (like "device_num#partition_name") or a device number plus a partition number
+ * separated by a ":". For example both "0#misc" and "0:1" can be valid
+ * partition descriptions for a given interface. If the partition is found, sets
+ * dev_desc and part_info accordingly with the information of the partition.
+ *
+ * @param[in] dev_iface Device interface
+ * @param[in] dev_part_str Input partition description, like "0#misc" or "0:1"
+ * @param[out] dev_desc Place to store the device description pointer
+ * @param[out] part_info Place to store the partition information
+ * @return 0 on success, or a negative on error
+ */
+int part_get_info_by_dev_and_name_or_num(const char *dev_iface,
+ const char *dev_part_str,
+ struct blk_desc **dev_desc,
+ disk_partition_t *part_info);
+
+/**
* part_set_generic_name() - create generic partition like hda1 or sdb2
*
* Helper function for partition tables, which don't hold partition names