我正在实现一个字符驱动程序。所以我正在注册文件操作。当我注册read功能时,我以这种方式提取minor数字
myread(struct file * file, char __user * ubuf, size_t lbuf, loff_t *offset)
{
int minor;
minor = MINOR(file->f_path.dentry->d_inode->f_pos->i_rdev);
.......
这条规则也适用于open调用。
myopen(struct inode * inode, struct file * file)
struct file定义有参考struct inode。所以一个论点就足够了open。
我的问题是:
- 为什么
open有两个论点?(或)为什么read不struct inode *争论? - 为了在
read通话中提取次要号码,我使用了上面的指令。为了找到定义和头文件,我花了 1 小时 30 分钟。有什么简单的方法可以找到结构的定义吗? - 有多少种方法可以找到
struct inodethrough的参考,struct file最好的方法是什么?