aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xattr.c
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2015-10-04 13:18:52 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-11-13 20:34:33 -0500
commite409de992e3ea3674393465f07cc71c948edd87a (patch)
treee650f63fbb38fb48cef2fd24f10651ea5765d5ff /fs/xattr.c
parentd9a82a04033f87bbd06efb29f78c0170a38154a8 (diff)
9p: xattr simplifications
Now that the xattr handler is passed to the xattr handler operations, we can use the same get and set operations for the user, trusted, and security xattr namespaces. In those namespaces, we can access the full attribute name by "reattaching" the name prefix the vfs has skipped for us. Add a xattr_full_name helper to make this obvious in the code. For the "system.posix_acl_access" and "system.posix_acl_default" attributes, handler->prefix is the full attribute name; the suffix is the empty string. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Cc: Eric Van Hensbergen <ericvh@gmail.com> Cc: Ron Minnich <rminnich@sandia.gov> Cc: Latchesar Ionkov <lucho@ionkov.net> Cc: v9fs-developer@lists.sourceforge.net Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/xattr.c')
-rw-r--r--fs/xattr.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/fs/xattr.c b/fs/xattr.c
index 44377b6f6001..9b932b95d74e 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -790,6 +790,30 @@ EXPORT_SYMBOL(generic_listxattr);
790EXPORT_SYMBOL(generic_setxattr); 790EXPORT_SYMBOL(generic_setxattr);
791EXPORT_SYMBOL(generic_removexattr); 791EXPORT_SYMBOL(generic_removexattr);
792 792
793/**
794 * xattr_full_name - Compute full attribute name from suffix
795 *
796 * @handler: handler of the xattr_handler operation
797 * @name: name passed to the xattr_handler operation
798 *
799 * The get and set xattr handler operations are called with the remainder of
800 * the attribute name after skipping the handler's prefix: for example, "foo"
801 * is passed to the get operation of a handler with prefix "user." to get
802 * attribute "user.foo". The full name is still "there" in the name though.
803 *
804 * Note: the list xattr handler operation when called from the vfs is passed a
805 * NULL name; some file systems use this operation internally, with varying
806 * semantics.
807 */
808const char *xattr_full_name(const struct xattr_handler *handler,
809 const char *name)
810{
811 size_t prefix_len = strlen(handler->prefix);
812
813 return name - prefix_len;
814}
815EXPORT_SYMBOL(xattr_full_name);
816
793/* 817/*
794 * Allocate new xattr and copy in the value; but leave the name to callers. 818 * Allocate new xattr and copy in the value; but leave the name to callers.
795 */ 819 */