[PATCH v4 17/59] allow to use CLASS() for struct filename *

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

Not all users match that model, but quite a few do. No mindless
mass conversions, please...

Added:
CLASS(filename, name)(user_path) =>
getname(user_path)
CLASS(filename_kernel, name)(string) =>
getname_kernel(string)
CLASS(filename_flags, name)(user_path, flags) =>
getname_flags(user_path, flags)
CLASS(filename_uflags, name)(user_path, flags) =>
getname_uflags(user_path, flags)
CLASS(filename_maybe_null, name)(user_path, flags) =>
getname_maybe_null(user_path, flags)
CLASS(filename_consume, name)(filename) =>
no_free_ptr(filename)
all with putname() as destructor.

"flags" in filename_flags() is in LOOKUP_... space, only LOOKUP_EMPTY matters.
"flags" in filename_uflags() and filename_maybe_null() is in AT_...... space,
and only AT_EMPTY_PATH matters.

These conventions might be worth reconsidering...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
include/linux/fs.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/include/linux/fs.h b/include/linux/fs.h
index a74ffcbe8407..ed16644545db 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2522,6 +2522,13 @@ static inline struct filename *refname(struct filename *name)
return name;
}

+DEFINE_CLASS(filename, struct filename *, putname(_T), getname(p), const char __user *p)
+EXTEND_CLASS(filename, _kernel, getname_kernel(p), const char *p)
+EXTEND_CLASS(filename, _flags, getname_flags(p, f), const char __user *p, unsigned int f)
+EXTEND_CLASS(filename, _uflags, getname_uflags(p, f), const char __user *p, unsigned int f)
+EXTEND_CLASS(filename, _maybe_null, getname_maybe_null(p, f), const char __user *p, unsigned int f)
+EXTEND_CLASS(filename, _consume, no_free_ptr(p), struct filename *p)
+
extern int finish_open(struct file *file, struct dentry *dentry,
int (*open)(struct inode *, struct file *));
extern int finish_no_open(struct file *file, struct dentry *dentry);
--
2.47.3