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§
Sourcefn open(&self, path: &str, flags: OpenFlags) -> Result<OpenResult, SyscallError>
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.
Sourcefn read(
&self,
file_id: u64,
offset: u64,
buf: &mut [u8],
) -> Result<usize, SyscallError>
fn read( &self, file_id: u64, offset: u64, buf: &mut [u8], ) -> Result<usize, SyscallError>
Read bytes from an open file.
Provided Methods§
Sourcefn 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_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.
Sourcefn async_write(
&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>
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.
Sourcefn truncate(&self, file_id: u64, new_size: u64) -> Result<(), SyscallError>
fn truncate(&self, file_id: u64, new_size: u64) -> Result<(), SyscallError>
Truncate/resize a file (if supported).
Sourcefn truncate_by_path(
&self,
_path: &str,
_new_size: u64,
) -> Result<(), SyscallError>
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.
Sourcefn create_file(&self, path: &str, mode: u32) -> Result<OpenResult, SyscallError>
fn create_file(&self, path: &str, mode: u32) -> Result<OpenResult, SyscallError>
Create a new regular file.
Sourcefn create_directory(
&self,
path: &str,
mode: u32,
) -> Result<OpenResult, SyscallError>
fn create_directory( &self, path: &str, mode: u32, ) -> Result<OpenResult, SyscallError>
Create a new directory.
Sourcefn readdir(&self, file_id: u64) -> Result<Vec<DirEntry>, SyscallError>
fn readdir(&self, file_id: u64) -> Result<Vec<DirEntry>, SyscallError>
Read directory entries from an open directory handle.
Sourcefn rename(&self, old_path: &str, new_path: &str) -> Result<(), SyscallError>
fn rename(&self, old_path: &str, new_path: &str) -> Result<(), SyscallError>
Rename/move an entry within this scheme.
Sourcefn chmod(&self, path: &str, mode: u32) -> Result<(), SyscallError>
fn chmod(&self, path: &str, mode: u32) -> Result<(), SyscallError>
Change permission bits on a path.
Sourcefn fchmod(&self, file_id: u64, mode: u32) -> Result<(), SyscallError>
fn fchmod(&self, file_id: u64, mode: u32) -> Result<(), SyscallError>
Change permission bits on an open file handle.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".