Joel Granados Moreno <[email protected]> writes: > * libparted/labels/gpt.c (_parse_header()) : The problem is that > last_usable_if_grown and last_usable_min_default should be both CPU > format, but last_usable_if_grown is converted to LE64. Patch taken from > parted mailing list, author (petr.uzel at suse.cz). > --- > libparted/labels/gpt.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c > index ae74123..df7a597 100644 > --- a/libparted/labels/gpt.c > +++ b/libparted/labels/gpt.c > @@ -676,10 +676,10 @@ _parse_header (PedDisk* disk, > GuidPartitionTableHeader_t* gpt, > */ > > last_usable_if_grown > - = PED_CPU_TO_LE64 (disk->dev->length - 2 - > + = disk->dev->length - 2 - > ((PedSector)(PED_LE32_TO_CPU(gpt->NumberOfPartitionEntries)) * > (PedSector)(PED_LE32_TO_CPU(gpt->SizeOfPartitionEntry)) / > - disk->dev->sector_size)); > + disk->dev->sector_size); > > last_usable_min_default = disk->dev->length - 2 - > GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / disk->dev->sector_size;
Ok, I see now that the existing gpt tests might already cover this case when run on a big-endian system. I've adjusted the patch not to remove parentheses (generally good to keep around multi-line expressions so automatic indenters can do the right thing). Of course, they're not much use right now, but I'm optimistic. Also adjusted the commit log. Petr, let me know if this is ok with you, and I'll push it. >From 9685f8ffa7f39700426fd099298a228b426e4a56 Mon Sep 17 00:00:00 2001 From: Petr Uzel <[email protected]> Date: Fri, 20 Feb 2009 14:52:39 +0100 Subject: [PATCH] gpt: avoid failed assertion on big-endian systems * libparted/labels/gpt.c (_parse_header): Compute last_usable_if_grown not as an LE64 value but as a CPU-format one, since we're about to compare it to another. --- libparted/labels/gpt.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c index ae74123..90e5068 100644 --- a/libparted/labels/gpt.c +++ b/libparted/labels/gpt.c @@ -676,7 +676,7 @@ _parse_header (PedDisk* disk, GuidPartitionTableHeader_t* gpt, */ last_usable_if_grown - = PED_CPU_TO_LE64 (disk->dev->length - 2 - + = (disk->dev->length - 2 - ((PedSector)(PED_LE32_TO_CPU(gpt->NumberOfPartitionEntries)) * (PedSector)(PED_LE32_TO_CPU(gpt->SizeOfPartitionEntry)) / disk->dev->sector_size)); -- 1.6.2.rc1.241.g7bf82 _______________________________________________ parted-devel mailing list [email protected] http://lists.alioth.debian.org/mailman/listinfo/parted-devel

