diff --git a/Cargo.lock b/Cargo.lock index 1d258d7841..17274c53aa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -861,6 +861,15 @@ dependencies = [ "autocfg", ] +[[package]] +name = "memoffset" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" +dependencies = [ + "autocfg", +] + [[package]] name = "minimal-lexical" version = "0.2.1" @@ -900,11 +909,23 @@ dependencies = [ "bitflags 1.3.2", "cfg-if 1.0.0", "libc", - "memoffset", + "memoffset 0.7.1", "pin-utils", "static_assertions", ] +[[package]] +name = "nix" +version = "0.27.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +dependencies = [ + "bitflags 2.4.0", + "cfg-if 1.0.0", + "libc", + "memoffset 0.9.0", +] + [[package]] name = "nom" version = "7.1.3" @@ -1297,7 +1318,7 @@ dependencies = [ "libudev", "log", "loopdev", - "nix 0.26.2", + "nix 0.27.1", "pkg-config", "predicates", "pretty-hex", diff --git a/Cargo.toml b/Cargo.toml index 25326b83c1..3860718e39 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -155,7 +155,8 @@ version = "0.4.19" optional = true [dependencies.nix] -version = "0.26.0" +version = "0.27.1" +features = ["fs", "ioctl", "mount", "poll", "process", "sched", "socket"] optional = true [dependencies.pretty-hex] diff --git a/src/engine/shared.rs b/src/engine/shared.rs index 10be45abfa..b26b2ffcf2 100644 --- a/src/engine/shared.rs +++ b/src/engine/shared.rs @@ -6,7 +6,8 @@ use std::{ collections::{hash_map::RandomState, HashMap, HashSet}, fs::File, io::Read, - os::unix::io::{AsRawFd, FromRawFd, RawFd}, + os::fd::AsFd, + os::unix::io::{FromRawFd, RawFd}, path::{Path, PathBuf}, }; @@ -118,7 +119,7 @@ pub fn set_key_shared(key_fd: RawFd, memory: &mut [u8]) -> StratisResult let bytes_read = key_file.read(memory)?; if bytes_read == MAX_STRATIS_PASS_SIZE { - let mut pollers = [PollFd::new(key_file.as_raw_fd(), PollFlags::POLLIN)]; + let mut pollers = [PollFd::new(&key_file.as_fd(), PollFlags::POLLIN)]; let num_events = poll(&mut pollers, 0)?; if num_events > 0 { return Err(StratisError::Msg(format!( diff --git a/src/engine/strat_engine/tests/loopbacked.rs b/src/engine/strat_engine/tests/loopbacked.rs index 6070134846..67eb55d102 100644 --- a/src/engine/strat_engine/tests/loopbacked.rs +++ b/src/engine/strat_engine/tests/loopbacked.rs @@ -6,7 +6,7 @@ use std::{ env, fs::{File, OpenOptions}, mem::forget, - os::unix::io::AsRawFd, + os::fd::AsFd, panic, path::{Path, PathBuf}, sync::Once, @@ -59,7 +59,7 @@ impl LoopTestDev { .unwrap(); nix::unistd::ftruncate( - f.as_raw_fd(), + f.as_fd(), convert_test!(*size.bytes(), u128, nix::libc::off_t), ) .unwrap(); diff --git a/src/jsonrpc/server/server.rs b/src/jsonrpc/server/server.rs index c0f4c89085..be9c24a6ae 100644 --- a/src/jsonrpc/server/server.rs +++ b/src/jsonrpc/server/server.rs @@ -438,14 +438,15 @@ impl StratisUnixListener { SockFlag::empty(), None, )?; - let flags = OFlag::from_bits(fcntl(fd, FcntlArg::F_GETFL)?).ok_or_else(|| { - StratisError::Msg("Unrecognized flag types returned from fcntl".to_string()) - })?; - fcntl(fd, FcntlArg::F_SETFL(flags | OFlag::O_NONBLOCK))?; - bind(fd, &UnixAddr::new(path.as_ref())?)?; - listen(fd, 0)?; + let flags = + OFlag::from_bits(fcntl(fd.as_raw_fd(), FcntlArg::F_GETFL)?).ok_or_else(|| { + StratisError::Msg("Unrecognized flag types returned from fcntl".to_string()) + })?; + fcntl(fd.as_raw_fd(), FcntlArg::F_SETFL(flags | OFlag::O_NONBLOCK))?; + bind(fd.as_raw_fd(), &UnixAddr::new(path.as_ref())?)?; + listen(&fd, 0)?; Ok(StratisUnixListener { - fd: AsyncFd::new(fd)?, + fd: AsyncFd::new(fd.as_raw_fd())?, }) } }