diff options
author | Christoph Hellwig <hch@lst.de> | 2009-11-13 04:52:56 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2009-12-16 12:16:49 -0500 |
commit | 431547b3c4533b8c7fd150ab36980b9a3147797b (patch) | |
tree | 807ff2790f3c13c7c91ed2afd6d833032899482d /fs/xattr.c | |
parent | ef26ca97e83052790940cbc444b01b0d17a813c1 (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/xattr.c')
-rw-r--r-- | fs/xattr.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/fs/xattr.c b/fs/xattr.c index 6d4f6d3449fb..46f87e828b48 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
@@ -615,12 +615,11 @@ ssize_t | |||
615 | generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) | 615 | generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t size) |
616 | { | 616 | { |
617 | struct xattr_handler *handler; | 617 | struct xattr_handler *handler; |
618 | struct inode *inode = dentry->d_inode; | ||
619 | 618 | ||
620 | handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); | 619 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
621 | if (!handler) | 620 | if (!handler) |
622 | return -EOPNOTSUPP; | 621 | return -EOPNOTSUPP; |
623 | return handler->get(inode, name, buffer, size); | 622 | return handler->get(dentry, name, buffer, size, handler->flags); |
624 | } | 623 | } |
625 | 624 | ||
626 | /* | 625 | /* |
@@ -630,18 +629,20 @@ generic_getxattr(struct dentry *dentry, const char *name, void *buffer, size_t s | |||
630 | ssize_t | 629 | ssize_t |
631 | generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) | 630 | generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size) |
632 | { | 631 | { |
633 | struct inode *inode = dentry->d_inode; | 632 | struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr; |
634 | struct xattr_handler *handler, **handlers = inode->i_sb->s_xattr; | ||
635 | unsigned int size = 0; | 633 | unsigned int size = 0; |
636 | 634 | ||
637 | if (!buffer) { | 635 | if (!buffer) { |
638 | for_each_xattr_handler(handlers, handler) | 636 | for_each_xattr_handler(handlers, handler) { |
639 | size += handler->list(inode, NULL, 0, NULL, 0); | 637 | size += handler->list(dentry, NULL, 0, NULL, 0, |
638 | handler->flags); | ||
639 | } | ||
640 | } else { | 640 | } else { |
641 | char *buf = buffer; | 641 | char *buf = buffer; |
642 | 642 | ||
643 | for_each_xattr_handler(handlers, handler) { | 643 | for_each_xattr_handler(handlers, handler) { |
644 | size = handler->list(inode, buf, buffer_size, NULL, 0); | 644 | size = handler->list(dentry, buf, buffer_size, |
645 | NULL, 0, handler->flags); | ||
645 | if (size > buffer_size) | 646 | if (size > buffer_size) |
646 | return -ERANGE; | 647 | return -ERANGE; |
647 | buf += size; | 648 | buf += size; |
@@ -659,14 +660,13 @@ int | |||
659 | generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) | 660 | generic_setxattr(struct dentry *dentry, const char *name, const void *value, size_t size, int flags) |
660 | { | 661 | { |
661 | struct xattr_handler *handler; | 662 | struct xattr_handler *handler; |
662 | struct inode *inode = dentry->d_inode; | ||
663 | 663 | ||
664 | if (size == 0) | 664 | if (size == 0) |
665 | value = ""; /* empty EA, do not remove */ | 665 | value = ""; /* empty EA, do not remove */ |
666 | handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); | 666 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
667 | if (!handler) | 667 | if (!handler) |
668 | return -EOPNOTSUPP; | 668 | return -EOPNOTSUPP; |
669 | return handler->set(inode, name, value, size, flags); | 669 | return handler->set(dentry, name, value, size, 0, handler->flags); |
670 | } | 670 | } |
671 | 671 | ||
672 | /* | 672 | /* |
@@ -677,12 +677,12 @@ int | |||
677 | generic_removexattr(struct dentry *dentry, const char *name) | 677 | generic_removexattr(struct dentry *dentry, const char *name) |
678 | { | 678 | { |
679 | struct xattr_handler *handler; | 679 | struct xattr_handler *handler; |
680 | struct inode *inode = dentry->d_inode; | ||
681 | 680 | ||
682 | handler = xattr_resolve_name(inode->i_sb->s_xattr, &name); | 681 | handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); |
683 | if (!handler) | 682 | if (!handler) |
684 | return -EOPNOTSUPP; | 683 | return -EOPNOTSUPP; |
685 | return handler->set(inode, name, NULL, 0, XATTR_REPLACE); | 684 | return handler->set(dentry, name, NULL, 0, |
685 | XATTR_REPLACE, handler->flags); | ||
686 | } | 686 | } |
687 | 687 | ||
688 | EXPORT_SYMBOL(generic_getxattr); | 688 | EXPORT_SYMBOL(generic_getxattr); |