1 From 485e71e8fb6356c08c7fc6bcce4bf02c9a9a663f Mon Sep 17 00:00:00 2001
2 From: Andreas Gruenbacher <agruenba@redhat.com>
3 Date: Wed, 22 Jun 2016 23:57:25 +0200
4 Subject: posix_acl: Add set_posix_acl
6 From: Andreas Gruenbacher <agruenba@redhat.com>
8 commit 485e71e8fb6356c08c7fc6bcce4bf02c9a9a663f upstream.
10 Factor out part of posix_acl_xattr_set into a common function that takes
11 a posix_acl, which nfsd can also call.
13 The prototype already exists in include/linux/posix_acl.h.
15 Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
16 Cc: Christoph Hellwig <hch@infradead.org>
17 Cc: Al Viro <viro@zeniv.linux.org.uk>
18 Signed-off-by: J. Bruce Fields <bfields@redhat.com>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 fs/posix_acl.c | 42 +++++++++++++++++++++++-------------------
23 1 file changed, 23 insertions(+), 19 deletions(-)
27 @@ -786,39 +786,43 @@ posix_acl_xattr_get(const struct xattr_h
32 -posix_acl_xattr_set(const struct xattr_handler *handler,
33 - struct dentry *dentry, const char *name,
34 - const void *value, size_t size, int flags)
36 +set_posix_acl(struct inode *inode, int type, struct posix_acl *acl)
38 - struct inode *inode = d_backing_inode(dentry);
39 - struct posix_acl *acl = NULL;
42 if (!IS_POSIXACL(inode))
44 if (!inode->i_op->set_acl)
47 - if (handler->flags == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
48 - return value ? -EACCES : 0;
49 + if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
50 + return acl ? -EACCES : 0;
51 if (!inode_owner_or_capable(inode))
55 + int ret = posix_acl_valid(acl);
59 + return inode->i_op->set_acl(inode, acl, type);
61 +EXPORT_SYMBOL(set_posix_acl);
64 +posix_acl_xattr_set(const struct xattr_handler *handler,
65 + struct dentry *dentry, const char *name,
66 + const void *value, size_t size, int flags)
68 + struct inode *inode = d_backing_inode(dentry);
69 + struct posix_acl *acl = NULL;
73 acl = posix_acl_from_xattr(&init_user_ns, value, size);
78 - ret = posix_acl_valid(acl);
84 - ret = inode->i_op->set_acl(inode, acl, handler->flags);
86 + ret = set_posix_acl(inode, handler->flags, acl);
87 posix_acl_release(acl);