From 2e10e621c4b1fa69356d19f1f2b9b447f9d55b70 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Fri, 29 Jan 2021 17:02:57 -0800 Subject: [PATCH] stub virtfs --- crates/wasi-common/virtfs/Cargo.toml | 18 ++++++ crates/wasi-common/virtfs/src/dir.rs | 82 +++++++++++++++++++++++++++ crates/wasi-common/virtfs/src/file.rs | 73 ++++++++++++++++++++++++ crates/wasi-common/virtfs/src/lib.rs | 2 + 4 files changed, 175 insertions(+) create mode 100644 crates/wasi-common/virtfs/Cargo.toml create mode 100644 crates/wasi-common/virtfs/src/dir.rs create mode 100644 crates/wasi-common/virtfs/src/file.rs create mode 100644 crates/wasi-common/virtfs/src/lib.rs diff --git a/crates/wasi-common/virtfs/Cargo.toml b/crates/wasi-common/virtfs/Cargo.toml new file mode 100644 index 0000000000..4a760434a6 --- /dev/null +++ b/crates/wasi-common/virtfs/Cargo.toml @@ -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" diff --git a/crates/wasi-common/virtfs/src/dir.rs b/crates/wasi-common/virtfs/src/dir.rs new file mode 100644 index 0000000000..45396e7de9 --- /dev/null +++ b/crates/wasi-common/virtfs/src/dir.rs @@ -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, Error> { + todo!() + } + + fn open_dir(&self, symlink_follow: bool, path: &str) -> Result, Error> { + todo!() + } + + fn create_dir(&self, path: &str) -> Result<(), Error> { + todo!() + } + fn readdir( + &self, + cursor: ReaddirCursor, + ) -> Result>>, 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 { + todo!() + } + fn get_filestat(&self) -> Result { + todo!() + } + fn get_path_filestat(&self, path: &str, follow_symlinks: bool) -> Result { + 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, + mtime: Option, + follow_symlinks: bool, + ) -> Result<(), Error> { + todo!() + } +} diff --git a/crates/wasi-common/virtfs/src/file.rs b/crates/wasi-common/virtfs/src/file.rs new file mode 100644 index 0000000000..1e3e775284 --- /dev/null +++ b/crates/wasi-common/virtfs/src/file.rs @@ -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 { + todo!() + } + fn get_fdflags(&self) -> Result { + todo!() + } + fn set_fdflags(&mut self, fdflags: FdFlags) -> Result<(), Error> { + todo!() + } + fn get_filestat(&self) -> Result { + 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, + mtime: Option, + ) -> Result<(), Error> { + todo!() + } + fn read_vectored(&self, bufs: &mut [io::IoSliceMut]) -> Result { + todo!() + } + fn read_vectored_at(&self, bufs: &mut [io::IoSliceMut], offset: u64) -> Result { + todo!() + } + fn write_vectored(&self, bufs: &[io::IoSlice]) -> Result { + todo!() + } + fn write_vectored_at(&self, bufs: &[io::IoSlice], offset: u64) -> Result { + todo!() + } + fn seek(&self, pos: std::io::SeekFrom) -> Result { + todo!() + } + fn peek(&self, buf: &mut [u8]) -> Result { + todo!() + } + fn num_ready_bytes(&self) -> Result { + todo!() + } +} diff --git a/crates/wasi-common/virtfs/src/lib.rs b/crates/wasi-common/virtfs/src/lib.rs new file mode 100644 index 0000000000..f8abfac3c4 --- /dev/null +++ b/crates/wasi-common/virtfs/src/lib.rs @@ -0,0 +1,2 @@ +pub mod file; +pub mod dir;