Commit 387b96a5 authored by Christian Brauner's avatar Christian Brauner Committed by Christian Brauner (Microsoft)

reiserfs: rework ->listxattr() implementation

Rework reiserfs so it doesn't have to rely on the dummy xattr handlers
in its s_xattr list anymore as this is completely unused for setting and
getting posix acls.

Cc: reiserfs-devel@vger.kernel.org
Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
parent a5488f29
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include <linux/quotaops.h> #include <linux/quotaops.h>
#include <linux/security.h> #include <linux/security.h>
#include <linux/posix_acl_xattr.h> #include <linux/posix_acl_xattr.h>
#include <linux/xattr.h>
#define PRIVROOT_NAME ".reiserfs_priv" #define PRIVROOT_NAME ".reiserfs_priv"
#define XAROOT_NAME "xattrs" #define XAROOT_NAME "xattrs"
...@@ -770,23 +771,34 @@ reiserfs_xattr_get(struct inode *inode, const char *name, void *buffer, ...@@ -770,23 +771,34 @@ reiserfs_xattr_get(struct inode *inode, const char *name, void *buffer,
(handler) != NULL; \ (handler) != NULL; \
(handler) = *(handlers)++) (handler) = *(handlers)++)
static inline bool reiserfs_posix_acl_list(const char *name,
struct dentry *dentry)
{
return (posix_acl_type(name) >= 0) &&
IS_POSIXACL(d_backing_inode(dentry));
}
/* This is the implementation for the xattr plugin infrastructure */ /* This is the implementation for the xattr plugin infrastructure */
static inline const struct xattr_handler * static inline bool reiserfs_xattr_list(const struct xattr_handler **handlers,
find_xattr_handler_prefix(const struct xattr_handler **handlers, const char *name, struct dentry *dentry)
const char *name)
{ {
const struct xattr_handler *xah; if (handlers) {
const struct xattr_handler *xah = NULL;
if (!handlers) for_each_xattr_handler(handlers, xah) {
return NULL; const char *prefix = xattr_prefix(xah);
for_each_xattr_handler(handlers, xah) { if (strncmp(prefix, name, strlen(prefix)))
const char *prefix = xattr_prefix(xah); continue;
if (strncmp(prefix, name, strlen(prefix)) == 0)
break; if (!xattr_handler_can_list(xah, dentry))
return false;
return true;
}
} }
return xah; return reiserfs_posix_acl_list(name, dentry);
} }
struct listxattr_buf { struct listxattr_buf {
...@@ -807,12 +819,8 @@ static bool listxattr_filler(struct dir_context *ctx, const char *name, ...@@ -807,12 +819,8 @@ static bool listxattr_filler(struct dir_context *ctx, const char *name,
if (name[0] != '.' || if (name[0] != '.' ||
(namelen != 1 && (name[1] != '.' || namelen != 2))) { (namelen != 1 && (name[1] != '.' || namelen != 2))) {
const struct xattr_handler *handler; if (!reiserfs_xattr_list(b->dentry->d_sb->s_xattr, name,
b->dentry))
handler = find_xattr_handler_prefix(b->dentry->d_sb->s_xattr,
name);
if (!handler /* Unsupported xattr name */ ||
(handler->list && !handler->list(b->dentry)))
return true; return true;
size = namelen + 1; size = namelen + 1;
if (b->buf) { if (b->buf) {
...@@ -910,10 +918,6 @@ const struct xattr_handler *reiserfs_xattr_handlers[] = { ...@@ -910,10 +918,6 @@ const struct xattr_handler *reiserfs_xattr_handlers[] = {
#endif #endif
#ifdef CONFIG_REISERFS_FS_SECURITY #ifdef CONFIG_REISERFS_FS_SECURITY
&reiserfs_xattr_security_handler, &reiserfs_xattr_security_handler,
#endif
#ifdef CONFIG_REISERFS_FS_POSIX_ACL
&posix_acl_access_xattr_handler,
&posix_acl_default_xattr_handler,
#endif #endif
NULL NULL
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment