Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux...
[safe/jmp/linux-2.6] / fs / xfs / xfs_attr.c
index c2c14b2..8fe6f6b 100644 (file)
@@ -1,69 +1,52 @@
 /*
- * Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc.
+ * All Rights Reserved.
  *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
  * published by the Free Software Foundation.
  *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * Further, this software is distributed without any warranty that it is
- * free of the rightful claim of any third person regarding infringement
- * or the like.  Any license provided herein, whether implied or
- * otherwise, applies only to this software file.  Patent licenses, if
- * any, provided herein do not apply to combinations of this program with
- * other software, or any other product whatsoever.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc., 59
- * Temple Place - Suite 330, Boston MA 02111-1307, USA.
- *
- * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
- * Mountain View, CA  94043, or:
- *
- * http://www.sgi.com
- *
- * For further information regarding this notice, see:
- *
- * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "xfs.h"
-
-#include "xfs_macros.h"
+#include "xfs_fs.h"
 #include "xfs_types.h"
-#include "xfs_inum.h"
+#include "xfs_bit.h"
 #include "xfs_log.h"
+#include "xfs_inum.h"
 #include "xfs_trans.h"
 #include "xfs_sb.h"
 #include "xfs_ag.h"
-#include "xfs_dir.h"
 #include "xfs_dir2.h"
 #include "xfs_dmapi.h"
 #include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
+#include "xfs_da_btree.h"
 #include "xfs_bmap_btree.h"
+#include "xfs_alloc_btree.h"
 #include "xfs_ialloc_btree.h"
-#include "xfs_alloc.h"
-#include "xfs_btree.h"
-#include "xfs_attr_sf.h"
-#include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
+#include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
-#include "xfs_inode_item.h"
 #include "xfs_inode.h"
+#include "xfs_alloc.h"
+#include "xfs_btree.h"
+#include "xfs_inode_item.h"
 #include "xfs_bmap.h"
-#include "xfs_da_btree.h"
 #include "xfs_attr.h"
 #include "xfs_attr_leaf.h"
 #include "xfs_error.h"
-#include "xfs_bit.h"
 #include "xfs_quota.h"
-#include "xfs_rw.h"
 #include "xfs_trans_space.h"
-#include "xfs_acl.h"
+#include "xfs_rw.h"
+#include "xfs_vnodeops.h"
 
 /*
  * xfs_attr.c
  * Provide the external interfaces to manage attribute lists.
  */
 
-#define ATTR_SYSCOUNT  2
-STATIC struct attrnames posix_acl_access;
-STATIC struct attrnames posix_acl_default;
-STATIC struct attrnames *attr_system_names[ATTR_SYSCOUNT];
-
 /*========================================================================
  * Function prototypes for the kernel.
  *========================================================================*/
@@ -106,7 +84,6 @@ STATIC int xfs_attr_refillstate(xfs_da_state_t *state);
 /*
  * Routines to manipulate out-of-line attribute values.
  */
-STATIC int xfs_attr_rmtval_get(xfs_da_args_t *args);
 STATIC int xfs_attr_rmtval_set(xfs_da_args_t *args);
 STATIC int xfs_attr_rmtval_remove(xfs_da_args_t *args);
 
@@ -116,34 +93,56 @@ STATIC int xfs_attr_rmtval_remove(xfs_da_args_t *args);
 ktrace_t *xfs_attr_trace_buf;
 #endif
 
+STATIC int
+xfs_attr_name_to_xname(
+       struct xfs_name *xname,
+       const char      *aname)
+{
+       if (!aname)
+               return EINVAL;
+       xname->name = aname;
+       xname->len = strlen(aname);
+       if (xname->len >= MAXNAMELEN)
+               return EFAULT;          /* match IRIX behaviour */
+
+       return 0;
+}
+
+STATIC int
+xfs_inode_hasattr(
+       struct xfs_inode        *ip)
+{
+       if (!XFS_IFORK_Q(ip) ||
+           (ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
+            ip->i_d.di_anextents == 0))
+               return 0;
+       return 1;
+}
 
 /*========================================================================
  * Overall external interface routines.
  *========================================================================*/
 
