From c1c99dbff1886ed49148483e6a9ed6b2e0313a51 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Wed, 3 Apr 2019 17:01:02 -0700 Subject: [PATCH] rename fs and fix (probable) bug in renumber syscall --- lib/wasi/src/state.rs | 2 +- lib/wasi/src/syscalls/mod.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/wasi/src/state.rs b/lib/wasi/src/state.rs index d56f2f5bec2..5b42ba1c7f8 100644 --- a/lib/wasi/src/state.rs +++ b/lib/wasi/src/state.rs @@ -63,7 +63,7 @@ impl WasiFs { Ok(Self { repo: RepoOpener::new() .create(true) - .open("mem://foo", "") + .open("mem://wasmer-test-fs", "") .map_err(|e| e.to_string())?, name_map: HashMap::new(), inodes: Arena::new(), diff --git a/lib/wasi/src/syscalls/mod.rs b/lib/wasi/src/syscalls/mod.rs index 068e4ed7801..15f0f26798a 100644 --- a/lib/wasi/src/syscalls/mod.rs +++ b/lib/wasi/src/syscalls/mod.rs @@ -8,7 +8,7 @@ pub mod windows; use self::types::*; use crate::{ ptr::{Array, WasmPtr}, - state::{Kind, WasiState, MAX_SYMLINKS}, + state::{Fd, Kind, WasiState, MAX_SYMLINKS}, }; use rand::{thread_rng, Rng}; use std::cell::Cell; @@ -768,7 +768,14 @@ pub fn fd_renumber(ctx: &mut Ctx, from: __wasi_fd_t, to: __wasi_fd_t) -> __wasi_ let state = get_wasi_state(ctx); let fd_entry = wasi_try!(state.fs.fd_map.get(&from).ok_or(__WASI_EBADF)); - state.fs.fd_map.insert(to, fd_entry.clone()); + state.fs.fd_map.insert( + to, + Fd { + // TODO: verify this is correct + rights: fd_entry.rights_inheriting, + ..*fd_entry + }, + ); __WASI_ESUCCESS }