diff options
-rw-r--r-- | fs/ocfs2/acl.c | 27 | ||||
-rw-r--r-- | fs/ocfs2/acl.h | 5 | ||||
-rw-r--r-- | fs/ocfs2/file.c | 6 |
3 files changed, 38 insertions, 0 deletions
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c index a6a2bf6d6845..df72256c4422 100644 --- a/fs/ocfs2/acl.c +++ b/fs/ocfs2/acl.c | |||
@@ -245,6 +245,33 @@ int ocfs2_check_acl(struct inode *inode, int mask) | |||
245 | return -EAGAIN; | 245 | return -EAGAIN; |
246 | } | 246 | } |
247 | 247 | ||
248 | int ocfs2_acl_chmod(struct inode *inode) | ||
249 | { | ||
250 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
251 | struct posix_acl *acl, *clone; | ||
252 | int ret; | ||
253 | |||
254 | if (S_ISLNK(inode->i_mode)) | ||
255 | return -EOPNOTSUPP; | ||
256 | |||
257 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | ||
258 | return 0; | ||
259 | |||
260 | acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS); | ||
261 | if (IS_ERR(acl) || !acl) | ||
262 | return PTR_ERR(acl); | ||
263 | clone = posix_acl_clone(acl, GFP_KERNEL); | ||
264 | posix_acl_release(acl); | ||
265 | if (!clone) | ||
266 | return -ENOMEM; | ||
267 | ret = posix_acl_chmod_masq(clone, inode->i_mode); | ||
268 | if (!ret) | ||
269 | ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS, | ||
270 | clone, NULL, NULL); | ||
271 | posix_acl_release(clone); | ||
272 | return ret; | ||
273 | } | ||
274 | |||
248 | static size_t ocfs2_xattr_list_acl_access(struct inode *inode, | 275 | static size_t ocfs2_xattr_list_acl_access(struct inode *inode, |
249 | char *list, | 276 | char *list, |
250 | size_t list_len, | 277 | size_t list_len, |
diff --git a/fs/ocfs2/acl.h b/fs/ocfs2/acl.h index fef10f1b782b..68ffd6436c50 100644 --- a/fs/ocfs2/acl.h +++ b/fs/ocfs2/acl.h | |||
@@ -29,10 +29,15 @@ struct ocfs2_acl_entry { | |||
29 | #ifdef CONFIG_OCFS2_FS_POSIX_ACL | 29 | #ifdef CONFIG_OCFS2_FS_POSIX_ACL |
30 | 30 | ||
31 | extern int ocfs2_check_acl(struct inode *, int); | 31 | extern int ocfs2_check_acl(struct inode *, int); |
32 | extern int ocfs2_acl_chmod(struct inode *); | ||
32 | 33 | ||
33 | #else /* CONFIG_OCFS2_FS_POSIX_ACL*/ | 34 | #else /* CONFIG_OCFS2_FS_POSIX_ACL*/ |
34 | 35 | ||
35 | #define ocfs2_check_acl NULL | 36 | #define ocfs2_check_acl NULL |
37 | static inline int ocfs2_acl_chmod(struct inode *inode) | ||
38 | { | ||
39 | return 0; | ||
40 | } | ||
36 | 41 | ||
37 | #endif /* CONFIG_OCFS2_FS_POSIX_ACL*/ | 42 | #endif /* CONFIG_OCFS2_FS_POSIX_ACL*/ |
38 | 43 | ||
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 7bad7d9b9a2c..4636aa6b0117 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -990,6 +990,12 @@ bail_unlock_rw: | |||
990 | bail: | 990 | bail: |
991 | brelse(bh); | 991 | brelse(bh); |
992 | 992 | ||
993 | if (!status && attr->ia_valid & ATTR_MODE) { | ||
994 | status = ocfs2_acl_chmod(inode); | ||
995 | if (status < 0) | ||
996 | mlog_errno(status); | ||
997 | } | ||
998 | |||
993 | mlog_exit(status); | 999 | mlog_exit(status); |
994 | return status; | 1000 | return status; |
995 | } | 1001 | } |