diff options
Diffstat (limited to 'fs/reiserfs/xattr_acl.c')
-rw-r--r-- | fs/reiserfs/xattr_acl.c | 79 |
1 files changed, 31 insertions, 48 deletions
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c index d3ce6ee9b262..bfecf7553002 100644 --- a/fs/reiserfs/xattr_acl.c +++ b/fs/reiserfs/xattr_acl.c | |||
@@ -271,7 +271,7 @@ reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) | |||
271 | char *name; | 271 | char *name; |
272 | void *value = NULL; | 272 | void *value = NULL; |
273 | struct posix_acl **p_acl; | 273 | struct posix_acl **p_acl; |
274 | size_t size; | 274 | size_t size = 0; |
275 | int error; | 275 | int error; |
276 | struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode); | 276 | struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode); |
277 | 277 | ||
@@ -308,16 +308,21 @@ reiserfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) | |||
308 | value = posix_acl_to_disk(acl, &size); | 308 | value = posix_acl_to_disk(acl, &size); |
309 | if (IS_ERR(value)) | 309 | if (IS_ERR(value)) |
310 | return (int)PTR_ERR(value); | 310 | return (int)PTR_ERR(value); |
311 | error = reiserfs_xattr_set(inode, name, value, size, 0); | 311 | } |
312 | } else { | 312 | |
313 | error = reiserfs_xattr_del(inode, name); | 313 | error = __reiserfs_xattr_set(inode, name, value, size, 0); |
314 | if (error == -ENODATA) { | 314 | |
315 | /* This may seem odd here, but it means that the ACL was set | 315 | /* |
316 | * with a value representable with mode bits. If there was | 316 | * Ensure that the inode gets dirtied if we're only using |
317 | * an ACL before, reiserfs_xattr_del already dirtied the inode. | 317 | * the mode bits and an old ACL didn't exist. We don't need |
318 | */ | 318 | * to check if the inode is hashed here since we won't get |
319 | * called by reiserfs_inherit_default_acl(). | ||
320 | */ | ||
321 | if (error == -ENODATA) { | ||
322 | error = 0; | ||
323 | if (type == ACL_TYPE_ACCESS) { | ||
324 | inode->i_ctime = CURRENT_TIME_SEC; | ||
319 | mark_inode_dirty(inode); | 325 | mark_inode_dirty(inode); |
320 | error = 0; | ||
321 | } | 326 | } |
322 | } | 327 | } |
323 | 328 | ||
@@ -474,33 +479,22 @@ posix_acl_access_set(struct inode *inode, const char *name, | |||
474 | return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | 479 | return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); |
475 | } | 480 | } |
476 | 481 | ||
477 | static int posix_acl_access_del(struct inode *inode, const char *name) | 482 | static size_t posix_acl_access_list(struct inode *inode, char *list, |
478 | { | 483 | size_t list_size, const char *name, |
479 | struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode); | 484 | size_t name_len) |
480 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1) | ||
481 | return -EINVAL; | ||
482 | iset_acl(inode, &reiserfs_i->i_acl_access, ERR_PTR(-ENODATA)); | ||
483 | return 0; | ||
484 | } | ||
485 | |||
486 | static int | ||
487 | posix_acl_access_list(struct inode *inode, const char *name, int namelen, | ||
488 | char *out) | ||
489 | { | 485 | { |
490 | int len = namelen; | 486 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); |
491 | if (!reiserfs_posixacl(inode->i_sb)) | 487 | if (!reiserfs_posixacl(inode->i_sb)) |
492 | return 0; | 488 | return 0; |
493 | if (out) | 489 | if (list && size <= list_size) |
494 | memcpy(out, name, len); | 490 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); |
495 | 491 | return size; | |
496 | return len; | ||
497 | } | 492 | } |
498 | 493 | ||
499 | struct reiserfs_xattr_handler posix_acl_access_handler = { | 494 | struct xattr_handler reiserfs_posix_acl_access_handler = { |
500 | .prefix = POSIX_ACL_XATTR_ACCESS, | 495 | .prefix = POSIX_ACL_XATTR_ACCESS, |
501 | .get = posix_acl_access_get, | 496 | .get = posix_acl_access_get, |
502 | .set = posix_acl_access_set, | 497 | .set = posix_acl_access_set, |
503 | .del = posix_acl_access_del, | ||
504 | .list = posix_acl_access_list, | 498 | .list = posix_acl_access_list, |
505 | }; | 499 | }; |
506 | 500 | ||
@@ -522,32 +516,21 @@ posix_acl_default_set(struct inode *inode, const char *name, | |||
522 | return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | 516 | return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); |
523 | } | 517 | } |
524 | 518 | ||
525 | static int posix_acl_default_del(struct inode *inode, const char *name) | 519 | static size_t posix_acl_default_list(struct inode *inode, char *list, |
520 | size_t list_size, const char *name, | ||
521 | size_t name_len) | ||
526 | { | 522 | { |
527 | struct reiserfs_inode_info *reiserfs_i = REISERFS_I(inode); | 523 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); |
528 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1) | ||
529 | return -EINVAL; | ||
530 | iset_acl(inode, &reiserfs_i->i_acl_default, ERR_PTR(-ENODATA)); | ||
531 | return 0; | ||
532 | } | ||
533 | |||
534 | static int | ||
535 | posix_acl_default_list(struct inode *inode, const char *name, int namelen, | ||
536 | char *out) | ||
537 | { | ||
538 | int len = namelen; | ||
539 | if (!reiserfs_posixacl(inode->i_sb)) | 524 | if (!reiserfs_posixacl(inode->i_sb)) |
540 | return 0; | 525 | return 0; |
541 | if (out) | 526 | if (list && size <= list_size) |
542 | memcpy(out, name, len); | 527 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); |
543 | 528 | return size; | |
544 | return len; | ||
545 | } | 529 | } |
546 | 530 | ||
547 | struct reiserfs_xattr_handler posix_acl_default_handler = { | 531 | struct xattr_handler reiserfs_posix_acl_default_handler = { |
548 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 532 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
549 | .get = posix_acl_default_get, | 533 | .get = posix_acl_default_get, |
550 | .set = posix_acl_default_set, | 534 | .set = posix_acl_default_set, |
551 | .del = posix_acl_default_del, | ||
552 | .list = posix_acl_default_list, | 535 | .list = posix_acl_default_list, |
553 | }; | 536 | }; |