diff options
Diffstat (limited to 'fs/reiserfs/xattr_acl.c')
-rw-r--r-- | fs/reiserfs/xattr_acl.c | 72 |
1 files changed, 22 insertions, 50 deletions
diff --git a/fs/reiserfs/xattr_acl.c b/fs/reiserfs/xattr_acl.c index 35d6e672a279..9cdb759645a9 100644 --- a/fs/reiserfs/xattr_acl.c +++ b/fs/reiserfs/xattr_acl.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <linux/errno.h> | 5 | #include <linux/errno.h> |
6 | #include <linux/pagemap.h> | 6 | #include <linux/pagemap.h> |
7 | #include <linux/xattr.h> | 7 | #include <linux/xattr.h> |
8 | #include <linux/slab.h> | ||
8 | #include <linux/posix_acl_xattr.h> | 9 | #include <linux/posix_acl_xattr.h> |
9 | #include <linux/reiserfs_xattr.h> | 10 | #include <linux/reiserfs_xattr.h> |
10 | #include <linux/reiserfs_acl.h> | 11 | #include <linux/reiserfs_acl.h> |
@@ -15,8 +16,10 @@ static int reiserfs_set_acl(struct reiserfs_transaction_handle *th, | |||
15 | struct posix_acl *acl); | 16 | struct posix_acl *acl); |
16 | 17 | ||
17 | static int | 18 | static int |
18 | xattr_set_acl(struct inode *inode, int type, const void *value, size_t size) | 19 | posix_acl_set(struct dentry *dentry, const char *name, const void *value, |
20 | size_t size, int flags, int type) | ||
19 | { | 21 | { |
22 | struct inode *inode = dentry->d_inode; | ||
20 | struct posix_acl *acl; | 23 | struct posix_acl *acl; |
21 | int error, error2; | 24 | int error, error2; |
22 | struct reiserfs_transaction_handle th; | 25 | struct reiserfs_transaction_handle th; |
@@ -60,15 +63,16 @@ xattr_set_acl(struct inode *inode, int type, const void *value, size_t size) | |||
60 | } | 63 | } |
61 | 64 | ||
62 | static int | 65 | static int |
63 | xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size) | 66 | posix_acl_get(struct dentry *dentry, const char *name, void *buffer, |
67 | size_t size, int type) | ||
64 | { | 68 | { |
65 | struct posix_acl *acl; | 69 | struct posix_acl *acl; |
66 | int error; | 70 | int error; |
67 | 71 | ||
68 | if (!reiserfs_posixacl(inode->i_sb)) | 72 | if (!reiserfs_posixacl(dentry->d_sb)) |
69 | return -EOPNOTSUPP; | 73 | return -EOPNOTSUPP; |
70 | 74 | ||
71 | acl = reiserfs_get_acl(inode, type); | 75 | acl = reiserfs_get_acl(dentry->d_inode, type); |
72 | if (IS_ERR(acl)) | 76 | if (IS_ERR(acl)) |
73 | return PTR_ERR(acl); | 77 | return PTR_ERR(acl); |
74 | if (acl == NULL) | 78 | if (acl == NULL) |
@@ -452,7 +456,9 @@ int reiserfs_acl_chmod(struct inode *inode) | |||
452 | return 0; | 456 | return 0; |
453 | } | 457 | } |
454 | 458 | ||
459 | reiserfs_write_unlock(inode->i_sb); | ||
455 | acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS); | 460 | acl = reiserfs_get_acl(inode, ACL_TYPE_ACCESS); |
461 | reiserfs_write_lock(inode->i_sb); | ||
456 | if (!acl) | 462 | if (!acl) |
457 | return 0; | 463 | return 0; |
458 | if (IS_ERR(acl)) | 464 | if (IS_ERR(acl)) |
@@ -482,30 +488,12 @@ int reiserfs_acl_chmod(struct inode *inode) | |||
482 | return error; | 488 | return error; |
483 | } | 489 | } |
484 | 490 | ||
485 | static int | 491 | static size_t posix_acl_access_list(struct dentry *dentry, char *list, |
486 | posix_acl_access_get(struct inode *inode, const char *name, | ||
487 | void *buffer, size_t size) | ||
488 | { | ||
489 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1) | ||
490 | return -EINVAL; | ||
491 | return xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size); | ||
492 | } | ||
493 | |||
494 | static int | ||
495 | posix_acl_access_set(struct inode *inode, const char *name, | ||
496 | const void *value, size_t size, int flags) | ||
497 | { | ||
498 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_ACCESS) - 1) | ||
499 | return -EINVAL; | ||
500 | return xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size); | ||
501 | } | ||
502 | |||
503 | static size_t posix_acl_access_list(struct inode *inode, char *list, | ||
504 | size_t list_size, const char *name, | 492 | size_t list_size, const char *name, |
505 | size_t name_len) | 493 | size_t name_len, int type) |
506 | { | 494 | { |
507 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); | 495 | const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); |
508 | if (!reiserfs_posixacl(inode->i_sb)) | 496 | if (!reiserfs_posixacl(dentry->d_sb)) |
509 | return 0; | 497 | return 0; |
510 | if (list && size <= list_size) | 498 | if (list && size <= list_size) |
511 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); | 499 | memcpy(list, POSIX_ACL_XATTR_ACCESS, size); |
@@ -514,35 +502,18 @@ static size_t posix_acl_access_list(struct inode *inode, char *list, | |||
514 | 502 | ||
515 | struct xattr_handler reiserfs_posix_acl_access_handler = { | 503 | struct xattr_handler reiserfs_posix_acl_access_handler = { |
516 | .prefix = POSIX_ACL_XATTR_ACCESS, | 504 | .prefix = POSIX_ACL_XATTR_ACCESS, |
517 | .get = posix_acl_access_get, | 505 | .flags = ACL_TYPE_ACCESS, |
518 | .set = posix_acl_access_set, | 506 | .get = posix_acl_get, |
507 | .set = posix_acl_set, | ||
519 | .list = posix_acl_access_list, | 508 | .list = posix_acl_access_list, |
520 | }; | 509 | }; |
521 | 510 | ||
522 | static int | 511 | static size_t posix_acl_default_list(struct dentry *dentry, char *list, |
523 | posix_acl_default_get(struct inode *inode, const char *name, | ||
524 | void *buffer, size_t size) | ||
525 | { | ||
526 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1) | ||
527 | return -EINVAL; | ||
528 | return xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size); | ||
529 | } | ||
530 | |||
531 | static int | ||
532 | posix_acl_default_set(struct inode *inode, const char *name, | ||
533 | const void *value, size_t size, int flags) | ||
534 | { | ||
535 | if (strlen(name) != sizeof(POSIX_ACL_XATTR_DEFAULT) - 1) | ||
536 | return -EINVAL; | ||
537 | return xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size); | ||
538 | } | ||
539 | |||
540 | static size_t posix_acl_default_list(struct inode *inode, char *list, | ||
541 | size_t list_size, const char *name, | 512 | size_t list_size, const char *name, |
542 | size_t name_len) | 513 | size_t name_len, int type) |
543 | { | 514 | { |
544 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); | 515 | const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); |
545 | if (!reiserfs_posixacl(inode->i_sb)) | 516 | if (!reiserfs_posixacl(dentry->d_sb)) |
546 | return 0; | 517 | return 0; |
547 | if (list && size <= list_size) | 518 | if (list && size <= list_size) |
548 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); | 519 | memcpy(list, POSIX_ACL_XATTR_DEFAULT, size); |
@@ -551,7 +522,8 @@ static size_t posix_acl_default_list(struct inode *inode, char *list, | |||
551 | 522 | ||
552 | struct xattr_handler reiserfs_posix_acl_default_handler = { | 523 | struct xattr_handler reiserfs_posix_acl_default_handler = { |
553 | .prefix = POSIX_ACL_XATTR_DEFAULT, | 524 | .prefix = POSIX_ACL_XATTR_DEFAULT, |
554 | .get = posix_acl_default_get, | 525 | .flags = ACL_TYPE_DEFAULT, |
555 | .set = posix_acl_default_set, | 526 | .get = posix_acl_get, |
527 | .set = posix_acl_set, | ||
556 | .list = posix_acl_default_list, | 528 | .list = posix_acl_default_list, |
557 | }; | 529 | }; |