[parted-devel] keeping partitions in disk order

Andrew Gaffney agaffney at gentoo.org
Mon Aug 28 04:14:49 UTC 2006


Andrew Gaffney wrote:
> Andrew Gaffney wrote:
>> leslie.polzer at gmx.net wrote:
>>> Sorry for letting you both wait so long.  A lot of things have
>>> backlogged during my absence in August and full-time work in July.
>>>
>>>   Try calling ped_disk_enumerate_partitions() after the operation
>>> and see whether it does what you want.
>>
>> What exactly does this function do? There doesn't appear to be a 
>> wrapper function in pyparted for it, which means that I can't really 
>> test it. If it does do exactly what I want, I'll try requesting its 
>> addition with pyparted upstream :)
> 
> Looking at the parted code, this function is currently only called at 
> the end of ped_disk_remove_partition(), so it stands to reason that it's 
> designed to "fill in holes" in the numbering scheme when a partition is 
> removed. Will this function also work as-is to rearrange the partition 
> numbers so that they match physical disk order? From what I can 
> understand of ped_disk_enumerate_partitions() and 
> _partition_enumerate(), it does not seem so. Please correct me if I'm 
> wrong :P

I traced the code down even farther to msdos_partition_enumerate() in 
libparted/labels/dos.c. I found the following code:

         /* don't re-number a primary partition */
         if (part->num != -1 && part->num <= 4)
                 return 1;

Looking around, I found something similar in sun_partition_enumerate() in 
libparted/labels/sun.c:

         /* never change the partition numbers */
         if (part->num != -1)
                 return 1;

Anyone know why these are here?

-- 
Andrew Gaffney                            http://dev.gentoo.org/~agaffney/
Gentoo Linux Developer                                   Installer Project



More information about the parted-devel mailing list