-int
-xfs_attr_fetch(xfs_inode_t *ip, const char *name, int namelen,
-              char *value, int *valuelenp, int flags, struct cred *cred)
+STATIC int
+xfs_attr_get_int(
+       struct xfs_inode        *ip,
+       struct xfs_name         *name,
+       char                    *value,
+       int                     *valuelenp,
+       int                     flags)
 {
        xfs_da_args_t   args;
        int             error;
 
-       if ((XFS_IFORK_Q(ip) == 0) ||
-           (ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
-            ip->i_d.di_anextents == 0))
-               return(ENOATTR);
-
-       if (!(flags & (ATTR_KERNACCESS|ATTR_SECURE))) {
-               if ((error = xfs_iaccess(ip, S_IRUSR, cred)))
-                       return(XFS_ERROR(error));
-       }
+       if (!xfs_inode_hasattr(ip))
+               return ENOATTR;
 
        /*
         * Fill in the arg structure for this request.
         */
        memset((char *)&args, 0, sizeof(args));
-       args.name = name;
-       args.namelen = namelen;
+       args.name = name->name;
+       args.namelen = name->len;
        args.value = value;
        args.valuelen = *valuelenp;
        args.flags = flags;
@@ -154,11 +153,7 @@ xfs_attr_fetch(xfs_inode_t *ip, const char *name, int namelen,
        /*
         * Decide on what work routines to call based on the inode size.
         */
-       if (XFS_IFORK_Q(ip) == 0 ||
-           (ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
-            ip->i_d.di_anextents == 0)) {
-               error = XFS_ERROR(ENOATTR);
-       } else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
+       if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
                error = xfs_attr_shortform_getvalue(&args);
        } else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK)) {
                error = xfs_attr_leaf_get(&args);
@@ -177,61 +172,99 @@ xfs_attr_fetch(xfs_inode_t *ip, const char *name, int namelen,
 }
 
 int
-xfs_attr_get(bhv_desc_t *bdp, const char *name, char *value, int *valuelenp,
-            int flags, struct cred *cred)
+xfs_attr_get(
+       xfs_inode_t     *ip,
+       const char      *name,
+       char            *value,
+       int             *valuelenp,
+       int             flags)
 {
-       xfs_inode_t     *ip = XFS_BHVTOI(bdp);
-       int             error, namelen;
+       int             error;
+       struct xfs_name xname;
 
        XFS_STATS_INC(xs_attr_get);
 
-       if (!name)
-               return(EINVAL);
-       namelen = strlen(name);
-       if (namelen >= MAXNAMELEN)
-               return(EFAULT);         /* match IRIX behaviour */
-
        if (XFS_FORCED_SHUTDOWN(ip->i_mount))
                return(EIO);
 
+       error = xfs_attr_name_to_xname(&xname, name);
+       if (error)
+               return error;
+
        xfs_ilock(ip, XFS_ILOCK_SHARED);
-       error = xfs_attr_fetch(ip, name, namelen, value, valuelenp, flags, cred);
+       error = xfs_attr_get_int(ip, &xname, value, valuelenp, flags);
        xfs_iunlock(ip, XFS_ILOCK_SHARED);
        return(error);
 }
 
+/*
+ * Calculate how many blocks we need for the new attribute,
+ */
+int
+xfs_attr_calc_size(
+       struct xfs_inode        *ip,
+       int                     namelen,
+       int                     valuelen,
+       int                     *local)
+{
+       struct xfs_mount        *mp = ip->i_mount;
+       int                     size;
+       int                     nblks;
+
+       /*
+        * Determine space new attribute will use, and if it would be
+        * "local" or "remote" (note: local != inline).
+        */
+       size = xfs_attr_leaf_newentsize(namelen, valuelen,
+                                       mp->m_sb.sb_blocksize, local);
+
+       nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
+       if (*local) {
+               if (size > (mp->m_sb.sb_blocksize >> 1)) {
+                       /* Double split possible */
+                       nblks *= 2;
+               }
+       } else {
+               /*
+                * Out of line attribute, cannot double split, but
+                * make room for the attribute value itself.
+                */
+               uint    dblocks = XFS_B_TO_FSB(mp, valuelen);
+               nblks += dblocks;
+               nblks += XFS_NEXTENTADD_SPACE_RES(mp, dblocks, XFS_ATTR_FORK);
+       }
+
+       return nblks;
+}
+
 STATIC int
-xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
-                char *value, int valuelen, int flags)
+xfs_attr_set_int(xfs_inode_t *dp, struct xfs_name *name,
+               char *value, int valuelen, int flags)
 {
        xfs_da_args_t   args;
        xfs_fsblock_t   firstblock;
        xfs_bmap_free_t flist;
        int             error, err2, committed;
-       int             local, size;
-       uint            nblks;
        xfs_mount_t     *mp = dp->i_mount;
        int             rsvd = (flags & ATTR_ROOT) != 0;
+       int             local;
 
        /*
         * Attach the dquots to the inode.
         */
-       if ((error = XFS_QM_DQATTACH(mp, dp, 0)))
-               return (error);
-
-       /*
-        * Determine space new attribute will use, and if it would be
-        * "local" or "remote" (note: local != inline).
-        */
-       size = xfs_attr_leaf_newentsize(namelen, valuelen,
-                                       mp->m_sb.sb_blocksize, &local);
+       error = xfs_qm_dqattach(dp, 0);
+       if (error)
+               return error;
 
        /*
         * If the inode doesn't have an attribute fork, add one.
         * (inode must not be locked when we call this routine)
         */
        if (XFS_IFORK_Q(dp) == 0) {
-               if ((error = xfs_bmap_add_attrfork(dp, size, rsvd)))
+               int sf_size = sizeof(xfs_attr_sf_hdr_t) +
+                             XFS_ATTR_SF_ENTSIZE_BYNAME(name->len, valuelen);
+
+               if ((error = xfs_bmap_add_attrfork(dp, sf_size, rsvd)))
                        return(error);
        }
 
@@ -239,8 +272,8 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
         * Fill in the arg structure for this request.
         */
        memset((char *)&args, 0, sizeof(args));
-       args.name = name;
-       args.namelen = namelen;
+       args.name = name->name;
+       args.namelen = name->len;
        args.value = value;
        args.valuelen = valuelen;
        args.flags = flags;
@@ -249,26 +282,10 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
        args.firstblock = &firstblock;
        args.flist = &flist;
        args.whichfork = XFS_ATTR_FORK;
-       args.addname = 1;
-       args.oknoent = 1;
-
-       nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
-       if (local) {
-               if (size > (mp->m_sb.sb_blocksize >> 1)) {
-                       /* Double split possible */
-                       nblks <<= 1;
-               }
-       } else {
-               uint    dblocks = XFS_B_TO_FSB(mp, valuelen);
-               /* Out of line attribute, cannot double split, but make
-                * room for the attribute value itself.
-                */
-               nblks += dblocks;
-               nblks += XFS_NEXTENTADD_SPACE_RES(mp, dblocks, XFS_ATTR_FORK);
-       }
+       args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
 
        /* Size is now blocks for attribute data */
-       args.total = nblks;
+       args.total = xfs_attr_calc_size(dp, name->len, valuelen, &local);
 
        /*
         * Start our first transaction of the day.
@@ -290,18 +307,17 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
        if (rsvd)
                args.trans->t_flags |= XFS_TRANS_RESERVE;
 
-       if ((error = xfs_trans_reserve(args.trans, (uint) nblks,
-                                     XFS_ATTRSET_LOG_RES(mp, nblks),
-                                     0, XFS_TRANS_PERM_LOG_RES,
-                                     XFS_ATTRSET_LOG_COUNT))) {
+       if ((error = xfs_trans_reserve(args.trans, args.total,
+                       XFS_ATTRSET_LOG_RES(mp, args.total), 0,
+                       XFS_TRANS_PERM_LOG_RES, XFS_ATTRSET_LOG_COUNT))) {
                xfs_trans_cancel(args.trans, 0);
                return(error);
        }
        xfs_ilock(dp, XFS_ILOCK_EXCL);
 
-       error = XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, args.trans, dp, nblks, 0,
-                        rsvd ? XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES :
-                               XFS_QMOPT_RES_REGBLKS);
+       error = xfs_trans_reserve_quota_nblks(args.trans, dp, args.total, 0,
+                               rsvd ? XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES :
+                                      XFS_QMOPT_RES_REGBLKS);
        if (error) {
                xfs_iunlock(dp, XFS_ILOCK_EXCL);
                xfs_trans_cancel(args.trans, XFS_TRANS_RELEASE_LOG_RES);
@@ -312,7 +328,7 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
        xfs_trans_ihold(args.trans, dp);
 
        /*
-        * If the attribute list is non-existant or a shortform list,
+        * If the attribute list is non-existent or a shortform list,
         * upgrade it to a single-leaf-block attribute list.
         */
        if ((dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) ||
@@ -346,8 +362,7 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
                                xfs_trans_set_sync(args.trans);
                        }
                        err2 = xfs_trans_commit(args.trans,
-                                                XFS_TRANS_RELEASE_LOG_RES,
-                                                NULL);
+                                                XFS_TRANS_RELEASE_LOG_RES);
                        xfs_iunlock(dp, XFS_ILOCK_EXCL);
 
                        /*
@@ -363,11 +378,11 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
                 * It won't fit in the shortform, transform to a leaf block.
                 * GROT: another possible req'mt for a double-split btree op.
                 */
-               XFS_BMAP_INIT(args.flist, args.firstblock);
+               xfs_bmap_init(args.flist, args.firstblock);
                error = xfs_attr_shortform_to_leaf(&args);
                if (!error) {
                        error = xfs_bmap_finish(&args.trans, args.flist,
-                                               *args.firstblock, &committed);
+                                               &committed);
                }
                if (error) {
                        ASSERT(committed);
@@ -389,7 +404,9 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
                 * Commit the leaf transformation.  We'll need another (linked)
                 * transaction to add the new attribute to the leaf.
                 */
-               if ((error = xfs_attr_rolltrans(&args.trans, dp)))
+
+               error = xfs_trans_roll(&args.trans, dp);
+               if (error)
                        goto out;
 
        }
@@ -415,8 +432,7 @@ xfs_attr_set_int(xfs_inode_t *dp, const char *name, int namelen,
         * Commit the last in the sequence of transactions.
         */
        xfs_trans_log_inode(args.trans, dp, XFS_ILOG_CORE);
-       error = xfs_trans_commit(args.trans, XFS_TRANS_RELEASE_LOG_RES,
-                                NULL);
+       error = xfs_trans_commit(args.trans, XFS_TRANS_RELEASE_LOG_RES);
        xfs_iunlock(dp, XFS_ILOCK_EXCL);
 
        /*
@@ -437,31 +453,26 @@ out:
 }
 
 int
-xfs_attr_set(bhv_desc_t *bdp, const char *name, char *value, int valuelen, int flags,
-            struct cred *cred)
+xfs_attr_set(
+       xfs_inode_t     *dp,
+       const char      *name,
+       char            *value,
+       int             valuelen,
+       int             flags)
 {
-       xfs_inode_t     *dp;
-       int             namelen, error;
-
-       namelen = strlen(name);
-       if (namelen >= MAXNAMELEN)
-               return EFAULT;          /* match IRIX behaviour */
+       int             error;
+       struct xfs_name xname;
 
        XFS_STATS_INC(xs_attr_set);
 
-       dp = XFS_BHVTOI(bdp);
        if (XFS_FORCED_SHUTDOWN(dp->i_mount))
                return (EIO);
 
-       xfs_ilock(dp, XFS_ILOCK_SHARED);
-       if (!(flags & ATTR_SECURE) &&
-            (error = xfs_iaccess(dp, S_IWUSR, cred))) {
-               xfs_iunlock(dp, XFS_ILOCK_SHARED);
-               return(XFS_ERROR(error));
-       }
-       xfs_iunlock(dp, XFS_ILOCK_SHARED);
+       error = xfs_attr_name_to_xname(&xname, name);
+       if (error)
+               return error;
 
-       return xfs_attr_set_int(dp, name, namelen, value, valuelen, flags);
+       return xfs_attr_set_int(dp, &xname, value, valuelen, flags);
 }
 
 /*
@@ -469,7 +480,7 @@ xfs_attr_set(bhv_desc_t *bdp, const char *name, char *value, int valuelen, int f
  * Transitions attribute list from Btree to shortform as necessary.
  */
 STATIC int
