Rename the syscalls module to sys

pull/1/head
Alessandro Decina 4 years ago
parent e83a26b307
commit 8f5a17b542

@ -12,7 +12,7 @@ use crate::{
maps::{Map, MapError},
obj::{btf::BtfError, Object, ParseError},
programs::{KProbe, Program, ProgramData, ProgramError, SocketFilter, TracePoint, UProbe, Xdp},
syscalls::bpf_map_update_elem_ptr,
sys::bpf_map_update_elem_ptr,
};
pub(crate) const BPF_OBJ_NAME_LEN: usize = 16;

@ -8,6 +8,6 @@ mod generated;
pub mod maps;
mod obj;
pub mod programs;
mod syscalls;
mod sys;
pub use bpf::*;

@ -9,7 +9,7 @@ use std::{
use crate::{
generated::bpf_map_type::BPF_MAP_TYPE_HASH,
maps::{IterableMap, Map, MapError, MapIter, MapKeys},
syscalls::{
sys::{
bpf_map_delete_elem, bpf_map_lookup_and_delete_elem, bpf_map_lookup_elem,
bpf_map_update_elem,
},
@ -142,7 +142,7 @@ mod tests {
bpf_map_type::{BPF_MAP_TYPE_HASH, BPF_MAP_TYPE_PERF_EVENT_ARRAY},
},
obj,
syscalls::{override_syscall, SysResult, Syscall},
sys::{override_syscall, SysResult, Syscall},
};
use super::*;

@ -3,7 +3,7 @@ use thiserror::Error;
use crate::{
obj,
syscalls::{bpf_create_map, bpf_map_get_next_key},
sys::{bpf_create_map, bpf_map_get_next_key},
Pod, RawFd,
};
@ -196,7 +196,7 @@ mod tests {
use crate::{
bpf_map_def,
generated::{bpf_cmd, bpf_map_type::BPF_MAP_TYPE_HASH},
syscalls::{override_syscall, Syscall},
sys::{override_syscall, Syscall},
};
use super::*;

@ -21,7 +21,7 @@ use crate::{
perf_event_type::*,
},
maps::{Map, MapError},
syscalls::{bpf_map_update_elem, perf_event_ioctl, perf_event_open},
sys::{bpf_map_update_elem, perf_event_ioctl, perf_event_open},
RawFd, PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE,
};
@ -397,7 +397,7 @@ unsafe fn mmap(
return libc::mmap(addr, len, prot, flags, fd, offset);
#[cfg(test)]
use crate::syscalls::TEST_MMAP_RET;
use crate::sys::TEST_MMAP_RET;
#[cfg(test)]
TEST_MMAP_RET.with(|ret| *ret.borrow())
@ -423,7 +423,7 @@ mod tests {
use super::*;
use crate::{
generated::perf_event_mmap_page,
syscalls::{override_syscall, Syscall, TEST_MMAP_RET},
sys::{override_syscall, Syscall, TEST_MMAP_RET},
};
use std::{convert::TryInto, fmt::Debug, iter::FromIterator, mem};

@ -10,7 +10,7 @@ use crate::{
generated::bpf_map_type::BPF_MAP_TYPE_PROG_ARRAY,
maps::{IterableMap, Map, MapError, MapIter, MapKeys},
programs::ProgramFd,
syscalls::{
sys::{
bpf_map_delete_elem, bpf_map_lookup_and_delete_elem, bpf_map_lookup_elem,
bpf_map_update_elem,
},

@ -23,7 +23,7 @@ pub use socket_filter::*;
pub use trace_point::*;
pub use xdp::*;
use crate::{obj, syscalls::bpf_load_program, RawFd};
use crate::{obj, sys::bpf_load_program, RawFd};
#[derive(Debug, Error)]
pub enum ProgramError {
#[error("the program {program} is already loaded")]

@ -3,7 +3,7 @@ use std::{cell::RefCell, rc::Rc};
use libc::close;
use crate::{
syscalls::perf_event_ioctl, RawFd, PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE,
sys::perf_event_ioctl, RawFd, PERF_EVENT_IOC_DISABLE, PERF_EVENT_IOC_ENABLE,
PERF_EVENT_IOC_SET_BPF,
};

@ -13,7 +13,7 @@ use thiserror::Error;
use crate::{
generated::bpf_prog_type::BPF_PROG_TYPE_KPROBE,
programs::{load_program, perf_attach, Link, ProgramData, ProgramError},
syscalls::perf_event_open_probe,
sys::perf_event_open_probe,
};
lazy_static! {

@ -1,8 +1,6 @@
use std::fs;
use crate::{
generated::bpf_prog_type::BPF_PROG_TYPE_TRACEPOINT, syscalls::perf_event_open_trace_point,
};
use crate::{generated::bpf_prog_type::BPF_PROG_TYPE_TRACEPOINT, sys::perf_event_open_trace_point};
use super::{load_program, perf_attach, Link, ProgramData, ProgramError};

@ -6,7 +6,7 @@ use crate::RawFd;
use crate::{
generated::{bpf_attach_type::BPF_XDP, bpf_prog_type::BPF_PROG_TYPE_XDP},
programs::{load_program, FdLink, Link, LinkRef, ProgramData, ProgramError},
syscalls::bpf_link_create,
sys::bpf_link_create,
};
#[derive(Debug)]

@ -12,7 +12,7 @@ use crate::{
bpf_map_def,
generated::{bpf_attach_type, bpf_attr, bpf_cmd, bpf_insn},
programs::VerifierLog,
syscalls::SysResult,
sys::SysResult,
Pod, RawFd, BPF_OBJ_NAME_LEN,
};

@ -17,6 +17,7 @@ unsafe fn test_syscall(_call: Syscall) -> SysResult {
return Err((-1, io::Error::from_raw_os_error(libc::EINVAL)));
}
#[cfg(test)]
pub(crate) fn override_syscall(call: unsafe fn(Syscall) -> SysResult) {
TEST_SYSCALL.with(|test_impl| *test_impl.borrow_mut() = call);
}

@ -85,5 +85,5 @@ pub(crate) fn perf_event_ioctl(fd: c_int, request: c_ulong, arg: c_int) -> SysRe
return syscall(call);
#[cfg(test)]
return crate::syscalls::TEST_SYSCALL.with(|test_impl| unsafe { test_impl.borrow()(call) });
return crate::sys::TEST_SYSCALL.with(|test_impl| unsafe { test_impl.borrow()(call) });
}
Loading…
Cancel
Save