|
|
|
|
@ -35,7 +35,6 @@ use crate::{
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read};
|
|
|
|
|
/// # fn try_test() -> Result<(), c_long> {
|
|
|
|
|
/// # let kernel_ptr: *const c_int = 0 as _;
|
|
|
|
|
@ -74,7 +73,6 @@ pub unsafe fn bpf_probe_read<T>(src: *const T) -> Result<T, c_long> {
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_buf};
|
|
|
|
|
/// # fn try_test() -> Result<(), c_long> {
|
|
|
|
|
/// # let ptr: *const u8 = 0 as _;
|
|
|
|
|
@ -103,7 +101,6 @@ pub unsafe fn bpf_probe_read_buf(src: *const u8, dst: &mut [u8]) -> Result<(), c
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_user};
|
|
|
|
|
/// # fn try_test() -> Result<(), c_long> {
|
|
|
|
|
/// # let user_ptr: *const c_int = 0 as _;
|
|
|
|
|
@ -140,7 +137,6 @@ pub unsafe fn bpf_probe_read_user<T>(src: *const T) -> Result<T, c_long> {
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_user_buf};
|
|
|
|
|
/// # fn try_test() -> Result<(), c_long> {
|
|
|
|
|
/// # let user_ptr: *const u8 = 0 as _;
|
|
|
|
|
@ -170,7 +166,6 @@ pub unsafe fn bpf_probe_read_user_buf(src: *const u8, dst: &mut [u8]) -> Result<
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_kernel};
|
|
|
|
|
/// # fn try_test() -> Result<(), c_long> {
|
|
|
|
|
/// # let kernel_ptr: *const c_int = 0 as _;
|
|
|
|
|
@ -207,7 +202,6 @@ pub unsafe fn bpf_probe_read_kernel<T>(src: *const T) -> Result<T, c_long> {
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_kernel_buf};
|
|
|
|
|
/// # fn try_test() -> Result<(), c_long> {
|
|
|
|
|
/// # let kernel_ptr: *const u8 = 0 as _;
|
|
|
|
|
@ -240,11 +234,12 @@ pub unsafe fn bpf_probe_read_kernel_buf(src: *const u8, dst: &mut [u8]) -> Resul
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # #[expect(deprecated)]
|
|
|
|
|
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_str};
|
|
|
|
|
/// # fn try_test() -> Result<(), c_long> {
|
|
|
|
|
/// # let kernel_ptr: *const u8 = 0 as _;
|
|
|
|
|
/// let mut my_str = [0u8; 16];
|
|
|
|
|
/// # #[expect(deprecated)]
|
|
|
|
|
/// let num_read = unsafe { bpf_probe_read_str(kernel_ptr, &mut my_str)? };
|
|
|
|
|
///
|
|
|
|
|
/// // Do something with num_read and my_str
|
|
|
|
|
@ -276,11 +271,12 @@ pub unsafe fn bpf_probe_read_str(src: *const u8, dest: &mut [u8]) -> Result<usiz
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # #[expect(deprecated)]
|
|
|
|
|
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_user_str};
|
|
|
|
|
/// # fn try_test() -> Result<(), c_long> {
|
|
|
|
|
/// # let user_ptr: *const u8 = 0 as _;
|
|
|
|
|
/// let mut my_str = [0u8; 16];
|
|
|
|
|
/// # #[expect(deprecated)]
|
|
|
|
|
/// let num_read = unsafe { bpf_probe_read_user_str(user_ptr, &mut my_str)? };
|
|
|
|
|
///
|
|
|
|
|
/// // Do something with num_read and my_str
|
|
|
|
|
@ -315,7 +311,6 @@ pub unsafe fn bpf_probe_read_user_str(src: *const u8, dest: &mut [u8]) -> Result
|
|
|
|
|
/// eBPF stack limit is 512 bytes):
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_user_str_bytes};
|
|
|
|
|
/// # fn try_test() -> Result<(), c_long> {
|
|
|
|
|
/// # let user_ptr: *const u8 = 0 as _;
|
|
|
|
|
@ -421,11 +416,12 @@ fn read_str_bytes(len: i64, dest: &[u8]) -> Result<&[u8], c_long> {
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # #[expect(deprecated)]
|
|
|
|
|
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_kernel_str};
|
|
|
|
|
/// # fn try_test() -> Result<(), c_long> {
|
|
|
|
|
/// # let kernel_ptr: *const u8 = 0 as _;
|
|
|
|
|
/// let mut my_str = [0u8; 16];
|
|
|
|
|
/// # #[expect(deprecated)]
|
|
|
|
|
/// let num_read = unsafe { bpf_probe_read_kernel_str(kernel_ptr, &mut my_str)? };
|
|
|
|
|
///
|
|
|
|
|
/// // Do something with num_read and my_str
|
|
|
|
|
@ -464,7 +460,6 @@ pub unsafe fn bpf_probe_read_kernel_str(src: *const u8, dest: &mut [u8]) -> Resu
|
|
|
|
|
/// eBPF stack limit is 512 bytes):
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_kernel_str_bytes};
|
|
|
|
|
/// # fn try_test() -> Result<(), c_long> {
|
|
|
|
|
/// # let kernel_ptr: *const u8 = 0 as _;
|
|
|
|
|
@ -554,7 +549,6 @@ pub unsafe fn bpf_probe_read_kernel_str_bytes(
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # use aya_ebpf::{
|
|
|
|
|
/// # cty::{c_int, c_long},
|
|
|
|
|
/// # helpers::bpf_probe_write_user,
|
|
|
|
|
@ -587,7 +581,6 @@ pub unsafe fn bpf_probe_write_user<T>(dst: *mut T, src: *const T) -> Result<(),
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # use aya_ebpf::helpers::bpf_get_current_comm;
|
|
|
|
|
/// let comm = bpf_get_current_comm();
|
|
|
|
|
///
|
|
|
|
|
@ -622,7 +615,6 @@ pub fn bpf_get_current_comm() -> Result<[u8; 16], c_long> {
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # use aya_ebpf::helpers::bpf_get_current_pid_tgid;
|
|
|
|
|
/// let tgid = (bpf_get_current_pid_tgid() >> 32) as u32;
|
|
|
|
|
/// let pid = bpf_get_current_pid_tgid() as u32;
|
|
|
|
|
@ -645,7 +637,6 @@ pub fn bpf_get_current_pid_tgid() -> u64 {
|
|
|
|
|
/// # Examples
|
|
|
|
|
///
|
|
|
|
|
/// ```no_run
|
|
|
|
|
/// # #![expect(dead_code)]
|
|
|
|
|
/// # use aya_ebpf::helpers::bpf_get_current_uid_gid;
|
|
|
|
|
/// let gid = (bpf_get_current_uid_gid() >> 32) as u32;
|
|
|
|
|
/// let uid = bpf_get_current_uid_gid() as u32;
|
|
|
|
|
|