资源简介
官方最新mkyaffs2image工具,直接编译生成mkyaffs2image
代码片段和文件信息
/*
* YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
*
* Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering
*
* Created by Charles Manning
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
const char *yaffs_checkptrw_c_version =
“$Id: yaffs_checkptrw.cv 1.23 2010/02/18 01:18:04 charles Exp $“;
#include “yaffs_checkptrw.h“
#include “yaffs_getblockinfo.h“
static int yaffs_CheckpointSpaceOk(yaffs_Device *dev)
{
int blocksAvailable = dev->nErasedBlocks - dev->param.nReservedBlocks;
T(YAFFS_TRACE_CHECKPOINT
(TSTR(“checkpt blocks available = %d“ TENDSTR)
blocksAvailable));
return (blocksAvailable <= 0) ? 0 : 1;
}
static int yaffs_CheckpointErase(yaffs_Device *dev)
{
int i;
if (!dev->param.eraseBlockInNAND)
return 0;
T(YAFFS_TRACE_CHECKPOINT (TSTR(“checking blocks %d to %d“TENDSTR)
dev->internalStartBlock dev->internalEndBlock));
for (i = dev->internalStartBlock; i <= dev->internalEndBlock; i++) {
yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev i);
if (bi->blockState == YAFFS_BLOCK_STATE_CHECKPOINT) {
T(YAFFS_TRACE_CHECKPOINT (TSTR(“erasing checkpt block %d“TENDSTR) i));
dev->nBlockErasures++;
if (dev->param.eraseBlockInNAND(dev i - dev->blockOffset /* realign */)) {
bi->blockState = YAFFS_BLOCK_STATE_EMPTY;
dev->nErasedBlocks++;
dev->nFreeChunks += dev->param.nChunksPerBlock;
} else {
dev->param.markNANDBlockBad(dev i);
bi->blockState = YAFFS_BLOCK_STATE_DEAD;
}
}
}
dev->blocksInCheckpoint = 0;
return 1;
}
static void yaffs_CheckpointFindNextErasedBlock(yaffs_Device *dev)
{
int i;
int blocksAvailable = dev->nErasedBlocks - dev->param.nReservedBlocks;
T(YAFFS_TRACE_CHECKPOINT
(TSTR(“allocating checkpt block: erased %d reserved %d avail %d next %d “TENDSTR)
dev->nErasedBlocks dev->param.nReservedBlocks blocksAvailable dev->checkpointNextBlock));
if (dev->checkpointNextBlock >= 0 &&
dev->checkpointNextBlock <= dev->internalEndBlock &&
blocksAvailable > 0) {
for (i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++) {
yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev i);
if (bi->blockState == YAFFS_BLOCK_STATE_EMPTY) {
dev->checkpointNextBlock = i + 1;
dev->checkpointCurrentBlock = i;
T(YAFFS_TRACE_CHECKPOINT (TSTR(“allocating checkpt block %d“TENDSTR) i));
return;
}
}
}
T(YAFFS_TRACE_CHECKPOINT (TSTR(“out of checkpt blocks“TENDSTR)));
dev->checkpointNextBlock = -1;
dev->checkpointCurrentBlock = -1;
}
static void yaffs_CheckpointFindNextCheckpointBlock(yaffs_Device *dev)
{
int i;
yaffs_ExtendedTags tags;
T(YAFFS_TRACE_CHECKPOINT (TSTR(“find next checkpt block: start: blocks %d next %d“ TENDSTR)
dev->blocksInCheckpoint dev->checkpointNextBlock));
if (dev->blocksI
- 上一篇:linux文件读写锁C代码
- 下一篇:线性代数,吉林大学,课后答案
评论
共有 条评论