]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - samples/bpf/tracex7_user.c
5 #include <bpf/libbpf.h>
7 int main(int argc
, char **argv
)
9 struct bpf_link
*link
= NULL
;
10 struct bpf_program
*prog
;
11 struct bpf_object
*obj
;
17 snprintf(filename
, sizeof(filename
), "%s_kern.o", argv
[0]);
18 obj
= bpf_object__open_file(filename
, NULL
);
19 if (libbpf_get_error(obj
)) {
20 fprintf(stderr
, "ERROR: opening BPF object file failed\n");
24 prog
= bpf_object__find_program_by_name(obj
, "bpf_prog1");
26 fprintf(stderr
, "ERROR: finding a prog in obj file failed\n");
30 /* load BPF program */
31 if (bpf_object__load(obj
)) {
32 fprintf(stderr
, "ERROR: loading BPF object file failed\n");
36 link
= bpf_program__attach(prog
);
37 if (libbpf_get_error(link
)) {
38 fprintf(stderr
, "ERROR: bpf_program__attach failed\n");
43 snprintf(command
, 256, "mount %s tmpmnt/", argv
[1]);
44 f
= popen(command
, "r");
48 bpf_link__destroy(link
);
49 bpf_object__close(obj
);