#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct RawTracePointFileDescriptor(RawFd);
impl Drop for RawTracePointFileDescriptor
{
#[inline(always)]
fn drop(&mut self)
{
self.as_raw_fd().close()
}
}
impl AsRawFd for RawTracePointFileDescriptor
{
#[inline(always)]
fn as_raw_fd(&self) -> RawFd
{
self.0
}
}
impl IntoRawFd for RawTracePointFileDescriptor
{
#[inline(always)]
fn into_raw_fd(self) -> RawFd
{
self.as_raw_fd()
}
}
impl FromRawFd for RawTracePointFileDescriptor
{
#[inline(always)]
unsafe fn from_raw_fd(fd: RawFd) -> Self
{
Self(fd)
}
}
impl FileDescriptor for RawTracePointFileDescriptor
{
}
impl ProcessQueryableFileDescriptor for RawTracePointFileDescriptor
{
}
impl LinkFileDescriptor for RawTracePointFileDescriptor
{
}
impl RawTracePointFileDescriptor
{
#[inline(always)]
pub fn attach(extended_bpf_program_file_descriptor: &ExtendedBpfProgramFileDescriptor, raw_trace_point_type: &RawTracePointType) -> Result<Self, RawTracePointAttachError>
{
use self::RawTracePointType::*;
let name = match raw_trace_point_type
{
TracingOfRawTracePoint => AlignedU64::Null,
RawTracePoint(TracePointDetails { ref trace_point_name }) => AlignedU64::from(trace_point_name.as_ptr()),
RawTracePointWritable(TracePointDetails { ref trace_point_name }) => AlignedU64::from(trace_point_name.as_ptr()),
};
use self::RawTracePointAttachError::*;
match raw_trace_point_open(extended_bpf_program_file_descriptor, name)
{
Ok(raw_fd) => Ok(Self(raw_fd)),
Err(errno) => match errno
{
ENOENT => Err(TracePointNameNotFound),
ENOMEM => Err(OutOfMemory),
_ => unreachable_code(format_args!("")),
}
}
}
}