aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2016-06-22 17:57:25 -0400
committerJ. Bruce Fields <bfields@redhat.com>2016-06-24 12:11:34 -0400
commit485e71e8fb6356c08c7fc6bcce4bf02c9a9a663f (patch)
treed5587256360eb42e819d5760e6e6db8250ccfa80 /fs
parent8c7245abda877d4689b3371db8ae2a4400d7d9ce (diff)
posix_acl: Add set_posix_acl
Factor out part of posix_acl_xattr_set into a common function that takes a posix_acl, which nfsd can also call. The prototype already exists in include/linux/posix_acl.h. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Cc: stable@vger.kernel.org Cc: Christoph Hellwig <hch@infradead.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/posix_acl.c42
1 files changed, 23 insertions, 19 deletions
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 8a4a266beff3..edc452c2a563 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -820,39 +820,43 @@ posix_acl_xattr_get(const struct xattr_handler *handler,
820 return error; 820 return error;
821} 821}
822 822
823static int 823int
824posix_acl_xattr_set(const struct xattr_handler *handler, 824set_posix_acl(struct inode *inode, int type, struct posix_acl *acl)
825 struct dentry *unused, struct inode *inode,
826 const char *name, const void *value,
827 size_t size, int flags)
828{ 825{
829 struct posix_acl *acl = NULL;
830 int ret;
831
832 if (!IS_POSIXACL(inode)) 826 if (!IS_POSIXACL(inode))
833 return -EOPNOTSUPP; 827 return -EOPNOTSUPP;
834 if (!inode->i_op->set_acl) 828 if (!inode->i_op->set_acl)
835 return -EOPNOTSUPP; 829 return -EOPNOTSUPP;
836 830
837 if (handler->flags == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode)) 831 if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
838 return value ? -EACCES : 0; 832 return acl ? -EACCES : 0;
839 if (!inode_owner_or_capable(inode)) 833 if (!inode_owner_or_capable(inode))
840 return -EPERM; 834 return -EPERM;
841 835
836 if (acl) {
837 int ret = posix_acl_valid(acl);
838 if (ret)
839 return ret;
840 }
841 return inode->i_op->set_acl(inode, acl, type);
842}
843EXPORT_SYMBOL(set_posix_acl);
844
845static int
846posix_acl_xattr_set(const struct xattr_handler *handler,
847 struct dentry *unused, struct inode *inode,
848 const char *name, const void *value,
849 size_t size, int flags)
850{
851 struct posix_acl *acl = NULL;
852 int ret;
853
842 if (value) { 854 if (value) {
843 acl = posix_acl_from_xattr(&init_user_ns, value, size); 855 acl = posix_acl_from_xattr(&init_user_ns, value, size);
844 if (IS_ERR(acl)) 856 if (IS_ERR(acl))
845 return PTR_ERR(acl); 857 return PTR_ERR(acl);
846
847 if (acl) {
848 ret = posix_acl_valid(acl);
849 if (ret)
850 goto out;
851 }
852 } 858 }
853 859 ret = set_posix_acl(inode, handler->flags, acl);
854 ret = inode->i_op->set_acl(inode, acl, handler->flags);
855out:
856 posix_acl_release(acl); 860 posix_acl_release(acl);
857 return ret; 861 return ret;
858} 862}