pub trait DirNodeOps: NodeOps {
// Required methods
fn read_dir(
&self,
offset: u64,
sink: &mut dyn DirEntrySink,
) -> VfsResult<usize>;
fn lookup(&self, name: &str) -> VfsResult<DirEntry>;
fn create(
&self,
name: &str,
node_type: NodeType,
permission: NodePermission,
) -> VfsResult<DirEntry>;
fn link(&self, name: &str, node: &DirEntry) -> VfsResult<DirEntry>;
fn unlink(&self, name: &str) -> VfsResult<()>;
fn rename(
&self,
src_name: &str,
dst_dir: &DirNode,
dst_name: &str,
) -> VfsResult<()>;
// Provided method
fn is_cacheable(&self) -> bool { ... }
}Required Methods§
Sourcefn read_dir(&self, offset: u64, sink: &mut dyn DirEntrySink) -> VfsResult<usize>
fn read_dir(&self, offset: u64, sink: &mut dyn DirEntrySink) -> VfsResult<usize>
Reads directory entries.
Returns the number of entries read.
Implementations should ensure that . and .. are present in the
result.
Sourcefn create(
&self,
name: &str,
node_type: NodeType,
permission: NodePermission,
) -> VfsResult<DirEntry>
fn create( &self, name: &str, node_type: NodeType, permission: NodePermission, ) -> VfsResult<DirEntry>
Creates a directory entry.
Sourcefn unlink(&self, name: &str) -> VfsResult<()>
fn unlink(&self, name: &str) -> VfsResult<()>
Unlinks a directory entry by name.
If the entry is a non-empty directory, it should return ENOTEMPTY
error.
Sourcefn rename(
&self,
src_name: &str,
dst_dir: &DirNode,
dst_name: &str,
) -> VfsResult<()>
fn rename( &self, src_name: &str, dst_dir: &DirNode, dst_name: &str, ) -> VfsResult<()>
Renames a directory entry, replacing the original entry (dst) if it already exists.
If src and dst link to the same file, this should do nothing and return
Ok(()).
The caller should ensure:
- If
srcis a directory,dstmust not exist or be an empty directory. - If
srcis not a directory,dstmust not exist or not be a directory.
Provided Methods§
Sourcefn is_cacheable(&self) -> bool
fn is_cacheable(&self) -> bool
Returns whether directory entries can be cached.
Some filesystems (like ‘/proc’) may not support caching directory entries, as they may change frequently or not be backed by persistent storage.
If this returns false, the directory will not be cached in dentry and
each call to DirNode::lookup will end up calling [lookup].
Implementations should take care to handle cases where [lookup] is
called multiple times for the same name.