- 论坛徽章:
- 16
|
回复 6# stuman
v3.14-rc2- static void follow_dotdot(struct nameidata *nd)
- {
- set_root(nd);
- while(1) {
- struct dentry *old = nd->path.dentry;
- if (nd->path.dentry == nd->root.dentry &&
- nd->path.mnt == nd->root.mnt) {
- break;
- }
- if (nd->path.dentry != nd->path.mnt->mnt_root) {
- /* rare case of legitimate dget_parent()... */
- nd->path.dentry = dget_parent(nd->path.dentry);
- dput(old);
- break;
- }
- if (!follow_up(&nd->path))
- break;
- }
- follow_mount(&nd->path);
- nd->inode = nd->path.dentry->d_inode;
- }
复制代码 我的理解是:
1. 在c中cd .., 由于nd->path.dentry == nd->path.mnt->mnt_root,执行follow_up,到了/a/b这里,然后再..到了/a
2. 在b中cd .., 由于nd->path.dentry != nd->path.mnt->mnt_root,执行 nd->path.dentry = dget_parent(nd->path.dentry), 这样到了/a |
|