linux驱动编写的三板斧:分配、设置和注册结构体。上一层面对的就是该结构体的成员,底层需分配、设置该结构体,并把该结构体注册到中间层的数组或者链表。
struct file_operations scull_fops = {
.owner = THIS_MODULE,
.llseek = scull_llseek,
.read = scull_read,
.write = scull_write,
.ioctl = scull_ioctl,
.open = scull_open,
.release = scull_release,
};
上面的例子是Linux Device Driver中抄来的示例代码。很好地展示了file operation结构体如何使用这种机制来定义一组文件操作的......
阅读全文