[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1431860222-61636-27-git-send-email-wangnan0@huawei.com>
Date: Sun, 17 May 2015 10:56:51 +0000
From: Wang Nan <wangnan0@...wei.com>
To: <paulus@...ba.org>, <a.p.zijlstra@...llo.nl>, <mingo@...hat.com>,
<acme@...nel.org>, <namhyung@...nel.org>, <jolsa@...nel.org>,
<dsahern@...il.com>, <ast@...mgrid.com>, <daniel@...earbox.net>,
<brendan.d.gregg@...il.com>, <masami.hiramatsu.pt@...achi.com>
CC: <lizefan@...wei.com>, <linux-kernel@...r.kernel.org>,
<pi3orama@....com>
Subject: [RFC PATCH v3 26/37] bpf tools: Introduce accessors for struct bpf_object
This patch add an accessor which allows caller to get count of programs
in an object file.
Signed-off-by: Wang Nan <wangnan0@...wei.com>
---
tools/lib/bpf/libbpf.c | 9 +++++++++
tools/lib/bpf/libbpf.h | 3 +++
2 files changed, 12 insertions(+)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index d770adc..89c725a 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -964,6 +964,15 @@ void bpf_close_object(struct bpf_object *obj)
free(obj);
}
+int bpf_obj_get_prog_cnt(struct bpf_object *obj, size_t *pcnt)
+{
+ if (!obj || !pcnt)
+ return -EINVAL;
+
+ *pcnt = obj->nr_programs;
+ return 0;
+}
+
static inline struct bpf_program *
handler_to_prog(struct bpf_prog_handler *handler)
{
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index b451d1a..31ff5d9 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -26,6 +26,9 @@ void bpf_close_object(struct bpf_object *object);
int bpf_load_object(struct bpf_object *obj);
int bpf_unload_object(struct bpf_object *obj);
+/* Accessors of bpf_object */
+int bpf_obj_get_prog_cnt(struct bpf_object *obj, size_t *pcnt);
+
/* Accessors of bpf_program. */
struct bpf_prog_handler;
struct bpf_prog_handler *bpf_next_prog(struct bpf_object *obj,
--
1.8.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists