/* Return a pointer to the extent record at file index idx.  */
xfs_bmbt_rec_host_t* xfs_iext_get_ext(xfs_ifork_t *ifp, xfs_extnum_t idx)
/* Return a pointer to the extent record at file index idx.  */
xfs_bmbt_rec_host_t* xfs_iext_get_ext(xfs_ifork_t *ifp, xfs_extnum_t idx)
{
	ASSERT(idx >= 0);
	if ((ifp->if_flags & XFS_IFEXTIREC) && (idx == 0)) {
		return ifp->if_u1.if_ext_irec->er_extbuf;
	} else if (ifp->if_flags & XFS_IFEXTIREC) {
		xfs_ext_irec_t	*erp;
		int		erp_idx = 0;
		xfs_extnum_t	page_idx = idx;
		erp = xfs_iext_idx_to_irec(ifp, &page_idx, &erp_idx, 0);
		return &erp->er_extbuf[page_idx];
	} else if (ifp->if_bytes) {
		return &ifp->if_u1.if_extents[idx];
	} else {
		return NULL;
	}
}