[parted-devel] [PATCH] gpt: support padding between Partition Header and Partition Table.

Brian C. Lane bcl at redhat.com
Tue Mar 29 18:47:48 UTC 2016


On Mon, Mar 21, 2016 at 11:29:04AM -0700, Tzu-Jung Lee wrote:
> From: =Tzu-Jung Lee <roylee17 at currant.com>
> 
> Some SoC requires their booting code at a specific location, which
> might conflict with the default layout of GPT.
> 
> Supporting a specified PartitionEntryLBA is required in this case.

I'm generally ok with this as long as the normal behavior isn't changed.

I don't think we should have interactive UI for this. Pass it in as
'--pte-lba 2' only. 99% of parted users won't know or need to know what
this is.

I need to look at this a bit more to make sure PedDevice is the only
place to pass this around. So I'll reserve judgement on that bit for now
:)

It needs to default to 2 when allocating PedDevice so that libparted
users don't need to do anything new.

And there were a couple places where you don't actually need to change
things:


> -  data_start = 2 + GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / dev->sector_size;
> -  data_end = dev->length - 2
> +  data_start = dev->pte_lba + GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / dev->sector_size;
> +  data_end = dev->length - dev->pte_lba
>      - GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / dev->sector_size;

The end is still going to be the same, the -2 there is for the backup
GPT Header at the end of the disk.

>  
>    /* If the device is too small to accommodate GPT headers and one data
> @@ -743,14 +744,14 @@ _parse_header (PedDisk *disk, const GuidPartitionTableHeader_t *gpt,
>    last_usable = PED_LE64_TO_CPU (gpt->LastUsableLBA);
>  
>    /* Need to check whether the volume has grown, the LastUsableLBA is
> -     normally set to disk->dev->length - 2 - ptes_size (at least for parted
> -     created volumes), where ptes_size is the number of entries *
> +     normally set to disk->dev->length - disb->dev->pte_lba - ptes_size (at least 
> +     for parted created volumes), where ptes_size is the number of entries *
>       size of each entry / sector size or 16k / sector size, whatever the greater.
>       If the volume has grown, offer the user the chance to use the new
>       space or continue with the current usable area.  Only ask once per
>       parted invocation. */
>  
> -  last_usable_if_grown = disk->dev->length - 2 - _ptes_sectors(disk, gpt);
> +  last_usable_if_grown = disk->dev->length - disk->dev->pte_lba - _ptes_sectors(disk, gpt);

And the same here, this is all relative to the length of the disk and
can be left as-is.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)



More information about the parted-devel mailing list