]>
Commit | Line | Data |
---|---|---|
00e5a55c BS |
1 | From: Tiger Yang <tiger.yang@oracle.com> |
2 | Date: Fri, 14 Nov 2008 11:17:18 +0800 | |
3 | Subject: ocfs2: add ocfs2_check_acl | |
4 | Patch-mainline: 2.6.29 | |
5 | ||
6 | This function is used to enhance permission checking with POSIX ACLs. | |
7 | ||
8 | Signed-off-by: Tiger Yang <tiger.yang@oracle.com> | |
9 | Signed-off-by: Mark Fasheh <mfasheh@suse.com> | |
10 | --- | |
11 | fs/ocfs2/acl.c | 15 +++++++++++++++ | |
12 | fs/ocfs2/acl.h | 10 ++++++++++ | |
13 | fs/ocfs2/file.c | 3 ++- | |
14 | 3 files changed, 27 insertions(+), 1 deletions(-) | |
15 | ||
16 | diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c | |
17 | index 62d0faa..a6a2bf6 100644 | |
18 | --- a/fs/ocfs2/acl.c | |
19 | +++ b/fs/ocfs2/acl.c | |
20 | @@ -230,6 +230,21 @@ static int ocfs2_set_acl(handle_t *handle, | |
21 | return ret; | |
22 | } | |
23 | ||
24 | +int ocfs2_check_acl(struct inode *inode, int mask) | |
25 | +{ | |
26 | + struct posix_acl *acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS); | |
27 | + | |
28 | + if (IS_ERR(acl)) | |
29 | + return PTR_ERR(acl); | |
30 | + if (acl) { | |
31 | + int ret = posix_acl_permission(inode, acl, mask); | |
32 | + posix_acl_release(acl); | |
33 | + return ret; | |
34 | + } | |
35 | + | |
36 | + return -EAGAIN; | |
37 | +} | |
38 | + | |
39 | static size_t ocfs2_xattr_list_acl_access(struct inode *inode, | |
40 | char *list, | |
41 | size_t list_len, | |
42 | diff --git a/fs/ocfs2/acl.h b/fs/ocfs2/acl.h | |
43 | index 1b39f3e..fef10f1 100644 | |
44 | --- a/fs/ocfs2/acl.h | |
45 | +++ b/fs/ocfs2/acl.h | |
46 | @@ -26,4 +26,14 @@ struct ocfs2_acl_entry { | |
47 | __le32 e_id; | |
48 | }; | |
49 | ||
50 | +#ifdef CONFIG_OCFS2_FS_POSIX_ACL | |
51 | + | |
52 | +extern int ocfs2_check_acl(struct inode *, int); | |
53 | + | |
54 | +#else /* CONFIG_OCFS2_FS_POSIX_ACL*/ | |
55 | + | |
56 | +#define ocfs2_check_acl NULL | |
57 | + | |
58 | +#endif /* CONFIG_OCFS2_FS_POSIX_ACL*/ | |
59 | + | |
60 | #endif /* OCFS2_ACL_H */ | |
61 | diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c | |
62 | index 3605491..7bad7d9 100644 | |
63 | --- a/fs/ocfs2/file.c | |
64 | +++ b/fs/ocfs2/file.c | |
65 | @@ -56,6 +56,7 @@ | |
66 | #include "suballoc.h" | |
67 | #include "super.h" | |
68 | #include "xattr.h" | |
69 | +#include "acl.h" | |
70 | ||
71 | #include "buffer_head_io.h" | |
72 | ||
73 | @@ -1035,7 +1036,7 @@ int ocfs2_permission(struct inode *inode, int mask) | |
74 | goto out; | |
75 | } | |
76 | ||
77 | - ret = generic_permission(inode, mask, NULL); | |
78 | + ret = generic_permission(inode, mask, ocfs2_check_acl); | |
79 | ||
80 | ocfs2_inode_unlock(inode, 0); | |
81 | out: | |
82 | -- | |
83 | 1.5.6 | |
84 |