[parted-devel] some issues with ped_disk_commit_to_os()

Bart Hakvoort bart at hakvoort.be
Sun Sep 10 20:13:26 UTC 2006


Hi people,

As many of you probably know gparted uses libparted to create partitions
and CLI tools to create filesystems on them. While this works quite well
there has been a small problem since the beginning.
Whenever i call ped_disk_commit_to_os() (which in turn will call ioctl(int
fd, BLKRRPART) somewhere in the process) the devicenodes show up after a
small delay. This delay causes the CLItools to throw a 'device not found'
error every now and then. I've tried working with sync() and fsync(), but
without luck so far.
Till now i simply 'solved' this by sleeping a bit after the reread, but
this is not perfect and every now and then someone encounters this. Also i
wonder if there is a better way to solve this?

Below is a small, dirty piece of source that illustrates the problem. It's
only for illustration, so don't run it at home :P

#include <parted/parted.h>

int main()
{
        PedDevice *device = ped_device_get( "/dev/sda" );
        PedDisk *disk = ped_disk_new( device );

        ped_disk_commit_to_os( disk ) ;

        ped_disk_destroy( disk ) ;
        ped_device_destroy( device ) ;

        system( "mke2fs /dev/sda2" ) ; //<-- sometimes /dev/sda2 doesn't
exist yet!!

        return 0 ;
}

This will work most of the time, but sometimes (depending on a lot of
factors) it'll fail. Insights and ideas are appreciated!

thanks,

Bart


-- 
--- plors




More information about the parted-devel mailing list