pub struct Dentry {
pub name: String,
pub inode: Arc<dyn Inode>,
parent: SpinLock<Weak<Dentry>>,
children: SpinLock<BTreeMap<String, Arc<Dentry>>>,
mount_point: SpinLock<Option<Weak<Dentry>>>,
}Expand description
目录项(Dentry)
表示路径中的一个组件,缓存文件名到 inode 的映射
Fields§
§name: String文件名(不含路径)
inode: Arc<dyn Inode>关联的 inode
parent: SpinLock<Weak<Dentry>>父目录 dentry(弱引用避免循环)
children: SpinLock<BTreeMap<String, Arc<Dentry>>>子 dentry 映射(文件名 -> dentry)
mount_point: SpinLock<Option<Weak<Dentry>>>如果此 dentry 是挂载点,指向挂载的根 dentry
Implementations§
Source§impl Dentry
impl Dentry
Sourcepub fn set_parent(&self, parent: &Arc<Dentry>)
pub fn set_parent(&self, parent: &Arc<Dentry>)
设置父 dentry
Sourcepub fn lookup_child(&self, name: &str) -> Option<Arc<Dentry>>
pub fn lookup_child(&self, name: &str) -> Option<Arc<Dentry>>
查找子 dentry
Sourcepub fn remove_child(&self, name: &str) -> Option<Arc<Dentry>>
pub fn remove_child(&self, name: &str) -> Option<Arc<Dentry>>
删除子 dentry
Sourcepub fn clear_mount(&self)
pub fn clear_mount(&self)
清除挂载点