1 #include <linux/ptrace.h>
2 #include <linux/version.h>
3 #include <uapi/linux/bpf.h>
4 #include <bpf/bpf_helpers.h>
6 struct bpf_map_def
SEC("maps") my_map
= {
7 .type
= BPF_MAP_TYPE_PERF_EVENT_ARRAY
,
8 .key_size
= sizeof(int),
9 .value_size
= sizeof(u32
),
13 SEC("kprobe/sys_write")
14 int bpf_prog1(struct pt_regs
*ctx
)
21 data
.pid
= bpf_get_current_pid_tgid();
22 data
.cookie
= 0x12345678;
24 bpf_perf_event_output(ctx
, &my_map
, 0, &data
, sizeof(data
));
29 char _license
[] SEC("license") = "GPL";
30 u32 _version
SEC("version") = LINUX_VERSION_CODE
;