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. Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
This commit is contained in:
parent
584550d76a
commit
c2fdd34569
|
@ -298,8 +298,8 @@ static int set_gpt_info(struct blk_desc *dev_desc,
|
||||||
if (extract_env(val, &p))
|
if (extract_env(val, &p))
|
||||||
p = val;
|
p = val;
|
||||||
if ((strcmp(p, "-") == 0)) {
|
if ((strcmp(p, "-") == 0)) {
|
||||||
/* remove first usable lba and last block */
|
/* Let part efi module to auto extend the size */
|
||||||
parts[i].size = dev_desc->lba - 34 - 1 - offset;
|
parts[i].size = 0;
|
||||||
} else {
|
} else {
|
||||||
size_ll = ustrtoull(p, &p, 0);
|
size_ll = ustrtoull(p, &p, 0);
|
||||||
parts[i].size = lldiv(size_ll, dev_desc->blksz);
|
parts[i].size = lldiv(size_ll, dev_desc->blksz);
|
||||||
|
|
|
@ -655,6 +655,10 @@ int gpt_verify_partitions(struct blk_desc *dev_desc,
|
||||||
(unsigned long long)partitions[i].size);
|
(unsigned long long)partitions[i].size);
|
||||||
|
|
||||||
if (le64_to_cpu(gpt_part_size) != 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",
|
error("Partition %s size: %llu does not match %llu!\n",
|
||||||
efi_str, (unsigned long long)gpt_part_size,
|
efi_str, (unsigned long long)gpt_part_size,
|
||||||
(unsigned long long)partitions[i].size);
|
(unsigned long long)partitions[i].size);
|
||||||
|
|
Loading…
Reference in New Issue