History

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.

Jiri Olsa committed 6 years ago

Commit 6e22ab91 parent eae2e834 files · +78 −0Browse files

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

Unified · Split

include/uapi/linux/bpf.h+14−0
@@ -3513,6 +3513,7 @@ union bpf_attr { · 3512 unmodified lines
35133513 *
35143514 * **-EPERM** This helper cannot be used under the
35153515 * current sock_ops->op.
3516+ *
35163517 * void *bpf_inode_storage_get(struct bpf_map *map, void *inode, void *value, u64 flags)
35173518 * Description
35183519 * Get a bpf_local_storage from an *inode*.
@@ -3548,6 +3549,18 @@ union bpf_attr { · 29 unmodified lines
35483549 * 0 on success.
35493550 *
35503551 * **-ENOENT** if the bpf_local_storage cannot be found.
3552+ *
3553+ * long bpf_d_path(struct path *path, char *buf, u32 sz)
3554+ * Description
3555+ * Return full path for given 'struct path' object, which
3556+ * needs to be the kernel BTF 'path' object. The path is
3557+ * returned in the provided buffer 'buf' of size 'sz' and
3558+ * is zero terminated.
3559+ *
3560+ * Return
3561+ * On success, the strictly positive length of the string,
3562+ * including the trailing NUL character. On error, a negative
3563+ * value.
35513564 */
35523565 #define __BPF_FUNC_MAPPER(FN) \
35533566 FN(unspec), \
@@ -3697,6 +3710,7 @@ union bpf_attr { · 143 unmodified lines
36973710 FN(reserve_hdr_opt), \
36983711 FN(inode_storage_get), \
36993712 FN(inode_storage_delete), \
3713+ FN(d_path), \
37003714 /* */
37013715
37023716 /* integer value in 'imm' field of BPF_CALL instruction selects which helper

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t