*/
const char *yaffs_guts_c_version =
- "$Id: yaffs_guts.c,v 1.67 2008-11-27 02:46:45 charles Exp $";
+ "$Id: yaffs_guts.c,v 1.70 2009-01-09 02:52:28 charles Exp $";
#include "yportenv.h"
return !(yaffs_traceMask & (YAFFS_TRACE_VERIFY | YAFFS_TRACE_VERIFY_FULL));
}
-#if 0
static int yaffs_SkipFullVerification(yaffs_Device *dev)
{
return !(yaffs_traceMask & (YAFFS_TRACE_VERIFY_FULL));
}
-#endif
-
static int yaffs_SkipNANDVerification(yaffs_Device *dev)
{
return !(yaffs_traceMask & (YAFFS_TRACE_VERIFY_NAND));
yaffs_VerifyBlock(dev,bi,n);
/* After collection the block should be in the erased state */
- /* TODO: This will need to change if we do partial gc */
+ /* This will need to change if we do partial gc */
- if(bi->blockState != YAFFS_BLOCK_STATE_EMPTY){
+ if(bi->blockState != YAFFS_BLOCK_STATE_COLLECTING &&
+ bi->blockState != YAFFS_BLOCK_STATE_EMPTY){
T(YAFFS_TRACE_ERROR,(TSTR("Block %d is in state %d after gc, should be erased"TENDSTR),
n,bi->blockState));
}
int nToWriteBack;
int startOfWrite = offset;
int chunkWritten = 0;
- int nBytesRead;
+ __u32 nBytesRead;
+ __u32 chunkStart;
yaffs_Device *dev;
* we need to write back as much as was there before.
*/
- nBytesRead =
- in->variant.fileVariant.fileSize -
- ((chunk - 1) * dev->nDataBytesPerChunk);
+ chunkStart = ((chunk - 1) * dev->nDataBytesPerChunk);
+
+ if(chunkStart > in->variant.fileVariant.fileSize)
+ nBytesRead = 0; /* Past end of file */
+ else
+ nBytesRead = in->variant.fileVariant.fileSize - chunkStart;
if (nBytesRead > dev->nDataBytesPerChunk) {
nBytesRead = dev->nDataBytesPerChunk;
nToWriteBack =
(nBytesRead >
- ((int)start + n)) ? nBytesRead : (start + n);
+ (start + n)) ? nBytesRead : (start + n);
+
+ if(nToWriteBack < 0 || nToWriteBack > dev->nDataBytesPerChunk)
+ YBUG();
} else {
nToCopy = dev->nDataBytesPerChunk - start;
int count = 0;
- if(!obj)
+ if(!obj){
+ T(YAFFS_TRACE_ALWAYS, (TSTR("No object to verify" TENDSTR)));
YBUG();
+ }
if(yaffs_SkipVerification(obj->myDev))
return;
- if(!obj->parent)
+ if(!obj->parent){
+ T(YAFFS_TRACE_ALWAYS, (TSTR("Object does not have parent" TENDSTR)));
YBUG();
+ }
- if(obj->parent->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
+ if(obj->parent->variantType != YAFFS_OBJECT_TYPE_DIRECTORY){
+ T(YAFFS_TRACE_ALWAYS, (TSTR("Parent is not directory" TENDSTR)));
YBUG();
+ }
/* Iterate through the objects in each hash entry */
}
}
- if(count != 1)
- YBUG();
-
+ if(count != 1){
+ T(YAFFS_TRACE_ALWAYS, (TSTR("Object in directory %d times" TENDSTR),count));
+ YBUG();
+ }
}
if(!directory)
YBUG();
- if(yaffs_SkipVerification(directory->myDev))
+ if(yaffs_SkipFullVerification(directory->myDev))
return;
- if(directory->variantType != YAFFS_OBJECT_TYPE_DIRECTORY)
+ if(directory->variantType != YAFFS_OBJECT_TYPE_DIRECTORY){
+ T(YAFFS_TRACE_ALWAYS, (TSTR("Directory has wrong type: %d" TENDSTR),directory->variantType));
YBUG();
+ }
/* Iterate through the objects in each hash entry */
ylist_for_each(lh, &directory->variant.directoryVariant.children) {
if (lh) {
listObj = ylist_entry(lh, yaffs_Object, siblings);
- if(listObj->parent != directory)
+ if(listObj->parent != directory){
+ T(YAFFS_TRACE_ALWAYS, (TSTR("Object in directory list has wrong parent %p" TENDSTR),listObj->parent));
YBUG();
+ }
yaffs_VerifyObjectInDirectory(listObj);
}
}