Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Christian Brauner (Microsoft) <brauner@kernel.org>

+26 -22
+26 -22
fs/reiserfs/xattr.c
··· 52 52 #include <linux/quotaops.h> 53 53 #include <linux/security.h> 54 54 #include <linux/posix_acl_xattr.h> 55 + #include <linux/xattr.h> 55 56 56 57 #define PRIVROOT_NAME ".reiserfs_priv" 57 58 #define XAROOT_NAME "xattrs" ··· 771 770 (handler) != NULL; \ 772 771 (handler) = *(handlers)++) 773 772 774 - /* This is the implementation for the xattr plugin infrastructure */ 775 - static inline const struct xattr_handler * 776 - find_xattr_handler_prefix(const struct xattr_handler **handlers, 777 - const char *name) 773 + static inline bool reiserfs_posix_acl_list(const char *name, 774 + struct dentry *dentry) 778 775 { 779 - const struct xattr_handler *xah; 776 + return (posix_acl_type(name) >= 0) && 777 + IS_POSIXACL(d_backing_inode(dentry)); 778 + } 780 779 781 - if (!handlers) 782 - return NULL; 780 + /* This is the implementation for the xattr plugin infrastructure */ 781 + static inline bool reiserfs_xattr_list(const struct xattr_handler **handlers, 782 + const char *name, struct dentry *dentry) 783 + { 784 + if (handlers) { 785 + const struct xattr_handler *xah = NULL; 783 786 784 - for_each_xattr_handler(handlers, xah) { 785 - const char *prefix = xattr_prefix(xah); 786 - if (strncmp(prefix, name, strlen(prefix)) == 0) 787 - break; 787 + for_each_xattr_handler(handlers, xah) { 788 + const char *prefix = xattr_prefix(xah); 789 + 790 + if (strncmp(prefix, name, strlen(prefix))) 791 + continue; 792 + 793 + if (!xattr_handler_can_list(xah, dentry)) 794 + return false; 795 + 796 + return true; 797 + } 788 798 } 789 799 790 - return xah; 800 + return reiserfs_posix_acl_list(name, dentry); 791 801 } 792 802 793 803 struct listxattr_buf { ··· 819 807 820 808 if (name[0] != '.' || 821 809 (namelen != 1 && (name[1] != '.' || namelen != 2))) { 822 - const struct xattr_handler *handler; 823 - 824 - handler = find_xattr_handler_prefix(b->dentry->d_sb->s_xattr, 825 - name); 826 - if (!handler /* Unsupported xattr name */ || 827 - (handler->list && !handler->list(b->dentry))) 810 + if (!reiserfs_xattr_list(b->dentry->d_sb->s_xattr, name, 811 + b->dentry)) 828 812 return true; 829 813 size = namelen + 1; 830 814 if (b->buf) { ··· 918 910 #endif 919 911 #ifdef CONFIG_REISERFS_FS_SECURITY 920 912 &reiserfs_xattr_security_handler, 921 - #endif 922 - #ifdef CONFIG_REISERFS_FS_POSIX_ACL 923 - &posix_acl_access_xattr_handler, 924 - &posix_acl_default_xattr_handler, 925 913 #endif 926 914 NULL 927 915 };