我正在尝试了解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 3.7.6 for User-Mode-Linux
发布于 2013-05-08 20:18:01
Linux内核是以OOP方式组织的(尽管是用C编写的)。struct file_operations实际上是一个类,成员(函数指针)是类的函数成员(Java头的“方法”)。您引用的代码用于通过填充函数指针来设置ext3对象。这是在编译/链接时完成的。
open(2)系统调用通过找出与当前文件系统相关的struct file_operations并调用其open成员间接调用此方法。
我建议您查看一下kernelnewbies页面,以获得总体视图和更详细的帮助。
https://stackoverflow.com/questions/16452846
复制相似问题