xfs_attr_list.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. /*
  2. * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  3. * Copyright (c) 2013 Red Hat, Inc.
  4. * All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it would be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write the Free Software Foundation,
  17. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #include "xfs.h"
  20. #include "xfs_fs.h"
  21. #include "xfs_types.h"
  22. #include "xfs_bit.h"
  23. #include "xfs_log.h"
  24. #include "xfs_trans.h"
  25. #include "xfs_sb.h"
  26. #include "xfs_ag.h"
  27. #include "xfs_mount.h"
  28. #include "xfs_da_btree.h"
  29. #include "xfs_bmap_btree.h"
  30. #include "xfs_alloc_btree.h"
  31. #include "xfs_ialloc_btree.h"
  32. #include "xfs_alloc.h"
  33. #include "xfs_btree.h"
  34. #include "xfs_attr_sf.h"
  35. #include "xfs_attr_remote.h"
  36. #include "xfs_dinode.h"
  37. #include "xfs_inode.h"
  38. #include "xfs_inode_item.h"
  39. #include "xfs_bmap.h"
  40. #include "xfs_attr.h"
  41. #include "xfs_attr_leaf.h"
  42. #include "xfs_error.h"
  43. #include "xfs_trace.h"
  44. #include "xfs_buf_item.h"
  45. #include "xfs_cksum.h"
  46. STATIC int
  47. xfs_attr_shortform_compare(const void *a, const void *b)
  48. {
  49. xfs_attr_sf_sort_t *sa, *sb;
  50. sa = (xfs_attr_sf_sort_t *)a;
  51. sb = (xfs_attr_sf_sort_t *)b;
  52. if (sa->hash < sb->hash) {
  53. return(-1);
  54. } else if (sa->hash > sb->hash) {
  55. return(1);
  56. } else {
  57. return(sa->entno - sb->entno);
  58. }
  59. }
  60. #define XFS_ISRESET_CURSOR(cursor) \
  61. (!((cursor)->initted) && !((cursor)->hashval) && \
  62. !((cursor)->blkno) && !((cursor)->offset))
  63. /*
  64. * Copy out entries of shortform attribute lists for attr_list().
  65. * Shortform attribute lists are not stored in hashval sorted order.
  66. * If the output buffer is not large enough to hold them all, then we
  67. * we have to calculate each entries' hashvalue and sort them before
  68. * we can begin returning them to the user.
  69. */
  70. int
  71. xfs_attr_shortform_list(xfs_attr_list_context_t *context)
  72. {
  73. attrlist_cursor_kern_t *cursor;
  74. xfs_attr_sf_sort_t *sbuf, *sbp;
  75. xfs_attr_shortform_t *sf;
  76. xfs_attr_sf_entry_t *sfe;
  77. xfs_inode_t *dp;
  78. int sbsize, nsbuf, count, i;
  79. int error;
  80. ASSERT(context != NULL);
  81. dp = context->dp;
  82. ASSERT(dp != NULL);
  83. ASSERT(dp->i_afp != NULL);
  84. sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data;
  85. ASSERT(sf != NULL);
  86. if (!sf->hdr.count)
  87. return(0);
  88. cursor = context->cursor;
  89. ASSERT(cursor != NULL);
  90. trace_xfs_attr_list_sf(context);
  91. /*
  92. * If the buffer is large enough and the cursor is at the start,
  93. * do not bother with sorting since we will return everything in
  94. * one buffer and another call using the cursor won't need to be
  95. * made.
  96. * Note the generous fudge factor of 16 overhead bytes per entry.
  97. * If bufsize is zero then put_listent must be a search function
  98. * and can just scan through what we have.
  99. */
  100. if (context->bufsize == 0 ||
  101. (XFS_ISRESET_CURSOR(cursor) &&
  102. (dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize)) {
  103. for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
  104. error = context->put_listent(context,
  105. sfe->flags,
  106. sfe->nameval,
  107. (int)sfe->namelen,
  108. (int)sfe->valuelen,
  109. &sfe->nameval[sfe->namelen]);
  110. /*
  111. * Either search callback finished early or
  112. * didn't fit it all in the buffer after all.
  113. */
  114. if (context->seen_enough)
  115. break;
  116. if (error)
  117. return error;
  118. sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
  119. }
  120. trace_xfs_attr_list_sf_all(context);
  121. return(0);
  122. }
  123. /* do no more for a search callback */
  124. if (context->bufsize == 0)
  125. return 0;
  126. /*
  127. * It didn't all fit, so we have to sort everything on hashval.
  128. */
  129. sbsize = sf->hdr.count * sizeof(*sbuf);
  130. sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP | KM_NOFS);
  131. /*
  132. * Scan the attribute list for the rest of the entries, storing
  133. * the relevant info from only those that match into a buffer.
  134. */
  135. nsbuf = 0;
  136. for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
  137. if (unlikely(
  138. ((char *)sfe < (char *)sf) ||
  139. ((char *)sfe >= ((char *)sf + dp->i_afp->if_bytes)))) {
  140. XFS_CORRUPTION_ERROR("xfs_attr_shortform_list",
  141. XFS_ERRLEVEL_LOW,
  142. context->dp->i_mount, sfe);
  143. kmem_free(sbuf);
  144. return XFS_ERROR(EFSCORRUPTED);
  145. }
  146. sbp->entno = i;
  147. sbp->hash = xfs_da_hashname(sfe->nameval, sfe->namelen);
  148. sbp->name = sfe->nameval;
  149. sbp->namelen = sfe->namelen;
  150. /* These are bytes, and both on-disk, don't endian-flip */
  151. sbp->valuelen = sfe->valuelen;
  152. sbp->flags = sfe->flags;
  153. sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
  154. sbp++;
  155. nsbuf++;
  156. }
  157. /*
  158. * Sort the entries on hash then entno.
  159. */
  160. xfs_sort(sbuf, nsbuf, sizeof(*sbuf), xfs_attr_shortform_compare);
  161. /*
  162. * Re-find our place IN THE SORTED LIST.
  163. */
  164. count = 0;
  165. cursor->initted = 1;
  166. cursor->blkno = 0;
  167. for (sbp = sbuf, i = 0; i < nsbuf; i++, sbp++) {
  168. if (sbp->hash == cursor->hashval) {
  169. if (cursor->offset == count) {
  170. break;
  171. }
  172. count++;
  173. } else if (sbp->hash > cursor->hashval) {
  174. break;
  175. }
  176. }
  177. if (i == nsbuf) {
  178. kmem_free(sbuf);
  179. return(0);
  180. }
  181. /*
  182. * Loop putting entries into the user buffer.
  183. */
  184. for ( ; i < nsbuf; i++, sbp++) {
  185. if (cursor->hashval != sbp->hash) {
  186. cursor->hashval = sbp->hash;
  187. cursor->offset = 0;
  188. }
  189. error = context->put_listent(context,
  190. sbp->flags,
  191. sbp->name,
  192. sbp->namelen,
  193. sbp->valuelen,
  194. &sbp->name[sbp->namelen]);
  195. if (error)
  196. return error;
  197. if (context->seen_enough)
  198. break;
  199. cursor->offset++;
  200. }
  201. kmem_free(sbuf);
  202. return(0);
  203. }
  204. STATIC int
  205. xfs_attr_node_list(xfs_attr_list_context_t *context)
  206. {
  207. attrlist_cursor_kern_t *cursor;
  208. xfs_attr_leafblock_t *leaf;
  209. xfs_da_intnode_t *node;
  210. struct xfs_attr3_icleaf_hdr leafhdr;
  211. struct xfs_da3_icnode_hdr nodehdr;
  212. struct xfs_da_node_entry *btree;
  213. int error, i;
  214. struct xfs_buf *bp;
  215. trace_xfs_attr_node_list(context);
  216. cursor = context->cursor;
  217. cursor->initted = 1;
  218. /*
  219. * Do all sorts of validation on the passed-in cursor structure.
  220. * If anything is amiss, ignore the cursor and look up the hashval
  221. * starting from the btree root.
  222. */
  223. bp = NULL;
  224. if (cursor->blkno > 0) {
  225. error = xfs_da3_node_read(NULL, context->dp, cursor->blkno, -1,
  226. &bp, XFS_ATTR_FORK);
  227. if ((error != 0) && (error != EFSCORRUPTED))
  228. return(error);
  229. if (bp) {
  230. struct xfs_attr_leaf_entry *entries;
  231. node = bp->b_addr;
  232. switch (be16_to_cpu(node->hdr.info.magic)) {
  233. case XFS_DA_NODE_MAGIC:
  234. case XFS_DA3_NODE_MAGIC:
  235. trace_xfs_attr_list_wrong_blk(context);
  236. xfs_trans_brelse(NULL, bp);
  237. bp = NULL;
  238. break;
  239. case XFS_ATTR_LEAF_MAGIC:
  240. case XFS_ATTR3_LEAF_MAGIC:
  241. leaf = bp->b_addr;
  242. xfs_attr3_leaf_hdr_from_disk(&leafhdr, leaf);
  243. entries = xfs_attr3_leaf_entryp(leaf);
  244. if (cursor->hashval > be32_to_cpu(
  245. entries[leafhdr.count - 1].hashval)) {
  246. trace_xfs_attr_list_wrong_blk(context);
  247. xfs_trans_brelse(NULL, bp);
  248. bp = NULL;
  249. } else if (cursor->hashval <= be32_to_cpu(
  250. entries[0].hashval)) {
  251. trace_xfs_attr_list_wrong_blk(context);
  252. xfs_trans_brelse(NULL, bp);
  253. bp = NULL;
  254. }
  255. break;
  256. default:
  257. trace_xfs_attr_list_wrong_blk(context);
  258. xfs_trans_brelse(NULL, bp);
  259. bp = NULL;
  260. }
  261. }
  262. }
  263. /*
  264. * We did not find what we expected given the cursor's contents,
  265. * so we start from the top and work down based on the hash value.
  266. * Note that start of node block is same as start of leaf block.
  267. */
  268. if (bp == NULL) {
  269. cursor->blkno = 0;
  270. for (;;) {
  271. __uint16_t magic;
  272. error = xfs_da3_node_read(NULL, context->dp,
  273. cursor->blkno, -1, &bp,
  274. XFS_ATTR_FORK);
  275. if (error)
  276. return(error);
  277. node = bp->b_addr;
  278. magic = be16_to_cpu(node->hdr.info.magic);
  279. if (magic == XFS_ATTR_LEAF_MAGIC ||
  280. magic == XFS_ATTR3_LEAF_MAGIC)
  281. break;
  282. if (magic != XFS_DA_NODE_MAGIC &&
  283. magic != XFS_DA3_NODE_MAGIC) {
  284. XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)",
  285. XFS_ERRLEVEL_LOW,
  286. context->dp->i_mount,
  287. node);
  288. xfs_trans_brelse(NULL, bp);
  289. return XFS_ERROR(EFSCORRUPTED);
  290. }
  291. xfs_da3_node_hdr_from_disk(&nodehdr, node);
  292. btree = xfs_da3_node_tree_p(node);
  293. for (i = 0; i < nodehdr.count; btree++, i++) {
  294. if (cursor->hashval
  295. <= be32_to_cpu(btree->hashval)) {
  296. cursor->blkno = be32_to_cpu(btree->before);
  297. trace_xfs_attr_list_node_descend(context,
  298. btree);
  299. break;
  300. }
  301. }
  302. if (i == nodehdr.count) {
  303. xfs_trans_brelse(NULL, bp);
  304. return 0;
  305. }
  306. xfs_trans_brelse(NULL, bp);
  307. }
  308. }
  309. ASSERT(bp != NULL);
  310. /*
  311. * Roll upward through the blocks, processing each leaf block in
  312. * order. As long as there is space in the result buffer, keep
  313. * adding the information.
  314. */
  315. for (;;) {
  316. leaf = bp->b_addr;
  317. error = xfs_attr3_leaf_list_int(bp, context);
  318. if (error) {
  319. xfs_trans_brelse(NULL, bp);
  320. return error;
  321. }
  322. xfs_attr3_leaf_hdr_from_disk(&leafhdr, leaf);
  323. if (context->seen_enough || leafhdr.forw == 0)
  324. break;
  325. cursor->blkno = leafhdr.forw;
  326. xfs_trans_brelse(NULL, bp);
  327. error = xfs_attr3_leaf_read(NULL, context->dp, cursor->blkno, -1,
  328. &bp);
  329. if (error)
  330. return error;
  331. }
  332. xfs_trans_brelse(NULL, bp);
  333. return 0;
  334. }
  335. /*
  336. * Copy out attribute list entries for attr_list(), for leaf attribute lists.
  337. */
  338. int
  339. xfs_attr3_leaf_list_int(
  340. struct xfs_buf *bp,
  341. struct xfs_attr_list_context *context)
  342. {
  343. struct attrlist_cursor_kern *cursor;
  344. struct xfs_attr_leafblock *leaf;
  345. struct xfs_attr3_icleaf_hdr ichdr;
  346. struct xfs_attr_leaf_entry *entries;
  347. struct xfs_attr_leaf_entry *entry;
  348. int retval;
  349. int i;
  350. trace_xfs_attr_list_leaf(context);
  351. leaf = bp->b_addr;
  352. xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf);
  353. entries = xfs_attr3_leaf_entryp(leaf);
  354. cursor = context->cursor;
  355. cursor->initted = 1;
  356. /*
  357. * Re-find our place in the leaf block if this is a new syscall.
  358. */
  359. if (context->resynch) {
  360. entry = &entries[0];
  361. for (i = 0; i < ichdr.count; entry++, i++) {
  362. if (be32_to_cpu(entry->hashval) == cursor->hashval) {
  363. if (cursor->offset == context->dupcnt) {
  364. context->dupcnt = 0;
  365. break;
  366. }
  367. context->dupcnt++;
  368. } else if (be32_to_cpu(entry->hashval) >
  369. cursor->hashval) {
  370. context->dupcnt = 0;
  371. break;
  372. }
  373. }
  374. if (i == ichdr.count) {
  375. trace_xfs_attr_list_notfound(context);
  376. return 0;
  377. }
  378. } else {
  379. entry = &entries[0];
  380. i = 0;
  381. }
  382. context->resynch = 0;
  383. /*
  384. * We have found our place, start copying out the new attributes.
  385. */
  386. retval = 0;
  387. for (; i < ichdr.count; entry++, i++) {
  388. if (be32_to_cpu(entry->hashval) != cursor->hashval) {
  389. cursor->hashval = be32_to_cpu(entry->hashval);
  390. cursor->offset = 0;
  391. }
  392. if (entry->flags & XFS_ATTR_INCOMPLETE)
  393. continue; /* skip incomplete entries */
  394. if (entry->flags & XFS_ATTR_LOCAL) {
  395. xfs_attr_leaf_name_local_t *name_loc =
  396. xfs_attr3_leaf_name_local(leaf, i);
  397. retval = context->put_listent(context,
  398. entry->flags,
  399. name_loc->nameval,
  400. (int)name_loc->namelen,
  401. be16_to_cpu(name_loc->valuelen),
  402. &name_loc->nameval[name_loc->namelen]);
  403. if (retval)
  404. return retval;
  405. } else {
  406. xfs_attr_leaf_name_remote_t *name_rmt =
  407. xfs_attr3_leaf_name_remote(leaf, i);
  408. int valuelen = be32_to_cpu(name_rmt->valuelen);
  409. if (context->put_value) {
  410. xfs_da_args_t args;
  411. memset((char *)&args, 0, sizeof(args));
  412. args.dp = context->dp;
  413. args.whichfork = XFS_ATTR_FORK;
  414. args.valuelen = valuelen;
  415. args.value = kmem_alloc(valuelen, KM_SLEEP | KM_NOFS);
  416. args.rmtblkno = be32_to_cpu(name_rmt->valueblk);
  417. args.rmtblkcnt = xfs_attr3_rmt_blocks(
  418. args.dp->i_mount, valuelen);
  419. retval = xfs_attr_rmtval_get(&args);
  420. if (retval)
  421. return retval;
  422. retval = context->put_listent(context,
  423. entry->flags,
  424. name_rmt->name,
  425. (int)name_rmt->namelen,
  426. valuelen,
  427. args.value);
  428. kmem_free(args.value);
  429. } else {
  430. retval = context->put_listent(context,
  431. entry->flags,
  432. name_rmt->name,
  433. (int)name_rmt->namelen,
  434. valuelen,
  435. NULL);
  436. }
  437. if (retval)
  438. return retval;
  439. }
  440. if (context->seen_enough)
  441. break;
  442. cursor->offset++;
  443. }
  444. trace_xfs_attr_list_leaf_end(context);
  445. return retval;
  446. }
  447. /*
  448. * Copy out attribute entries for attr_list(), for leaf attribute lists.
  449. */
  450. STATIC int
  451. xfs_attr_leaf_list(xfs_attr_list_context_t *context)
  452. {
  453. int error;
  454. struct xfs_buf *bp;
  455. trace_xfs_attr_leaf_list(context);
  456. context->cursor->blkno = 0;
  457. error = xfs_attr3_leaf_read(NULL, context->dp, 0, -1, &bp);
  458. if (error)
  459. return XFS_ERROR(error);
  460. error = xfs_attr3_leaf_list_int(bp, context);
  461. xfs_trans_brelse(NULL, bp);
  462. return XFS_ERROR(error);
  463. }
  464. int
  465. xfs_attr_list_int(
  466. xfs_attr_list_context_t *context)
  467. {
  468. int error;
  469. xfs_inode_t *dp = context->dp;
  470. XFS_STATS_INC(xs_attr_list);
  471. if (XFS_FORCED_SHUTDOWN(dp->i_mount))
  472. return EIO;
  473. xfs_ilock(dp, XFS_ILOCK_SHARED);
  474. /*
  475. * Decide on what work routines to call based on the inode size.
  476. */
  477. if (!xfs_inode_hasattr(dp)) {
  478. error = 0;
  479. } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
  480. error = xfs_attr_shortform_list(context);
  481. } else if (xfs_bmap_one_block(dp, XFS_ATTR_FORK)) {
  482. error = xfs_attr_leaf_list(context);
  483. } else {
  484. error = xfs_attr_node_list(context);
  485. }
  486. xfs_iunlock(dp, XFS_ILOCK_SHARED);
  487. return error;
  488. }
  489. #define ATTR_ENTBASESIZE /* minimum bytes used by an attr */ \
  490. (((struct attrlist_ent *) 0)->a_name - (char *) 0)
  491. #define ATTR_ENTSIZE(namelen) /* actual bytes used by an attr */ \
  492. ((ATTR_ENTBASESIZE + (namelen) + 1 + sizeof(u_int32_t)-1) \
  493. & ~(sizeof(u_int32_t)-1))
  494. /*
  495. * Format an attribute and copy it out to the user's buffer.
  496. * Take care to check values and protect against them changing later,
  497. * we may be reading them directly out of a user buffer.
  498. */
  499. STATIC int
  500. xfs_attr_put_listent(
  501. xfs_attr_list_context_t *context,
  502. int flags,
  503. unsigned char *name,
  504. int namelen,
  505. int valuelen,
  506. unsigned char *value)
  507. {
  508. struct attrlist *alist = (struct attrlist *)context->alist;
  509. attrlist_ent_t *aep;
  510. int arraytop;
  511. ASSERT(!(context->flags & ATTR_KERNOVAL));
  512. ASSERT(context->count >= 0);
  513. ASSERT(context->count < (ATTR_MAX_VALUELEN/8));
  514. ASSERT(context->firstu >= sizeof(*alist));
  515. ASSERT(context->firstu <= context->bufsize);
  516. /*
  517. * Only list entries in the right namespace.
  518. */
  519. if (((context->flags & ATTR_SECURE) == 0) !=
  520. ((flags & XFS_ATTR_SECURE) == 0))
  521. return 0;
  522. if (((context->flags & ATTR_ROOT) == 0) !=
  523. ((flags & XFS_ATTR_ROOT) == 0))
  524. return 0;
  525. arraytop = sizeof(*alist) +
  526. context->count * sizeof(alist->al_offset[0]);
  527. context->firstu -= ATTR_ENTSIZE(namelen);
  528. if (context->firstu < arraytop) {
  529. trace_xfs_attr_list_full(context);
  530. alist->al_more = 1;
  531. context->seen_enough = 1;
  532. return 1;
  533. }
  534. aep = (attrlist_ent_t *)&context->alist[context->firstu];
  535. aep->a_valuelen = valuelen;
  536. memcpy(aep->a_name, name, namelen);
  537. aep->a_name[namelen] = 0;
  538. alist->al_offset[context->count++] = context->firstu;
  539. alist->al_count = context->count;
  540. trace_xfs_attr_list_add(context);
  541. return 0;
  542. }
  543. /*
  544. * Generate a list of extended attribute names and optionally
  545. * also value lengths. Positive return value follows the XFS
  546. * convention of being an error, zero or negative return code
  547. * is the length of the buffer returned (negated), indicating
  548. * success.
  549. */
  550. int
  551. xfs_attr_list(
  552. xfs_inode_t *dp,
  553. char *buffer,
  554. int bufsize,
  555. int flags,
  556. attrlist_cursor_kern_t *cursor)
  557. {
  558. xfs_attr_list_context_t context;
  559. struct attrlist *alist;
  560. int error;
  561. /*
  562. * Validate the cursor.
  563. */
  564. if (cursor->pad1 || cursor->pad2)
  565. return(XFS_ERROR(EINVAL));
  566. if ((cursor->initted == 0) &&
  567. (cursor->hashval || cursor->blkno || cursor->offset))
  568. return XFS_ERROR(EINVAL);
  569. /*
  570. * Check for a properly aligned buffer.
  571. */
  572. if (((long)buffer) & (sizeof(int)-1))
  573. return XFS_ERROR(EFAULT);
  574. if (flags & ATTR_KERNOVAL)
  575. bufsize = 0;
  576. /*
  577. * Initialize the output buffer.
  578. */
  579. memset(&context, 0, sizeof(context));
  580. context.dp = dp;
  581. context.cursor = cursor;
  582. context.resynch = 1;
  583. context.flags = flags;
  584. context.alist = buffer;
  585. context.bufsize = (bufsize & ~(sizeof(int)-1)); /* align */
  586. context.firstu = context.bufsize;
  587. context.put_listent = xfs_attr_put_listent;
  588. alist = (struct attrlist *)context.alist;
  589. alist->al_count = 0;
  590. alist->al_more = 0;
  591. alist->al_offset[0] = context.bufsize;
  592. error = xfs_attr_list_int(&context);
  593. ASSERT(error >= 0);
  594. return error;
  595. }