[PATCH v4 48/59] namei.c: switch user pathname imports to CLASS(filename{,_flags})

Al Viro
2026-01-08T07:36:58Z

filename_flags is used by user_path_at(). I suspect that mixing
LOOKUP_EMPTY with real lookup flags had been a mistake all along; the
former belongs to pathname import, the latter - to pathwalk. Right now
none of the remaining in-tree callers of user_path_at() are getting
LOOKUP_EMPTY in flags, so user_path_at() could probably be switched
to CLASS(filename)...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
fs/namei.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index 325a69f2bfff..cbddd5d44a12 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3022,11 +3022,8 @@ struct dentry *start_removing_user_path_at(int dfd,
const char __user *name,
struct path *path)
{
- struct filename *filename = getname(name);
- struct dentry *res = __start_removing_path(dfd, filename, path);
-
- putname(filename);
- return res;
+ CLASS(filename, filename)(name);
+ return __start_removing_path(dfd, filename, path);
}
EXPORT_SYMBOL(start_removing_user_path_at);

@@ -3604,11 +3601,8 @@ int path_pts(struct path *path)
int user_path_at(int dfd, const char __user *name, unsigned flags,
struct path *path)
{
- struct filename *filename = getname_flags(name, flags);
- int ret = filename_lookup(dfd, filename, flags, path, NULL);
-
- putname(filename);
- return ret;
+ CLASS(filename_flags, filename)(name, flags);
+ return filename_lookup(dfd, filename, flags, path, NULL);
}
EXPORT_SYMBOL(user_path_at);

@@ -4967,11 +4961,8 @@ inline struct dentry *start_creating_user_path(
int dfd, const char __user *pathname,
struct path *path, unsigned int lookup_flags)
{
- struct filename *filename = getname(pathname);
- struct dentry *res = filename_create(dfd, filename, path, lookup_flags);
-
- putname(filename);
- return res;
+ CLASS(filename, filename)(pathname);
+ return filename_create(dfd, filename, path, lookup_flags);
}
EXPORT_SYMBOL(start_creating_user_path);

--
2.47.3