make a pipe filetype, reorder filetype enum

This commit is contained in:
Pat Hickey
2021-01-22 11:37:39 -08:00
parent 86d369c72a
commit a06c4fbe1a
4 changed files with 9 additions and 8 deletions

View File

@@ -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"

View File

@@ -37,19 +37,17 @@ pub trait WasiFile {
fn num_ready_bytes(&self) -> Result<u64, Error>; // 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! {

View File

@@ -109,7 +109,7 @@ impl<R: Read + Any> WasiFile for ReadPipe<R> {
Ok(()) // trivial
}
fn get_filetype(&self) -> Result<FileType, Error> {
Ok(FileType::CharacterDevice) // XXX wrong
Ok(FileType::Pipe)
}
fn get_fdflags(&self) -> Result<FdFlags, Error> {
Ok(FdFlags::empty())
@@ -245,7 +245,7 @@ impl<W: Write + Any> WasiFile for WritePipe<W> {
Ok(())
}
fn get_filetype(&self) -> Result<FileType, Error> {
Ok(FileType::CharacterDevice) // XXX
Ok(FileType::Pipe)
}
fn get_fdflags(&self) -> Result<FdFlags, Error> {
Ok(FdFlags::APPEND)

View File

@@ -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,
}
}
}