change the preopen strategy again, implement more calls

This commit is contained in:
Pat Hickey
2020-12-03 17:12:21 -08:00
parent 40f8f69e03
commit 05ecdbfa96
6 changed files with 116 additions and 36 deletions

24
crates/wasi-c2/src/dir.rs Normal file
View File

@@ -0,0 +1,24 @@
use std::path::PathBuf;
pub trait WasiDir {}
pub(crate) struct DirEntry {
pub(crate) flags: u32,
pub(crate) preopen_path: Option<PathBuf>, // precondition: PathBuf is valid unicode
pub(crate) dir: Box<dyn WasiDir>,
}
pub trait TableDirExt {
fn is_preopen(&self, fd: u32) -> bool;
}
impl TableDirExt for crate::table::Table {
fn is_preopen(&self, fd: u32) -> bool {
if self.is::<DirEntry>(fd) {
let dir_entry: std::cell::RefMut<DirEntry> = self.get(fd).unwrap();
dir_entry.preopen_path.is_some()
} else {
false
}
}
}