[parted-devel] [PATCH] Fix gpt end of disk handling

Jim Meyering jim at meyering.net
Tue Jan 3 15:38:11 UTC 2012


Phillip Susi wrote:
> On 1/3/2012 3:03 AM, Jim Meyering wrote:
>> Thanks for the patch.  I like the sound of it.
>> Would you please write a NEWS entry for it?
>> Also, this will require a test to exercise the new behavior.
>
> I'm a little unsure how to write such a test.  Testing the grown disk
> part is easy, but testing the backup in the wrong place part requires
> manually munging the backup location.  I suppose I could intentionally
> break parted and use it to build a hand crafted image file to test on,
> but I don't see a directory with pre-created images for testing.
> Would this be acceptable?

The trick to munging anything in a GPT header is to be able to
recalculate the checksum, once you've poked in a new value.
I did that for a few different entries in tests/gpt-header-munge.
Given a new backup LBA sector number that you want to insert,
use a function like its poke_n_pe:

  sub poke_n_pe ($$)
  {
    my ($buf, $n_pe) = @_;

    # Poke the little-endian value into place.
    substr ($$buf, 80, 4) = pack ('L<', $n_pe);
  }

Just adapt for the offset/size of the backup LBA:

  sub poke_backup_LBA ($$)
  {
    my ($buf, $b) = @_;
    substr ($$buf, 32, 8) = pack ('Q<', $b);
  }


>> Also, please run this in your parted clone directories,
>>
>>    git config format.signoff true

The above was wrong.
This is the command to run:

    git config format.signoff false

>> That arranges to suppress those Signed-off-by lines.
>> When you're the Author, an identical Signed-off-by line is just clutter.
>
> I always thought so too, but the guys on lkml want it as some sort of
> indicator that yes, you're ok with the code being gpl ( I'm submitting
> a patch aren't I? ), so I got in the habit of adding -s to
> format-patch. I'll not bother from now on for parted.



More information about the parted-devel mailing list