Dentry

Struct Dentry 

Source
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

Source

pub fn new(name: String, inode: Arc<dyn Inode>) -> Arc<Self>

创建新的 dentry

Source

pub fn set_parent(&self, parent: &Arc<Dentry>)

设置父 dentry

Source

pub fn parent(&self) -> Option<Arc<Dentry>>

获取父 dentry

Source

pub fn lookup_child(&self, name: &str) -> Option<Arc<Dentry>>

查找子 dentry

Source

pub fn add_child(self: &Arc<Self>, child: Arc<Dentry>)

添加子 dentry

Source

pub fn remove_child(&self, name: &str) -> Option<Arc<Dentry>>

删除子 dentry

Source

pub fn full_path(&self) -> String

获取完整路径(通过向上遍历父节点直到根目录)

Source

pub fn set_mount(&self, mounted_root: &Arc<Dentry>)

设置挂载点

Source

pub fn clear_mount(&self)

清除挂载点

Source

pub fn get_mount(&self) -> Option<Arc<Dentry>>

获取挂载的根 dentry(如果有)

Trait Implementations§

Source§

impl Debug for Dentry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Dentry

§

impl !RefUnwindSafe for Dentry

§

impl Send for Dentry

§

impl Sync for Dentry

§

impl Unpin for Dentry

§

impl !UnwindSafe for Dentry

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.