diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com> | 2010-09-27 14:57:40 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2010-10-28 10:08:46 -0400 |
commit | 6e8dc55550273084b7fb5846df2f44439f5d03d9 (patch) | |
tree | 87d2e765f05f6775a71784870a2d0054713821a1 /fs/9p/acl.c | |
parent | 22d8dcdf8f8a3882d98757e78169014bb0bc6b23 (diff) |
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) | |||
97 | return -EAGAIN; | 97 | return -EAGAIN; |
98 | } | 98 | } |
99 | 99 | ||
100 | static int v9fs_set_acl(struct dentry *dentry, int type, struct posix_acl *acl) | ||
101 | { | ||
102 | int retval; | ||
103 | char *name; | ||
104 | size_t size; | ||
105 | void *buffer; | ||
106 | struct inode *inode = dentry->d_inode; | ||
107 | |||
108 | set_cached_acl(inode, type, acl); | ||
109 | /* Set a setxattr request to server */ | ||
110 | size = posix_acl_xattr_size(acl->a_count); | ||
111 | buffer = kmalloc(size, GFP_KERNEL); | ||
112 | if (!buffer) | ||
113 | return -ENOMEM; | ||
114 | retval = posix_acl_to_xattr(acl, buffer, size); | ||
115 | if (retval < 0) | ||
116 | goto err_free_out; | ||
117 | switch (type) { | ||
118 | case ACL_TYPE_ACCESS: | ||
119 | name = POSIX_ACL_XATTR_ACCESS; | ||
120 | break; | ||
121 | case ACL_TYPE_DEFAULT: | ||
122 | name = POSIX_ACL_XATTR_DEFAULT; | ||
123 | break; | ||
124 | default: | ||
125 | BUG(); | ||
126 | } | ||
127 | retval = v9fs_xattr_set(dentry, name, buffer, size, 0); | ||
128 | err_free_out: | ||
129 | kfree(buffer); | ||
130 | return retval; | ||
131 | } | ||
132 | |||
133 | int v9fs_acl_chmod(struct dentry *dentry) | ||
134 | { | ||
135 | int retval = 0; | ||
136 | struct posix_acl *acl, *clone; | ||
137 | struct inode *inode = dentry->d_inode; | ||
138 | |||
139 | if (S_ISLNK(inode->i_mode)) | ||
140 | return -EOPNOTSUPP; | ||
141 | acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS); | ||
142 | if (acl) { | ||
143 | clone = posix_acl_clone(acl, GFP_KERNEL); | ||
144 | posix_acl_release(acl); | ||
145 | if (!clone) | ||
146 | return -ENOMEM; | ||
147 | retval = posix_acl_chmod_masq(clone, inode->i_mode); | ||
148 | if (!retval) | ||
149 | retval = v9fs_set_acl(dentry, ACL_TYPE_ACCESS, clone); | ||
150 | posix_acl_release(clone); | ||
151 | } | ||
152 | return retval; | ||
153 | } | ||
154 | |||
100 | static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name, | 155 | static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name, |
101 | void *buffer, size_t size, int type) | 156 | void *buffer, size_t size, int type) |
102 | { | 157 | { |