S
S
smithana2017-07-27 17:35:35
linux
smithana, 2017-07-27 17:35:35

How to find out MINOR device number in modern linux in kernel mode?

Good afternoon,
n-years ago I wrote a driver for a custom device for the then versions of Linux kernels.
Today I had to dust it off and run this driver on fresh Linux (Ubuntu 16).
But an error occurred during compilation:
struct file has no member f_dentry
It swears at the line where I get the minor device number:
minor = MINOR(filp->f_dentry->d_inode->i_rdev);
(filp is a struct file *filp)
Please tell me how to get the minor device number correctly now?
Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2017-07-28
@smithana

filp->f_path.dentry->d_inode->i_rdevinstead offilp->f_dentry->d_inode->i_rdev

V
Vladimir Zhurkin, 2017-07-27
@icCE

C, the /sys and /udev subsystems appeared, most device numbers are assigned dynamically at boot time. I think we need to look in the direction of udev and how it gets device numbers.
I'm not a developer myself, but I hope the links will help or lead to the right thoughts.
https://superuser.com/questions/686774/what-proble...
https://unix.stackexchange.com/questions/104836/ho...
https://unix.stackexchange.com/questions/315186/ ho...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question