【问题标题】:Reaching the "write" and "ioctl" inside fops到达 fops 中的“write”和“ioctl”
【发布时间】:2017-02-17 08:22:35
【问题描述】:

我正在查看 linux 源代码,并试图找出在设备节点上执行 writeioctl 时所采用的路径。我想知道调用 fops 结构中的函数指针的确切位置和位置。我在源代码中找不到任何对 fops 结构的引用。

谁能给我更多关于这方面的信息/指出我正确的方向?

【问题讨论】:

    标签: linux linux-kernel kernel linux-device-driver


    【解决方案1】:

    这取决于特定的子系统。以文件系统为例,我们可以检查任何不同的文件系统。让我们以 FAT 为例,因为这是我最近一直在研究的。它的实现在fs/fat/ 目录下。在该目录中运行 git grep file_operations 正是我们正在寻找的内容:

    $ git grep file_operations
    dir.c:const struct file_operations fat_dir_operations = {
    fat.h:extern const struct file_operations fat_dir_operations;
    fat.h:extern const struct file_operations fat_file_operations;
    file.c:const struct file_operations fat_file_operations = {
    inode.c:                inode->i_fop = &fat_file_operations;
    

    所以file_operations 有两个定义 - 一个在 dir.c 中称为 fat_dir_operations,另一个在 file.c 中称为 fat_file_operations。这些名称是不言自明的。在这些文件中,您可以看到 readwriteunlocked_ioctl(即不持有 BKL 锁的 ioctl)的实现。

    同样,您可以为drivers/ 下的不同驱动程序查找file_operations。许多驱动程序都实现了它们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-13
      • 2015-04-21
      • 2013-10-20
      • 1970-01-01
      • 2021-07-14
      • 2011-04-14
      • 2014-03-27
      • 2011-10-22
      相关资源
      最近更新 更多