-xfs_attr_remove_int(xfs_inode_t *dp, const char *name, int namelen, int flags)
+xfs_attr_remove_int(xfs_inode_t *dp, struct xfs_name *name, int flags)
 {
        xfs_da_args_t   args;
        xfs_fsblock_t   firstblock;
@@ -481,8 +492,8 @@ xfs_attr_remove_int(xfs_inode_t *dp, const char *name, int namelen, int flags)
         * Fill in the arg structure for this request.
         */
        memset((char *)&args, 0, sizeof(args));
-       args.name = name;
-       args.namelen = namelen;
+       args.name = name->name;
+       args.namelen = name->len;
        args.flags = flags;
        args.hashval = xfs_da_hashname(args.name, args.namelen);
        args.dp = dp;
@@ -494,8 +505,9 @@ xfs_attr_remove_int(xfs_inode_t *dp, const char *name, int namelen, int flags)
        /*
         * Attach the dquots to the inode.
         */
-       if ((error = XFS_QM_DQATTACH(mp, dp, 0)))
-               return (error);
+       error = xfs_qm_dqattach(dp, 0);
+       if (error)
+               return error;
 
        /*
         * Start our first transaction of the day.
@@ -537,9 +549,7 @@ xfs_attr_remove_int(xfs_inode_t *dp, const char *name, int namelen, int flags)
        /*
         * Decide on what work routines to call based on the inode size.
         */
-       if (XFS_IFORK_Q(dp) == 0 ||
-           (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
-            dp->i_d.di_anextents == 0)) {
+       if (!xfs_inode_hasattr(dp)) {
                error = XFS_ERROR(ENOATTR);
                goto out;
        }
@@ -570,8 +580,7 @@ xfs_attr_remove_int(xfs_inode_t *dp, const char *name, int namelen, int flags)
         * Commit the last in the sequence of transactions.
         */
        xfs_trans_log_inode(args.trans, dp, XFS_ILOG_CORE);
-       error = xfs_trans_commit(args.trans, XFS_TRANS_RELEASE_LOG_RES,
-                                NULL);
+       error = xfs_trans_commit(args.trans, XFS_TRANS_RELEASE_LOG_RES);
        xfs_iunlock(dp, XFS_ILOCK_EXCL);
 
        /*
@@ -592,35 +601,121 @@ out:
 }
 
 int
-xfs_attr_remove(bhv_desc_t *bdp, const char *name, int flags, struct cred *cred)
+xfs_attr_remove(
+       xfs_inode_t     *dp,
+       const char      *name,
+       int             flags)
 {
-       xfs_inode_t         *dp;
-       int                 namelen, error;
-
-       namelen = strlen(name);
-       if (namelen >= MAXNAMELEN)
-               return EFAULT;          /* match IRIX behaviour */
+       int             error;
+       struct xfs_name xname;
 
        XFS_STATS_INC(xs_attr_remove);
 
-       dp = XFS_BHVTOI(bdp);
        if (XFS_FORCED_SHUTDOWN(dp->i_mount))
                return (EIO);
 
+       error = xfs_attr_name_to_xname(&xname, name);
+       if (error)
+               return error;
+
        xfs_ilock(dp, XFS_ILOCK_SHARED);
-       if (!(flags & ATTR_SECURE) &&
-            (error = xfs_iaccess(dp, S_IWUSR, cred))) {
-               xfs_iunlock(dp, XFS_ILOCK_SHARED);
-               return(XFS_ERROR(error));
-       } else if (XFS_IFORK_Q(dp) == 0 ||
-                  (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
-                   dp->i_d.di_anextents == 0)) {
+       if (!xfs_inode_hasattr(dp)) {
                xfs_iunlock(dp, XFS_ILOCK_SHARED);
-               return(XFS_ERROR(ENOATTR));
+               return XFS_ERROR(ENOATTR);
+       }
+       xfs_iunlock(dp, XFS_ILOCK_SHARED);
+
+       return xfs_attr_remove_int(dp, &xname, flags);
+}
+
+int
+xfs_attr_list_int(xfs_attr_list_context_t *context)
+{
+       int error;
+       xfs_inode_t *dp = context->dp;
+
+       XFS_STATS_INC(xs_attr_list);
+
+       if (XFS_FORCED_SHUTDOWN(dp->i_mount))
+               return EIO;
+
+       xfs_ilock(dp, XFS_ILOCK_SHARED);
+       xfs_attr_trace_l_c("syscall start", context);
+
+       /*
+        * Decide on what work routines to call based on the inode size.
+        */
+       if (!xfs_inode_hasattr(dp)) {
+               error = 0;
+       } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
+               error = xfs_attr_shortform_list(context);
+       } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) {
+               error = xfs_attr_leaf_list(context);
+       } else {
+               error = xfs_attr_node_list(context);
        }
+
        xfs_iunlock(dp, XFS_ILOCK_SHARED);
+       xfs_attr_trace_l_c("syscall end", context);
+
+       return error;
+}
+
+#define        ATTR_ENTBASESIZE                /* minimum bytes used by an attr */ \
+       (((struct attrlist_ent *) 0)->a_name - (char *) 0)
+#define        ATTR_ENTSIZE(namelen)           /* actual bytes used by an attr */ \
+       ((ATTR_ENTBASESIZE + (namelen) + 1 + sizeof(u_int32_t)-1) \
+        & ~(sizeof(u_int32_t)-1))
 
-       return xfs_attr_remove_int(dp, name, namelen, flags);
+/*
+ * Format an attribute and copy it out to the user's buffer.
+ * Take care to check values and protect against them changing later,
+ * we may be reading them directly out of a user buffer.
+ */
+/*ARGSUSED*/
+STATIC int
+xfs_attr_put_listent(xfs_attr_list_context_t *context, int flags,
+                    char *name, int namelen,
+                    int valuelen, char *value)
+{
+       struct attrlist *alist = (struct attrlist *)context->alist;
+       attrlist_ent_t *aep;
+       int arraytop;
+
+       ASSERT(!(context->flags & ATTR_KERNOVAL));
+       ASSERT(context->count >= 0);
+       ASSERT(context->count < (ATTR_MAX_VALUELEN/8));
+       ASSERT(context->firstu >= sizeof(*alist));
+       ASSERT(context->firstu <= context->bufsize);
+
+       /*
+        * Only list entries in the right namespace.
+        */
+       if (((context->flags & ATTR_SECURE) == 0) !=
+           ((flags & XFS_ATTR_SECURE) == 0))
+               return 0;
+       if (((context->flags & ATTR_ROOT) == 0) !=
+           ((flags & XFS_ATTR_ROOT) == 0))
+               return 0;
+
+       arraytop = sizeof(*alist) +
+                       context->count * sizeof(alist->al_offset[0]);
+       context->firstu -= ATTR_ENTSIZE(namelen);
+       if (context->firstu < arraytop) {
+               xfs_attr_trace_l_c("buffer full", context);
+               alist->al_more = 1;
+               context->seen_enough = 1;
+               return 1;
+       }
+
+       aep = (attrlist_ent_t *)&context->alist[context->firstu];
+       aep->a_valuelen = valuelen;
+       memcpy(aep->a_name, name, namelen);
+       aep->a_name[namelen] = 0;
+       alist->al_offset[context->count++] = context->firstu;
+       alist->al_count = context->count;
+       xfs_attr_trace_l_c("add", context);
+       return 0;
 }
 
 /*
@@ -631,15 +726,17 @@ xfs_attr_remove(bhv_desc_t *bdp, const char *name, int flags, struct cred *cred)
  * success.
  */
 int
