@@ -189,25 +189,8 @@ const struct xattr_handler f2fs_xattr_security_handler = {
.set = f2fs_xattr_generic_set,
};
-static const struct xattr_handler *f2fs_xattr_handler_map[] = {
- [F2FS_XATTR_INDEX_USER] = &f2fs_xattr_user_handler,
-#ifdef CONFIG_F2FS_FS_POSIX_ACL
- [F2FS_XATTR_INDEX_POSIX_ACL_ACCESS] = &posix_acl_access_xattr_handler,
- [F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT] = &posix_acl_default_xattr_handler,
-#endif
- [F2FS_XATTR_INDEX_TRUSTED] = &f2fs_xattr_trusted_handler,
-#ifdef CONFIG_F2FS_FS_SECURITY
- [F2FS_XATTR_INDEX_SECURITY] = &f2fs_xattr_security_handler,
-#endif
- [F2FS_XATTR_INDEX_ADVISE] = &f2fs_xattr_advise_handler,
-};
-
const struct xattr_handler *f2fs_xattr_handlers[] = {
&f2fs_xattr_user_handler,
-#ifdef CONFIG_F2FS_FS_POSIX_ACL
- &posix_acl_access_xattr_handler,
- &posix_acl_default_xattr_handler,
-#endif
&f2fs_xattr_trusted_handler,
#ifdef CONFIG_F2FS_FS_SECURITY
&f2fs_xattr_security_handler,
@@ -216,13 +199,44 @@ const struct xattr_handler *f2fs_xattr_handlers[] = {
NULL,
};
-static inline const struct xattr_handler *f2fs_xattr_handler(int index)
+static const char *f2fs_xattr_prefix(int xattr_index, struct dentry *dentry)
{
+ const char *name = NULL;
const struct xattr_handler *handler = NULL;
- if (index > 0 && index < ARRAY_SIZE(f2fs_xattr_handler_map))
- handler = f2fs_xattr_handler_map[index];
- return handler;
+ switch (xattr_index) {
+ case F2FS_XATTR_INDEX_USER:
+ handler = &f2fs_xattr_user_handler;
+ break;
+ case F2FS_XATTR_INDEX_TRUSTED:
+ handler = &f2fs_xattr_trusted_handler;
+ break;
+ case F2FS_XATTR_INDEX_ADVISE:
+ handler = &f2fs_xattr_advise_handler;
+ break;
+#ifdef CONFIG_F2FS_FS_SECURITY
+ case F2FS_XATTR_INDEX_SECURITY:
+ handler = &f2fs_xattr_security_handler;
+ break;
+#endif
+#ifdef CONFIG_F2FS_FS_POSIX_ACL
+ case F2FS_XATTR_INDEX_POSIX_ACL_ACCESS:
+ if (posix_acl_dentry_list(dentry))
+ name = XATTR_NAME_POSIX_ACL_ACCESS;
+ break;
+ case F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT:
+ if (posix_acl_dentry_list(dentry))
+ name = XATTR_NAME_POSIX_ACL_DEFAULT;
+ break;
+#endif
+ default:
+ return NULL;
+ }
+
+ if (xattr_dentry_list(handler, dentry))
+ name = xattr_prefix(handler);
+
+ return name;
}
static struct f2fs_xattr_entry *__find_xattr(void *base_addr,
@@ -573,12 +587,12 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
last_base_addr = (void *)base_addr + XATTR_SIZE(inode);
list_for_each_xattr(entry, base_addr) {
- const struct xattr_handler *handler =
- f2fs_xattr_handler(entry->e_name_index);
const char *prefix;
size_t prefix_len;
size_t size;
+ prefix = f2fs_xattr_prefix(entry->e_name_index, dentry);
+
if ((void *)(entry) + sizeof(__u32) > last_base_addr ||
(void *)XATTR_NEXT_ENTRY(entry) > last_base_addr) {
f2fs_err(F2FS_I_SB(inode), "inode (%lu) has corrupted xattr",
@@ -590,10 +604,9 @@ ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
goto cleanup;
}
- if (!handler || (handler->list && !handler->list(dentry)))
+ if (!prefix)
continue;
- prefix = xattr_prefix(handler);
prefix_len = strlen(prefix);
size = prefix_len + entry->e_name_len + 1;
if (buffer) {
Last cycle we introduced a new posix acl api. Filesystems now only need to implement the inode operations for posix acls. The generic xattr handlers aren't used anymore by the vfs and will be completely removed. Keeping the handler around is confusing and gives the false impression that the xattr infrastructure of the vfs is used to interact with posix acls when it really isn't anymore. For this to work we simply rework the ->listxattr() inode operation to not rely on the generix posix acl handlers anymore. Cc: <linux-f2fs-devel@lists.sourceforge.net> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> --- fs/f2fs/xattr.c | 63 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 25 deletions(-)