diff options
author | Frank van der Linden <fllinden@amazon.com> | 2020-06-24 00:39:19 +0200 |
---|---|---|
committer | Chuck Lever <chuck.lever@oracle.com> | 2020-07-13 23:27:03 +0200 |
commit | cab8d289c5ad541a5351a651d95c4086b7f84d7c (patch) | |
tree | 6c30bbee0157751414bb2e12665e1fcc6284e12b /fs/xattr.c | |
parent | xattr: break delegations in {set,remove}xattr (diff) | |
download | linux-cab8d289c5ad541a5351a651d95c4086b7f84d7c.tar.xz linux-cab8d289c5ad541a5351a651d95c4086b7f84d7c.zip |
xattr: add a function to check if a namespace is supported
Add a function that checks is an extended attribute namespace is
supported for an inode, meaning that a handler must be present
for either the whole namespace, or at least one synthetic
xattr in the namespace.
To be used by the nfs server code when being queried for extended
attributes support.
Cc: linux-fsdevel@vger.kernel.org
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Frank van der Linden <fllinden@amazon.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'fs/xattr.c')
-rw-r--r-- | fs/xattr.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/fs/xattr.c b/fs/xattr.c index 95f38f57347f..386b45676d7e 100644 --- a/fs/xattr.c +++ b/fs/xattr.c @@ -134,6 +134,33 @@ xattr_permission(struct inode *inode, const char *name, int mask) return inode_permission(inode, mask); } +/* + * Look for any handler that deals with the specified namespace. + */ +int +xattr_supported_namespace(struct inode *inode, const char *prefix) +{ + const struct xattr_handler **handlers = inode->i_sb->s_xattr; + const struct xattr_handler *handler; + size_t preflen; + + if (!(inode->i_opflags & IOP_XATTR)) { + if (unlikely(is_bad_inode(inode))) + return -EIO; + return -EOPNOTSUPP; + } + + preflen = strlen(prefix); + + for_each_xattr_handler(handlers, handler) { + if (!strncmp(xattr_prefix(handler), prefix, preflen)) + return 0; + } + + return -EOPNOTSUPP; +} +EXPORT_SYMBOL(xattr_supported_namespace); + int __vfs_setxattr(struct dentry *dentry, struct inode *inode, const char *name, const void *value, size_t size, int flags) |