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