summaryrefslogtreecommitdiffstats
path: root/include/linux/xattr.h
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2015-12-02 08:44:36 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-12-06 21:33:52 -0500
commit98e9cb5711c68223f0e4d5201b9a6add255ec550 (patch)
tree12fee55d296fc85a6e8188368ca4944fc4d913a8 /include/linux/xattr.h
parent97d79299223baab330b194437e676d301f12d5f6 (diff)
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>
Diffstat (limited to 'include/linux/xattr.h')
-rw-r--r--include/linux/xattr.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/xattr.h b/include/linux/xattr.h
index 45fa3456a0cc..03c847fb6cc1 100644
--- a/include/linux/xattr.h
+++ b/include/linux/xattr.h
@@ -19,7 +19,13 @@
19struct inode; 19struct inode;
20struct dentry; 20struct dentry;
21 21
22/*
23 * struct xattr_handler: When @name is set, match attributes with exactly that
24 * name. When @prefix is set instead, match attributes with that prefix and
25 * with a non-empty suffix.
26 */
22struct xattr_handler { 27struct xattr_handler {
28 const char *name;
23 const char *prefix; 29 const char *prefix;
24 int flags; /* fs private flags */ 30 int flags; /* fs private flags */
25 size_t (*list)(const struct xattr_handler *, struct dentry *dentry, 31 size_t (*list)(const struct xattr_handler *, struct dentry *dentry,
@@ -54,6 +60,11 @@ int generic_removexattr(struct dentry *dentry, const char *name);
54ssize_t vfs_getxattr_alloc(struct dentry *dentry, const char *name, 60ssize_t vfs_getxattr_alloc(struct dentry *dentry, const char *name,
55 char **xattr_value, size_t size, gfp_t flags); 61 char **xattr_value, size_t size, gfp_t flags);
56 62
63static inline const char *xattr_prefix(const struct xattr_handler *handler)
64{
65 return handler->prefix ?: handler->name;
66}
67
57struct simple_xattrs { 68struct simple_xattrs {
58 struct list_head head; 69 struct list_head head;
59 spinlock_t lock; 70 spinlock_t lock;