Bug#237410: [Parted-maintainers] Bug#237410: Bug#262868: still a problem

Sven Luther Sven Luther <sven.luther@wanadoo.fr>, 237410@bugs.debian.org
Mon, 20 Dec 2004 01:05:39 +0100


CCing Andrew and the parted upstream devel list. Andrew, this is a debian bug
report (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=237410), which i am
investigating right now.

On Tue, Dec 14, 2004 at 08:35:30PM +0200, Anton Zinoviev wrote:
> On Mon, Dec 13, 2004 at 06:10:16PM +0100, Sven Luther wrote:
> > > This week I will send you a simple program to check if the problem
> > > exists.  I can be used on every platform (not only sun).
> > 
> > Ok, thanks. I will have a look.
> 
> It is attached:

I had a quick look at this and the there is a fundamental flaw in the below
program, not sure if it is worked around or not by the fuzzy partition
geometry logic.

The sun partition geometry constrain code shows : 

        SunDiskData*    disk_data = disk->disk_specific;
        PedSector       block = dev->sectors * dev->heads;

        if (!ped_alignment_init (&start_align, 0, block))
                return NULL;
        if (!ped_alignment_init (&end_align, -1, block))
                return NULL;
        if (!ped_geometry_init (&max_geom, dev, 0, disk_data->length))
                return NULL;

        return ped_constraint_new (&start_align, &end_align, &max_geom,
                                   &max_geom, 1, dev->length);

Where the end_align constraint is used only for the strict version, and
removed if it doesn't work.

What this means is :

  1) The sun partition needs to be aligned on cylinder (called blocks here)
     boundaries, it should start at the first sector of a cylinder and end at
     the last of it, if possible.

  => your code as a device which defaults to a geometry of CHS= 800,4,32,
     thus needing partitions on cylinders of 160 sectors boundaries. 1-10 is
     no such geometry, but 0-159 or 160-319 is, but this doesn'y seem to
     change anything to the result below.

  2) data from the disk is used in two occasions in the above code. In one
     form, it is the dev->CHS stuff, and the other is dev->length. The second
     place  where this happens is disk_data->length, which reads the
     disk_specific sun partition table, either from disk or from the raw
     partition.

Not yet found the problem, but hoping that CCing upstream will help, and will
be searching more later on.

> $ dd count=100k if=/dev/zero of=sundisk 
> 102400+0 records in
> 102400+0 records out
> 52428800 bytes transferred in 1.383157 seconds (37905169 bytes/sec)
> $ cc -lparted -ldl suntest.c
> $ ./a.out sundisk 
> Error: Can't have the end before the start!
> Error: Can't have the end before the start!
> Error: Unable to satisfy all constraints on the partition.
> 
> There are no problems if another label type is used instead of "sun".
> 
> Anton Zinoviev
> 

> #include <parted/parted.h>
> 
> #define TYPE "sun"
> 
> int
> main(int argc, char *argv[])
> {
>         PedDevice *dev;
>         PedDiskType *type;
>         PedDisk *disk;
>         PedFileSystemType *fs_type;
>         PedPartition *part;
>         PedConstraint *constraint;
> 
>         dev = ped_device_get(argv[1]);
>         type = ped_disk_type_get(TYPE);
>         disk = ped_disk_new_fresh(dev, type);
>         fs_type = ped_file_system_type_get("ext3");
>         part = ped_partition_new(disk, PED_PARTITION_NORMAL, fs_type, 1, 10);
>         constraint = ped_constraint_any(dev);
>         ped_disk_add_partition(disk, part, constraint);
> 
>         return 0;
> }

Friendly,

Sven Luther