Replace std::os::unix::io for std::os::fd

This is just taking https://github.com/aya-rs/aya/pull/633 to its
logical conclusion. Because `std::os::fd` was only introduced as a
module in Rust v1.66.0 I have also updated the `Cargo.toml` of the
`aya` package to reflect the true MSRV. Note that this commit is *not*
the cause for this MSRV bump, that was done by a previous commit, this
commit is just making it explicit in the `Cargo.toml`
reviewable/pr662/r12
Andrés Medina 1 year ago
parent 1bc9a1ad04
commit c63d9904f7

@ -9,6 +9,7 @@ repository = "https://github.com/aya-rs/aya"
readme = "README.md"
documentation = "https://docs.rs/aya"
edition = "2021"
rust-version = "1.66"
[dependencies]
async-io = { workspace = true, optional = true }

@ -3,7 +3,7 @@ use std::{
collections::{HashMap, HashSet},
ffi::CString,
fs, io,
os::{raw::c_int, unix::io::RawFd},
os::{fd::RawFd, raw::c_int},
path::{Path, PathBuf},
};

@ -1,7 +1,7 @@
use std::{
ffi::c_void,
io, mem,
os::unix::io::{AsRawFd, RawFd},
os::fd::{AsRawFd, RawFd},
ptr, slice,
sync::atomic::{self, AtomicPtr, Ordering},
};

@ -4,7 +4,7 @@
use std::{
borrow::{Borrow, BorrowMut},
ops::Deref,
os::unix::io::{AsRawFd, RawFd},
os::fd::{AsRawFd, RawFd},
sync::Arc,
};
@ -64,7 +64,7 @@ impl<T: BorrowMut<MapData> + Borrow<MapData>> AsRawFd for PerfEventArrayBuffer<T
/// A map that can be used to receive events from eBPF programs using the linux [`perf`] API.
///
/// Each element of a [`PerfEventArray`] is a separate [`PerfEventArrayBuffer`] which can be used
/// to receive events sent by eBPF programs that use `bpf_perf_event_output()`.
/// to receive events sent by eBPF programs that use `bpf_perf_event_output()`.
///
/// To receive events you need to:
/// * call [`PerfEventArray::open`]
@ -138,7 +138,7 @@ impl<T: BorrowMut<MapData> + Borrow<MapData>> AsRawFd for PerfEventArrayBuffer<T
///
/// In the example above the implementation of `poll_buffers()` and `poll.poll_readable()` is not
/// given. [`PerfEventArrayBuffer`] implements the [`AsRawFd`] trait, so you can implement polling
/// using any crate that can poll file descriptors, like [epoll], [mio] etc.
/// using any crate that can poll file descriptors, like [epoll], [mio] etc.
///
/// Perf buffers are internally implemented as ring buffers. If your eBPF programs produce large
/// amounts of data, in order not to lose events you might want to process each

@ -5,7 +5,7 @@ mod sock_map;
pub use sock_hash::SockHash;
pub use sock_map::SockMap;
use std::os::unix::io::{AsRawFd, RawFd};
use std::os::fd::{AsRawFd, RawFd};
/// A socket map file descriptor.
#[derive(Copy, Clone)]

@ -1,7 +1,7 @@
use std::{
borrow::{Borrow, BorrowMut},
marker::PhantomData,
os::unix::io::{AsRawFd, RawFd},
os::fd::{AsRawFd, RawFd},
};
use crate::{
@ -42,7 +42,7 @@ use crate::{
/// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::io::Write;
/// use std::net::TcpStream;
/// use std::os::unix::io::AsRawFd;
/// use std::os::fd::AsRawFd;
/// use aya::maps::SockHash;
/// use aya::programs::SkMsg;
///

@ -354,7 +354,7 @@ pub enum LinkError {
#[cfg(test)]
mod tests {
use assert_matches::assert_matches;
use std::{cell::RefCell, fs::File, mem, os::unix::io::AsRawFd, rc::Rc};
use std::{cell::RefCell, fs::File, mem, os::fd::AsRawFd, rc::Rc};
use tempfile::tempdir;
use crate::{programs::ProgramError, sys::override_syscall};

@ -1,6 +1,6 @@
//! Perf attach links.
use libc::close;
use std::os::unix::io::RawFd;
use std::os::fd::RawFd;
use crate::{
generated::bpf_attach_type::BPF_PERF_EVENT,

@ -1,6 +1,6 @@
//! Skmsg programs.
use std::os::unix::io::AsRawFd;
use std::os::fd::AsRawFd;
use crate::{
generated::{bpf_attach_type::BPF_SK_MSG_VERDICT, bpf_prog_type::BPF_PROG_TYPE_SK_MSG},
@ -39,7 +39,7 @@ use crate::{
/// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::io::Write;
/// use std::net::TcpStream;
/// use std::os::unix::io::AsRawFd;
/// use std::os::fd::AsRawFd;
/// use aya::maps::SockHash;
/// use aya::programs::SkMsg;
///

@ -1,6 +1,6 @@
//! Skskb programs.
use std::{os::unix::io::AsRawFd, path::Path};
use std::{os::fd::AsRawFd, path::Path};
use crate::{
generated::{

@ -1,5 +1,5 @@
//! Socket option programs.
use std::os::unix::io::AsRawFd;
use std::os::fd::AsRawFd;
use crate::{
generated::{bpf_attach_type::BPF_CGROUP_SOCK_OPS, bpf_prog_type::BPF_PROG_TYPE_SOCK_OPS},

@ -48,7 +48,7 @@ pub enum SocketFilterError {
/// # }
/// # let mut bpf = aya::Bpf::load(&[])?;
/// use std::net::TcpStream;
/// use std::os::unix::io::AsRawFd;
/// use std::os::fd::AsRawFd;
/// use aya::programs::SocketFilter;
///
/// let mut client = TcpStream::connect("127.0.0.1:1234")?;

@ -1,5 +1,5 @@
//! Common functions shared between multiple eBPF program types.
use std::{ffi::CStr, io, os::unix::io::RawFd, path::Path};
use std::{ffi::CStr, io, os::fd::RawFd, path::Path};
use crate::{
programs::{FdLink, Link, ProgramData, ProgramError},

@ -3,7 +3,7 @@
use crate::util::KernelVersion;
use bitflags;
use libc::if_nametoindex;
use std::{convert::TryFrom, ffi::CString, hash::Hash, io, mem, os::unix::io::RawFd};
use std::{convert::TryFrom, ffi::CString, hash::Hash, io, mem, os::fd::RawFd};
use thiserror::Error;
use crate::{

@ -1,4 +1,4 @@
use std::{collections::HashMap, ffi::CStr, io, mem, os::unix::io::RawFd, ptr, slice};
use std::{collections::HashMap, ffi::CStr, io, mem, os::fd::RawFd, ptr, slice};
use thiserror::Error;
use libc::{

Loading…
Cancel
Save