Skip to content

Commit f0e4c33

Browse files
committed
samples/trace_event: use the new TaskStruct::get_comm signature
Signed-off-by: MinhPhan8803 <[email protected]>
1 parent c528d1e commit f0e4c33

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

samples/trace_event/src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub const TASK_COMM_LEN: usize = 16;
1515
#[repr(C)]
1616
#[derive(Copy, Clone)]
1717
pub struct KeyT {
18-
pub comm: [i8; TASK_COMM_LEN],
18+
pub comm: [u8; TASK_COMM_LEN],
1919
pub kernstack: u32,
2020
pub userstack: u32,
2121
}
@@ -50,7 +50,10 @@ fn rex_prog1(obj: &perf_event, ctx: &bpf_perf_event_data) -> Result {
5050

5151
obj.bpf_get_current_task()
5252
.map(|t| {
53-
t.get_comm(&mut key.comm);
53+
let prog_name = t.get_comm().unwrap_or_default();
54+
key.comm
55+
.copy_from_slice(&prog_name.to_bytes()[..TASK_COMM_LEN]);
56+
key.comm[TASK_COMM_LEN - 1] = 0;
5457
0u64
5558
})
5659
.ok_or(0i32)?;

0 commit comments

Comments
 (0)