vfs: Distinguish between full xattr names and proper prefixes
Add an additional "name" field to struct xattr_handler. When the name
is set, the handler matches attributes with exactly that name. When the
prefix is set instead, the handler matches attributes with the given
prefix and with a non-empty suffix.
This patch should avoid bugs like the one fixed in commit c361016a
in
the future.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: James Morris <james.l.morris@oracle.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:

committed by
Al Viro

parent
97d7929922
commit
98e9cb5711
@@ -19,7 +19,13 @@
|
||||
struct inode;
|
||||
struct dentry;
|
||||
|
||||
/*
|
||||
* struct xattr_handler: When @name is set, match attributes with exactly that
|
||||
* name. When @prefix is set instead, match attributes with that prefix and
|
||||
* with a non-empty suffix.
|
||||
*/
|
||||
struct xattr_handler {
|
||||
const char *name;
|
||||
const char *prefix;
|
||||
int flags; /* fs private flags */
|
||||
size_t (*list)(const struct xattr_handler *, struct dentry *dentry,
|
||||
@@ -54,6 +60,11 @@ int generic_removexattr(struct dentry *dentry, const char *name);
|
||||
ssize_t vfs_getxattr_alloc(struct dentry *dentry, const char *name,
|
||||
char **xattr_value, size_t size, gfp_t flags);
|
||||
|
||||
static inline const char *xattr_prefix(const struct xattr_handler *handler)
|
||||
{
|
||||
return handler->prefix ?: handler->name;
|
||||
}
|
||||
|
||||
struct simple_xattrs {
|
||||
struct list_head head;
|
||||
spinlock_t lock;
|
||||
|
Reference in New Issue
Block a user