]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/suse-2.6.27.25/patches.suse/ocfs2-add-ocfs2_acl_chmod.patch
Updated xen patches taken from suse.
[people/teissler/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.suse / ocfs2-add-ocfs2_acl_chmod.patch
1 From: Tiger Yang <tiger.yang@oracle.com>
2 Date: Fri, 14 Nov 2008 11:17:29 +0800
3 Subject: ocfs2: add ocfs2_acl_chmod
4 Patch-mainline: 2.6.29
5
6 This function is used to update acl xattrs during file mode changes.
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 | 27 +++++++++++++++++++++++++++
12 fs/ocfs2/acl.h | 5 +++++
13 fs/ocfs2/file.c | 6 ++++++
14 3 files changed, 38 insertions(+), 0 deletions(-)
15
16 diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
17 index a6a2bf6..df72256 100644
18 --- a/fs/ocfs2/acl.c
19 +++ b/fs/ocfs2/acl.c
20 @@ -245,6 +245,33 @@ int ocfs2_check_acl(struct inode *inode, int mask)
21 return -EAGAIN;
22 }
23
24 +int ocfs2_acl_chmod(struct inode *inode)
25 +{
26 + struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
27 + struct posix_acl *acl, *clone;
28 + int ret;
29 +
30 + if (S_ISLNK(inode->i_mode))
31 + return -EOPNOTSUPP;
32 +
33 + if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
34 + return 0;
35 +
36 + acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS);
37 + if (IS_ERR(acl) || !acl)
38 + return PTR_ERR(acl);
39 + clone = posix_acl_clone(acl, GFP_KERNEL);
40 + posix_acl_release(acl);
41 + if (!clone)
42 + return -ENOMEM;
43 + ret = posix_acl_chmod_masq(clone, inode->i_mode);
44 + if (!ret)
45 + ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS,
46 + clone, NULL, NULL);
47 + posix_acl_release(clone);
48 + return ret;
49 +}
50 +
51 static size_t ocfs2_xattr_list_acl_access(struct inode *inode,
52 char *list,
53 size_t list_len,
54 diff --git a/fs/ocfs2/acl.h b/fs/ocfs2/acl.h
55 index fef10f1..68ffd64 100644
56 --- a/fs/ocfs2/acl.h
57 +++ b/fs/ocfs2/acl.h
58 @@ -29,10 +29,15 @@ struct ocfs2_acl_entry {
59 #ifdef CONFIG_OCFS2_FS_POSIX_ACL
60
61 extern int ocfs2_check_acl(struct inode *, int);
62 +extern int ocfs2_acl_chmod(struct inode *);
63
64 #else /* CONFIG_OCFS2_FS_POSIX_ACL*/
65
66 #define ocfs2_check_acl NULL
67 +static inline int ocfs2_acl_chmod(struct inode *inode)
68 +{
69 + return 0;
70 +}
71
72 #endif /* CONFIG_OCFS2_FS_POSIX_ACL*/
73
74 diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
75 index 7bad7d9..4636aa6 100644
76 --- a/fs/ocfs2/file.c
77 +++ b/fs/ocfs2/file.c
78 @@ -990,6 +990,12 @@ bail_unlock_rw:
79 bail:
80 brelse(bh);
81
82 + if (!status && attr->ia_valid & ATTR_MODE) {
83 + status = ocfs2_acl_chmod(inode);
84 + if (status < 0)
85 + mlog_errno(status);
86 + }
87 +
88 mlog_exit(status);
89 return status;
90 }
91 --
92 1.5.6
93