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
3630 * The number of bytes that were written (or would have been3630 * The number of bytes that were written (or would have been
3631 * written if output had to be truncated due to string size),3631 * written if output had to be truncated due to string size),
3632 * or a negative error in cases of failure.3632 * 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.
3633 */3641 */
3634#define __BPF_FUNC_MAPPER(FN) \3642#define __BPF_FUNC_MAPPER(FN) \
3635 FN(unspec), \3643 FN(unspec), \
@@ -3782,6 +3790,7 @@ union bpf_attr { · 146 unmodified lines
3782 FN(d_path), \3790 FN(d_path), \
3783 FN(copy_from_user), \3791 FN(copy_from_user), \
3784 FN(snprintf_btf), \3792 FN(snprintf_btf), \
3793 FN(seq_printf_btf), \
3785 /* */3794 /* */
3786 3795
3787/* integer value in 'imm' field of BPF_CALL instruction selects which helper3796/* integer value in 'imm' field of BPF_CALL instruction selects which helper