On Thu, Mar 01, 2012 at 12:58:13PM +0530, Pranay Kumar Srivastava wrote: > Hi, > > I've a kernel module which needs to get hold of the gen_disk > structure. Wait, stop there, why do you need to do this? And why are you trying to do this by a major/minor number? What is the root problem you are trying to solve here? > To make it a bit interactive I've a user space program which uses stat > sys call to get the respective device's dev_t number (I use s_rdev of > the struct stat) and pass it on to my module via an ioctl call. This > part works good. > > When my module tries to use the get_gendisk function it returns NULL. I printed out the MAJOR(dev_t) and MINOR(dev_t) and was surprised to get the value 0 for MAJOR(dev_t). A little more digging got me to this code snippet, the file is kdev_t.h As you have found out, you can't pass a userspace dev_t to the kernel and expect it to work properly. Try passing a major/minor number and using the proper internal macros instead, that should work. greg k-h _______________________________________________ Kernelnewbies mailing list Kernelnewbies@xxxxxxxxxxxxxxxxx http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies