kbpf_basic/
raw_tracepoint.rs1use alloc::string::String;
3
4use crate::{BpfError, KernelAuxiliaryOps, Result, linux_bpf::*};
5
6#[derive(Debug)]
8pub struct BpfRawTracePointArg {
9 pub name: String,
11 pub prog_fd: u32,
13}
14
15impl BpfRawTracePointArg {
16 pub fn try_from_bpf_attr<F: KernelAuxiliaryOps>(attr: &bpf_attr) -> Result<Self> {
18 let (name_ptr, prog_fd) = unsafe {
19 let name_ptr = attr.raw_tracepoint.name as *const u8;
20
21 let prog_fd = attr.raw_tracepoint.prog_fd;
22 (name_ptr, prog_fd)
23 };
24 let name = F::string_from_user_cstr(name_ptr)?;
25 Ok(BpfRawTracePointArg { name, prog_fd })
26 }
27}