Skip to content

Commit

Permalink
Merge pull request #3500 from jbaublitz/issue-project-672
Browse files Browse the repository at this point in the history
Update to nix 0.27.1
  • Loading branch information
mulkieran authored Nov 14, 2023
2 parents e11e58c + 1adcd1e commit 2288f9f
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 24 deletions.
25 changes: 23 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@ version = "0.4.19"
optional = true

[dependencies.nix]
version = "0.26.0"
version = "0.27.1"
optional = true
features = ["fs", "ioctl", "mount", "poll", "process", "sched", "signal", "socket"]

[dependencies.pretty-hex]
version = "0.3.0"
Expand Down
4 changes: 2 additions & 2 deletions src/engine/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
collections::{hash_map::RandomState, HashMap, HashSet},
fs::File,
io::Read,
os::unix::io::{AsRawFd, FromRawFd, RawFd},
os::unix::io::{FromRawFd, RawFd},
path::{Path, PathBuf},
};

Expand Down Expand Up @@ -118,7 +118,7 @@ pub fn set_key_shared(key_fd: RawFd, memory: &mut [u8]) -> StratisResult<usize>
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, PollFlags::POLLIN)];
let num_events = poll(&mut pollers, 0)?;
if num_events > 0 {
return Err(StratisError::Msg(format!(
Expand Down
7 changes: 1 addition & 6 deletions src/engine/strat_engine/tests/loopbacked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::{
env,
fs::{File, OpenOptions},
mem::forget,
os::unix::io::AsRawFd,
panic,
path::{Path, PathBuf},
sync::Once,
Expand Down Expand Up @@ -58,11 +57,7 @@ impl LoopTestDev {
.open(path)
.unwrap();

nix::unistd::ftruncate(
f.as_raw_fd(),
convert_test!(*size.bytes(), u128, nix::libc::off_t),
)
.unwrap();
nix::unistd::ftruncate(&f, convert_test!(*size.bytes(), u128, nix::libc::off_t)).unwrap();
f.sync_all().unwrap();

let ld = lc.next_free().unwrap();
Expand Down
17 changes: 9 additions & 8 deletions src/jsonrpc/server/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
fs::{create_dir_all, remove_file},
future::Future,
io::{IoSlice, IoSliceMut},
os::unix::io::{AsRawFd, RawFd},
os::unix::io::{AsRawFd, OwnedFd, RawFd},
path::Path,
pin::Pin,
sync::Arc,
Expand Down Expand Up @@ -418,7 +418,7 @@ impl Future for StratisUnixResponse {
}

pub struct StratisUnixListener {
fd: AsyncFd<RawFd>,
fd: AsyncFd<OwnedFd>,
}

impl StratisUnixListener {
Expand All @@ -438,12 +438,13 @@ 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)?,
})
Expand Down
10 changes: 5 additions & 5 deletions src/stratis/udev_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

//! Support for monitoring udev events.
use std::os::unix::io::{AsRawFd, RawFd};
use std::os::unix::io::{AsFd, AsRawFd, BorrowedFd};

use libudev::Event;
use nix::poll::{poll, PollFd, PollFlags};
Expand Down Expand Up @@ -32,8 +32,8 @@ pub async fn udev_thread(
let mut udev = UdevMonitor::create(&context)?;


let mut pollers = [PollFd::new(udev.as_raw_fd(), PollFlags::POLLIN)];
loop {
let mut pollers = [PollFd::new(&udev, PollFlags::POLLIN)];
match poll(&mut pollers, 100)? {
0 => {
match should_exit.try_recv() {
Expand Down Expand Up @@ -88,8 +88,8 @@ impl UdevMonitor {
}
}

impl AsRawFd for UdevMonitor {
fn as_raw_fd(&self) -> RawFd {
self.socket.as_raw_fd()
impl AsFd for UdevMonitor {
fn as_fd(&self) -> BorrowedFd<'_> {
unsafe { BorrowedFd::borrow_raw(self.socket.as_raw_fd()) }
}
}

0 comments on commit 2288f9f

Please sign in to comment.