Linux 内核文件系统与设备操作流程分析(23) // 用 real_lookup() 读取 // if (!dentry) goto need_lookup; if (IS_ERR(dentry)) goto fail; goto done;fail: return PTR_ERR(dentry);}在分析 real_lookup() 函数前,我们先来看一下 ext3 文件系统的 inode结构。很明显可以看出 lookup 指向了 ext3_lookup() 函数。struct inode_operations ext3_dir_inode_operations = { // // 为了更清晰,在这个结构中只列出我们感兴趣的字段 // ...... .lookup = ext3_lookup, ...... };此函数先从缓存中查找对应的 inode,如果没有则新分配一个 struct dentry结构,然后调用 parent->d_inode->i_op->lookup 即调用了 ext3_lookup()函数来查找 inode。static struct dentry * real_lookup(struct dentry * parent, struct qstr * name, struct nameidata *nd){ struct dentry * result; // // 篇幅所限,在这个函数中我们只列出相关代码。 // // // 获得上一层目录的 inode。别忘了我们是分解路径依次 // 调用的,所以上一层的 inode 肯定是存在的。 // struct inode *dir = parent->d_inode; ...... //