diff options
Diffstat (limited to 'fs/jffs2/acl.c')
-rw-r--r-- | fs/jffs2/acl.c | 49 |
1 files changed, 11 insertions, 38 deletions
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index 3675b3cdee89..27c511a1cf05 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c | |||
@@ -156,7 +156,7 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size) | |||
156 | return ERR_PTR(-EINVAL); | 156 | return ERR_PTR(-EINVAL); |
157 | } | 157 | } |
158 | 158 | ||
159 | static struct posix_acl *jffs2_get_acl(struct inode *inode, int type) | 159 | struct posix_acl *jffs2_get_acl(struct inode *inode, int type) |
160 | { | 160 | { |
161 | struct posix_acl *acl; | 161 | struct posix_acl *acl; |
162 | char *value = NULL; | 162 | char *value = NULL; |
@@ -259,30 +259,11 @@ static int jffs2_set_acl(struct inode *inode, int type, struct posix_acl *acl) | |||
259 | return rc; | 259 | return rc; |
260 | } | 260 | } |
261 | 261 | ||
262 | int jffs2_check_acl(struct inode *inode, int mask) | 262 | int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, mode_t *i_mode) |
263 | { | 263 | { |
264 | struct posix_acl *acl; | 264 | struct posix_acl *acl; |
265 | int rc; | 265 | int rc; |
266 | 266 | ||
267 | if (mask & MAY_NOT_BLOCK) | ||
268 | return -ECHILD; | ||
269 | |||
270 | acl = jffs2_get_acl(inode, ACL_TYPE_ACCESS); | ||
271 | if (IS_ERR(acl)) | ||
272 | return PTR_ERR(acl); | ||
273 | if (acl) { | ||
274 | rc = posix_acl_permission(inode, acl, mask); | ||
275 | posix_acl_release(acl); | ||
276 | return rc; | ||
277 | } | ||
278 | return -EAGAIN; | ||
279 | } | ||
280 | |||
281 | int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode) | ||
282 | { | ||
283 | struct posix_acl *acl, *clone; | ||
284 | int rc; | ||
285 | |||
286 | cache_no_acl(inode); | 267 | cache_no_acl(inode); |
287 | 268 | ||
288 | if (S_ISLNK(*i_mode)) | 269 | if (S_ISLNK(*i_mode)) |
@@ -298,18 +279,13 @@ int jffs2_init_acl_pre(struct inode *dir_i, struct inode *inode, int *i_mode) | |||
298 | if (S_ISDIR(*i_mode)) | 279 | if (S_ISDIR(*i_mode)) |
299 | set_cached_acl(inode, ACL_TYPE_DEFAULT, acl); | 280 | set_cached_acl(inode, ACL_TYPE_DEFAULT, acl); |
300 | 281 | ||
301 | clone = posix_acl_clone(acl, GFP_KERNEL); | 282 | rc = posix_acl_create(&acl, GFP_KERNEL, i_mode); |
302 | if (!clone) | 283 | if (rc < 0) |
303 | return -ENOMEM; | ||
304 | rc = posix_acl_create_masq(clone, (mode_t *)i_mode); | ||
305 | if (rc < 0) { | ||
306 | posix_acl_release(clone); | ||
307 | return rc; | 284 | return rc; |
308 | } | ||
309 | if (rc > 0) | 285 | if (rc > 0) |
310 | set_cached_acl(inode, ACL_TYPE_ACCESS, clone); | 286 | set_cached_acl(inode, ACL_TYPE_ACCESS, acl); |
311 | 287 | ||
312 | posix_acl_release(clone); | 288 | posix_acl_release(acl); |
313 | } | 289 | } |
314 | return 0; | 290 | return 0; |
315 | } | 291 | } |
@@ -335,7 +311,7 @@ int jffs2_init_acl_post(struct inode *inode) | |||
335 | 311 | ||
336 | int jffs2_acl_chmod(struct inode *inode) | 312 | int jffs2_acl_chmod(struct inode *inode) |
337 | { | 313 | { |
338 | struct posix_acl *acl, *clone; | 314 | struct posix_acl *acl; |
339 | int rc; | 315 | int rc; |
340 | 316 | ||
341 | if (S_ISLNK(inode->i_mode)) | 317 | if (S_ISLNK(inode->i_mode)) |
@@ -343,14 +319,11 @@ int jffs2_acl_chmod(struct inode *inode) | |||
343 | acl = jffs2_get_acl(inode, ACL_TYPE_ACCESS); | 319 | acl = jffs2_get_acl(inode, ACL_TYPE_ACCESS); |
344 | if (IS_ERR(acl) || !acl) | 320 | if (IS_ERR(acl) || !acl) |
345 | return PTR_ERR(acl); | 321 | return PTR_ERR(acl); |
346 | clone = posix_acl_clone(acl, GFP_KERNEL); | 322 | rc = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); |
323 | if (rc) | ||
324 | return rc; | ||
325 | rc = jffs2_set_acl(inode, ACL_TYPE_ACCESS, acl); | ||
347 | posix_acl_release(acl); | 326 | posix_acl_release(acl); |
348 | if (!clone) | ||
349 | return -ENOMEM; | ||
350 | rc = posix_acl_chmod_masq(clone, inode->i_mode); | ||
351 | if (!rc) | ||
352 | rc = jffs2_set_acl(inode, ACL_TYPE_ACCESS, clone); | ||
353 | posix_acl_release(clone); | ||
354 | return rc; | 327 | return rc; |
355 | } | 328 | } |
356 | 329 | ||