Subject: Re: [PATCH] libparted: Check AlternateLBA against LBA-1

From: Phillip Susi <[email-masked]>
Date: Fri, 28 Mar 2014 13:31:18 -0400

On 3/28/2014 1:02 PM, Brian C. Lane wrote:
> No, this would still set the new end to gpt_disk_end which is the 
> calculation I was complaining about. You cannot assume that the PTE
> will start right after LastUsableLBA, you have to use the backup's 
> PartitionEntryLBA for any calculations related to that.

It doesn't assume the pte will start right after LastUsableLBA.  What
it does is to use LastUsableLBA to infer that AlternateLBA was
perfectly correct, before the disk was grown.

> When the new backup is written it *must* be written to
> disk->dev->length - 1, there is no flexibility there. And because
> the gpt_disk_data->data_area is initialized to the disk size it
> will automatically update the LastUsableLBA when it rewrites the
> headers.

There is flexibility here just as there is for LastUsableLBA.  If the
user chooses not to fix the table so things are where they should be,
then we need to respect that.

> With these changes are you trying to keep the backup at the wrong
> place AND change the LastUsableLBA? If so, that is incorrect
> behavior.

The purpose is to keep the backup where it is if the user says to
ignore the "error" and if the "error" is that the disk has grown, then
just say the disk has grown, without first complaining that the backup
is in the "wrong" place ( since it is in fact, in the right place if
you are going by the old size of the disk ).

In other words, if we know that the backup being in the wrong place is
purely a side effect of the disk growing, then don't treat it as a
separate error; it will be handled as part of the disk growing error.