Make vfs_walk_start(), vfs_walk_next() and vfs_walk_end() non-static and declare them in fs/internal.h next to the walk state, so an iterating consumer (BPF) can drive the walk with every step and invariant staying in namei.c. vfs_walk_ancestors() and its callback contract are unchanged. Signed-off-by: Justin Suess --- fs/internal.h | 5 +++++ fs/namei.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/internal.h b/fs/internal.h index bfe62c9bdfc9..3ce2220ff57f 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -81,6 +81,11 @@ struct vfs_ancestor_walk { unsigned int flags; /* VFS_WALK_* */ }; +void vfs_walk_start(struct vfs_ancestor_walk *aw, const struct path *path, + unsigned int flags); +int vfs_walk_next(struct vfs_ancestor_walk *aw); +void vfs_walk_end(struct vfs_ancestor_walk *aw); + void __init filename_init(void); /* diff --git a/fs/namei.c b/fs/namei.c index 6d5b4b214334..d6151fa27844 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2249,8 +2249,8 @@ static const struct path vfs_walk_no_root; * @path: position to walk up from; never modified * @flags: %VFS_WALK_* flags; none defined yet, pass 0 */ -static void vfs_walk_start(struct vfs_ancestor_walk *aw, - const struct path *path, unsigned int flags) +void vfs_walk_start(struct vfs_ancestor_walk *aw, const struct path *path, + unsigned int flags) { if (WARN_ON_ONCE(flags)) flags = 0; @@ -2299,7 +2299,7 @@ static int vfs_walk_step_ref(struct vfs_ancestor_walk *aw) * Returns: 0 with @aw->pos valid, 1 once the walk has passed the real * root. */ -static int vfs_walk_next(struct vfs_ancestor_walk *aw) +int vfs_walk_next(struct vfs_ancestor_walk *aw) { if (aw->flags & VFS_WALK_STARTED) { int err = vfs_walk_step_ref(aw); @@ -2317,7 +2317,7 @@ static int vfs_walk_next(struct vfs_ancestor_walk *aw) * vfs_walk_end - finish a stepwise ancestor walk * @aw: the walk; its positions, including @aw->pos, become invalid */ -static void vfs_walk_end(struct vfs_ancestor_walk *aw) +void vfs_walk_end(struct vfs_ancestor_walk *aw) { path_put(&aw->pos); } -- 2.55.0