Mr *_*nky 7 linux driver linux-device-driver linux-kernel
我正在实现一个Linux字符设备驱动程序.
linux/fs.h头文件列出了没有参数名称的file_operations.
例如
struct file_operations {
struct module *owner;
loff_t (*llseek) (struct file *, loff_t, int);
ssize_t (*read) (struct file *, char __user *, size_t, loff_t *);
ssize_t (*write) (struct file *, const char __user *, size_t, loff_t *);
ssize_t (*aio_read) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
ssize_t (*aio_write) (struct kiocb *, const struct iovec *, unsigned long, loff_t);
int (*readdir) (struct file *, void *, filldir_t);
unsigned int (*poll) (struct file *, struct poll_table_struct *);
long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
int (*mmap) (struct file *, struct vm_area_struct *);
int (*open) (struct inode *, struct file *);
int (*flush) (struct file *, fl_owner_t id);
int (*release) (struct inode *, struct file *);
int (*fsync) (struct file *, loff_t, loff_t, int datasync);
int (*aio_fsync) (struct kiocb *, int datasync);
int (*fasync) (int, struct file *, int);
int (*lock) (struct file *, int, struct file_lock *);
ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int);
unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
int (*check_flags)(int);
int (*flock) (struct file *, int, struct file_lock *);
ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int);
ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int);
int (*setlease)(struct file *, long, struct file_lock **);
long (*fallocate)(struct file *file, int mode, loff_t offset,
loff_t len);
};
Run Code Online (Sandbox Code Playgroud)
文档在哪里告诉我每个参数是什么?有些是显而易见的,但有些则不是.如果可以,我更愿意参考官方文档,但我找不到它.
例如
int (*fsync) (struct file *, loff_t, loff_t, int datasync);
Run Code Online (Sandbox Code Playgroud)
有两个loff_t参数.我怎么知道他们做了什么?
我一直在谷歌搜索和阅读设备驱动程序书,但我找不到任何文件来解释争论的内容.从编写LDD3开始,一些论点也发生了变化.
LDD3书籍对于了解大局非常有用,但它对细节没有帮助(对于内核2.6.10,同时我们正在向3.9迈进).该kernelnewbies司机页面也许是最先进的最新,全面的资源.对于日常更改,LWN会定期评估API更改并发布更长时间的新功能概述.H-online包含一系列文章,详细介绍了从内核版本到内核版本的更改,以及指向讨论和补丁的链接.