[parted-devel] [PATCH] Properly sync partitions with operating system

Joel Granados jgranado at redhat.com
Fri Feb 20 10:56:25 UTC 2009


On Fri, Feb 20, 2009 at 11:24:10AM +0100, Joel Granados wrote:
> On Thu, Feb 19, 2009 at 07:01:33PM +0100, Jim Meyering wrote:
> > Joel Granados Moreno wrote:
> > > diff --git a/include/parted/disk.h b/include/parted/disk.h
> > > index dfcf39e..9e50716 100644
> > > --- a/include/parted/disk.h
> > > +++ b/include/parted/disk.h
> > > @@ -210,6 +210,7 @@ struct _PedDiskOps {
> > >          /* other */
> > >          int (*alloc_metadata) (PedDisk* disk);
> > >          int (*get_max_primary_partition_count) (const PedDisk* disk);
> > > +        int (*get_max_partition_count) (const PedDisk* disk);
> > >  };
> > >
> > >  struct _PedDiskType {
> > > @@ -322,7 +323,7 @@ extern PedPartition* ped_disk_extended_partition (const PedDisk* disk);
> > >  /* internal functions */
> > >  extern PedDisk* _ped_disk_alloc (const PedDevice* dev, const PedDiskType* type);
> > >  extern void _ped_disk_free (PedDisk* disk);
> > > -
> > > +extern int ped_disk_get_max_partition_num(const PedDisk* disk);
> > 
> > Thanks for working on this.
> > 
> > If the only values ever returned are non-negative (as it seems they are),
> > then it'd be far more readable to make the return type "unsigned int".
> > Otherwise, I have to wonder if some of these functions may return a
> > negative value, and write code in each caller to handle that.
> > 
> 
> Seems like a good idea.  And: No, they are supposed to be possitive
> values.  Note this will propagate into other elements of the patch as
> well.
> 

On the other hand, ped_disk_get_max_partition would need to return -1
when it encounters an error.  All possitive numbers can be valide to
express max_number_of_supported_partitions.  Including 0. So a negative
number would seem natural for me to use in this case.

 0: means that the label does no support partitions.
 <0: means the number of partitions
 >0: means something nasty has ocurred.

-- 
Joel Andres Granados
Brno, Czech Republic, Red Hat.



More information about the parted-devel mailing list