From 018346770b04e32caf75d5730301f3ba52ed005f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 26 Aug 2023 03:53:41 +0200 Subject: cmd: fix gpt setenv Do not assume that partitions are continuously numbered starting at 1. Having a partition table with a single partition 63 is valid. Fixes: 12fc1f3bb223 ("cmd: gpt: add eMMC and GPT support") Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- cmd/gpt.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'cmd/gpt.c') diff --git a/cmd/gpt.c b/cmd/gpt.c index 007a68eaa72..d0e165d5394 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -786,10 +786,8 @@ static int gpt_setenv(struct blk_desc *desc, const char *name) for (i = 1; i < part_drv->max_entries; i++) { ret = part_drv->get_info(desc, i, &pinfo); - if (ret) { - /* no more entries in table */ - break; - } + if (ret) + continue; if (!strcmp(name, (const char *)pinfo.name)) { /* match found, setup environment variables */ -- cgit v1.2.3 From 41cd23b7be6e097daa5c2b1eda5539de227bf745 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 26 Aug 2023 03:53:42 +0200 Subject: cmd: fix gpt enumerate Do not assume that partitions are numbered continuously starting at 1. Only a single partition table type can exist on a block device. If we found a GPT partition table, we must not re-enumerate with the MBR partition driver which would find the protective partition. Fixes: 12fc1f3bb223 ("cmd: gpt: add eMMC and GPT support") Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- cmd/gpt.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'cmd/gpt.c') diff --git a/cmd/gpt.c b/cmd/gpt.c index d0e165d5394..99ca0a61630 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -691,12 +691,13 @@ static int gpt_enumerate(struct blk_desc *desc) int ret; int i; + if (part_drv->test(desc)) + continue; + for (i = 1; i < part_drv->max_entries; i++) { ret = part_drv->get_info(desc, i, &pinfo); - if (ret) { - /* no more entries in table */ - break; - } + if (ret) + continue; ptr = &part_list[str_len]; tmp_len = strlen((const char *)pinfo.name); @@ -711,9 +712,10 @@ static int gpt_enumerate(struct blk_desc *desc) /* One byte for space(" ") delimiter */ ptr[tmp_len] = ' '; } + if (*part_list) + part_list[strlen(part_list) - 1] = 0; + break; } - if (*part_list) - part_list[strlen(part_list) - 1] = 0; debug("setenv gpt_partition_list %s\n", part_list); return env_set("gpt_partition_list", part_list); -- cgit v1.2.3 From eeef584015209cd8f23d438f8a29e8065838d34f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 26 Aug 2023 03:53:43 +0200 Subject: cmd: let gpt_partition_entry be hexadecimal In commands like 'ls mmc 0:f' the partition number is hexadecimal. In command 'gpt setenv' variable gpt_partition_entry needs to be set to a hexadecimal value to allow its use as a parameter in a subsequent command. Fixes: 57f8cf1b9aea ("cmd: fix gpt enumerate") Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- cmd/gpt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd/gpt.c') diff --git a/cmd/gpt.c b/cmd/gpt.c index 99ca0a61630..964056bd28b 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -744,7 +744,7 @@ static int gpt_setenv_part_variables(struct disk_partition *pinfo, int i) if (ret) goto fail; - ret = env_set_ulong("gpt_partition_entry", i); + ret = env_set_hex("gpt_partition_entry", i); if (ret) goto fail; -- cgit v1.2.3 From 1fa11cdcfebe7f2477ad383971b5abbe3525a015 Mon Sep 17 00:00:00 2001 From: Joshua Watt Date: Thu, 31 Aug 2023 10:51:34 -0600 Subject: cmd: gpt: Remove confusing help text This help text appears to be a fragment of the text shown when CONFIG_CMD_GPT_RENAME is enabled, but is confusing so remove it. Signed-off-by: Joshua Watt Reviewed-by: Heinrich Schuchardt --- cmd/gpt.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'cmd/gpt.c') diff --git a/cmd/gpt.c b/cmd/gpt.c index 964056bd28b..fe9e06681ce 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -1060,8 +1060,6 @@ U_BOOT_CMD(gpt, CONFIG_SYS_MAXARGS, 1, do_gpt, " gpt_partition_name, gpt_partition_entry\n" " gpt enumerate mmc 0\n" " - store list of partitions to gpt_partition_list environment variable\n" - " read \n" - " - read GPT into a data structure for manipulation\n" " gpt guid \n" " - print disk GUID\n" " gpt guid \n" -- cgit v1.2.3