我正在学习字符设备驱动编程。我有一些疑惑,并希望在这里澄清它们: -字符设备驱动编程
(a)“设备文件与主号码和次号码相关联,而且在我们的驱动程序模块中,我们定义了一个定义了fops字段的cdev对象根据我们的功能和相同的主要和次要的数字作为我们的设备文件。“
1. I want to know what exactly happens when a function is called on the device file.
Here is what I think. Suppose, I make a file called mydevfile using mknod(). Now
when I call open(mydevfile, O_RDWR), the kernel is searched for a cdev object with
same minor and major number. When found, the cdev 's fops is searched for function
for open() (say dev_open()). It is written that the dev_open() should have first
argument inode* and second argument file*. My question is how are these parameters
passed to the dev_open() function?
2. I learnt that inode is associated with a file on disk. Which file is it associated
with here? Also inode has a pointer to corresponding cdev. Now if we have already
got the cdev by searching major and minor number from mydevfile, why do we need
inode? W
3. What does the file*(i.e. the second argument) point to in this case?
但你可以在你的首选方式来解释这一点,但我宁愿如果你可以用一个例子来解释它。谢谢!