-xfs_attr_list(bhv_desc_t *bdp, char *buffer, int bufsize, int flags,
-                     attrlist_cursor_kern_t *cursor, struct cred *cred)
+xfs_attr_list(
+       xfs_inode_t     *dp,
+       char            *buffer,
+       int             bufsize,
+       int             flags,
+       attrlist_cursor_kern_t *cursor)
 {
        xfs_attr_list_context_t context;
-       xfs_inode_t *dp;
+       struct attrlist *alist;
        int error;
 
-       XFS_STATS_INC(xs_attr_list);
-
        /*
         * Validate the cursor.
         */
@@ -647,78 +744,37 @@ xfs_attr_list(bhv_desc_t *bdp, char *buffer, int bufsize, int flags,
                return(XFS_ERROR(EINVAL));
        if ((cursor->initted == 0) &&
            (cursor->hashval || cursor->blkno || cursor->offset))
-               return(XFS_ERROR(EINVAL));
+               return XFS_ERROR(EINVAL);
 
        /*
         * Check for a properly aligned buffer.
         */
        if (((long)buffer) & (sizeof(int)-1))
-               return(XFS_ERROR(EFAULT));
+               return XFS_ERROR(EFAULT);
        if (flags & ATTR_KERNOVAL)
                bufsize = 0;
 
        /*
         * Initialize the output buffer.
         */
-       context.dp = dp = XFS_BHVTOI(bdp);
+       memset(&context, 0, sizeof(context));
+       context.dp = dp;
        context.cursor = cursor;
-       context.count = 0;
-       context.dupcnt = 0;
        context.resynch = 1;
        context.flags = flags;
-       if (!(flags & ATTR_KERNAMELS)) {
-               context.bufsize = (bufsize & ~(sizeof(int)-1));  /* align */
-               context.firstu = context.bufsize;
-               context.alist = (attrlist_t *)buffer;
-               context.alist->al_count = 0;
-               context.alist->al_more = 0;
-               context.alist->al_offset[0] = context.bufsize;
-       }
-       else {
-               context.bufsize = bufsize;
-               context.firstu = context.bufsize;
-               context.alist = (attrlist_t *)buffer;
-       }
-
-       if (XFS_FORCED_SHUTDOWN(dp->i_mount))
-               return (EIO);
-
-       xfs_ilock(dp, XFS_ILOCK_SHARED);
-       if (!(flags & ATTR_SECURE) &&
-            (error = xfs_iaccess(dp, S_IRUSR, cred))) {
-               xfs_iunlock(dp, XFS_ILOCK_SHARED);
-               return(XFS_ERROR(error));
-       }
-
-       /*
-        * Decide on what work routines to call based on the inode size.
-        */
-       xfs_attr_trace_l_c("syscall start", &context);
-       if (XFS_IFORK_Q(dp) == 0 ||
-           (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
-            dp->i_d.di_anextents == 0)) {
-               error = 0;
-       } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
-               error = xfs_attr_shortform_list(&context);
-       } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) {
-               error = xfs_attr_leaf_list(&context);
-       } else {
-               error = xfs_attr_node_list(&context);
-       }
-       xfs_iunlock(dp, XFS_ILOCK_SHARED);
-       xfs_attr_trace_l_c("syscall end", &context);
-
-       if (!(context.flags & (ATTR_KERNOVAL|ATTR_KERNAMELS))) {
-               ASSERT(error >= 0);
-       }
-       else {  /* must return negated buffer size or the error */
-               if (context.count < 0)
-                       error = XFS_ERROR(ERANGE);
-               else
-                       error = -context.count;
-       }
-
-       return(error);
+       context.alist = buffer;
+       context.bufsize = (bufsize & ~(sizeof(int)-1));  /* align */
+       context.firstu = context.bufsize;
+       context.put_listent = xfs_attr_put_listent;
+
+       alist = (struct attrlist *)context.alist;
+       alist->al_count = 0;
+       alist->al_more = 0;
+       alist->al_offset[0] = context.bufsize;
+
+       error = xfs_attr_list_int(&context);
+       ASSERT(error >= 0);
+       return error;
 }
 
 int                                                            /* error */
@@ -732,12 +788,10 @@ xfs_attr_inactive(xfs_inode_t *dp)
        ASSERT(! XFS_NOT_DQATTACHED(mp, dp));
 
        xfs_ilock(dp, XFS_ILOCK_SHARED);
-       if ((XFS_IFORK_Q(dp) == 0) ||
-           (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) ||
-           (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
-            dp->i_d.di_anextents == 0)) {
+       if (!xfs_inode_hasattr(dp) ||
+           dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
                xfs_iunlock(dp, XFS_ILOCK_SHARED);
-               return(0);
+               return 0;
        }
        xfs_iunlock(dp, XFS_ILOCK_SHARED);
 
@@ -770,10 +824,8 @@ xfs_attr_inactive(xfs_inode_t *dp)
        /*
         * Decide on what work routines to call based on the inode size.
         */
-       if ((XFS_IFORK_Q(dp) == 0) ||
-           (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) ||
-           (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
-            dp->i_d.di_anextents == 0)) {
+       if (!xfs_inode_hasattr(dp) ||
+           dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
                error = 0;
                goto out;
        }
@@ -797,8 +849,7 @@ xfs_attr_inactive(xfs_inode_t *dp)
         * Commit the last in the sequence of transactions.
         */
        xfs_trans_log_inode(trans, dp, XFS_ILOG_CORE);
-       error = xfs_trans_commit(trans, XFS_TRANS_RELEASE_LOG_RES,
-                                NULL);
+       error = xfs_trans_commit(trans, XFS_TRANS_RELEASE_LOG_RES);
        xfs_iunlock(dp, XFS_ILOCK_EXCL);
 
        return(error);
@@ -860,7 +911,7 @@ xfs_attr_shortform_addname(xfs_da_args_t *args)
  * This leaf block cannot have a "remote" value, we only call this routine
  * if bmap_one_block() says there is only one block (ie: no remote blks).
  */
-int
+STATIC int
 xfs_attr_leaf_addname(xfs_da_args_t *args)
 {
        xfs_inode_t *dp;
@@ -891,7 +942,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
                        xfs_da_brelse(args->trans, bp);
                        return(retval);
                }
-               args->rename = 1;                       /* an atomic rename */
+               args->op_flags |= XFS_DA_OP_RENAME;     /* an atomic rename */
                args->blkno2 = args->blkno;             /* set 2nd entry info*/
                args->index2 = args->index;
                args->rmtblkno2 = args->rmtblkno;
@@ -910,11 +961,11 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
                 * Commit that transaction so that the node_addname() call
                 * can manage its own transactions.
                 */
-               XFS_BMAP_INIT(args->flist, args->firstblock);
+               xfs_bmap_init(args->flist, args->firstblock);
                error = xfs_attr_leaf_to_node(args);
                if (!error) {
                        error = xfs_bmap_finish(&args->trans, args->flist,
-                                               *args->firstblock, &committed);
+                                               &committed);
                }
                if (error) {
                        ASSERT(committed);
@@ -936,7 +987,8 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
                 * Commit the current trans (including the inode) and start
                 * a new one.
                 */
-               if ((error = xfs_attr_rolltrans(&args->trans, dp)))
+               error = xfs_trans_roll(&args->trans, dp);
+               if (error)
                        return (error);
 
                /*
@@ -950,7 +1002,8 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
         * Commit the transaction that added the attr name so that
         * later routines can manage their own transactions.
         */
-       if ((error = xfs_attr_rolltrans(&args->trans, dp)))
+       error = xfs_trans_roll(&args->trans, dp);
+       if (error)
                return (error);
 
        /*
@@ -971,7 +1024,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
         * so that one disappears and one appears atomically.  Then we
         * must remove the "old" attribute/value pair.
         */
-       if (args->rename) {
+       if (args->op_flags & XFS_DA_OP_RENAME) {
                /*
                 * In a separate transaction, set the incomplete flag on the
                 * "old" attr and clear the incomplete flag on the "new" attr.
@@ -1009,13 +1062,12 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
                 * If the result is small enough, shrink it all into the inode.
                 */
                if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
-                       XFS_BMAP_INIT(args->flist, args->firstblock);
+                       xfs_bmap_init(args->flist, args->firstblock);
                        error = xfs_attr_leaf_to_shortform(bp, args, forkoff);
                        /* bp is gone due to xfs_da_shrink_inode */
                        if (!error) {
                                error = xfs_bmap_finish(&args->trans,
                                                        args->flist,
-                                                       *args->firstblock,
                                                        &committed);
                        }
                        if (error) {
@@ -1040,7 +1092,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args)
                /*
                 * Commit the remove and start the next trans in series.
                 */
-               error = xfs_attr_rolltrans(&args->trans, dp);
+               error = xfs_trans_roll(&args->trans, dp);
 
        } else if (args->rmtblkno > 0) {
                /*
@@ -1088,12 +1140,12 @@ xfs_attr_leaf_removename(xfs_da_args_t *args)
         * If the result is small enough, shrink it all into the inode.
         */
        if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
-               XFS_BMAP_INIT(args->flist, args->firstblock);
+               xfs_bmap_init(args->flist, args->firstblock);
                error = xfs_attr_leaf_to_shortform(bp, args, forkoff);
                /* bp is gone due to xfs_da_shrink_inode */
                if (!error) {
                        error = xfs_bmap_finish(&args->trans, args->flist,
-                                               *args->firstblock, &committed);
+                                               &committed);
                }
                if (error) {
                        ASSERT(committed);
@@ -1160,20 +1212,19 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
        context->cursor->blkno = 0;
        error = xfs_da_read_buf(NULL, context->dp, 0, -1, &bp, XFS_ATTR_FORK);
        if (error)
-               return(error);
+               return XFS_ERROR(error);
        ASSERT(bp != NULL);
        leaf = bp->data;
-       if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
-                                               != XFS_ATTR_LEAF_MAGIC)) {
+       if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)) {
                XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW,
                                     context->dp->i_mount, leaf);
                xfs_da_brelse(NULL, bp);
-               return(XFS_ERROR(EFSCORRUPTED));
+               return XFS_ERROR(EFSCORRUPTED);
        }
 
