projects
/
yaffs2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Better retirement and erasure checking.
[yaffs2.git]
/
direct
/
yaffs_fileem2k.c
diff --git
a/direct/yaffs_fileem2k.c
b/direct/yaffs_fileem2k.c
index 786094b349a307c5ab28ba41feb05f068086e1b4..7e867f61b0d7573cc182f7343977303bbbdc0bd8 100644
(file)
--- a/
direct/yaffs_fileem2k.c
+++ b/
direct/yaffs_fileem2k.c
@@
-15,7
+15,7
@@
// This provides a YAFFS nand emulation on a file for emulating 2kB pages.
// THis is only intended as test code to test persistence etc.
// This provides a YAFFS nand emulation on a file for emulating 2kB pages.
// THis is only intended as test code to test persistence etc.
-const char *yaffs_flashif_c_version = "$Id: yaffs_fileem2k.c,v 1.
3 2005-07-03 05:48:11
charles Exp $";
+const char *yaffs_flashif_c_version = "$Id: yaffs_fileem2k.c,v 1.
5 2006-09-21 08:13:59
charles Exp $";
#include "yportenv.h"
#include "yportenv.h"
@@
-55,7
+55,9
@@
typedef struct
static yflash_Device filedisk;
static yflash_Device filedisk;
-static int CheckInit(yaffs_Device *dev)
+int yaffs_testPartialWrite = 0;
+
+static int CheckInit(void)
{
static int initialised = 0;
{
static int initialised = 0;
@@
-107,16
+109,28
@@
static int CheckInit(yaffs_Device *dev)
}
}
}
}
}
}
+ else
+ {
+ filedisk.nBlocks = fSize/(BLOCK_SIZE);
+ }
return 1;
}
return 1;
}
+
+int yflash_GetNumberOfBlocks(void)
+{
+ CheckInit();
+
+ return filedisk.nBlocks;
+}
+
int yflash_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_ExtendedTags *tags)
{
int written;
int pos;
int yflash_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8 *data, yaffs_ExtendedTags *tags)
{
int written;
int pos;
- CheckInit(
dev
);
+ CheckInit();
@@
-126,6
+140,11
@@
int yflash_WriteChunkWithTagsToNAND(yaffs_Device *dev,int chunkInNAND,const __u8
lseek(filedisk.handle,pos,SEEK_SET);
written = write(filedisk.handle,data,dev->nBytesPerChunk);
lseek(filedisk.handle,pos,SEEK_SET);
written = write(filedisk.handle,data,dev->nBytesPerChunk);
+ if(yaffs_testPartialWrite){
+ close(filedisk.handle);
+ exit(1);
+ }
+
if(written != dev->nBytesPerChunk) return YAFFS_FAIL;
}
if(written != dev->nBytesPerChunk) return YAFFS_FAIL;
}
@@
-160,7
+179,7
@@
int yflash_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
yaffs_PackedTags2 pt;
yaffs_PackedTags2 pt;
- CheckInit(
dev
);
+ CheckInit();
memset(&pt,0,sizeof(pt));
lseek(filedisk.handle,(blockNo * dev->nChunksPerBlock) * PAGE_SIZE + PAGE_DATA_SIZE,SEEK_SET);
memset(&pt,0,sizeof(pt));
lseek(filedisk.handle,(blockNo * dev->nChunksPerBlock) * PAGE_SIZE + PAGE_DATA_SIZE,SEEK_SET);
@@
-190,7
+209,7
@@
int yflash_ReadChunkWithTagsFromNAND(yaffs_Device *dev,int chunkInNAND, __u8 *da
int nread;
int pos;
int nread;
int pos;
- CheckInit(
dev
);
+ CheckInit();
@@
-240,7
+259,7
@@
int yflash_EraseBlockInNAND(yaffs_Device *dev, int blockNumber)
int i;
int i;
- CheckInit(
dev
);
+ CheckInit();
if(blockNumber < 0 || blockNumber >= filedisk.nBlocks)
{
if(blockNumber < 0 || blockNumber >= filedisk.nBlocks)
{
@@
-271,7
+290,7
@@
int yflash_EraseBlockInNAND(yaffs_Device *dev, int blockNumber)
int yflash_InitialiseNAND(yaffs_Device *dev)
{
int yflash_InitialiseNAND(yaffs_Device *dev)
{
- CheckInit(
dev
);
+ CheckInit();
return YAFFS_OK;
}
return YAFFS_OK;
}