diff --git a/crates/wasi-c2/cap-std-sync/Cargo.toml b/crates/wasi-c2/cap-std-sync/Cargo.toml index f61afb51a0..d396933560 100644 --- a/crates/wasi-c2/cap-std-sync/Cargo.toml +++ b/crates/wasi-c2/cap-std-sync/Cargo.toml @@ -22,5 +22,7 @@ fs-set-times = "0.2.2" unsafe-io = "0.2" system-interface = { version = "0.5.2", features = ["cap_std_impls"] } tracing = "0.1.19" -libc = "0.2" bitflags = "1.2" + +[target.'cfg(unix)'.dependencies] +libc = "0.2" diff --git a/crates/wasi-c2/src/file.rs b/crates/wasi-c2/src/file.rs index a034d09770..3f1e81395a 100644 --- a/crates/wasi-c2/src/file.rs +++ b/crates/wasi-c2/src/file.rs @@ -37,19 +37,17 @@ pub trait WasiFile { fn num_ready_bytes(&self) -> Result; // read op } -// XXX we will add pipes to wasi - lets add it to this internal enum and present them as -// Unknown to old wasis -// XXX put the enum variants in same order as WASI so conversion funcs are no-op #[derive(Debug, Copy, Clone)] pub enum FileType { - Directory, + Unknown, BlockDevice, CharacterDevice, + Directory, RegularFile, SocketDgram, SocketStream, SymbolicLink, - Unknown, + Pipe, } bitflags! { diff --git a/crates/wasi-c2/src/pipe.rs b/crates/wasi-c2/src/pipe.rs index f434e8fb0b..b0fb6f41c2 100644 --- a/crates/wasi-c2/src/pipe.rs +++ b/crates/wasi-c2/src/pipe.rs @@ -109,7 +109,7 @@ impl WasiFile for ReadPipe { Ok(()) // trivial } fn get_filetype(&self) -> Result { - Ok(FileType::CharacterDevice) // XXX wrong + Ok(FileType::Pipe) } fn get_fdflags(&self) -> Result { Ok(FdFlags::empty()) @@ -245,7 +245,7 @@ impl WasiFile for WritePipe { Ok(()) } fn get_filetype(&self) -> Result { - Ok(FileType::CharacterDevice) // XXX + Ok(FileType::Pipe) } fn get_fdflags(&self) -> Result { Ok(FdFlags::APPEND) diff --git a/crates/wasi-c2/src/snapshots/preview_1.rs b/crates/wasi-c2/src/snapshots/preview_1.rs index d5bd655713..d1656875b7 100644 --- a/crates/wasi-c2/src/snapshots/preview_1.rs +++ b/crates/wasi-c2/src/snapshots/preview_1.rs @@ -1294,6 +1294,7 @@ impl From<&FileType> for types::Filetype { FileType::SocketStream => types::Filetype::SocketStream, FileType::SymbolicLink => types::Filetype::SymbolicLink, FileType::Unknown => types::Filetype::Unknown, + FileType::Pipe => types::Filetype::Unknown, } } }