diff options
author | Wang Nan <wangnan0@huawei.com> | 2015-11-06 08:49:38 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-11-06 13:56:41 -0500 |
commit | 45825d8ab8ef6287f5d05aea141419d8d4278852 (patch) | |
tree | 86d651dd9ee3f1f4b911193c6ccd536a649b82dd | |
parent | 6371ca3b541c82d8aa6a9002bd52d92bcdda5944 (diff) |
bpf tools: Add new API bpf_object__get_kversion()
bpf_object__get_kversion() can be used to fetch value of object's
'version' section. Following patch will use it for error reporting.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Zefan Li <lizefan@huawei.com>
Cc: pi3orama@163.com
Link: http://lkml.kernel.org/r/1446817783-86722-3-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/lib/bpf/libbpf.c | 8 | ||||
-rw-r--r-- | tools/lib/bpf/libbpf.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 07b492d3dfaa..e176bad19bcb 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c | |||
@@ -1055,6 +1055,14 @@ bpf_object__get_name(struct bpf_object *obj) | |||
1055 | return obj->path; | 1055 | return obj->path; |
1056 | } | 1056 | } |
1057 | 1057 | ||
1058 | unsigned int | ||
1059 | bpf_object__get_kversion(struct bpf_object *obj) | ||
1060 | { | ||
1061 | if (!obj) | ||
1062 | return 0; | ||
1063 | return obj->kern_version; | ||
1064 | } | ||
1065 | |||
1058 | struct bpf_program * | 1066 | struct bpf_program * |
1059 | bpf_program__next(struct bpf_program *prev, struct bpf_object *obj) | 1067 | bpf_program__next(struct bpf_program *prev, struct bpf_object *obj) |
1060 | { | 1068 | { |
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index 30a40e9fa503..c9a9aef2806c 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h | |||
@@ -56,6 +56,7 @@ void bpf_object__close(struct bpf_object *object); | |||
56 | int bpf_object__load(struct bpf_object *obj); | 56 | int bpf_object__load(struct bpf_object *obj); |
57 | int bpf_object__unload(struct bpf_object *obj); | 57 | int bpf_object__unload(struct bpf_object *obj); |
58 | const char *bpf_object__get_name(struct bpf_object *obj); | 58 | const char *bpf_object__get_name(struct bpf_object *obj); |
59 | unsigned int bpf_object__get_kversion(struct bpf_object *obj); | ||
59 | 60 | ||
60 | struct bpf_object *bpf_object__next(struct bpf_object *prev); | 61 | struct bpf_object *bpf_object__next(struct bpf_object *prev); |
61 | #define bpf_object__for_each_safe(pos, tmp) \ | 62 | #define bpf_object__for_each_safe(pos, tmp) \ |