stub virtfs
This commit is contained in:
18
crates/wasi-common/virtfs/Cargo.toml
Normal file
18
crates/wasi-common/virtfs/Cargo.toml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[package]
|
||||||
|
name = "wasi-virtfs"
|
||||||
|
version = "0.22.0"
|
||||||
|
authors = ["The Wasmtime Project Developers"]
|
||||||
|
description = "WASI implementation in Rust"
|
||||||
|
license = "Apache-2.0 WITH LLVM-exception"
|
||||||
|
categories = ["wasm"]
|
||||||
|
keywords = ["webassembly", "wasm"]
|
||||||
|
repository = "https://github.com/bytecodealliance/wasmtime"
|
||||||
|
readme = "README.md"
|
||||||
|
edition = "2018"
|
||||||
|
include = ["src/**/*", "LICENSE" ]
|
||||||
|
publish = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wasi-common = { path = "../", version = "0.22.0" }
|
||||||
|
anyhow = "1.0"
|
||||||
|
cap-std = "0.12"
|
||||||
82
crates/wasi-common/virtfs/src/dir.rs
Normal file
82
crates/wasi-common/virtfs/src/dir.rs
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
use crate::file::File;
|
||||||
|
use std::any::Any;
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use wasi_common::{
|
||||||
|
dir::{ReaddirCursor, ReaddirEntity, WasiDir},
|
||||||
|
file::{FdFlags, FileCaps, FileType, Filestat, OFlags, WasiFile},
|
||||||
|
Error, ErrorExt,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct Dir;
|
||||||
|
|
||||||
|
impl Dir {}
|
||||||
|
|
||||||
|
impl WasiDir for Dir {
|
||||||
|
fn as_any(&self) -> &dyn Any {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
fn open_file(
|
||||||
|
&self,
|
||||||
|
symlink_follow: bool,
|
||||||
|
path: &str,
|
||||||
|
oflags: OFlags,
|
||||||
|
caps: FileCaps,
|
||||||
|
fdflags: FdFlags,
|
||||||
|
) -> Result<Box<dyn WasiFile>, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn open_dir(&self, symlink_follow: bool, path: &str) -> Result<Box<dyn WasiDir>, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_dir(&self, path: &str) -> Result<(), Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn readdir(
|
||||||
|
&self,
|
||||||
|
cursor: ReaddirCursor,
|
||||||
|
) -> Result<Box<dyn Iterator<Item = Result<(ReaddirEntity, String), Error>>>, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn symlink(&self, src_path: &str, dest_path: &str) -> Result<(), Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn remove_dir(&self, path: &str) -> Result<(), Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn unlink_file(&self, path: &str) -> Result<(), Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn read_link(&self, path: &str) -> Result<PathBuf, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn get_filestat(&self) -> Result<Filestat, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn get_path_filestat(&self, path: &str, follow_symlinks: bool) -> Result<Filestat, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn rename(&self, src_path: &str, dest_dir: &dyn WasiDir, dest_path: &str) -> Result<(), Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn hard_link(
|
||||||
|
&self,
|
||||||
|
src_path: &str,
|
||||||
|
target_dir: &dyn WasiDir,
|
||||||
|
target_path: &str,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn set_times(
|
||||||
|
&self,
|
||||||
|
path: &str,
|
||||||
|
atime: Option<wasi_common::SystemTimeSpec>,
|
||||||
|
mtime: Option<wasi_common::SystemTimeSpec>,
|
||||||
|
follow_symlinks: bool,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
73
crates/wasi-common/virtfs/src/file.rs
Normal file
73
crates/wasi-common/virtfs/src/file.rs
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
use cap_std::Advice;
|
||||||
|
use std::any::Any;
|
||||||
|
use std::convert::TryInto;
|
||||||
|
use std::io;
|
||||||
|
use wasi_common::{
|
||||||
|
file::{FdFlags, FileType, Filestat, WasiFile},
|
||||||
|
Error,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct File;
|
||||||
|
|
||||||
|
impl File {}
|
||||||
|
|
||||||
|
impl WasiFile for File {
|
||||||
|
fn as_any(&self) -> &dyn Any {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
fn datasync(&self) -> Result<(), Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
fn sync(&self) -> Result<(), Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
fn get_filetype(&self) -> Result<FileType, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn get_fdflags(&self) -> Result<FdFlags, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn set_fdflags(&mut self, fdflags: FdFlags) -> Result<(), Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn get_filestat(&self) -> Result<Filestat, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn set_filestat_size(&self, size: u64) -> Result<(), Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn advise(&self, _offset: u64, _len: u64, _advice: Advice) -> Result<(), Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
fn allocate(&self, offset: u64, len: u64) -> Result<(), Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn set_times(
|
||||||
|
&self,
|
||||||
|
atime: Option<wasi_common::SystemTimeSpec>,
|
||||||
|
mtime: Option<wasi_common::SystemTimeSpec>,
|
||||||
|
) -> Result<(), Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn read_vectored(&self, bufs: &mut [io::IoSliceMut]) -> Result<u64, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn read_vectored_at(&self, bufs: &mut [io::IoSliceMut], offset: u64) -> Result<u64, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn write_vectored(&self, bufs: &[io::IoSlice]) -> Result<u64, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn write_vectored_at(&self, bufs: &[io::IoSlice], offset: u64) -> Result<u64, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn seek(&self, pos: std::io::SeekFrom) -> Result<u64, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn peek(&self, buf: &mut [u8]) -> Result<u64, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
fn num_ready_bytes(&self) -> Result<u64, Error> {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
2
crates/wasi-common/virtfs/src/lib.rs
Normal file
2
crates/wasi-common/virtfs/src/lib.rs
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
pub mod file;
|
||||||
|
pub mod dir;
|
||||||
Reference in New Issue
Block a user