diff options
author | Tiger Yang <tiger.yang@oracle.com> | 2008-11-13 22:17:18 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2009-01-05 11:34:20 -0500 |
commit | 23fc2702bea686569281708ad519b41a11d0a2f4 (patch) | |
tree | a567f38647047836332d1cfc17d7ad0be05c55ef | |
parent | 929fb014e041c6572c5e8c3686f1e32742b5b953 (diff) |
ocfs2: add ocfs2_check_acl
This function is used to enhance permission checking with POSIX ACLs.
Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
-rw-r--r-- | fs/ocfs2/acl.c | 15 | ||||
-rw-r--r-- | fs/ocfs2/acl.h | 10 | ||||
-rw-r--r-- | fs/ocfs2/file.c | 3 |
3 files changed, 27 insertions, 1 deletions
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c index 62d0faad600b..a6a2bf6d6845 100644 --- a/fs/ocfs2/acl.c +++ b/fs/ocfs2/acl.c | |||
@@ -230,6 +230,21 @@ static int ocfs2_set_acl(handle_t *handle, | |||
230 | return ret; | 230 | return ret; |
231 | } | 231 | } |
232 | 232 | ||
233 | int ocfs2_check_acl(struct inode *inode, int mask) | ||
234 | { | ||
235 | struct posix_acl *acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS); | ||
236 | |||
237 | if (IS_ERR(acl)) | ||
238 | return PTR_ERR(acl); | ||
239 | if (acl) { | ||
240 | int ret = posix_acl_permission(inode, acl, mask); | ||
241 | posix_acl_release(acl); | ||
242 | return ret; | ||
243 | } | ||
244 | |||
245 | return -EAGAIN; | ||
246 | } | ||
247 | |||
233 | static size_t ocfs2_xattr_list_acl_access(struct inode *inode, | 248 | static size_t ocfs2_xattr_list_acl_access(struct inode *inode, |
234 | char *list, | 249 | char *list, |
235 | size_t list_len, | 250 | size_t list_len, |
diff --git a/fs/ocfs2/acl.h b/fs/ocfs2/acl.h index 1b39f3e14c1b..fef10f1b782b 100644 --- a/fs/ocfs2/acl.h +++ b/fs/ocfs2/acl.h | |||
@@ -26,4 +26,14 @@ struct ocfs2_acl_entry { | |||
26 | __le32 e_id; | 26 | __le32 e_id; |
27 | }; | 27 | }; |
28 | 28 | ||
29 | #ifdef CONFIG_OCFS2_FS_POSIX_ACL | ||
30 | |||
31 | extern int ocfs2_check_acl(struct inode *, int); | ||
32 | |||
33 | #else /* CONFIG_OCFS2_FS_POSIX_ACL*/ | ||
34 | |||
35 | #define ocfs2_check_acl NULL | ||
36 | |||
37 | #endif /* CONFIG_OCFS2_FS_POSIX_ACL*/ | ||
38 | |||
29 | #endif /* OCFS2_ACL_H */ | 39 | #endif /* OCFS2_ACL_H */ |
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 360549161e20..7bad7d9b9a2c 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -56,6 +56,7 @@ | |||
56 | #include "suballoc.h" | 56 | #include "suballoc.h" |
57 | #include "super.h" | 57 | #include "super.h" |
58 | #include "xattr.h" | 58 | #include "xattr.h" |
59 | #include "acl.h" | ||
59 | 60 | ||
60 | #include "buffer_head_io.h" | 61 | #include "buffer_head_io.h" |
61 | 62 | ||
@@ -1035,7 +1036,7 @@ int ocfs2_permission(struct inode *inode, int mask) | |||
1035 | goto out; | 1036 | goto out; |
1036 | } | 1037 | } |
1037 | 1038 | ||
1038 | ret = generic_permission(inode, mask, NULL); | 1039 | ret = generic_permission(inode, mask, ocfs2_check_acl); |
1039 | 1040 | ||
1040 | ocfs2_inode_unlock(inode, 0); | 1041 | ocfs2_inode_unlock(inode, 0); |
1041 | out: | 1042 | out: |