From 102a0743326a03cd1a1202ceda21e175b7d3575c Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Tue, 20 Feb 2024 01:20:52 +0000 Subject: [PATCH] add new system file --- kernel/samples/bpf/bpf_load.c | 33 ++++++--------------------------- 1 files changed, 6 insertions(+), 27 deletions(-) diff --git a/kernel/samples/bpf/bpf_load.c b/kernel/samples/bpf/bpf_load.c index 176c04a..c5ad528 100644 --- a/kernel/samples/bpf/bpf_load.c +++ b/kernel/samples/bpf/bpf_load.c @@ -16,7 +16,6 @@ #include <linux/netlink.h> #include <linux/rtnetlink.h> #include <linux/types.h> -#include <sys/types.h> #include <sys/socket.h> #include <sys/syscall.h> #include <sys/ioctl.h> @@ -41,7 +40,7 @@ int prog_array_fd = -1; struct bpf_map_data map_data[MAX_MAPS]; -int map_data_count = 0; +int map_data_count; static int populate_prog_array(const char *event, int prog_fd) { @@ -66,7 +65,7 @@ else flags = O_WRONLY | O_APPEND; - fd = open("/sys/kernel/debug/tracing/kprobe_events", flags); + fd = open(DEBUGFS "kprobe_events", flags); ret = write(fd, val, strlen(val)); close(fd); @@ -302,8 +301,8 @@ numa_node); } if (map_fd[i] < 0) { - printf("failed to create a map: %d %s\n", - errno, strerror(errno)); + printf("failed to create map %d (%s): %d %s\n", + i, maps[i].name, errno, strerror(errno)); return 1; } maps[i].fd = map_fd[i]; @@ -491,8 +490,8 @@ /* Verify no newer features were requested */ if (validate_zero) { - addr = (unsigned char*) def + map_sz_copy; - end = (unsigned char*) def + map_sz_elf; + addr = (unsigned char *) def + map_sz_copy; + end = (unsigned char *) def + map_sz_elf; for (; addr < end; addr++) { if (*addr != 0) { free(sym); @@ -665,24 +664,4 @@ int load_bpf_file_fixup_map(const char *path, fixup_map_cb fixup_map) { return do_load_bpf_file(path, fixup_map); -} - -void read_trace_pipe(void) -{ - int trace_fd; - - trace_fd = open(DEBUGFS "trace_pipe", O_RDONLY, 0); - if (trace_fd < 0) - return; - - while (1) { - static char buf[4096]; - ssize_t sz; - - sz = read(trace_fd, buf, sizeof(buf) - 1); - if (sz > 0) { - buf[sz] = 0; - puts(buf); - } - } } -- Gitblit v1.6.2