Re: [RFC PATCH v6 1/9] fs/namei.c: make lookup_last() use trailing_slashes()

From: NeilBrown

Date: Sun May 31 2026 - 22:10:05 EST


On Mon, 01 Jun 2026, Jori Koolstra wrote:
> Small cleanup to use the existing trailing_slashes() function in
> lookup_last().

I think this is good and useful but could be better.
There are 5 other places in namei.c where trailing_slashes() could be
used to replace the same test. Let's do them all at once.

Thanks,
NeilBrown


>
> Signed-off-by: Jori Koolstra <jkoolstra@xxxxxxxxx>
> ---
> fs/namei.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/fs/namei.c b/fs/namei.c
> index c7fac83c9a85..137d9fffbe80 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -2777,9 +2777,14 @@ static const char *path_init(struct nameidata *nd, unsigned flags)
> return s;
> }
>
> +static inline bool trailing_slashes(struct nameidata *nd)
> +{
> + return (bool)nd->last.name[nd->last.len];
> +}
> +
> static inline const char *lookup_last(struct nameidata *nd)
> {
> - if (nd->last_type == LAST_NORM && nd->last.name[nd->last.len])
> + if (nd->last_type == LAST_NORM && trailing_slashes(nd))
> nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY;
>
> return walk_component(nd, WALK_TRAILING);
> @@ -4524,11 +4529,6 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
> return ERR_PTR(error);
> }
>
> -static inline bool trailing_slashes(struct nameidata *nd)
> -{
> - return (bool)nd->last.name[nd->last.len];
> -}
> -
> static struct dentry *lookup_fast_for_open(struct nameidata *nd, int open_flag)
> {
> struct dentry *dentry;
>
> base-commit: 174914ea551314c52a61713b9c4bde9e42d48073
> --
> 2.54.0
>
>