On Sat, Jun 10, 2017 at 04:33:37PM -0700, ali...@peloton-tech.com wrote:
> From: Alison Chaiken <ali...@peloton-tech.com>
> 
> This patch provides support in u-boot for renaming GPT
> partitions.  The renaming is accomplished via new 'gpt swap'
> and 'gpt rename' commands.
> 
> The 'swap' mode prints a warning if no matching partition names
> are found.  If only one matching name of a provided pair is found, it
> renames the matching partitions to the new name.

So in the case where 'gpt swap partA partB' is used and partB doesn't
exist, it's the same as 'gpt rename partA partB' ?  That seems like it
might surprise users and I think if we changed:

> +     if (!strcmp(subcomm, "swap")) {
> +             if ((strlen(name1) > PART_NAME_LEN) || (strlen(name2) > 
> PART_NAME_LEN)) {
> +                     printf("Names longer than %d characters are 
> truncated.\n", PART_NAME_LEN);
> +                     return -EINVAL;
> +             }
> +             list_for_each(pos, &disk_partitions) {
> +                     curr = list_entry(pos, struct disk_part, list);
> +                     if (!strcmp((char *)curr->gpt_part_info.name, name1)) {
> +                             strcpy((char *)curr->gpt_part_info.name, name2);
> +                             changed++;
> +                     }
> +                     else if (!strcmp((char *)curr->gpt_part_info.name, 
> name2)) {
> +                             strcpy((char *)curr->gpt_part_info.name, name1);
> +                             changed++;
> +                     }
> +
> +             }
> +             if (changed == 0) {
> +                     printf("No matching partition names were found.\n");
> +                     return ret;
> +             }

We could also test for if changed == 1 and return an error.  I assume
that a GPT with the same name used more than one time is already
invalid, but we could be defensive here and test for != 2 instead.
Thanks!

-- 
Tom

Attachment: signature.asc
Description: Digital signature

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot

Reply via email to