Monday, May 31, 2010

Forcing Block Devices to Re-Read Partitions Using IOCTL

Got a block device in module that stubbornly refuses to produce dependent partition devices in Linux? (Looking at you, NBD..)


#include <fcntl.h>
#include <sys/mount.h>

int main( int argc, char** argv ){
if( argc != 2 ) return -1;
int f = open( argv[1], O_RDONLY );
if( f < 1 ) return -2;
return ioctl( f, BLKRRPART );
}


That or you could just sleep for a while, checking for the existence of /dev/nbdXpX -- but I am an impatient bastard..

No comments:

Post a Comment