| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4071 人关注过本帖
标题:VFS中的 dentry object 的一点介绍
只看楼主 加入收藏
madfrogme
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:1160
专家分:1106
注 册:2009-6-24
结帖率:98.63%
收藏
 问题点数:0 回复次数:0 
VFS中的 dentry object 的一点介绍
dentry object

VFS中的四种主要对象有
superblock object
inode object
dentry object
file object

下面想对dentry object 做一些简单了解

VFS即使对于directories 也是把他们当作一种文件

比如路径/bin/vi, bin和vi都是文件,

bin一个是特殊的文件夹文件(directory file),

vi是一个普通文件

用一个inode object可以表示这两个components

但是VFS经常需要执行一些directory-specific的操作

比如说查阅路径名(path name lookup)

这就包括了翻译路径的每一个部件(component)

保证它们是有效的

为了实现这个功能,VFS引入了directory entry的概念

一个dentry就是路径中的一个特别的部件

比如 /, bin, vi ,它们都是dentry objects

前两个是文件夹,最后一个是普通文件

所以说很重要一点就是

gentry objects  是一个路径中的所有部件

分解一个路径不是一件轻松活,

耗时间,大量的字符串操作,执行大量的代码

但是dentry object 让处理工作变的简单了一些

下面一句就不翻译了,很重要

The VFS constructs dentry objects on-the-fly,

as needed, when performing directory operations

struct dentry 被定已在<linux/dcache.h>

程序代码:
struct dentry {

    atomic_t d_count;

    unsigned int d_flags;        /* protected by d_lock */

    spinlock_t d_lock;        /* per dentry lock */

    int d_mounted;

    struct inode *d_inode;  
  
    /*
     * The next three fields are touched by __d_lookup.  Place them here
     * so they all fit in a cache line.
     */
    struct hlist_node d_hash;    /* lookup hash list */

    struct dentry *d_parent;    /* parent directory */

    struct qstr d_name;

    struct list_head d_lru;        /* LRU list */
    /*
     * d_child and d_rcu can share memory
     */
    union {

        struct list_head d_child;    /* child of parent list */

         struct rcu_head d_rcu;

    } d_u;

    struct list_head d_subdirs;    /* our children */

    struct list_head d_alias;    /* inode alias list */

    unsigned long d_time;        /* used by d_revalidate */

    const struct dentry_operations *d_op;

    struct super_block *d_sb;    /* The root of the dentry tree */
    void *d_fsdata;            /* fs-specific data */

    unsigned char d_iname[DNAME_INLINE_LEN_MIN];    /* small names */
};


还有重要的一点是dentry object 没有任何对应在disk上的数据结构体(dentry object does not correspond to any sort of on-disk structure)

因为VFS creates it on-the-fly from a string representation of a path name.

因为dentry object没有物理的存储在磁盘上,

所以 struct dentry 也没有flag 去指示这个object是不是被修改了
(Because the dentry object is not physically stored on the disk,

no flag in struct dentry specifies whether the object is modified

(that is, whether it is dirty and needs to be written back to disk).


[ 本帖最后由 madfrogme 于 2012-8-1 02:48 编辑 ]
搜索更多相关主题的帖子: file 
2012-07-31 21:23
快速回复:VFS中的 dentry object 的一点介绍
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.010760 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved