is_metadata()
PROTOTYPE
#include <bfs.h>
int is_block_bad(ui32 page, void *dev);
DESCRIPTION
is_metadata() is called during initialization to determine if a page has been marked as metadata by a prior write_page() call. Every write_page() call includes a metadata flag that is stored on the page when it is written. page specifies the number of the page.
dev is a driver-supplied data pointer. The value passed to TargetBFS by the bfsAddNandVol() call is passed back as the last parameter of each driver callback function. It can be used in any way that is convenient for the driver implementation.
is_metadata() returns TRUE if, and only if, the page’s metadata flag is recovered and found to be TRUE. It return FALSE if errors were encountered or the flag is false. This causes the page to be skipped as TargetBFS searches for its metadata during startup.
EXAMPLE
/***********************************************************************/
/* is_metadata: Read metadata flag and determine its value */
/* */
/***********************************************************************/
static int is_metadata(ui32 page, void *dev)
{
uint cnt, meta;
...
/*-------------------------------------------------------------------*/
/* If no bits errors (usual case) and flag equals 0xFF, return TRUE. */
/*-------------------------------------------------------------------*/
if (meta == 0xFF)
return FALSE;
/*-------------------------------------------------------------------*/
/* Check for and count 1's, ending early if no 1's left. */
/*-------------------------------------------------------------------*/
for (cnt = 0; meta; meta >>= 1)
if (meta & 1)
if (++cnt >= 4)
return FALSE;
return TRUE;
} /*lint !e818*/