【发布时间】:2020-12-15 21:03:41
【问题描述】:
当我尝试编译包含 bio.h 的 eBPF 程序时,出现错误。 为什么我可以包含其他 Linux 头文件,而不包含这个特定的头文件?
我使用以下命令编译
clang -O2 -target bpf -c src/bpf_program.c -Ikernel-src/tools/testing/selftests/bpf -Ikernel-src/tools/lib/bpf -o src/bpf_program.o
程序:
#include <asm/ptrace.h>
#include <linux/bpf.h>
#include "bpf_helpers.h"
#include <linux/bio.h>
SEC("kprobe/nvme_queue_rq")
int bpf_prog(struct pt_regs *ctx) {
..
}
char _license[] SEC("license") = "GPL";
我得到了这个错误
src/bpf_program.c:4:10: fatal error: 'linux/bio.h' file not found
#include <linux/bio.h>
^~~~~~~~~~~~~
1 error generated.
make: *** [Makefile:36: build] Error 1
【问题讨论】:
标签: c linux linux-kernel clang