diff options
| -rw-r--r-- | Cargo.toml | 24 | ||||
| -rw-r--r-- | examples/ext2.rs | 7 | ||||
| -rw-r--r-- | src/fuse/mount.rs | 5 | ||||
| -rw-r--r-- | src/fuse/session.rs | 12 | ||||
| -rw-r--r-- | src/util.rs | 14 |
5 files changed, 25 insertions, 37 deletions
@@ -12,20 +12,20 @@ mount = ["server"] client = [] [dependencies] -async-trait = "0.1.42" -bitflags = "1.2.1" -bytemuck = "1.5.0" +async-trait = "0.1.52" +bitflags = "1.3.2" +bytemuck = "1.7.3" bytemuck_derive = "1.0.1" -futures-util = "0.3.12" +futures-util = "0.3.19" log = "0.4.14" -nix = "0.19.1" -num_enum = "0.5.1" -quick-error = "2.0.0" -smallvec = "1.6.1" -tokio = { version = "1.2.0", features = ["rt", "net", "macros", "sync"] } +nix = "0.23.1" +num_enum = "0.5.5" +quick-error = "2.0.1" +smallvec = "1.7.0" +tokio = { version = "1.15.0", features = ["rt", "net", "macros", "sync"] } [dev-dependencies] -clap = "2.33.3" -env_logger = "0.8.2" -tokio = { version = "1.2.0", features = ["rt-multi-thread"] } +clap = "2.34.0" +env_logger = "0.9.0" +tokio = { version = "1.15.0", features = ["rt-multi-thread"] } uuid = "0.8.2" diff --git a/examples/ext2.rs b/examples/ext2.rs index 01bbf4b..996d1fd 100644 --- a/examples/ext2.rs +++ b/examples/ext2.rs @@ -476,11 +476,8 @@ impl blown_fuse::fs::Inode for Inode { } } -fn early_error<T, E>(_: ()) -> Result<T, E> -where - nix::Error: Into<E>, -{ - Err(nix::Error::Sys(Errno::EINVAL).into()) +fn early_error<T, E: From<Errno>>(_: ()) -> Result<T, E> { + Err(Errno::EINVAL.into()) } fn main() -> Result<(), Box<dyn std::error::Error>> { diff --git a/src/fuse/mount.rs b/src/fuse/mount.rs index ebf7e5d..955b28a 100644 --- a/src/fuse/mount.rs +++ b/src/fuse/mount.rs @@ -1,5 +1,6 @@ use std::{ ffi::{OsStr, OsString}, + io, os::unix::{ ffi::OsStrExt, io::{AsRawFd, IntoRawFd, RawFd}, @@ -17,7 +18,7 @@ use nix::{ use quick_error::quick_error; use super::Start; -use crate::util::{from_nix_error, DumbFd}; +use crate::util::DumbFd; quick_error! { #[derive(Debug)] @@ -131,7 +132,7 @@ where Some(&mut buffer), MsgFlags::empty(), ) - .map_err(from_nix_error)?; + .map_err(io::Error::from)?; let session_fd = match message.cmsgs().next() { Some(ControlMessageOwned::ScmRights(fds)) => fds.into_iter().next(), diff --git a/src/fuse/session.rs b/src/fuse/session.rs index 35ebb69..4a34aae 100644 --- a/src/fuse/session.rs +++ b/src/fuse/session.rs @@ -1,7 +1,8 @@ use std::{ collections::{hash_map, HashMap}, convert::TryInto, - os::unix::io::IntoRawFd, + io, + os::unix::io::{IntoRawFd, RawFd}, sync::{Arc, Mutex}, }; @@ -21,7 +22,7 @@ use smallvec::SmallVec; use crate::{ proto::{self, InHeader}, - util::{display_or, from_nix_error, OutputChain}, + util::{display_or, OutputChain}, Errno, FuseError, FuseResult, Ino, }; @@ -140,7 +141,7 @@ impl<Fs: Fuse> Session<Fs> { IoVec::from_mut_slice(large_buffer), ]; - let bytes = readv(*self.session_fd.get_ref(), &mut io_vecs).map_err(from_nix_error)?; + let bytes = readv(*self.session_fd.get_ref(), &mut io_vecs).map_err(io::Error::from)?; InputBuffer { bytes, data } }; @@ -429,7 +430,8 @@ impl<Fs: Fuse> Session<Fs> { IoVec::from_mut_slice(&mut large_buffer[SBO_SIZE..]), ]; - match readable.try_io(|fd| readv(*fd.get_ref(), &mut io_vecs).map_err(from_nix_error)) { + let mut read = |fd: &AsyncFd<RawFd>| readv(*fd.get_ref(), &mut io_vecs); + match readable.try_io(|fd| read(fd).map_err(io::Error::from)) { Ok(Ok(bytes)) => { if bytes > SBO_SIZE { (&mut large_buffer[..SBO_SIZE]).copy_from_slice(sbo); @@ -479,7 +481,7 @@ impl<Fs: Fuse> Session<Fs> { .map(IoVec::from_slice) .collect(); - let written = writev(*self.session_fd.get_ref(), &buffers).map_err(from_nix_error)?; + let written = writev(*self.session_fd.get_ref(), &buffers).map_err(io::Error::from)?; if written == length as usize { Ok(()) } else { diff --git a/src/util.rs b/src/util.rs index dba954b..7263738 100644 --- a/src/util.rs +++ b/src/util.rs @@ -3,7 +3,7 @@ use std::{ os::unix::io::{IntoRawFd, RawFd}, }; -use nix::{self, errno::Errno, unistd::close}; +use nix::unistd::close; use quick_error::quick_error; quick_error! { @@ -79,18 +79,6 @@ impl<'a> Iterator for OutputChainIter<'a> { } } -pub fn from_nix_error(error: nix::Error) -> std::io::Error { - use nix::Error::*; - let from_raw = |code| std::io::Error::from_raw_os_error(code as i32); - - match error { - Sys(errno) => errno.into(), - InvalidPath => from_raw(Errno::ENAMETOOLONG), - InvalidUtf8 => from_raw(Errno::EILSEQ), - UnsupportedOperation => from_raw(Errno::EOPNOTSUPP), - } -} - pub fn display_or<'a, T: fmt::Display + 'a>( maybe: Option<T>, default: &'a str, |
