lkml.org 
[lkml]   [2015]   [Jul]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [RFC PATCH v10 21/50] bpf tools: Introduce accessors for struct bpf_object
Em Wed, Jul 01, 2015 at 02:14:09AM +0000, Wang Nan escreveu:
> This patch add an accessor which allows caller to get count of programs
> in an object file.
>
> Signed-off-by: Wang Nan <wangnan0@huawei.com>
> Acked-by: Alexei Starovoitov <ast@plumgrid.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 e4c5f07..1c210fb 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -936,6 +936,15 @@ void bpf_object__close(struct bpf_object *obj)
> free(obj);
> }
>
> +int bpf_object__get_prog_cnt(struct bpf_object *obj, size_t *pcnt)
> +{
> + if (!obj || !pcnt)
> + return -EINVAL;
> +
> + *pcnt = obj->nr_programs;
> + return 0;
> +}
> +

Ditto, what is wrong with:

int bpf_object__nr_programs(struct bpf_object *obj)
{
return obj ? obj->nr_programs : -EINVAL;
}

- Arnaldo

> struct bpf_program *
> bpf_program__next(struct bpf_program *prev, struct bpf_object *obj)
> {
> diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> index 9e0e102..a20ae2e 100644
> --- a/tools/lib/bpf/libbpf.h
> +++ b/tools/lib/bpf/libbpf.h
> @@ -35,6 +35,9 @@ void bpf_object__close(struct bpf_object *object);
> int bpf_object__load(struct bpf_object *obj);
> int bpf_object__unload(struct bpf_object *obj);
>
> +/* Accessors of bpf_object */
> +int bpf_object__get_prog_cnt(struct bpf_object *obj, size_t *pcnt);
> +
> /* Accessors of bpf_program. */
> struct bpf_program;
> struct bpf_program *bpf_program__next(struct bpf_program *prog,
> --
> 1.8.3.4


\
 
 \ /
  Last update: 2015-07-07 22:01    [W:0.333 / U:0.184 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site