Skip to main content

Scheme

Trait Scheme 

Source
pub trait Scheme: Send + Sync {
Show 21 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 async_read( &self, file_id: u64, offset: u64, user_buf_vaddr: u64, len: usize, _ring_id: u64, _user_data: u64, ) -> Result<AsyncSubmitResult, SyscallError> { ... } fn async_write( &self, file_id: u64, offset: u64, user_buf_vaddr: u64, len: usize, _ring_id: u64, _user_data: u64, ) -> Result<AsyncSubmitResult, SyscallError> { ... } fn size(&self, file_id: u64) -> Result<u64, SyscallError> { ... } fn truncate(&self, file_id: u64, new_size: u64) -> Result<(), SyscallError> { ... } fn truncate_by_path( &self, _path: &str, _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 async_read( &self, file_id: u64, offset: u64, user_buf_vaddr: u64, len: usize, _ring_id: u64, _user_data: u64, ) -> Result<AsyncSubmitResult, SyscallError>

Submit a read against a userspace buffer for async I/O.

The default implementation performs the read synchronously and copies the result back into the validated userspace slice before returning a completed result.

Source

fn async_write( &self, file_id: u64, offset: u64, user_buf_vaddr: u64, len: usize, _ring_id: u64, _user_data: u64, ) -> Result<AsyncSubmitResult, SyscallError>

Submit a write sourced from a userspace buffer for async I/O.

The default implementation validates and copies the user buffer, then performs the write synchronously before returning a completed result.

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 truncate_by_path( &self, _path: &str, _new_size: u64, ) -> Result<(), SyscallError>

Truncate a file by path (avoids open/close round-trip).

Default implementation returns NotImplemented, causing the caller to fall back to open+truncate+close.

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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§