1 // SPDX-License-Identifier: GPL-2.0
4 #include <bpf/bpf_helpers.h>
5 #include <bpf/bpf_tracing.h>
7 #define MAX_PATH_LEN 128
13 char paths_stat
[MAX_FILES
][MAX_PATH_LEN
] = {};
14 char paths_close
[MAX_FILES
][MAX_PATH_LEN
] = {};
15 int rets_stat
[MAX_FILES
] = {};
16 int rets_close
[MAX_FILES
] = {};
21 SEC("fentry/security_inode_getattr")
22 int BPF_PROG(prog_stat
, struct path
*path
, struct kstat
*stat
,
23 __u32 request_mask
, unsigned int query_flags
)
25 pid_t pid
= bpf_get_current_pid_tgid() >> 32;
36 ret
= bpf_d_path(path
, paths_stat
[cnt
], MAX_PATH_LEN
);
43 SEC("fentry/filp_close")
44 int BPF_PROG(prog_close
, struct file
*file
, void *id
)
46 pid_t pid
= bpf_get_current_pid_tgid() >> 32;
47 __u32 cnt
= cnt_close
;
57 ret
= bpf_d_path(&file
->f_path
,
58 paths_close
[cnt
], MAX_PATH_LEN
);
60 rets_close
[cnt
] = ret
;
65 char _license
[] SEC("license") = "GPL";