All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kever Yang <kever.yang@rock-chips.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] cmd: gpt: fix the wrong size parse for the last partition
Date: Thu, 04 Aug 2016 11:37:50 +0800	[thread overview]
Message-ID: <57A2B88E.2000309@rock-chips.com> (raw)
In-Reply-To: <1469761938-1728-1-git-send-email-kever.yang@rock-chips.com>

Hi Michael,

     Do you think this patch is necessary?

Thanks,
-Kever
On 07/29/2016 11:12 AM, Kever Yang wrote:
> The calculation of "dev_desc->lba - 34  - 1 - offset" is not correct for
> size '-', because both fist_usable_lba and last_usable_lba will remain
> 34 sectors.
>
> We can simply use 0 for size '-' because the part_efi module will decode
> the size and auto extend the size to maximum available size.
>
> Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
> ---
>
> Changes in v2:
> - fix gpt verify error, do not check the extend partition size
>
>   cmd/gpt.c       | 4 ++--
>   disk/part_efi.c | 4 ++++
>   2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/cmd/gpt.c b/cmd/gpt.c
> index 3d9706b..897596a 100644
> --- a/cmd/gpt.c
> +++ b/cmd/gpt.c
> @@ -298,8 +298,8 @@ static int set_gpt_info(struct blk_desc *dev_desc,
>   		if (extract_env(val, &p))
>   			p = val;
>   		if ((strcmp(p, "-") == 0)) {
> -			/* remove first usable lba and last block */
> -			parts[i].size = dev_desc->lba - 34  - 1 - offset;
> +			/* Let part efi module to auto extend the size */
> +			parts[i].size = 0;
>   		} else {
>   			size_ll = ustrtoull(p, &p, 0);
>   			parts[i].size = lldiv(size_ll, dev_desc->blksz);
> diff --git a/disk/part_efi.c b/disk/part_efi.c
> index 0af1e92..4566cab 100644
> --- a/disk/part_efi.c
> +++ b/disk/part_efi.c
> @@ -655,6 +655,10 @@ int gpt_verify_partitions(struct blk_desc *dev_desc,
>   		      (unsigned long long)partitions[i].size);
>   
>   		if (le64_to_cpu(gpt_part_size) != partitions[i].size) {
> +			/* We do not check the extend partition size */
> +			if ((i == parts - 1) && (partitions[i].size == 0))
> +				continue;
> +
>   			error("Partition %s size: %llu does not match %llu!\n",
>   			      efi_str, (unsigned long long)gpt_part_size,
>   			      (unsigned long long)partitions[i].size);

  reply	other threads:[~2016-08-04  3:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-29  3:12 [U-Boot] [PATCH v2] cmd: gpt: fix the wrong size parse for the last partition Kever Yang
2016-08-04  3:37 ` Kever Yang [this message]
2016-08-04  4:56   ` Michael Trimarchi
2016-08-06  1:00 ` [U-Boot] [U-Boot, " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57A2B88E.2000309@rock-chips.com \
    --to=kever.yang@rock-chips.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.