[U-Boot] [PATCH] cmd: gpt: fix the wrong size parse for the last partition

Michael Trimarchi
2016-07-26T09:08:31Z

Hi

On Tue, Jul 26, 2016 at 10:59 AM, Kever Yang <kever.yang@rock-chips.com> wrote:
> Hi Michael,
>
>
> On 07/26/2016 04:37 PM, Michael Trimarchi wrote:
>>
>> Hi
>>
>> On Tue, Jul 26, 2016 at 9:56 AM, Kever Yang <kever.yang@rock-chips.com>
>> 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>
>>> ---
>>>
>>> cmd/gpt.c | 4 ++--
>>> 1 file changed, 2 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;
>>
>> gpt verify give you success?
>
>
> Yes.
>
> I use below gpt table and "gpt write mmc 0 $partitions" command to do the
> test:
> #define PARTS_DEFAULT \
> "uuid_disk=${uuid_gpt_disk};" \
> "name=boot,size=32M,uuid=${uuid_gpt_boot};" \
> "name=rootfs,size=-,uuid=${uuid_gpt_rootfs};"
>
> Without this patch, I get message:
> => gpt write mmc 0 $partitions
> Writing GPT: Partitions layout exceds disk size
> error!
>
> After I apply this patch, I get below message:
> Writing GPT: success!
>

gpt read back does give you success?

Michael

> Thanks,
> - Kever
>
>
>>
>> Michael
>>
>>> } else {
>>> size_ll = ustrtoull(p, &p, 0);
>>> parts[i].size = lldiv(size_ll, dev_desc->blksz);
>>> --
>>> 1.9.1
>>>
>>>
>>
>>
>
>

--
| Michael Nazzareno Trimarchi Amarula Solutions BV |
| COO - Founder Cruquiuskade 47 |
| +31(0)851119172 Amsterdam 1018 AM NL |
| [`as] http://www.amarulasolutions.com |