-       (void)xfs_attr_leaf_list_int(bp, context);
+       error = xfs_attr_leaf_list_int(bp, context);
        xfs_da_brelse(NULL, bp);
-       return(0);
+       return XFS_ERROR(error);
 }
 
 
@@ -1226,7 +1277,7 @@ restart:
        } else if (retval == EEXIST) {
                if (args->flags & ATTR_CREATE)
                        goto out;
-               args->rename = 1;                       /* atomic rename op */
+               args->op_flags |= XFS_DA_OP_RENAME;     /* atomic rename op */
                args->blkno2 = args->blkno;             /* set 2nd entry info*/
                args->index2 = args->index;
                args->rmtblkno2 = args->rmtblkno;
@@ -1244,12 +1295,11 @@ restart:
                         * have been a b-tree.
                         */
                        xfs_da_state_free(state);
-                       XFS_BMAP_INIT(args->flist, args->firstblock);
+                       xfs_bmap_init(args->flist, args->firstblock);
                        error = xfs_attr_leaf_to_node(args);
                        if (!error) {
                                error = xfs_bmap_finish(&args->trans,
                                                        args->flist,
-                                                       *args->firstblock,
                                                        &committed);
                        }
                        if (error) {
@@ -1273,7 +1323,8 @@ restart:
                         * Commit the node conversion and start the next
                         * trans in the chain.
                         */
-                       if ((error = xfs_attr_rolltrans(&args->trans, dp)))
+                       error = xfs_trans_roll(&args->trans, dp);
+                       if (error)
                                goto out;
 
                        goto restart;
@@ -1285,11 +1336,11 @@ restart:
                 * in the index/blkno/rmtblkno/rmtblkcnt fields and
                 * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields.
                 */
-               XFS_BMAP_INIT(args->flist, args->firstblock);
+               xfs_bmap_init(args->flist, args->firstblock);
                error = xfs_da_split(state);
                if (!error) {
                        error = xfs_bmap_finish(&args->trans, args->flist,
-                                               *args->firstblock, &committed);
+                                               &committed);
                }
                if (error) {
                        ASSERT(committed);
@@ -1324,7 +1375,8 @@ restart:
         * Commit the leaf addition or btree split and start the next
         * trans in the chain.
         */
-       if ((error = xfs_attr_rolltrans(&args->trans, dp)))
+       error = xfs_trans_roll(&args->trans, dp);
+       if (error)
                goto out;
 
        /*
@@ -1345,7 +1397,7 @@ restart:
         * so that one disappears and one appears atomically.  Then we
         * must remove the "old" attribute/value pair.
         */
-       if (args->rename) {
+       if (args->op_flags & XFS_DA_OP_RENAME) {
                /*
                 * In a separate transaction, set the incomplete flag on the
                 * "old" attr and clear the incomplete flag on the "new" attr.
@@ -1396,12 +1448,11 @@ restart:
                 * Check to see if the tree needs to be collapsed.
                 */
                if (retval && (state->path.active > 1)) {
-                       XFS_BMAP_INIT(args->flist, args->firstblock);
+                       xfs_bmap_init(args->flist, args->firstblock);
                        error = xfs_da_join(state);
                        if (!error) {
                                error = xfs_bmap_finish(&args->trans,
                                                        args->flist,
-                                                       *args->firstblock,
                                                        &committed);
                        }
                        if (error) {
@@ -1425,7 +1476,8 @@ restart:
                /*
                 * Commit and start the next trans in the chain.
                 */
-               if ((error = xfs_attr_rolltrans(&args->trans, dp)))
+               error = xfs_trans_roll(&args->trans, dp);
+               if (error)
                        goto out;
 
        } else if (args->rmtblkno > 0) {
@@ -1532,11 +1584,11 @@ xfs_attr_node_removename(xfs_da_args_t *args)
         * Check to see if the tree needs to be collapsed.
         */
        if (retval && (state->path.active > 1)) {
-               XFS_BMAP_INIT(args->flist, args->firstblock);
+               xfs_bmap_init(args->flist, args->firstblock);
                error = xfs_da_join(state);
                if (!error) {
                        error = xfs_bmap_finish(&args->trans, args->flist,
-                                               *args->firstblock, &committed);
+                                               &committed);
                }
                if (error) {
                        ASSERT(committed);
@@ -1557,7 +1609,8 @@ xfs_attr_node_removename(xfs_da_args_t *args)
                /*
                 * Commit the Btree join operation and start a new trans.
                 */
-               if ((error = xfs_attr_rolltrans(&args->trans, dp)))
+               error = xfs_trans_roll(&args->trans, dp);
+               if (error)
                        goto out;
        }
 
@@ -1577,18 +1630,17 @@ xfs_attr_node_removename(xfs_da_args_t *args)
                                                     XFS_ATTR_FORK);
                if (error)
                        goto out;
-               ASSERT(INT_GET(((xfs_attr_leafblock_t *)
-                                     bp->data)->hdr.info.magic, ARCH_CONVERT)
+               ASSERT(be16_to_cpu(((xfs_attr_leafblock_t *)
+                                     bp->data)->hdr.info.magic)
                                                       == XFS_ATTR_LEAF_MAGIC);
 
                if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
-                       XFS_BMAP_INIT(args->flist, args->firstblock);
+                       xfs_bmap_init(args->flist, args->firstblock);
                        error = xfs_attr_leaf_to_shortform(bp, args, forkoff);
                        /* bp is gone due to xfs_da_shrink_inode */
                        if (!error) {
                                error = xfs_bmap_finish(&args->trans,
                                                        args->flist,
-                                                       *args->firstblock,
                                                        &committed);
                        }
                        if (error) {
@@ -1621,7 +1673,7 @@ out:
  * Fill in the disk block numbers in the state structure for the buffers
  * that are attached to the state structure.
  * This is done so that we can quickly reattach ourselves to those buffers
- * after some set of transaction commit's has released these buffers.
+ * after some set of transaction commits have released these buffers.
  */
 STATIC int
 xfs_attr_fillstate(xfs_da_state_t *state)
@@ -1668,7 +1720,7 @@ xfs_attr_fillstate(xfs_da_state_t *state)
 /*
  * Reattach the buffers to the state structure based on the disk block
  * numbers stored in the state structure.
- * This is done after some set of transaction commit's has released those
+ * This is done after some set of transaction commits have released those
  * buffers from our grip.
  */
 STATIC int
@@ -1799,7 +1851,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                        return(error);
                if (bp) {
                        node = bp->data;
-                       switch (INT_GET(node->hdr.info.magic, ARCH_CONVERT)) {
+                       switch (be16_to_cpu(node->hdr.info.magic)) {
                        case XFS_DA_NODE_MAGIC:
                                xfs_attr_trace_l_cn("wrong blk", context, node);
                                xfs_da_brelse(NULL, bp);
@@ -1807,18 +1859,14 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                                break;
                        case XFS_ATTR_LEAF_MAGIC:
                                leaf = bp->data;
-                               if (cursor->hashval >
-                                   INT_GET(leaf->entries[
-                                        INT_GET(leaf->hdr.count,
-                                               ARCH_CONVERT)-1].hashval,
-                                                       ARCH_CONVERT)) {
+                               if (cursor->hashval > be32_to_cpu(leaf->entries[
+                                   be16_to_cpu(leaf->hdr.count)-1].hashval)) {
                                        xfs_attr_trace_l_cl("wrong blk",
                                                           context, leaf);
                                        xfs_da_brelse(NULL, bp);
                                        bp = NULL;
                                } else if (cursor->hashval <=
-                                            INT_GET(leaf->entries[0].hashval,
-                                                       ARCH_CONVERT)) {
+                                            be32_to_cpu(leaf->entries[0].hashval)) {
                                        xfs_attr_trace_l_cl("maybe wrong blk",
                                                           context, leaf);
                                        xfs_da_brelse(NULL, bp);
@@ -1853,10 +1901,10 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                                return(XFS_ERROR(EFSCORRUPTED));
                        }
                        node = bp->data;
-                       if (INT_GET(node->hdr.info.magic, ARCH_CONVERT)
+                       if (be16_to_cpu(node->hdr.info.magic)
                                                        == XFS_ATTR_LEAF_MAGIC)
                                break;
-                       if (unlikely(INT_GET(node->hdr.info.magic, ARCH_CONVERT)
+                       if (unlikely(be16_to_cpu(node->hdr.info.magic)
                                                        != XFS_DA_NODE_MAGIC)) {
                                XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)",
                                                     XFS_ERRLEVEL_LOW,
@@ -1866,19 +1914,17 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                                return(XFS_ERROR(EFSCORRUPTED));
                        }
                        btree = node->btree;
-                       for (i = 0;
-                               i < INT_GET(node->hdr.count, ARCH_CONVERT);
+                       for (i = 0; i < be16_to_cpu(node->hdr.count);
                                                                btree++, i++) {
                                if (cursor->hashval
-                                               <= INT_GET(btree->hashval,
-                                                           ARCH_CONVERT)) {
-                                       cursor->blkno = INT_GET(btree->before, ARCH_CONVERT);
+                                               <= be32_to_cpu(btree->hashval)) {
+                                       cursor->blkno = be32_to_cpu(btree->before);
                                        xfs_attr_trace_l_cb("descending",
                                                            context, btree);
                                        break;
                                }
                        }
-                       if (i == INT_GET(node->hdr.count, ARCH_CONVERT)) {
+                       if (i == be16_to_cpu(node->hdr.count)) {
                                xfs_da_brelse(NULL, bp);
                                return(0);
                        }
@@ -1894,7 +1940,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
         */
        for (;;) {
                leaf = bp->data;
-               if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
+               if (unlikely(be16_to_cpu(leaf->hdr.info.magic)
                                                != XFS_ATTR_LEAF_MAGIC)) {
                        XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)",
                                             XFS_ERRLEVEL_LOW,
@@ -1903,9 +1949,13 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
                        return(XFS_ERROR(EFSCORRUPTED));
                }
                error = xfs_attr_leaf_list_int(bp, context);
-               if (error || !leaf->hdr.info.forw)
-                       break;  /* not really an error, buffer full or EOF */
-               cursor->blkno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT);
+               if (error) {
+                       xfs_da_brelse(NULL, bp);
+                       return error;
+               }
+               if (context->seen_enough || leaf->hdr.info.forw == 0)
+                       break;
+               cursor->blkno = be32_to_cpu(leaf->hdr.info.forw);
                xfs_da_brelse(NULL, bp);
                error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
                                              &bp, XFS_ATTR_FORK);
@@ -1931,7 +1981,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
  * Read the value associated with an attribute from the out-of-line buffer
  * that we stored it in.
  */
-STATIC int
+int
 xfs_attr_rmtval_get(xfs_da_args_t *args)
 {
        xfs_bmbt_irec_t map[ATTR_RMTVALUE_MAPSIZE];
@@ -1953,7 +2003,7 @@ xfs_attr_rmtval_get(xfs_da_args_t *args)
                error = xfs_bmapi(args->trans, args->dp, (xfs_fileoff_t)lblkno,
                                  args->rmtblkcnt,
                                  XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA,
-                                 NULL, 0, map, &nmap, NULL);
+                                 NULL, 0, map, &nmap, NULL, NULL);
                if (error)
                        return(error);
                ASSERT(nmap >= 1);
@@ -1964,7 +2014,9 @@ xfs_attr_rmtval_get(xfs_da_args_t *args)
                        dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);
                        blkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
                        error = xfs_read_buf(mp, mp->m_ddev_targp, dblkno,
-                                            blkcnt, XFS_BUF_LOCK, &bp);
+                                            blkcnt,
+                                            XFS_BUF_LOCK | XBF_DONT_BLOCK,
+                                            &bp);
                        if (error)
                                return(error);
 
@@ -2024,17 +2076,17 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
                /*
                 * Allocate a single extent, up to the size of the value.
                 */
-               XFS_BMAP_INIT(args->flist, args->firstblock);
+               xfs_bmap_init(args->flist, args->firstblock);
                nmap = 1;
                error = xfs_bmapi(args->trans, dp, (xfs_fileoff_t)lblkno,
                                  blkcnt,
                                  XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA |
                                                        XFS_BMAPI_WRITE,
                                  args->firstblock, args->total, &map, &nmap,
-                                 args->flist);
+                                 args->flist, NULL);
                if (!error) {
                        error = xfs_bmap_finish(&args->trans, args->flist,
-                                               *args->firstblock, &committed);
+                                               &committed);
                }
                if (error) {
                        ASSERT(committed);
@@ -2061,7 +2113,8 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
                /*
                 * Start the next trans in the chain.
                 */
-               if ((error = xfs_attr_rolltrans(&args->trans, dp)))
+               error = xfs_trans_roll(&args->trans, dp);
+               if (error)
                        return (error);
        }
 
@@ -2077,12 +2130,13 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
                /*
                 * Try to remember where we decided to put the value.
                 */
-               XFS_BMAP_INIT(args->flist, args->firstblock);
+               xfs_bmap_init(args->flist, args->firstblock);
                nmap = 1;
                error = xfs_bmapi(NULL, dp, (xfs_fileoff_t)lblkno,
                                  args->rmtblkcnt,
                                  XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA,
-                                 args->firstblock, 0, &map, &nmap, NULL);
+                                 args->firstblock, 0, &map, &nmap,
+                                 NULL, NULL);
                if (error) {
                        return(error);
                }
@@ -2093,8 +2147,8 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
                dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock),
                blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
 
-               bp = xfs_buf_get_flags(mp->m_ddev_targp, dblkno,
-                                                       blkcnt, XFS_BUF_LOCK);
+               bp = xfs_buf_get(mp->m_ddev_targp, dblkno, blkcnt,
+                                XFS_BUF_LOCK | XBF_DONT_BLOCK);
                ASSERT(bp);
                ASSERT(!XFS_BUF_GETERROR(bp));
 
@@ -2141,13 +2195,13 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
                /*
                 * Try to remember where we decided to put the value.
                 */
-               XFS_BMAP_INIT(args->flist, args->firstblock);
+               xfs_bmap_init(args->flist, args->firstblock);
                nmap = 1;
                error = xfs_bmapi(NULL, args->dp, (xfs_fileoff_t)lblkno,
                                        args->rmtblkcnt,
                                        XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA,
                                        args->firstblock, 0, &map, &nmap,
-                                       args->flist);
+                                       args->flist, NULL);
                if (error) {
                        return(error);
                }
@@ -2182,13 +2236,14 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
        blkcnt = args->rmtblkcnt;
        done = 0;
        while (!done) {
-               XFS_BMAP_INIT(args->flist, args->firstblock);
+               xfs_bmap_init(args->flist, args->firstblock);
                error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
                                    XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA,
-                                   1, args->firstblock, args->flist, &done);
+                                   1, args->firstblock, args->flist,
+                                   NULL, &done);
                if (!error) {
                        error = xfs_bmap_finish(&args->trans, args->flist,
-                                               *args->firstblock, &committed);
+                                               &committed);
                }
                if (error) {
                        ASSERT(committed);
@@ -2209,7 +2264,8 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
                /*
                 * Close out trans and start the next one in the chain.
                 */
-               if ((error = xfs_attr_rolltrans(&args->trans, args->dp)))
+               error = xfs_trans_roll(&args->trans, args->dp);
+               if (error)
                        return (error);
        }
        return(0);
@@ -2222,23 +2278,7 @@ xfs_attr_rmtval_remove(xfs_da_args_t *args)
 void
 xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context)
 {
-       xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_C, where,
-               (__psunsigned_t)context->dp,
-               (__psunsigned_t)context->cursor->hashval,
-               (__psunsigned_t)context->cursor->blkno,
-               (__psunsigned_t)context->cursor->offset,
-               (__psunsigned_t)context->alist,
-               (__psunsigned_t)context->bufsize,
-               (__psunsigned_t)context->count,
-               (__psunsigned_t)context->firstu,
-               (__psunsigned_t)
-                       ((context->count > 0) &&
-                       !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
-                               ? (ATTR_ENTRY(context->alist,
-                                             context->count-1)->a_valuelen)
-                               : 0,
-               (__psunsigned_t)context->dupcnt,
-               (__psunsigned_t)context->flags,
+       xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_C, where, context,
                (__psunsigned_t)NULL,
                (__psunsigned_t)NULL,
                (__psunsigned_t)NULL);
@@ -2251,26 +2291,11 @@ void
 xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
                         struct xfs_da_intnode *node)
 {
-       xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CN, where,
-               (__psunsigned_t)context->dp,
-               (__psunsigned_t)context->cursor->hashval,
-               (__psunsigned_t)context->cursor->blkno,
-               (__psunsigned_t)context->cursor->offset,
-               (__psunsigned_t)context->alist,
-               (__psunsigned_t)context->bufsize,
-               (__psunsigned_t)context->count,
-               (__psunsigned_t)context->firstu,
-               (__psunsigned_t)
-                       ((context->count > 0) &&
-                       !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
-                               ? (ATTR_ENTRY(context->alist,
-                                             context->count-1)->a_valuelen)
-                               : 0,
-               (__psunsigned_t)context->dupcnt,
-               (__psunsigned_t)context->flags,
-               (__psunsigned_t)INT_GET(node->hdr.count, ARCH_CONVERT),
-               (__psunsigned_t)INT_GET(node->btree[0].hashval, ARCH_CONVERT),
-               (__psunsigned_t)INT_GET(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT));
+       xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CN, where, context,
+               (__psunsigned_t)be16_to_cpu(node->hdr.count),
+               (__psunsigned_t)be32_to_cpu(node->btree[0].hashval),
+               (__psunsigned_t)be32_to_cpu(node->btree[
+                                   be16_to_cpu(node->hdr.count)-1].hashval));
 }
 
 /*
@@ -2280,25 +2305,9 @@ void
 xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context,
                          struct xfs_da_node_entry *btree)
 {
-       xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CB, where,
-               (__psunsigned_t)context->dp,
-               (__psunsigned_t)context->cursor->hashval,
-               (__psunsigned_t)context->cursor->blkno,
-               (__psunsigned_t)context->cursor->offset,
-               (__psunsigned_t)context->alist,
-               (__psunsigned_t)context->bufsize,
-               (__psunsigned_t)context->count,
-               (__psunsigned_t)context->firstu,
-               (__psunsigned_t)
-                       ((context->count > 0) &&
-                       !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
-                               ? (ATTR_ENTRY(context->alist,
-                                             context->count-1)->a_valuelen)
-                               : 0,
-               (__psunsigned_t)context->dupcnt,
-               (__psunsigned_t)context->flags,
-               (__psunsigned_t)INT_GET(btree->hashval, ARCH_CONVERT),
-               (__psunsigned_t)INT_GET(btree->before, ARCH_CONVERT),
+       xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CB, where, context,
+               (__psunsigned_t)be32_to_cpu(btree->hashval),
+               (__psunsigned_t)be32_to_cpu(btree->before),
                (__psunsigned_t)NULL);
 }
 
@@ -2309,26 +2318,11 @@ void
 xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context,
                              struct xfs_attr_leafblock *leaf)
 {
-       xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CL, where,
-               (__psunsigned_t)context->dp,
-               (__psunsigned_t)context->cursor->hashval,
-               (__psunsigned_t)context->cursor->blkno,
-               (__psunsigned_t)context->cursor->offset,
-               (__psunsigned_t)context->alist,
-               (__psunsigned_t)context->bufsize,
-               (__psunsigned_t)context->count,
-               (__psunsigned_t)context->firstu,
-               (__psunsigned_t)
-                       ((context->count > 0) &&
-                       !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
-                               ? (ATTR_ENTRY(context->alist,
-                                             context->count-1)->a_valuelen)
-                               : 0,
-               (__psunsigned_t)context->dupcnt,
-               (__psunsigned_t)context->flags,
-               (__psunsigned_t)INT_GET(leaf->hdr.count, ARCH_CONVERT),
-               (__psunsigned_t)INT_GET(leaf->entries[0].hashval, ARCH_CONVERT),
-               (__psunsigned_t)INT_GET(leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT));
+       xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CL, where, context,
+               (__psunsigned_t)be16_to_cpu(leaf->hdr.count),
+               (__psunsigned_t)be32_to_cpu(leaf->entries[0].hashval),
+               (__psunsigned_t)be32_to_cpu(leaf->entries[
+                               be16_to_cpu(leaf->hdr.count)-1].hashval));
 }
 
 /*
@@ -2337,343 +2331,24 @@ xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context,
  */
 void
 xfs_attr_trace_enter(int type, char *where,
-                        __psunsigned_t a2, __psunsigned_t a3,
-                        __psunsigned_t a4, __psunsigned_t a5,
-                        __psunsigned_t a6, __psunsigned_t a7,
-                        __psunsigned_t a8, __psunsigned_t a9,
-                        __psunsigned_t a10, __psunsigned_t a11,
-                        __psunsigned_t a12, __psunsigned_t a13,
-                        __psunsigned_t a14, __psunsigned_t a15)
+                        struct xfs_attr_list_context *context,
+                        __psunsigned_t a13, __psunsigned_t a14,
+                        __psunsigned_t a15)
 {
        ASSERT(xfs_attr_trace_buf);
        ktrace_enter(xfs_attr_trace_buf, (void *)((__psunsigned_t)type),
-                                        (void *)where,
-                                        (void *)a2,  (void *)a3,  (void *)a4,
-                                        (void *)a5,  (void *)a6,  (void *)a7,
-                                        (void *)a8,  (void *)a9,  (void *)a10,
-                                        (void *)a11, (void *)a12, (void *)a13,
-                                        (void *)a14, (void *)a15);
+               (void *)((__psunsigned_t)where),
+               (void *)((__psunsigned_t)context->dp),
+               (void *)((__psunsigned_t)context->cursor->hashval),
+               (void *)((__psunsigned_t)context->cursor->blkno),
+               (void *)((__psunsigned_t)context->cursor->offset),
+               (void *)((__psunsigned_t)context->alist),
+               (void *)((__psunsigned_t)context->bufsize),
+               (void *)((__psunsigned_t)context->count),
+               (void *)((__psunsigned_t)context->firstu),
+               NULL,
+               (void *)((__psunsigned_t)context->dupcnt),
+               (void *)((__psunsigned_t)context->flags),
+               (void *)a13, (void *)a14, (void *)a15);
 }
 #endif /* XFS_ATTR_TRACE */
