From 50ad5720bc8a65f358284b56cab4e8d496785c2d Mon Sep 17 00:00:00 2001 From: jxy_git Date: Sat, 1 Jul 2023 14:25:51 +0800 Subject: [PATCH] Used to set signal processing, check function availability --- src/fsslower/fsslower.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/fsslower/fsslower.c b/src/fsslower/fsslower.c index 2979a3d1..166ff3ef 100644 --- a/src/fsslower/fsslower.c +++ b/src/fsslower/fsslower.c @@ -156,3 +156,26 @@ static int libbpf_print_fn(enum libbpf_print_level level, const char *format, return 0; return vfprintf(stderr, format, args); } + +static void sig_handler(int sig) +{ + exiting = 1; +} + +static bool check_fentry() +{ + for (int i = 0; i < F_MAX_OP; i++) { + const char *fn_name = fs_configs[fs_type].op_funcs[i]; + const char *module = fs_configs[fs_type].fs; + + if (fn_name && !fentry_can_attach(fn_name, module)) + return false; + } + + return true; +} + +static int fentry_set_attach_target(struct bpf_program *prog, enum fs_file_op op) +{ + return bpf_program__set_attach_target(prog, 0, fs_configs[fs_type].op_funcs[op]); +} -- Gitee