diff options
Diffstat (limited to 'fs/jfs/acl.c')
-rw-r--r-- | fs/jfs/acl.c | 75 |
1 files changed, 22 insertions, 53 deletions
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c index 8a0a0666d5a6..b3a32caf2b45 100644 --- a/fs/jfs/acl.c +++ b/fs/jfs/acl.c | |||
@@ -27,7 +27,7 @@ | |||
27 | #include "jfs_xattr.h" | 27 | #include "jfs_xattr.h" |
28 | #include "jfs_acl.h" | 28 | #include "jfs_acl.h" |
29 | 29 | ||
30 | static struct posix_acl *jfs_get_acl(struct inode *inode, int type) | 30 | struct posix_acl *jfs_get_acl(struct inode *inode, int type) |
31 | { | 31 | { |
32 | struct posix_acl *acl; | 32 | struct posix_acl *acl; |
33 | char *ea_name; | 33 | char *ea_name; |
@@ -114,30 +114,9 @@ out: | |||
114 | return rc; | 114 | return rc; |
115 | } | 115 | } |
116 | 116 | ||
117 | int jfs_check_acl(struct inode *inode, int mask) | ||
118 | { | ||
119 | struct posix_acl *acl; | ||
120 | |||
121 | if (mask & MAY_NOT_BLOCK) | ||
122 | return -ECHILD; | ||
123 | |||
124 | acl = jfs_get_acl(inode, ACL_TYPE_ACCESS); | ||
125 | if (IS_ERR(acl)) | ||
126 | return PTR_ERR(acl); | ||
127 | if (acl) { | ||
128 | int error = posix_acl_permission(inode, acl, mask); | ||
129 | posix_acl_release(acl); | ||
130 | return error; | ||
131 | } | ||
132 | |||
133 | return -EAGAIN; | ||
134 | } | ||
135 | |||
136 | int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir) | 117 | int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir) |
137 | { | 118 | { |
138 | struct posix_acl *acl = NULL; | 119 | struct posix_acl *acl = NULL; |
139 | struct posix_acl *clone; | ||
140 | mode_t mode; | ||
141 | int rc = 0; | 120 | int rc = 0; |
142 | 121 | ||
143 | if (S_ISLNK(inode->i_mode)) | 122 | if (S_ISLNK(inode->i_mode)) |
@@ -148,25 +127,18 @@ int jfs_init_acl(tid_t tid, struct inode *inode, struct inode *dir) | |||
148 | return PTR_ERR(acl); | 127 | return PTR_ERR(acl); |
149 | 128 | ||
150 | if (acl) { | 129 | if (acl) { |
130 | mode_t mode = inode->i_mode; | ||
151 | if (S_ISDIR(inode->i_mode)) { | 131 | if (S_ISDIR(inode->i_mode)) { |
152 | rc = jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, acl); | 132 | rc = jfs_set_acl(tid, inode, ACL_TYPE_DEFAULT, acl); |
153 | if (rc) | 133 | if (rc) |
154 | goto cleanup; | 134 | goto cleanup; |
155 | } | 135 | } |
156 | clone = posix_acl_clone(acl, GFP_KERNEL); | 136 | rc = posix_acl_create(&acl, GFP_KERNEL, &mode); |
157 | if (!clone) { | 137 | if (rc < 0) |
158 | rc = -ENOMEM; | 138 | goto cleanup; /* posix_acl_release(NULL) is no-op */ |
159 | goto cleanup; | 139 | inode->i_mode = mode; |
160 | } | 140 | if (rc > 0) |
161 | mode = inode->i_mode; | 141 | rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, acl); |
162 | rc = posix_acl_create_masq(clone, &mode); | ||
163 | if (rc >= 0) { | ||
164 | inode->i_mode = mode; | ||
165 | if (rc > 0) | ||
166 | rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, | ||
167 | clone); | ||
168 | } | ||
169 | posix_acl_release(clone); | ||
170 | cleanup: | 142 | cleanup: |
171 | posix_acl_release(acl); | 143 | posix_acl_release(acl); |
172 | } else | 144 | } else |
@@ -180,8 +152,9 @@ cleanup: | |||
180 | 152 | ||
181 | int jfs_acl_chmod(struct inode *inode) | 153 | int jfs_acl_chmod(struct inode *inode) |
182 | { | 154 | { |
183 | struct posix_acl *acl, *clone; | 155 | struct posix_acl *acl; |
184 | int rc; | 156 | int rc; |
157 | tid_t tid; | ||
185 | 158 | ||
186 | if (S_ISLNK(inode->i_mode)) | 159 | if (S_ISLNK(inode->i_mode)) |
187 | return -EOPNOTSUPP; | 160 | return -EOPNOTSUPP; |
@@ -190,22 +163,18 @@ int jfs_acl_chmod(struct inode *inode) | |||
190 | if (IS_ERR(acl) || !acl) | 163 | if (IS_ERR(acl) || !acl) |
191 | return PTR_ERR(acl); | 164 | return PTR_ERR(acl); |
192 | 165 | ||
193 | clone = posix_acl_clone(acl, GFP_KERNEL); | 166 | rc = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); |
194 | posix_acl_release(acl); | 167 | if (rc) |
195 | if (!clone) | 168 | return rc; |
196 | return -ENOMEM; | ||
197 | |||
198 | rc = posix_acl_chmod_masq(clone, inode->i_mode); | ||
199 | if (!rc) { | ||
200 | tid_t tid = txBegin(inode->i_sb, 0); | ||
201 | mutex_lock(&JFS_IP(inode)->commit_mutex); | ||
202 | rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, clone); | ||
203 | if (!rc) | ||
204 | rc = txCommit(tid, 1, &inode, 0); | ||
205 | txEnd(tid); | ||
206 | mutex_unlock(&JFS_IP(inode)->commit_mutex); | ||
207 | } | ||
208 | 169 | ||
209 | posix_acl_release(clone); | 170 | tid = txBegin(inode->i_sb, 0); |
171 | mutex_lock(&JFS_IP(inode)->commit_mutex); | ||
172 | rc = jfs_set_acl(tid, inode, ACL_TYPE_ACCESS, acl); | ||
173 | if (!rc) | ||
174 | rc = txCommit(tid, 1, &inode, 0); | ||
175 | txEnd(tid); | ||
176 | mutex_unlock(&JFS_IP(inode)->commit_mutex); | ||
177 | |||
178 | posix_acl_release(acl); | ||
210 | return rc; | 179 | return rc; |
211 | } | 180 | } |