History

bpf: Add bpf_seq_printf_btf helper

A helper is added to allow seq file writing of kernel data structures using vmlinux BTF. Its signature is long bpf_seq_printf_btf(struct seq_file *m, struct btf_ptr *ptr, u32 btf_ptr_size, u64 flags); Flags and struct btf_ptr definitions/use are identical to the bpf_snprintf_btf helper, and the helper returns 0 on success or a negative error value.

Alan Maguire committed 6 years ago

Commit eb411371 parent eb58bbf6 files · +56 −2Browse files

Showing the changes to include/uapi (1 of 6 files). Show all

Unified · Split

include/uapi/linux/bpf.h+9−0
@@ -3630,6 +3630,14 @@ union bpf_attr { · 3629 unmodified lines
36303630 * The number of bytes that were written (or would have been
36313631 * written if output had to be truncated due to string size),
36323632 * or a negative error in cases of failure.
3633+ *
3634+ * long bpf_seq_printf_btf(struct seq_file *m, struct btf_ptr *ptr, u32 ptr_size, u64 flags)
3635+ * Description
3636+ * Use BTF to write to seq_write a string representation of
3637+ * *ptr*->ptr, using *ptr*->type_id as per bpf_snprintf_btf().
3638+ * *flags* are identical to those used for bpf_snprintf_btf.
3639+ * Return
3640+ * 0 on success or a negative error in case of failure.
36333641 */
36343642 #define __BPF_FUNC_MAPPER(FN) \
36353643 FN(unspec), \
@@ -3782,6 +3790,7 @@ union bpf_attr { · 146 unmodified lines
37823790 FN(d_path), \
37833791 FN(copy_from_user), \
37843792 FN(snprintf_btf), \
3793+ FN(seq_printf_btf), \
37853794 /* */
37863795
37873796 /* integer value in 'imm' field of BPF_CALL instruction selects which helper