int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
{
+
+ dev->checkpointOpenForWrite = forWriting;
+
/* Got the functions we need? */
if (!dev->writeChunkWithTagsToNAND ||
!dev->readChunkWithTagsFromNAND ||
dev->checkpointPageSequence = 0;
-
- dev->checkpointOpenForWrite = forWriting;
-
dev->checkpointByteCount = 0;
dev->checkpointSum = 0;
dev->checkpointXor = 0;
if (dev->checkpointOpenForWrite) {
if (dev->checkpointByteOffset != 0)
yaffs_CheckpointFlushBuffer(dev);
- } else {
+ } else if(dev->checkpointBlockList){
int i;
for (i = 0; i < dev->blocksInCheckpoint && dev->checkpointBlockList[i] >= 0; i++) {
- yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, dev->checkpointBlockList[i]);
- if (bi->blockState == YAFFS_BLOCK_STATE_EMPTY)
+ int blk = dev->checkpointBlockList[i];
+ yaffs_BlockInfo *bi = NULL;
+ if( dev->internalStartBlock <= blk && blk <= dev->internalEndBlock)
+ bi = yaffs_GetBlockInfo(dev, blk);
+ if (bi && bi->blockState == YAFFS_BLOCK_STATE_EMPTY)
bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT;
else {
/* Todo this looks odd... */
int yaffs_CheckpointInvalidateStream(yaffs_Device *dev)
{
- /* Erase the first checksum block */
-
- T(YAFFS_TRACE_CHECKPOINT, (TSTR("checkpoint invalidate"TENDSTR)));
+ /* Erase the checkpoint data */
- if (!yaffs_CheckpointSpaceOk(dev))
- return 0;
+ T(YAFFS_TRACE_CHECKPOINT, (TSTR("checkpoint invalidate of %d blocks"TENDSTR),
+ dev->blocksInCheckpoint));
return yaffs_CheckpointErase(dev);
}
-
-
-