Skip to main content

Scheme

Trait Scheme 

Source
pub trait Scheme: Send + Sync {
Show 18 methods // Required methods fn open( &self, path: &str, flags: OpenFlags, ) -> Result<OpenResult, SyscallError>; fn read( &self, file_id: u64, offset: u64, buf: &mut [u8], ) -> Result<usize, SyscallError>; fn write( &self, file_id: u64, offset: u64, buf: &[u8], ) -> Result<usize, SyscallError>; fn close(&self, file_id: u64) -> Result<(), SyscallError>; // Provided methods fn size(&self, file_id: u64) -> Result<u64, SyscallError> { ... } fn truncate(&self, file_id: u64, new_size: u64) -> Result<(), SyscallError> { ... } fn sync(&self, file_id: u64) -> Result<(), SyscallError> { ... } fn create_file( &self, path: &str, mode: u32, ) -> Result<OpenResult, SyscallError> { ... } fn create_directory( &self, path: &str, mode: u32, ) -> Result<OpenResult, SyscallError> { ... } fn unlink(&self, path: &str) -> Result<(), SyscallError> { ... } fn stat(&self, file_id: u64) -> Result<FileStat, SyscallError> { ... } fn readdir(&self, file_id: u64) -> Result<Vec<DirEntry>, SyscallError> { ... } fn rename(&self, old_path: &str, new_path: &str) -> Result<(), SyscallError> { ... } fn chmod(&self, path: &str, mode: u32) -> Result<(), SyscallError> { ... } fn fchmod(&self, file_id: u64, mode: u32) -> Result<(), SyscallError> { ... } fn link(&self, old_path: &str, new_path: &str) -> Result<(), SyscallError> { ... } fn symlink(&self, target: &str, link_path: &str) -> Result<(), SyscallError> { ... } fn readlink(&self, path: &str) -> Result<String, SyscallError> { ... }
}
Expand description

Abstraction for a filesystem/service backend.

Required Methods§

Source

fn open(&self, path: &str, flags: OpenFlags) -> Result<OpenResult, SyscallError>

Open a file/resource at the given path within this scheme.

path is relative to the scheme’s mount point. Returns a unique file handle + metadata.

Source

fn read( &self, file_id: u64, offset: u64, buf: &mut [u8], ) -> Result<usize, SyscallError>

Read bytes from an open file.

Source

fn write( &self, file_id: u64, offset: u64, buf: &[u8], ) -> Result<usize, SyscallError>

Write bytes to an open file.

Source

fn close(&self, file_id: u64) -> Result<(), SyscallError>

Close an open file.

Provided Methods§

Source

fn size(&self, file_id: u64) -> Result<u64, SyscallError>

Get file size (if supported).

Source

fn truncate(&self, file_id: u64, new_size: u64) -> Result<(), SyscallError>

Truncate/resize a file (if supported).

Source

fn sync(&self, file_id: u64) -> Result<(), SyscallError>

Sync file to storage (if applicable).

Source

fn create_file(&self, path: &str, mode: u32) -> Result<OpenResult, SyscallError>

Create a new regular file.

Source

fn create_directory( &self, path: &str, mode: u32, ) -> Result<OpenResult, SyscallError>

Create a new directory.

Remove a file or directory.

Source

fn stat(&self, file_id: u64) -> Result<FileStat, SyscallError>

Get metadata for an open file.

Source

fn readdir(&self, file_id: u64) -> Result<Vec<DirEntry>, SyscallError>

Read directory entries from an open directory handle.

Source

fn rename(&self, old_path: &str, new_path: &str) -> Result<(), SyscallError>

Rename/move an entry within this scheme.

Source

fn chmod(&self, path: &str, mode: u32) -> Result<(), SyscallError>

Change permission bits on a path.

Source

fn fchmod(&self, file_id: u64, mode: u32) -> Result<(), SyscallError>

Change permission bits on an open file handle.

Create a hard link.

Create a symbolic link.

Read the target of a symbolic link.

Implementors§