]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
cmd: gpt: fix the wrong size parse for the last partition
authorKever Yang <kever.yang@rock-chips.com>
Fri, 29 Jul 2016 03:12:18 +0000 (11:12 +0800)
committerTom Rini <trini@konsulko.com>
Sat, 6 Aug 2016 00:55:16 +0000 (20:55 -0400)
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>
cmd/gpt.c
disk/part_efi.c

index 3d9706b679c5c2ff8f6a2b2ce2fd0546c08b6470..897596a969f64c03d84eb42c1dfc26f87142d460 100644 (file)
--- 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);
index 01f71bee79e2656a295ee1cd3505185efc9c5cf7..8d67c09a43a22669af9e702114dc90f4a0d51fad 100644 (file)
@@ -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);