Skip to content

Commit

Permalink
Merge #446
Browse files Browse the repository at this point in the history
446: apply base path update to wasi::path_filestat_get r=MarkMcCaskey a=MarkMcCaskey

resolves #434 (again)

causes `path_filestat_get` to start at the base path calculated from the fd passed in.  This technique was applied to `path_open` but didn't make it to `path_filestat_get`, this fixes that

Co-authored-by: Mark McCaskey <mark@wasmer.io>
  • Loading branch information
bors[bot] and MarkMcCaskey committed May 15, 2019
2 parents 6b43a6a + ace7a19 commit 245cc32
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/wasi/src/syscalls/mod.rs
Expand Up @@ -791,6 +791,7 @@ pub fn fd_readdir(
let entry_path = entry.path();
let entry_path_str = entry_path.to_string_lossy();
let namlen = entry_path_str.len();
debug!("Returning dirent for {}", entry_path_str);
let dirent = __wasi_dirent_t {
d_next: cur_cookie,
d_ino: 0, // TODO: inode
Expand Down Expand Up @@ -1151,7 +1152,10 @@ pub fn path_filestat_get(
if path_vec.is_empty() {
return __WASI_EINVAL;
}
let mut cumulative_path = std::path::PathBuf::new();
let mut cumulative_path = std::path::PathBuf::from(wasi_try!(state
.fs
.get_base_path_for_directory(root_dir.inode)
.ok_or(__WASI_EIO)));

debug!("=> Path vec: {:?}:", &path_vec);
// find the inode by traversing the path
Expand Down Expand Up @@ -1455,7 +1459,6 @@ pub fn path_open(
};
// TODO: handle __WASI_O_TRUNC on directories

dbg!(&cumulative_path);
// TODO: refactor and reuse
let cur_file_metadata =
wasi_try!(cumulative_path.metadata().map_err(|_| __WASI_EINVAL));
Expand Down Expand Up @@ -1554,10 +1557,8 @@ pub fn path_open(
open_options
};
debug!("Opening host file {:?}", &file_path);
let real_open_file = wasi_try!(open_options.open(&file_path).map_err(|e| {
dbg!(e);
__WASI_EIO
}));
let real_open_file =
wasi_try!(open_options.open(&file_path).map_err(|_| __WASI_EIO));

real_open_file
};
Expand Down

0 comments on commit 245cc32

Please sign in to comment.