免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1646 | 回复: 1
打印 上一主题 下一主题

2.4.0(情景分析代码请教) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-30 09:21 |只看该作者 |倒序浏览
static inline void follow_dotdot(struct nameidata *nd)
{
        while(1) {
                struct vfsmount *parent;
                struct dentry *dentry;
                read_lock(&current->fs->lock);
                if (nd->dentry == current->fs->root &&
                    nd->mnt == current->fs->rootmnt)  {
                        read_unlock(&current->fs->lock);
                        break;
                }
                read_unlock(&current->fs->lock);
                spin_lock(&dcache_lock);
                if (nd->dentry != nd->mnt->mnt_root) {
                        dentry = dget(nd->dentry->d_parent);
                        spin_unlock(&dcache_lock);
                        dput(nd->dentry);
                        nd->dentry = dentry;
                        break;
                }
                parent=nd->mnt->mnt_parent;
                if (parent == nd->mnt) {
                        spin_unlock(&dcache_lock);
                        break;
                }
                mntget(parent);
                dentry=dget(nd->mnt->mnt_mountpoint);
                spin_unlock(&dcache_lock);
                dput(nd->dentry);
                nd->dentry = dentry;
                mntput(nd->mnt);
                nd->mnt = parent;
        }
}

current->fs->root究竟什么意思呢?   如果用户不是root,那么它的 root目录是什么,是/home下的一个目录吗?那么cd ./../..也会登陆到/目录啊,到底是怎么回事呢?
请大虾们帮忙解释解释,谢谢先
nd->dentry == current->fs->root &&
                    nd->mnt == current->fs->rootmnt     为什么要做两个判断?

论坛徽章:
0
2 [报告]
发表于 2008-05-05 08:59 |只看该作者
>>
current->fs->root究竟什么意思呢?   如果用户不是root,那么它的 root目录是什么,是/home下的一个目录吗?那么cd ./../..也会登陆到/目录啊,到底是怎么回事呢?

current->fs->root一般指向根目录/

>>
nd->dentry == current->fs->root &&
                    nd->mnt == current->fs->rootmnt     为什么要做两个判断?

我看一个就可以,nd->dentry == current->fs->root,第二个多余了
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP