1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-09-12 07:08:03 +03:00

[kernel] nuke trailing whitespaces in the yaffs code

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@11277 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
juhosg 2008-05-28 07:31:26 +00:00
parent 6be2f95016
commit 512f1628d2
56 changed files with 1272 additions and 1272 deletions

View File

@ -26,7 +26,7 @@ config YAFFS_YAFFS1
default y default y
help help
Enable YAFFS1 support -- yaffs for 512 byte / page devices Enable YAFFS1 support -- yaffs for 512 byte / page devices
Not needed for 2K-page devices. Not needed for 2K-page devices.
If unsure, say Y. If unsure, say Y.
@ -157,9 +157,9 @@ config YAFFS_ALWAYS_CHECK_CHUNK_ERASED
Enabling this forces on the test that chunks are erased in flash Enabling this forces on the test that chunks are erased in flash
before writing to them. This takes more time but is potentially before writing to them. This takes more time but is potentially
a bit more secure. a bit more secure.
Suggest setting Y during development and ironing out driver Suggest setting Y during development and ironing out driver
issues etc. Suggest setting to N if you want faster writing. issues etc. Suggest setting to N if you want faster writing.
If unsure, say Y. If unsure, say Y.

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering
@ -15,7 +15,7 @@
/* /*
* This file is just holds extra declarations used during development. * This file is just holds extra declarations used during development.
* Most of these are from kernel includes placed here so we can use them in * Most of these are from kernel includes placed here so we can use them in
* applications. * applications.
* *
*/ */

View File

@ -1,10 +1,10 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering
* *
* Created by Martin Fouts <Martin.Fouts@palmsource.com> * Created by Martin Fouts <Martin.Fouts@palmsource.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1 as * it under the terms of the GNU Lesser General Public License version 2.1 as

View File

@ -22,27 +22,27 @@ static int yaffs_CheckpointSpaceOk(yaffs_Device *dev)
{ {
int blocksAvailable = dev->nErasedBlocks - dev->nReservedBlocks; int blocksAvailable = dev->nErasedBlocks - dev->nReservedBlocks;
T(YAFFS_TRACE_CHECKPOINT, T(YAFFS_TRACE_CHECKPOINT,
(TSTR("checkpt blocks available = %d" TENDSTR), (TSTR("checkpt blocks available = %d" TENDSTR),
blocksAvailable)); blocksAvailable));
return (blocksAvailable <= 0) ? 0 : 1; return (blocksAvailable <= 0) ? 0 : 1;
} }
static int yaffs_CheckpointErase(yaffs_Device *dev) static int yaffs_CheckpointErase(yaffs_Device *dev)
{ {
int i;
if(!dev->eraseBlockInNAND) int i;
if(!dev->eraseBlockInNAND)
return 0; return 0;
T(YAFFS_TRACE_CHECKPOINT,(TSTR("checking blocks %d to %d"TENDSTR), T(YAFFS_TRACE_CHECKPOINT,(TSTR("checking blocks %d to %d"TENDSTR),
dev->internalStartBlock,dev->internalEndBlock)); dev->internalStartBlock,dev->internalEndBlock));
for(i = dev->internalStartBlock; i <= dev->internalEndBlock; i++) { for(i = dev->internalStartBlock; i <= dev->internalEndBlock; i++) {
yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i); yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i);
if(bi->blockState == YAFFS_BLOCK_STATE_CHECKPOINT){ if(bi->blockState == YAFFS_BLOCK_STATE_CHECKPOINT){
@ -58,9 +58,9 @@ static int yaffs_CheckpointErase(yaffs_Device *dev)
} }
} }
} }
dev->blocksInCheckpoint = 0; dev->blocksInCheckpoint = 0;
return 1; return 1;
} }
@ -72,11 +72,11 @@ static void yaffs_CheckpointFindNextErasedBlock(yaffs_Device *dev)
T(YAFFS_TRACE_CHECKPOINT, T(YAFFS_TRACE_CHECKPOINT,
(TSTR("allocating checkpt block: erased %d reserved %d avail %d next %d "TENDSTR), (TSTR("allocating checkpt block: erased %d reserved %d avail %d next %d "TENDSTR),
dev->nErasedBlocks,dev->nReservedBlocks,blocksAvailable,dev->checkpointNextBlock)); dev->nErasedBlocks,dev->nReservedBlocks,blocksAvailable,dev->checkpointNextBlock));
if(dev->checkpointNextBlock >= 0 && if(dev->checkpointNextBlock >= 0 &&
dev->checkpointNextBlock <= dev->internalEndBlock && dev->checkpointNextBlock <= dev->internalEndBlock &&
blocksAvailable > 0){ blocksAvailable > 0){
for(i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++){ for(i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++){
yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i); yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i);
if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY){ if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY){
@ -88,7 +88,7 @@ static void yaffs_CheckpointFindNextErasedBlock(yaffs_Device *dev)
} }
} }
T(YAFFS_TRACE_CHECKPOINT,(TSTR("out of checkpt blocks"TENDSTR))); T(YAFFS_TRACE_CHECKPOINT,(TSTR("out of checkpt blocks"TENDSTR)));
dev->checkpointNextBlock = -1; dev->checkpointNextBlock = -1;
dev->checkpointCurrentBlock = -1; dev->checkpointCurrentBlock = -1;
} }
@ -97,19 +97,19 @@ static void yaffs_CheckpointFindNextCheckpointBlock(yaffs_Device *dev)
{ {
int i; int i;
yaffs_ExtendedTags tags; yaffs_ExtendedTags tags;
T(YAFFS_TRACE_CHECKPOINT,(TSTR("find next checkpt block: start: blocks %d next %d" TENDSTR), T(YAFFS_TRACE_CHECKPOINT,(TSTR("find next checkpt block: start: blocks %d next %d" TENDSTR),
dev->blocksInCheckpoint, dev->checkpointNextBlock)); dev->blocksInCheckpoint, dev->checkpointNextBlock));
if(dev->blocksInCheckpoint < dev->checkpointMaxBlocks) if(dev->blocksInCheckpoint < dev->checkpointMaxBlocks)
for(i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++){ for(i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++){
int chunk = i * dev->nChunksPerBlock; int chunk = i * dev->nChunksPerBlock;
int realignedChunk = chunk - dev->chunkOffset; int realignedChunk = chunk - dev->chunkOffset;
dev->readChunkWithTagsFromNAND(dev,realignedChunk,NULL,&tags); dev->readChunkWithTagsFromNAND(dev,realignedChunk,NULL,&tags);
T(YAFFS_TRACE_CHECKPOINT,(TSTR("find next checkpt block: search: block %d oid %d seq %d eccr %d" TENDSTR), T(YAFFS_TRACE_CHECKPOINT,(TSTR("find next checkpt block: search: block %d oid %d seq %d eccr %d" TENDSTR),
i, tags.objectId,tags.sequenceNumber,tags.eccResult)); i, tags.objectId,tags.sequenceNumber,tags.eccResult));
if(tags.sequenceNumber == YAFFS_SEQUENCE_CHECKPOINT_DATA){ if(tags.sequenceNumber == YAFFS_SEQUENCE_CHECKPOINT_DATA){
/* Right kind of block */ /* Right kind of block */
dev->checkpointNextBlock = tags.objectId; dev->checkpointNextBlock = tags.objectId;
@ -130,7 +130,7 @@ static void yaffs_CheckpointFindNextCheckpointBlock(yaffs_Device *dev)
int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting) int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
{ {
/* Got the functions we need? */ /* Got the functions we need? */
if (!dev->writeChunkWithTagsToNAND || if (!dev->writeChunkWithTagsToNAND ||
!dev->readChunkWithTagsFromNAND || !dev->readChunkWithTagsFromNAND ||
@ -140,31 +140,31 @@ int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
if(forWriting && !yaffs_CheckpointSpaceOk(dev)) if(forWriting && !yaffs_CheckpointSpaceOk(dev))
return 0; return 0;
if(!dev->checkpointBuffer) if(!dev->checkpointBuffer)
dev->checkpointBuffer = YMALLOC_DMA(dev->nDataBytesPerChunk); dev->checkpointBuffer = YMALLOC_DMA(dev->nDataBytesPerChunk);
if(!dev->checkpointBuffer) if(!dev->checkpointBuffer)
return 0; return 0;
dev->checkpointPageSequence = 0; dev->checkpointPageSequence = 0;
dev->checkpointOpenForWrite = forWriting; dev->checkpointOpenForWrite = forWriting;
dev->checkpointByteCount = 0; dev->checkpointByteCount = 0;
dev->checkpointSum = 0; dev->checkpointSum = 0;
dev->checkpointXor = 0; dev->checkpointXor = 0;
dev->checkpointCurrentBlock = -1; dev->checkpointCurrentBlock = -1;
dev->checkpointCurrentChunk = -1; dev->checkpointCurrentChunk = -1;
dev->checkpointNextBlock = dev->internalStartBlock; dev->checkpointNextBlock = dev->internalStartBlock;
/* Erase all the blocks in the checkpoint area */ /* Erase all the blocks in the checkpoint area */
if(forWriting){ if(forWriting){
memset(dev->checkpointBuffer,0,dev->nDataBytesPerChunk); memset(dev->checkpointBuffer,0,dev->nDataBytesPerChunk);
dev->checkpointByteOffset = 0; dev->checkpointByteOffset = 0;
return yaffs_CheckpointErase(dev); return yaffs_CheckpointErase(dev);
} else { } else {
int i; int i;
/* Set to a value that will kick off a read */ /* Set to a value that will kick off a read */
@ -177,7 +177,7 @@ int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
for(i = 0; i < dev->checkpointMaxBlocks; i++) for(i = 0; i < dev->checkpointMaxBlocks; i++)
dev->checkpointBlockList[i] = -1; dev->checkpointBlockList[i] = -1;
} }
return 1; return 1;
} }
@ -196,15 +196,15 @@ static int yaffs_CheckpointFlushBuffer(yaffs_Device *dev)
int realignedChunk; int realignedChunk;
yaffs_ExtendedTags tags; yaffs_ExtendedTags tags;
if(dev->checkpointCurrentBlock < 0){ if(dev->checkpointCurrentBlock < 0){
yaffs_CheckpointFindNextErasedBlock(dev); yaffs_CheckpointFindNextErasedBlock(dev);
dev->checkpointCurrentChunk = 0; dev->checkpointCurrentChunk = 0;
} }
if(dev->checkpointCurrentBlock < 0) if(dev->checkpointCurrentBlock < 0)
return 0; return 0;
tags.chunkDeleted = 0; tags.chunkDeleted = 0;
tags.objectId = dev->checkpointNextBlock; /* Hint to next place to look */ tags.objectId = dev->checkpointNextBlock; /* Hint to next place to look */
tags.chunkId = dev->checkpointPageSequence + 1; tags.chunkId = dev->checkpointPageSequence + 1;
@ -217,25 +217,25 @@ static int yaffs_CheckpointFlushBuffer(yaffs_Device *dev)
bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT; bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT;
dev->blocksInCheckpoint++; dev->blocksInCheckpoint++;
} }
chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock + dev->checkpointCurrentChunk; chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock + dev->checkpointCurrentChunk;
T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint wite buffer nand %d(%d:%d) objid %d chId %d" TENDSTR), T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint wite buffer nand %d(%d:%d) objid %d chId %d" TENDSTR),
chunk, dev->checkpointCurrentBlock, dev->checkpointCurrentChunk,tags.objectId,tags.chunkId)); chunk, dev->checkpointCurrentBlock, dev->checkpointCurrentChunk,tags.objectId,tags.chunkId));
realignedChunk = chunk - dev->chunkOffset; realignedChunk = chunk - dev->chunkOffset;
dev->writeChunkWithTagsToNAND(dev,realignedChunk,dev->checkpointBuffer,&tags); dev->writeChunkWithTagsToNAND(dev,realignedChunk,dev->checkpointBuffer,&tags);
dev->checkpointByteOffset = 0; dev->checkpointByteOffset = 0;
dev->checkpointPageSequence++; dev->checkpointPageSequence++;
dev->checkpointCurrentChunk++; dev->checkpointCurrentChunk++;
if(dev->checkpointCurrentChunk >= dev->nChunksPerBlock){ if(dev->checkpointCurrentChunk >= dev->nChunksPerBlock){
dev->checkpointCurrentChunk = 0; dev->checkpointCurrentChunk = 0;
dev->checkpointCurrentBlock = -1; dev->checkpointCurrentBlock = -1;
} }
memset(dev->checkpointBuffer,0,dev->nDataBytesPerChunk); memset(dev->checkpointBuffer,0,dev->nDataBytesPerChunk);
return 1; return 1;
} }
@ -245,37 +245,37 @@ int yaffs_CheckpointWrite(yaffs_Device *dev,const void *data, int nBytes)
int i=0; int i=0;
int ok = 1; int ok = 1;
__u8 * dataBytes = (__u8 *)data; __u8 * dataBytes = (__u8 *)data;
if(!dev->checkpointBuffer) if(!dev->checkpointBuffer)
return 0; return 0;
if(!dev->checkpointOpenForWrite) if(!dev->checkpointOpenForWrite)
return -1; return -1;
while(i < nBytes && ok) { while(i < nBytes && ok) {
dev->checkpointBuffer[dev->checkpointByteOffset] = *dataBytes ; dev->checkpointBuffer[dev->checkpointByteOffset] = *dataBytes ;
dev->checkpointSum += *dataBytes; dev->checkpointSum += *dataBytes;
dev->checkpointXor ^= *dataBytes; dev->checkpointXor ^= *dataBytes;
dev->checkpointByteOffset++; dev->checkpointByteOffset++;
i++; i++;
dataBytes++; dataBytes++;
dev->checkpointByteCount++; dev->checkpointByteCount++;
if(dev->checkpointByteOffset < 0 || if(dev->checkpointByteOffset < 0 ||
dev->checkpointByteOffset >= dev->nDataBytesPerChunk) dev->checkpointByteOffset >= dev->nDataBytesPerChunk)
ok = yaffs_CheckpointFlushBuffer(dev); ok = yaffs_CheckpointFlushBuffer(dev);
} }
return i; return i;
} }
@ -285,12 +285,12 @@ int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
int ok = 1; int ok = 1;
yaffs_ExtendedTags tags; yaffs_ExtendedTags tags;
int chunk; int chunk;
int realignedChunk; int realignedChunk;
__u8 *dataBytes = (__u8 *)data; __u8 *dataBytes = (__u8 *)data;
if(!dev->checkpointBuffer) if(!dev->checkpointBuffer)
return 0; return 0;
@ -298,31 +298,31 @@ int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
return -1; return -1;
while(i < nBytes && ok) { while(i < nBytes && ok) {
if(dev->checkpointByteOffset < 0 || if(dev->checkpointByteOffset < 0 ||
dev->checkpointByteOffset >= dev->nDataBytesPerChunk) { dev->checkpointByteOffset >= dev->nDataBytesPerChunk) {
if(dev->checkpointCurrentBlock < 0){ if(dev->checkpointCurrentBlock < 0){
yaffs_CheckpointFindNextCheckpointBlock(dev); yaffs_CheckpointFindNextCheckpointBlock(dev);
dev->checkpointCurrentChunk = 0; dev->checkpointCurrentChunk = 0;
} }
if(dev->checkpointCurrentBlock < 0) if(dev->checkpointCurrentBlock < 0)
ok = 0; ok = 0;
else { else {
chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock + chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock +
dev->checkpointCurrentChunk; dev->checkpointCurrentChunk;
realignedChunk = chunk - dev->chunkOffset; realignedChunk = chunk - dev->chunkOffset;
/* read in the next chunk */ /* read in the next chunk */
/* printf("read checkpoint page %d\n",dev->checkpointPage); */ /* printf("read checkpoint page %d\n",dev->checkpointPage); */
dev->readChunkWithTagsFromNAND(dev, realignedChunk, dev->readChunkWithTagsFromNAND(dev, realignedChunk,
dev->checkpointBuffer, dev->checkpointBuffer,
&tags); &tags);
if(tags.chunkId != (dev->checkpointPageSequence + 1) || if(tags.chunkId != (dev->checkpointPageSequence + 1) ||
tags.sequenceNumber != YAFFS_SEQUENCE_CHECKPOINT_DATA) tags.sequenceNumber != YAFFS_SEQUENCE_CHECKPOINT_DATA)
ok = 0; ok = 0;
@ -330,12 +330,12 @@ int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
dev->checkpointByteOffset = 0; dev->checkpointByteOffset = 0;
dev->checkpointPageSequence++; dev->checkpointPageSequence++;
dev->checkpointCurrentChunk++; dev->checkpointCurrentChunk++;
if(dev->checkpointCurrentChunk >= dev->nChunksPerBlock) if(dev->checkpointCurrentChunk >= dev->nChunksPerBlock)
dev->checkpointCurrentBlock = -1; dev->checkpointCurrentBlock = -1;
} }
} }
if(ok){ if(ok){
*dataBytes = dev->checkpointBuffer[dev->checkpointByteOffset]; *dataBytes = dev->checkpointBuffer[dev->checkpointByteOffset];
dev->checkpointSum += *dataBytes; dev->checkpointSum += *dataBytes;
@ -346,14 +346,14 @@ int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
dev->checkpointByteCount++; dev->checkpointByteCount++;
} }
} }
return i; return i;
} }
int yaffs_CheckpointClose(yaffs_Device *dev) int yaffs_CheckpointClose(yaffs_Device *dev)
{ {
if(dev->checkpointOpenForWrite){ if(dev->checkpointOpenForWrite){
if(dev->checkpointByteOffset != 0) if(dev->checkpointByteOffset != 0)
yaffs_CheckpointFlushBuffer(dev); yaffs_CheckpointFlushBuffer(dev);
} else { } else {
@ -373,19 +373,19 @@ int yaffs_CheckpointClose(yaffs_Device *dev)
dev->nFreeChunks -= dev->blocksInCheckpoint * dev->nChunksPerBlock; dev->nFreeChunks -= dev->blocksInCheckpoint * dev->nChunksPerBlock;
dev->nErasedBlocks -= dev->blocksInCheckpoint; dev->nErasedBlocks -= dev->blocksInCheckpoint;
T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint byte count %d" TENDSTR), T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint byte count %d" TENDSTR),
dev->checkpointByteCount)); dev->checkpointByteCount));
if(dev->checkpointBuffer){ if(dev->checkpointBuffer){
/* free the buffer */ /* free the buffer */
YFREE(dev->checkpointBuffer); YFREE(dev->checkpointBuffer);
dev->checkpointBuffer = NULL; dev->checkpointBuffer = NULL;
return 1; return 1;
} }
else else
return 0; return 0;
} }
int yaffs_CheckpointInvalidateStream(yaffs_Device *dev) int yaffs_CheckpointInvalidateStream(yaffs_Device *dev)

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -14,9 +14,9 @@
/* /*
* This code implements the ECC algorithm used in SmartMedia. * This code implements the ECC algorithm used in SmartMedia.
* *
* The ECC comprises 22 bits of parity information and is stuffed into 3 bytes. * The ECC comprises 22 bits of parity information and is stuffed into 3 bytes.
* The two unused bit are set to 1. * The two unused bit are set to 1.
* The ECC can correct single bit errors in a 256-byte page of data. Thus, two such ECC * The ECC can correct single bit errors in a 256-byte page of data. Thus, two such ECC
* blocks are used on a 512-byte NAND page. * blocks are used on a 512-byte NAND page.
* *
*/ */
@ -228,8 +228,8 @@ int yaffs_ECCCorrect(unsigned char *data, unsigned char *read_ecc,
return 1; /* Corrected the error */ return 1; /* Corrected the error */
} }
if ((yaffs_CountBits(d0) + if ((yaffs_CountBits(d0) +
yaffs_CountBits(d1) + yaffs_CountBits(d1) +
yaffs_CountBits(d2)) == 1) { yaffs_CountBits(d2)) == 1) {
/* Reccoverable error in ecc */ /* Reccoverable error in ecc */
@ -239,7 +239,7 @@ int yaffs_ECCCorrect(unsigned char *data, unsigned char *read_ecc,
return 1; /* Corrected the error */ return 1; /* Corrected the error */
} }
/* Unrecoverable error */ /* Unrecoverable error */
return -1; return -1;
@ -293,7 +293,7 @@ int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes,
if ((cDelta | lDelta | lDeltaPrime) == 0) if ((cDelta | lDelta | lDeltaPrime) == 0)
return 0; /* no error */ return 0; /* no error */
if (lDelta == ~lDeltaPrime && if (lDelta == ~lDeltaPrime &&
(((cDelta ^ (cDelta >> 1)) & 0x15) == 0x15)) (((cDelta ^ (cDelta >> 1)) & 0x15) == 0x15))
{ {
/* Single bit (recoverable) error in data */ /* Single bit (recoverable) error in data */
@ -309,7 +309,7 @@ int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes,
if(lDelta >= nBytes) if(lDelta >= nBytes)
return -1; return -1;
data[lDelta] ^= (1 << bit); data[lDelta] ^= (1 << bit);
return 1; /* corrected */ return 1; /* corrected */

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering
@ -16,9 +16,9 @@
/* /*
* This code implements the ECC algorithm used in SmartMedia. * This code implements the ECC algorithm used in SmartMedia.
* *
* The ECC comprises 22 bits of parity information and is stuffed into 3 bytes. * The ECC comprises 22 bits of parity information and is stuffed into 3 bytes.
* The two unused bit are set to 1. * The two unused bit are set to 1.
* The ECC can correct single bit errors in a 256-byte page of data. Thus, two such ECC * The ECC can correct single bit errors in a 256-byte page of data. Thus, two such ECC
* blocks are used on a 512-byte NAND page. * blocks are used on a 512-byte NAND page.
* *
*/ */

View File

@ -23,7 +23,7 @@
* This is the file system front-end to YAFFS that hooks it up to * This is the file system front-end to YAFFS that hooks it up to
* the VFS. * the VFS.
* *
* Special notes: * Special notes:
* >> 2.4: sb->u.generic_sbp points to the yaffs_Device associated with * >> 2.4: sb->u.generic_sbp points to the yaffs_Device associated with
* this superblock * this superblock
* >> 2.6: sb->s_fs_info points to the yaffs_Device associated with this * >> 2.6: sb->s_fs_info points to the yaffs_Device associated with this
@ -391,7 +391,7 @@ static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry)
dentry->d_name.name); dentry->d_name.name);
obj = yaffs_GetEquivalentObject(obj); /* in case it was a hardlink */ obj = yaffs_GetEquivalentObject(obj); /* in case it was a hardlink */
/* Can't hold gross lock when calling yaffs_get_inode() */ /* Can't hold gross lock when calling yaffs_get_inode() */
yaffs_GrossUnlock(dev); yaffs_GrossUnlock(dev);
@ -729,21 +729,21 @@ static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object * obj)
obj->yst_mode &= ~S_IFMT; obj->yst_mode &= ~S_IFMT;
obj->yst_mode |= S_IFREG; obj->yst_mode |= S_IFREG;
} }
break; break;
case YAFFS_OBJECT_TYPE_SYMLINK : case YAFFS_OBJECT_TYPE_SYMLINK :
if( ! S_ISLNK(mode) ){ if( ! S_ISLNK(mode) ){
obj->yst_mode &= ~S_IFMT; obj->yst_mode &= ~S_IFMT;
obj->yst_mode |= S_IFLNK; obj->yst_mode |= S_IFLNK;
} }
break; break;
case YAFFS_OBJECT_TYPE_DIRECTORY : case YAFFS_OBJECT_TYPE_DIRECTORY :
if( ! S_ISDIR(mode) ){ if( ! S_ISDIR(mode) ){
obj->yst_mode &= ~S_IFMT; obj->yst_mode &= ~S_IFMT;
obj->yst_mode |= S_IFDIR; obj->yst_mode |= S_IFDIR;
} }
break; break;
case YAFFS_OBJECT_TYPE_UNKNOWN : case YAFFS_OBJECT_TYPE_UNKNOWN :
case YAFFS_OBJECT_TYPE_HARDLINK : case YAFFS_OBJECT_TYPE_HARDLINK :
@ -1020,7 +1020,7 @@ static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
int error = -ENOSPC; int error = -ENOSPC;
uid_t uid = current->fsuid; uid_t uid = current->fsuid;
gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid; gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
if((dir->i_mode & S_ISGID) && S_ISDIR(mode)) if((dir->i_mode & S_ISGID) && S_ISDIR(mode))
mode |= S_ISGID; mode |= S_ISGID;
@ -1075,7 +1075,7 @@ static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
obj = NULL; /* Do we ever get here? */ obj = NULL; /* Do we ever get here? */
break; break;
} }
/* Can not call yaffs_get_inode() with gross lock held */ /* Can not call yaffs_get_inode() with gross lock held */
yaffs_GrossUnlock(dev); yaffs_GrossUnlock(dev);
@ -1264,13 +1264,13 @@ static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
target = target =
yaffs_FindObjectByName(yaffs_InodeToObject(new_dir), yaffs_FindObjectByName(yaffs_InodeToObject(new_dir),
new_dentry->d_name.name); new_dentry->d_name.name);
if (target && if (target &&
target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY && target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
!list_empty(&target->variant.directoryVariant.children)) { !list_empty(&target->variant.directoryVariant.children)) {
T(YAFFS_TRACE_OS, (KERN_DEBUG "target is non-empty dir\n")); T(YAFFS_TRACE_OS, (KERN_DEBUG "target is non-empty dir\n"));
retVal = YAFFS_FAIL; retVal = YAFFS_FAIL;
@ -1278,7 +1278,7 @@ static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
/* Now does unlinking internally using shadowing mechanism */ /* Now does unlinking internally using shadowing mechanism */
T(YAFFS_TRACE_OS, (KERN_DEBUG "calling yaffs_RenameObject\n")); T(YAFFS_TRACE_OS, (KERN_DEBUG "calling yaffs_RenameObject\n"));
retVal = retVal =
yaffs_RenameObject(yaffs_InodeToObject(old_dir), yaffs_RenameObject(yaffs_InodeToObject(old_dir),
old_dentry->d_name.name, old_dentry->d_name.name,
@ -1390,7 +1390,7 @@ static int yaffs_do_sync_fs(struct super_block *sb)
if(dev) if(dev)
yaffs_CheckpointSave(dev); yaffs_CheckpointSave(dev);
yaffs_GrossUnlock(dev); yaffs_GrossUnlock(dev);
sb->s_dirt = 0; sb->s_dirt = 0;
@ -1421,16 +1421,16 @@ static int yaffs_sync_fs(struct super_block *sb)
{ {
T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_sync_fs\n")); T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_sync_fs\n"));
return 0; /* yaffs_do_sync_fs(sb);*/ return 0; /* yaffs_do_sync_fs(sb);*/
} }
static void yaffs_read_inode(struct inode *inode) static void yaffs_read_inode(struct inode *inode)
{ {
/* NB This is called as a side effect of other functions, but /* NB This is called as a side effect of other functions, but
* we had to release the lock to prevent deadlocks, so * we had to release the lock to prevent deadlocks, so
* need to lock again. * need to lock again.
*/ */
@ -1441,7 +1441,7 @@ static void yaffs_read_inode(struct inode *inode)
(KERN_DEBUG "yaffs_read_inode for %d\n", (int)inode->i_ino)); (KERN_DEBUG "yaffs_read_inode for %d\n", (int)inode->i_ino));
yaffs_GrossLock(dev); yaffs_GrossLock(dev);
obj = yaffs_FindObjectByNumber(dev, inode->i_ino); obj = yaffs_FindObjectByNumber(dev, inode->i_ino);
yaffs_FillInodeFromObject(inode, obj); yaffs_FillInodeFromObject(inode, obj);
@ -1458,26 +1458,26 @@ static int yaffs_remount_fs(struct super_block *sb, int *flags, char *data)
if( *flags & MS_RDONLY ) { if( *flags & MS_RDONLY ) {
struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice; struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
T(YAFFS_TRACE_OS, T(YAFFS_TRACE_OS,
(KERN_DEBUG "yaffs_remount_fs: %s: RO\n", dev->name )); (KERN_DEBUG "yaffs_remount_fs: %s: RO\n", dev->name ));
yaffs_GrossLock(dev); yaffs_GrossLock(dev);
yaffs_FlushEntireDeviceCache(dev); yaffs_FlushEntireDeviceCache(dev);
yaffs_CheckpointSave(dev); yaffs_CheckpointSave(dev);
if (mtd->sync) if (mtd->sync)
mtd->sync(mtd); mtd->sync(mtd);
yaffs_GrossUnlock(dev); yaffs_GrossUnlock(dev);
} }
else { else {
T(YAFFS_TRACE_OS, T(YAFFS_TRACE_OS,
(KERN_DEBUG "yaffs_remount_fs: %s: RW\n", dev->name )); (KERN_DEBUG "yaffs_remount_fs: %s: RW\n", dev->name ));
} }
return 0; return 0;
} }
#endif #endif
@ -1489,7 +1489,7 @@ static void yaffs_put_super(struct super_block *sb)
T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_put_super\n")); T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_put_super\n"));
yaffs_GrossLock(dev); yaffs_GrossLock(dev);
yaffs_FlushEntireDeviceCache(dev); yaffs_FlushEntireDeviceCache(dev);
yaffs_CheckpointSave(dev); yaffs_CheckpointSave(dev);
@ -1499,12 +1499,12 @@ static void yaffs_put_super(struct super_block *sb)
} }
yaffs_Deinitialise(dev); yaffs_Deinitialise(dev);
yaffs_GrossUnlock(dev); yaffs_GrossUnlock(dev);
/* we assume this is protected by lock_kernel() in mount/umount */ /* we assume this is protected by lock_kernel() in mount/umount */
list_del(&dev->devList); list_del(&dev->devList);
if(dev->spareBuffer){ if(dev->spareBuffer){
YFREE(dev->spareBuffer); YFREE(dev->spareBuffer);
dev->spareBuffer = NULL; dev->spareBuffer = NULL;
@ -1530,7 +1530,7 @@ static void yaffs_MTDPutSuper(struct super_block *sb)
static void yaffs_MarkSuperBlockDirty(void *vsb) static void yaffs_MarkSuperBlockDirty(void *vsb)
{ {
struct super_block *sb = (struct super_block *)vsb; struct super_block *sb = (struct super_block *)vsb;
T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_MarkSuperBlockDirty() sb = %p\n",sb)); T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_MarkSuperBlockDirty() sb = %p\n",sb));
// if(sb) // if(sb)
// sb->s_dirt = 1; // sb->s_dirt = 1;
@ -1549,13 +1549,13 @@ static int yaffs_parse_options(yaffs_options *options, const char *options_str)
char cur_opt[MAX_OPT_LEN+1]; char cur_opt[MAX_OPT_LEN+1];
int p; int p;
int error = 0; int error = 0;
/* Parse through the options which is a comma seperated list */ /* Parse through the options which is a comma seperated list */
while(options_str && *options_str && !error){ while(options_str && *options_str && !error){
memset(cur_opt,0,MAX_OPT_LEN+1); memset(cur_opt,0,MAX_OPT_LEN+1);
p = 0; p = 0;
while(*options_str && *options_str != ','){ while(*options_str && *options_str != ','){
if(p < MAX_OPT_LEN){ if(p < MAX_OPT_LEN){
cur_opt[p] = *options_str; cur_opt[p] = *options_str;
@ -1563,7 +1563,7 @@ static int yaffs_parse_options(yaffs_options *options, const char *options_str)
} }
options_str++; options_str++;
} }
if(!strcmp(cur_opt,"inband-tags")) if(!strcmp(cur_opt,"inband-tags"))
options->inband_tags = 1; options->inband_tags = 1;
else if(!strcmp(cur_opt,"no-cache")) else if(!strcmp(cur_opt,"no-cache"))
@ -1579,7 +1579,7 @@ static int yaffs_parse_options(yaffs_options *options, const char *options_str)
printk(KERN_INFO "yaffs: Bad mount option \"%s\"\n",cur_opt); printk(KERN_INFO "yaffs: Bad mount option \"%s\"\n",cur_opt);
error = 1; error = 1;
} }
} }
return error; return error;
@ -1597,7 +1597,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
struct mtd_info *mtd; struct mtd_info *mtd;
int err; int err;
char *data_str = (char *)data; char *data_str = (char *)data;
yaffs_options options; yaffs_options options;
sb->s_magic = YAFFS_MAGIC; sb->s_magic = YAFFS_MAGIC;
@ -1613,14 +1613,14 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
printk(KERN_INFO "yaffs: dev is %d name is \"%s\"\n", printk(KERN_INFO "yaffs: dev is %d name is \"%s\"\n",
sb->s_dev, sb->s_dev,
yaffs_devname(sb, devname_buf)); yaffs_devname(sb, devname_buf));
if(!data_str) if(!data_str)
data_str = ""; data_str = "";
printk(KERN_INFO "yaffs: passed flags \"%s\"\n",data_str); printk(KERN_INFO "yaffs: passed flags \"%s\"\n",data_str);
memset(&options,0,sizeof(options)); memset(&options,0,sizeof(options));
if(yaffs_parse_options(&options,data_str)){ if(yaffs_parse_options(&options,data_str)){
/* Option parsing failed */ /* Option parsing failed */
return NULL; return NULL;
@ -1674,10 +1674,10 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
T(YAFFS_TRACE_OS, (" oobsize %d\n", mtd->oobsize)); T(YAFFS_TRACE_OS, (" oobsize %d\n", mtd->oobsize));
T(YAFFS_TRACE_OS, (" erasesize %d\n", mtd->erasesize)); T(YAFFS_TRACE_OS, (" erasesize %d\n", mtd->erasesize));
T(YAFFS_TRACE_OS, (" size %d\n", mtd->size)); T(YAFFS_TRACE_OS, (" size %d\n", mtd->size));
#ifdef CONFIG_YAFFS_AUTO_YAFFS2 #ifdef CONFIG_YAFFS_AUTO_YAFFS2
if (yaffsVersion == 1 && if (yaffsVersion == 1 &&
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17)) #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
mtd->writesize >= 2048) { mtd->writesize >= 2048) {
#else #else
@ -1685,10 +1685,10 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
#endif #endif
T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs2\n")); T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs2\n"));
yaffsVersion = 2; yaffsVersion = 2;
} }
/* Added NCB 26/5/2006 for completeness */ /* Added NCB 26/5/2006 for completeness */
if (yaffsVersion == 2 && if (yaffsVersion == 2 &&
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17)) #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
mtd->writesize == 512) { mtd->writesize == 512) {
#else #else
@ -1696,7 +1696,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
#endif #endif
T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs1\n")); T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs1\n"));
yaffsVersion = 1; yaffsVersion = 1;
} }
#endif #endif
@ -1830,10 +1830,10 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
dev->initialiseNAND = nandmtd_InitialiseNAND; dev->initialiseNAND = nandmtd_InitialiseNAND;
dev->putSuperFunc = yaffs_MTDPutSuper; dev->putSuperFunc = yaffs_MTDPutSuper;
dev->superBlock = (void *)sb; dev->superBlock = (void *)sb;
dev->markSuperBlockDirty = yaffs_MarkSuperBlockDirty; dev->markSuperBlockDirty = yaffs_MarkSuperBlockDirty;
#ifndef CONFIG_YAFFS_DOES_ECC #ifndef CONFIG_YAFFS_DOES_ECC
dev->useNANDECC = 1; dev->useNANDECC = 1;
@ -1845,7 +1845,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
dev->skipCheckpointRead = options.skip_checkpoint_read; dev->skipCheckpointRead = options.skip_checkpoint_read;
dev->skipCheckpointWrite = options.skip_checkpoint_write; dev->skipCheckpointWrite = options.skip_checkpoint_write;
/* we assume this is protected by lock_kernel() in mount/umount */ /* we assume this is protected by lock_kernel() in mount/umount */
list_add_tail(&dev->devList, &yaffs_dev_list); list_add_tail(&dev->devList, &yaffs_dev_list);
@ -1858,7 +1858,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
T(YAFFS_TRACE_OS, T(YAFFS_TRACE_OS,
("yaffs_read_super: guts initialised %s\n", ("yaffs_read_super: guts initialised %s\n",
(err == YAFFS_OK) ? "OK" : "FAILED")); (err == YAFFS_OK) ? "OK" : "FAILED"));
/* Release lock before yaffs_get_inode() */ /* Release lock before yaffs_get_inode() */
yaffs_GrossUnlock(dev); yaffs_GrossUnlock(dev);
@ -2118,7 +2118,7 @@ static int yaffs_proc_write(struct file *file, const char *buf,
unsigned rg = 0, mask_bitfield; unsigned rg = 0, mask_bitfield;
char *end; char *end;
char *mask_name; char *mask_name;
const char *x; const char *x;
char substring[MAX_MASK_NAME_LENGTH+1]; char substring[MAX_MASK_NAME_LENGTH+1];
int i; int i;
int done = 0; int done = 0;
@ -2146,7 +2146,7 @@ static int yaffs_proc_write(struct file *file, const char *buf,
break; break;
} }
mask_name = NULL; mask_name = NULL;
mask_bitfield = simple_strtoul(buf + pos, &end, 0); mask_bitfield = simple_strtoul(buf + pos, &end, 0);
if (end > buf + pos) { if (end > buf + pos) {
mask_name = "numeral"; mask_name = "numeral";
@ -2154,12 +2154,12 @@ static int yaffs_proc_write(struct file *file, const char *buf,
pos += len; pos += len;
done = 0; done = 0;
} else { } else {
for(x = buf + pos, i = 0; for(x = buf + pos, i = 0;
(*x == '_' || (*x >='a' && *x <= 'z')) && (*x == '_' || (*x >='a' && *x <= 'z')) &&
i <MAX_MASK_NAME_LENGTH; x++, i++, pos++) i <MAX_MASK_NAME_LENGTH; x++, i++, pos++)
substring[i] = *x; substring[i] = *x;
substring[i] = '\0'; substring[i] = '\0';
for (i = 0; mask_flags[i].mask_name != NULL; i++) { for (i = 0; mask_flags[i].mask_name != NULL; i++) {
if(strcmp(substring,mask_flags[i].mask_name) == 0){ if(strcmp(substring,mask_flags[i].mask_name) == 0){
mask_name = mask_flags[i].mask_name; mask_name = mask_flags[i].mask_name;
@ -2190,9 +2190,9 @@ static int yaffs_proc_write(struct file *file, const char *buf,
} }
yaffs_traceMask = rg | YAFFS_TRACE_ALWAYS; yaffs_traceMask = rg | YAFFS_TRACE_ALWAYS;
printk("new trace = 0x%08X\n",yaffs_traceMask); printk("new trace = 0x%08X\n",yaffs_traceMask);
if (rg & YAFFS_TRACE_ALWAYS) { if (rg & YAFFS_TRACE_ALWAYS) {
for (i = 0; mask_flags[i].mask_name != NULL; i++) { for (i = 0; mask_flags[i].mask_name != NULL; i++) {
char flag; char flag;

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering
@ -22,11 +22,11 @@
#define YAFFS_OK 1 #define YAFFS_OK 1
#define YAFFS_FAIL 0 #define YAFFS_FAIL 0
/* Give us a Y=0x59, /* Give us a Y=0x59,
* Give us an A=0x41, * Give us an A=0x41,
* Give us an FF=0xFF * Give us an FF=0xFF
* Give us an S=0x53 * Give us an S=0x53
* And what have we got... * And what have we got...
*/ */
#define YAFFS_MAGIC 0x5941FF53 #define YAFFS_MAGIC 0x5941FF53
@ -102,7 +102,7 @@
* The range is limited slightly to help distinguish bad numbers from good. * The range is limited slightly to help distinguish bad numbers from good.
* This also allows us to perhaps in the future use special numbers for * This also allows us to perhaps in the future use special numbers for
* special purposes. * special purposes.
* EFFFFF00 allows the allocation of 8 blocks per second (~1Mbytes) for 15 years, * EFFFFF00 allows the allocation of 8 blocks per second (~1Mbytes) for 15 years,
* and is a larger number than the lifetime of a 2GB device. * and is a larger number than the lifetime of a 2GB device.
*/ */
#define YAFFS_LOWEST_SEQUENCE_NUMBER 0x00001000 #define YAFFS_LOWEST_SEQUENCE_NUMBER 0x00001000
@ -178,7 +178,7 @@ typedef struct {
/* The following stuff only has meaning when we read */ /* The following stuff only has meaning when we read */
yaffs_ECCResult eccResult; yaffs_ECCResult eccResult;
unsigned blockBad; unsigned blockBad;
/* YAFFS 1 stuff */ /* YAFFS 1 stuff */
unsigned chunkDeleted; /* The chunk is marked deleted */ unsigned chunkDeleted; /* The chunk is marked deleted */
@ -244,29 +244,29 @@ typedef enum {
/* This block is empty */ /* This block is empty */
YAFFS_BLOCK_STATE_ALLOCATING, YAFFS_BLOCK_STATE_ALLOCATING,
/* This block is partially allocated. /* This block is partially allocated.
* At least one page holds valid data. * At least one page holds valid data.
* This is the one currently being used for page * This is the one currently being used for page
* allocation. Should never be more than one of these * allocation. Should never be more than one of these
*/ */
YAFFS_BLOCK_STATE_FULL, YAFFS_BLOCK_STATE_FULL,
/* All the pages in this block have been allocated. /* All the pages in this block have been allocated.
*/ */
YAFFS_BLOCK_STATE_DIRTY, YAFFS_BLOCK_STATE_DIRTY,
/* All pages have been allocated and deleted. /* All pages have been allocated and deleted.
* Erase me, reuse me. * Erase me, reuse me.
*/ */
YAFFS_BLOCK_STATE_CHECKPOINT, YAFFS_BLOCK_STATE_CHECKPOINT,
/* This block is assigned to holding checkpoint data. /* This block is assigned to holding checkpoint data.
*/ */
YAFFS_BLOCK_STATE_COLLECTING, YAFFS_BLOCK_STATE_COLLECTING,
/* This block is being garbage collected */ /* This block is being garbage collected */
YAFFS_BLOCK_STATE_DEAD YAFFS_BLOCK_STATE_DEAD
/* This block has failed and is not in use */ /* This block has failed and is not in use */
} yaffs_BlockState; } yaffs_BlockState;
@ -281,7 +281,7 @@ typedef struct {
__u32 needsRetiring:1; /* Data has failed on this block, need to get valid data off */ __u32 needsRetiring:1; /* Data has failed on this block, need to get valid data off */
/* and retire the block. */ /* and retire the block. */
__u32 skipErasedCheck: 1; /* If this is set we can skip the erased check on this block */ __u32 skipErasedCheck: 1; /* If this is set we can skip the erased check on this block */
__u32 gcPrioritise: 1; /* An ECC check or blank check has failed on this block. __u32 gcPrioritise: 1; /* An ECC check or blank check has failed on this block.
It should be prioritised for GC */ It should be prioritised for GC */
__u32 chunkErrorStrikes:3; /* How many times we've had ecc etc failures on this block and tried to reuse it */ __u32 chunkErrorStrikes:3; /* How many times we've had ecc etc failures on this block and tried to reuse it */
@ -408,7 +408,7 @@ struct yaffs_ObjectStruct {
__u8 renameAllowed:1; /* Some objects are not allowed to be renamed. */ __u8 renameAllowed:1; /* Some objects are not allowed to be renamed. */
__u8 unlinkAllowed:1; __u8 unlinkAllowed:1;
__u8 dirty:1; /* the object needs to be written to flash */ __u8 dirty:1; /* the object needs to be written to flash */
__u8 valid:1; /* When the file system is being loaded up, this __u8 valid:1; /* When the file system is being loaded up, this
* object might be created before the data * object might be created before the data
* is available (ie. file data records appear before the header). * is available (ie. file data records appear before the header).
*/ */
@ -430,11 +430,11 @@ struct yaffs_ObjectStruct {
/* directory structure stuff */ /* directory structure stuff */
/* also used for linking up the free list */ /* also used for linking up the free list */
struct yaffs_ObjectStruct *parent; struct yaffs_ObjectStruct *parent;
struct list_head siblings; struct list_head siblings;
/* Where's my object header in NAND? */ /* Where's my object header in NAND? */
int chunkId; int chunkId;
int nDataChunks; /* Number of data chunks attached to the file. */ int nDataChunks; /* Number of data chunks attached to the file. */
@ -490,26 +490,26 @@ typedef struct {
} yaffs_ObjectBucket; } yaffs_ObjectBucket;
/* yaffs_CheckpointObject holds the definition of an object as dumped /* yaffs_CheckpointObject holds the definition of an object as dumped
* by checkpointing. * by checkpointing.
*/ */
typedef struct { typedef struct {
int structType; int structType;
__u32 objectId; __u32 objectId;
__u32 parentId; __u32 parentId;
int chunkId; int chunkId;
yaffs_ObjectType variantType:3; yaffs_ObjectType variantType:3;
__u8 deleted:1; __u8 deleted:1;
__u8 softDeleted:1; __u8 softDeleted:1;
__u8 unlinked:1; __u8 unlinked:1;
__u8 fake:1; __u8 fake:1;
__u8 renameAllowed:1; __u8 renameAllowed:1;
__u8 unlinkAllowed:1; __u8 unlinkAllowed:1;
__u8 serial; __u8 serial;
int nDataChunks; int nDataChunks;
__u32 fileSizeOrEquivalentObjectId; __u32 fileSizeOrEquivalentObjectId;
}yaffs_CheckpointObject; }yaffs_CheckpointObject;
@ -539,14 +539,14 @@ struct yaffs_DeviceStruct {
int endBlock; /* End block we're allowed to use */ int endBlock; /* End block we're allowed to use */
int nReservedBlocks; /* We want this tuneable so that we can reduce */ int nReservedBlocks; /* We want this tuneable so that we can reduce */
/* reserved blocks on NOR and RAM. */ /* reserved blocks on NOR and RAM. */
/* Stuff used by the shared space checkpointing mechanism */ /* Stuff used by the shared space checkpointing mechanism */
/* If this value is zero, then this mechanism is disabled */ /* If this value is zero, then this mechanism is disabled */
int nCheckpointReservedBlocks; /* Blocks to reserve for checkpoint data */ int nCheckpointReservedBlocks; /* Blocks to reserve for checkpoint data */
int nShortOpCaches; /* If <= 0, then short op caching is disabled, else int nShortOpCaches; /* If <= 0, then short op caching is disabled, else
@ -561,7 +561,7 @@ struct yaffs_DeviceStruct {
* On an mtd this holds the mtd pointer. * On an mtd this holds the mtd pointer.
*/ */
void *superBlock; void *superBlock;
/* NAND access functions (Must be set before calling YAFFS)*/ /* NAND access functions (Must be set before calling YAFFS)*/
int (*writeChunkToNAND) (struct yaffs_DeviceStruct * dev, int (*writeChunkToNAND) (struct yaffs_DeviceStruct * dev,
@ -587,21 +587,21 @@ struct yaffs_DeviceStruct {
#endif #endif
int isYaffs2; int isYaffs2;
/* The removeObjectCallback function must be supplied by OS flavours that /* The removeObjectCallback function must be supplied by OS flavours that
* need it. The Linux kernel does not use this, but yaffs direct does use * need it. The Linux kernel does not use this, but yaffs direct does use
* it to implement the faster readdir * it to implement the faster readdir
*/ */
void (*removeObjectCallback)(struct yaffs_ObjectStruct *obj); void (*removeObjectCallback)(struct yaffs_ObjectStruct *obj);
/* Callback to mark the superblock dirsty */ /* Callback to mark the superblock dirsty */
void (*markSuperBlockDirty)(void * superblock); void (*markSuperBlockDirty)(void * superblock);
int wideTnodesDisabled; /* Set to disable wide tnodes */ int wideTnodesDisabled; /* Set to disable wide tnodes */
/* End of stuff that must be set before initialisation. */ /* End of stuff that must be set before initialisation. */
/* Checkpoint control. Can be set before or after initialisation */ /* Checkpoint control. Can be set before or after initialisation */
__u8 skipCheckpointRead; __u8 skipCheckpointRead;
__u8 skipCheckpointWrite; __u8 skipCheckpointWrite;
@ -610,34 +610,34 @@ struct yaffs_DeviceStruct {
__u16 chunkGroupBits; /* 0 for devices <= 32MB. else log2(nchunks) - 16 */ __u16 chunkGroupBits; /* 0 for devices <= 32MB. else log2(nchunks) - 16 */
__u16 chunkGroupSize; /* == 2^^chunkGroupBits */ __u16 chunkGroupSize; /* == 2^^chunkGroupBits */
/* Stuff to support wide tnodes */ /* Stuff to support wide tnodes */
__u32 tnodeWidth; __u32 tnodeWidth;
__u32 tnodeMask; __u32 tnodeMask;
/* Stuff to support various file offses to chunk/offset translations */ /* Stuff to support various file offses to chunk/offset translations */
/* "Crumbs" for nDataBytesPerChunk not being a power of 2 */ /* "Crumbs" for nDataBytesPerChunk not being a power of 2 */
__u32 crumbMask; __u32 crumbMask;
__u32 crumbShift; __u32 crumbShift;
__u32 crumbsPerChunk; __u32 crumbsPerChunk;
/* Straight shifting for nDataBytesPerChunk being a power of 2 */ /* Straight shifting for nDataBytesPerChunk being a power of 2 */
__u32 chunkShift; __u32 chunkShift;
__u32 chunkMask; __u32 chunkMask;
#ifdef __KERNEL__ #ifdef __KERNEL__
struct semaphore sem; /* Semaphore for waiting on erasure.*/ struct semaphore sem; /* Semaphore for waiting on erasure.*/
struct semaphore grossLock; /* Gross locking semaphore */ struct semaphore grossLock; /* Gross locking semaphore */
__u8 *spareBuffer; /* For mtdif2 use. Don't know the size of the buffer __u8 *spareBuffer; /* For mtdif2 use. Don't know the size of the buffer
* at compile time so we have to allocate it. * at compile time so we have to allocate it.
*/ */
void (*putSuperFunc) (struct super_block * sb); void (*putSuperFunc) (struct super_block * sb);
#endif #endif
int isMounted; int isMounted;
int isCheckpointed; int isCheckpointed;
@ -646,7 +646,7 @@ struct yaffs_DeviceStruct {
int internalEndBlock; int internalEndBlock;
int blockOffset; int blockOffset;
int chunkOffset; int chunkOffset;
/* Runtime checkpointing stuff */ /* Runtime checkpointing stuff */
int checkpointPageSequence; /* running sequence number of checkpoint pages */ int checkpointPageSequence; /* running sequence number of checkpoint pages */
@ -662,13 +662,13 @@ struct yaffs_DeviceStruct {
int checkpointMaxBlocks; int checkpointMaxBlocks;
__u32 checkpointSum; __u32 checkpointSum;
__u32 checkpointXor; __u32 checkpointXor;
/* Block Info */ /* Block Info */
yaffs_BlockInfo *blockInfo; yaffs_BlockInfo *blockInfo;
__u8 *chunkBits; /* bitmap of chunks in use */ __u8 *chunkBits; /* bitmap of chunks in use */
unsigned blockInfoAlt:1; /* was allocated using alternative strategy */ unsigned blockInfoAlt:1; /* was allocated using alternative strategy */
unsigned chunkBitsAlt:1; /* was allocated using alternative strategy */ unsigned chunkBitsAlt:1; /* was allocated using alternative strategy */
int chunkBitmapStride; /* Number of bytes of chunkBits per block. int chunkBitmapStride; /* Number of bytes of chunkBits per block.
* Must be consistent with nChunksPerBlock. * Must be consistent with nChunksPerBlock.
*/ */
@ -716,7 +716,7 @@ struct yaffs_DeviceStruct {
int tagsEccUnfixed; int tagsEccUnfixed;
int nDeletions; int nDeletions;
int nUnmarkedDeletions; int nUnmarkedDeletions;
int hasPendingPrioritisedGCs; /* We think this device might have pending prioritised gcs */ int hasPendingPrioritisedGCs; /* We think this device might have pending prioritised gcs */
/* Special directories */ /* Special directories */
@ -727,7 +727,7 @@ struct yaffs_DeviceStruct {
* __u8 bufferedData[YAFFS_CHUNKS_PER_BLOCK][YAFFS_BYTES_PER_CHUNK]; * __u8 bufferedData[YAFFS_CHUNKS_PER_BLOCK][YAFFS_BYTES_PER_CHUNK];
* yaffs_Spare bufferedSpare[YAFFS_CHUNKS_PER_BLOCK]; * yaffs_Spare bufferedSpare[YAFFS_CHUNKS_PER_BLOCK];
*/ */
int bufferedBlock; /* Which block is buffered here? */ int bufferedBlock; /* Which block is buffered here? */
int doingBufferedBlockRewrite; int doingBufferedBlockRewrite;
@ -768,7 +768,7 @@ typedef struct {
int endBlock; int endBlock;
int rfu[100]; int rfu[100];
} yaffs_SuperBlockHeader; } yaffs_SuperBlockHeader;
/* The CheckpointDevice structure holds the device information that changes at runtime and /* The CheckpointDevice structure holds the device information that changes at runtime and
* must be preserved over unmount/mount cycles. * must be preserved over unmount/mount cycles.
*/ */

View File

@ -172,7 +172,7 @@ int nandmtd_ReadChunkFromNAND(yaffs_Device * dev, int chunkInNAND, __u8 * data,
__u8 *spareAsBytes = (__u8 *) spare; __u8 *spareAsBytes = (__u8 *) spare;
if (data && spare) { if (data && spare) {
if (dev->useNANDECC) { if (dev->useNANDECC) {
/* Careful, this call adds 2 ints */ /* Careful, this call adds 2 ints */
/* to the end of the spare data. Calling function */ /* to the end of the spare data. Calling function */
/* should allocate enough memory for spare, */ /* should allocate enough memory for spare, */

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -30,9 +30,9 @@ Message-Id: <200705181006.49860.ian@brightstareng.com>
X-Virus-Scanned: by amavisd-new at brightstareng.com X-Virus-Scanned: by amavisd-new at brightstareng.com
Status: R Status: R
X-Status: NT X-Status: NT
X-KMail-EncryptionState: X-KMail-EncryptionState:
X-KMail-SignatureState: X-KMail-SignatureState:
X-KMail-MDN-Sent: X-KMail-MDN-Sent:
--Boundary-00=_5LbTGmt62YoutxM --Boundary-00=_5LbTGmt62YoutxM
Content-Type: text/plain; Content-Type: text/plain;
@ -49,9 +49,9 @@ On Friday 18 May 2007 08:34, you wrote:
Good news! Good news!
Attached is a newer yaffs_mtdif1.c with a bandaid to help the Attached is a newer yaffs_mtdif1.c with a bandaid to help the
2.6.18 and 2.6.19 versions of MTD not trip on the oob read. 2.6.18 and 2.6.19 versions of MTD not trip on the oob read.
See the LINUX_VERSION_CODE conditional in See the LINUX_VERSION_CODE conditional in
nandmtd1_ReadChunkWithTagsFromNAND. nandmtd1_ReadChunkWithTagsFromNAND.
-imcd -imcd
@ -361,7 +361,7 @@ int nandmtd1_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
} }
/* Check any MTD prerequists. /* Check any MTD prerequists.
* *
* Returns YAFFS_OK or YAFFS_FAIL. * Returns YAFFS_OK or YAFFS_FAIL.
*/ */
static int nandmtd1_TestPrerequists(struct mtd_info * mtd) static int nandmtd1_TestPrerequists(struct mtd_info * mtd)

View File

@ -295,7 +295,7 @@ int nandmtd1_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
} }
/* Check any MTD prerequists. /* Check any MTD prerequists.
* *
* Returns YAFFS_OK or YAFFS_FAIL. * Returns YAFFS_OK or YAFFS_FAIL.
*/ */
static int nandmtd1_TestPrerequists(struct mtd_info * mtd) static int nandmtd1_TestPrerequists(struct mtd_info * mtd)

View File

@ -158,7 +158,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
if (tags) if (tags)
yaffs_UnpackTags2(tags, &pt); yaffs_UnpackTags2(tags, &pt);
if(tags && retval == -EBADMSG && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR) if(tags && retval == -EBADMSG && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR)
tags->eccResult = YAFFS_ECC_RESULT_UNFIXED; tags->eccResult = YAFFS_ECC_RESULT_UNFIXED;

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -10,7 +10,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
const char *yaffs_nand_c_version = const char *yaffs_nand_c_version =
"$Id: yaffs_nand.c,v 1.7 2007-02-14 01:09:06 wookey Exp $"; "$Id: yaffs_nand.c,v 1.7 2007-02-14 01:09:06 wookey Exp $";
@ -25,9 +25,9 @@ int yaffs_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
{ {
int result; int result;
yaffs_ExtendedTags localTags; yaffs_ExtendedTags localTags;
int realignedChunkInNAND = chunkInNAND - dev->chunkOffset; int realignedChunkInNAND = chunkInNAND - dev->chunkOffset;
/* If there are no tags provided, use local tags to get prioritised gc working */ /* If there are no tags provided, use local tags to get prioritised gc working */
if(!tags) if(!tags)
tags = &localTags; tags = &localTags;
@ -39,14 +39,14 @@ int yaffs_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
result = yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(dev, result = yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(dev,
realignedChunkInNAND, realignedChunkInNAND,
buffer, buffer,
tags); tags);
if(tags && if(tags &&
tags->eccResult > YAFFS_ECC_RESULT_NO_ERROR){ tags->eccResult > YAFFS_ECC_RESULT_NO_ERROR){
yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, chunkInNAND/dev->nChunksPerBlock); yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, chunkInNAND/dev->nChunksPerBlock);
yaffs_HandleChunkError(dev,bi); yaffs_HandleChunkError(dev,bi);
} }
return result; return result;
} }
@ -57,7 +57,7 @@ int yaffs_WriteChunkWithTagsToNAND(yaffs_Device * dev,
{ {
chunkInNAND -= dev->chunkOffset; chunkInNAND -= dev->chunkOffset;
if (tags) { if (tags) {
tags->sequenceNumber = dev->sequenceNumber; tags->sequenceNumber = dev->sequenceNumber;
tags->chunkUsed = 1; tags->chunkUsed = 1;
@ -131,4 +131,4 @@ int yaffs_InitialiseNAND(struct yaffs_DeviceStruct *dev)
} }

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -128,10 +128,10 @@ void yaffs_UnpackTags2(yaffs_ExtendedTags * t, yaffs_PackedTags2 * pt)
(yaffs_PackedTags2TagsPart), (yaffs_PackedTags2TagsPart),
&pt->ecc, &ecc); &pt->ecc, &ecc);
switch(result){ switch(result){
case 0: case 0:
t->eccResult = YAFFS_ECC_RESULT_NO_ERROR; t->eccResult = YAFFS_ECC_RESULT_NO_ERROR;
break; break;
case 1: case 1:
t->eccResult = YAFFS_ECC_RESULT_FIXED; t->eccResult = YAFFS_ECC_RESULT_FIXED;
break; break;
case -1: case -1:

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -50,7 +50,7 @@
static __inline void static __inline void
swapfunc(char *a, char *b, int n, int swaptype) swapfunc(char *a, char *b, int n, int swaptype)
{ {
if (swaptype <= 1) if (swaptype <= 1)
swapcode(long, a, b, n) swapcode(long, a, b, n)
else else
swapcode(char, a, b, n) swapcode(char, a, b, n)
@ -137,7 +137,7 @@ loop: SWAPINIT(a, es);
} }
if (swap_cnt == 0) { /* Switch to insertion sort */ if (swap_cnt == 0) { /* Switch to insertion sort */
for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es) for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
pl -= es) pl -= es)
swap(pl, pl - es); swap(pl, pl - es);
return; return;
@ -150,7 +150,7 @@ loop: SWAPINIT(a, es);
vecswap(pb, pn - r, r); vecswap(pb, pn - r, r);
if ((r = pb - pa) > es) if ((r = pb - pa) > es)
yaffs_qsort(a, r / es, es, cmp); yaffs_qsort(a, r / es, es, cmp);
if ((r = pd - pc) > es) { if ((r = pd - pc) > es) {
/* Iterate rather than recurse to save stack space */ /* Iterate rather than recurse to save stack space */
a = pn - r; a = pn - r;
n = r / es; n = r / es;

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering
@ -150,7 +150,7 @@ extern unsigned int yaffs_wr_attempts;
* Tracing flags. * Tracing flags.
* The flags masked in YAFFS_TRACE_ALWAYS are always traced. * The flags masked in YAFFS_TRACE_ALWAYS are always traced.
*/ */
#define YAFFS_TRACE_OS 0x00000002 #define YAFFS_TRACE_OS 0x00000002
#define YAFFS_TRACE_ALLOCATE 0x00000004 #define YAFFS_TRACE_ALLOCATE 0x00000004
#define YAFFS_TRACE_SCAN 0x00000008 #define YAFFS_TRACE_SCAN 0x00000008

View File

@ -26,7 +26,7 @@ config YAFFS_YAFFS1
default y default y
help help
Enable YAFFS1 support -- yaffs for 512 byte / page devices Enable YAFFS1 support -- yaffs for 512 byte / page devices
Not needed for 2K-page devices. Not needed for 2K-page devices.
If unsure, say Y. If unsure, say Y.
@ -157,9 +157,9 @@ config YAFFS_ALWAYS_CHECK_CHUNK_ERASED
Enabling this forces on the test that chunks are erased in flash Enabling this forces on the test that chunks are erased in flash
before writing to them. This takes more time but is potentially before writing to them. This takes more time but is potentially
a bit more secure. a bit more secure.
Suggest setting Y during development and ironing out driver Suggest setting Y during development and ironing out driver
issues etc. Suggest setting to N if you want faster writing. issues etc. Suggest setting to N if you want faster writing.
If unsure, say Y. If unsure, say Y.

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering
@ -15,7 +15,7 @@
/* /*
* This file is just holds extra declarations used during development. * This file is just holds extra declarations used during development.
* Most of these are from kernel includes placed here so we can use them in * Most of these are from kernel includes placed here so we can use them in
* applications. * applications.
* *
*/ */

View File

@ -1,10 +1,10 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering
* *
* Created by Martin Fouts <Martin.Fouts@palmsource.com> * Created by Martin Fouts <Martin.Fouts@palmsource.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 2.1 as * it under the terms of the GNU Lesser General Public License version 2.1 as

View File

@ -22,27 +22,27 @@ static int yaffs_CheckpointSpaceOk(yaffs_Device *dev)
{ {
int blocksAvailable = dev->nErasedBlocks - dev->nReservedBlocks; int blocksAvailable = dev->nErasedBlocks - dev->nReservedBlocks;
T(YAFFS_TRACE_CHECKPOINT, T(YAFFS_TRACE_CHECKPOINT,
(TSTR("checkpt blocks available = %d" TENDSTR), (TSTR("checkpt blocks available = %d" TENDSTR),
blocksAvailable)); blocksAvailable));
return (blocksAvailable <= 0) ? 0 : 1; return (blocksAvailable <= 0) ? 0 : 1;
} }
static int yaffs_CheckpointErase(yaffs_Device *dev) static int yaffs_CheckpointErase(yaffs_Device *dev)
{ {
int i;
if(!dev->eraseBlockInNAND) int i;
if(!dev->eraseBlockInNAND)
return 0; return 0;
T(YAFFS_TRACE_CHECKPOINT,(TSTR("checking blocks %d to %d"TENDSTR), T(YAFFS_TRACE_CHECKPOINT,(TSTR("checking blocks %d to %d"TENDSTR),
dev->internalStartBlock,dev->internalEndBlock)); dev->internalStartBlock,dev->internalEndBlock));
for(i = dev->internalStartBlock; i <= dev->internalEndBlock; i++) { for(i = dev->internalStartBlock; i <= dev->internalEndBlock; i++) {
yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i); yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i);
if(bi->blockState == YAFFS_BLOCK_STATE_CHECKPOINT){ if(bi->blockState == YAFFS_BLOCK_STATE_CHECKPOINT){
@ -58,9 +58,9 @@ static int yaffs_CheckpointErase(yaffs_Device *dev)
} }
} }
} }
dev->blocksInCheckpoint = 0; dev->blocksInCheckpoint = 0;
return 1; return 1;
} }
@ -72,11 +72,11 @@ static void yaffs_CheckpointFindNextErasedBlock(yaffs_Device *dev)
T(YAFFS_TRACE_CHECKPOINT, T(YAFFS_TRACE_CHECKPOINT,
(TSTR("allocating checkpt block: erased %d reserved %d avail %d next %d "TENDSTR), (TSTR("allocating checkpt block: erased %d reserved %d avail %d next %d "TENDSTR),
dev->nErasedBlocks,dev->nReservedBlocks,blocksAvailable,dev->checkpointNextBlock)); dev->nErasedBlocks,dev->nReservedBlocks,blocksAvailable,dev->checkpointNextBlock));
if(dev->checkpointNextBlock >= 0 && if(dev->checkpointNextBlock >= 0 &&
dev->checkpointNextBlock <= dev->internalEndBlock && dev->checkpointNextBlock <= dev->internalEndBlock &&
blocksAvailable > 0){ blocksAvailable > 0){
for(i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++){ for(i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++){
yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i); yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i);
if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY){ if(bi->blockState == YAFFS_BLOCK_STATE_EMPTY){
@ -88,7 +88,7 @@ static void yaffs_CheckpointFindNextErasedBlock(yaffs_Device *dev)
} }
} }
T(YAFFS_TRACE_CHECKPOINT,(TSTR("out of checkpt blocks"TENDSTR))); T(YAFFS_TRACE_CHECKPOINT,(TSTR("out of checkpt blocks"TENDSTR)));
dev->checkpointNextBlock = -1; dev->checkpointNextBlock = -1;
dev->checkpointCurrentBlock = -1; dev->checkpointCurrentBlock = -1;
} }
@ -97,19 +97,19 @@ static void yaffs_CheckpointFindNextCheckpointBlock(yaffs_Device *dev)
{ {
int i; int i;
yaffs_ExtendedTags tags; yaffs_ExtendedTags tags;
T(YAFFS_TRACE_CHECKPOINT,(TSTR("find next checkpt block: start: blocks %d next %d" TENDSTR), T(YAFFS_TRACE_CHECKPOINT,(TSTR("find next checkpt block: start: blocks %d next %d" TENDSTR),
dev->blocksInCheckpoint, dev->checkpointNextBlock)); dev->blocksInCheckpoint, dev->checkpointNextBlock));
if(dev->blocksInCheckpoint < dev->checkpointMaxBlocks) if(dev->blocksInCheckpoint < dev->checkpointMaxBlocks)
for(i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++){ for(i = dev->checkpointNextBlock; i <= dev->internalEndBlock; i++){
int chunk = i * dev->nChunksPerBlock; int chunk = i * dev->nChunksPerBlock;
int realignedChunk = chunk - dev->chunkOffset; int realignedChunk = chunk - dev->chunkOffset;
dev->readChunkWithTagsFromNAND(dev,realignedChunk,NULL,&tags); dev->readChunkWithTagsFromNAND(dev,realignedChunk,NULL,&tags);
T(YAFFS_TRACE_CHECKPOINT,(TSTR("find next checkpt block: search: block %d oid %d seq %d eccr %d" TENDSTR), T(YAFFS_TRACE_CHECKPOINT,(TSTR("find next checkpt block: search: block %d oid %d seq %d eccr %d" TENDSTR),
i, tags.objectId,tags.sequenceNumber,tags.eccResult)); i, tags.objectId,tags.sequenceNumber,tags.eccResult));
if(tags.sequenceNumber == YAFFS_SEQUENCE_CHECKPOINT_DATA){ if(tags.sequenceNumber == YAFFS_SEQUENCE_CHECKPOINT_DATA){
/* Right kind of block */ /* Right kind of block */
dev->checkpointNextBlock = tags.objectId; dev->checkpointNextBlock = tags.objectId;
@ -130,7 +130,7 @@ static void yaffs_CheckpointFindNextCheckpointBlock(yaffs_Device *dev)
int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting) int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
{ {
/* Got the functions we need? */ /* Got the functions we need? */
if (!dev->writeChunkWithTagsToNAND || if (!dev->writeChunkWithTagsToNAND ||
!dev->readChunkWithTagsFromNAND || !dev->readChunkWithTagsFromNAND ||
@ -140,31 +140,31 @@ int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
if(forWriting && !yaffs_CheckpointSpaceOk(dev)) if(forWriting && !yaffs_CheckpointSpaceOk(dev))
return 0; return 0;
if(!dev->checkpointBuffer) if(!dev->checkpointBuffer)
dev->checkpointBuffer = YMALLOC_DMA(dev->nDataBytesPerChunk); dev->checkpointBuffer = YMALLOC_DMA(dev->nDataBytesPerChunk);
if(!dev->checkpointBuffer) if(!dev->checkpointBuffer)
return 0; return 0;
dev->checkpointPageSequence = 0; dev->checkpointPageSequence = 0;
dev->checkpointOpenForWrite = forWriting; dev->checkpointOpenForWrite = forWriting;
dev->checkpointByteCount = 0; dev->checkpointByteCount = 0;
dev->checkpointSum = 0; dev->checkpointSum = 0;
dev->checkpointXor = 0; dev->checkpointXor = 0;
dev->checkpointCurrentBlock = -1; dev->checkpointCurrentBlock = -1;
dev->checkpointCurrentChunk = -1; dev->checkpointCurrentChunk = -1;
dev->checkpointNextBlock = dev->internalStartBlock; dev->checkpointNextBlock = dev->internalStartBlock;
/* Erase all the blocks in the checkpoint area */ /* Erase all the blocks in the checkpoint area */
if(forWriting){ if(forWriting){
memset(dev->checkpointBuffer,0,dev->nDataBytesPerChunk); memset(dev->checkpointBuffer,0,dev->nDataBytesPerChunk);
dev->checkpointByteOffset = 0; dev->checkpointByteOffset = 0;
return yaffs_CheckpointErase(dev); return yaffs_CheckpointErase(dev);
} else { } else {
int i; int i;
/* Set to a value that will kick off a read */ /* Set to a value that will kick off a read */
@ -177,7 +177,7 @@ int yaffs_CheckpointOpen(yaffs_Device *dev, int forWriting)
for(i = 0; i < dev->checkpointMaxBlocks; i++) for(i = 0; i < dev->checkpointMaxBlocks; i++)
dev->checkpointBlockList[i] = -1; dev->checkpointBlockList[i] = -1;
} }
return 1; return 1;
} }
@ -196,15 +196,15 @@ static int yaffs_CheckpointFlushBuffer(yaffs_Device *dev)
int realignedChunk; int realignedChunk;
yaffs_ExtendedTags tags; yaffs_ExtendedTags tags;
if(dev->checkpointCurrentBlock < 0){ if(dev->checkpointCurrentBlock < 0){
yaffs_CheckpointFindNextErasedBlock(dev); yaffs_CheckpointFindNextErasedBlock(dev);
dev->checkpointCurrentChunk = 0; dev->checkpointCurrentChunk = 0;
} }
if(dev->checkpointCurrentBlock < 0) if(dev->checkpointCurrentBlock < 0)
return 0; return 0;
tags.chunkDeleted = 0; tags.chunkDeleted = 0;
tags.objectId = dev->checkpointNextBlock; /* Hint to next place to look */ tags.objectId = dev->checkpointNextBlock; /* Hint to next place to look */
tags.chunkId = dev->checkpointPageSequence + 1; tags.chunkId = dev->checkpointPageSequence + 1;
@ -217,25 +217,25 @@ static int yaffs_CheckpointFlushBuffer(yaffs_Device *dev)
bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT; bi->blockState = YAFFS_BLOCK_STATE_CHECKPOINT;
dev->blocksInCheckpoint++; dev->blocksInCheckpoint++;
} }
chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock + dev->checkpointCurrentChunk; chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock + dev->checkpointCurrentChunk;
T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint wite buffer nand %d(%d:%d) objid %d chId %d" TENDSTR), T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint wite buffer nand %d(%d:%d) objid %d chId %d" TENDSTR),
chunk, dev->checkpointCurrentBlock, dev->checkpointCurrentChunk,tags.objectId,tags.chunkId)); chunk, dev->checkpointCurrentBlock, dev->checkpointCurrentChunk,tags.objectId,tags.chunkId));
realignedChunk = chunk - dev->chunkOffset; realignedChunk = chunk - dev->chunkOffset;
dev->writeChunkWithTagsToNAND(dev,realignedChunk,dev->checkpointBuffer,&tags); dev->writeChunkWithTagsToNAND(dev,realignedChunk,dev->checkpointBuffer,&tags);
dev->checkpointByteOffset = 0; dev->checkpointByteOffset = 0;
dev->checkpointPageSequence++; dev->checkpointPageSequence++;
dev->checkpointCurrentChunk++; dev->checkpointCurrentChunk++;
if(dev->checkpointCurrentChunk >= dev->nChunksPerBlock){ if(dev->checkpointCurrentChunk >= dev->nChunksPerBlock){
dev->checkpointCurrentChunk = 0; dev->checkpointCurrentChunk = 0;
dev->checkpointCurrentBlock = -1; dev->checkpointCurrentBlock = -1;
} }
memset(dev->checkpointBuffer,0,dev->nDataBytesPerChunk); memset(dev->checkpointBuffer,0,dev->nDataBytesPerChunk);
return 1; return 1;
} }
@ -245,37 +245,37 @@ int yaffs_CheckpointWrite(yaffs_Device *dev,const void *data, int nBytes)
int i=0; int i=0;
int ok = 1; int ok = 1;
__u8 * dataBytes = (__u8 *)data; __u8 * dataBytes = (__u8 *)data;
if(!dev->checkpointBuffer) if(!dev->checkpointBuffer)
return 0; return 0;
if(!dev->checkpointOpenForWrite) if(!dev->checkpointOpenForWrite)
return -1; return -1;
while(i < nBytes && ok) { while(i < nBytes && ok) {
dev->checkpointBuffer[dev->checkpointByteOffset] = *dataBytes ; dev->checkpointBuffer[dev->checkpointByteOffset] = *dataBytes ;
dev->checkpointSum += *dataBytes; dev->checkpointSum += *dataBytes;
dev->checkpointXor ^= *dataBytes; dev->checkpointXor ^= *dataBytes;
dev->checkpointByteOffset++; dev->checkpointByteOffset++;
i++; i++;
dataBytes++; dataBytes++;
dev->checkpointByteCount++; dev->checkpointByteCount++;
if(dev->checkpointByteOffset < 0 || if(dev->checkpointByteOffset < 0 ||
dev->checkpointByteOffset >= dev->nDataBytesPerChunk) dev->checkpointByteOffset >= dev->nDataBytesPerChunk)
ok = yaffs_CheckpointFlushBuffer(dev); ok = yaffs_CheckpointFlushBuffer(dev);
} }
return i; return i;
} }
@ -285,12 +285,12 @@ int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
int ok = 1; int ok = 1;
yaffs_ExtendedTags tags; yaffs_ExtendedTags tags;
int chunk; int chunk;
int realignedChunk; int realignedChunk;
__u8 *dataBytes = (__u8 *)data; __u8 *dataBytes = (__u8 *)data;
if(!dev->checkpointBuffer) if(!dev->checkpointBuffer)
return 0; return 0;
@ -298,31 +298,31 @@ int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
return -1; return -1;
while(i < nBytes && ok) { while(i < nBytes && ok) {
if(dev->checkpointByteOffset < 0 || if(dev->checkpointByteOffset < 0 ||
dev->checkpointByteOffset >= dev->nDataBytesPerChunk) { dev->checkpointByteOffset >= dev->nDataBytesPerChunk) {
if(dev->checkpointCurrentBlock < 0){ if(dev->checkpointCurrentBlock < 0){
yaffs_CheckpointFindNextCheckpointBlock(dev); yaffs_CheckpointFindNextCheckpointBlock(dev);
dev->checkpointCurrentChunk = 0; dev->checkpointCurrentChunk = 0;
} }
if(dev->checkpointCurrentBlock < 0) if(dev->checkpointCurrentBlock < 0)
ok = 0; ok = 0;
else { else {
chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock + chunk = dev->checkpointCurrentBlock * dev->nChunksPerBlock +
dev->checkpointCurrentChunk; dev->checkpointCurrentChunk;
realignedChunk = chunk - dev->chunkOffset; realignedChunk = chunk - dev->chunkOffset;
/* read in the next chunk */ /* read in the next chunk */
/* printf("read checkpoint page %d\n",dev->checkpointPage); */ /* printf("read checkpoint page %d\n",dev->checkpointPage); */
dev->readChunkWithTagsFromNAND(dev, realignedChunk, dev->readChunkWithTagsFromNAND(dev, realignedChunk,
dev->checkpointBuffer, dev->checkpointBuffer,
&tags); &tags);
if(tags.chunkId != (dev->checkpointPageSequence + 1) || if(tags.chunkId != (dev->checkpointPageSequence + 1) ||
tags.sequenceNumber != YAFFS_SEQUENCE_CHECKPOINT_DATA) tags.sequenceNumber != YAFFS_SEQUENCE_CHECKPOINT_DATA)
ok = 0; ok = 0;
@ -330,12 +330,12 @@ int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
dev->checkpointByteOffset = 0; dev->checkpointByteOffset = 0;
dev->checkpointPageSequence++; dev->checkpointPageSequence++;
dev->checkpointCurrentChunk++; dev->checkpointCurrentChunk++;
if(dev->checkpointCurrentChunk >= dev->nChunksPerBlock) if(dev->checkpointCurrentChunk >= dev->nChunksPerBlock)
dev->checkpointCurrentBlock = -1; dev->checkpointCurrentBlock = -1;
} }
} }
if(ok){ if(ok){
*dataBytes = dev->checkpointBuffer[dev->checkpointByteOffset]; *dataBytes = dev->checkpointBuffer[dev->checkpointByteOffset];
dev->checkpointSum += *dataBytes; dev->checkpointSum += *dataBytes;
@ -346,14 +346,14 @@ int yaffs_CheckpointRead(yaffs_Device *dev, void *data, int nBytes)
dev->checkpointByteCount++; dev->checkpointByteCount++;
} }
} }
return i; return i;
} }
int yaffs_CheckpointClose(yaffs_Device *dev) int yaffs_CheckpointClose(yaffs_Device *dev)
{ {
if(dev->checkpointOpenForWrite){ if(dev->checkpointOpenForWrite){
if(dev->checkpointByteOffset != 0) if(dev->checkpointByteOffset != 0)
yaffs_CheckpointFlushBuffer(dev); yaffs_CheckpointFlushBuffer(dev);
} else { } else {
@ -373,19 +373,19 @@ int yaffs_CheckpointClose(yaffs_Device *dev)
dev->nFreeChunks -= dev->blocksInCheckpoint * dev->nChunksPerBlock; dev->nFreeChunks -= dev->blocksInCheckpoint * dev->nChunksPerBlock;
dev->nErasedBlocks -= dev->blocksInCheckpoint; dev->nErasedBlocks -= dev->blocksInCheckpoint;
T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint byte count %d" TENDSTR), T(YAFFS_TRACE_CHECKPOINT,(TSTR("checkpoint byte count %d" TENDSTR),
dev->checkpointByteCount)); dev->checkpointByteCount));
if(dev->checkpointBuffer){ if(dev->checkpointBuffer){
/* free the buffer */ /* free the buffer */
YFREE(dev->checkpointBuffer); YFREE(dev->checkpointBuffer);
dev->checkpointBuffer = NULL; dev->checkpointBuffer = NULL;
return 1; return 1;
} }
else else
return 0; return 0;
} }
int yaffs_CheckpointInvalidateStream(yaffs_Device *dev) int yaffs_CheckpointInvalidateStream(yaffs_Device *dev)

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -14,9 +14,9 @@
/* /*
* This code implements the ECC algorithm used in SmartMedia. * This code implements the ECC algorithm used in SmartMedia.
* *
* The ECC comprises 22 bits of parity information and is stuffed into 3 bytes. * The ECC comprises 22 bits of parity information and is stuffed into 3 bytes.
* The two unused bit are set to 1. * The two unused bit are set to 1.
* The ECC can correct single bit errors in a 256-byte page of data. Thus, two such ECC * The ECC can correct single bit errors in a 256-byte page of data. Thus, two such ECC
* blocks are used on a 512-byte NAND page. * blocks are used on a 512-byte NAND page.
* *
*/ */
@ -228,8 +228,8 @@ int yaffs_ECCCorrect(unsigned char *data, unsigned char *read_ecc,
return 1; /* Corrected the error */ return 1; /* Corrected the error */
} }
if ((yaffs_CountBits(d0) + if ((yaffs_CountBits(d0) +
yaffs_CountBits(d1) + yaffs_CountBits(d1) +
yaffs_CountBits(d2)) == 1) { yaffs_CountBits(d2)) == 1) {
/* Reccoverable error in ecc */ /* Reccoverable error in ecc */
@ -239,7 +239,7 @@ int yaffs_ECCCorrect(unsigned char *data, unsigned char *read_ecc,
return 1; /* Corrected the error */ return 1; /* Corrected the error */
} }
/* Unrecoverable error */ /* Unrecoverable error */
return -1; return -1;
@ -293,7 +293,7 @@ int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes,
if ((cDelta | lDelta | lDeltaPrime) == 0) if ((cDelta | lDelta | lDeltaPrime) == 0)
return 0; /* no error */ return 0; /* no error */
if (lDelta == ~lDeltaPrime && if (lDelta == ~lDeltaPrime &&
(((cDelta ^ (cDelta >> 1)) & 0x15) == 0x15)) (((cDelta ^ (cDelta >> 1)) & 0x15) == 0x15))
{ {
/* Single bit (recoverable) error in data */ /* Single bit (recoverable) error in data */
@ -309,7 +309,7 @@ int yaffs_ECCCorrectOther(unsigned char *data, unsigned nBytes,
if(lDelta >= nBytes) if(lDelta >= nBytes)
return -1; return -1;
data[lDelta] ^= (1 << bit); data[lDelta] ^= (1 << bit);
return 1; /* corrected */ return 1; /* corrected */

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering
@ -16,9 +16,9 @@
/* /*
* This code implements the ECC algorithm used in SmartMedia. * This code implements the ECC algorithm used in SmartMedia.
* *
* The ECC comprises 22 bits of parity information and is stuffed into 3 bytes. * The ECC comprises 22 bits of parity information and is stuffed into 3 bytes.
* The two unused bit are set to 1. * The two unused bit are set to 1.
* The ECC can correct single bit errors in a 256-byte page of data. Thus, two such ECC * The ECC can correct single bit errors in a 256-byte page of data. Thus, two such ECC
* blocks are used on a 512-byte NAND page. * blocks are used on a 512-byte NAND page.
* *
*/ */

View File

@ -23,7 +23,7 @@
* This is the file system front-end to YAFFS that hooks it up to * This is the file system front-end to YAFFS that hooks it up to
* the VFS. * the VFS.
* *
* Special notes: * Special notes:
* >> 2.4: sb->u.generic_sbp points to the yaffs_Device associated with * >> 2.4: sb->u.generic_sbp points to the yaffs_Device associated with
* this superblock * this superblock
* >> 2.6: sb->s_fs_info points to the yaffs_Device associated with this * >> 2.6: sb->s_fs_info points to the yaffs_Device associated with this
@ -391,7 +391,7 @@ static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry)
dentry->d_name.name); dentry->d_name.name);
obj = yaffs_GetEquivalentObject(obj); /* in case it was a hardlink */ obj = yaffs_GetEquivalentObject(obj); /* in case it was a hardlink */
/* Can't hold gross lock when calling yaffs_get_inode() */ /* Can't hold gross lock when calling yaffs_get_inode() */
yaffs_GrossUnlock(dev); yaffs_GrossUnlock(dev);
@ -729,21 +729,21 @@ static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object * obj)
obj->yst_mode &= ~S_IFMT; obj->yst_mode &= ~S_IFMT;
obj->yst_mode |= S_IFREG; obj->yst_mode |= S_IFREG;
} }
break; break;
case YAFFS_OBJECT_TYPE_SYMLINK : case YAFFS_OBJECT_TYPE_SYMLINK :
if( ! S_ISLNK(mode) ){ if( ! S_ISLNK(mode) ){
obj->yst_mode &= ~S_IFMT; obj->yst_mode &= ~S_IFMT;
obj->yst_mode |= S_IFLNK; obj->yst_mode |= S_IFLNK;
} }
break; break;
case YAFFS_OBJECT_TYPE_DIRECTORY : case YAFFS_OBJECT_TYPE_DIRECTORY :
if( ! S_ISDIR(mode) ){ if( ! S_ISDIR(mode) ){
obj->yst_mode &= ~S_IFMT; obj->yst_mode &= ~S_IFMT;
obj->yst_mode |= S_IFDIR; obj->yst_mode |= S_IFDIR;
} }
break; break;
case YAFFS_OBJECT_TYPE_UNKNOWN : case YAFFS_OBJECT_TYPE_UNKNOWN :
case YAFFS_OBJECT_TYPE_HARDLINK : case YAFFS_OBJECT_TYPE_HARDLINK :
@ -1020,7 +1020,7 @@ static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
int error = -ENOSPC; int error = -ENOSPC;
uid_t uid = current->fsuid; uid_t uid = current->fsuid;
gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid; gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
if((dir->i_mode & S_ISGID) && S_ISDIR(mode)) if((dir->i_mode & S_ISGID) && S_ISDIR(mode))
mode |= S_ISGID; mode |= S_ISGID;
@ -1075,7 +1075,7 @@ static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
obj = NULL; /* Do we ever get here? */ obj = NULL; /* Do we ever get here? */
break; break;
} }
/* Can not call yaffs_get_inode() with gross lock held */ /* Can not call yaffs_get_inode() with gross lock held */
yaffs_GrossUnlock(dev); yaffs_GrossUnlock(dev);
@ -1264,13 +1264,13 @@ static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
target = target =
yaffs_FindObjectByName(yaffs_InodeToObject(new_dir), yaffs_FindObjectByName(yaffs_InodeToObject(new_dir),
new_dentry->d_name.name); new_dentry->d_name.name);
if (target && if (target &&
target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY && target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
!list_empty(&target->variant.directoryVariant.children)) { !list_empty(&target->variant.directoryVariant.children)) {
T(YAFFS_TRACE_OS, (KERN_DEBUG "target is non-empty dir\n")); T(YAFFS_TRACE_OS, (KERN_DEBUG "target is non-empty dir\n"));
retVal = YAFFS_FAIL; retVal = YAFFS_FAIL;
@ -1278,7 +1278,7 @@ static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
/* Now does unlinking internally using shadowing mechanism */ /* Now does unlinking internally using shadowing mechanism */
T(YAFFS_TRACE_OS, (KERN_DEBUG "calling yaffs_RenameObject\n")); T(YAFFS_TRACE_OS, (KERN_DEBUG "calling yaffs_RenameObject\n"));
retVal = retVal =
yaffs_RenameObject(yaffs_InodeToObject(old_dir), yaffs_RenameObject(yaffs_InodeToObject(old_dir),
old_dentry->d_name.name, old_dentry->d_name.name,
@ -1390,7 +1390,7 @@ static int yaffs_do_sync_fs(struct super_block *sb)
if(dev) if(dev)
yaffs_CheckpointSave(dev); yaffs_CheckpointSave(dev);
yaffs_GrossUnlock(dev); yaffs_GrossUnlock(dev);
sb->s_dirt = 0; sb->s_dirt = 0;
@ -1421,16 +1421,16 @@ static int yaffs_sync_fs(struct super_block *sb)
{ {
T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_sync_fs\n")); T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_sync_fs\n"));
return 0; /* yaffs_do_sync_fs(sb);*/ return 0; /* yaffs_do_sync_fs(sb);*/
} }
static void yaffs_read_inode(struct inode *inode) static void yaffs_read_inode(struct inode *inode)
{ {
/* NB This is called as a side effect of other functions, but /* NB This is called as a side effect of other functions, but
* we had to release the lock to prevent deadlocks, so * we had to release the lock to prevent deadlocks, so
* need to lock again. * need to lock again.
*/ */
@ -1441,7 +1441,7 @@ static void yaffs_read_inode(struct inode *inode)
(KERN_DEBUG "yaffs_read_inode for %d\n", (int)inode->i_ino)); (KERN_DEBUG "yaffs_read_inode for %d\n", (int)inode->i_ino));
yaffs_GrossLock(dev); yaffs_GrossLock(dev);
obj = yaffs_FindObjectByNumber(dev, inode->i_ino); obj = yaffs_FindObjectByNumber(dev, inode->i_ino);
yaffs_FillInodeFromObject(inode, obj); yaffs_FillInodeFromObject(inode, obj);
@ -1458,26 +1458,26 @@ static int yaffs_remount_fs(struct super_block *sb, int *flags, char *data)
if( *flags & MS_RDONLY ) { if( *flags & MS_RDONLY ) {
struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice; struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
T(YAFFS_TRACE_OS, T(YAFFS_TRACE_OS,
(KERN_DEBUG "yaffs_remount_fs: %s: RO\n", dev->name )); (KERN_DEBUG "yaffs_remount_fs: %s: RO\n", dev->name ));
yaffs_GrossLock(dev); yaffs_GrossLock(dev);
yaffs_FlushEntireDeviceCache(dev); yaffs_FlushEntireDeviceCache(dev);
yaffs_CheckpointSave(dev); yaffs_CheckpointSave(dev);
if (mtd->sync) if (mtd->sync)
mtd->sync(mtd); mtd->sync(mtd);
yaffs_GrossUnlock(dev); yaffs_GrossUnlock(dev);
} }
else { else {
T(YAFFS_TRACE_OS, T(YAFFS_TRACE_OS,
(KERN_DEBUG "yaffs_remount_fs: %s: RW\n", dev->name )); (KERN_DEBUG "yaffs_remount_fs: %s: RW\n", dev->name ));
} }
return 0; return 0;
} }
#endif #endif
@ -1489,7 +1489,7 @@ static void yaffs_put_super(struct super_block *sb)
T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_put_super\n")); T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_put_super\n"));
yaffs_GrossLock(dev); yaffs_GrossLock(dev);
yaffs_FlushEntireDeviceCache(dev); yaffs_FlushEntireDeviceCache(dev);
yaffs_CheckpointSave(dev); yaffs_CheckpointSave(dev);
@ -1499,12 +1499,12 @@ static void yaffs_put_super(struct super_block *sb)
} }
yaffs_Deinitialise(dev); yaffs_Deinitialise(dev);
yaffs_GrossUnlock(dev); yaffs_GrossUnlock(dev);
/* we assume this is protected by lock_kernel() in mount/umount */ /* we assume this is protected by lock_kernel() in mount/umount */
list_del(&dev->devList); list_del(&dev->devList);
if(dev->spareBuffer){ if(dev->spareBuffer){
YFREE(dev->spareBuffer); YFREE(dev->spareBuffer);
dev->spareBuffer = NULL; dev->spareBuffer = NULL;
@ -1530,7 +1530,7 @@ static void yaffs_MTDPutSuper(struct super_block *sb)
static void yaffs_MarkSuperBlockDirty(void *vsb) static void yaffs_MarkSuperBlockDirty(void *vsb)
{ {
struct super_block *sb = (struct super_block *)vsb; struct super_block *sb = (struct super_block *)vsb;
T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_MarkSuperBlockDirty() sb = %p\n",sb)); T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_MarkSuperBlockDirty() sb = %p\n",sb));
// if(sb) // if(sb)
// sb->s_dirt = 1; // sb->s_dirt = 1;
@ -1549,13 +1549,13 @@ static int yaffs_parse_options(yaffs_options *options, const char *options_str)
char cur_opt[MAX_OPT_LEN+1]; char cur_opt[MAX_OPT_LEN+1];
int p; int p;
int error = 0; int error = 0;
/* Parse through the options which is a comma seperated list */ /* Parse through the options which is a comma seperated list */
while(options_str && *options_str && !error){ while(options_str && *options_str && !error){
memset(cur_opt,0,MAX_OPT_LEN+1); memset(cur_opt,0,MAX_OPT_LEN+1);
p = 0; p = 0;
while(*options_str && *options_str != ','){ while(*options_str && *options_str != ','){
if(p < MAX_OPT_LEN){ if(p < MAX_OPT_LEN){
cur_opt[p] = *options_str; cur_opt[p] = *options_str;
@ -1563,7 +1563,7 @@ static int yaffs_parse_options(yaffs_options *options, const char *options_str)
} }
options_str++; options_str++;
} }
if(!strcmp(cur_opt,"inband-tags")) if(!strcmp(cur_opt,"inband-tags"))
options->inband_tags = 1; options->inband_tags = 1;
else if(!strcmp(cur_opt,"no-cache")) else if(!strcmp(cur_opt,"no-cache"))
@ -1579,7 +1579,7 @@ static int yaffs_parse_options(yaffs_options *options, const char *options_str)
printk(KERN_INFO "yaffs: Bad mount option \"%s\"\n",cur_opt); printk(KERN_INFO "yaffs: Bad mount option \"%s\"\n",cur_opt);
error = 1; error = 1;
} }
} }
return error; return error;
@ -1597,7 +1597,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
struct mtd_info *mtd; struct mtd_info *mtd;
int err; int err;
char *data_str = (char *)data; char *data_str = (char *)data;
yaffs_options options; yaffs_options options;
sb->s_magic = YAFFS_MAGIC; sb->s_magic = YAFFS_MAGIC;
@ -1613,14 +1613,14 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
printk(KERN_INFO "yaffs: dev is %d name is \"%s\"\n", printk(KERN_INFO "yaffs: dev is %d name is \"%s\"\n",
sb->s_dev, sb->s_dev,
yaffs_devname(sb, devname_buf)); yaffs_devname(sb, devname_buf));
if(!data_str) if(!data_str)
data_str = ""; data_str = "";
printk(KERN_INFO "yaffs: passed flags \"%s\"\n",data_str); printk(KERN_INFO "yaffs: passed flags \"%s\"\n",data_str);
memset(&options,0,sizeof(options)); memset(&options,0,sizeof(options));
if(yaffs_parse_options(&options,data_str)){ if(yaffs_parse_options(&options,data_str)){
/* Option parsing failed */ /* Option parsing failed */
return NULL; return NULL;
@ -1674,10 +1674,10 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
T(YAFFS_TRACE_OS, (" oobsize %d\n", mtd->oobsize)); T(YAFFS_TRACE_OS, (" oobsize %d\n", mtd->oobsize));
T(YAFFS_TRACE_OS, (" erasesize %d\n", mtd->erasesize)); T(YAFFS_TRACE_OS, (" erasesize %d\n", mtd->erasesize));
T(YAFFS_TRACE_OS, (" size %d\n", mtd->size)); T(YAFFS_TRACE_OS, (" size %d\n", mtd->size));
#ifdef CONFIG_YAFFS_AUTO_YAFFS2 #ifdef CONFIG_YAFFS_AUTO_YAFFS2
if (yaffsVersion == 1 && if (yaffsVersion == 1 &&
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17)) #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
mtd->writesize >= 2048) { mtd->writesize >= 2048) {
#else #else
@ -1685,10 +1685,10 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
#endif #endif
T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs2\n")); T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs2\n"));
yaffsVersion = 2; yaffsVersion = 2;
} }
/* Added NCB 26/5/2006 for completeness */ /* Added NCB 26/5/2006 for completeness */
if (yaffsVersion == 2 && if (yaffsVersion == 2 &&
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17)) #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,17))
mtd->writesize == 512) { mtd->writesize == 512) {
#else #else
@ -1696,7 +1696,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
#endif #endif
T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs1\n")); T(YAFFS_TRACE_ALWAYS,("yaffs: auto selecting yaffs1\n"));
yaffsVersion = 1; yaffsVersion = 1;
} }
#endif #endif
@ -1830,10 +1830,10 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
dev->initialiseNAND = nandmtd_InitialiseNAND; dev->initialiseNAND = nandmtd_InitialiseNAND;
dev->putSuperFunc = yaffs_MTDPutSuper; dev->putSuperFunc = yaffs_MTDPutSuper;
dev->superBlock = (void *)sb; dev->superBlock = (void *)sb;
dev->markSuperBlockDirty = yaffs_MarkSuperBlockDirty; dev->markSuperBlockDirty = yaffs_MarkSuperBlockDirty;
#ifndef CONFIG_YAFFS_DOES_ECC #ifndef CONFIG_YAFFS_DOES_ECC
dev->useNANDECC = 1; dev->useNANDECC = 1;
@ -1845,7 +1845,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
dev->skipCheckpointRead = options.skip_checkpoint_read; dev->skipCheckpointRead = options.skip_checkpoint_read;
dev->skipCheckpointWrite = options.skip_checkpoint_write; dev->skipCheckpointWrite = options.skip_checkpoint_write;
/* we assume this is protected by lock_kernel() in mount/umount */ /* we assume this is protected by lock_kernel() in mount/umount */
list_add_tail(&dev->devList, &yaffs_dev_list); list_add_tail(&dev->devList, &yaffs_dev_list);
@ -1858,7 +1858,7 @@ static struct super_block *yaffs_internal_read_super(int yaffsVersion,
T(YAFFS_TRACE_OS, T(YAFFS_TRACE_OS,
("yaffs_read_super: guts initialised %s\n", ("yaffs_read_super: guts initialised %s\n",
(err == YAFFS_OK) ? "OK" : "FAILED")); (err == YAFFS_OK) ? "OK" : "FAILED"));
/* Release lock before yaffs_get_inode() */ /* Release lock before yaffs_get_inode() */
yaffs_GrossUnlock(dev); yaffs_GrossUnlock(dev);
@ -2118,7 +2118,7 @@ static int yaffs_proc_write(struct file *file, const char *buf,
unsigned rg = 0, mask_bitfield; unsigned rg = 0, mask_bitfield;
char *end; char *end;
char *mask_name; char *mask_name;
const char *x; const char *x;
char substring[MAX_MASK_NAME_LENGTH+1]; char substring[MAX_MASK_NAME_LENGTH+1];
int i; int i;
int done = 0; int done = 0;
@ -2146,7 +2146,7 @@ static int yaffs_proc_write(struct file *file, const char *buf,
break; break;
} }
mask_name = NULL; mask_name = NULL;
mask_bitfield = simple_strtoul(buf + pos, &end, 0); mask_bitfield = simple_strtoul(buf + pos, &end, 0);
if (end > buf + pos) { if (end > buf + pos) {
mask_name = "numeral"; mask_name = "numeral";
@ -2154,12 +2154,12 @@ static int yaffs_proc_write(struct file *file, const char *buf,
pos += len; pos += len;
done = 0; done = 0;
} else { } else {
for(x = buf + pos, i = 0; for(x = buf + pos, i = 0;
(*x == '_' || (*x >='a' && *x <= 'z')) && (*x == '_' || (*x >='a' && *x <= 'z')) &&
i <MAX_MASK_NAME_LENGTH; x++, i++, pos++) i <MAX_MASK_NAME_LENGTH; x++, i++, pos++)
substring[i] = *x; substring[i] = *x;
substring[i] = '\0'; substring[i] = '\0';
for (i = 0; mask_flags[i].mask_name != NULL; i++) { for (i = 0; mask_flags[i].mask_name != NULL; i++) {
if(strcmp(substring,mask_flags[i].mask_name) == 0){ if(strcmp(substring,mask_flags[i].mask_name) == 0){
mask_name = mask_flags[i].mask_name; mask_name = mask_flags[i].mask_name;
@ -2190,9 +2190,9 @@ static int yaffs_proc_write(struct file *file, const char *buf,
} }
yaffs_traceMask = rg | YAFFS_TRACE_ALWAYS; yaffs_traceMask = rg | YAFFS_TRACE_ALWAYS;
printk("new trace = 0x%08X\n",yaffs_traceMask); printk("new trace = 0x%08X\n",yaffs_traceMask);
if (rg & YAFFS_TRACE_ALWAYS) { if (rg & YAFFS_TRACE_ALWAYS) {
for (i = 0; mask_flags[i].mask_name != NULL; i++) { for (i = 0; mask_flags[i].mask_name != NULL; i++) {
char flag; char flag;

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering
@ -22,11 +22,11 @@
#define YAFFS_OK 1 #define YAFFS_OK 1
#define YAFFS_FAIL 0 #define YAFFS_FAIL 0
/* Give us a Y=0x59, /* Give us a Y=0x59,
* Give us an A=0x41, * Give us an A=0x41,
* Give us an FF=0xFF * Give us an FF=0xFF
* Give us an S=0x53 * Give us an S=0x53
* And what have we got... * And what have we got...
*/ */
#define YAFFS_MAGIC 0x5941FF53 #define YAFFS_MAGIC 0x5941FF53
@ -102,7 +102,7 @@
* The range is limited slightly to help distinguish bad numbers from good. * The range is limited slightly to help distinguish bad numbers from good.
* This also allows us to perhaps in the future use special numbers for * This also allows us to perhaps in the future use special numbers for
* special purposes. * special purposes.
* EFFFFF00 allows the allocation of 8 blocks per second (~1Mbytes) for 15 years, * EFFFFF00 allows the allocation of 8 blocks per second (~1Mbytes) for 15 years,
* and is a larger number than the lifetime of a 2GB device. * and is a larger number than the lifetime of a 2GB device.
*/ */
#define YAFFS_LOWEST_SEQUENCE_NUMBER 0x00001000 #define YAFFS_LOWEST_SEQUENCE_NUMBER 0x00001000
@ -178,7 +178,7 @@ typedef struct {
/* The following stuff only has meaning when we read */ /* The following stuff only has meaning when we read */
yaffs_ECCResult eccResult; yaffs_ECCResult eccResult;
unsigned blockBad; unsigned blockBad;
/* YAFFS 1 stuff */ /* YAFFS 1 stuff */
unsigned chunkDeleted; /* The chunk is marked deleted */ unsigned chunkDeleted; /* The chunk is marked deleted */
@ -244,29 +244,29 @@ typedef enum {
/* This block is empty */ /* This block is empty */
YAFFS_BLOCK_STATE_ALLOCATING, YAFFS_BLOCK_STATE_ALLOCATING,
/* This block is partially allocated. /* This block is partially allocated.
* At least one page holds valid data. * At least one page holds valid data.
* This is the one currently being used for page * This is the one currently being used for page
* allocation. Should never be more than one of these * allocation. Should never be more than one of these
*/ */
YAFFS_BLOCK_STATE_FULL, YAFFS_BLOCK_STATE_FULL,
/* All the pages in this block have been allocated. /* All the pages in this block have been allocated.
*/ */
YAFFS_BLOCK_STATE_DIRTY, YAFFS_BLOCK_STATE_DIRTY,
/* All pages have been allocated and deleted. /* All pages have been allocated and deleted.
* Erase me, reuse me. * Erase me, reuse me.
*/ */
YAFFS_BLOCK_STATE_CHECKPOINT, YAFFS_BLOCK_STATE_CHECKPOINT,
/* This block is assigned to holding checkpoint data. /* This block is assigned to holding checkpoint data.
*/ */
YAFFS_BLOCK_STATE_COLLECTING, YAFFS_BLOCK_STATE_COLLECTING,
/* This block is being garbage collected */ /* This block is being garbage collected */
YAFFS_BLOCK_STATE_DEAD YAFFS_BLOCK_STATE_DEAD
/* This block has failed and is not in use */ /* This block has failed and is not in use */
} yaffs_BlockState; } yaffs_BlockState;
@ -281,7 +281,7 @@ typedef struct {
__u32 needsRetiring:1; /* Data has failed on this block, need to get valid data off */ __u32 needsRetiring:1; /* Data has failed on this block, need to get valid data off */
/* and retire the block. */ /* and retire the block. */
__u32 skipErasedCheck: 1; /* If this is set we can skip the erased check on this block */ __u32 skipErasedCheck: 1; /* If this is set we can skip the erased check on this block */
__u32 gcPrioritise: 1; /* An ECC check or blank check has failed on this block. __u32 gcPrioritise: 1; /* An ECC check or blank check has failed on this block.
It should be prioritised for GC */ It should be prioritised for GC */
__u32 chunkErrorStrikes:3; /* How many times we've had ecc etc failures on this block and tried to reuse it */ __u32 chunkErrorStrikes:3; /* How many times we've had ecc etc failures on this block and tried to reuse it */
@ -408,7 +408,7 @@ struct yaffs_ObjectStruct {
__u8 renameAllowed:1; /* Some objects are not allowed to be renamed. */ __u8 renameAllowed:1; /* Some objects are not allowed to be renamed. */
__u8 unlinkAllowed:1; __u8 unlinkAllowed:1;
__u8 dirty:1; /* the object needs to be written to flash */ __u8 dirty:1; /* the object needs to be written to flash */
__u8 valid:1; /* When the file system is being loaded up, this __u8 valid:1; /* When the file system is being loaded up, this
* object might be created before the data * object might be created before the data
* is available (ie. file data records appear before the header). * is available (ie. file data records appear before the header).
*/ */
@ -430,11 +430,11 @@ struct yaffs_ObjectStruct {
/* directory structure stuff */ /* directory structure stuff */
/* also used for linking up the free list */ /* also used for linking up the free list */
struct yaffs_ObjectStruct *parent; struct yaffs_ObjectStruct *parent;
struct list_head siblings; struct list_head siblings;
/* Where's my object header in NAND? */ /* Where's my object header in NAND? */
int chunkId; int chunkId;
int nDataChunks; /* Number of data chunks attached to the file. */ int nDataChunks; /* Number of data chunks attached to the file. */
@ -490,26 +490,26 @@ typedef struct {
} yaffs_ObjectBucket; } yaffs_ObjectBucket;
/* yaffs_CheckpointObject holds the definition of an object as dumped /* yaffs_CheckpointObject holds the definition of an object as dumped
* by checkpointing. * by checkpointing.
*/ */
typedef struct { typedef struct {
int structType; int structType;
__u32 objectId; __u32 objectId;
__u32 parentId; __u32 parentId;
int chunkId; int chunkId;
yaffs_ObjectType variantType:3; yaffs_ObjectType variantType:3;
__u8 deleted:1; __u8 deleted:1;
__u8 softDeleted:1; __u8 softDeleted:1;
__u8 unlinked:1; __u8 unlinked:1;
__u8 fake:1; __u8 fake:1;
__u8 renameAllowed:1; __u8 renameAllowed:1;
__u8 unlinkAllowed:1; __u8 unlinkAllowed:1;
__u8 serial; __u8 serial;
int nDataChunks; int nDataChunks;
__u32 fileSizeOrEquivalentObjectId; __u32 fileSizeOrEquivalentObjectId;
}yaffs_CheckpointObject; }yaffs_CheckpointObject;
@ -539,14 +539,14 @@ struct yaffs_DeviceStruct {
int endBlock; /* End block we're allowed to use */ int endBlock; /* End block we're allowed to use */
int nReservedBlocks; /* We want this tuneable so that we can reduce */ int nReservedBlocks; /* We want this tuneable so that we can reduce */
/* reserved blocks on NOR and RAM. */ /* reserved blocks on NOR and RAM. */
/* Stuff used by the shared space checkpointing mechanism */ /* Stuff used by the shared space checkpointing mechanism */
/* If this value is zero, then this mechanism is disabled */ /* If this value is zero, then this mechanism is disabled */
int nCheckpointReservedBlocks; /* Blocks to reserve for checkpoint data */ int nCheckpointReservedBlocks; /* Blocks to reserve for checkpoint data */
int nShortOpCaches; /* If <= 0, then short op caching is disabled, else int nShortOpCaches; /* If <= 0, then short op caching is disabled, else
@ -561,7 +561,7 @@ struct yaffs_DeviceStruct {
* On an mtd this holds the mtd pointer. * On an mtd this holds the mtd pointer.
*/ */
void *superBlock; void *superBlock;
/* NAND access functions (Must be set before calling YAFFS)*/ /* NAND access functions (Must be set before calling YAFFS)*/
int (*writeChunkToNAND) (struct yaffs_DeviceStruct * dev, int (*writeChunkToNAND) (struct yaffs_DeviceStruct * dev,
@ -587,21 +587,21 @@ struct yaffs_DeviceStruct {
#endif #endif
int isYaffs2; int isYaffs2;
/* The removeObjectCallback function must be supplied by OS flavours that /* The removeObjectCallback function must be supplied by OS flavours that
* need it. The Linux kernel does not use this, but yaffs direct does use * need it. The Linux kernel does not use this, but yaffs direct does use
* it to implement the faster readdir * it to implement the faster readdir
*/ */
void (*removeObjectCallback)(struct yaffs_ObjectStruct *obj); void (*removeObjectCallback)(struct yaffs_ObjectStruct *obj);
/* Callback to mark the superblock dirsty */ /* Callback to mark the superblock dirsty */
void (*markSuperBlockDirty)(void * superblock); void (*markSuperBlockDirty)(void * superblock);
int wideTnodesDisabled; /* Set to disable wide tnodes */ int wideTnodesDisabled; /* Set to disable wide tnodes */
/* End of stuff that must be set before initialisation. */ /* End of stuff that must be set before initialisation. */
/* Checkpoint control. Can be set before or after initialisation */ /* Checkpoint control. Can be set before or after initialisation */
__u8 skipCheckpointRead; __u8 skipCheckpointRead;
__u8 skipCheckpointWrite; __u8 skipCheckpointWrite;
@ -610,34 +610,34 @@ struct yaffs_DeviceStruct {
__u16 chunkGroupBits; /* 0 for devices <= 32MB. else log2(nchunks) - 16 */ __u16 chunkGroupBits; /* 0 for devices <= 32MB. else log2(nchunks) - 16 */
__u16 chunkGroupSize; /* == 2^^chunkGroupBits */ __u16 chunkGroupSize; /* == 2^^chunkGroupBits */
/* Stuff to support wide tnodes */ /* Stuff to support wide tnodes */
__u32 tnodeWidth; __u32 tnodeWidth;
__u32 tnodeMask; __u32 tnodeMask;
/* Stuff to support various file offses to chunk/offset translations */ /* Stuff to support various file offses to chunk/offset translations */
/* "Crumbs" for nDataBytesPerChunk not being a power of 2 */ /* "Crumbs" for nDataBytesPerChunk not being a power of 2 */
__u32 crumbMask; __u32 crumbMask;
__u32 crumbShift; __u32 crumbShift;
__u32 crumbsPerChunk; __u32 crumbsPerChunk;
/* Straight shifting for nDataBytesPerChunk being a power of 2 */ /* Straight shifting for nDataBytesPerChunk being a power of 2 */
__u32 chunkShift; __u32 chunkShift;
__u32 chunkMask; __u32 chunkMask;
#ifdef __KERNEL__ #ifdef __KERNEL__
struct semaphore sem; /* Semaphore for waiting on erasure.*/ struct semaphore sem; /* Semaphore for waiting on erasure.*/
struct semaphore grossLock; /* Gross locking semaphore */ struct semaphore grossLock; /* Gross locking semaphore */
__u8 *spareBuffer; /* For mtdif2 use. Don't know the size of the buffer __u8 *spareBuffer; /* For mtdif2 use. Don't know the size of the buffer
* at compile time so we have to allocate it. * at compile time so we have to allocate it.
*/ */
void (*putSuperFunc) (struct super_block * sb); void (*putSuperFunc) (struct super_block * sb);
#endif #endif
int isMounted; int isMounted;
int isCheckpointed; int isCheckpointed;
@ -646,7 +646,7 @@ struct yaffs_DeviceStruct {
int internalEndBlock; int internalEndBlock;
int blockOffset; int blockOffset;
int chunkOffset; int chunkOffset;
/* Runtime checkpointing stuff */ /* Runtime checkpointing stuff */
int checkpointPageSequence; /* running sequence number of checkpoint pages */ int checkpointPageSequence; /* running sequence number of checkpoint pages */
@ -662,13 +662,13 @@ struct yaffs_DeviceStruct {
int checkpointMaxBlocks; int checkpointMaxBlocks;
__u32 checkpointSum; __u32 checkpointSum;
__u32 checkpointXor; __u32 checkpointXor;
/* Block Info */ /* Block Info */
yaffs_BlockInfo *blockInfo; yaffs_BlockInfo *blockInfo;
__u8 *chunkBits; /* bitmap of chunks in use */ __u8 *chunkBits; /* bitmap of chunks in use */
unsigned blockInfoAlt:1; /* was allocated using alternative strategy */ unsigned blockInfoAlt:1; /* was allocated using alternative strategy */
unsigned chunkBitsAlt:1; /* was allocated using alternative strategy */ unsigned chunkBitsAlt:1; /* was allocated using alternative strategy */
int chunkBitmapStride; /* Number of bytes of chunkBits per block. int chunkBitmapStride; /* Number of bytes of chunkBits per block.
* Must be consistent with nChunksPerBlock. * Must be consistent with nChunksPerBlock.
*/ */
@ -716,7 +716,7 @@ struct yaffs_DeviceStruct {
int tagsEccUnfixed; int tagsEccUnfixed;
int nDeletions; int nDeletions;
int nUnmarkedDeletions; int nUnmarkedDeletions;
int hasPendingPrioritisedGCs; /* We think this device might have pending prioritised gcs */ int hasPendingPrioritisedGCs; /* We think this device might have pending prioritised gcs */
/* Special directories */ /* Special directories */
@ -727,7 +727,7 @@ struct yaffs_DeviceStruct {
* __u8 bufferedData[YAFFS_CHUNKS_PER_BLOCK][YAFFS_BYTES_PER_CHUNK]; * __u8 bufferedData[YAFFS_CHUNKS_PER_BLOCK][YAFFS_BYTES_PER_CHUNK];
* yaffs_Spare bufferedSpare[YAFFS_CHUNKS_PER_BLOCK]; * yaffs_Spare bufferedSpare[YAFFS_CHUNKS_PER_BLOCK];
*/ */
int bufferedBlock; /* Which block is buffered here? */ int bufferedBlock; /* Which block is buffered here? */
int doingBufferedBlockRewrite; int doingBufferedBlockRewrite;
@ -768,7 +768,7 @@ typedef struct {
int endBlock; int endBlock;
int rfu[100]; int rfu[100];
} yaffs_SuperBlockHeader; } yaffs_SuperBlockHeader;
/* The CheckpointDevice structure holds the device information that changes at runtime and /* The CheckpointDevice structure holds the device information that changes at runtime and
* must be preserved over unmount/mount cycles. * must be preserved over unmount/mount cycles.
*/ */

View File

@ -172,7 +172,7 @@ int nandmtd_ReadChunkFromNAND(yaffs_Device * dev, int chunkInNAND, __u8 * data,
__u8 *spareAsBytes = (__u8 *) spare; __u8 *spareAsBytes = (__u8 *) spare;
if (data && spare) { if (data && spare) {
if (dev->useNANDECC) { if (dev->useNANDECC) {
/* Careful, this call adds 2 ints */ /* Careful, this call adds 2 ints */
/* to the end of the spare data. Calling function */ /* to the end of the spare data. Calling function */
/* should allocate enough memory for spare, */ /* should allocate enough memory for spare, */

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -30,9 +30,9 @@ Message-Id: <200705181006.49860.ian@brightstareng.com>
X-Virus-Scanned: by amavisd-new at brightstareng.com X-Virus-Scanned: by amavisd-new at brightstareng.com
Status: R Status: R
X-Status: NT X-Status: NT
X-KMail-EncryptionState: X-KMail-EncryptionState:
X-KMail-SignatureState: X-KMail-SignatureState:
X-KMail-MDN-Sent: X-KMail-MDN-Sent:
--Boundary-00=_5LbTGmt62YoutxM --Boundary-00=_5LbTGmt62YoutxM
Content-Type: text/plain; Content-Type: text/plain;
@ -49,9 +49,9 @@ On Friday 18 May 2007 08:34, you wrote:
Good news! Good news!
Attached is a newer yaffs_mtdif1.c with a bandaid to help the Attached is a newer yaffs_mtdif1.c with a bandaid to help the
2.6.18 and 2.6.19 versions of MTD not trip on the oob read. 2.6.18 and 2.6.19 versions of MTD not trip on the oob read.
See the LINUX_VERSION_CODE conditional in See the LINUX_VERSION_CODE conditional in
nandmtd1_ReadChunkWithTagsFromNAND. nandmtd1_ReadChunkWithTagsFromNAND.
-imcd -imcd
@ -361,7 +361,7 @@ int nandmtd1_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
} }
/* Check any MTD prerequists. /* Check any MTD prerequists.
* *
* Returns YAFFS_OK or YAFFS_FAIL. * Returns YAFFS_OK or YAFFS_FAIL.
*/ */
static int nandmtd1_TestPrerequists(struct mtd_info * mtd) static int nandmtd1_TestPrerequists(struct mtd_info * mtd)

View File

@ -295,7 +295,7 @@ int nandmtd1_MarkNANDBlockBad(struct yaffs_DeviceStruct *dev, int blockNo)
} }
/* Check any MTD prerequists. /* Check any MTD prerequists.
* *
* Returns YAFFS_OK or YAFFS_FAIL. * Returns YAFFS_OK or YAFFS_FAIL.
*/ */
static int nandmtd1_TestPrerequists(struct mtd_info * mtd) static int nandmtd1_TestPrerequists(struct mtd_info * mtd)

View File

@ -158,7 +158,7 @@ int nandmtd2_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
if (tags) if (tags)
yaffs_UnpackTags2(tags, &pt); yaffs_UnpackTags2(tags, &pt);
if(tags && retval == -EBADMSG && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR) if(tags && retval == -EBADMSG && tags->eccResult == YAFFS_ECC_RESULT_NO_ERROR)
tags->eccResult = YAFFS_ECC_RESULT_UNFIXED; tags->eccResult = YAFFS_ECC_RESULT_UNFIXED;

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -10,7 +10,7 @@
* it under the terms of the GNU General Public License version 2 as * it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
const char *yaffs_nand_c_version = const char *yaffs_nand_c_version =
"$Id: yaffs_nand.c,v 1.7 2007-02-14 01:09:06 wookey Exp $"; "$Id: yaffs_nand.c,v 1.7 2007-02-14 01:09:06 wookey Exp $";
@ -25,9 +25,9 @@ int yaffs_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
{ {
int result; int result;
yaffs_ExtendedTags localTags; yaffs_ExtendedTags localTags;
int realignedChunkInNAND = chunkInNAND - dev->chunkOffset; int realignedChunkInNAND = chunkInNAND - dev->chunkOffset;
/* If there are no tags provided, use local tags to get prioritised gc working */ /* If there are no tags provided, use local tags to get prioritised gc working */
if(!tags) if(!tags)
tags = &localTags; tags = &localTags;
@ -39,14 +39,14 @@ int yaffs_ReadChunkWithTagsFromNAND(yaffs_Device * dev, int chunkInNAND,
result = yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(dev, result = yaffs_TagsCompatabilityReadChunkWithTagsFromNAND(dev,
realignedChunkInNAND, realignedChunkInNAND,
buffer, buffer,
tags); tags);
if(tags && if(tags &&
tags->eccResult > YAFFS_ECC_RESULT_NO_ERROR){ tags->eccResult > YAFFS_ECC_RESULT_NO_ERROR){
yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, chunkInNAND/dev->nChunksPerBlock); yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev, chunkInNAND/dev->nChunksPerBlock);
yaffs_HandleChunkError(dev,bi); yaffs_HandleChunkError(dev,bi);
} }
return result; return result;
} }
@ -57,7 +57,7 @@ int yaffs_WriteChunkWithTagsToNAND(yaffs_Device * dev,
{ {
chunkInNAND -= dev->chunkOffset; chunkInNAND -= dev->chunkOffset;
if (tags) { if (tags) {
tags->sequenceNumber = dev->sequenceNumber; tags->sequenceNumber = dev->sequenceNumber;
tags->chunkUsed = 1; tags->chunkUsed = 1;
@ -131,4 +131,4 @@ int yaffs_InitialiseNAND(struct yaffs_DeviceStruct *dev)
} }

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -128,10 +128,10 @@ void yaffs_UnpackTags2(yaffs_ExtendedTags * t, yaffs_PackedTags2 * pt)
(yaffs_PackedTags2TagsPart), (yaffs_PackedTags2TagsPart),
&pt->ecc, &ecc); &pt->ecc, &ecc);
switch(result){ switch(result){
case 0: case 0:
t->eccResult = YAFFS_ECC_RESULT_NO_ERROR; t->eccResult = YAFFS_ECC_RESULT_NO_ERROR;
break; break;
case 1: case 1:
t->eccResult = YAFFS_ECC_RESULT_FIXED; t->eccResult = YAFFS_ECC_RESULT_FIXED;
break; break;
case -1: case -1:

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -50,7 +50,7 @@
static __inline void static __inline void
swapfunc(char *a, char *b, int n, int swaptype) swapfunc(char *a, char *b, int n, int swaptype)
{ {
if (swaptype <= 1) if (swaptype <= 1)
swapcode(long, a, b, n) swapcode(long, a, b, n)
else else
swapcode(char, a, b, n) swapcode(char, a, b, n)
@ -137,7 +137,7 @@ loop: SWAPINIT(a, es);
} }
if (swap_cnt == 0) { /* Switch to insertion sort */ if (swap_cnt == 0) { /* Switch to insertion sort */
for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es) for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
pl -= es) pl -= es)
swap(pl, pl - es); swap(pl, pl - es);
return; return;
@ -150,7 +150,7 @@ loop: SWAPINIT(a, es);
vecswap(pb, pn - r, r); vecswap(pb, pn - r, r);
if ((r = pb - pa) > es) if ((r = pb - pa) > es)
yaffs_qsort(a, r / es, es, cmp); yaffs_qsort(a, r / es, es, cmp);
if ((r = pd - pc) > es) { if ((r = pd - pc) > es) {
/* Iterate rather than recurse to save stack space */ /* Iterate rather than recurse to save stack space */
a = pn - r; a = pn - r;
n = r / es; n = r / es;

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering

View File

@ -1,5 +1,5 @@
/* /*
* YAFFS: Yet another Flash File System . A NAND-flash specific file system. * YAFFS: Yet another Flash File System . A NAND-flash specific file system.
* *
* Copyright (C) 2002-2007 Aleph One Ltd. * Copyright (C) 2002-2007 Aleph One Ltd.
* for Toby Churchill Ltd and Brightstar Engineering * for Toby Churchill Ltd and Brightstar Engineering
@ -150,7 +150,7 @@ extern unsigned int yaffs_wr_attempts;
* Tracing flags. * Tracing flags.
* The flags masked in YAFFS_TRACE_ALWAYS are always traced. * The flags masked in YAFFS_TRACE_ALWAYS are always traced.
*/ */
#define YAFFS_TRACE_OS 0x00000002 #define YAFFS_TRACE_OS 0x00000002
#define YAFFS_TRACE_ALLOCATE 0x00000004 #define YAFFS_TRACE_ALLOCATE 0x00000004
#define YAFFS_TRACE_SCAN 0x00000008 #define YAFFS_TRACE_SCAN 0x00000008