[U-Boot] [PATCH v6 3/3] GPT: provide commands to selectively rename partitions

Wolfgang Denk wd at denx.de
Mon Jun 12 07:45:57 UTC 2017


Dear Alison,

In message <1497137617-772-1-git-send-email-alison at peloton-tech.com> you wrote:
> 
> This patch provides support in u-boot for renaming GPT
> partitions.  The renaming is accomplished via new 'gpt swap'
> and 'gpt rename' commands.

Thanks.

One question: can multiple GPT partitions have the same name?

> 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.

I see a problem here...

> +	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;
> +		}

You will never know if there really was a pair of names that was
swapped.  Just a single rename of name1->name2 _or_ of name2->name1
will make the user think everything was fine.

[Note: I'm in the process of relocating and will be offline for the
next 2..3. days.  Don't expect more comments from mee soon.
Sorry...]

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I dislike companies that have a we-are-the-high-priests-of-hardware-
so-you'll-like-what-we-give-you attitude. I like commodity markets in
which iron-and-silicon hawkers know that they exist to  provide  fast
toys for software types like me to play with..."    - Eric S. Raymond


More information about the U-Boot mailing list