【问题标题】:EXT3 file operationsEXT3 文件操作
【发布时间】:2013-05-08 07:04:26
【问题描述】:

我正在尝试了解 Linux 如何处理 EXT3 文件。 我正在查看fs/ext3/file.c,其中存在处理文件的文件操作:

const struct file_operations ext3_file_operations = {
    .llseek         = generic_file_llseek,
    .read           = do_sync_read,
    .write          = do_sync_write,
    .aio_read       = generic_file_aio_read,
    .aio_write      = generic_file_aio_write,
    .unlocked_ioctl = ext3_ioctl,
#ifdef CONFIG_COMPAT
    .compat_ioctl   = ext3_compat_ioctl,
#endif
    .mmap           = generic_file_mmap,
    .open           = dquot_file_open,
    .release        = ext3_release_file,
    .fsync          = ext3_sync_file,
    .splice_read    = generic_file_splice_read,
    .splice_write   = generic_file_splice_write,
};

例如,我怎样才能找到 .open 何时被函数“dquot_file_open”替换? 我应该遵循fs/open.c中定义的系统调用:

SYSCALL_DEFINE3(open, const char __user *, filename, int, flags, umode_t, mode)

或者我应该看看其他功能?

我正在为用户模式 ​​Linux 开发 Linux 3.7.6

【问题讨论】:

    标签: filesystems linux-kernel ext3


    【解决方案1】:

    Linux 内核以 OOP 方式组织(尽管是用 C 编写的)。 struct file_operations 实际上是一个类,成员(函数指针)是类的函数成员(Java 头的“方法”)。您引用的代码用于通过填写函数指针来设置 ext3 对象。这是在编译/链接时完成的。

    open(2) 系统调用间接调用它,通过找出与手头文件系统相关的struct file_operations,并调用其open 成员。

    我建议您查看kernelnewbies 页面以获取整体视图和更详细的帮助。

    【讨论】:

    • 是的,我知道这些信息。我的问题是open函数在哪里与EXT3的“file_operations”交互?
    猜你喜欢
    • 2010-12-15
    • 1970-01-01
    • 2012-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-29
    • 2023-03-17
    相关资源
    最近更新 更多