Recently, while I was writing a dummy character devices, one of my friends asked me this question “If I register a character device to the same major number, is it possible for me to identify the major number and minor of the node during file_operations”. After researching a bit, I saw a solution to it. I could do it using the dentry structure in struct file. For reference I will paste the code here :
struct dentry * dentry = f->f_path.dentry;
struct inode * p_inode = dentry->d_inode;
minor_number = iminor(p_inode);
PS : Please suggest me alternate or better ways and point out any errors.
Originally Posted on Sysbyte Technologies.