| Message ID | 20260419143247.437733-5-dario.binacchi@amarulasolutions.com |
|---|---|
| State | New |
| Headers | show |
| Series |
|
| Related | show |
Hi Dario, On 4/19/26 4:31 PM, Dario Binacchi wrote: > The 'part' command currently allows looking up a partition only by its > number or name. > > Extend the 'number', 'start', and 'size' subcommands to support looking > up the partition via its UUID. Unlike names, UUIDs guarantee unique > partition identification, avoiding ambiguity. > > The logic is updated to check if the provided string is a valid UUID > before falling back to a name-based search. The help strings for these > subcommands are updated accordingly. > > Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com> > Reviewed-by: Simon Glass <sjg@chromium.org> > Please update doc/usage/cmd/part.rst to reflect the changes made in this patch. Cheers, Quentin > --- > > (no changes since v3) > > Changes in v3: > - Add Reviewed-by tag of Simon Glass > > Changes in v2: > - Update commit message. > - Update help for 'part start', 'part size' to mention UUID. > > cmd/part.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/cmd/part.c b/cmd/part.c > index 5e520d707f39..3191d5861fdb 100644 > --- a/cmd/part.c > +++ b/cmd/part.c > @@ -144,6 +144,10 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param) > err = part_get_info(desc, part, &info); > if (err) > return 1; > + } else if (uuid_str_valid(argv[2])) { > + part = part_get_info_by_uuid(desc, argv[2], &info); > + if (part < 0) > + return 1; > } else { > part = part_get_info_by_name(desc, argv[2], &info); > if (part < 0) > @@ -517,13 +521,13 @@ U_BOOT_CMD( > " flags can be -bootable (list only bootable partitions)\n" > "part start <interface> <dev> <part> <varname>\n" > " - set environment variable to the start of the partition (in blocks)\n" > - " part can be either partition number or partition name\n" > + " part can be either partition number, UUID or 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 can be either partition number, UUID or name\n" > "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" > + " - set environment variable to the partition number using the partition UUID or name\n" > + " part must be specified as partition UUID or 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" To unsubscribe from this group and stop receiving emails from it, send an email to linux-amarula+unsubscribe@amarulasolutions.com.
diff --git a/cmd/part.c b/cmd/part.c index 5e520d707f39..3191d5861fdb 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -144,6 +144,10 @@ static int do_part_info(int argc, char *const argv[], enum cmd_part_info param) err = part_get_info(desc, part, &info); if (err) return 1; + } else if (uuid_str_valid(argv[2])) { + part = part_get_info_by_uuid(desc, argv[2], &info); + if (part < 0) + return 1; } else { part = part_get_info_by_name(desc, argv[2], &info); if (part < 0) @@ -517,13 +521,13 @@ U_BOOT_CMD( " flags can be -bootable (list only bootable partitions)\n" "part start <interface> <dev> <part> <varname>\n" " - set environment variable to the start of the partition (in blocks)\n" - " part can be either partition number or partition name\n" + " part can be either partition number, UUID or 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 can be either partition number, UUID or name\n" "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" + " - set environment variable to the partition number using the partition UUID or name\n" + " part must be specified as partition UUID or 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"