[parted-devel] Progress about ipod issue (https://bugzilla.redhat.com/show_bug.cgi?id=212066)

Jim Meyering jim at meyering.net
Thu May 29 08:41:36 UTC 2008


Otavio Salvador <otavio at debian.org> wrote:
> I think I did some progress about the ipod issue.

Hi Otavio,
Thanks for looking into this.

> Adding the bug patch or the current proposed Colin's patch it fixes
> the label detection but fails due a bad geom. Looking at code, I found
> where it was doing a wrong thing...

Would you please explain (give examples with real numbers)
what was going wrong and how this change fixes it?

> diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
> index e513a05..0b11867 100644
> --- a/libparted/labels/dos.c
> +++ b/libparted/labels/dos.c
> @@ -378,9 +378,7 @@ linear_start (const PedDisk* disk, const DosRawPartition* raw_part,
>  	PED_ASSERT (disk != NULL, return 0);
>  	PED_ASSERT (raw_part != NULL, return 0);
>
> -	return offset
> -	       + PED_LE32_TO_CPU (raw_part->start)
> -	       	 	* (disk->dev->sector_size / 512);
> +	return offset + PED_LE32_TO_CPU (raw_part->start);
>  }
>
>  static PedSector
> @@ -391,8 +389,7 @@ linear_end (const PedDisk* disk, const DosRawPartition* raw_part,
>  	PED_ASSERT (raw_part != NULL, return 0);
>
>  	return linear_start (disk, raw_part, offset)
> -	       + (PED_LE32_TO_CPU (raw_part->length) - 1)
> -	       	 	* (disk->dev->sector_size / 512);
> +	       + (PED_LE32_TO_CPU (raw_part->length) - 1);
>  }
>
>  #ifndef DISCOVER_ONLY
>
> This provides right geom; code now has a segfault that I was unable to
> find. Any hint?

I presume you're trying to use a disk with sector_size > 512.  Converting
parted to work with such sector sizes is a big job, and will require
a significant widespread changes.  The typical failure I've seen while
addressing this sort of problem is a stack-smashing (tiresome to debug)
or heap-corrupting bug, because there are hard-coded 512-byte buffers
everywhere.  I've converted the code for a few partition table types
already, and posted an incomplete patch months ago, but haven't yet
returned to the task.  And until all partition table types are converted,
it's not really usable due to the way Parted probes using each type
until it finds one that works.

I hope to resume work on this in the next couple months,
but can't say for sure.



More information about the parted-devel mailing list