diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2010-09-28 00:27:40 +0530 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2010-10-28 09:08:46 -0500 |
commit | 6e8dc55550273084b7fb5846df2f44439f5d03d9 (patch) | |
tree | 87d2e765f05f6775a71784870a2d0054713821a1 /fs/9p/acl.c | |
parent | 22d8dcdf8f8a3882d98757e78169014bb0bc6b23 (diff) | |
download | linux-stable-6e8dc55550273084b7fb5846df2f44439f5d03d9.tar.gz linux-stable-6e8dc55550273084b7fb5846df2f44439f5d03d9.tar.bz2 linux-stable-6e8dc55550273084b7fb5846df2f44439f5d03d9.zip |
fs/9p: Update ACL on chmod
We need update the acl value on chmod
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
Diffstat (limited to 'fs/9p/acl.c')
-rw-r--r-- | fs/9p/acl.c | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/fs/9p/acl.c b/fs/9p/acl.c index cad38bc1710e..8f2acde74c05 100644 --- a/fs/9p/acl.c +++ b/fs/9p/acl.c @@ -97,6 +97,61 @@ int v9fs_check_acl(struct inode *inode, int mask) return -EAGAIN; } +static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl) +{ + int retval; + char *name; + size_t size; + void *buffer; + struct inode *inode = dentry->d_inode; + + set_cached_acl(inode, type, acl); + /* Set a setxattr request to server */ + size = posix_acl_xattr_size(acl->a_count); + buffer = kmalloc(size, GFP_KERNEL); + if (!buffer) + return -ENOMEM; + retval = posix_acl_to_xattr(acl, buffer, size); + if (retval < 0) + goto err_free_out; + switch (type) { + case ACL_TYPE_ACCESS: + name = POSIX_ACL_XATTR_ACCESS; + break; + case ACL_TYPE_DEFAULT: + name = POSIX_ACL_XATTR_DEFAULT; + break; + default: + BUG(); + } + retval = v9fs_xattr_set(dentry, name, buffer, size, 0); +err_free_out: + kfree(buffer); + return retval; +} + +int v9fs_acl_chmod(struct dentry *dentry) +{ + int retval = 0; + struct posix_acl *acl, *clone; + struct inode *inode = dentry->d_inode; + + if (S_ISLNK(inode->i_mode)) + return -EOPNOTSUPP; + acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS); + if (acl) { + clone = posix_acl_clone(acl, GFP_KERNEL); + posix_acl_release(acl); + if (!clone) + return -ENOMEM; + retval = posix_acl_chmod_masq(clone, inode->i_mode); + if (!retval) + retval = v9fs_set_acl(dentry, ACL_TYPE_ACCESS, clone); + posix_acl_release(clone); + } + return retval; +} + static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer, size_t size, int type) { |