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
3513 *3513 *
3514 * **-EPERM** This helper cannot be used under the3514 * **-EPERM** This helper cannot be used under the
3515 * current sock_ops->op.3515 * current sock_ops->op.
3516 *
3516 * void *bpf_inode_storage_get(struct bpf_map *map, void *inode, void *value, u64 flags)3517 * void *bpf_inode_storage_get(struct bpf_map *map, void *inode, void *value, u64 flags)
3517 * Description3518 * Description
3518 * Get a bpf_local_storage from an *inode*.3519 * Get a bpf_local_storage from an *inode*.
@@ -3548,6 +3549,18 @@ union bpf_attr { · 29 unmodified lines
3548 * 0 on success.3549 * 0 on success.
3549 *3550 *
3550 * **-ENOENT** if the bpf_local_storage cannot be found.3551 * **-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.
3551 */3564 */
3552#define __BPF_FUNC_MAPPER(FN) \3565#define __BPF_FUNC_MAPPER(FN) \
3553 FN(unspec), \3566 FN(unspec), \
@@ -3697,6 +3710,7 @@ union bpf_attr { · 143 unmodified lines
3697 FN(reserve_hdr_opt), \3710 FN(reserve_hdr_opt), \
3698 FN(inode_storage_get), \3711 FN(inode_storage_get), \
3699 FN(inode_storage_delete), \3712 FN(inode_storage_delete), \
3713 FN(d_path), \
3700 /* */3714 /* */
3701 3715
3702/* integer value in 'imm' field of BPF_CALL instruction selects which helper3716/* 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