-
-
-/*========================================================================
- * System (pseudo) namespace attribute interface routines.
- *========================================================================*/
-
-STATIC int
-posix_acl_access_set(
-       vnode_t *vp, char *name, void *data, size_t size, int xflags)
-{
-       return xfs_acl_vset(vp, data, size, _ACL_TYPE_ACCESS);
-}
-
-STATIC int
-posix_acl_access_remove(
-       struct vnode *vp, char *name, int xflags)
-{
-       return xfs_acl_vremove(vp, _ACL_TYPE_ACCESS);
-}
-
-STATIC int
-posix_acl_access_get(
-       vnode_t *vp, char *name, void *data, size_t size, int xflags)
-{
-       return xfs_acl_vget(vp, data, size, _ACL_TYPE_ACCESS);
-}
-
-STATIC int
-posix_acl_access_exists(
-       vnode_t *vp)
-{
-       return xfs_acl_vhasacl_access(vp);
-}
-
-STATIC int
-posix_acl_default_set(
-       vnode_t *vp, char *name, void *data, size_t size, int xflags)
-{
-       return xfs_acl_vset(vp, data, size, _ACL_TYPE_DEFAULT);
-}
-
-STATIC int
-posix_acl_default_get(
-       vnode_t *vp, char *name, void *data, size_t size, int xflags)
-{
-       return xfs_acl_vget(vp, data, size, _ACL_TYPE_DEFAULT);
-}
-
-STATIC int
-posix_acl_default_remove(
-       struct vnode *vp, char *name, int xflags)
-{
-       return xfs_acl_vremove(vp, _ACL_TYPE_DEFAULT);
-}
-
-STATIC int
-posix_acl_default_exists(
-       vnode_t *vp)
-{
-       return xfs_acl_vhasacl_default(vp);
-}
-
-STATIC struct attrnames posix_acl_access = {
-       .attr_name      = "posix_acl_access",
-       .attr_namelen   = sizeof("posix_acl_access") - 1,
-       .attr_get       = posix_acl_access_get,
-       .attr_set       = posix_acl_access_set,
-       .attr_remove    = posix_acl_access_remove,
-       .attr_exists    = posix_acl_access_exists,
-};
-
-STATIC struct attrnames posix_acl_default = {
-       .attr_name      = "posix_acl_default",
-       .attr_namelen   = sizeof("posix_acl_default") - 1,
-       .attr_get       = posix_acl_default_get,
-       .attr_set       = posix_acl_default_set,
-       .attr_remove    = posix_acl_default_remove,
-       .attr_exists    = posix_acl_default_exists,
-};
-
-STATIC struct attrnames *attr_system_names[] =
-       { &posix_acl_access, &posix_acl_default };
-
-
-/*========================================================================
- * Namespace-prefix-style attribute name interface routines.
- *========================================================================*/
-
-STATIC int
-attr_generic_set(
-       struct vnode *vp, char *name, void *data, size_t size, int xflags)
-{
-       int     error;
-
-       VOP_ATTR_SET(vp, name, data, size, xflags, NULL, error);
-       return -error;
-}
-
-STATIC int
-attr_generic_get(
-       struct vnode *vp, char *name, void *data, size_t size, int xflags)
-{
-       int     error, asize = size;
-
-       VOP_ATTR_GET(vp, name, data, &asize, xflags, NULL, error);
-       if (!error)
-               return asize;
-       return -error;
-}
-
-STATIC int
-attr_generic_remove(
-       struct vnode *vp, char *name, int xflags)
-{
-       int     error;
-
-       VOP_ATTR_REMOVE(vp, name, xflags, NULL, error);
-       return -error;
-}
-
-STATIC int
-attr_generic_listadd(
-       attrnames_t             *prefix,
-       attrnames_t             *namesp,
-       void                    *data,
-       size_t                  size,
-       ssize_t                 *result)
-{
-       char                    *p = data + *result;
-
-       *result += prefix->attr_namelen;
-       *result += namesp->attr_namelen + 1;
-       if (!size)
-               return 0;
-       if (*result > size)
-               return -ERANGE;
-       strcpy(p, prefix->attr_name);
-       p += prefix->attr_namelen;
-       strcpy(p, namesp->attr_name);
-       p += namesp->attr_namelen + 1;
-       return 0;
-}
-
-STATIC int
-attr_system_list(
-       struct vnode            *vp,
-       void                    *data,
-       size_t                  size,
-       ssize_t                 *result)
-{
-       attrnames_t             *namesp;
-       int                     i, error = 0;
-
-       for (i = 0; i < ATTR_SYSCOUNT; i++) {
-               namesp = attr_system_names[i];
-               if (!namesp->attr_exists || !namesp->attr_exists(vp))
-                       continue;
-               error = attr_generic_listadd(&attr_system, namesp,
-                                               data, size, result);
-               if (error)
-                       break;
-       }
-       return error;
-}
-
-int
-attr_generic_list(
-       struct vnode *vp, void *data, size_t size, int xflags, ssize_t *result)
-{
-       attrlist_cursor_kern_t  cursor = { 0 };
-       int                     error;
-
-       VOP_ATTR_LIST(vp, data, size, xflags, &cursor, NULL, error);
-       if (error > 0)
-               return -error;
-       *result = -error;
-       return attr_system_list(vp, data, size, result);
-}
-
-attrnames_t *
-attr_lookup_namespace(
-       char                    *name,
-       struct attrnames        **names,
-       int                     nnames)
-{
-       int                     i;
-
-       for (i = 0; i < nnames; i++)
-               if (!strncmp(name, names[i]->attr_name, names[i]->attr_namelen))
-                       return names[i];
-       return NULL;
-}
-
-/*
- * Some checks to prevent people abusing EAs to get over quota:
- * - Don't allow modifying user EAs on devices/symlinks;
- * - Don't allow modifying user EAs if sticky bit set;
- */
-STATIC int
-attr_user_capable(
-       struct vnode    *vp,
-       cred_t          *cred)
-{
-       struct inode    *inode = LINVFS_GET_IP(vp);
-
-       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
-               return -EPERM;
-       if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) &&
-           !capable(CAP_SYS_ADMIN))
-               return -EPERM;
-       if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
-           (current_fsuid(cred) != inode->i_uid) && !capable(CAP_FOWNER))
-               return -EPERM;
-       return 0;
-}
-
-STATIC int
-attr_trusted_capable(
-       struct vnode    *vp,
-       cred_t          *cred)
-{
-       struct inode    *inode = LINVFS_GET_IP(vp);
-
-       if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
-               return -EPERM;
-       if (!capable(CAP_SYS_ADMIN))
-               return -EPERM;
-       return 0;
-}
-
-STATIC int
-attr_secure_capable(
-       struct vnode    *vp,
-       cred_t          *cred)
-{
-       return -ENOSECURITY;
-}
-
-STATIC int
-attr_system_set(
-       struct vnode *vp, char *name, void *data, size_t size, int xflags)
-{
-       attrnames_t     *namesp;
-       int             error;
-
-       if (xflags & ATTR_CREATE)
-               return -EINVAL;
-
-       namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
-       if (!namesp)
-               return -EOPNOTSUPP;
-       error = namesp->attr_set(vp, name, data, size, xflags);
-       if (!error)
-               error = vn_revalidate(vp);
-       return error;
-}
-
-STATIC int
-attr_system_get(
-       struct vnode *vp, char *name, void *data, size_t size, int xflags)
-{
-       attrnames_t     *namesp;
-
-       namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
-       if (!namesp)
-               return -EOPNOTSUPP;
-       return namesp->attr_get(vp, name, data, size, xflags);
-}
-
-STATIC int
-attr_system_remove(
-       struct vnode *vp, char *name, int xflags)
-{
-       attrnames_t     *namesp;
-
-       namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
-       if (!namesp)
-               return -EOPNOTSUPP;
-       return namesp->attr_remove(vp, name, xflags);
-}
-
-struct attrnames attr_system = {
-       .attr_name      = "system.",
-       .attr_namelen   = sizeof("system.") - 1,
-       .attr_flag      = ATTR_SYSTEM,
-       .attr_get       = attr_system_get,
-       .attr_set       = attr_system_set,
-       .attr_remove    = attr_system_remove,
-       .attr_capable   = (attrcapable_t)fs_noerr,
-};
-
-struct attrnames attr_trusted = {
-       .attr_name      = "trusted.",
-       .attr_namelen   = sizeof("trusted.") - 1,
-       .attr_flag      = ATTR_ROOT,
-       .attr_get       = attr_generic_get,
-       .attr_set       = attr_generic_set,
-       .attr_remove    = attr_generic_remove,
-       .attr_capable   = attr_trusted_capable,
-};
-
-struct attrnames attr_secure = {
-       .attr_name      = "security.",
-       .attr_namelen   = sizeof("security.") - 1,
-       .attr_flag      = ATTR_SECURE,
-       .attr_get       = attr_generic_get,
-       .attr_set       = attr_generic_set,
-       .attr_remove    = attr_generic_remove,
-       .attr_capable   = attr_secure_capable,
-};
-
-struct attrnames attr_user = {
-       .attr_name      = "user.",
-       .attr_namelen   = sizeof("user.") - 1,
-       .attr_get       = attr_generic_get,
-       .attr_set       = attr_generic_set,
-       .attr_remove    = attr_generic_remove,
-       .attr_capable   = attr_user_capable,
-};
-
-struct attrnames *attr_namespaces[] =
-       { &attr_system, &attr_trusted, &attr_secure, &attr_user };