aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/include
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2020-08-25 21:21:20 +0200
committerAlexei Starovoitov <ast@kernel.org>2020-08-25 15:41:15 -0700
commit6e22ab9da79343532cd3cde39df25e5a5478c692 (patch)
tree0421c44d1e43134bdf0abcdf575b0520e99796ec /tools/include
parentbpf: Add BTF_SET_START/END macros (diff)
downloadwireguard-linux-6e22ab9da79343532cd3cde39df25e5a5478c692.tar.xz
wireguard-linux-6e22ab9da79343532cd3cde39df25e5a5478c692.zip
bpf: Add d_path helper
Adding d_path helper function that returns full path for given 'struct path' object, which needs to be the kernel BTF 'path' object. The path is returned in buffer provided 'buf' of size 'sz' and is zero terminated. bpf_d_path(&file->f_path, buf, size); The helper calls directly d_path function, so there's only limited set of function it can be called from. Adding just very modest set for the start. Updating also bpf.h tools uapi header and adding 'path' to bpf_helpers_doc.py script. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andriin@fb.com> Acked-by: KP Singh <kpsingh@google.com> Link: https://lore.kernel.org/bpf/20200825192124.710397-11-jolsa@kernel.org
Diffstat (limited to 'tools/include')
-rw-r--r--tools/include/uapi/linux/bpf.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index 0e1cdf806fe1..0388bc0200b0 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -3513,6 +3513,7 @@ union bpf_attr {
*
* **-EPERM** This helper cannot be used under the
* current sock_ops->op.
+ *
* void *bpf_inode_storage_get(struct bpf_map *map, void *inode, void *value, u64 flags)
* Description
* Get a bpf_local_storage from an *inode*.
@@ -3548,6 +3549,18 @@ union bpf_attr {
* 0 on success.
*
* **-ENOENT** if the bpf_local_storage cannot be found.
+ *
+ * long bpf_d_path(struct path *path, char *buf, u32 sz)
+ * Description
+ * Return full path for given 'struct path' object, which
+ * needs to be the kernel BTF 'path' object. The path is
+ * returned in the provided buffer 'buf' of size 'sz' and
+ * is zero terminated.
+ *
+ * Return
+ * On success, the strictly positive length of the string,
+ * including the trailing NUL character. On error, a negative
+ * value.
*/
#define __BPF_FUNC_MAPPER(FN) \
FN(unspec), \
@@ -3697,6 +3710,7 @@ union bpf_attr {
FN(reserve_hdr_opt), \
FN(inode_storage_get), \
FN(inode_storage_delete), \
+ FN(d_path), \
/* */
/* integer value in 'imm' field of BPF_CALL instruction selects which helper