aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_acl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_acl.c')
-rw-r--r--fs/xfs/xfs_acl.c69
1 files changed, 31 insertions, 38 deletions
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index ebee3a4f703a..b2f639a1416f 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -37,15 +37,15 @@
37#include <linux/capability.h> 37#include <linux/capability.h>
38#include <linux/posix_acl_xattr.h> 38#include <linux/posix_acl_xattr.h>
39 39
40STATIC int xfs_acl_setmode(bhv_vnode_t *, xfs_acl_t *, int *); 40STATIC int xfs_acl_setmode(struct inode *, xfs_acl_t *, int *);
41STATIC void xfs_acl_filter_mode(mode_t, xfs_acl_t *); 41STATIC void xfs_acl_filter_mode(mode_t, xfs_acl_t *);
42STATIC void xfs_acl_get_endian(xfs_acl_t *); 42STATIC void xfs_acl_get_endian(xfs_acl_t *);
43STATIC int xfs_acl_access(uid_t, gid_t, xfs_acl_t *, mode_t, cred_t *); 43STATIC int xfs_acl_access(uid_t, gid_t, xfs_acl_t *, mode_t, cred_t *);
44STATIC int xfs_acl_invalid(xfs_acl_t *); 44STATIC int xfs_acl_invalid(xfs_acl_t *);
45STATIC void xfs_acl_sync_mode(mode_t, xfs_acl_t *); 45STATIC void xfs_acl_sync_mode(mode_t, xfs_acl_t *);
46STATIC void xfs_acl_get_attr(bhv_vnode_t *, xfs_acl_t *, int, int, int *); 46STATIC void xfs_acl_get_attr(struct inode *, xfs_acl_t *, int, int, int *);
47STATIC void xfs_acl_set_attr(bhv_vnode_t *, xfs_acl_t *, int, int *); 47STATIC void xfs_acl_set_attr(struct inode *, xfs_acl_t *, int, int *);
48STATIC int xfs_acl_allow_set(bhv_vnode_t *, int); 48STATIC int xfs_acl_allow_set(struct inode *, int);
49 49
50kmem_zone_t *xfs_acl_zone; 50kmem_zone_t *xfs_acl_zone;
51 51
@@ -55,7 +55,7 @@ kmem_zone_t *xfs_acl_zone;
55 */ 55 */
56int 56int
57xfs_acl_vhasacl_access( 57xfs_acl_vhasacl_access(
58 bhv_vnode_t *vp) 58 struct inode *vp)
59{ 59{
60 int error; 60 int error;
61 61
@@ -68,7 +68,7 @@ xfs_acl_vhasacl_access(
68 */ 68 */
69int 69int
70xfs_acl_vhasacl_default( 70xfs_acl_vhasacl_default(
71 bhv_vnode_t *vp) 71 struct inode *vp)
72{ 72{
73 int error; 73 int error;
74 74
@@ -207,7 +207,7 @@ posix_acl_xfs_to_xattr(
207 207
208int 208int
209xfs_acl_vget( 209xfs_acl_vget(
210 bhv_vnode_t *vp, 210 struct inode *vp,
211 void *acl, 211 void *acl,
212 size_t size, 212 size_t size,
213 int kind) 213 int kind)
@@ -217,7 +217,6 @@ xfs_acl_vget(
217 posix_acl_xattr_header *ext_acl = acl; 217 posix_acl_xattr_header *ext_acl = acl;
218 int flags = 0; 218 int flags = 0;
219 219
220 VN_HOLD(vp);
221 if(size) { 220 if(size) {
222 if (!(_ACL_ALLOC(xfs_acl))) { 221 if (!(_ACL_ALLOC(xfs_acl))) {
223 error = ENOMEM; 222 error = ENOMEM;
@@ -239,11 +238,10 @@ xfs_acl_vget(
239 goto out; 238 goto out;
240 } 239 }
241 if (kind == _ACL_TYPE_ACCESS) 240 if (kind == _ACL_TYPE_ACCESS)
242 xfs_acl_sync_mode(xfs_vtoi(vp)->i_d.di_mode, xfs_acl); 241 xfs_acl_sync_mode(XFS_I(vp)->i_d.di_mode, xfs_acl);
243 error = -posix_acl_xfs_to_xattr(xfs_acl, ext_acl, size); 242 error = -posix_acl_xfs_to_xattr(xfs_acl, ext_acl, size);
244 } 243 }
245out: 244out:
246 VN_RELE(vp);
247 if(xfs_acl) 245 if(xfs_acl)
248 _ACL_FREE(xfs_acl); 246 _ACL_FREE(xfs_acl);
249 return -error; 247 return -error;
@@ -251,28 +249,26 @@ out:
251 249
252int 250int
253xfs_acl_vremove( 251xfs_acl_vremove(
254 bhv_vnode_t *vp, 252 struct inode *vp,
255 int kind) 253 int kind)
256{ 254{
257 int error; 255 int error;
258 256
259 VN_HOLD(vp);
260 error = xfs_acl_allow_set(vp, kind); 257 error = xfs_acl_allow_set(vp, kind);
261 if (!error) { 258 if (!error) {
262 error = xfs_attr_remove(xfs_vtoi(vp), 259 error = xfs_attr_remove(XFS_I(vp),
263 kind == _ACL_TYPE_DEFAULT? 260 kind == _ACL_TYPE_DEFAULT?
264 SGI_ACL_DEFAULT: SGI_ACL_FILE, 261 SGI_ACL_DEFAULT: SGI_ACL_FILE,
265 ATTR_ROOT); 262 ATTR_ROOT);
266 if (error == ENOATTR) 263 if (error == ENOATTR)
267 error = 0; /* 'scool */ 264 error = 0; /* 'scool */
268 } 265 }
269 VN_RELE(vp);
270 return -error; 266 return -error;
271} 267}
272 268
273int 269int
274xfs_acl_vset( 270xfs_acl_vset(
275 bhv_vnode_t *vp, 271 struct inode *vp,
276 void *acl, 272 void *acl,
277 size_t size, 273 size_t size,
278 int kind) 274 int kind)
@@ -298,7 +294,6 @@ xfs_acl_vset(
298 return 0; 294 return 0;
299 } 295 }
300 296
301 VN_HOLD(vp);
302 error = xfs_acl_allow_set(vp, kind); 297 error = xfs_acl_allow_set(vp, kind);
303 298
304 /* Incoming ACL exists, set file mode based on its value */ 299 /* Incoming ACL exists, set file mode based on its value */
@@ -321,7 +316,6 @@ xfs_acl_vset(
321 } 316 }
322 317
323out: 318out:
324 VN_RELE(vp);
325 _ACL_FREE(xfs_acl); 319 _ACL_FREE(xfs_acl);
326 return -error; 320 return -error;
327} 321}
@@ -341,8 +335,7 @@ xfs_acl_iaccess(
341 335
342 /* If the file has no ACL return -1. */ 336 /* If the file has no ACL return -1. */
343 rval = sizeof(xfs_acl_t); 337 rval = sizeof(xfs_acl_t);
344 if (xfs_attr_fetch(ip, &acl_name, (char *)acl, &rval, 338 if (xfs_attr_fetch(ip, &acl_name, (char *)acl, &rval, ATTR_ROOT)) {
345 ATTR_ROOT | ATTR_KERNACCESS)) {
346 _ACL_FREE(acl); 339 _ACL_FREE(acl);
347 return -1; 340 return -1;
348 } 341 }
@@ -364,7 +357,7 @@ xfs_acl_iaccess(
364 357
365STATIC int 358STATIC int
366xfs_acl_allow_set( 359xfs_acl_allow_set(
367 bhv_vnode_t *vp, 360 struct inode *vp,
368 int kind) 361 int kind)
369{ 362{
370 if (vp->i_flags & (S_IMMUTABLE|S_APPEND)) 363 if (vp->i_flags & (S_IMMUTABLE|S_APPEND))
@@ -373,7 +366,7 @@ xfs_acl_allow_set(
373 return ENOTDIR; 366 return ENOTDIR;
374 if (vp->i_sb->s_flags & MS_RDONLY) 367 if (vp->i_sb->s_flags & MS_RDONLY)
375 return EROFS; 368 return EROFS;
376 if (xfs_vtoi(vp)->i_d.di_uid != current->fsuid && !capable(CAP_FOWNER)) 369 if (XFS_I(vp)->i_d.di_uid != current->fsuid && !capable(CAP_FOWNER))
377 return EPERM; 370 return EPERM;
378 return 0; 371 return 0;
379} 372}
@@ -567,7 +560,7 @@ xfs_acl_get_endian(
567 */ 560 */
568STATIC void 561STATIC void
569xfs_acl_get_attr( 562xfs_acl_get_attr(
570 bhv_vnode_t *vp, 563 struct inode *vp,
571 xfs_acl_t *aclp, 564 xfs_acl_t *aclp,
572 int kind, 565 int kind,
573 int flags, 566 int flags,
@@ -577,7 +570,7 @@ xfs_acl_get_attr(
577 570
578 ASSERT((flags & ATTR_KERNOVAL) ? (aclp == NULL) : 1); 571 ASSERT((flags & ATTR_KERNOVAL) ? (aclp == NULL) : 1);
579 flags |= ATTR_ROOT; 572 flags |= ATTR_ROOT;
580 *error = xfs_attr_get(xfs_vtoi(vp), 573 *error = xfs_attr_get(XFS_I(vp),
581 kind == _ACL_TYPE_ACCESS ? 574 kind == _ACL_TYPE_ACCESS ?
582 SGI_ACL_FILE : SGI_ACL_DEFAULT, 575 SGI_ACL_FILE : SGI_ACL_DEFAULT,
583 (char *)aclp, &len, flags); 576 (char *)aclp, &len, flags);
@@ -591,7 +584,7 @@ xfs_acl_get_attr(
591 */ 584 */
592STATIC void 585STATIC void
593xfs_acl_set_attr( 586xfs_acl_set_attr(
594 bhv_vnode_t *vp, 587 struct inode *vp,
595 xfs_acl_t *aclp, 588 xfs_acl_t *aclp,
596 int kind, 589 int kind,
597 int *error) 590 int *error)
@@ -616,7 +609,7 @@ xfs_acl_set_attr(
616 INT_SET(newace->ae_perm, ARCH_CONVERT, ace->ae_perm); 609 INT_SET(newace->ae_perm, ARCH_CONVERT, ace->ae_perm);
617 } 610 }
618 INT_SET(newacl->acl_cnt, ARCH_CONVERT, aclp->acl_cnt); 611 INT_SET(newacl->acl_cnt, ARCH_CONVERT, aclp->acl_cnt);
619 *error = xfs_attr_set(xfs_vtoi(vp), 612 *error = xfs_attr_set(XFS_I(vp),
620 kind == _ACL_TYPE_ACCESS ? 613 kind == _ACL_TYPE_ACCESS ?
621 SGI_ACL_FILE: SGI_ACL_DEFAULT, 614 SGI_ACL_FILE: SGI_ACL_DEFAULT,
622 (char *)newacl, len, ATTR_ROOT); 615 (char *)newacl, len, ATTR_ROOT);
@@ -625,7 +618,7 @@ xfs_acl_set_attr(
625 618
626int 619int
627xfs_acl_vtoacl( 620xfs_acl_vtoacl(
628 bhv_vnode_t *vp, 621 struct inode *vp,
629 xfs_acl_t *access_acl, 622 xfs_acl_t *access_acl,
630 xfs_acl_t *default_acl) 623 xfs_acl_t *default_acl)
631{ 624{
@@ -640,7 +633,7 @@ xfs_acl_vtoacl(
640 if (error) 633 if (error)
641 access_acl->acl_cnt = XFS_ACL_NOT_PRESENT; 634 access_acl->acl_cnt = XFS_ACL_NOT_PRESENT;
642 else /* We have a good ACL and the file mode, synchronize. */ 635 else /* We have a good ACL and the file mode, synchronize. */
643 xfs_acl_sync_mode(xfs_vtoi(vp)->i_d.di_mode, access_acl); 636 xfs_acl_sync_mode(XFS_I(vp)->i_d.di_mode, access_acl);
644 } 637 }
645 638
646 if (default_acl) { 639 if (default_acl) {
@@ -657,7 +650,7 @@ xfs_acl_vtoacl(
657 */ 650 */
658int 651int
659xfs_acl_inherit( 652xfs_acl_inherit(
660 bhv_vnode_t *vp, 653 struct inode *vp,
661 mode_t mode, 654 mode_t mode,
662 xfs_acl_t *pdaclp) 655 xfs_acl_t *pdaclp)
663{ 656{
@@ -716,11 +709,11 @@ out_error:
716 */ 709 */
717STATIC int 710STATIC int
718xfs_acl_setmode( 711xfs_acl_setmode(
719 bhv_vnode_t *vp, 712 struct inode *vp,
720 xfs_acl_t *acl, 713 xfs_acl_t *acl,
721 int *basicperms) 714 int *basicperms)
722{ 715{
723 bhv_vattr_t va; 716 struct iattr iattr;
724 xfs_acl_entry_t *ap; 717 xfs_acl_entry_t *ap;
725 xfs_acl_entry_t *gap = NULL; 718 xfs_acl_entry_t *gap = NULL;
726 int i, nomask = 1; 719 int i, nomask = 1;
@@ -734,25 +727,25 @@ xfs_acl_setmode(
734 * Copy the u::, g::, o::, and m:: bits from the ACL into the 727 * Copy the u::, g::, o::, and m:: bits from the ACL into the
735 * mode. The m:: bits take precedence over the g:: bits. 728 * mode. The m:: bits take precedence over the g:: bits.
736 */ 729 */
737 va.va_mask = XFS_AT_MODE; 730 iattr.ia_valid = ATTR_MODE;
738 va.va_mode = xfs_vtoi(vp)->i_d.di_mode; 731 iattr.ia_mode = XFS_I(vp)->i_d.di_mode;
739 va.va_mode &= ~(S_IRWXU|S_IRWXG|S_IRWXO); 732 iattr.ia_mode &= ~(S_IRWXU|S_IRWXG|S_IRWXO);
740 ap = acl->acl_entry; 733 ap = acl->acl_entry;
741 for (i = 0; i < acl->acl_cnt; ++i) { 734 for (i = 0; i < acl->acl_cnt; ++i) {
742 switch (ap->ae_tag) { 735 switch (ap->ae_tag) {
743 case ACL_USER_OBJ: 736 case ACL_USER_OBJ:
744 va.va_mode |= ap->ae_perm << 6; 737 iattr.ia_mode |= ap->ae_perm << 6;
745 break; 738 break;
746 case ACL_GROUP_OBJ: 739 case ACL_GROUP_OBJ:
747 gap = ap; 740 gap = ap;
748 break; 741 break;
749 case ACL_MASK: /* more than just standard modes */ 742 case ACL_MASK: /* more than just standard modes */
750 nomask = 0; 743 nomask = 0;
751 va.va_mode |= ap->ae_perm << 3; 744 iattr.ia_mode |= ap->ae_perm << 3;
752 *basicperms = 0; 745 *basicperms = 0;
753 break; 746 break;
754 case ACL_OTHER: 747 case ACL_OTHER:
755 va.va_mode |= ap->ae_perm; 748 iattr.ia_mode |= ap->ae_perm;
756 break; 749 break;
757 default: /* more than just standard modes */ 750 default: /* more than just standard modes */
758 *basicperms = 0; 751 *basicperms = 0;
@@ -763,9 +756,9 @@ xfs_acl_setmode(
763 756
764 /* Set the group bits from ACL_GROUP_OBJ if there's no ACL_MASK */ 757 /* Set the group bits from ACL_GROUP_OBJ if there's no ACL_MASK */
765 if (gap && nomask) 758 if (gap && nomask)
766 va.va_mode |= gap->ae_perm << 3; 759 iattr.ia_mode |= gap->ae_perm << 3;
767 760
768 return xfs_setattr(xfs_vtoi(vp), &va, 0, sys_cred); 761 return xfs_setattr(XFS_I(vp), &iattr, 0, sys_cred);
769} 762}
770 763
771/* 764/*