From f3419239a79eb19e86eb1635b4e9b9547c94a7e7 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Mon, 31 May 2021 17:18:55 +0200 Subject: [PATCH] chore(wasi) Remove the deprecated code. --- lib/wasi/src/lib.rs | 7 -- lib/wasi/src/state/builder.rs | 2 - lib/wasi/src/state/mod.rs | 125 +--------------------------------- 3 files changed, 1 insertion(+), 133 deletions(-) diff --git a/lib/wasi/src/lib.rs b/lib/wasi/src/lib.rs index 944ab34e7f7..181f485b982 100644 --- a/lib/wasi/src/lib.rs +++ b/lib/wasi/src/lib.rs @@ -105,13 +105,6 @@ impl WasiEnv { self.state.lock().unwrap() } - // TODO: delete this method before 1.0.0 release - #[doc(hidden)] - #[deprecated(since = "1.0.0-beta1", note = "Please use the `state` method instead")] - pub fn state_mut(&mut self) -> MutexGuard { - self.state.lock().unwrap() - } - /// Get a reference to the memory pub fn memory(&self) -> &Memory { self.memory_ref() diff --git a/lib/wasi/src/state/builder.rs b/lib/wasi/src/state/builder.rs index 3422601cd0a..e950decd110 100644 --- a/lib/wasi/src/state/builder.rs +++ b/lib/wasi/src/state/builder.rs @@ -361,8 +361,6 @@ impl WasiStateBuilder { // self.preopens are checked in [`PreopenDirBuilder::build`] - // this deprecation warning only applies to external callers - #[allow(deprecated)] let mut wasi_fs = WasiFs::new_with_preopen(&self.preopens) .map_err(WasiStateCreationError::WasiFsCreationError)?; // set up the file system, overriding base files and calling the setup function diff --git a/lib/wasi/src/state/mod.rs b/lib/wasi/src/state/mod.rs index f58c7e48cb1..4766b8006ab 100644 --- a/lib/wasi/src/state/mod.rs +++ b/lib/wasi/src/state/mod.rs @@ -71,7 +71,7 @@ pub struct InodeVal { #[derive(Debug, Serialize, Deserialize)] pub enum Kind { File { - /// the open file, if it's open + /// The open file, if it's open handle: Option>, /// The path on the host system where the file is located /// This is deprecated and will be removed soon @@ -166,129 +166,6 @@ pub struct WasiFs { } impl WasiFs { - /// Internal function for constructing a [`WasiFs`]. Please use - /// [`WasiState::new`]. - #[deprecated( - since = "0.14.0", - note = "This method will change or be made private in the future. Please use `WasiState::new` and the builder API instead." - )] - pub fn new( - preopened_dirs: &[PathBuf], - mapped_dirs: &[(String, PathBuf)], - ) -> Result { - let (mut wasi_fs, root_inode) = Self::new_init()?; - - debug!("wasi::fs::preopen_dirs"); - for dir in preopened_dirs { - debug!("Attempting to preopen {}", &dir.to_string_lossy()); - // TODO: think about this - let default_rights = ALL_RIGHTS; - let cur_dir_metadata = dir.metadata().map_err(|e| { - format!( - "Could not get metadata for file {:?}: {}", - dir, - e.to_string() - ) - })?; - let kind = if cur_dir_metadata.is_dir() { - Kind::Dir { - parent: Some(root_inode), - path: dir.clone(), - entries: Default::default(), - } - } else { - return Err(format!( - "WASI only supports pre-opened directories right now; found \"{}\"", - &dir.to_string_lossy() - )); - }; - // TODO: handle nested pats in `file` - let inode = wasi_fs - .create_inode(kind, true, dir.to_string_lossy().into_owned()) - .map_err(|e| { - format!( - "Failed to create inode for preopened dir: WASI error code: {}", - e - ) - })?; - let fd = wasi_fs - .create_fd( - default_rights, - default_rights, - 0, - Fd::READ | Fd::WRITE, - inode, - ) - .map_err(|e| format!("Could not open fd for file {:?}: {}", dir, e))?; - if let Kind::Root { entries } = &mut wasi_fs.inodes[root_inode].kind { - let result = entries.insert(dir.to_string_lossy().into_owned(), inode); - if result.is_some() { - return Err(format!( - "Error: found collision in preopened directory names, `{}`", - dir.to_string_lossy() - )); - } - } - wasi_fs.preopen_fds.push(fd); - } - debug!("wasi::fs::mapped_dirs"); - for (alias, real_dir) in mapped_dirs { - debug!("Attempting to open {:?} at {}", real_dir, alias); - // TODO: think about this - let default_rights = ALL_RIGHTS; - let cur_dir_metadata = real_dir.metadata().map_err(|e| { - format!( - "Could not get metadata for file {:?}: {}", - &real_dir, - e.to_string() - ) - })?; - let kind = if cur_dir_metadata.is_dir() { - Kind::Dir { - parent: Some(root_inode), - path: real_dir.clone(), - entries: Default::default(), - } - } else { - return Err(format!( - "WASI only supports pre-opened directories right now; found \"{:?}\"", - &real_dir, - )); - }; - // TODO: handle nested pats in `file` - let inode = wasi_fs - .create_inode(kind, true, alias.clone()) - .map_err(|e| { - format!( - "Failed to create inode for preopened dir: WASI error code: {}", - e - ) - })?; - let fd = wasi_fs - .create_fd( - default_rights, - default_rights, - 0, - Fd::READ | Fd::WRITE, - inode, - ) - .map_err(|e| format!("Could not open fd for file {:?}: {}", &real_dir, e))?; - if let Kind::Root { entries } = &mut wasi_fs.inodes[root_inode].kind { - let result = entries.insert(alias.clone(), inode); - if result.is_some() { - return Err(format!( - "Error: found collision in preopened directory aliases, `{}`", - alias, - )); - } - } - wasi_fs.preopen_fds.push(fd); - } - - debug!("wasi::fs::end"); - Ok(wasi_fs) - } - /// Created for the builder API. like `new` but with more information pub(crate) fn new_with_preopen(preopens: &[PreopenedDir]) -> Result { let (mut wasi_fs, root_inode) = Self::new_init()?;