]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
cmd: part: support lookup by UUID
authorDario Binacchi <dario.binacchi@amarulasolutions.com>
Thu, 30 Apr 2026 08:06:05 +0000 (10:06 +0200)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Tue, 12 May 2026 13:52:01 +0000 (15:52 +0200)
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>
cmd/part.c
doc/usage/cmd/part.rst

index 5e520d707f39b4d21171a62063da5f57c8b7b858..3191d5861fdb910cdd1740218f0ccba3e4700e0a 100644 (file)
@@ -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"
index b91f6541f7f867f46f71f558bba3f008c9089d44..a0e7be08a9ab21968d93bf9b9f13a595daab7edc 100644 (file)
@@ -52,7 +52,7 @@ The 'part list' command prints or sets an environment variable to the list of pa
         an optional environment variable to store the list of partitions value into.
 
 The 'part start' command sets an environment variable to the start of the partition (in blocks),
-part can be either partition number or partition name.
+part can be either partition number, partition UUID or partition name.
 
     interface
         interface for accessing the block device (mmc, sata, scsi, usb, ....)
@@ -64,7 +64,7 @@ part can be either partition number or partition name.
         a variable to store the current start of the partition value into.
 
 The 'part size' command sets an environment variable to the size of the partition (in blocks),
-part can be either partition number or partition name.
+part can be either partition number, partition UUID or partition name.
 
     interface
         interface for accessing the block device (mmc, sata, scsi, usb, ....)
@@ -76,7 +76,7 @@ part can be either partition number or partition name.
         a variable to store the current size of the partition value into.
 
 The 'part number' command sets an environment variable to the partition number using the partition name,
-part must be specified as partition name.
+part must be specified as partition UUID or partition name.
 
     interface
         interface for accessing the block device (mmc, sata, scsi, usb, ....)