在字符设备驱动程序中手动调用flush

时间:2011-10-09 21:38:45

标签: file-io linux-device-driver

我想要一个字符设备在写入时刷新。如何调用file_operation的flush方法?

以下是一些相关代码:

struct file_operations ent_fops = {
          .owner = THIS_MODULE,
          .read = ent_read,
          .write = ent_write,
};

我没有自己定义冲洗

ssize_t ent_write(struct file *filp, const char __user *buf, size_t count,loff_t *f_pos)
{
blah...
*(ent_fops.flush)(file);
blah...
}

代码不会编译,错误是我发送的flush太少了。我无法找到任何需要不止一个的地方。

1 个答案:

答案 0 :(得分:0)

您错过了指向文件锁所有者的指针。尝试

*(ent_fops.flush)(filp, NULL);