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