mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
flip order of args in mapdir
This commit is contained in:
parent
be4dd453c2
commit
7cc967e709
@ -30,7 +30,7 @@ pub fn generate_import_object(
|
||||
args: Vec<Vec<u8>>,
|
||||
envs: Vec<Vec<u8>>,
|
||||
preopened_files: Vec<String>,
|
||||
mapped_dirs: Vec<(PathBuf, String)>,
|
||||
mapped_dirs: Vec<(String, PathBuf)>,
|
||||
) -> ImportObject {
|
||||
let state_gen = move || {
|
||||
fn state_destructor(data: *mut c_void) {
|
||||
|
@ -177,7 +177,7 @@ pub struct WasiFs {
|
||||
impl WasiFs {
|
||||
pub fn new(
|
||||
preopened_dirs: &[String],
|
||||
mapped_dirs: &[(PathBuf, String)],
|
||||
mapped_dirs: &[(String, PathBuf)],
|
||||
) -> Result<Self, String> {
|
||||
debug!("wasi::fs::inodes");
|
||||
let inodes = Arena::new();
|
||||
@ -218,28 +218,28 @@ impl WasiFs {
|
||||
.expect("Could not open fd");
|
||||
}
|
||||
debug!("wasi::fs::mapped_dirs");
|
||||
for (src_dir, dest_dir) in mapped_dirs {
|
||||
debug!("Attempting to open {:?} at {}", src_dir, dest_dir);
|
||||
for (alias, real_dir) in mapped_dirs {
|
||||
debug!("Attempting to open {:?} at {}", dest_dir, alias);
|
||||
// TODO: think about this
|
||||
let default_rights = 0x1FFFFFFF; // all rights
|
||||
let cur_dir_metadata = src_dir
|
||||
let cur_dir_metadata = real_dir
|
||||
.metadata()
|
||||
.expect("mapped dir not at previously verified location");
|
||||
let kind = if cur_dir_metadata.is_dir() {
|
||||
Kind::Dir {
|
||||
parent: None,
|
||||
path: src_dir.clone(),
|
||||
path: real_dir.clone(),
|
||||
entries: Default::default(),
|
||||
}
|
||||
} else {
|
||||
return Err(format!(
|
||||
"WASI only supports pre-opened directories right now; found \"{:?}\"",
|
||||
&src_dir,
|
||||
&real_dir,
|
||||
));
|
||||
};
|
||||
// TODO: handle nested pats in `file`
|
||||
let inode_val =
|
||||
InodeVal::from_file_metadata(&cur_dir_metadata, dest_dir.clone(), true, kind);
|
||||
InodeVal::from_file_metadata(&cur_dir_metadata, alias.clone(), true, kind);
|
||||
|
||||
let inode = wasi_fs.inodes.insert(inode_val);
|
||||
wasi_fs.inodes[inode].stat.st_ino = wasi_fs.inode_counter.get();
|
||||
|
@ -234,16 +234,19 @@ fn execute_wasm(options: &Run) -> Result<(), String> {
|
||||
let mapped_dirs = {
|
||||
let mut md = vec![];
|
||||
for entry in options.mapped_dirs.iter() {
|
||||
if let &[source, dest] = &entry.split(':').collect::<Vec<&str>>()[..] {
|
||||
let pb = PathBuf::from(&source);
|
||||
if let &[alias, real_dir] = &entry.split(':').collect::<Vec<&str>>()[..] {
|
||||
let pb = PathBuf::from(&real_dir);
|
||||
if let Ok(pb_metadata) = pb.metadata() {
|
||||
if !pb_metadata.is_dir() {
|
||||
return Err(format!("\"{}\" exists, but it is not a directory", &source));
|
||||
return Err(format!(
|
||||
"\"{}\" exists, but it is not a directory",
|
||||
&real_dir
|
||||
));
|
||||
}
|
||||
} else {
|
||||
return Err(format!("Directory \"{}\" does not exist", &source));
|
||||
return Err(format!("Directory \"{}\" does not exist", &real_dir));
|
||||
}
|
||||
md.push((pb, dest.to_string()));
|
||||
md.push((alias.to_string(), pb));
|
||||
continue;
|
||||
}
|
||||
return Err(format!(
|
||||
|
Loading…
Reference in New Issue
Block a user