[PATCH] cmd/part.c: implement "part name" subcommand
Rasmus Villemoes
ravi at prevas.dk
Fri Oct 17 10:22:02 CEST 2025
On Thu, Oct 16 2025, Quentin Schulz <quentin.schulz at cherry.de> wrote:
> Hi Rasmus,
>
> On 10/16/25 2:52 PM, Rasmus Villemoes wrote:
>> This is a natural buddy to the existing "part number", allowing one to
>> get the partition name for a given partition number.
>>
>
> Can you update the documentation in doc/usage/cmd/part.rst as well?
Will do, thanks.
>> cmd/part.c | 16 +++++++++++++++-
>> 1 file changed, 15 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);
>
> Is it possible info.name is never set by the fs/blk driver? Should we
> initialize this field?
>
So I took a look, and it seems that all but part_amiga.c do initialize
it.
- iso and dos uses part_set_generic_name()
- mac and efi have real data from the partition table to put in
- mtd also initializes name, either from a name defined in mtdparts or a
size at offset generated one
- ubi uses the volume name
I suppose we should make sure info.name is zero-initialized (or, at
least, that info.name[0] is 0 so there's a valid C string). But I think
that shouldn't have to be the responsibility of every caller of
part_get_info(). IOW, I think we should just add
info->name[0] = '\0';
info->type[0] = '\0';
into part_get_info_by_type(), and then that's a separate patch. WDYT?
Rasmus
More information about the U-Boot
mailing list