cmd: gpt: fix the wrong size parse for the last partition
PATCH v2 1/1 cmd: gpt: fix the wrong size parse for the last partition
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.
---
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(-)
cmd/gpt.c +2 -2
@@ -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);
disk/part_efi.c +4 -0
@@ -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);
Signature · 1 line
1.9.1
PATCH v2 1/1 cmd: gpt: fix the wrong size parse for the last partition
Hi Michael,
Do you think this patch is necessary?
Thanks,
-Kever
Quoted 47 lines · Kever Yang
The calculation of "
dev_desc->lba- 34 - 1 - offset" is not correct for size '-', because bothfist_usable_lbaandlast_usable_lbawill remain 34 sectors.We can simply use 0 for size '-' because the
part_efimodule will decode the size and auto extend the size to maximum available size.Signed-off-by Kever Yang <[email protected]>---
Changes in v2:
- fix gpt verify error, do not check the extend partition sizecmd/gpt.c | 4 ++-- disk/part_efi.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-)cmd/gpt.c +2
-2@@ -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);disk/part_efi.c +4
-0@@ -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);
PATCH v2 1/1 cmd: gpt: fix the wrong size parse for the last partition
Hi
Quoted 5 lines · Kever Yang
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
Quoted 38 lines
Thanks,
-KeverQuoted 34 lines · Kever Yang
The calculation of "
dev_desc->lba- 34 - 1 - offset" is not correct for size '-', because bothfist_usable_lbaandlast_usable_lbawill remain 34 sectors.We can simply use 0 for size '-' because the
part_efimodule will decode the size and auto extend the size to maximum available size.Signed-off-by Kever Yang <[email protected]>---
Changes in v2:
- fix gpt verify error, do not check the extend partition sizecmd/gpt.c | 4 ++-- disk/part_efi.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-)cmd/gpt.c +2
-2@@ -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);disk/part_efi.c +0
-0
Quoted 8 lines
disk/part_efi.c int gpt_verify_partitions(struct blk_desc *dev_desc, · line 658
Quoted 8 lines
index 0af1e92..4566cab 100644
disk/part_efi.c +2
-0@@ -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))
Quoted 3 lines
disk/part_efi.c int gpt_verify_partitions(struct blk_desc *dev_desc,
Quoted 3 lines
disk/part_efi.c +2
-0+continue ; + error("Partition %s size: %llu does not match
%llu!\n",
Quoted 5 lines
Quoted 2 lines
disk/part_efi.c +0
-0efi_str, (unsigned long long )gpt_part_size, (unsigned long long)partitions[i].size);
PATCH v2 1/1 cmd: gpt: fix the wrong size parse for the last partition
In reply to Kever YangQuoted 8 lines · Kever Yang
The calculation of "
dev_desc->lba- 34 - 1 - offset" is not correct for size '-', because bothfist_usable_lbaandlast_usable_lbawill remain 34 sectors.We can simply use 0 for size '-' because the
part_efimodule will decode the size and auto extend the size to maximum available size.Signed-off-by Kever Yang <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
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>