From: Rasmus Villemoes <ravi@prevas.dk>
To: u-boot@lists.denx.de
Cc: Quentin Schulz <quentin.schulz@cherry.de>,
Tom Rini <trini@konsulko.com>, Rasmus Villemoes <ravi@prevas.dk>
Subject: [PATCH v2 2/2] cmd/part.c: implement "part name" subcommand
Date: Mon, 20 Oct 2025 14:11:00 +0200 [thread overview]
Message-ID: <20251020121100.1742812-3-ravi@prevas.dk> (raw)
In-Reply-To: <20251020121100.1742812-1-ravi@prevas.dk>
This is a natural buddy to the existing "part number", allowing one to
get the partition name for a given partition number.
Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
---
v2: include documentation update
cmd/part.c | 16 +++++++++++++++-
doc/usage/cmd/part.rst | 13 +++++++++++++
2 files changed, 28 insertions(+), 1 deletion(-)
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"
diff --git a/doc/usage/cmd/part.rst b/doc/usage/cmd/part.rst
index e7f6e54ecea..df510685154 100644
--- a/doc/usage/cmd/part.rst
+++ b/doc/usage/cmd/part.rst
@@ -16,6 +16,7 @@ Synopsis
part start <interface> <dev> <part> <varname>
part size <interface> <dev> <part> <varname>
part number <interface> <dev> <part> <varname>
+ part name <interface> <dev> <part> <varname>
part set <interface> <dev> <part> <type>
part type <interface> <dev>:<part> [varname]
part types
@@ -86,6 +87,18 @@ part must be specified as partition name.
varname
a variable to store the current partition number value into
+The 'part name' command sets an environment variable to the partition name using the partition number,
+part must be specified as partition number.
+
+ interface
+ interface for accessing the block device (mmc, sata, scsi, usb, ....)
+ dev
+ device number
+ part
+ partition number
+ varname
+ a variable to store the current partition name into
+
The 'part set' command sets the type of a partition. This is useful when
autodetection fails or does not do the correct thing:
--
2.51.0
next prev parent reply other threads:[~2025-10-20 12:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 12:10 [PATCH v2 0/2] 'part name' subcommand and some robustification Rasmus Villemoes
2025-10-20 12:10 ` [PATCH v2 1/2] disk/part.c: ensure strings in struct disk_partition are valid after successful get_info Rasmus Villemoes
2025-11-03 14:07 ` Quentin Schulz
2025-10-20 12:11 ` Rasmus Villemoes [this message]
2025-11-03 14:14 ` [PATCH v2 2/2] cmd/part.c: implement "part name" subcommand Quentin Schulz
2025-11-03 20:38 ` Rasmus Villemoes
2025-11-04 9:36 ` Quentin Schulz
2025-11-07 20:19 ` [PATCH v2 0/2] 'part name' subcommand and some robustification Tom Rini
2025-11-08 0:02 ` Rasmus Villemoes
2025-11-08 15:01 ` Tom Rini
2025-11-10 0:33 ` Rasmus Villemoes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251020121100.1742812-3-ravi@prevas.dk \
--to=ravi@prevas.dk \
--cc=quentin.schulz@cherry.de \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox