pub trait Directorywhere
Self: Send + Sync,{
// Required methods
fn ino(&self) -> InodeNumber;
fn size(&self) -> usize;
fn link_count(&self) -> usize;
fn open_entry(&self, entry: &str) -> Result<File, KernelError>;
fn create_entry(
&self,
entry: &str,
is_dir: bool,
) -> Result<File, KernelError>;
fn unlink_entry(&self, entry: &str) -> Result<(), KernelError>;
fn read_dir(&self) -> Result<Vec<(InodeNumber, String)>, KernelError>;
fn removed(&self) -> Result<&AtomicBool, KernelError>;
}Expand description
Trait representing a directory in the filesystem.
A directory contains entries that reference other files or directories.
Required Methods§
Sourcefn ino(&self) -> InodeNumber
fn ino(&self) -> InodeNumber
Returns the inode number of the directory.
Sourcefn link_count(&self) -> usize
fn link_count(&self) -> usize
Returns the link count of the directory.
Sourcefn open_entry(&self, entry: &str) -> Result<File, KernelError>
fn open_entry(&self, entry: &str) -> Result<File, KernelError>
Sourcefn create_entry(&self, entry: &str, is_dir: bool) -> Result<File, KernelError>
fn create_entry(&self, entry: &str, is_dir: bool) -> Result<File, KernelError>
Sourcefn unlink_entry(&self, entry: &str) -> Result<(), KernelError>
fn unlink_entry(&self, entry: &str) -> Result<(), KernelError>
Sourcefn read_dir(&self) -> Result<Vec<(InodeNumber, String)>, KernelError>
fn read_dir(&self) -> Result<Vec<(InodeNumber, String)>, KernelError>
Reads the contents of the directory.
This function lists all the entries within the directory.
§Returns
Ok(()): If the directory was successfully read.Err(Error): An error if the read operation fails.
Sourcefn removed(&self) -> Result<&AtomicBool, KernelError>
fn removed(&self) -> Result<&AtomicBool, KernelError>
Returns a reference of AtomicBool which contains whether
directory is removed.
This is important because directory operations against the removed directory will result in undesirable behavior (e.g. unreachable file).
§Returns
Ok(()): If the directory was successfully read.Err(Error): An error if the operation fails.