From 43fd4bcefd4ea5e586e201a0908018d1e8395c82 Mon Sep 17 00:00:00 2001 From: Varadarajan Narayanan Date: Tue, 13 May 2025 14:47:06 +0530 Subject: disk: part: implement generic function part_get_info_by_uuid() Add function to search for a partition by UUID as partition names may not be unique. Signed-off-by: Varadarajan Narayanan Acked-by: Casey Connolly --- include/part.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/part.h b/include/part.h index fcb3c13dea4..3e6eb0ec33f 100644 --- a/include/part.h +++ b/include/part.h @@ -315,6 +315,20 @@ int blk_get_device_part_str(const char *ifname, const char *dev_part_str, int part_get_info_by_name(struct blk_desc *desc, const char *name, struct disk_partition *info); +/** + * part_get_info_by_uuid() - Search for a partition by uuid + * among all available registered partitions + * + * @desc: block device descriptor + * @uuid: the specified table entry uuid + * @info: the disk partition info + * + * Return: the partition number on match (starting on 1), -ENOENT on no match, + * otherwise error + */ +int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid, + struct disk_partition *info); + /** * part_get_info_by_dev_and_name_or_num() - Get partition info from dev number * and part name, or dev number and @@ -386,6 +400,12 @@ static inline int part_get_info_by_name(struct blk_desc *desc, const char *name, return -ENOENT; } +static inline int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid, + struct disk_partition *info) +{ + return -ENOENT; +} + static inline int part_get_info_by_dev_and_name_or_num(const char *dev_iface, const char *dev_part_str, -- cgit v1.2.3