return 0;
}
+static int do_part_start(int argc, char * const argv[])
+{
+ block_dev_desc_t *desc;
+ disk_partition_t info;
+ char buf[512] = { 0 };
+ int part;
+ int err;
+ int ret;
+
+ if (argc < 3)
+ return CMD_RET_USAGE;
+ if (argc > 4)
+ return CMD_RET_USAGE;
+
+ part = simple_strtoul(argv[2], NULL, 0);
+
+ ret = get_device(argv[0], argv[1], &desc);
+ if (ret < 0)
+ return 1;
+
+ err = get_partition_info(desc, part, &info);
+ if (err)
+ return 1;
+
+ snprintf(buf, sizeof(buf), LBAF, info.start);
+
+ if (argc > 3)
+ setenv(argv[3], buf);
+ else
+ printf("%s\n", buf);
+
+ return 0;
+}
+
+static int do_part_size(int argc, char * const argv[])
+{
+ block_dev_desc_t *desc;
+ disk_partition_t info;
+ char buf[512] = { 0 };
+ int part;
+ int err;
+ int ret;
+
+ if (argc < 3)
+ return CMD_RET_USAGE;
+ if (argc > 4)
+ return CMD_RET_USAGE;
+
+ part = simple_strtoul(argv[2], NULL, 0);
+
+ ret = get_device(argv[0], argv[1], &desc);
+ if (ret < 0)
+ return 1;
+
+ err = get_partition_info(desc, part, &info);
+ if (err)
+ return 1;
+
+ snprintf(buf, sizeof(buf), LBAF, info.size);
+
+ if (argc > 3)
+ setenv(argv[3], buf);
+ else
+ printf("%s\n", buf);
+
+ return 0;
+}
+
static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
if (argc < 2)
return do_part_uuid(argc - 2, argv + 2);
else if (!strcmp(argv[1], "list"))
return do_part_list(argc - 2, argv + 2);
+ else if (!strcmp(argv[1], "start"))
+ return do_part_start(argc - 2, argv + 2);
+ else if (!strcmp(argv[1], "size"))
+ return do_part_size(argc - 2, argv + 2);
return CMD_RET_USAGE;
}
" - print a device's partition table\n"
"part list <interface> <dev> [flags] <varname>\n"
" - set environment variable to the list of partitions\n"
- " flags can be -bootable (list only bootable partitions)"
+ " 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 size <interface> <dev> <part> <varname>\n"
+ " - set environment variable to the size of the partition (in blocks)"
);