mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2025-12-31 21:06:25 +00:00
add ringbuf reserve function
This commit is contained in:
@ -28,22 +28,22 @@ int trace_execve(void *ctx)
|
||||
|
||||
// Reserve space in the ringbuffer
|
||||
e = bpf_ringbuf_reserve(&events, sizeof(*e), 0);
|
||||
if (!e)
|
||||
return 0;
|
||||
|
||||
// Fill the struct with data
|
||||
pid_tgid = bpf_get_current_pid_tgid();
|
||||
e->pid = pid_tgid >> 32;
|
||||
|
||||
uid_gid = bpf_get_current_uid_gid();
|
||||
e->uid = uid_gid & 0xFFFFFFFF;
|
||||
|
||||
e->timestamp = bpf_ktime_get_ns();
|
||||
|
||||
bpf_get_current_comm(&e->comm, sizeof(e->comm));
|
||||
|
||||
// Submit the event to ringbuffer
|
||||
bpf_ringbuf_submit(e, 0);
|
||||
// if (!e)
|
||||
// return 0;
|
||||
//
|
||||
// // Fill the struct with data
|
||||
// pid_tgid = bpf_get_current_pid_tgid();
|
||||
// e->pid = pid_tgid >> 32;
|
||||
//
|
||||
// uid_gid = bpf_get_current_uid_gid();
|
||||
// e->uid = uid_gid & 0xFFFFFFFF;
|
||||
//
|
||||
// e->timestamp = bpf_ktime_get_ns();
|
||||
//
|
||||
// bpf_get_current_comm(&e->comm, sizeof(e->comm));
|
||||
//
|
||||
// // Submit the event to ringbuffer
|
||||
// bpf_ringbuf_submit(e, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user