aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/acl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/acl.c')
-rw-r--r--fs/ocfs2/acl.c91
1 files changed, 25 insertions, 66 deletions
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
index fbeaec76210..0501974bedd 100644
--- a/fs/ocfs2/acl.c
+++ b/fs/ocfs2/acl.c
@@ -98,15 +98,11 @@ static struct posix_acl *ocfs2_get_acl_nolock(struct inode *inode,
98 int type, 98 int type,
99 struct buffer_head *di_bh) 99 struct buffer_head *di_bh)
100{ 100{
101 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
102 int name_index; 101 int name_index;
103 char *value = NULL; 102 char *value = NULL;
104 struct posix_acl *acl; 103 struct posix_acl *acl;
105 int retval; 104 int retval;
106 105
107 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
108 return NULL;
109
110 switch (type) { 106 switch (type) {
111 case ACL_TYPE_ACCESS: 107 case ACL_TYPE_ACCESS:
112 name_index = OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS; 108 name_index = OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS;
@@ -331,13 +327,14 @@ cleanup:
331 return ret; 327 return ret;
332} 328}
333 329
334static size_t ocfs2_xattr_list_acl_access(struct inode *inode, 330static size_t ocfs2_xattr_list_acl_access(struct dentry *dentry,
335 char *list, 331 char *list,
336 size_t list_len, 332 size_t list_len,
337 const char *name, 333 const char *name,
338 size_t name_len) 334 size_t name_len,
335 int type)
339{ 336{
340 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 337 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
341 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS); 338 const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
342 339
343 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) 340 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
@@ -348,13 +345,14 @@ static size_t ocfs2_xattr_list_acl_access(struct inode *inode,
348 return size; 345 return size;
349} 346}
350 347
351static size_t ocfs2_xattr_list_acl_default(struct inode *inode, 348static size_t ocfs2_xattr_list_acl_default(struct dentry *dentry,
352 char *list, 349 char *list,
353 size_t list_len, 350 size_t list_len,
354 const char *name, 351 const char *name,
355 size_t name_len) 352 size_t name_len,
353 int type)
356{ 354{
357 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 355 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
358 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT); 356 const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
359 357
360 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) 358 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
@@ -365,19 +363,19 @@ static size_t ocfs2_xattr_list_acl_default(struct inode *inode,
365 return size; 363 return size;
366} 364}
367 365
368static int ocfs2_xattr_get_acl(struct inode *inode, 366static int ocfs2_xattr_get_acl(struct dentry *dentry, const char *name,
369 int type, 367 void *buffer, size_t size, int type)
370 void *buffer,
371 size_t size)
372{ 368{
373 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 369 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
374 struct posix_acl *acl; 370 struct posix_acl *acl;
375 int ret; 371 int ret;
376 372
373 if (strcmp(name, "") != 0)
374 return -EINVAL;
377 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) 375 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
378 return -EOPNOTSUPP; 376 return -EOPNOTSUPP;
379 377
380 acl = ocfs2_get_acl(inode, type); 378 acl = ocfs2_get_acl(dentry->d_inode, type);
381 if (IS_ERR(acl)) 379 if (IS_ERR(acl))
382 return PTR_ERR(acl); 380 return PTR_ERR(acl);
383 if (acl == NULL) 381 if (acl == NULL)
@@ -388,35 +386,16 @@ static int ocfs2_xattr_get_acl(struct inode *inode,
388 return ret; 386 return ret;
389} 387}
390 388
391static int ocfs2_xattr_get_acl_access(struct inode *inode, 389static int ocfs2_xattr_set_acl(struct dentry *dentry, const char *name,
392 const char *name, 390 const void *value, size_t size, int flags, int type)
393 void *buffer,
394 size_t size)
395{
396 if (strcmp(name, "") != 0)
397 return -EINVAL;
398 return ocfs2_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
399}
400
401static int ocfs2_xattr_get_acl_default(struct inode *inode,
402 const char *name,
403 void *buffer,
404 size_t size)
405{
406 if (strcmp(name, "") != 0)
407 return -EINVAL;
408 return ocfs2_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
409}
410
411static int ocfs2_xattr_set_acl(struct inode *inode,
412 int type,
413 const void *value,
414 size_t size)
415{ 391{
392 struct inode *inode = dentry->d_inode;
416 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); 393 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
417 struct posix_acl *acl; 394 struct posix_acl *acl;
418 int ret = 0; 395 int ret = 0;
419 396
397 if (strcmp(name, "") != 0)
398 return -EINVAL;
420 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL)) 399 if (!(osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL))
421 return -EOPNOTSUPP; 400 return -EOPNOTSUPP;
422 401
@@ -442,38 +421,18 @@ cleanup:
442 return ret; 421 return ret;
443} 422}
444 423
445static int ocfs2_xattr_set_acl_access(struct inode *inode,
446 const char *name,
447 const void *value,
448 size_t size,
449 int flags)
450{
451 if (strcmp(name, "") != 0)
452 return -EINVAL;
453 return ocfs2_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
454}
455
456static int ocfs2_xattr_set_acl_default(struct inode *inode,
457 const char *name,
458 const void *value,
459 size_t size,
460 int flags)
461{
462 if (strcmp(name, "") != 0)
463 return -EINVAL;
464 return ocfs2_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
465}
466
467struct xattr_handler ocfs2_xattr_acl_access_handler = { 424struct xattr_handler ocfs2_xattr_acl_access_handler = {
468 .prefix = POSIX_ACL_XATTR_ACCESS, 425 .prefix = POSIX_ACL_XATTR_ACCESS,
426 .flags = ACL_TYPE_ACCESS,
469 .list = ocfs2_xattr_list_acl_access, 427 .list = ocfs2_xattr_list_acl_access,
470 .get = ocfs2_xattr_get_acl_access, 428 .get = ocfs2_xattr_get_acl,
471 .set = ocfs2_xattr_set_acl_access, 429 .set = ocfs2_xattr_set_acl,
472}; 430};
473 431
474struct xattr_handler ocfs2_xattr_acl_default_handler = { 432struct xattr_handler ocfs2_xattr_acl_default_handler = {
475 .prefix = POSIX_ACL_XATTR_DEFAULT, 433 .prefix = POSIX_ACL_XATTR_DEFAULT,
434 .flags = ACL_TYPE_DEFAULT,
476 .list = ocfs2_xattr_list_acl_default, 435 .list = ocfs2_xattr_list_acl_default,
477 .get = ocfs2_xattr_get_acl_default, 436 .get = ocfs2_xattr_get_acl,
478 .set = ocfs2_xattr_set_acl_default, 437 .set = ocfs2_xattr_set_acl,
479}; 438};