[U-Boot] [PATCH v4 5/7] gpt: Support for GPT (GUID Partition Table) restoration

Stephen Warren swarren at wwwdotorg.org
Tue Nov 27 00:46:27 CET 2012


On 11/22/2012 05:16 AM, Lukasz Majewski wrote:
> Hi Piotr,
> 
>> Dear Stephen,
>>
>>> Stephen Warren  wrote at Monday, November 19, 2012 9:17 PM:
>>> On 11/09/2012 03:48 AM, Piotr Wilczek wrote:
>>>> The restoration of GPT table (both primary and secondary) is now possible.
>>>> Simple GUID generation is supported.

>>>> +void gpt_fill_header(block_dev_desc_t *dev_desc, gpt_header
>>>> *gpt_h)
>>>
>>>> +	gpt_h->first_usable_lba = cpu_to_le64(34);
>>>> +	gpt_h->last_usable_lba = cpu_to_le64(dev_desc->lba - 34);
>>>
>>> Is lba the number of LBAs or the last LBA number? include/part.h
>>> says its the number of LBAs, in which case I think that should be
>>> dev_desc-
>>>> lba - 1 - 34?
> 
> LBA is the number of blocks. So the addressable range is 0 to LBA-1.
> The last_usable_lba is calculated with following equation (it is
> similar with parted tool):
> 
> lba - 2 - ptes_size = lba -2 -32 = lba - 34
> 
> ptes_size = number_of_entries(128) * sizeof(pte_entry) (128) /
> sector_size (512) = 32

Ah right, I was forgetting that there is no protective MBR at the end of
the disk, so 1 less sector is used there.

>>>> +	s = getenv("uuid_gpt_disk");
>>>
>>> I'd rather not depend on environment variables; can't this be a
>>> command-line parameter to the gpt command?
> 
> I think, that the uuid_gpt_disk shall be added as another key=value to
> the partitions.
> 
> e.g. gpt
> uuid_gpt_disk=6aa01a70-349d-11e2-ae74-001fd09285c0;name=boot,size=100MiB,uuid=xx;name=kernel,
> size=200MiB,uuid=yy;....

I guess that'd work. Note that means the calculation of # of partitions
based on counting the # of ; different. Perhaps a separate command-line
argument would be simpler?



More information about the U-Boot mailing list