Struct wasmer_wasix::fs::WasiFs
source · pub struct WasiFs {
pub preopen_fds: RwLock<Vec<u32>>,
pub name_map: HashMap<String, Inode>,
pub fd_map: Arc<RwLock<HashMap<WasiFd, Fd>>>,
pub next_fd: AtomicU32,
pub current_dir: Mutex<String>,
pub root_fs: WasiFsRoot,
pub root_inode: InodeGuard,
pub has_unioned: Arc<Mutex<HashSet<String>>>,
/* private fields */
}
Expand description
Warning, modifying these fields directly may cause invariants to break and should be considered unsafe. These fields may be made private in a future release
Fields§
§preopen_fds: RwLock<Vec<u32>>
§name_map: HashMap<String, Inode>
§fd_map: Arc<RwLock<HashMap<WasiFd, Fd>>>
§next_fd: AtomicU32
§current_dir: Mutex<String>
§root_fs: WasiFsRoot
§root_inode: InodeGuard
§has_unioned: Arc<Mutex<HashSet<String>>>
Implementations§
source§impl WasiFs
impl WasiFs
pub fn is_wasix(&self) -> bool
pub fn set_is_wasix(&self, is_wasix: bool)
sourcepub fn conditional_union(&self, binary: &BinaryPackage) -> bool
pub fn conditional_union(&self, binary: &BinaryPackage) -> bool
Will conditionally union the binary file system with this one if it has not already been unioned
sourcepub unsafe fn open_dir_all(
&mut self,
inodes: &WasiInodes,
base: WasiFd,
name: String,
rights: Rights,
rights_inheriting: Rights,
flags: Fdflags
) -> Result<WasiFd, FsError>
pub unsafe fn open_dir_all( &mut self, inodes: &WasiInodes, base: WasiFd, name: String, rights: Rights, rights_inheriting: Rights, flags: Fdflags ) -> Result<WasiFd, FsError>
This function is like create dir all, but it also opens it. Function is unsafe because it may break invariants and hasn’t been tested. This is an experimental function and may be removed
Safety
- Virtual directories created with this function must not conflict with the standard operation of the WASI filesystem. This is vague and unlikely in pratice. Join the discussion for what the newer, safer WASI FS APIs should look like.
sourcepub fn open_file_at(
&mut self,
inodes: &WasiInodes,
base: WasiFd,
file: Box<dyn VirtualFile + Send + Sync + 'static>,
open_flags: u16,
name: String,
rights: Rights,
rights_inheriting: Rights,
flags: Fdflags
) -> Result<WasiFd, FsError>
pub fn open_file_at( &mut self, inodes: &WasiInodes, base: WasiFd, file: Box<dyn VirtualFile + Send + Sync + 'static>, open_flags: u16, name: String, rights: Rights, rights_inheriting: Rights, flags: Fdflags ) -> Result<WasiFd, FsError>
Opens a user-supplied file in the directory specified with the name and flags given
sourcepub fn swap_file(
&self,
fd: WasiFd,
file: Box<dyn VirtualFile + Send + Sync + 'static>
) -> Result<Option<Box<dyn VirtualFile + Send + Sync + 'static>>, FsError>
pub fn swap_file( &self, fd: WasiFd, file: Box<dyn VirtualFile + Send + Sync + 'static> ) -> Result<Option<Box<dyn VirtualFile + Send + Sync + 'static>>, FsError>
Change the backing of a given file descriptor Returns the old backing TODO: add examples
sourcepub fn filestat_resync_size(&self, fd: WasiFd) -> Result<Filesize, Errno>
pub fn filestat_resync_size(&self, fd: WasiFd) -> Result<Filesize, Errno>
refresh size from filesystem
sourcepub fn set_current_dir(&self, path: &str)
pub fn set_current_dir(&self, path: &str)
Changes the current directory
sourcepub fn get_current_dir(
&self,
inodes: &WasiInodes,
base: WasiFd
) -> Result<(InodeGuard, String), Errno>
pub fn get_current_dir( &self, inodes: &WasiInodes, base: WasiFd ) -> Result<(InodeGuard, String), Errno>
Gets the current directory
pub fn get_fd(&self, fd: WasiFd) -> Result<Fd, Errno>
pub fn get_fd_inode(&self, fd: WasiFd) -> Result<InodeGuard, Errno>
pub fn filestat_fd(&self, fd: WasiFd) -> Result<Filestat, Errno>
pub fn fdstat(&self, fd: WasiFd) -> Result<Fdstat, Errno>
pub fn prestat_fd(&self, fd: WasiFd) -> Result<Prestat, Errno>
pub async fn flush(&self, fd: WasiFd) -> Result<(), Errno>
pub fn create_fd( &self, rights: Rights, rights_inheriting: Rights, flags: Fdflags, open_flags: u16, inode: InodeGuard ) -> Result<WasiFd, Errno>
pub fn create_fd_ext( &self, rights: Rights, rights_inheriting: Rights, flags: Fdflags, open_flags: u16, inode: InodeGuard, idx: WasiFd ) -> Result<(), Errno>
pub fn clone_fd(&self, fd: WasiFd) -> Result<WasiFd, Errno>
sourcepub unsafe fn remove_inode(
&self,
inodes: &WasiInodes,
ino: Inode
) -> Option<Arc<InodeVal>>
pub unsafe fn remove_inode( &self, inodes: &WasiInodes, ino: Inode ) -> Option<Arc<InodeVal>>
Low level function to remove an inode, that is it deletes the WASI FS’s knowledge of a file.
This function returns the inode if it existed and was removed.
Safety
- The caller must ensure that all references to the specified inode have been removed from the filesystem.