static bool fentry_try_attach()

in helpers/trace_helpers.c [1013:1032]


static bool fentry_try_attach(int id)
{
	struct bpf_insn insns[] = { { .code = BPF_JMP | BPF_EXIT } };
	LIBBPF_OPTS(bpf_prog_load_opts, opts);
	int prog_fd, attach_fd;

	opts.expected_attach_type = BPF_TRACE_FENTRY;
	opts.attach_btf_id = id,

	prog_fd = bpf_prog_load(BPF_PROG_TYPE_TRACING, "test", NULL, insns, 1, &opts);
	if (prog_fd < 0)
		return false;

	attach_fd = bpf_raw_tracepoint_open(NULL, prog_fd);
	if (attach_fd >= 0)
		close(attach_fd);

	close(prog_fd);
	return attach_fd >= 0;
}