Skip to content

Libbpf userspace function btf__add_struct

0.2.0

Append new BTF_KIND_STRUCT type to BTF object.

Definition

int btf__add_struct(struct btf *btf, const char *name, __u32 sz);

Parameters

  • btf: pointer to a struct btf object
  • name: name of the struct, can be NULL or empty for anonymous structs;
  • sz: size of the struct, in bytes;

Return

>0, type ID of newly added BTF type; <0, on error.

Usage

Struct initially has no fields in it. Fields can be added by btf__add_field right after btf__add_struct succeeds.

Example

Docs could be improved

This part of the docs is incomplete, contributions are very welcome