aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_attr_leaf.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_attr_leaf.c')
-rw-r--r--fs/xfs/xfs_attr_leaf.c61
1 files changed, 7 insertions, 54 deletions
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index cb345e6e4850..23ef5d7c87e1 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -94,13 +94,6 @@ STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index);
94 * Namespace helper routines 94 * Namespace helper routines
95 *========================================================================*/ 95 *========================================================================*/
96 96
97STATIC_INLINE attrnames_t *
98xfs_attr_flags_namesp(int flags)
99{
100 return ((flags & XFS_ATTR_SECURE) ? &attr_secure:
101 ((flags & XFS_ATTR_ROOT) ? &attr_trusted : &attr_user));
102}
103
104/* 97/*
105 * If namespace bits don't match return 0. 98 * If namespace bits don't match return 0.
106 * If all match then return 1. 99 * If all match then return 1.
@@ -111,25 +104,6 @@ xfs_attr_namesp_match(int arg_flags, int ondisk_flags)
111 return XFS_ATTR_NSP_ONDISK(ondisk_flags) == XFS_ATTR_NSP_ARGS_TO_ONDISK(arg_flags); 104 return XFS_ATTR_NSP_ONDISK(ondisk_flags) == XFS_ATTR_NSP_ARGS_TO_ONDISK(arg_flags);
112} 105}
113 106
114/*
115 * If namespace bits don't match and we don't have an override for it
116 * then return 0.
117 * If all match or are overridable then return 1.
118 */
119STATIC_INLINE int
120xfs_attr_namesp_match_overrides(int arg_flags, int ondisk_flags)
121{
122 if (((arg_flags & ATTR_SECURE) == 0) !=
123 ((ondisk_flags & XFS_ATTR_SECURE) == 0) &&
124 !(arg_flags & ATTR_KERNORMALS))
125 return 0;
126 if (((arg_flags & ATTR_ROOT) == 0) !=
127 ((ondisk_flags & XFS_ATTR_ROOT) == 0) &&
128 !(arg_flags & ATTR_KERNROOTLS))
129 return 0;
130 return 1;
131}
132
133 107
134/*======================================================================== 108/*========================================================================
135 * External routines when attribute fork size < XFS_LITINO(mp). 109 * External routines when attribute fork size < XFS_LITINO(mp).
@@ -626,15 +600,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
626 (XFS_ISRESET_CURSOR(cursor) && 600 (XFS_ISRESET_CURSOR(cursor) &&
627 (dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize)) { 601 (dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize)) {
628 for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) { 602 for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
629 attrnames_t *namesp;
630
631 if (!xfs_attr_namesp_match_overrides(context->flags, sfe->flags)) {
632 sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
633 continue;
634 }
635 namesp = xfs_attr_flags_namesp(sfe->flags);
636 error = context->put_listent(context, 603 error = context->put_listent(context,
637 namesp, 604 sfe->flags,
638 (char *)sfe->nameval, 605 (char *)sfe->nameval,
639 (int)sfe->namelen, 606 (int)sfe->namelen,
640 (int)sfe->valuelen, 607 (int)sfe->valuelen,
@@ -681,10 +648,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
681 kmem_free(sbuf); 648 kmem_free(sbuf);
682 return XFS_ERROR(EFSCORRUPTED); 649 return XFS_ERROR(EFSCORRUPTED);
683 } 650 }
684 if (!xfs_attr_namesp_match_overrides(context->flags, sfe->flags)) { 651
685 sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
686 continue;
687 }
688 sbp->entno = i; 652 sbp->entno = i;
689 sbp->hash = xfs_da_hashname((char *)sfe->nameval, sfe->namelen); 653 sbp->hash = xfs_da_hashname((char *)sfe->nameval, sfe->namelen);
690 sbp->name = (char *)sfe->nameval; 654 sbp->name = (char *)sfe->nameval;
@@ -728,16 +692,12 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
728 * Loop putting entries into the user buffer. 692 * Loop putting entries into the user buffer.
729 */ 693 */
730 for ( ; i < nsbuf; i++, sbp++) { 694 for ( ; i < nsbuf; i++, sbp++) {
731 attrnames_t *namesp;
732
733 namesp = xfs_attr_flags_namesp(sbp->flags);
734
735 if (cursor->hashval != sbp->hash) { 695 if (cursor->hashval != sbp->hash) {
736 cursor->hashval = sbp->hash; 696 cursor->hashval = sbp->hash;
737 cursor->offset = 0; 697 cursor->offset = 0;
738 } 698 }
739 error = context->put_listent(context, 699 error = context->put_listent(context,
740 namesp, 700 sbp->flags,
741 sbp->name, 701 sbp->name,
742 sbp->namelen, 702 sbp->namelen,
743 sbp->valuelen, 703 sbp->valuelen,
@@ -2402,8 +2362,6 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
2402 */ 2362 */
2403 retval = 0; 2363 retval = 0;
2404 for ( ; (i < be16_to_cpu(leaf->hdr.count)); entry++, i++) { 2364 for ( ; (i < be16_to_cpu(leaf->hdr.count)); entry++, i++) {
2405 attrnames_t *namesp;
2406
2407 if (be32_to_cpu(entry->hashval) != cursor->hashval) { 2365 if (be32_to_cpu(entry->hashval) != cursor->hashval) {
2408 cursor->hashval = be32_to_cpu(entry->hashval); 2366 cursor->hashval = be32_to_cpu(entry->hashval);
2409 cursor->offset = 0; 2367 cursor->offset = 0;
@@ -2411,17 +2369,13 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
2411 2369
2412 if (entry->flags & XFS_ATTR_INCOMPLETE) 2370 if (entry->flags & XFS_ATTR_INCOMPLETE)
2413 continue; /* skip incomplete entries */ 2371 continue; /* skip incomplete entries */
2414 if (!xfs_attr_namesp_match_overrides(context->flags, entry->flags))
2415 continue;
2416
2417 namesp = xfs_attr_flags_namesp(entry->flags);
2418 2372
2419 if (entry->flags & XFS_ATTR_LOCAL) { 2373 if (entry->flags & XFS_ATTR_LOCAL) {
2420 xfs_attr_leaf_name_local_t *name_loc = 2374 xfs_attr_leaf_name_local_t *name_loc =
2421 XFS_ATTR_LEAF_NAME_LOCAL(leaf, i); 2375 XFS_ATTR_LEAF_NAME_LOCAL(leaf, i);
2422 2376
2423 retval = context->put_listent(context, 2377 retval = context->put_listent(context,
2424 namesp, 2378 entry->flags,
2425 (char *)name_loc->nameval, 2379 (char *)name_loc->nameval,
2426 (int)name_loc->namelen, 2380 (int)name_loc->namelen,
2427 be16_to_cpu(name_loc->valuelen), 2381 be16_to_cpu(name_loc->valuelen),
@@ -2448,16 +2402,15 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
2448 if (retval) 2402 if (retval)
2449 return retval; 2403 return retval;
2450 retval = context->put_listent(context, 2404 retval = context->put_listent(context,
2451 namesp, 2405 entry->flags,
2452 (char *)name_rmt->name, 2406 (char *)name_rmt->name,
2453 (int)name_rmt->namelen, 2407 (int)name_rmt->namelen,
2454 valuelen, 2408 valuelen,
2455 (char*)args.value); 2409 (char*)args.value);
2456 kmem_free(args.value); 2410 kmem_free(args.value);
2457 } 2411 } else {
2458 else {
2459 retval = context->put_listent(context, 2412 retval = context->put_listent(context,
2460 namesp, 2413 entry->flags,
2461 (char *)name_rmt->name, 2414 (char *)name_rmt->name,
2462 (int)name_rmt->namelen, 2415 (int)name_rmt->namelen,
2463 valuelen, 2416 valuelen,