2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
35 #include "xfs_macros.h"
36 #include "xfs_types.h"
39 #include "xfs_trans.h"
44 #include "xfs_dmapi.h"
45 #include "xfs_mount.h"
46 #include "xfs_alloc_btree.h"
47 #include "xfs_bmap_btree.h"
48 #include "xfs_ialloc_btree.h"
49 #include "xfs_alloc.h"
50 #include "xfs_btree.h"
51 #include "xfs_attr_sf.h"
52 #include "xfs_dir_sf.h"
53 #include "xfs_dir2_sf.h"
54 #include "xfs_dinode.h"
55 #include "xfs_inode_item.h"
56 #include "xfs_inode.h"
58 #include "xfs_da_btree.h"
60 #include "xfs_attr_leaf.h"
61 #include "xfs_error.h"
63 #include "xfs_quota.h"
65 #include "xfs_trans_space.h"
71 * Provide the external interfaces to manage attribute lists.
74 /*========================================================================
75 * Function prototypes for the kernel.
76 *========================================================================*/
79 * Internal routines when attribute list fits inside the inode.
81 STATIC int xfs_attr_shortform_addname(xfs_da_args_t *args);
84 * Internal routines when attribute list is one block.
86 STATIC int xfs_attr_leaf_addname(xfs_da_args_t *args);
87 STATIC int xfs_attr_leaf_removename(xfs_da_args_t *args);
88 STATIC int xfs_attr_leaf_list(xfs_attr_list_context_t *context);
91 * Internal routines when attribute list is more than one block.
93 STATIC int xfs_attr_node_addname(xfs_da_args_t *args);
94 STATIC int xfs_attr_node_removename(xfs_da_args_t *args);
95 STATIC int xfs_attr_node_list(xfs_attr_list_context_t *context);
96 STATIC int xfs_attr_fillstate(xfs_da_state_t *state);
97 STATIC int xfs_attr_refillstate(xfs_da_state_t *state);
100 * Routines to manipulate out-of-line attribute values.
102 STATIC int xfs_attr_rmtval_get(xfs_da_args_t *args);
103 STATIC int xfs_attr_rmtval_set(xfs_da_args_t *args);
104 STATIC int xfs_attr_rmtval_remove(xfs_da_args_t *args);
106 #define ATTR_RMTVALUE_MAPSIZE 1 /* # of map entries at once */
107 #define ATTR_RMTVALUE_TRANSBLKS 8 /* max # of blks in a transaction */
109 #if defined(XFS_ATTR_TRACE)
110 ktrace_t *xfs_attr_trace_buf;
114 /*========================================================================
115 * Overall external interface routines.
116 *========================================================================*/
120 xfs_attr_get_int(xfs_inode_t *ip, char *name, char *value, int *valuelenp,
121 int flags, int lock, struct cred *cred)
127 ASSERT(MAXNAMELEN-1 <= 0xff); /* length is stored in uint8 */
128 namelen = strlen(name);
129 if (namelen >= MAXNAMELEN)
130 return(EFAULT); /* match IRIX behaviour */
131 XFS_STATS_INC(xs_attr_get);
133 if (XFS_FORCED_SHUTDOWN(ip->i_mount))
136 if ((XFS_IFORK_Q(ip) == 0) ||
137 (ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
138 ip->i_d.di_anextents == 0))
142 xfs_ilock(ip, XFS_ILOCK_SHARED);
144 * Do we answer them, or ignore them?
146 if ((error = xfs_iaccess(ip, S_IRUSR, cred))) {
147 xfs_iunlock(ip, XFS_ILOCK_SHARED);
148 return(XFS_ERROR(error));
153 * Fill in the arg structure for this request.
155 memset((char *)&args, 0, sizeof(args));
157 args.namelen = namelen;
159 args.valuelen = *valuelenp;
161 args.hashval = xfs_da_hashname(args.name, args.namelen);
163 args.whichfork = XFS_ATTR_FORK;
167 * Decide on what work routines to call based on the inode size.
169 if (XFS_IFORK_Q(ip) == 0 ||
170 (ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
171 ip->i_d.di_anextents == 0)) {
172 error = XFS_ERROR(ENOATTR);
173 } else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
174 error = xfs_attr_shortform_getvalue(&args);
175 } else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK)) {
176 error = xfs_attr_leaf_get(&args);
178 error = xfs_attr_node_get(&args);
182 xfs_iunlock(ip, XFS_ILOCK_SHARED);
185 * Return the number of bytes in the value to the caller.
187 *valuelenp = args.valuelen;
195 xfs_attr_fetch(xfs_inode_t *ip, char *name, char *value, int valuelen)
197 return xfs_attr_get_int(ip, name, value, &valuelen, ATTR_ROOT, 0, NULL);
201 xfs_attr_get(bhv_desc_t *bdp, char *name, char *value, int *valuelenp,
202 int flags, struct cred *cred)
204 xfs_inode_t *ip = XFS_BHVTOI(bdp);
208 return xfs_attr_get_int(ip, name, value, valuelenp, flags, 1, cred);
213 xfs_attr_set(bhv_desc_t *bdp, char *name, char *value, int valuelen, int flags,
218 xfs_fsblock_t firstblock;
219 xfs_bmap_free_t flist;
220 int error, err2, committed;
224 int rsvd = (flags & ATTR_ROOT) != 0;
227 ASSERT(MAXNAMELEN-1 <= 0xff); /* length is stored in uint8 */
228 namelen = strlen(name);
229 if (namelen >= MAXNAMELEN)
230 return EFAULT; /* match irix behaviour */
232 XFS_STATS_INC(xs_attr_set);
234 * Do we answer them, or ignore them?
236 dp = XFS_BHVTOI(bdp);
238 if (XFS_FORCED_SHUTDOWN(mp))
241 xfs_ilock(dp, XFS_ILOCK_SHARED);
242 if ((error = xfs_iaccess(dp, S_IWUSR, cred))) {
243 xfs_iunlock(dp, XFS_ILOCK_SHARED);
244 return(XFS_ERROR(error));
246 xfs_iunlock(dp, XFS_ILOCK_SHARED);
249 * Attach the dquots to the inode.
251 if ((error = XFS_QM_DQATTACH(mp, dp, 0)))
255 * If the inode doesn't have an attribute fork, add one.
256 * (inode must not be locked when we call this routine)
258 if (XFS_IFORK_Q(dp) == 0) {
259 error = xfs_bmap_add_attrfork(dp, rsvd);
265 * Fill in the arg structure for this request.
267 memset((char *)&args, 0, sizeof(args));
269 args.namelen = namelen;
271 args.valuelen = valuelen;
273 args.hashval = xfs_da_hashname(args.name, args.namelen);
275 args.firstblock = &firstblock;
277 args.whichfork = XFS_ATTR_FORK;
280 /* Determine space new attribute will use, and if it will be inline
283 size = xfs_attr_leaf_newentsize(&args, mp->m_sb.sb_blocksize, &local);
285 nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
287 if (size > (mp->m_sb.sb_blocksize >> 1)) {
288 /* Double split possible */
292 uint dblocks = XFS_B_TO_FSB(mp, valuelen);
293 /* Out of line attribute, cannot double split, but make
294 * room for the attribute value itself.
297 nblks += XFS_NEXTENTADD_SPACE_RES(mp, dblocks, XFS_ATTR_FORK);
300 /* Size is now blocks for attribute data */
304 * Start our first transaction of the day.
306 * All future transactions during this code must be "chained" off
307 * this one via the trans_dup() call. All transactions will contain
308 * the inode, and the inode will always be marked with trans_ihold().
309 * Since the inode will be locked in all transactions, we must log
310 * the inode in every transaction to let it float upward through
313 args.trans = xfs_trans_alloc(mp, XFS_TRANS_ATTR_SET);
316 * Root fork attributes can use reserved data blocks for this
317 * operation if necessary
321 args.trans->t_flags |= XFS_TRANS_RESERVE;
323 if ((error = xfs_trans_reserve(args.trans, (uint) nblks,
324 XFS_ATTRSET_LOG_RES(mp, nblks),
325 0, XFS_TRANS_PERM_LOG_RES,
326 XFS_ATTRSET_LOG_COUNT))) {
327 xfs_trans_cancel(args.trans, 0);
330 xfs_ilock(dp, XFS_ILOCK_EXCL);
332 error = XFS_TRANS_RESERVE_QUOTA_NBLKS(mp, args.trans, dp, nblks, 0,
333 rsvd ? XFS_QMOPT_RES_REGBLKS | XFS_QMOPT_FORCE_RES :
334 XFS_QMOPT_RES_REGBLKS);
336 xfs_iunlock(dp, XFS_ILOCK_EXCL);
337 xfs_trans_cancel(args.trans, XFS_TRANS_RELEASE_LOG_RES);
341 xfs_trans_ijoin(args.trans, dp, XFS_ILOCK_EXCL);
342 xfs_trans_ihold(args.trans, dp);
345 * If the attribute list is non-existant or a shortform list,
346 * upgrade it to a single-leaf-block attribute list.
348 if ((dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) ||
349 ((dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS) &&
350 (dp->i_d.di_anextents == 0))) {
353 * Build initial attribute list (if required).
355 if (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS)
356 (void)xfs_attr_shortform_create(&args);
359 * Try to add the attr to the attribute list in
362 error = xfs_attr_shortform_addname(&args);
363 if (error != ENOSPC) {
365 * Commit the shortform mods, and we're done.
366 * NOTE: this is also the error path (EEXIST, etc).
368 ASSERT(args.trans != NULL);
371 * If this is a synchronous mount, make sure that
372 * the transaction goes to disk before returning
375 if (mp->m_flags & XFS_MOUNT_WSYNC) {
376 xfs_trans_set_sync(args.trans);
378 err2 = xfs_trans_commit(args.trans,
379 XFS_TRANS_RELEASE_LOG_RES,
381 xfs_iunlock(dp, XFS_ILOCK_EXCL);
384 * Hit the inode change time.
386 if (!error && (flags & ATTR_KERNOTIME) == 0) {
387 xfs_ichgtime(dp, XFS_ICHGTIME_CHG);
389 return(error == 0 ? err2 : error);
393 * It won't fit in the shortform, transform to a leaf block.
394 * GROT: another possible req'mt for a double-split btree op.
396 XFS_BMAP_INIT(args.flist, args.firstblock);
397 error = xfs_attr_shortform_to_leaf(&args);
399 error = xfs_bmap_finish(&args.trans, args.flist,
400 *args.firstblock, &committed);
405 xfs_bmap_cancel(&flist);
410 * bmap_finish() may have committed the last trans and started
411 * a new one. We need the inode to be in all transactions.
414 xfs_trans_ijoin(args.trans, dp, XFS_ILOCK_EXCL);
415 xfs_trans_ihold(args.trans, dp);
419 * Commit the leaf transformation. We'll need another (linked)
420 * transaction to add the new attribute to the leaf.
422 if ((error = xfs_attr_rolltrans(&args.trans, dp)))
427 if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) {
428 error = xfs_attr_leaf_addname(&args);
430 error = xfs_attr_node_addname(&args);
437 * If this is a synchronous mount, make sure that the
438 * transaction goes to disk before returning to the user.
440 if (mp->m_flags & XFS_MOUNT_WSYNC) {
441 xfs_trans_set_sync(args.trans);
445 * Commit the last in the sequence of transactions.
447 xfs_trans_log_inode(args.trans, dp, XFS_ILOG_CORE);
448 error = xfs_trans_commit(args.trans, XFS_TRANS_RELEASE_LOG_RES,
450 xfs_iunlock(dp, XFS_ILOCK_EXCL);
453 * Hit the inode change time.
455 if (!error && (flags & ATTR_KERNOTIME) == 0) {
456 xfs_ichgtime(dp, XFS_ICHGTIME_CHG);
463 xfs_trans_cancel(args.trans,
464 XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);
465 xfs_iunlock(dp, XFS_ILOCK_EXCL);
470 * Generic handler routine to remove a name from an attribute list.
471 * Transitions attribute list from Btree to shortform as necessary.
475 xfs_attr_remove(bhv_desc_t *bdp, char *name, int flags, struct cred *cred)
479 xfs_fsblock_t firstblock;
480 xfs_bmap_free_t flist;
485 ASSERT(MAXNAMELEN-1<=0xff); /* length is stored in uint8 */
486 namelen = strlen(name);
487 if (namelen>=MAXNAMELEN)
488 return EFAULT; /* match irix behaviour */
490 XFS_STATS_INC(xs_attr_remove);
493 * Do we answer them, or ignore them?
495 dp = XFS_BHVTOI(bdp);
497 if (XFS_FORCED_SHUTDOWN(mp))
500 xfs_ilock(dp, XFS_ILOCK_SHARED);
501 if ((error = xfs_iaccess(dp, S_IWUSR, cred))) {
502 xfs_iunlock(dp, XFS_ILOCK_SHARED);
503 return(XFS_ERROR(error));
504 } else if (XFS_IFORK_Q(dp) == 0 ||
505 (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
506 dp->i_d.di_anextents == 0)) {
507 xfs_iunlock(dp, XFS_ILOCK_SHARED);
508 return(XFS_ERROR(ENOATTR));
510 xfs_iunlock(dp, XFS_ILOCK_SHARED);
513 * Fill in the arg structure for this request.
515 memset((char *)&args, 0, sizeof(args));
517 args.namelen = namelen;
519 args.hashval = xfs_da_hashname(args.name, args.namelen);
521 args.firstblock = &firstblock;
524 args.whichfork = XFS_ATTR_FORK;
527 * Attach the dquots to the inode.
529 if ((error = XFS_QM_DQATTACH(mp, dp, 0)))
533 * Start our first transaction of the day.
535 * All future transactions during this code must be "chained" off
536 * this one via the trans_dup() call. All transactions will contain
537 * the inode, and the inode will always be marked with trans_ihold().
538 * Since the inode will be locked in all transactions, we must log
539 * the inode in every transaction to let it float upward through
542 args.trans = xfs_trans_alloc(mp, XFS_TRANS_ATTR_RM);
545 * Root fork attributes can use reserved data blocks for this
546 * operation if necessary
549 if (flags & ATTR_ROOT)
550 args.trans->t_flags |= XFS_TRANS_RESERVE;
552 if ((error = xfs_trans_reserve(args.trans,
553 XFS_ATTRRM_SPACE_RES(mp),
554 XFS_ATTRRM_LOG_RES(mp),
555 0, XFS_TRANS_PERM_LOG_RES,
556 XFS_ATTRRM_LOG_COUNT))) {
557 xfs_trans_cancel(args.trans, 0);
562 xfs_ilock(dp, XFS_ILOCK_EXCL);
564 * No need to make quota reservations here. We expect to release some
565 * blocks not allocate in the common case.
567 xfs_trans_ijoin(args.trans, dp, XFS_ILOCK_EXCL);
568 xfs_trans_ihold(args.trans, dp);
571 * Decide on what work routines to call based on the inode size.
573 if (XFS_IFORK_Q(dp) == 0 ||
574 (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
575 dp->i_d.di_anextents == 0)) {
576 error = XFS_ERROR(ENOATTR);
579 if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
580 ASSERT(dp->i_afp->if_flags & XFS_IFINLINE);
581 error = xfs_attr_shortform_remove(&args);
585 } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) {
586 error = xfs_attr_leaf_removename(&args);
588 error = xfs_attr_node_removename(&args);
595 * If this is a synchronous mount, make sure that the
596 * transaction goes to disk before returning to the user.
598 if (mp->m_flags & XFS_MOUNT_WSYNC) {
599 xfs_trans_set_sync(args.trans);
603 * Commit the last in the sequence of transactions.
605 xfs_trans_log_inode(args.trans, dp, XFS_ILOG_CORE);
606 error = xfs_trans_commit(args.trans, XFS_TRANS_RELEASE_LOG_RES,
608 xfs_iunlock(dp, XFS_ILOCK_EXCL);
611 * Hit the inode change time.
613 if (!error && (flags & ATTR_KERNOTIME) == 0) {
614 xfs_ichgtime(dp, XFS_ICHGTIME_CHG);
621 xfs_trans_cancel(args.trans,
622 XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);
623 xfs_iunlock(dp, XFS_ILOCK_EXCL);
628 * Generate a list of extended attribute names and optionally
629 * also value lengths. Positive return value follows the XFS
630 * convention of being an error, zero or negative return code
631 * is the length of the buffer returned (negated), indicating
635 xfs_attr_list(bhv_desc_t *bdp, char *buffer, int bufsize, int flags,
636 attrlist_cursor_kern_t *cursor, struct cred *cred)
638 xfs_attr_list_context_t context;
642 XFS_STATS_INC(xs_attr_list);
645 * Validate the cursor.
647 if (cursor->pad1 || cursor->pad2)
648 return(XFS_ERROR(EINVAL));
649 if ((cursor->initted == 0) &&
650 (cursor->hashval || cursor->blkno || cursor->offset))
651 return(XFS_ERROR(EINVAL));
654 * Check for a properly aligned buffer.
656 if (((long)buffer) & (sizeof(int)-1))
657 return(XFS_ERROR(EFAULT));
658 if (flags & ATTR_KERNOVAL)
662 * Initialize the output buffer.
664 context.dp = dp = XFS_BHVTOI(bdp);
665 context.cursor = cursor;
669 context.flags = flags;
670 if (!(flags & ATTR_KERNAMELS)) {
671 context.bufsize = (bufsize & ~(sizeof(int)-1)); /* align */
672 context.firstu = context.bufsize;
673 context.alist = (attrlist_t *)buffer;
674 context.alist->al_count = 0;
675 context.alist->al_more = 0;
676 context.alist->al_offset[0] = context.bufsize;
679 context.bufsize = bufsize;
680 context.firstu = context.bufsize;
681 context.alist = (attrlist_t *)buffer;
684 if (XFS_FORCED_SHUTDOWN(dp->i_mount))
687 * Do they have permission?
689 xfs_ilock(dp, XFS_ILOCK_SHARED);
690 if ((error = xfs_iaccess(dp, S_IRUSR, cred))) {
691 xfs_iunlock(dp, XFS_ILOCK_SHARED);
692 return(XFS_ERROR(error));
696 * Decide on what work routines to call based on the inode size.
698 xfs_attr_trace_l_c("syscall start", &context);
699 if (XFS_IFORK_Q(dp) == 0 ||
700 (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
701 dp->i_d.di_anextents == 0)) {
703 } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
704 error = xfs_attr_shortform_list(&context);
705 } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) {
706 error = xfs_attr_leaf_list(&context);
708 error = xfs_attr_node_list(&context);
710 xfs_iunlock(dp, XFS_ILOCK_SHARED);
711 xfs_attr_trace_l_c("syscall end", &context);
713 if (!(context.flags & (ATTR_KERNOVAL|ATTR_KERNAMELS))) {
716 else { /* must return negated buffer size or the error */
717 if (context.count < 0)
718 error = XFS_ERROR(ERANGE);
720 error = -context.count;
727 xfs_attr_inactive(xfs_inode_t *dp)
734 ASSERT(! XFS_NOT_DQATTACHED(mp, dp));
736 /* XXXsup - why on earth are we taking ILOCK_EXCL here??? */
737 xfs_ilock(dp, XFS_ILOCK_EXCL);
738 if ((XFS_IFORK_Q(dp) == 0) ||
739 (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) ||
740 (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
741 dp->i_d.di_anextents == 0)) {
742 xfs_iunlock(dp, XFS_ILOCK_EXCL);
745 xfs_iunlock(dp, XFS_ILOCK_EXCL);
748 * Start our first transaction of the day.
750 * All future transactions during this code must be "chained" off
751 * this one via the trans_dup() call. All transactions will contain
752 * the inode, and the inode will always be marked with trans_ihold().
753 * Since the inode will be locked in all transactions, we must log
754 * the inode in every transaction to let it float upward through
757 trans = xfs_trans_alloc(mp, XFS_TRANS_ATTRINVAL);
758 if ((error = xfs_trans_reserve(trans, 0, XFS_ATTRINVAL_LOG_RES(mp), 0,
759 XFS_TRANS_PERM_LOG_RES,
760 XFS_ATTRINVAL_LOG_COUNT))) {
761 xfs_trans_cancel(trans, 0);
764 xfs_ilock(dp, XFS_ILOCK_EXCL);
767 * No need to make quota reservations here. We expect to release some
768 * blocks, not allocate, in the common case.
770 xfs_trans_ijoin(trans, dp, XFS_ILOCK_EXCL);
771 xfs_trans_ihold(trans, dp);
774 * Decide on what work routines to call based on the inode size.
776 if ((XFS_IFORK_Q(dp) == 0) ||
777 (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) ||
778 (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
779 dp->i_d.di_anextents == 0)) {
783 error = xfs_attr_root_inactive(&trans, dp);
787 * signal synchronous inactive transactions unless this
788 * is a synchronous mount filesystem in which case we
789 * know that we're here because we've been called out of
790 * xfs_inactive which means that the last reference is gone
791 * and the unlink transaction has already hit the disk so
792 * async inactive transactions are safe.
794 if ((error = xfs_itruncate_finish(&trans, dp, 0LL, XFS_ATTR_FORK,
795 (!(mp->m_flags & XFS_MOUNT_WSYNC)
800 * Commit the last in the sequence of transactions.
802 xfs_trans_log_inode(trans, dp, XFS_ILOG_CORE);
803 error = xfs_trans_commit(trans, XFS_TRANS_RELEASE_LOG_RES,
805 xfs_iunlock(dp, XFS_ILOCK_EXCL);
810 xfs_trans_cancel(trans, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT);
811 xfs_iunlock(dp, XFS_ILOCK_EXCL);
817 /*========================================================================
818 * External routines when attribute list is inside the inode
819 *========================================================================*/
822 * Add a name to the shortform attribute list structure
823 * This is the external routine.
826 xfs_attr_shortform_addname(xfs_da_args_t *args)
830 retval = xfs_attr_shortform_lookup(args);
831 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
833 } else if (retval == EEXIST) {
834 if (args->flags & ATTR_CREATE)
836 retval = xfs_attr_shortform_remove(args);
840 newsize = XFS_ATTR_SF_TOTSIZE(args->dp);
841 newsize += XFS_ATTR_SF_ENTSIZE_BYNAME(args->namelen, args->valuelen);
842 if ((newsize <= XFS_IFORK_ASIZE(args->dp)) &&
843 (args->namelen < XFS_ATTR_SF_ENTSIZE_MAX) &&
844 (args->valuelen < XFS_ATTR_SF_ENTSIZE_MAX)) {
845 retval = xfs_attr_shortform_add(args);
848 return(XFS_ERROR(ENOSPC));
854 /*========================================================================
855 * External routines when attribute list is one block
856 *========================================================================*/
859 * Add a name to the leaf attribute list structure
861 * This leaf block cannot have a "remote" value, we only call this routine
862 * if bmap_one_block() says there is only one block (ie: no remote blks).
865 xfs_attr_leaf_addname(xfs_da_args_t *args)
869 int retval, error, committed;
872 * Read the (only) block in the attribute list in.
876 error = xfs_da_read_buf(args->trans, args->dp, args->blkno, -1, &bp,
883 * Look up the given attribute in the leaf block. Figure out if
884 * the given flags produce an error or call for an atomic rename.
886 retval = xfs_attr_leaf_lookup_int(bp, args);
887 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
888 xfs_da_brelse(args->trans, bp);
890 } else if (retval == EEXIST) {
891 if (args->flags & ATTR_CREATE) { /* pure create op */
892 xfs_da_brelse(args->trans, bp);
895 args->rename = 1; /* an atomic rename */
896 args->blkno2 = args->blkno; /* set 2nd entry info*/
897 args->index2 = args->index;
898 args->rmtblkno2 = args->rmtblkno;
899 args->rmtblkcnt2 = args->rmtblkcnt;
903 * Add the attribute to the leaf block, transitioning to a Btree
906 retval = xfs_attr_leaf_add(bp, args);
908 if (retval == ENOSPC) {
910 * Promote the attribute list to the Btree format, then
911 * Commit that transaction so that the node_addname() call
912 * can manage its own transactions.
914 XFS_BMAP_INIT(args->flist, args->firstblock);
915 error = xfs_attr_leaf_to_node(args);
917 error = xfs_bmap_finish(&args->trans, args->flist,
918 *args->firstblock, &committed);
923 xfs_bmap_cancel(args->flist);
928 * bmap_finish() may have committed the last trans and started
929 * a new one. We need the inode to be in all transactions.
932 xfs_trans_ijoin(args->trans, dp, XFS_ILOCK_EXCL);
933 xfs_trans_ihold(args->trans, dp);
937 * Commit the current trans (including the inode) and start
940 if ((error = xfs_attr_rolltrans(&args->trans, dp)))
944 * Fob the whole rest of the problem off on the Btree code.
946 error = xfs_attr_node_addname(args);
951 * Commit the transaction that added the attr name so that
952 * later routines can manage their own transactions.
954 if ((error = xfs_attr_rolltrans(&args->trans, dp)))
958 * If there was an out-of-line value, allocate the blocks we
959 * identified for its storage and copy the value. This is done
960 * after we create the attribute so that we don't overflow the
961 * maximum size of a transaction and/or hit a deadlock.
963 if (args->rmtblkno > 0) {
964 error = xfs_attr_rmtval_set(args);
970 * If this is an atomic rename operation, we must "flip" the
971 * incomplete flags on the "new" and "old" attribute/value pairs
972 * so that one disappears and one appears atomically. Then we
973 * must remove the "old" attribute/value pair.
977 * In a separate transaction, set the incomplete flag on the
978 * "old" attr and clear the incomplete flag on the "new" attr.
980 error = xfs_attr_leaf_flipflags(args);
985 * Dismantle the "old" attribute/value pair by removing
986 * a "remote" value (if it exists).
988 args->index = args->index2;
989 args->blkno = args->blkno2;
990 args->rmtblkno = args->rmtblkno2;
991 args->rmtblkcnt = args->rmtblkcnt2;
992 if (args->rmtblkno) {
993 error = xfs_attr_rmtval_remove(args);
999 * Read in the block containing the "old" attr, then
1000 * remove the "old" attr from that block (neat, huh!)
1002 error = xfs_da_read_buf(args->trans, args->dp, args->blkno, -1,
1003 &bp, XFS_ATTR_FORK);
1007 (void)xfs_attr_leaf_remove(bp, args);
1010 * If the result is small enough, shrink it all into the inode.
1012 if (xfs_attr_shortform_allfit(bp, dp)) {
1013 XFS_BMAP_INIT(args->flist, args->firstblock);
1014 error = xfs_attr_leaf_to_shortform(bp, args);
1015 /* bp is gone due to xfs_da_shrink_inode */
1017 error = xfs_bmap_finish(&args->trans,
1025 xfs_bmap_cancel(args->flist);
1030 * bmap_finish() may have committed the last trans
1031 * and started a new one. We need the inode to be
1032 * in all transactions.
1035 xfs_trans_ijoin(args->trans, dp, XFS_ILOCK_EXCL);
1036 xfs_trans_ihold(args->trans, dp);
1039 xfs_da_buf_done(bp);
1042 * Commit the remove and start the next trans in series.
1044 error = xfs_attr_rolltrans(&args->trans, dp);
1046 } else if (args->rmtblkno > 0) {
1048 * Added a "remote" value, just clear the incomplete flag.
1050 error = xfs_attr_leaf_clearflag(args);
1056 * Remove a name from the leaf attribute list structure
1058 * This leaf block cannot have a "remote" value, we only call this routine
1059 * if bmap_one_block() says there is only one block (ie: no remote blks).
1062 xfs_attr_leaf_removename(xfs_da_args_t *args)
1070 * Remove the attribute.
1074 error = xfs_da_read_buf(args->trans, args->dp, args->blkno, -1, &bp,
1081 error = xfs_attr_leaf_lookup_int(bp, args);
1082 if (error == ENOATTR) {
1083 xfs_da_brelse(args->trans, bp);
1087 (void)xfs_attr_leaf_remove(bp, args);
1090 * If the result is small enough, shrink it all into the inode.
1092 if (xfs_attr_shortform_allfit(bp, dp)) {
1093 XFS_BMAP_INIT(args->flist, args->firstblock);
1094 error = xfs_attr_leaf_to_shortform(bp, args);
1095 /* bp is gone due to xfs_da_shrink_inode */
1097 error = xfs_bmap_finish(&args->trans, args->flist,
1098 *args->firstblock, &committed);
1103 xfs_bmap_cancel(args->flist);
1108 * bmap_finish() may have committed the last trans and started
1109 * a new one. We need the inode to be in all transactions.
1112 xfs_trans_ijoin(args->trans, dp, XFS_ILOCK_EXCL);
1113 xfs_trans_ihold(args->trans, dp);
1116 xfs_da_buf_done(bp);
1121 * Look up a name in a leaf attribute list structure.
1123 * This leaf block cannot have a "remote" value, we only call this routine
1124 * if bmap_one_block() says there is only one block (ie: no remote blks).
1127 xfs_attr_leaf_get(xfs_da_args_t *args)
1133 error = xfs_da_read_buf(args->trans, args->dp, args->blkno, -1, &bp,
1139 error = xfs_attr_leaf_lookup_int(bp, args);
1140 if (error != EEXIST) {
1141 xfs_da_brelse(args->trans, bp);
1144 error = xfs_attr_leaf_getvalue(bp, args);
1145 xfs_da_brelse(args->trans, bp);
1146 if (!error && (args->rmtblkno > 0) && !(args->flags & ATTR_KERNOVAL)) {
1147 error = xfs_attr_rmtval_get(args);
1153 * Copy out attribute entries for attr_list(), for leaf attribute lists.
1156 xfs_attr_leaf_list(xfs_attr_list_context_t *context)
1158 xfs_attr_leafblock_t *leaf;
1162 context->cursor->blkno = 0;
1163 error = xfs_da_read_buf(NULL, context->dp, 0, -1, &bp, XFS_ATTR_FORK);
1168 if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
1169 != XFS_ATTR_LEAF_MAGIC)) {
1170 XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW,
1171 context->dp->i_mount, leaf);
1172 xfs_da_brelse(NULL, bp);
1173 return(XFS_ERROR(EFSCORRUPTED));
1176 (void)xfs_attr_leaf_list_int(bp, context);
1177 xfs_da_brelse(NULL, bp);
1182 /*========================================================================
1183 * External routines when attribute list size > XFS_LBSIZE(mp).
1184 *========================================================================*/
1187 * Add a name to a Btree-format attribute list.
1189 * This will involve walking down the Btree, and may involve splitting
1190 * leaf nodes and even splitting intermediate nodes up to and including
1191 * the root node (a special case of an intermediate node).
1193 * "Remote" attribute values confuse the issue and atomic rename operations
1194 * add a whole extra layer of confusion on top of that.
1197 xfs_attr_node_addname(xfs_da_args_t *args)
1199 xfs_da_state_t *state;
1200 xfs_da_state_blk_t *blk;
1203 int committed, retval, error;
1206 * Fill in bucket of arguments/results/context to carry around.
1211 state = xfs_da_state_alloc();
1214 state->blocksize = state->mp->m_sb.sb_blocksize;
1215 state->node_ents = state->mp->m_attr_node_ents;
1218 * Search to see if name already exists, and get back a pointer
1219 * to where it should go.
1221 error = xfs_da_node_lookup_int(state, &retval);
1224 blk = &state->path.blk[ state->path.active-1 ];
1225 ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
1226 if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) {
1228 } else if (retval == EEXIST) {
1229 if (args->flags & ATTR_CREATE)
1231 args->rename = 1; /* atomic rename op */
1232 args->blkno2 = args->blkno; /* set 2nd entry info*/
1233 args->index2 = args->index;
1234 args->rmtblkno2 = args->rmtblkno;
1235 args->rmtblkcnt2 = args->rmtblkcnt;
1237 args->rmtblkcnt = 0;
1240 retval = xfs_attr_leaf_add(blk->bp, state->args);
1241 if (retval == ENOSPC) {
1242 if (state->path.active == 1) {
1244 * Its really a single leaf node, but it had
1245 * out-of-line values so it looked like it *might*
1246 * have been a b-tree.
1248 xfs_da_state_free(state);
1249 XFS_BMAP_INIT(args->flist, args->firstblock);
1250 error = xfs_attr_leaf_to_node(args);
1252 error = xfs_bmap_finish(&args->trans,
1260 xfs_bmap_cancel(args->flist);
1265 * bmap_finish() may have committed the last trans
1266 * and started a new one. We need the inode to be
1267 * in all transactions.
1270 xfs_trans_ijoin(args->trans, dp, XFS_ILOCK_EXCL);
1271 xfs_trans_ihold(args->trans, dp);
1275 * Commit the node conversion and start the next
1276 * trans in the chain.
1278 if ((error = xfs_attr_rolltrans(&args->trans, dp)))
1285 * Split as many Btree elements as required.
1286 * This code tracks the new and old attr's location
1287 * in the index/blkno/rmtblkno/rmtblkcnt fields and
1288 * in the index2/blkno2/rmtblkno2/rmtblkcnt2 fields.
1290 XFS_BMAP_INIT(args->flist, args->firstblock);
1291 error = xfs_da_split(state);
1293 error = xfs_bmap_finish(&args->trans, args->flist,
1294 *args->firstblock, &committed);
1299 xfs_bmap_cancel(args->flist);
1304 * bmap_finish() may have committed the last trans and started
1305 * a new one. We need the inode to be in all transactions.
1308 xfs_trans_ijoin(args->trans, dp, XFS_ILOCK_EXCL);
1309 xfs_trans_ihold(args->trans, dp);
1313 * Addition succeeded, update Btree hashvals.
1315 xfs_da_fixhashpath(state, &state->path);
1319 * Kill the state structure, we're done with it and need to
1320 * allow the buffers to come back later.
1322 xfs_da_state_free(state);
1326 * Commit the leaf addition or btree split and start the next
1327 * trans in the chain.
1329 if ((error = xfs_attr_rolltrans(&args->trans, dp)))
1333 * If there was an out-of-line value, allocate the blocks we
1334 * identified for its storage and copy the value. This is done
1335 * after we create the attribute so that we don't overflow the
1336 * maximum size of a transaction and/or hit a deadlock.
1338 if (args->rmtblkno > 0) {
1339 error = xfs_attr_rmtval_set(args);
1345 * If this is an atomic rename operation, we must "flip" the
1346 * incomplete flags on the "new" and "old" attribute/value pairs
1347 * so that one disappears and one appears atomically. Then we
1348 * must remove the "old" attribute/value pair.
1352 * In a separate transaction, set the incomplete flag on the
1353 * "old" attr and clear the incomplete flag on the "new" attr.
1355 error = xfs_attr_leaf_flipflags(args);
1360 * Dismantle the "old" attribute/value pair by removing
1361 * a "remote" value (if it exists).
1363 args->index = args->index2;
1364 args->blkno = args->blkno2;
1365 args->rmtblkno = args->rmtblkno2;
1366 args->rmtblkcnt = args->rmtblkcnt2;
1367 if (args->rmtblkno) {
1368 error = xfs_attr_rmtval_remove(args);
1374 * Re-find the "old" attribute entry after any split ops.
1375 * The INCOMPLETE flag means that we will find the "old"
1376 * attr, not the "new" one.
1378 args->flags |= XFS_ATTR_INCOMPLETE;
1379 state = xfs_da_state_alloc();
1382 state->blocksize = state->mp->m_sb.sb_blocksize;
1383 state->node_ents = state->mp->m_attr_node_ents;
1385 error = xfs_da_node_lookup_int(state, &retval);
1390 * Remove the name and update the hashvals in the tree.
1392 blk = &state->path.blk[ state->path.active-1 ];
1393 ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
1394 error = xfs_attr_leaf_remove(blk->bp, args);
1395 xfs_da_fixhashpath(state, &state->path);
1398 * Check to see if the tree needs to be collapsed.
1400 if (retval && (state->path.active > 1)) {
1401 XFS_BMAP_INIT(args->flist, args->firstblock);
1402 error = xfs_da_join(state);
1404 error = xfs_bmap_finish(&args->trans,
1412 xfs_bmap_cancel(args->flist);
1417 * bmap_finish() may have committed the last trans
1418 * and started a new one. We need the inode to be
1419 * in all transactions.
1422 xfs_trans_ijoin(args->trans, dp, XFS_ILOCK_EXCL);
1423 xfs_trans_ihold(args->trans, dp);
1428 * Commit and start the next trans in the chain.
1430 if ((error = xfs_attr_rolltrans(&args->trans, dp)))
1433 } else if (args->rmtblkno > 0) {
1435 * Added a "remote" value, just clear the incomplete flag.
1437 error = xfs_attr_leaf_clearflag(args);
1445 xfs_da_state_free(state);
1452 * Remove a name from a B-tree attribute list.
1454 * This will involve walking down the Btree, and may involve joining
1455 * leaf nodes and even joining intermediate nodes up to and including
1456 * the root node (a special case of an intermediate node).
1459 xfs_attr_node_removename(xfs_da_args_t *args)
1461 xfs_da_state_t *state;
1462 xfs_da_state_blk_t *blk;
1465 int retval, error, committed;
1468 * Tie a string around our finger to remind us where we are.
1471 state = xfs_da_state_alloc();
1473 state->mp = dp->i_mount;
1474 state->blocksize = state->mp->m_sb.sb_blocksize;
1475 state->node_ents = state->mp->m_attr_node_ents;
1478 * Search to see if name exists, and get back a pointer to it.
1480 error = xfs_da_node_lookup_int(state, &retval);
1481 if (error || (retval != EEXIST)) {
1488 * If there is an out-of-line value, de-allocate the blocks.
1489 * This is done before we remove the attribute so that we don't
1490 * overflow the maximum size of a transaction and/or hit a deadlock.
1492 blk = &state->path.blk[ state->path.active-1 ];
1493 ASSERT(blk->bp != NULL);
1494 ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
1495 if (args->rmtblkno > 0) {
1497 * Fill in disk block numbers in the state structure
1498 * so that we can get the buffers back after we commit
1499 * several transactions in the following calls.
1501 error = xfs_attr_fillstate(state);
1506 * Mark the attribute as INCOMPLETE, then bunmapi() the
1509 error = xfs_attr_leaf_setflag(args);
1512 error = xfs_attr_rmtval_remove(args);
1517 * Refill the state structure with buffers, the prior calls
1518 * released our buffers.
1520 error = xfs_attr_refillstate(state);
1526 * Remove the name and update the hashvals in the tree.
1528 blk = &state->path.blk[ state->path.active-1 ];
1529 ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
1530 retval = xfs_attr_leaf_remove(blk->bp, args);
1531 xfs_da_fixhashpath(state, &state->path);
1534 * Check to see if the tree needs to be collapsed.
1536 if (retval && (state->path.active > 1)) {
1537 XFS_BMAP_INIT(args->flist, args->firstblock);
1538 error = xfs_da_join(state);
1540 error = xfs_bmap_finish(&args->trans, args->flist,
1541 *args->firstblock, &committed);
1546 xfs_bmap_cancel(args->flist);
1551 * bmap_finish() may have committed the last trans and started
1552 * a new one. We need the inode to be in all transactions.
1555 xfs_trans_ijoin(args->trans, dp, XFS_ILOCK_EXCL);
1556 xfs_trans_ihold(args->trans, dp);
1560 * Commit the Btree join operation and start a new trans.
1562 if ((error = xfs_attr_rolltrans(&args->trans, dp)))
1567 * If the result is small enough, push it all into the inode.
1569 if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) {
1571 * Have to get rid of the copy of this dabuf in the state.
1573 ASSERT(state->path.active == 1);
1574 ASSERT(state->path.blk[0].bp);
1575 xfs_da_buf_done(state->path.blk[0].bp);
1576 state->path.blk[0].bp = NULL;
1578 error = xfs_da_read_buf(args->trans, args->dp, 0, -1, &bp,
1582 ASSERT(INT_GET(((xfs_attr_leafblock_t *)
1583 bp->data)->hdr.info.magic, ARCH_CONVERT)
1584 == XFS_ATTR_LEAF_MAGIC);
1586 if (xfs_attr_shortform_allfit(bp, dp)) {
1587 XFS_BMAP_INIT(args->flist, args->firstblock);
1588 error = xfs_attr_leaf_to_shortform(bp, args);
1589 /* bp is gone due to xfs_da_shrink_inode */
1591 error = xfs_bmap_finish(&args->trans,
1599 xfs_bmap_cancel(args->flist);
1604 * bmap_finish() may have committed the last trans
1605 * and started a new one. We need the inode to be
1606 * in all transactions.
1609 xfs_trans_ijoin(args->trans, dp, XFS_ILOCK_EXCL);
1610 xfs_trans_ihold(args->trans, dp);
1613 xfs_da_brelse(args->trans, bp);
1618 xfs_da_state_free(state);
1623 * Fill in the disk block numbers in the state structure for the buffers
1624 * that are attached to the state structure.
1625 * This is done so that we can quickly reattach ourselves to those buffers
1626 * after some set of transaction commit's has released these buffers.
1629 xfs_attr_fillstate(xfs_da_state_t *state)
1631 xfs_da_state_path_t *path;
1632 xfs_da_state_blk_t *blk;
1636 * Roll down the "path" in the state structure, storing the on-disk
1637 * block number for those buffers in the "path".
1639 path = &state->path;
1640 ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
1641 for (blk = path->blk, level = 0; level < path->active; blk++, level++) {
1643 blk->disk_blkno = xfs_da_blkno(blk->bp);
1644 xfs_da_buf_done(blk->bp);
1647 blk->disk_blkno = 0;
1652 * Roll down the "altpath" in the state structure, storing the on-disk
1653 * block number for those buffers in the "altpath".
1655 path = &state->altpath;
1656 ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
1657 for (blk = path->blk, level = 0; level < path->active; blk++, level++) {
1659 blk->disk_blkno = xfs_da_blkno(blk->bp);
1660 xfs_da_buf_done(blk->bp);
1663 blk->disk_blkno = 0;
1671 * Reattach the buffers to the state structure based on the disk block
1672 * numbers stored in the state structure.
1673 * This is done after some set of transaction commit's has released those
1674 * buffers from our grip.
1677 xfs_attr_refillstate(xfs_da_state_t *state)
1679 xfs_da_state_path_t *path;
1680 xfs_da_state_blk_t *blk;
1684 * Roll down the "path" in the state structure, storing the on-disk
1685 * block number for those buffers in the "path".
1687 path = &state->path;
1688 ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
1689 for (blk = path->blk, level = 0; level < path->active; blk++, level++) {
1690 if (blk->disk_blkno) {
1691 error = xfs_da_read_buf(state->args->trans,
1693 blk->blkno, blk->disk_blkno,
1694 &blk->bp, XFS_ATTR_FORK);
1703 * Roll down the "altpath" in the state structure, storing the on-disk
1704 * block number for those buffers in the "altpath".
1706 path = &state->altpath;
1707 ASSERT((path->active >= 0) && (path->active < XFS_DA_NODE_MAXDEPTH));
1708 for (blk = path->blk, level = 0; level < path->active; blk++, level++) {
1709 if (blk->disk_blkno) {
1710 error = xfs_da_read_buf(state->args->trans,
1712 blk->blkno, blk->disk_blkno,
1713 &blk->bp, XFS_ATTR_FORK);
1725 * Look up a filename in a node attribute list.
1727 * This routine gets called for any attribute fork that has more than one
1728 * block, ie: both true Btree attr lists and for single-leaf-blocks with
1729 * "remote" values taking up more blocks.
1732 xfs_attr_node_get(xfs_da_args_t *args)
1734 xfs_da_state_t *state;
1735 xfs_da_state_blk_t *blk;
1739 state = xfs_da_state_alloc();
1741 state->mp = args->dp->i_mount;
1742 state->blocksize = state->mp->m_sb.sb_blocksize;
1743 state->node_ents = state->mp->m_attr_node_ents;
1746 * Search to see if name exists, and get back a pointer to it.
1748 error = xfs_da_node_lookup_int(state, &retval);
1751 } else if (retval == EEXIST) {
1752 blk = &state->path.blk[ state->path.active-1 ];
1753 ASSERT(blk->bp != NULL);
1754 ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC);
1757 * Get the value, local or "remote"
1759 retval = xfs_attr_leaf_getvalue(blk->bp, args);
1760 if (!retval && (args->rmtblkno > 0)
1761 && !(args->flags & ATTR_KERNOVAL)) {
1762 retval = xfs_attr_rmtval_get(args);
1767 * If not in a transaction, we have to release all the buffers.
1769 for (i = 0; i < state->path.active; i++) {
1770 xfs_da_brelse(args->trans, state->path.blk[i].bp);
1771 state->path.blk[i].bp = NULL;
1774 xfs_da_state_free(state);
1778 STATIC int /* error */
1779 xfs_attr_node_list(xfs_attr_list_context_t *context)
1781 attrlist_cursor_kern_t *cursor;
1782 xfs_attr_leafblock_t *leaf;
1783 xfs_da_intnode_t *node;
1784 xfs_da_node_entry_t *btree;
1788 cursor = context->cursor;
1789 cursor->initted = 1;
1792 * Do all sorts of validation on the passed-in cursor structure.
1793 * If anything is amiss, ignore the cursor and look up the hashval
1794 * starting from the btree root.
1797 if (cursor->blkno > 0) {
1798 error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
1799 &bp, XFS_ATTR_FORK);
1800 if ((error != 0) && (error != EFSCORRUPTED))
1804 switch (INT_GET(node->hdr.info.magic, ARCH_CONVERT)) {
1805 case XFS_DA_NODE_MAGIC:
1806 xfs_attr_trace_l_cn("wrong blk", context, node);
1807 xfs_da_brelse(NULL, bp);
1810 case XFS_ATTR_LEAF_MAGIC:
1812 if (cursor->hashval >
1813 INT_GET(leaf->entries[
1814 INT_GET(leaf->hdr.count,
1815 ARCH_CONVERT)-1].hashval,
1817 xfs_attr_trace_l_cl("wrong blk",
1819 xfs_da_brelse(NULL, bp);
1821 } else if (cursor->hashval <=
1822 INT_GET(leaf->entries[0].hashval,
1824 xfs_attr_trace_l_cl("maybe wrong blk",
1826 xfs_da_brelse(NULL, bp);
1831 xfs_attr_trace_l_c("wrong blk - ??", context);
1832 xfs_da_brelse(NULL, bp);
1839 * We did not find what we expected given the cursor's contents,
1840 * so we start from the top and work down based on the hash value.
1841 * Note that start of node block is same as start of leaf block.
1846 error = xfs_da_read_buf(NULL, context->dp,
1847 cursor->blkno, -1, &bp,
1851 if (unlikely(bp == NULL)) {
1852 XFS_ERROR_REPORT("xfs_attr_node_list(2)",
1854 context->dp->i_mount);
1855 return(XFS_ERROR(EFSCORRUPTED));
1858 if (INT_GET(node->hdr.info.magic, ARCH_CONVERT)
1859 == XFS_ATTR_LEAF_MAGIC)
1861 if (unlikely(INT_GET(node->hdr.info.magic, ARCH_CONVERT)
1862 != XFS_DA_NODE_MAGIC)) {
1863 XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)",
1865 context->dp->i_mount,
1867 xfs_da_brelse(NULL, bp);
1868 return(XFS_ERROR(EFSCORRUPTED));
1870 btree = node->btree;
1872 i < INT_GET(node->hdr.count, ARCH_CONVERT);
1875 <= INT_GET(btree->hashval,
1877 cursor->blkno = INT_GET(btree->before, ARCH_CONVERT);
1878 xfs_attr_trace_l_cb("descending",
1883 if (i == INT_GET(node->hdr.count, ARCH_CONVERT)) {
1884 xfs_da_brelse(NULL, bp);
1887 xfs_da_brelse(NULL, bp);
1893 * Roll upward through the blocks, processing each leaf block in
1894 * order. As long as there is space in the result buffer, keep
1895 * adding the information.
1899 if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
1900 != XFS_ATTR_LEAF_MAGIC)) {
1901 XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)",
1903 context->dp->i_mount, leaf);
1904 xfs_da_brelse(NULL, bp);
1905 return(XFS_ERROR(EFSCORRUPTED));
1907 error = xfs_attr_leaf_list_int(bp, context);
1908 if (error || (INT_ISZERO(leaf->hdr.info.forw, ARCH_CONVERT)))
1909 break; /* not really an error, buffer full or EOF */
1910 cursor->blkno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT);
1911 xfs_da_brelse(NULL, bp);
1912 error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
1913 &bp, XFS_ATTR_FORK);
1916 if (unlikely((bp == NULL))) {
1917 XFS_ERROR_REPORT("xfs_attr_node_list(5)",
1919 context->dp->i_mount);
1920 return(XFS_ERROR(EFSCORRUPTED));
1923 xfs_da_brelse(NULL, bp);
1928 /*========================================================================
1929 * External routines for manipulating out-of-line attribute values.
1930 *========================================================================*/
1933 * Read the value associated with an attribute from the out-of-line buffer
1934 * that we stored it in.
1937 xfs_attr_rmtval_get(xfs_da_args_t *args)
1939 xfs_bmbt_irec_t map[ATTR_RMTVALUE_MAPSIZE];
1944 int nmap, error, tmp, valuelen, blkcnt, i;
1947 ASSERT(!(args->flags & ATTR_KERNOVAL));
1949 mp = args->dp->i_mount;
1951 valuelen = args->valuelen;
1952 lblkno = args->rmtblkno;
1953 while (valuelen > 0) {
1954 nmap = ATTR_RMTVALUE_MAPSIZE;
1955 error = xfs_bmapi(args->trans, args->dp, (xfs_fileoff_t)lblkno,
1957 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA,
1958 NULL, 0, map, &nmap, NULL);
1963 for (i = 0; (i < nmap) && (valuelen > 0); i++) {
1964 ASSERT((map[i].br_startblock != DELAYSTARTBLOCK) &&
1965 (map[i].br_startblock != HOLESTARTBLOCK));
1966 dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);
1967 blkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
1968 error = xfs_read_buf(mp, mp->m_ddev_targp, dblkno,
1969 blkcnt, XFS_BUF_LOCK, &bp);
1973 tmp = (valuelen < XFS_BUF_SIZE(bp))
1974 ? valuelen : XFS_BUF_SIZE(bp);
1975 xfs_biomove(bp, 0, tmp, dst, XFS_B_READ);
1980 lblkno += map[i].br_blockcount;
1983 ASSERT(valuelen == 0);
1988 * Write the value associated with an attribute into the out-of-line buffer
1989 * that we have defined for it.
1992 xfs_attr_rmtval_set(xfs_da_args_t *args)
1995 xfs_fileoff_t lfileoff;
1997 xfs_bmbt_irec_t map;
2002 int blkcnt, valuelen, nmap, error, tmp, committed;
2009 * Find a "hole" in the attribute address space large enough for
2010 * us to drop the new attribute's value into.
2012 blkcnt = XFS_B_TO_FSB(mp, args->valuelen);
2014 error = xfs_bmap_first_unused(args->trans, args->dp, blkcnt, &lfileoff,
2019 args->rmtblkno = lblkno = (xfs_dablk_t)lfileoff;
2020 args->rmtblkcnt = blkcnt;
2023 * Roll through the "value", allocating blocks on disk as required.
2025 while (blkcnt > 0) {
2027 * Allocate a single extent, up to the size of the value.
2029 XFS_BMAP_INIT(args->flist, args->firstblock);
2031 error = xfs_bmapi(args->trans, dp, (xfs_fileoff_t)lblkno,
2033 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA |
2035 args->firstblock, args->total, &map, &nmap,
2038 error = xfs_bmap_finish(&args->trans, args->flist,
2039 *args->firstblock, &committed);
2044 xfs_bmap_cancel(args->flist);
2049 * bmap_finish() may have committed the last trans and started
2050 * a new one. We need the inode to be in all transactions.
2053 xfs_trans_ijoin(args->trans, dp, XFS_ILOCK_EXCL);
2054 xfs_trans_ihold(args->trans, dp);
2058 ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
2059 (map.br_startblock != HOLESTARTBLOCK));
2060 lblkno += map.br_blockcount;
2061 blkcnt -= map.br_blockcount;
2064 * Start the next trans in the chain.
2066 if ((error = xfs_attr_rolltrans(&args->trans, dp)))
2071 * Roll through the "value", copying the attribute value to the
2072 * already-allocated blocks. Blocks are written synchronously
2073 * so that we can know they are all on disk before we turn off
2074 * the INCOMPLETE flag.
2076 lblkno = args->rmtblkno;
2077 valuelen = args->valuelen;
2078 while (valuelen > 0) {
2080 * Try to remember where we decided to put the value.
2082 XFS_BMAP_INIT(args->flist, args->firstblock);
2084 error = xfs_bmapi(NULL, dp, (xfs_fileoff_t)lblkno,
2086 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA,
2087 args->firstblock, 0, &map, &nmap, NULL);
2092 ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
2093 (map.br_startblock != HOLESTARTBLOCK));
2095 dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock),
2096 blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
2098 bp = xfs_buf_get_flags(mp->m_ddev_targp, dblkno,
2099 blkcnt, XFS_BUF_LOCK);
2101 ASSERT(!XFS_BUF_GETERROR(bp));
2103 tmp = (valuelen < XFS_BUF_SIZE(bp)) ? valuelen :
2105 xfs_biomove(bp, 0, tmp, src, XFS_B_WRITE);
2106 if (tmp < XFS_BUF_SIZE(bp))
2107 xfs_biozero(bp, tmp, XFS_BUF_SIZE(bp) - tmp);
2108 if ((error = xfs_bwrite(mp, bp))) {/* GROT: NOTE: synchronous write */
2114 lblkno += map.br_blockcount;
2116 ASSERT(valuelen == 0);
2121 * Remove the value associated with an attribute by deleting the
2122 * out-of-line buffer that it is stored on.
2125 xfs_attr_rmtval_remove(xfs_da_args_t *args)
2128 xfs_bmbt_irec_t map;
2132 int valuelen, blkcnt, nmap, error, done, committed;
2134 mp = args->dp->i_mount;
2137 * Roll through the "value", invalidating the attribute value's
2140 lblkno = args->rmtblkno;
2141 valuelen = args->rmtblkcnt;
2142 while (valuelen > 0) {
2144 * Try to remember where we decided to put the value.
2146 XFS_BMAP_INIT(args->flist, args->firstblock);
2148 error = xfs_bmapi(NULL, args->dp, (xfs_fileoff_t)lblkno,
2150 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA,
2151 args->firstblock, 0, &map, &nmap,
2157 ASSERT((map.br_startblock != DELAYSTARTBLOCK) &&
2158 (map.br_startblock != HOLESTARTBLOCK));
2160 dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock),
2161 blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
2164 * If the "remote" value is in the cache, remove it.
2166 /* bp = incore(mp->m_dev, dblkno, blkcnt, 1); */
2167 bp = xfs_incore(mp->m_ddev_targp, dblkno, blkcnt, 1);
2170 XFS_BUF_UNDELAYWRITE(bp);
2175 valuelen -= map.br_blockcount;
2177 lblkno += map.br_blockcount;
2181 * Keep de-allocating extents until the remote-value region is gone.
2183 lblkno = args->rmtblkno;
2184 blkcnt = args->rmtblkcnt;
2187 XFS_BMAP_INIT(args->flist, args->firstblock);
2188 error = xfs_bunmapi(args->trans, args->dp, lblkno, blkcnt,
2189 XFS_BMAPI_ATTRFORK | XFS_BMAPI_METADATA,
2190 1, args->firstblock, args->flist, &done);
2192 error = xfs_bmap_finish(&args->trans, args->flist,
2193 *args->firstblock, &committed);
2198 xfs_bmap_cancel(args->flist);
2203 * bmap_finish() may have committed the last trans and started
2204 * a new one. We need the inode to be in all transactions.
2207 xfs_trans_ijoin(args->trans, args->dp, XFS_ILOCK_EXCL);
2208 xfs_trans_ihold(args->trans, args->dp);
2212 * Close out trans and start the next one in the chain.
2214 if ((error = xfs_attr_rolltrans(&args->trans, args->dp)))
2220 #if defined(XFS_ATTR_TRACE)
2222 * Add a trace buffer entry for an attr_list context structure.
2225 xfs_attr_trace_l_c(char *where, struct xfs_attr_list_context *context)
2227 xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_C, where,
2228 (__psunsigned_t)context->dp,
2229 (__psunsigned_t)context->cursor->hashval,
2230 (__psunsigned_t)context->cursor->blkno,
2231 (__psunsigned_t)context->cursor->offset,
2232 (__psunsigned_t)context->alist,
2233 (__psunsigned_t)context->bufsize,
2234 (__psunsigned_t)context->count,
2235 (__psunsigned_t)context->firstu,
2237 ((context->count > 0) &&
2238 !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
2239 ? (ATTR_ENTRY(context->alist,
2240 context->count-1)->a_valuelen)
2242 (__psunsigned_t)context->dupcnt,
2243 (__psunsigned_t)context->flags,
2244 (__psunsigned_t)NULL,
2245 (__psunsigned_t)NULL,
2246 (__psunsigned_t)NULL);
2250 * Add a trace buffer entry for a context structure and a Btree node.
2253 xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
2254 struct xfs_da_intnode *node)
2256 xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CN, where,
2257 (__psunsigned_t)context->dp,
2258 (__psunsigned_t)context->cursor->hashval,
2259 (__psunsigned_t)context->cursor->blkno,
2260 (__psunsigned_t)context->cursor->offset,
2261 (__psunsigned_t)context->alist,
2262 (__psunsigned_t)context->bufsize,
2263 (__psunsigned_t)context->count,
2264 (__psunsigned_t)context->firstu,
2266 ((context->count > 0) &&
2267 !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
2268 ? (ATTR_ENTRY(context->alist,
2269 context->count-1)->a_valuelen)
2271 (__psunsigned_t)context->dupcnt,
2272 (__psunsigned_t)context->flags,
2273 (__psunsigned_t)INT_GET(node->hdr.count, ARCH_CONVERT),
2274 (__psunsigned_t)INT_GET(node->btree[0].hashval, ARCH_CONVERT),
2275 (__psunsigned_t)INT_GET(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT));
2279 * Add a trace buffer entry for a context structure and a Btree element.
2282 xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context,
2283 struct xfs_da_node_entry *btree)
2285 xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CB, where,
2286 (__psunsigned_t)context->dp,
2287 (__psunsigned_t)context->cursor->hashval,
2288 (__psunsigned_t)context->cursor->blkno,
2289 (__psunsigned_t)context->cursor->offset,
2290 (__psunsigned_t)context->alist,
2291 (__psunsigned_t)context->bufsize,
2292 (__psunsigned_t)context->count,
2293 (__psunsigned_t)context->firstu,
2295 ((context->count > 0) &&
2296 !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
2297 ? (ATTR_ENTRY(context->alist,
2298 context->count-1)->a_valuelen)
2300 (__psunsigned_t)context->dupcnt,
2301 (__psunsigned_t)context->flags,
2302 (__psunsigned_t)INT_GET(btree->hashval, ARCH_CONVERT),
2303 (__psunsigned_t)INT_GET(btree->before, ARCH_CONVERT),
2304 (__psunsigned_t)NULL);
2308 * Add a trace buffer entry for a context structure and a leaf block.
2311 xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context,
2312 struct xfs_attr_leafblock *leaf)
2314 xfs_attr_trace_enter(XFS_ATTR_KTRACE_L_CL, where,
2315 (__psunsigned_t)context->dp,
2316 (__psunsigned_t)context->cursor->hashval,
2317 (__psunsigned_t)context->cursor->blkno,
2318 (__psunsigned_t)context->cursor->offset,
2319 (__psunsigned_t)context->alist,
2320 (__psunsigned_t)context->bufsize,
2321 (__psunsigned_t)context->count,
2322 (__psunsigned_t)context->firstu,
2324 ((context->count > 0) &&
2325 !(context->flags & (ATTR_KERNAMELS|ATTR_KERNOVAL)))
2326 ? (ATTR_ENTRY(context->alist,
2327 context->count-1)->a_valuelen)
2329 (__psunsigned_t)context->dupcnt,
2330 (__psunsigned_t)context->flags,
2331 (__psunsigned_t)INT_GET(leaf->hdr.count, ARCH_CONVERT),
2332 (__psunsigned_t)INT_GET(leaf->entries[0].hashval, ARCH_CONVERT),
2333 (__psunsigned_t)INT_GET(leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT));
2337 * Add a trace buffer entry for the arguments given to the routine,
2341 xfs_attr_trace_enter(int type, char *where,
2342 __psunsigned_t a2, __psunsigned_t a3,
2343 __psunsigned_t a4, __psunsigned_t a5,
2344 __psunsigned_t a6, __psunsigned_t a7,
2345 __psunsigned_t a8, __psunsigned_t a9,
2346 __psunsigned_t a10, __psunsigned_t a11,
2347 __psunsigned_t a12, __psunsigned_t a13,
2348 __psunsigned_t a14, __psunsigned_t a15)
2350 ASSERT(xfs_attr_trace_buf);
2351 ktrace_enter(xfs_attr_trace_buf, (void *)((__psunsigned_t)type),
2353 (void *)a2, (void *)a3, (void *)a4,
2354 (void *)a5, (void *)a6, (void *)a7,
2355 (void *)a8, (void *)a9, (void *)a10,
2356 (void *)a11, (void *)a12, (void *)a13,
2357 (void *)a14, (void *)a15);
2359 #endif /* XFS_ATTR_TRACE */
2362 /*========================================================================
2363 * System (pseudo) namespace attribute interface routines.
2364 *========================================================================*/
2367 posix_acl_access_set(
2368 vnode_t *vp, char *name, void *data, size_t size, int xflags)
2370 return xfs_acl_vset(vp, data, size, _ACL_TYPE_ACCESS);
2374 posix_acl_access_remove(
2375 struct vnode *vp, char *name, int xflags)
2377 return xfs_acl_vremove(vp, _ACL_TYPE_ACCESS);
2381 posix_acl_access_get(
2382 vnode_t *vp, char *name, void *data, size_t size, int xflags)
2384 return xfs_acl_vget(vp, data, size, _ACL_TYPE_ACCESS);
2388 posix_acl_access_exists(
2391 return xfs_acl_vhasacl_access(vp);
2395 posix_acl_default_set(
2396 vnode_t *vp, char *name, void *data, size_t size, int xflags)
2398 return xfs_acl_vset(vp, data, size, _ACL_TYPE_DEFAULT);
2402 posix_acl_default_get(
2403 vnode_t *vp, char *name, void *data, size_t size, int xflags)
2405 return xfs_acl_vget(vp, data, size, _ACL_TYPE_DEFAULT);
2409 posix_acl_default_remove(
2410 struct vnode *vp, char *name, int xflags)
2412 return xfs_acl_vremove(vp, _ACL_TYPE_DEFAULT);
2416 posix_acl_default_exists(
2419 return xfs_acl_vhasacl_default(vp);
2422 struct attrnames posix_acl_access = {
2423 .attr_name = "posix_acl_access",
2424 .attr_namelen = sizeof("posix_acl_access") - 1,
2425 .attr_get = posix_acl_access_get,
2426 .attr_set = posix_acl_access_set,
2427 .attr_remove = posix_acl_access_remove,
2428 .attr_exists = posix_acl_access_exists,
2431 struct attrnames posix_acl_default = {
2432 .attr_name = "posix_acl_default",
2433 .attr_namelen = sizeof("posix_acl_default") - 1,
2434 .attr_get = posix_acl_default_get,
2435 .attr_set = posix_acl_default_set,
2436 .attr_remove = posix_acl_default_remove,
2437 .attr_exists = posix_acl_default_exists,
2440 struct attrnames *attr_system_names[] =
2441 { &posix_acl_access, &posix_acl_default };
2444 /*========================================================================
2445 * Namespace-prefix-style attribute name interface routines.
2446 *========================================================================*/
2450 struct vnode *vp, char *name, void *data, size_t size, int xflags)
2454 VOP_ATTR_SET(vp, name, data, size, xflags, NULL, error);
2460 struct vnode *vp, char *name, void *data, size_t size, int xflags)
2462 int error, asize = size;
2464 VOP_ATTR_GET(vp, name, data, &asize, xflags, NULL, error);
2471 attr_generic_remove(
2472 struct vnode *vp, char *name, int xflags)
2476 VOP_ATTR_REMOVE(vp, name, xflags, NULL, error);
2481 attr_generic_listadd(
2482 attrnames_t *prefix,
2483 attrnames_t *namesp,
2488 char *p = data + *result;
2490 *result += prefix->attr_namelen;
2491 *result += namesp->attr_namelen + 1;
2496 strcpy(p, prefix->attr_name);
2497 p += prefix->attr_namelen;
2498 strcpy(p, namesp->attr_name);
2499 p += namesp->attr_namelen + 1;
2510 attrnames_t *namesp;
2513 for (i = 0; i < ATTR_SYSCOUNT; i++) {
2514 namesp = attr_system_names[i];
2515 if (!namesp->attr_exists || !namesp->attr_exists(vp))
2517 error = attr_generic_listadd(&attr_system, namesp,
2518 data, size, result);
2527 struct vnode *vp, void *data, size_t size, int xflags, ssize_t *result)
2529 attrlist_cursor_kern_t cursor = { 0 };
2532 VOP_ATTR_LIST(vp, data, size, xflags, &cursor, NULL, error);
2536 return attr_system_list(vp, data, size, result);
2540 attr_lookup_namespace(
2542 struct attrnames **names,
2547 for (i = 0; i < nnames; i++)
2548 if (!strncmp(name, names[i]->attr_name, names[i]->attr_namelen))
2554 * Some checks to prevent people abusing EAs to get over quota:
2555 * - Don't allow modifying user EAs on devices/symlinks;
2556 * - Don't allow modifying user EAs if sticky bit set;
2563 struct inode *inode = LINVFS_GET_IP(vp);
2565 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
2567 if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode) &&
2568 !capable(CAP_SYS_ADMIN))
2570 if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
2571 (current_fsuid(cred) != inode->i_uid) && !capable(CAP_FOWNER))
2577 attr_trusted_capable(
2581 struct inode *inode = LINVFS_GET_IP(vp);
2583 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
2585 if (!capable(CAP_SYS_ADMIN))
2591 attr_secure_capable(
2595 return -ENOSECURITY;
2600 struct vnode *vp, char *name, void *data, size_t size, int xflags)
2602 attrnames_t *namesp;
2605 if (xflags & ATTR_CREATE)
2608 namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
2611 error = namesp->attr_set(vp, name, data, size, xflags);
2613 error = vn_revalidate(vp);
2619 struct vnode *vp, char *name, void *data, size_t size, int xflags)
2621 attrnames_t *namesp;
2623 namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
2626 return namesp->attr_get(vp, name, data, size, xflags);
2631 struct vnode *vp, char *name, int xflags)
2633 attrnames_t *namesp;
2635 namesp = attr_lookup_namespace(name, attr_system_names, ATTR_SYSCOUNT);
2638 return namesp->attr_remove(vp, name, xflags);
2641 struct attrnames attr_system = {
2642 .attr_name = "system.",
2643 .attr_namelen = sizeof("system.") - 1,
2644 .attr_flag = ATTR_SYSTEM,
2645 .attr_get = attr_system_get,
2646 .attr_set = attr_system_set,
2647 .attr_remove = attr_system_remove,
2648 .attr_capable = (attrcapable_t)fs_noerr,
2651 struct attrnames attr_trusted = {
2652 .attr_name = "trusted.",
2653 .attr_namelen = sizeof("trusted.") - 1,
2654 .attr_flag = ATTR_ROOT,
2655 .attr_get = attr_generic_get,
2656 .attr_set = attr_generic_set,
2657 .attr_remove = attr_generic_remove,
2658 .attr_capable = attr_trusted_capable,
2661 struct attrnames attr_secure = {
2662 .attr_name = "security.",
2663 .attr_namelen = sizeof("security.") - 1,
2664 .attr_flag = ATTR_SECURE,
2665 .attr_get = attr_generic_get,
2666 .attr_set = attr_generic_set,
2667 .attr_remove = attr_generic_remove,
2668 .attr_capable = attr_secure_capable,
2671 struct attrnames attr_user = {
2672 .attr_name = "user.",
2673 .attr_namelen = sizeof("user.") - 1,
2674 .attr_get = attr_generic_get,
2675 .attr_set = attr_generic_set,
2676 .attr_remove = attr_generic_remove,
2677 .attr_capable = attr_user_capable,
2680 struct attrnames *attr_namespaces[] =
2681 { &attr_system, &attr_trusted, &attr_secure, &attr_user };