All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] cmd: gpt: fix the wrong size parse for the last partition
@ 2016-07-29  3:12 Kever Yang
  2016-08-04  3:37 ` Kever Yang
  2016-08-06  1:00 ` [U-Boot] [U-Boot, " Tom Rini
  0 siblings, 2 replies; 4+ messages in thread
From: Kever Yang @ 2016-07-29  3:12 UTC (permalink / raw)
  To: u-boot

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);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2] cmd: gpt: fix the wrong size parse for the last partition
  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
  2016-08-04  4:56   ` Michael Trimarchi
  2016-08-06  1:00 ` [U-Boot] [U-Boot, " Tom Rini
  1 sibling, 1 reply; 4+ messages in thread
From: Kever Yang @ 2016-08-04  3:37 UTC (permalink / raw)
  To: u-boot

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);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH v2] cmd: gpt: fix the wrong size parse for the last partition
  2016-08-04  3:37 ` Kever Yang
@ 2016-08-04  4:56   ` Michael Trimarchi
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Trimarchi @ 2016-08-04  4:56 UTC (permalink / raw)
  To: u-boot

Hi

On Aug 4, 2016 05:38, "Kever Yang" <kever.yang@rock-chips.com> wrote:
>
> Hi Michael,
>
>     Do you think this patch is necessary?
>

Yes, I have checked it and fix the regression. Today I will confirm on hot
correctness but I think too

Michael

> 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);
>
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [U-Boot, v2] cmd: gpt: fix the wrong size parse for the last partition
  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
@ 2016-08-06  1:00 ` Tom Rini
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Rini @ 2016-08-06  1:00 UTC (permalink / raw)
  To: u-boot

On Fri, Jul 29, 2016 at 11:12:18AM +0800, 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>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160805/bf7d5de4/attachment.sig>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-06  1:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2016-08-04  4:56   ` Michael Trimarchi
2016-08-06  1:00 ` [U-Boot] [U-Boot, " Tom Rini

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.