.. | .. |
---|
6 | 6 | #include <sys/socket.h> |
---|
7 | 7 | #include <fcntl.h> |
---|
8 | 8 | #include <unistd.h> |
---|
9 | | -#include "include/uapi/linux/bpf.h" |
---|
| 9 | +#include "../../include/uapi/linux/bpf.h" |
---|
10 | 10 | #include <asm/unistd.h> |
---|
11 | 11 | #include "msgfmt.h" |
---|
12 | 12 | |
---|
13 | | -int debug_fd; |
---|
| 13 | +FILE *debug_f; |
---|
14 | 14 | |
---|
15 | 15 | static int handle_get_cmd(struct mbox_request *cmd) |
---|
16 | 16 | { |
---|
.. | .. |
---|
37 | 37 | |
---|
38 | 38 | n = read(0, &req, sizeof(req)); |
---|
39 | 39 | if (n != sizeof(req)) { |
---|
40 | | - dprintf(debug_fd, "invalid request %d\n", n); |
---|
| 40 | + fprintf(debug_f, "invalid request %d\n", n); |
---|
41 | 41 | return; |
---|
42 | 42 | } |
---|
43 | 43 | |
---|
.. | .. |
---|
47 | 47 | |
---|
48 | 48 | n = write(1, &reply, sizeof(reply)); |
---|
49 | 49 | if (n != sizeof(reply)) { |
---|
50 | | - dprintf(debug_fd, "reply failed %d\n", n); |
---|
| 50 | + fprintf(debug_f, "reply failed %d\n", n); |
---|
51 | 51 | return; |
---|
52 | 52 | } |
---|
53 | 53 | } |
---|
.. | .. |
---|
55 | 55 | |
---|
56 | 56 | int main(void) |
---|
57 | 57 | { |
---|
58 | | - debug_fd = open("/dev/console", 00000002); |
---|
59 | | - dprintf(debug_fd, "Started bpfilter\n"); |
---|
| 58 | + debug_f = fopen("/dev/kmsg", "w"); |
---|
| 59 | + setvbuf(debug_f, 0, _IOLBF, 0); |
---|
| 60 | + fprintf(debug_f, "<5>Started bpfilter\n"); |
---|
60 | 61 | loop(); |
---|
61 | | - close(debug_fd); |
---|
| 62 | + fclose(debug_f); |
---|
62 | 63 | return 0; |
---|
63 | 64 | } |
---|