-
-static int yaffs_CalcCheckpointBlocksRequired(yaffs_Device *dev)
-{
- if(!dev->nCheckpointBlocksRequired){
- /* Not a valid value so recalculate */
- int nBytes = 0;
- int nBlocks;
- int devBlocks = (dev->endBlock - dev->startBlock + 1);
- int tnodeSize;
-
- tnodeSize = (dev->tnodeWidth * YAFFS_NTNODES_LEVEL0)/8;
-
- if(tnodeSize < sizeof(yaffs_Tnode))
- tnodeSize = sizeof(yaffs_Tnode);
-
- nBytes += sizeof(yaffs_CheckpointValidity);
- nBytes += sizeof(yaffs_CheckpointDevice);
- nBytes += devBlocks * sizeof(yaffs_BlockInfo);
- nBytes += devBlocks * dev->chunkBitmapStride;
- nBytes += (sizeof(yaffs_CheckpointObject) + sizeof(__u32)) * (dev->nObjectsCreated - dev->nFreeObjects);
- nBytes += (tnodeSize + sizeof(__u32)) * (dev->nTnodesCreated - dev->nFreeTnodes);
- nBytes += sizeof(yaffs_CheckpointValidity);
- nBytes += sizeof(__u32); /* checksum*/
-
- /* Round up and add 2 blocks to allow for some bad blocks, so add 3 */
-
- nBlocks = (nBytes/(dev->nDataBytesPerChunk * dev->nChunksPerBlock)) + 3;
-
- dev->nCheckpointBlocksRequired = nBlocks;
- }
-
- return dev->nCheckpointBlocksRequired;
-}
-