diff options
author | Christoph Hellwig <hch@lst.de> | 2011-07-23 11:37:31 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-07-25 14:30:23 -0400 |
commit | 4e34e719e457f2e031297175410fc0bd4016a085 (patch) | |
tree | ab969a371e0d2efc6bfbf503ca6cdfce3af3bf6c /fs/ext4 | |
parent | edde854e8bb34a7f32fa993d721f1da0faf64165 (diff) |
fs: take the ACL checks to common code
Replace the ->check_acl method with a ->get_acl method that simply reads an
ACL from disk after having a cache miss. This means we can replace the ACL
checking boilerplate code with a single implementation in namei.c.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/acl.c | 19 | ||||
-rw-r--r-- | fs/ext4/acl.h | 4 | ||||
-rw-r--r-- | fs/ext4/file.c | 2 | ||||
-rw-r--r-- | fs/ext4/namei.c | 4 |
4 files changed, 6 insertions, 23 deletions
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c index 7b094d1a8d3e..dca2d1ded931 100644 --- a/fs/ext4/acl.c +++ b/fs/ext4/acl.c | |||
@@ -131,7 +131,7 @@ fail: | |||
131 | * | 131 | * |
132 | * inode->i_mutex: don't care | 132 | * inode->i_mutex: don't care |
133 | */ | 133 | */ |
134 | static struct posix_acl * | 134 | struct posix_acl * |
135 | ext4_get_acl(struct inode *inode, int type) | 135 | ext4_get_acl(struct inode *inode, int type) |
136 | { | 136 | { |
137 | int name_index; | 137 | int name_index; |
@@ -237,23 +237,6 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type, | |||
237 | return error; | 237 | return error; |
238 | } | 238 | } |
239 | 239 | ||
240 | int | ||
241 | ext4_check_acl(struct inode *inode, int mask) | ||
242 | { | ||
243 | struct posix_acl *acl; | ||
244 | |||
245 | acl = ext4_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 | /* | 240 | /* |
258 | * Initialize the ACLs of a new inode. Called from ext4_new_inode. | 241 | * Initialize the ACLs of a new inode. Called from ext4_new_inode. |
259 | * | 242 | * |
diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h index 9d843d5deac4..18cb39ed7c7b 100644 --- a/fs/ext4/acl.h +++ b/fs/ext4/acl.h | |||
@@ -54,13 +54,13 @@ static inline int ext4_acl_count(size_t size) | |||
54 | #ifdef CONFIG_EXT4_FS_POSIX_ACL | 54 | #ifdef CONFIG_EXT4_FS_POSIX_ACL |
55 | 55 | ||
56 | /* acl.c */ | 56 | /* acl.c */ |
57 | extern int ext4_check_acl(struct inode *, int); | 57 | struct posix_acl *ext4_get_acl(struct inode *inode, int type); |
58 | extern int ext4_acl_chmod(struct inode *); | 58 | extern int ext4_acl_chmod(struct inode *); |
59 | extern int ext4_init_acl(handle_t *, struct inode *, struct inode *); | 59 | extern int ext4_init_acl(handle_t *, struct inode *, struct inode *); |
60 | 60 | ||
61 | #else /* CONFIG_EXT4_FS_POSIX_ACL */ | 61 | #else /* CONFIG_EXT4_FS_POSIX_ACL */ |
62 | #include <linux/sched.h> | 62 | #include <linux/sched.h> |
63 | #define ext4_check_acl NULL | 63 | #define ext4_get_acl NULL |
64 | 64 | ||
65 | static inline int | 65 | static inline int |
66 | ext4_acl_chmod(struct inode *inode) | 66 | ext4_acl_chmod(struct inode *inode) |
diff --git a/fs/ext4/file.c b/fs/ext4/file.c index ce766f974b1d..e4095e988eba 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c | |||
@@ -301,7 +301,7 @@ const struct inode_operations ext4_file_inode_operations = { | |||
301 | .listxattr = ext4_listxattr, | 301 | .listxattr = ext4_listxattr, |
302 | .removexattr = generic_removexattr, | 302 | .removexattr = generic_removexattr, |
303 | #endif | 303 | #endif |
304 | .check_acl = ext4_check_acl, | 304 | .get_acl = ext4_get_acl, |
305 | .fiemap = ext4_fiemap, | 305 | .fiemap = ext4_fiemap, |
306 | }; | 306 | }; |
307 | 307 | ||
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 707d605bf769..8c9babac43dc 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -2590,7 +2590,7 @@ const struct inode_operations ext4_dir_inode_operations = { | |||
2590 | .listxattr = ext4_listxattr, | 2590 | .listxattr = ext4_listxattr, |
2591 | .removexattr = generic_removexattr, | 2591 | .removexattr = generic_removexattr, |
2592 | #endif | 2592 | #endif |
2593 | .check_acl = ext4_check_acl, | 2593 | .get_acl = ext4_get_acl, |
2594 | .fiemap = ext4_fiemap, | 2594 | .fiemap = ext4_fiemap, |
2595 | }; | 2595 | }; |
2596 | 2596 | ||
@@ -2602,5 +2602,5 @@ const struct inode_operations ext4_special_inode_operations = { | |||
2602 | .listxattr = ext4_listxattr, | 2602 | .listxattr = ext4_listxattr, |
2603 | .removexattr = generic_removexattr, | 2603 | .removexattr = generic_removexattr, |
2604 | #endif | 2604 | #endif |
2605 | .check_acl = ext4_check_acl, | 2605 | .get_acl = ext4_get_acl, |
2606 | }; | 2606 | }; |