Linux 内核文件系统与设备操作流程分析(16) // struct file *filp = get_empty_filp(); int err; if (filp == NULL) return -ENFILE; // // 先填充要返回的 struct nameidata 结构中的相关字段 // nd->intent.open.file = filp; nd->intent.open.flags = open_flags; // // 填充建立标志位,这个也就是 path_lookup_open() // 与 path_lookup_create() 函数调用的区别 // nd->intent.open.create_mode = create_mode; // // 根据路径调用 do_path_lookup() 得到一个 struct nameidata 结构 // err = do_path_lookup(dfd, name, lookup_flagsLOOKUP_OPEN, nd); if (IS_ERR(nd->intent.open.file)) { if (err == 0) { err = PTR_ERR(nd->intent.open.file); path_release(nd); } } else if (err != 0) release_open_intent(nd); return err;}此函数根据 "/" 根路径与 AT_FDCWD 标志从不同位置得到 struct vfsmount 与struct dentry 结构来填充 struct nameidata 中的相关字段,这里应该仅是占位用。最终路径分解工作与查找由 link_path_walk() 函数来完成。static int fastcall do_path_lookup(int dfd, const char *name,