[XFS] implement generic xfs_btree_get_rec
Not really much reason to make it generic given that it's so small, but this is the last non-method in xfs_alloc_btree.c and xfs_ialloc_btree.c, so it makes the whole btree implementation more structured. SGI-PV: 985583 SGI-Modid: xfs-linux-melb:xfs-kern:32206a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com> Signed-off-by: Bill O'Donnell <billodo@sgi.com> Signed-off-by: David Chinner <david@fromorbit.com>
This commit is contained in:
committed by
Lachlan McIlroy
parent
91cca5df9b
commit
8cc938fe42
@@ -3764,3 +3764,44 @@ error0:
|
||||
XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the data from the pointed-to record.
|
||||
*/
|
||||
int /* error */
|
||||
xfs_btree_get_rec(
|
||||
struct xfs_btree_cur *cur, /* btree cursor */
|
||||
union xfs_btree_rec **recp, /* output: btree record */
|
||||
int *stat) /* output: success/failure */
|
||||
{
|
||||
struct xfs_btree_block *block; /* btree block */
|
||||
struct xfs_buf *bp; /* buffer pointer */
|
||||
int ptr; /* record number */
|
||||
#ifdef DEBUG
|
||||
int error; /* error return value */
|
||||
#endif
|
||||
|
||||
ptr = cur->bc_ptrs[0];
|
||||
block = xfs_btree_get_block(cur, 0, &bp);
|
||||
|
||||
#ifdef DEBUG
|
||||
error = xfs_btree_check_block(cur, block, 0, bp);
|
||||
if (error)
|
||||
return error;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Off the right end or left end, return failure.
|
||||
*/
|
||||
if (ptr > xfs_btree_get_numrecs(block) || ptr <= 0) {
|
||||
*stat = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Point to the record and extract its data.
|
||||
*/
|
||||
*recp = xfs_btree_rec_addr(cur, ptr, block);
|
||||
*stat = 1;
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user