/*static char *SCCSID = "@(#)lsdbm.c	6.1 90/11/17";*/
/*static char *SCCSID = "@(#)lsdbm.c      13.2 90/01/25";*/
#define INCL_DOSERRORS
#include <os2def.h>
#include <bse.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 "superb.h"
#include "lw.h"
#include "frame.h"
#include "fsdata.h"
#include "pbmacros.h"

#include "pr_CACHE.h"
#include "pr_DEBUG.h"
#include "pr_FSINI.h"
#include "pr_MISC.h"


/*
 ***	LsdBM - Locate Sector Data - BITMAP
 *
 *	LSDBM is identical to LSD except instead of returning NULL
 *	for a single bad sector it checks the entire bitmap block
 *	(i.e, the cache block) for an error.  Any error sectors
 *	are zeroed, the "volume needs repair" flag is set, and
 *	offending sectors are zeroed.  The bandtab fields and the
 *	volume fields are adjusted as appropriate.
 *
 *	ENTRY	pscpDesired = (eax) address of SECPTR structure
 *		priBuf	    = (dl)  priority of buffer once found
 *	EXIT	Returns 	    NULL if error
 *		Returns 	    address of data sector if OK
 *		  *ppbuf    = (ECX) address of the buffer header
 *
 *		Yields CPU
 *
 *	HISTORY
 *	    19-Sep-89 by JR (John Rogers, JohnRo@Microsoft)
 *		- Avoid warnings from Microsoft C 5.2 (on slash-slash comments).
 *	    21-Apr-1989 by John Rogers [JohnRo@Microsoft]
 *		- Changed names of rounding macros in <pbmacros.h>.
 *		- PTR B783576: prevent overflow.
 */

/* NOTE!!!  LSDBM is now a macro defined in pr_cache.h */

#if 0

PVOID
LSDBM (pscpDesired, priBuf, ppbuf)
PSECPTR  	pscpDesired; 	/* pointer to desired sector/hint pair */
USHORT		priBuf; 	/* where does it belong in LRU chain?  */
PBUFNODE far	*ppbuf; 	/* pointer to the PBUFNODE for desired sector */
{
    PVOID pb;

    pb = LSD (pscpDesired, priBuf, ppbuf);

    /* BUGBUG - MarkH - *ppbuf->fFlag |= BFL_BITMAP;
     *	    I don't really know why the following bit is set.
     *	    PIA sets it here & in MFS, but it is never checked.
     */
    (*ppbuf)->fFlag |= BFL_BITMAP;

    if ((*ppbuf)->bBadMask != 0) {
	LSDBMError (*ppbuf);
    }
    return pb;
}
#endif
