DirNodeOps

Trait DirNodeOps 

Source
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§

Source

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.

Source

fn lookup(&self, name: &str) -> VfsResult<DirEntry>

Lookups a directory entry by name.

Source

fn create( &self, name: &str, node_type: NodeType, permission: NodePermission, ) -> VfsResult<DirEntry>

Creates a directory entry.

Creates a link to a node.

Unlinks a directory entry by name.

If the entry is a non-empty directory, it should return ENOTEMPTY error.

Source

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 src is a directory, dst must not exist or be an empty directory.
  • If src is not a directory, dst must not exist or not be a directory.

Provided Methods§

Source

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.

Implementors§