-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtrack.c
54 lines (42 loc) · 1.13 KB
/
track.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <logger.h>
#include <track.skel.h>
#include <handler.h>
static bool running = false;
static void signalHandler() {
running = false;
}
static void bump_memlock_rlimit(void) {
struct rlimit rlim_new = {
.rlim_cur = RLIM_INFINITY,
.rlim_max = RLIM_INFINITY,
};
if (setrlimit(RLIMIT_MEMLOCK, &rlim_new)) {
fprintf(stderr, "Failed to increase RLIMIT_MEMLOCK limit!\n");
exit(1);
}
}
int main(void) {
signal(SIGINT, signalHandler);
bump_memlock_rlimit();
if (loggerInit("output.bin") != 0) {
printf("Could not initialize logger\n");
return 1;
}
struct track_bpf *skel = track_bpf__open();
track_bpf__load(skel);
track_bpf__attach(skel);
struct ring_buffer *rb = ring_buffer__new(bpf_map__fd(skel->maps.ring_buff), handle, NULL, NULL);
running = true;
while (running) {
ring_buffer__poll(rb, 1000);
}
ring_buffer__free(rb);
track_bpf__destroy(skel);
loggerDestroy();
printf("Catching syscalls ended\n");
return 0;
}