深入理解linux内核之文件系统分析二

来源:互联网 发布:caffe bias term false 编辑:程序博客网 时间:2024/05/18 09:14

卸载文件系统
umout() 系统调用用来卸载一个文件系统,对应系统卸载函数sys_umount,
1.调用path_lookup()查找安装点路径名,path_init(), path_walk(),这两个函数通常成对调用,可以根据给定的路径名找内存中找到代表目标文件的或目录的dentry结构和inode结构,

static int do_path_lookup(int dfd, const char *name,                unsigned int flags, struct nameidata *nd){    int retval = path_init(dfd, name, flags, nd);    if (!retval)        retval = path_walk(name, nd);    if (unlikely(!retval && !audit_dummy_context() && nd->path.dentry &&                nd->path.dentry->d_inode))        audit_inode(name, nd->path.dentry);    if (nd->root.mnt) {        path_put(&nd->root);        nd->root.mnt = NULL;    }    return retval;}

下面是path_init()函数的内容,下面判断是从绝对路径开始搜索还是从相对路径开始搜索

    if (*name=='/') {          //是不是根目录        set_root(nd);        nd->path = nd->root;        path_get(&nd->root);    } else if (dfd == AT_FDCWD) {   //当前目录        struct fs_struct *fs = current->fs;        read_lock(&fs->lock);        nd->path = fs->pwd;        path_get(&fs->pwd);        read_unlock(&fs->lock);    } else {

然后到 path_walk()函数 转到link_path_walk()函数中

原创粉丝点击