diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2015-01-05 18:13:37 +0100 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2015-01-29 13:36:54 -0500 |
commit | e86df6ef4f392879c0654e91e6c94801911491a9 (patch) | |
tree | baddd47e21363660f630f10e248d64d9dd02a99e | |
parent | 1a1ad8e0903ec916d1e3ef8c18fa335d765a4342 (diff) |
part: let list put the list in an environment variable
Add an optional third argument to the "part list" command which puts a
space seperated list of valid partitions into the given environment
variable. This is useful for allowing boot scripts to iterate of all
partitions of a device.
Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Reviewed-by: Stephen Warren <swarren@nvidia.com>
-rw-r--r-- | common/cmd_part.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/common/cmd_part.c b/common/cmd_part.c index 39e8666b77..c99f52735f 100644 --- a/common/cmd_part.c +++ b/common/cmd_part.c @@ -54,13 +54,31 @@ static int do_part_list(int argc, char * const argv[]) int ret; block_dev_desc_t *desc; - if (argc != 2) + if (argc < 2 || argc > 3) return CMD_RET_USAGE; ret = get_device(argv[0], argv[1], &desc); if (ret < 0) return 1; + if (argc == 3) { + int p; + char str[512] = { 0, }; + disk_partition_t info; + + for (p = 1; p < 128; p++) { + int r = get_partition_info(desc, p, &info); + + if (r == 0) { + char t[5]; + sprintf(t, "%s%d", str[0] ? " " : "", p); + strcat(str, t); + } + } + setenv(argv[2], str); + return 0; + } + print_part(desc); return 0; @@ -87,5 +105,7 @@ U_BOOT_CMD( "part uuid <interface> <dev>:<part> <varname>\n" " - set environment variable to partition UUID\n" "part list <interface> <dev>\n" - " - print a device's partition table" + " - print a device's partition table\n" + "part list <interface> <dev> <varname>\n" + " - set environment variable to the list of partitions" ); |