mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
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 <quic_varada@quicinc.com> Acked-by: Casey Connolly <casey.connolly@linaro.org>
This commit is contained in:
committed by
Tom Rini
parent
48db49b097
commit
43fd4bcefd
39
disk/part.c
39
disk/part.c
@@ -698,6 +698,45 @@ int part_get_info_by_name(struct blk_desc *desc, const char *name,
|
|||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int part_get_info_by_uuid(struct blk_desc *desc, const char *uuid,
|
||||||
|
struct disk_partition *info)
|
||||||
|
{
|
||||||
|
struct part_driver *part_drv;
|
||||||
|
int ret;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (!CONFIG_IS_ENABLED(PARTITION_UUIDS))
|
||||||
|
return -ENOENT;
|
||||||
|
|
||||||
|
part_drv = part_driver_lookup_type(desc);
|
||||||
|
if (!part_drv)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (!part_drv->get_info) {
|
||||||
|
log_debug("## Driver %s does not have the get_info() method\n",
|
||||||
|
part_drv->name);
|
||||||
|
return -ENOSYS;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 1; i < part_drv->max_entries; i++) {
|
||||||
|
ret = part_drv->get_info(desc, i, info);
|
||||||
|
if (ret != 0) {
|
||||||
|
/*
|
||||||
|
* Partition with this index can't be obtained, but
|
||||||
|
* further partitions might be, so keep checking.
|
||||||
|
*/
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strncasecmp(uuid, disk_partition_uuid(info), UUID_STR_LEN)) {
|
||||||
|
/* matched */
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return -ENOENT;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get partition info from device number and partition name.
|
* Get partition info from device number and partition name.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -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,
|
int part_get_info_by_name(struct blk_desc *desc, const char *name,
|
||||||
struct disk_partition *info);
|
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
|
* part_get_info_by_dev_and_name_or_num() - Get partition info from dev number
|
||||||
* and part name, or dev number and
|
* 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;
|
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
|
static inline int
|
||||||
part_get_info_by_dev_and_name_or_num(const char *dev_iface,
|
part_get_info_by_dev_and_name_or_num(const char *dev_iface,
|
||||||
const char *dev_part_str,
|
const char *dev_part_str,
|
||||||
|
|||||||
Reference in New Issue
Block a user