/* Use xfs_imap() to determine the size and location of the buffer to read from disk.  */
int xfs_inotobp(xfs_mount_t *mp, xfs_trans_t *tp, xfs_ino_t ino, xfs_dinode_t **dipp, xfs_buf_t **bpp, int *offset, uint imap_flags)
/* Use xfs_imap() to determine the size and location of the buffer to read from disk.  */
int xfs_inotobp(xfs_mount_t *mp, xfs_trans_t *tp, xfs_ino_t ino, xfs_dinode_t **dipp, xfs_buf_t **bpp, int *offset, uint imap_flags)
{
	struct xfs_imap	imap;
	xfs_buf_t	*bp;
	int		error;
	imap.im_blkno = 0;
	error = xfs_imap(mp, tp, ino, &imap, imap_flags);
	if (error)
		return error;
	error = xfs_imap_to_bp(mp, tp, &imap, &bp, XFS_BUF_LOCK, imap_flags);
	if (error)
		return error;
	*dipp = (xfs_dinode_t *)xfs_buf_offset(bp, imap.im_boffset);
	*bpp = bp;
	*offset = imap.im_boffset;
	return 0;
}