summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2025-11-18 12:51:22 -0600
committerTom Rini <[email protected]>2025-11-18 12:51:22 -0600
commitb8872deb4450b09586e28550c23d33a71084d94f (patch)
tree8dd5e2c78ed30bd1c0983f5e134ac2a77b85ddf0 /cmd
parentabf15eb60c8a87f833f7e75e5e8a51a7eb115e0b (diff)
parent30890051ab23a0293f6404c9a49e86f33e45df66 (diff)
Merge patch series "'part name' subcommand and some robustification"
Rasmus Villemoes <[email protected]> says: Implement a "part name" subcommand, mirroring the existing "part number" subcommand. In the discussion for v1 of that, it came up that there's a bit of inconsistency in how much and what one can assume to be initialized in 'struct disk_partition' after a successful call of one of the get_info* family of functions. Patch 1/2 tries to consolidate that by making sure all ->get_info invocations go through a common helper that at least always initializes the string members. Quentin, I've taken the liberty of including your Acks, as the incremental diff in patch 1 is quite minor, but do speak up if I should not have done that. Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'cmd')
-rw-r--r--cmd/gpt.c4
-rw-r--r--cmd/part.c16
2 files changed, 17 insertions, 3 deletions
diff --git a/cmd/gpt.c b/cmd/gpt.c
index e18e5036a06..84221881c39 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -724,7 +724,7 @@ static int gpt_enumerate(struct blk_desc *desc)
continue;
for (i = 1; i < part_drv->max_entries; i++) {
- ret = part_drv->get_info(desc, i, &pinfo);
+ ret = part_driver_get_info(part_drv, desc, i, &pinfo);
if (ret)
continue;
@@ -820,7 +820,7 @@ static int gpt_setenv(struct blk_desc *desc, const char *name)
int i;
for (i = 1; i < part_drv->max_entries; i++) {
- ret = part_drv->get_info(desc, i, &pinfo);
+ ret = part_driver_get_info(part_drv, desc, i, &pinfo);
if (ret)
continue;
diff --git a/cmd/part.c b/cmd/part.c
index db7bc5819c0..975a0a08a99 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -25,7 +25,8 @@
enum cmd_part_info {
CMD_PART_INFO_START = 0,
CMD_PART_INFO_SIZE,
- CMD_PART_INFO_NUMBER
+ CMD_PART_INFO_NUMBER,
+ CMD_PART_INFO_NAME,
};
static int do_part_uuid(int argc, char *const argv[])
@@ -154,6 +155,9 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param)
case CMD_PART_INFO_NUMBER:
snprintf(buf, sizeof(buf), "0x%x", part);
break;
+ case CMD_PART_INFO_NAME:
+ snprintf(buf, sizeof(buf), "%s", info.name);
+ break;
default:
printf("** Unknown cmd_part_info value: %d\n", param);
return 1;
@@ -182,6 +186,11 @@ static int do_part_number(int argc, char *const argv[])
return do_part_info(argc, argv, CMD_PART_INFO_NUMBER);
}
+static int do_part_name(int argc, char *const argv[])
+{
+ return do_part_info(argc, argv, CMD_PART_INFO_NAME);
+}
+
static int do_part_set(int argc, char *const argv[])
{
const char *devname, *partstr, *typestr;
@@ -273,6 +282,8 @@ static int do_part(struct cmd_tbl *cmdtp, int flag, int argc,
return do_part_size(argc - 2, argv + 2);
else if (!strcmp(argv[1], "number"))
return do_part_number(argc - 2, argv + 2);
+ else if (!strcmp(argv[1], "name"))
+ return do_part_name(argc - 2, argv + 2);
else if (!strcmp(argv[1], "types"))
return do_part_types(argc - 2, argv + 2);
else if (!strcmp(argv[1], "set"))
@@ -305,6 +316,9 @@ U_BOOT_CMD(
"part number <interface> <dev> <part> <varname>\n"
" - set environment variable to the partition number using the partition name\n"
" part must be specified as partition name\n"
+ "part name <interface> <dev> <part> <varname>\n"
+ " - set environment variable to the partition name using the partition number\n"
+ " part must be specified as partition number\n"
#ifdef CONFIG_PARTITION_TYPE_GUID
"part type <interface> <dev>:<part>\n"
" - print partition type\n"