- 论坛徽章:
- 0
|
本帖最后由 mxgsgtc 于 2017-02-22 13:12 编辑
大家都知道,比如打开一个文件 "/etc/1.txt",需要调用open函数
最近跟了一下open函数的源码,最后会调用__dentry_open()这个函数
__dentry_open()这个函数中
static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt,
struct file *f,
int (*open)(struct inode *, struct file *),
const struct cred *cred)
{
......................
struct inode *inode;
inode = dentry->d_inode; //dentry对应的是"/etc"目录吧,这句话是获取"/etc"目录对应的inode
.....................
f->f_op = fops_get(inode->i_fop);
.......................
if (!open && f->f_op)
open = f->f_op->open;////将"/etc"目录inode对应的i_fop赋值给open
...............................
}
问题: 不应该是1.txt文件对应的inode->f_op赋值给open吗?,但是这个函数貌似没有关于1.txt文件inode的获取操作确是把/etc/这个目录的f_open->open赋值给了open参数,不太明白,求助大家了!
|
|