include/linux/btf.h
Source file repositories/reference/linux-study-clean/include/linux/btf.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/btf.h- Extension
.h- Size
- 21190 bytes
- Lines
- 689
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/bpfptr.hlinux/bsearch.hlinux/btf_ids.huapi/linux/btf.huapi/linux/bpf.h
Detected Declarations
struct btfstruct btf_memberstruct btf_typestruct btf_showstruct btf_id_setstruct bpf_progstruct btf_kfunc_id_setstruct btf_id_dtor_kfuncstruct btf_struct_metastruct btf_struct_metasstruct bpf_log_attrstruct bpf_verifier_logstruct bpf_struct_opsstruct btf_field_descstruct btf_field_iterenum btf_field_iter_kindfunction btf_type_is_ptrfunction btf_type_is_intfunction btf_type_is_small_intfunction btf_int_encodingfunction btf_type_is_signed_intfunction btf_type_is_enumfunction btf_is_any_enumfunction btf_kind_core_compatfunction str_is_emptyfunction btf_kindfunction btf_is_enumfunction btf_is_enum64function btf_enum64_valuefunction btf_is_compositefunction btf_is_arrayfunction btf_is_intfunction btf_is_ptrfunction btf_int_offsetfunction btf_int_bitsfunction btf_type_is_scalarfunction btf_type_is_fwdfunction btf_type_is_typedeffunction btf_type_is_volatilefunction btf_type_is_funcfunction btf_type_is_func_protofunction btf_type_is_varfunction btf_type_is_type_tagfunction offsetoffunction __btf_type_is_structfunction btf_type_is_arrayfunction btf_type_vlenfunction btf_vlen
Annotated Snippet
extern const struct file_operations btf_fops;
const char *btf_get_name(const struct btf *btf);
void btf_get(struct btf *btf);
void btf_put(struct btf *btf);
const struct btf_header *btf_header(const struct btf *btf);
struct bpf_log_attr;
int btf_new_fd(const union bpf_attr *attr, bpfptr_t uattr, struct bpf_log_attr *attr_log);
struct btf *btf_get_by_fd(int fd);
int btf_get_info_by_fd(const struct btf *btf,
const union bpf_attr *attr,
union bpf_attr __user *uattr);
/* Figure out the size of a type_id. If type_id is a modifier
* (e.g. const), it will be resolved to find out the type with size.
*
* For example:
* In describing "const void *", type_id is "const" and "const"
* refers to "void *". The return type will be "void *".
*
* If type_id is a simple "int", then return type will be "int".
*
* @btf: struct btf object
* @type_id: Find out the size of type_id. The type_id of the return
* type is set to *type_id.
* @ret_size: It can be NULL. If not NULL, the size of the return
* type is set to *ret_size.
* Return: The btf_type (resolved to another type with size info if needed).
* NULL is returned if type_id itself does not have size info
* (e.g. void) or it cannot be resolved to another type that
* has size info.
* *type_id and *ret_size will not be changed in the
* NULL return case.
*/
const struct btf_type *btf_type_id_size(const struct btf *btf,
u32 *type_id,
u32 *ret_size);
/*
* Options to control show behaviour.
* - BTF_SHOW_COMPACT: no formatting around type information
* - BTF_SHOW_NONAME: no struct/union member names/types
* - BTF_SHOW_PTR_RAW: show raw (unobfuscated) pointer values;
* equivalent to %px.
* - BTF_SHOW_ZERO: show zero-valued struct/union members; they
* are not displayed by default
* - BTF_SHOW_UNSAFE: skip use of bpf_probe_read() to safely read
* data before displaying it.
*/
#define BTF_SHOW_COMPACT BTF_F_COMPACT
#define BTF_SHOW_NONAME BTF_F_NONAME
#define BTF_SHOW_PTR_RAW BTF_F_PTR_RAW
#define BTF_SHOW_ZERO BTF_F_ZERO
#define BTF_SHOW_UNSAFE (1ULL << 4)
void btf_type_seq_show(const struct btf *btf, u32 type_id, void *obj,
struct seq_file *m);
int btf_type_seq_show_flags(const struct btf *btf, u32 type_id, void *obj,
struct seq_file *m, u64 flags);
/*
* Copy len bytes of string representation of obj of BTF type_id into buf.
*
* @btf: struct btf object
* @type_id: type id of type obj points to
* @obj: pointer to typed data
* @buf: buffer to write to
* @len: maximum length to write to buf
* @flags: show options (see above)
*
* Return: length that would have been/was copied as per snprintf, or
* negative error.
*/
int btf_type_snprintf_show(const struct btf *btf, u32 type_id, void *obj,
char *buf, int len, u64 flags);
int btf_get_fd_by_id(u32 id);
u32 btf_obj_id(const struct btf *btf);
bool btf_is_kernel(const struct btf *btf);
bool btf_is_module(const struct btf *btf);
bool btf_is_vmlinux(const struct btf *btf);
struct module *btf_try_get_module(const struct btf *btf);
u32 btf_nr_types(const struct btf *btf);
u32 btf_named_start_id(const struct btf *btf, bool own);
struct btf *btf_base_btf(const struct btf *btf);
bool btf_type_is_i32(const struct btf_type *t);
bool btf_type_is_i64(const struct btf_type *t);
bool btf_type_is_primitive(const struct btf_type *t);
bool btf_member_is_reg_int(const struct btf *btf, const struct btf_type *s,
const struct btf_member *m,
u32 expected_offset, u32 expected_size);
Annotation
- Immediate include surface: `linux/types.h`, `linux/bpfptr.h`, `linux/bsearch.h`, `linux/btf_ids.h`, `uapi/linux/btf.h`, `uapi/linux/bpf.h`.
- Detected declarations: `struct btf`, `struct btf_member`, `struct btf_type`, `struct btf_show`, `struct btf_id_set`, `struct bpf_prog`, `struct btf_kfunc_id_set`, `struct btf_id_dtor_kfunc`, `struct btf_struct_meta`, `struct btf_struct_metas`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: pattern implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.