/usr/bin/go
这个文件,/
表示根目录,是由一个inode表示,该inode的数据段不包含普通文件的数据,而是根目录下面的各个目录项,这些目录项可能代表文件或者目录,每个目录项(dentry)是由一个inode和文件或者目录名组成.目录项中的inode存储该目录下文件或者目录名称和对应的inode。/
目录inode中查找子目录user
的inode,这会读取/
目录的inode的数据段,直到找到usr
目录项(如果查找失败,返回错误即可)。接着读取usr
的inode查找子目录bin
的目录项,读取bin
目录的inode,查找go
这个文件所在的inode,读取go
文件的元数据返回即可。struct dentry {
/* RCU lookup touched fields */
unsigned int d_flags; /* protected by d_lock */
seqcount_spinlock_t d_seq; /* per dentry seqlock */
struct hlist_bl_node d_hash; /* lookup hash list */
// 父节点目录的dentry指针
struct dentry *d_parent;
// 文件名称超过一定长度时候,文件名称存储在这里
struct qstr d_name;
// 指向关联的inode对象
struct inode *d_inode;
// 当文件名称不超过16个字符时候,文件名称存储在d_iname中
unsigned char d_iname[DNAME_INLINE_LEN];
// 提供各种dentry对象操作的函数结构指针
const struct dentry_operations *d_op;
// dentry对象所属文件系统超级块的实例
struct super_block *d_sb;
// 实际文件系统的私有数据
void *d_fsdata;
// 父目录节点的下所有子目录或者文件的dentry
struct list_head d_child; /* child of parent list */
// 子目录或者文件dentry的链表
struct list_head d_subdirs; /* our children */
/*
* d_alias and d_rcu can share memory
*/
union {
// 用于将dentry连接到inode的i_dentry指针
struct hlist_node d_alias;
// 哈哈西散列表
struct hlist_bl_node d_in_lookup_hash;
} d_u;
} __randomize_layout;