Message ID | 1544634754-3435-2-git-send-email-ruslan.trofymenko@linaro.org |
---|---|
State | Accepted |
Commit | be683756f620349966e0ebb4a5e02e5ff03c8a8e |
Headers | show |
Series | android: Implement A/B boot process | expand |
Reviewed-by: Igor Opaniuk <igor.opaniuk@linaro.org> On Wed, 12 Dec 2018 at 19:12, Ruslan Trofymenko <ruslan.trofymenko@linaro.org> wrote: > > This sub-command serves for getting the partition index from > partition name. Also it can be used to test the existence of specified > partition. > > Signed-off-by: Ruslan Trofymenko <ruslan.trofymenko@linaro.org> > Reviewed-by: Alistair Strachan <astrachan@google.com> > Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org> > Reviewed-by: Simon Glass <sjg@chromium.org> > --- > Changes in v2: None > > cmd/part.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/cmd/part.c b/cmd/part.c > index bfb6488..653e13c 100644 > --- a/cmd/part.c > +++ b/cmd/part.c > @@ -24,6 +24,7 @@ > enum cmd_part_info { > CMD_PART_INFO_START = 0, > CMD_PART_INFO_SIZE, > + CMD_PART_INFO_NUMBER > }; > > static int do_part_uuid(int argc, char * const argv[]) > @@ -149,6 +150,9 @@ static int do_part_info(int argc, char * const argv[], enum cmd_part_info param) > case CMD_PART_INFO_SIZE: > snprintf(buf, sizeof(buf), LBAF, info.size); > break; > + case CMD_PART_INFO_NUMBER: > + snprintf(buf, sizeof(buf), "%d", part); > + break; > default: > printf("** Unknown cmd_part_info value: %d\n", param); > return 1; > @@ -172,6 +176,11 @@ static int do_part_size(int argc, char * const argv[]) > return do_part_info(argc, argv, CMD_PART_INFO_SIZE); > } > > +static int do_part_number(int argc, char * const argv[]) > +{ > + return do_part_info(argc, argv, CMD_PART_INFO_NUMBER); > +} > + > static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) > { > if (argc < 2) > @@ -185,6 +194,8 @@ static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) > return do_part_start(argc - 2, argv + 2); > else if (!strcmp(argv[1], "size")) > return do_part_size(argc - 2, argv + 2); > + else if (!strcmp(argv[1], "number")) > + return do_part_number(argc - 2, argv + 2); > > return CMD_RET_USAGE; > } > @@ -206,5 +217,8 @@ U_BOOT_CMD( > " part can be either partition number or partition 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" > + " part can be either partition number or partition 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" > ); > -- > 2.7.4 >
diff --git a/cmd/part.c b/cmd/part.c index bfb6488..653e13c 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -24,6 +24,7 @@ enum cmd_part_info { CMD_PART_INFO_START = 0, CMD_PART_INFO_SIZE, + CMD_PART_INFO_NUMBER }; static int do_part_uuid(int argc, char * const argv[]) @@ -149,6 +150,9 @@ static int do_part_info(int argc, char * const argv[], enum cmd_part_info param) case CMD_PART_INFO_SIZE: snprintf(buf, sizeof(buf), LBAF, info.size); break; + case CMD_PART_INFO_NUMBER: + snprintf(buf, sizeof(buf), "%d", part); + break; default: printf("** Unknown cmd_part_info value: %d\n", param); return 1; @@ -172,6 +176,11 @@ static int do_part_size(int argc, char * const argv[]) return do_part_info(argc, argv, CMD_PART_INFO_SIZE); } +static int do_part_number(int argc, char * const argv[]) +{ + return do_part_info(argc, argv, CMD_PART_INFO_NUMBER); +} + static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { if (argc < 2) @@ -185,6 +194,8 @@ static int do_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return do_part_start(argc - 2, argv + 2); else if (!strcmp(argv[1], "size")) return do_part_size(argc - 2, argv + 2); + else if (!strcmp(argv[1], "number")) + return do_part_number(argc - 2, argv + 2); return CMD_RET_USAGE; } @@ -206,5 +217,8 @@ U_BOOT_CMD( " part can be either partition number or partition 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" + " part can be either partition number or partition 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" );