Re: [RFC PATCH v3 09/37] bpf tools: Open eBPF object file and do basic validation

Jiri Olsa
2015-05-22T17:24:34Z

On Sun, May 17, 2015 at 10:56:34AM +0000, Wang Nan wrote:

SNIP

> + obj->path);
> + err = -EINVAL;
> + goto errout;
> + }
> + ep = &obj->elf.ehdr;
> +
> + if ((ep->e_type != ET_REL) || (ep->e_machine != 0)) {
> + pr_warning("%s is not an eBPF object file\n",
> + obj->path);
> + err = -EINVAL;
> + goto errout;
> + }
> +
> return 0;
> +errout:
> + bpf_obj_clear_elf(obj);
> + return err;
> +}
> +
> +struct bpf_object *bpf_open_object(const char *path)
> +{

another suggestion for the namespace.. Arnaldo forces us ;-)
to use the object name first plus '__(method name)' for
interface functions so that would be:

bpf_object__open
bpf_object__close

not sure we want to keep that standard in here though.. Arnaldo?

jirka

SNIP

> +void bpf_close_object(struct bpf_object *obj)
> +{
> + if (!obj)
> + return;
> +
> + bpf_obj_clear_elf(obj);
> +
> + if (obj->path)
> + free(obj->path);
> + free(obj);
> }
> --
> 1.8.3.4
>