I am learning Linux device driver and got stuck on the major, minor numbers. What I have so far is:
Devices are accessed through names in the file system. Those names are called as special files or device files or inodes of the file system.
And each of the device files are associated with the MAJOR and MINOR numbers bundled into a
dev_t
type.- These numbers are assigned to the device by the function
register_chrdev_region
Some of the Questions are yet troubling me...
- Does the
fops
structure is linked to thef_ops
field of file structure of the device file when we initialize device likecdev_init(&c_dev, &fops);
? - How does a call to
open("/dev/mydev", O_RONLY);
actually calls theopen()
function of the drivers. Does numbers comes in picture here to find the actual write method of device driver, if yes how? - The numbers, major is used to identify device driver and
minor to device file. What is the actual role of the the this numbers
when we perform operations on the device file like
open()
read()
write()
etc.?