aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_btree.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-10-30 01:58:11 -0400
committerLachlan McIlroy <lachlan@sgi.com>2008-10-30 01:58:11 -0400
commit8cc938fe4237e50bea4aa557ed53b06de2319d49 (patch)
tree1b9dd352d423a573d96d5b1b311286a39232ef5b /fs/xfs/xfs_btree.c
parent91cca5df9bc85efdabfa645f51d54259ed09f4bf (diff)
[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>
Diffstat (limited to 'fs/xfs/xfs_btree.c')
-rw-r--r--fs/xfs/xfs_btree.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index 28cc76818343..8503ed5d10a0 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -3764,3 +3764,44 @@ error0:
3764 XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR); 3764 XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
3765 return error; 3765 return error;
3766} 3766}
3767
3768/*
3769 * Get the data from the pointed-to record.
3770 */
3771int /* error */
3772xfs_btree_get_rec(
3773 struct xfs_btree_cur *cur, /* btree cursor */
3774 union xfs_btree_rec **recp, /* output: btree record */
3775 int *stat) /* output: success/failure */
3776{
3777 struct xfs_btree_block *block; /* btree block */
3778 struct xfs_buf *bp; /* buffer pointer */
3779 int ptr; /* record number */
3780#ifdef DEBUG
3781 int error; /* error return value */
3782#endif
3783
3784 ptr = cur->bc_ptrs[0];
3785 block = xfs_btree_get_block(cur, 0, &bp);
3786
3787#ifdef DEBUG
3788 error = xfs_btree_check_block(cur, block, 0, bp);
3789 if (error)
3790 return error;
3791#endif
3792
3793 /*
3794 * Off the right end or left end, return failure.
3795 */
3796 if (ptr > xfs_btree_get_numrecs(block) || ptr <= 0) {
3797 *stat = 0;
3798 return 0;
3799 }
3800
3801 /*
3802 * Point to the record and extract its data.
3803 */
3804 *recp = xfs_btree_rec_addr(cur, ptr, block);
3805 *stat = 1;
3806 return 0;
3807}