[U-Boot] [PATCH] cmd: part: unify syntax of uuid according to start/size subcommands
roman.stratiienko at globallogic.com
roman.stratiienko at globallogic.com
Thu Apr 25 11:18:22 UTC 2019
From: Roman Stratiienko <roman.stratiienko at globallogic.com>
This allows retrieving uuid of the partition using it's name.
Signed-off-by: Roman Stratiienko <roman.stratiienko at globallogic.com>
---
cmd/part.c | 40 ++++++++++------------------------------
1 file changed, 10 insertions(+), 30 deletions(-)
diff --git a/cmd/part.c b/cmd/part.c
index bee204f..57657ec 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -24,31 +24,9 @@
enum cmd_part_info {
CMD_PART_INFO_START = 0,
CMD_PART_INFO_SIZE,
+ CMD_PART_INFO_UUID,
};
-static int do_part_uuid(int argc, char * const argv[])
-{
- int part;
- struct blk_desc *dev_desc;
- disk_partition_t info;
-
- if (argc < 2)
- return CMD_RET_USAGE;
- if (argc > 3)
- return CMD_RET_USAGE;
-
- part = blk_get_device_part_str(argv[0], argv[1], &dev_desc, &info, 0);
- if (part < 0)
- return 1;
-
- if (argc > 2)
- env_set(argv[2], info.uuid);
- else
- printf("%s\n", info.uuid);
-
- return 0;
-}
-
static int do_part_list(int argc, char * const argv[])
{
int ret;
@@ -149,6 +127,9 @@ static int do_part_info(int argc, char * const argv[], enum cmd_part_info param)
case CMD_PART_INFO_SIZE:
snprintf(buf, sizeof(buf), LBAF, info.size);
break;
+ case CMD_PART_INFO_UUID:
+ snprintf(buf, sizeof(buf), "%s", info.uuid);
+ break;
default:
printf("** Unknown cmd_part_info value: %d\n", param);
return 1;
@@ -177,14 +158,14 @@ static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (argc < 2)
return CMD_RET_USAGE;
- if (!strcmp(argv[1], "uuid"))
- return do_part_uuid(argc - 2, argv + 2);
- else if (!strcmp(argv[1], "list"))
+ if (!strcmp(argv[1], "list"))
return do_part_list(argc - 2, argv + 2);
else if (!strcmp(argv[1], "start"))
return do_part_start(argc - 2, argv + 2);
else if (!strcmp(argv[1], "size"))
return do_part_size(argc - 2, argv + 2);
+ else if (!strcmp(argv[1], "uuid"))
+ return do_part_info(argc - 2, argv + 2, CMD_PART_INFO_UUID);
return CMD_RET_USAGE;
}
@@ -192,10 +173,6 @@ static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
U_BOOT_CMD(
part, CONFIG_SYS_MAXARGS, 1, do_part,
"disk partition related commands",
- "uuid <interface> <dev>:<part>\n"
- " - print partition UUID\n"
- "part uuid <interface> <dev>:<part> <varname>\n"
- " - set environment variable to partition UUID\n"
"part list <interface> <dev>\n"
" - print a device's partition table\n"
"part list <interface> <dev> [flags] <varname>\n"
@@ -206,5 +183,8 @@ U_BOOT_CMD(
" part can be either partition number or partition name\n"
"part size <interface> <dev> <part> <varname>\n"
" - set environment variable to the size of the partition (in blocks)\n"
+ " part can be either partition number or partition name\n"
+ "part uuid <interface> <dev> <part> <varname>\n"
+ " - set environment variable to the uuid of the partition\n"
" part can be either partition number or partition name"
);
--
2.7.4
More information about the U-Boot
mailing list