Bdev->bd_disk is NULL @ initrd time

From: Block Device
Date: Thu Dec 15 2005 - 08:52:59 EST


Hi,

I have a problem running the following code snippet from a kernel module.

struct block_device *bdev=bdget(MKDEV(3,10));

if(!bdev){
printk(KERN_ALERT "NULL bdev.!!!\n");
return -1;
}

if(!bdev->bd_disk){
printk(KERN_ALERT "NULL bdev bd_disk.!!!\n");
return -1;
}
printk(KERN_ALERT "Diskname is %s.\n",bdev->bd_disk->disk_name);

When this module is inserted from initrd's init script ( after block
drivers are loaded ) bdev->bd_disk is always NULL. But when its
inserted after the system has booted it
works fine. Can someone please explain this behaviour ?.

I checked that the block devices are up by spawning a shell just after
this module is inserted from the init script. When I cat /proc/devices
the ide device shows up.

Thanks
-BD
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/