aboutsummaryrefslogtreecommitdiffstats
path: root/fs/reiserfs/xattr_acl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/reiserfs/xattr_acl.c')
-rw-r--r--fs/reiserfs/xattr_acl.c77
1 files changed, 25 insertions, 52 deletions
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c
index 3dc38f1206f..6da0396e505 100644
--- a/fs/reiserfs/xattr_acl.c
+++ b/fs/reiserfs/xattr_acl.c
@@ -272,12 +272,10 @@ reiserfs_set_acl(struct reiserfs_transaction_handle *th, struct inode *inode,
272 case ACL_TYPE_ACCESS: 272 case ACL_TYPE_ACCESS:
273 name = POSIX_ACL_XATTR_ACCESS; 273 name = POSIX_ACL_XATTR_ACCESS;
274 if (acl) { 274 if (acl) {
275 mode_t mode = inode->i_mode; 275 error = posix_acl_equiv_mode(acl, &inode->i_mode);
276 error = posix_acl_equiv_mode(acl, &mode);
277 if (error < 0) 276 if (error < 0)
278 return error; 277 return error;
279 else { 278 else {
280 inode->i_mode = mode;
281 if (error == 0) 279 if (error == 0)
282 acl = NULL; 280 acl = NULL;
283 } 281 }
@@ -354,10 +352,6 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
354 return PTR_ERR(acl); 352 return PTR_ERR(acl);
355 353
356 if (acl) { 354 if (acl) {
357 struct posix_acl *acl_copy;
358 mode_t mode = inode->i_mode;
359 int need_acl;
360
361 /* Copy the default ACL to the default ACL of a new directory */ 355 /* Copy the default ACL to the default ACL of a new directory */
362 if (S_ISDIR(inode->i_mode)) { 356 if (S_ISDIR(inode->i_mode)) {
363 err = reiserfs_set_acl(th, inode, ACL_TYPE_DEFAULT, 357 err = reiserfs_set_acl(th, inode, ACL_TYPE_DEFAULT,
@@ -368,29 +362,13 @@ reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
368 362
369 /* Now we reconcile the new ACL and the mode, 363 /* Now we reconcile the new ACL and the mode,
370 potentially modifying both */ 364 potentially modifying both */
371 acl_copy = posix_acl_clone(acl, GFP_NOFS); 365 err = posix_acl_create(&acl, GFP_NOFS, &inode->i_mode);
372 if (!acl_copy) { 366 if (err < 0)
373 err = -ENOMEM; 367 return err;
374 goto cleanup;
375 }
376
377 need_acl = posix_acl_create_masq(acl_copy, &mode);
378 if (need_acl >= 0) {
379 if (mode != inode->i_mode) {
380 inode->i_mode = mode;
381 }
382 368
383 /* If we need an ACL.. */ 369 /* If we need an ACL.. */
384 if (need_acl > 0) { 370 if (err > 0)
385 err = reiserfs_set_acl(th, inode, 371 err = reiserfs_set_acl(th, inode, ACL_TYPE_ACCESS, acl);
386 ACL_TYPE_ACCESS,
387 acl_copy);
388 if (err)
389 goto cleanup_copy;
390 }
391 }
392 cleanup_copy:
393 posix_acl_release(acl_copy);
394 cleanup: 372 cleanup:
395 posix_acl_release(acl); 373 posix_acl_release(acl);
396 } else { 374 } else {
@@ -445,7 +423,10 @@ int reiserfs_cache_default_acl(struct inode *inode)
445 423
446int reiserfs_acl_chmod(struct inode *inode) 424int reiserfs_acl_chmod(struct inode *inode)
447{ 425{
448 struct posix_acl *acl, *clone; 426 struct reiserfs_transaction_handle th;
427 struct posix_acl *acl;
428 size_t size;
429 int depth;
449 int error; 430 int error;
450 431
451 if (S_ISLNK(inode->i_mode)) 432 if (S_ISLNK(inode->i_mode))
@@ -463,30 +444,22 @@ int reiserfs_acl_chmod(struct inode *inode)
463 return 0; 444 return 0;
464 if (IS_ERR(acl)) 445 if (IS_ERR(acl))
465 return PTR_ERR(acl); 446 return PTR_ERR(acl);
466 clone = posix_acl_clone(acl, GFP_NOFS); 447 error = posix_acl_chmod(&acl, GFP_NOFS, inode->i_mode);
467 posix_acl_release(acl); 448 if (error)
468 if (!clone) 449 return error;
469 return -ENOMEM; 450
470 error = posix_acl_chmod_masq(clone, inode->i_mode); 451 size = reiserfs_xattr_nblocks(inode, reiserfs_acl_size(acl->a_count));
452 depth = reiserfs_write_lock_once(inode->i_sb);
453 error = journal_begin(&th, inode->i_sb, size * 2);
471 if (!error) { 454 if (!error) {
472 struct reiserfs_transaction_handle th; 455 int error2;
473 size_t size = reiserfs_xattr_nblocks(inode, 456 error = reiserfs_set_acl(&th, inode, ACL_TYPE_ACCESS, acl);
474 reiserfs_acl_size(clone->a_count)); 457 error2 = journal_end(&th, inode->i_sb, size * 2);
475 int depth; 458 if (error2)
476 459 error = error2;
477 depth = reiserfs_write_lock_once(inode->i_sb);
478 error = journal_begin(&th, inode->i_sb, size * 2);
479 if (!error) {
480 int error2;
481 error = reiserfs_set_acl(&th, inode, ACL_TYPE_ACCESS,
482 clone);
483 error2 = journal_end(&th, inode->i_sb, size * 2);
484 if (error2)
485 error = error2;
486 }
487 reiserfs_write_unlock_once(inode->i_sb, depth);
488 } 460 }
489 posix_acl_release(clone); 461 reiserfs_write_unlock_once(inode->i_sb, depth);
462 posix_acl_release(acl);
490 return error; 463 return error;
491} 464}
492 465