hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/samples/bpf/test_current_task_under_cgroup_kern.c
....@@ -8,25 +8,26 @@
88 #include <linux/ptrace.h>
99 #include <uapi/linux/bpf.h>
1010 #include <linux/version.h>
11
-#include "bpf_helpers.h"
11
+#include <bpf/bpf_helpers.h>
1212 #include <uapi/linux/utsname.h>
13
+#include "trace_common.h"
1314
14
-struct bpf_map_def SEC("maps") cgroup_map = {
15
- .type = BPF_MAP_TYPE_CGROUP_ARRAY,
16
- .key_size = sizeof(u32),
17
- .value_size = sizeof(u32),
18
- .max_entries = 1,
19
-};
15
+struct {
16
+ __uint(type, BPF_MAP_TYPE_CGROUP_ARRAY);
17
+ __uint(key_size, sizeof(u32));
18
+ __uint(value_size, sizeof(u32));
19
+ __uint(max_entries, 1);
20
+} cgroup_map SEC(".maps");
2021
21
-struct bpf_map_def SEC("maps") perf_map = {
22
- .type = BPF_MAP_TYPE_ARRAY,
23
- .key_size = sizeof(u32),
24
- .value_size = sizeof(u64),
25
- .max_entries = 1,
26
-};
22
+struct {
23
+ __uint(type, BPF_MAP_TYPE_ARRAY);
24
+ __type(key, u32);
25
+ __type(value, u64);
26
+ __uint(max_entries, 1);
27
+} perf_map SEC(".maps");
2728
2829 /* Writes the last PID that called sync to a map at index 0 */
29
-SEC("kprobe/sys_sync")
30
+SEC("kprobe/" SYSCALL(sys_sync))
3031 int bpf_prog1(struct pt_regs *ctx)
3132 {
3233 u64 pid = bpf_get_current_pid_tgid();