diff options
Diffstat (limited to 'fs/ocfs2/acl.c')
-rw-r--r-- | fs/ocfs2/acl.c | 81 |
1 files changed, 28 insertions, 53 deletions
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c index e913ad130fd..a7219075b4d 100644 --- a/fs/ocfs2/acl.c +++ b/fs/ocfs2/acl.c | |||
@@ -247,7 +247,7 @@ static int ocfs2_set_acl(handle_t *handle, | |||
247 | case ACL_TYPE_ACCESS: | 247 | case ACL_TYPE_ACCESS: |
248 | name_index = OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS; | 248 | name_index = OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS; |
249 | if (acl) { | 249 | if (acl) { |
250 | mode_t mode = inode->i_mode; | 250 | umode_t mode = inode->i_mode; |
251 | ret = posix_acl_equiv_mode(acl, &mode); | 251 | ret = posix_acl_equiv_mode(acl, &mode); |
252 | if (ret < 0) | 252 | if (ret < 0) |
253 | return ret; | 253 | return ret; |
@@ -290,47 +290,32 @@ static int ocfs2_set_acl(handle_t *handle, | |||
290 | return ret; | 290 | return ret; |
291 | } | 291 | } |
292 | 292 | ||
293 | int ocfs2_check_acl(struct inode *inode, int mask, unsigned int flags) | 293 | struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type) |
294 | { | 294 | { |
295 | struct ocfs2_super *osb; | 295 | struct ocfs2_super *osb; |
296 | struct buffer_head *di_bh = NULL; | 296 | struct buffer_head *di_bh = NULL; |
297 | struct posix_acl *acl; | 297 | struct posix_acl *acl; |
298 | int ret = -EAGAIN; | 298 | int ret = -EAGAIN; |
299 | 299 | ||
300 | if (flags & IPERM_FLAG_RCU) | ||
301 | return -ECHILD; | ||
302 | |||
303 | osb = OCFS2_SB(inode->i_sb); | 300 | osb = OCFS2_SB(inode->i_sb); |
304 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) | 301 | if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) |
305 | return ret; | 302 | return NULL; |
306 | 303 | ||
307 | ret = ocfs2_read_inode_block(inode, &di_bh); | 304 | ret = ocfs2_read_inode_block(inode, &di_bh); |
308 | if (ret < 0) { | 305 | if (ret < 0) |
309 | mlog_errno(ret); | 306 | return ERR_PTR(ret); |
310 | return ret; | ||
311 | } | ||
312 | 307 | ||
313 | acl = ocfs2_get_acl_nolock(inode, ACL_TYPE_ACCESS, di_bh); | 308 | acl = ocfs2_get_acl_nolock(inode, type, di_bh); |
314 | 309 | ||
315 | brelse(di_bh); | 310 | brelse(di_bh); |
316 | 311 | ||
317 | if (IS_ERR(acl)) { | 312 | return acl; |
318 | mlog_errno(PTR_ERR(acl)); | ||
319 | return PTR_ERR(acl); | ||
320 | } | ||
321 | if (acl) { | ||
322 | ret = posix_acl_permission(inode, acl, mask); | ||
323 | posix_acl_release(acl); | ||
324 | return ret; | ||
325 | } | ||
326 | |||
327 | return -EAGAIN; | ||
328 | } | 313 | } |
329 | 314 | ||
330 | int ocfs2_acl_chmod(struct inode *inode) | 315 | int ocfs2_acl_chmod(struct inode *inode) |
331 | { | 316 | { |
332 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 317 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
333 | struct posix_acl *acl, *clone; | 318 | struct posix_acl *acl; |
334 | int ret; | 319 | int ret; |
335 | 320 | ||
336 | if (S_ISLNK(inode->i_mode)) | 321 | if (S_ISLNK(inode->i_mode)) |
@@ -342,15 +327,12 @@ int ocfs2_acl_chmod(struct inode *inode) | |||
342 | acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS); | 327 | acl = ocfs2_get_acl(inode, ACL_TYPE_ACCESS); |
343 | if (IS_ERR(acl) || !acl) | 328 | if (IS_ERR(acl) || !acl) |
344 | return PTR_ERR(acl); | 329 | return PTR_ERR(acl); |
345 | clone = posix_acl_clone(acl, GFP_KERNEL); | 330 | ret = posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode); |
331 | if (ret) | ||
332 | return ret; | ||
333 | ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS, | ||
334 | acl, NULL, NULL); | ||
346 | posix_acl_release(acl); | 335 | posix_acl_release(acl); |
347 | if (!clone) | ||
348 | return -ENOMEM; | ||
349 | ret = posix_acl_chmod_masq(clone, inode->i_mode); | ||
350 | if (!ret) | ||
351 | ret = ocfs2_set_acl(NULL, inode, NULL, ACL_TYPE_ACCESS, | ||
352 | clone, NULL, NULL); | ||
353 | posix_acl_release(clone); | ||
354 | return ret; | 336 | return ret; |
355 | } | 337 | } |
356 | 338 | ||
@@ -369,7 +351,7 @@ int ocfs2_init_acl(handle_t *handle, | |||
369 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | 351 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); |
370 | struct posix_acl *acl = NULL; | 352 | struct posix_acl *acl = NULL; |
371 | int ret = 0, ret2; | 353 | int ret = 0, ret2; |
372 | mode_t mode; | 354 | umode_t mode; |
373 | 355 | ||
374 | if (!S_ISLNK(inode->i_mode)) { | 356 | if (!S_ISLNK(inode->i_mode)) { |
375 | if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) { | 357 | if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) { |
@@ -388,8 +370,6 @@ int ocfs2_init_acl(handle_t *handle, | |||
388 | } | 370 | } |
389 | } | 371 | } |
390 | if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) { | 372 | if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) { |
391 | struct posix_acl *clone; | ||
392 | |||
393 | if (S_ISDIR(inode->i_mode)) { | 373 | if (S_ISDIR(inode->i_mode)) { |
394 | ret = ocfs2_set_acl(handle, inode, di_bh, | 374 | ret = ocfs2_set_acl(handle, inode, di_bh, |
395 | ACL_TYPE_DEFAULT, acl, | 375 | ACL_TYPE_DEFAULT, acl, |
@@ -397,27 +377,22 @@ int ocfs2_init_acl(handle_t *handle, | |||
397 | if (ret) | 377 | if (ret) |
398 | goto cleanup; | 378 | goto cleanup; |
399 | } | 379 | } |
400 | clone = posix_acl_clone(acl, GFP_NOFS); | ||
401 | ret = -ENOMEM; | ||
402 | if (!clone) | ||
403 | goto cleanup; | ||
404 | |||
405 | mode = inode->i_mode; | 380 | mode = inode->i_mode; |
406 | ret = posix_acl_create_masq(clone, &mode); | 381 | ret = posix_acl_create(&acl, GFP_NOFS, &mode); |
407 | if (ret >= 0) { | 382 | if (ret < 0) |
408 | ret2 = ocfs2_acl_set_mode(inode, di_bh, handle, mode); | 383 | return ret; |
409 | if (ret2) { | 384 | |
410 | mlog_errno(ret2); | 385 | ret2 = ocfs2_acl_set_mode(inode, di_bh, handle, mode); |
411 | ret = ret2; | 386 | if (ret2) { |
412 | goto cleanup; | 387 | mlog_errno(ret2); |
413 | } | 388 | ret = ret2; |
414 | if (ret > 0) { | 389 | goto cleanup; |
415 | ret = ocfs2_set_acl(handle, inode, | 390 | } |
416 | di_bh, ACL_TYPE_ACCESS, | 391 | if (ret > 0) { |
417 | clone, meta_ac, data_ac); | 392 | ret = ocfs2_set_acl(handle, inode, |
418 | } | 393 | di_bh, ACL_TYPE_ACCESS, |
394 | acl, meta_ac, data_ac); | ||
419 | } | 395 | } |
420 | posix_acl_release(clone); | ||
421 | } | 396 | } |
422 | cleanup: | 397 | cleanup: |
423 | posix_acl_release(acl); | 398 | posix_acl_release(acl); |