Skip to content

Commit 2c6dcad

Browse files
RtoaxKernel Patches Daemon
authored andcommitted
bpf_doc: Support 1st const parameter of bpf_d_path()
Since commit 1b8abbb ("bpf...d_path(): constify path argument"), the first parameter of the bpf_d_path() has been changed to a const constant. We need to modify the header file and bpf_doc.py. The two error messages are as follows: linux/tools/testing/selftests/bpf$ make CLNG-BPF [test_progs] bpf_iter_task_vmas.bpf.o progs/bpf_iter_task_vmas.c:52:14: error: passing 'const struct path *' to parameter of type 'struct path *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] 52 | bpf_d_path(&file->f_path, d_path_buf, D_PATH_BUF_SIZE); | ^~~~~~~~~~~~~ 1 error generated. .... progs/verifier_vfs_accept.c:80:7: error: assigning to 'struct path *' from 'const struct path *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers] 80 | path = &file->f_path; | ^ ~~~~~~~~~~~~~ 1 error generated. Fixes: 1b8abbb ("bpf...d_path(): constify path argument") Signed-off-by: Rong Tao <[email protected]>
1 parent e0b1dc1 commit 2c6dcad

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

include/uapi/linux/bpf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4891,7 +4891,7 @@ union bpf_attr {
48914891
*
48924892
* **-ENOENT** if the bpf_local_storage cannot be found.
48934893
*
4894-
* long bpf_d_path(struct path *path, char *buf, u32 sz)
4894+
* long bpf_d_path(const struct path *path, char *buf, u32 sz)
48954895
* Description
48964896
* Return full path for given **struct path** object, which
48974897
* needs to be the kernel BTF *path* object. The path is

scripts/bpf_doc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ def __init__(self, parser):
788788
'struct task_struct',
789789
'struct cgroup',
790790
'struct path',
791+
'const struct path',
791792
'struct btf_ptr',
792793
'struct inode',
793794
'struct socket',

tools/include/uapi/linux/bpf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4891,7 +4891,7 @@ union bpf_attr {
48914891
*
48924892
* **-ENOENT** if the bpf_local_storage cannot be found.
48934893
*
4894-
* long bpf_d_path(struct path *path, char *buf, u32 sz)
4894+
* long bpf_d_path(const struct path *path, char *buf, u32 sz)
48954895
* Description
48964896
* Return full path for given **struct path** object, which
48974897
* needs to be the kernel BTF *path* object. The path is

tools/testing/selftests/bpf/progs/verifier_vfs_accept.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ __success
7070
int BPF_PROG(path_d_path_from_file_argument, struct file *file)
7171
{
7272
int ret;
73-
struct path *path;
73+
const struct path *path;
7474

7575
/* The f_path member is a path which is embedded directly within a
7676
* file. Therefore, a pointer to such embedded members are still

0 commit comments

Comments
 (0)