#include <fcntl.h>
#include <string.h>
-#define FILE_SIZE_IN_MEG 32
+#define FILE_SIZE_IN_MEG 4
+
+// #define YAFFS_ERROR_TESTING
#define BLOCK_SIZE (32 * 528)
#define BLOCKS_PER_MEG ((1024*1024)/(32 * 512))
static int IsAMarkedBadBlock(int blk)
{
+#if YAFFS_ERROR_TESTING
int *m = markedBadBlocks;
while(*m >= 0)
if(*m == blk) return 1;
m++;
}
+#endif
return 0;
}
static __u8 yaffs_WriteFailCorruption(int chunkInNAND)
{
+#if YAFFS_ERROR_TESTING
// Whole blocks that fail
switch(chunkInNAND/YAFFS_CHUNKS_PER_BLOCK)
}
-
+#endif
return 0;
}
static void yaffs_ModifyWriteData(int chunkInNAND,__u8 *data)
{
+#if YAFFS_ERROR_TESTING
if(data)
{
*data ^= yaffs_WriteFailCorruption(chunkInNAND);
}
+#endif
}
static __u8 yaffs_ReadFailCorruption(int chunkInNAND)
{
switch(chunkInNAND)
{
+#if YAFFS_ERROR_TESTING
case 500:
return 3;// ding two bits
case 700:
case 750:
return 1;// ding one bit
+#endif
default: return 0;
}
static void yaffs_ModifyReadData(int chunkInNAND,__u8 *data)
{
+#if YAFFS_ERROR_TESTING
if(data)
{
*data ^= yaffs_ReadFailCorruption(chunkInNAND);
}
+#endif
}
{
memset(ffChunk,0xFF,528);
+#ifdef YAFFS_DUMP
+ h = open("yaffs-em-file" , O_RDONLY);
+#else
h = open("yaffs-em-file" , O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
+#endif
if(h < 0)
{
perror("Fatal error opening yaffs emulation file");