aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2/acl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext2/acl.c')
-rw-r--r--fs/ext2/acl.c63
1 files changed, 14 insertions, 49 deletions
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index bfe651f9ae16..52c053763942 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -128,7 +128,7 @@ fail:
128/* 128/*
129 * inode->i_mutex: don't care 129 * inode->i_mutex: don't care
130 */ 130 */
131static struct posix_acl * 131struct posix_acl *
132ext2_get_acl(struct inode *inode, int type) 132ext2_get_acl(struct inode *inode, int type)
133{ 133{
134 int name_index; 134 int name_index;
@@ -231,29 +231,6 @@ ext2_set_acl(struct inode *inode, int type, struct posix_acl *acl)
231 return error; 231 return error;
232} 232}
233 233
234int
235ext2_check_acl(struct inode *inode, int mask)
236{
237 struct posix_acl *acl;
238
239 if (mask & MAY_NOT_BLOCK) {
240 if (!negative_cached_acl(inode, ACL_TYPE_ACCESS))
241 return -ECHILD;
242 return -EAGAIN;
243 }
244
245 acl = ext2_get_acl(inode, ACL_TYPE_ACCESS);
246 if (IS_ERR(acl))
247 return PTR_ERR(acl);
248 if (acl) {
249 int error = posix_acl_permission(inode, acl, mask);
250 posix_acl_release(acl);
251 return error;
252 }
253
254 return -EAGAIN;
255}
256
257/* 234/*
258 * Initialize the ACLs of a new inode. Called from ext2_new_inode. 235 * Initialize the ACLs of a new inode. Called from ext2_new_inode.
259 * 236 *
@@ -276,29 +253,20 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
276 inode->i_mode &= ~current_umask(); 253 inode->i_mode &= ~current_umask();
277 } 254 }
278 if (test_opt(inode->i_sb, POSIX_ACL) && acl) { 255 if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
279 struct posix_acl *clone; 256 mode_t mode = inode->i_mode;
280 mode_t mode;
281
282 if (S_ISDIR(inode->i_mode)) { 257 if (S_ISDIR(inode->i_mode)) {
283 error = ext2_set_acl(inode, ACL_TYPE_DEFAULT, acl); 258 error = ext2_set_acl(inode, ACL_TYPE_DEFAULT, acl);
284 if (error) 259 if (error)
285 goto cleanup; 260 goto cleanup;
286 } 261 }
287 clone = posix_acl_clone(acl, GFP_KERNEL); 262 error = posix_acl_create(&acl, GFP_KERNEL, &mode);
288 error = -ENOMEM; 263 if (error < 0)
289 if (!clone) 264 return error;
290 goto cleanup; 265 inode->i_mode = mode;
291 mode = inode->i_mode; 266 if (error > 0) {
292 error = posix_acl_create_masq(clone, &mode); 267 /* This is an extended ACL */
293 if (error >= 0) { 268 error = ext2_set_acl(inode, ACL_TYPE_ACCESS, acl);
294 inode->i_mode = mode;
295 if (error > 0) {
296 /* This is an extended ACL */
297 error = ext2_set_acl(inode,
298 ACL_TYPE_ACCESS, clone);
299 }
300 } 269 }
301 posix_acl_release(clone);
302 } 270 }
303cleanup: 271cleanup:
304 posix_acl_release(acl); 272 posix_acl_release(acl);
@@ -322,7 +290,7 @@ cleanup:
322int 290int
323ext2_acl_chmod(struct inode *inode) 291ext2_acl_chmod(struct inode *inode)
324{ 292{
325 struct posix_acl *acl, *clone; 293 struct posix_acl *acl;
326 int error; 294 int error;
327 295
328 if (!test_opt(inode->i_sb, POSIX_ACL)) 296 if (!test_opt(inode->i_sb, POSIX_ACL))
@@ -332,14 +300,11 @@ ext2_acl_chmod(struct inode *inode)
332 acl = ext2_get_acl(inode, ACL_TYPE_ACCESS); 300 acl = ext2_get_acl(inode, ACL_TYPE_ACCESS);
333 if (IS_ERR(acl) || !acl) 301 if (IS_ERR(acl) || !acl)
334 return PTR_ERR(acl); 302 return PTR_ERR(acl);
335 clone = posix_acl_clone(acl, GFP_KERNEL); 303 error = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
304 if (error)
305 return error;
306 error = ext2_set_acl(inode, ACL_TYPE_ACCESS, acl);
336 posix_acl_release(acl); 307 posix_acl_release(acl);
337 if (!clone)
338 return -ENOMEM;
339 error = posix_acl_chmod_masq(clone, inode->i_mode);
340 if (!error)
341 error = ext2_set_acl(inode, ACL_TYPE_ACCESS, clone);
342 posix_acl_release(clone);
343 return error; 308 return error;
344} 309}
345 310