Kernel

核心 4.1 中更改了文件操作 aio_read

  • February 17, 2020

我有一個我維護的驅動程序,我需要使用 Linux 標頭檔 4.1.21 對其進行編譯,但我得到了 , 的編譯錯誤aio_readaio_write它們從 中失去struct file_operations,我假設它們已被替換。

我如何找出替代品是什麼?

fs.h在核心 4.0中有:

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);
ssize_t (*read_iter) (struct kiocb *, struct iov_iter *);
ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
...  

fs.h在核心 4.1 中有:

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 (*read_iter) (struct kiocb *, struct iov_iter *);
ssize_t (*write_iter) (struct kiocb *, struct iov_iter *);
int (*iterate) (struct file *, struct dir_context *);

如果你在做核心工作,你應該訂閱Linux Weekly News

一個非常快速的搜尋出現了這篇文章,其中提到了aio_read並且aio_write正在由read_iterand處理write_iter

您還可以在 中找到關於該效果的簡短聲明Documentation/filesystems/porting

引用自:https://unix.stackexchange.com/questions/324661