diff options
Diffstat (limited to 'fs/xfs/xfs_acl.c')
-rw-r--r-- | fs/xfs/xfs_acl.c | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c index 3e4648ad9cfc..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 | ||
40 | STATIC int xfs_acl_setmode(bhv_vnode_t *, xfs_acl_t *, int *); | 40 | STATIC int xfs_acl_setmode(struct inode *, xfs_acl_t *, int *); |
41 | STATIC void xfs_acl_filter_mode(mode_t, xfs_acl_t *); | 41 | STATIC void xfs_acl_filter_mode(mode_t, xfs_acl_t *); |
42 | STATIC void xfs_acl_get_endian(xfs_acl_t *); | 42 | STATIC void xfs_acl_get_endian(xfs_acl_t *); |
43 | STATIC int xfs_acl_access(uid_t, gid_t, xfs_acl_t *, mode_t, cred_t *); | 43 | STATIC int xfs_acl_access(uid_t, gid_t, xfs_acl_t *, mode_t, cred_t *); |
44 | STATIC int xfs_acl_invalid(xfs_acl_t *); | 44 | STATIC int xfs_acl_invalid(xfs_acl_t *); |
45 | STATIC void xfs_acl_sync_mode(mode_t, xfs_acl_t *); | 45 | STATIC void xfs_acl_sync_mode(mode_t, xfs_acl_t *); |
46 | STATIC void xfs_acl_get_attr(bhv_vnode_t *, xfs_acl_t *, int, int, int *); | 46 | STATIC void xfs_acl_get_attr(struct inode *, xfs_acl_t *, int, int, int *); |
47 | STATIC void xfs_acl_set_attr(bhv_vnode_t *, xfs_acl_t *, int, int *); | 47 | STATIC void xfs_acl_set_attr(struct inode *, xfs_acl_t *, int, int *); |
48 | STATIC int xfs_acl_allow_set(bhv_vnode_t *, int); | 48 | STATIC int xfs_acl_allow_set(struct inode *, int); |
49 | 49 | ||
50 | kmem_zone_t *xfs_acl_zone; | 50 | kmem_zone_t *xfs_acl_zone; |
51 | 51 | ||
@@ -55,7 +55,7 @@ kmem_zone_t *xfs_acl_zone; | |||
55 | */ | 55 | */ |
56 | int | 56 | int |
57 | xfs_acl_vhasacl_access( | 57 | xfs_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 | */ |
69 | int | 69 | int |
70 | xfs_acl_vhasacl_default( | 70 | xfs_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 | ||
208 | int | 208 | int |
209 | xfs_acl_vget( | 209 | xfs_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 | } |
245 | out: | 244 | out: |
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 | ||
252 | int | 250 | int |
253 | xfs_acl_vremove( | 251 | xfs_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 | ||
273 | int | 269 | int |
274 | xfs_acl_vset( | 270 | xfs_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 | ||
323 | out: | 318 | out: |
324 | VN_RELE(vp); | ||
325 | _ACL_FREE(xfs_acl); | 319 | _ACL_FREE(xfs_acl); |
326 | return -error; | 320 | return -error; |
327 | } | 321 | } |
@@ -363,7 +357,7 @@ xfs_acl_iaccess( | |||
363 | 357 | ||
364 | STATIC int | 358 | STATIC int |
365 | xfs_acl_allow_set( | 359 | xfs_acl_allow_set( |
366 | bhv_vnode_t *vp, | 360 | struct inode *vp, |
367 | int kind) | 361 | int kind) |
368 | { | 362 | { |
369 | if (vp->i_flags & (S_IMMUTABLE|S_APPEND)) | 363 | if (vp->i_flags & (S_IMMUTABLE|S_APPEND)) |
@@ -372,7 +366,7 @@ xfs_acl_allow_set( | |||
372 | return ENOTDIR; | 366 | return ENOTDIR; |
373 | if (vp->i_sb->s_flags & MS_RDONLY) | 367 | if (vp->i_sb->s_flags & MS_RDONLY) |
374 | return EROFS; | 368 | return EROFS; |
375 | 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)) |
376 | return EPERM; | 370 | return EPERM; |
377 | return 0; | 371 | return 0; |
378 | } | 372 | } |
@@ -566,7 +560,7 @@ xfs_acl_get_endian( | |||
566 | */ | 560 | */ |
567 | STATIC void | 561 | STATIC void |
568 | xfs_acl_get_attr( | 562 | xfs_acl_get_attr( |
569 | bhv_vnode_t *vp, | 563 | struct inode *vp, |
570 | xfs_acl_t *aclp, | 564 | xfs_acl_t *aclp, |
571 | int kind, | 565 | int kind, |
572 | int flags, | 566 | int flags, |
@@ -576,7 +570,7 @@ xfs_acl_get_attr( | |||
576 | 570 | ||
577 | ASSERT((flags & ATTR_KERNOVAL) ? (aclp == NULL) : 1); | 571 | ASSERT((flags & ATTR_KERNOVAL) ? (aclp == NULL) : 1); |
578 | flags |= ATTR_ROOT; | 572 | flags |= ATTR_ROOT; |
579 | *error = xfs_attr_get(xfs_vtoi(vp), | 573 | *error = xfs_attr_get(XFS_I(vp), |
580 | kind == _ACL_TYPE_ACCESS ? | 574 | kind == _ACL_TYPE_ACCESS ? |
581 | SGI_ACL_FILE : SGI_ACL_DEFAULT, | 575 | SGI_ACL_FILE : SGI_ACL_DEFAULT, |
582 | (char *)aclp, &len, flags); | 576 | (char *)aclp, &len, flags); |
@@ -590,7 +584,7 @@ xfs_acl_get_attr( | |||
590 | */ | 584 | */ |
591 | STATIC void | 585 | STATIC void |
592 | xfs_acl_set_attr( | 586 | xfs_acl_set_attr( |
593 | bhv_vnode_t *vp, | 587 | struct inode *vp, |
594 | xfs_acl_t *aclp, | 588 | xfs_acl_t *aclp, |
595 | int kind, | 589 | int kind, |
596 | int *error) | 590 | int *error) |
@@ -615,7 +609,7 @@ xfs_acl_set_attr( | |||
615 | INT_SET(newace->ae_perm, ARCH_CONVERT, ace->ae_perm); | 609 | INT_SET(newace->ae_perm, ARCH_CONVERT, ace->ae_perm); |
616 | } | 610 | } |
617 | INT_SET(newacl->acl_cnt, ARCH_CONVERT, aclp->acl_cnt); | 611 | INT_SET(newacl->acl_cnt, ARCH_CONVERT, aclp->acl_cnt); |
618 | *error = xfs_attr_set(xfs_vtoi(vp), | 612 | *error = xfs_attr_set(XFS_I(vp), |
619 | kind == _ACL_TYPE_ACCESS ? | 613 | kind == _ACL_TYPE_ACCESS ? |
620 | SGI_ACL_FILE: SGI_ACL_DEFAULT, | 614 | SGI_ACL_FILE: SGI_ACL_DEFAULT, |
621 | (char *)newacl, len, ATTR_ROOT); | 615 | (char *)newacl, len, ATTR_ROOT); |
@@ -624,7 +618,7 @@ xfs_acl_set_attr( | |||
624 | 618 | ||
625 | int | 619 | int |
626 | xfs_acl_vtoacl( | 620 | xfs_acl_vtoacl( |
627 | bhv_vnode_t *vp, | 621 | struct inode *vp, |
628 | xfs_acl_t *access_acl, | 622 | xfs_acl_t *access_acl, |
629 | xfs_acl_t *default_acl) | 623 | xfs_acl_t *default_acl) |
630 | { | 624 | { |
@@ -639,7 +633,7 @@ xfs_acl_vtoacl( | |||
639 | if (error) | 633 | if (error) |
640 | access_acl->acl_cnt = XFS_ACL_NOT_PRESENT; | 634 | access_acl->acl_cnt = XFS_ACL_NOT_PRESENT; |
641 | else /* We have a good ACL and the file mode, synchronize. */ | 635 | else /* We have a good ACL and the file mode, synchronize. */ |
642 | 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); |
643 | } | 637 | } |
644 | 638 | ||
645 | if (default_acl) { | 639 | if (default_acl) { |
@@ -656,7 +650,7 @@ xfs_acl_vtoacl( | |||
656 | */ | 650 | */ |
657 | int | 651 | int |
658 | xfs_acl_inherit( | 652 | xfs_acl_inherit( |
659 | bhv_vnode_t *vp, | 653 | struct inode *vp, |
660 | mode_t mode, | 654 | mode_t mode, |
661 | xfs_acl_t *pdaclp) | 655 | xfs_acl_t *pdaclp) |
662 | { | 656 | { |
@@ -715,7 +709,7 @@ out_error: | |||
715 | */ | 709 | */ |
716 | STATIC int | 710 | STATIC int |
717 | xfs_acl_setmode( | 711 | xfs_acl_setmode( |
718 | bhv_vnode_t *vp, | 712 | struct inode *vp, |
719 | xfs_acl_t *acl, | 713 | xfs_acl_t *acl, |
720 | int *basicperms) | 714 | int *basicperms) |
721 | { | 715 | { |
@@ -734,7 +728,7 @@ xfs_acl_setmode( | |||
734 | * mode. The m:: bits take precedence over the g:: bits. | 728 | * mode. The m:: bits take precedence over the g:: bits. |
735 | */ | 729 | */ |
736 | iattr.ia_valid = ATTR_MODE; | 730 | iattr.ia_valid = ATTR_MODE; |
737 | iattr.ia_mode = xfs_vtoi(vp)->i_d.di_mode; | 731 | iattr.ia_mode = XFS_I(vp)->i_d.di_mode; |
738 | iattr.ia_mode &= ~(S_IRWXU|S_IRWXG|S_IRWXO); | 732 | iattr.ia_mode &= ~(S_IRWXU|S_IRWXG|S_IRWXO); |
739 | ap = acl->acl_entry; | 733 | ap = acl->acl_entry; |
740 | for (i = 0; i < acl->acl_cnt; ++i) { | 734 | for (i = 0; i < acl->acl_cnt; ++i) { |
@@ -764,7 +758,7 @@ xfs_acl_setmode( | |||
764 | if (gap && nomask) | 758 | if (gap && nomask) |
765 | iattr.ia_mode |= gap->ae_perm << 3; | 759 | iattr.ia_mode |= gap->ae_perm << 3; |
766 | 760 | ||
767 | return xfs_setattr(xfs_vtoi(vp), &iattr, 0, sys_cred); | 761 | return xfs_setattr(XFS_I(vp), &iattr, 0, sys_cred); |
768 | } | 762 | } |
769 | 763 | ||
770 | /* | 764 | /* |