aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/xattr.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2009-11-13 04:52:56 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2009-12-16 12:16:49 -0500
commit431547b3c4533b8c7fd150ab36980b9a3147797b (patch)
tree807ff2790f3c13c7c91ed2afd6d833032899482d /fs/reiserfs/xattr.c
parentef26ca97e83052790940cbc444b01b0d17a813c1 (diff)
sanitize xattr handler prototypes
Add a flags argument to struct xattr_handler and pass it to all xattr handler methods. This allows using the same methods for multiple handlers, e.g. for the ACL methods which perform exactly the same action for the access and default ACLs, just using a different underlying attribute. With a little more groundwork it'll also allow sharing the methods for the regular user/trusted/secure handlers in extN, ocfs2 and jffs2 like it's already done for xfs in this patch. Also change the inode argument to the handlers to a dentry to allow using the handlers mechnism for filesystems that require it later, e.g. cifs. [with GFS2 bits updated by Steven Whitehouse <swhiteho@redhat.com>] Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: James Morris <jmorris@namei.org> Acked-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/reiserfs/xattr.c')
-rw-r--r--fs/reiserfs/xattr.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/fs/reiserfs/xattr.c b/fs/reiserfs/xattr.c
index 58aa8e75f7f5..8c7033a8b67e 100644
--- a/fs/reiserfs/xattr.c
+++ b/fs/reiserfs/xattr.c
@@ -48,6 +48,7 @@
48#include <net/checksum.h> 48#include <net/checksum.h>
49#include <linux/stat.h> 49#include <linux/stat.h>
50#include <linux/quotaops.h> 50#include <linux/quotaops.h>
51#include <linux/security.h>
51 52
52#define PRIVROOT_NAME ".reiserfs_priv" 53#define PRIVROOT_NAME ".reiserfs_priv"
53#define XAROOT_NAME "xattrs" 54#define XAROOT_NAME "xattrs"
@@ -726,15 +727,14 @@ ssize_t
726reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer, 727reiserfs_getxattr(struct dentry * dentry, const char *name, void *buffer,
727 size_t size) 728 size_t size)
728{ 729{
729 struct inode *inode = dentry->d_inode;
730 struct xattr_handler *handler; 730 struct xattr_handler *handler;
731 731
732 handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); 732 handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name);
733 733
734 if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1) 734 if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
735 return -EOPNOTSUPP; 735 return -EOPNOTSUPP;
736 736
737 return handler->get(inode, name, buffer, size); 737 return handler->get(dentry, name, buffer, size, handler->flags);
738} 738}
739 739
740/* 740/*
@@ -746,15 +746,14 @@ int
746reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value, 746reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
747 size_t size, int flags) 747 size_t size, int flags)
748{ 748{
749 struct inode *inode = dentry->d_inode;
750 struct xattr_handler *handler; 749 struct xattr_handler *handler;
751 750
752 handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); 751 handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name);
753 752
754 if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1) 753 if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
755 return -EOPNOTSUPP; 754 return -EOPNOTSUPP;
756 755
757 return handler->set(inode, name, value, size, flags); 756 return handler->set(dentry, name, value, size, flags, handler->flags);
758} 757}
759 758
760/* 759/*
@@ -764,21 +763,20 @@ reiserfs_setxattr(struct dentry *dentry, const char *name, const void *value,
764 */ 763 */
765int reiserfs_removexattr(struct dentry *dentry, const char *name) 764int reiserfs_removexattr(struct dentry *dentry, const char *name)
766{ 765{
767 struct inode *inode = dentry->d_inode;
768 struct xattr_handler *handler; 766 struct xattr_handler *handler;
769 handler = find_xattr_handler_prefix(inode->i_sb->s_xattr, name); 767 handler = find_xattr_handler_prefix(dentry->d_sb->s_xattr, name);
770 768
771 if (!handler || get_inode_sd_version(inode) == STAT_DATA_V1) 769 if (!handler || get_inode_sd_version(dentry->d_inode) == STAT_DATA_V1)
772 return -EOPNOTSUPP; 770 return -EOPNOTSUPP;
773 771
774 return handler->set(inode, name, NULL, 0, XATTR_REPLACE); 772 return handler->set(dentry, name, NULL, 0, XATTR_REPLACE, handler->flags);
775} 773}
776 774
777struct listxattr_buf { 775struct listxattr_buf {
778 size_t size; 776 size_t size;
779 size_t pos; 777 size_t pos;
780 char *buf; 778 char *buf;
781 struct inode *inode; 779 struct dentry *dentry;
782}; 780};
783 781
784static int listxattr_filler(void *buf, const char *name, int namelen, 782static int listxattr_filler(void *buf, const char *name, int namelen,
@@ -789,17 +787,19 @@ static int listxattr_filler(void *buf, const char *name, int namelen,
789 if (name[0] != '.' || 787 if (name[0] != '.' ||
790 (namelen != 1 && (name[1] != '.' || namelen != 2))) { 788 (namelen != 1 && (name[1] != '.' || namelen != 2))) {
791 struct xattr_handler *handler; 789 struct xattr_handler *handler;
792 handler = find_xattr_handler_prefix(b->inode->i_sb->s_xattr, 790 handler = find_xattr_handler_prefix(b->dentry->d_sb->s_xattr,
793 name); 791 name);
794 if (!handler) /* Unsupported xattr name */ 792 if (!handler) /* Unsupported xattr name */
795 return 0; 793 return 0;
796 if (b->buf) { 794 if (b->buf) {
797 size = handler->list(b->inode, b->buf + b->pos, 795 size = handler->list(b->dentry, b->buf + b->pos,
798 b->size, name, namelen); 796 b->size, name, namelen,
797 handler->flags);
799 if (size > b->size) 798 if (size > b->size)
800 return -ERANGE; 799 return -ERANGE;
801 } else { 800 } else {
802 size = handler->list(b->inode, NULL, 0, name, namelen); 801 size = handler->list(b->dentry, NULL, 0, name,
802 namelen, handler->flags);
803 } 803 }
804 804
805 b->pos += size; 805 b->pos += size;
@@ -820,7 +820,7 @@ ssize_t reiserfs_listxattr(struct dentry * dentry, char *buffer, size_t size)
820 int err = 0; 820 int err = 0;
821 loff_t pos = 0; 821 loff_t pos = 0;
822 struct listxattr_buf buf = { 822 struct listxattr_buf buf = {
823 .inode = dentry->d_inode, 823 .dentry = dentry,
824 .buf = buffer, 824 .buf = buffer,
825 .size = buffer ? size : 0, 825 .size = buffer ? size : 0,
826 }; 826 };