/*static char *SCCSID = "@(#)rdhf.c	6.5 92/01/31";*/
#define _BTXT _BTXT
#define INCL_DOSERRORS
#include <os2def.h>
#include <bse.h>

#include <fsd.h>
#include <fsh.h>

#include "const.h"
#include "misc.h"
#include "chain.h"
#include "buf.h"
#include "dir.h"
#include "volume.h"
#include "storage.h"
#include "tables.h"
#include "pbmacros.h"
#include "message.h"		/* MESSAGE, PMESSAGE. */

#include "lw.h"
#include "frame.h"
#include "fsdata.h"
#include "strat2.h"
#include "asyncio.h"
#include "pbmsg.h"

#ifdef DEBUG
#include "pr_debug.h"
#endif

#include "pr_cache.h"
#include "pr_dskio.h"
#include "pr_misc.h"

extern MESSAGE _TXT_MSG_HPFS_DISK_ERROR_WARN;

/***	RdHF - Read into HotFix buffer
 *
 *	The HotFix logic has to read the disk but it can't use
 *	the buffering code to do this because it may have been
 *	called by the buffering code.  RdHF is called instead.
 *	The single sector is read into a 1-sector special hotfix buffer
 *	and returned.
 *
 *	See WtHF for more info.
 *
 *	NOTE - the caller is responsible for interlocking via HFSem.
 *
 *	ENTRY	vlsn - lsn of disk sector to read
 *
 *	RETURNS - address of sector in the buffer data area
 *
 *	Yields CPU (IO)
 */

PVOID far
RdHF (LSN vlsn, PFRAME pfrm)

{
    USHORT  clsn = 1;
    PVOLTAB pvoltab = VolPtr [IVOLFROMLSN (vlsn)];

    if (DoVolIOFar(DVIO_OPREAD,vlsn,&clsn,abHotFixBuf,pfrm) != NO_ERROR) {

#ifdef DEBUG
	dprintf( "RdHF.c:  RdHF failed.\n " );
	Int3();
#endif
	{
	CHAR chDriveLetter [3];

	chDriveLetter [0] = (CHAR)pvoltab->chDriveLetter;
	chDriveLetter [1] = ':';
	chDriveLetter [2] = 0;

	MAYBLOCK (FSH_CRITERROR(_TXT_MSG_HPFS_DISK_ERROR_WARN.cchMessage,
				_TXT_MSG_HPFS_DISK_ERROR_WARN.pszMessage,
				1,
				chDriveLetter,
				CE_ALLACK));
	}

	return NULL;
    }

   return abHotFixBuf;
}
