|
|
|
@ -48,14 +48,14 @@ use thiserror::Error;
|
|
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
|
generated::bpf_map_type,
|
|
|
|
|
obj,
|
|
|
|
|
obj::{self, parse_map_info},
|
|
|
|
|
pin::PinError,
|
|
|
|
|
sys::{
|
|
|
|
|
bpf_create_map, bpf_get_object, bpf_map_get_info_by_fd, bpf_map_get_next_key,
|
|
|
|
|
bpf_pin_object, kernel_version,
|
|
|
|
|
},
|
|
|
|
|
util::nr_cpus,
|
|
|
|
|
Pod,
|
|
|
|
|
PinningType, Pod,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
mod map_lock;
|
|
|
|
@ -303,7 +303,7 @@ impl Map {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Loads a map from a pinned path in bpffs.
|
|
|
|
|
pub fn from_pinned<P: AsRef<Path>>(path: P) -> Result<Map, MapError> {
|
|
|
|
|
pub fn from_pin<P: AsRef<Path>>(path: P) -> Result<Map, MapError> {
|
|
|
|
|
let path_string =
|
|
|
|
|
CString::new(path.as_ref().to_string_lossy().into_owned()).map_err(|e| {
|
|
|
|
|
MapError::PinError {
|
|
|
|
@ -325,7 +325,7 @@ impl Map {
|
|
|
|
|
})?;
|
|
|
|
|
|
|
|
|
|
Ok(Map {
|
|
|
|
|
obj: obj::parse_map_info(info, crate::PinningType::ByName),
|
|
|
|
|
obj: parse_map_info(info, PinningType::ByName),
|
|
|
|
|
fd: Some(fd),
|
|
|
|
|
btf_fd: None,
|
|
|
|
|
pinned: true,
|
|
|
|
@ -334,7 +334,7 @@ impl Map {
|
|
|
|
|
|
|
|
|
|
/// Loads a map from a [`RawFd`].
|
|
|
|
|
///
|
|
|
|
|
/// If loading from a BPF Filesystem (bpffs) you should use [`Map::from_pinned`].
|
|
|
|
|
/// If loading from a BPF Filesystem (bpffs) you should use [`Map::from_pin`].
|
|
|
|
|
/// This API is intended for cases where you have received a valid BPF FD from some other means.
|
|
|
|
|
/// For example, you received an FD over Unix Domain Socket.
|
|
|
|
|
pub fn from_fd(fd: RawFd) -> Result<Map, MapError> {
|
|
|
|
@ -344,7 +344,7 @@ impl Map {
|
|
|
|
|
})?;
|
|
|
|
|
|
|
|
|
|
Ok(Map {
|
|
|
|
|
obj: obj::parse_map_info(info, crate::PinningType::None),
|
|
|
|
|
obj: parse_map_info(info, PinningType::None),
|
|
|
|
|
fd: Some(fd),
|
|
|
|
|
btf_fd: None,
|
|
|
|
|
pinned: false,
|
|
|
|
|