*/
const char *yaffs_guts_c_version =
- "$Id: yaffs_guts.c,v 1.59 2008-07-21 01:03:19 charles Exp $";
+ "$Id: yaffs_guts.c,v 1.60 2008-10-30 17:58:44 charles Exp $";
#include "yportenv.h"
return;
/* Report illegal runtime states */
- if(bi->blockState <0 || bi->blockState >= YAFFS_NUMBER_OF_BLOCK_STATES)
+ if(bi->blockState >= YAFFS_NUMBER_OF_BLOCK_STATES)
T(YAFFS_TRACE_VERIFY,(TSTR("Block %d has undefined state %d"TENDSTR),n,bi->blockState));
switch(bi->blockState){
yaffs_BlockInfo *bi = yaffs_GetBlockInfo(dev,i);
yaffs_VerifyBlock(dev,bi,i);
- if(bi->blockState >=0 && bi->blockState < YAFFS_NUMBER_OF_BLOCK_STATES)
+ if(bi->blockState < YAFFS_NUMBER_OF_BLOCK_STATES)
nBlocksPerState[bi->blockState]++;
else
nIllegalBlockStates++;
*/
static void yaffs_VerifyObjectHeader(yaffs_Object *obj, yaffs_ObjectHeader *oh, yaffs_ExtendedTags *tags, int parentCheck)
{
- if(yaffs_SkipVerification(obj->myDev))
+ if(obj && yaffs_SkipVerification(obj->myDev))
return;
if(!(tags && obj && oh)){
}
}
} else if (level == 0) {
- int i;
yaffs_ExtendedTags tags;
__u32 objectId = obj->objectId;
yaffs_Tnode *tn;
__u32 objectId;
- if(obj && yaffs_SkipVerification(obj->myDev))
+ if(!obj)
+ return;
+
+ if(yaffs_SkipVerification(obj->myDev))
return;
dev = obj->myDev;
}
in = yaffs_CreateNewObject(dev, -1, type);
+
+ if(!in)
+ return YAFFS_FAIL;
if(type == YAFFS_OBJECT_TYPE_SYMLINK){
str = yaffs_CloneString(aliasString);
if (newDir->variantType != YAFFS_OBJECT_TYPE_DIRECTORY) {
T(YAFFS_TRACE_ALWAYS,
(TSTR
- ("tragendy: yaffs_ChangeObjectName: newDir is not a directory"
+ ("tragedy: yaffs_ChangeObjectName: newDir is not a directory"
TENDSTR)));
YBUG();
}
* Can't get space to gc
*/
T(YAFFS_TRACE_ERROR,
- (TSTR("yaffs tragedy: no more eraased blocks" TENDSTR)));
+ (TSTR("yaffs tragedy: no more erased blocks" TENDSTR)));
return -1;
}
T(YAFFS_TRACE_ALWAYS,
(TSTR
- ("yaffs tragedy: no more eraased blocks, but there should have been %d"
+ ("yaffs tragedy: no more erased blocks, but there should have been %d"
TENDSTR), dev->nErasedBlocks));
return -1;
* not be loaded during a scan
*/
- newSerial = newTags.serialNumber;
- existingSerial = existingTags.serialNumber;
+ if(inScan > 0) {
+ newSerial = newTags.serialNumber;
+ existingSerial = existingTags.serialNumber;
+ }
if ((inScan > 0) &&
(in->myDev->isYaffs2 ||
* show we've shrunk the file, if need be
* Do this only if the file is not in the deleted directories.
*/
- if (in->parent->objectId != YAFFS_OBJECTID_UNLINKED &&
+ if (in->parent &&
+ in->parent->objectId != YAFFS_OBJECTID_UNLINKED &&
in->parent->objectId != YAFFS_OBJECTID_DELETED) {
yaffs_UpdateObjectHeader(in, NULL, 0,
(newSize < oldFileSize) ? 1 : 0, 0);
{
__u8 *chunkData;
yaffs_ObjectHeader *oh;
- yaffs_Device *dev = in->myDev;
+ yaffs_Device *dev;
yaffs_ExtendedTags tags;
int result;
int alloc_failed = 0;
if(!in)
return;
+ dev = in->myDev;
+
#if 0
T(YAFFS_TRACE_SCAN,(TSTR("details for object %d %s loaded" TENDSTR),
in->objectId,
(oh) ? oh->
parentObjectId : tags.
extraParentObjectId;
- unsigned isShrink =
+
+
+ isShrink =
(oh) ? oh->isShrink : tags.
extraIsShrinkHeader;
dev->isMounted = 1;
-
-
/* OK now calculate a few things for the device */
/*
* Calculate all the chunk size manipulation numbers:
*/
- {
- __u32 x = dev->nDataBytesPerChunk;
- /* We always use dev->chunkShift and dev->chunkDiv */
- dev->chunkShift = Shifts(x);
- x >>= dev->chunkShift;
- dev->chunkDiv = x;
- /* We only use chunk mask if chunkDiv is 1 */
- dev->chunkMask = (1<<dev->chunkShift) - 1;
- }
+ x = dev->nDataBytesPerChunk;
+ /* We always use dev->chunkShift and dev->chunkDiv */
+ dev->chunkShift = Shifts(x);
+ x >>= dev->chunkShift;
+ dev->chunkDiv = x;
+ /* We only use chunk mask if chunkDiv is 1 */
+ dev->chunkMask = (1<<dev->chunkShift) - 1;
-
/*
* Calculate chunkGroupBits.
* We need to find the next power of 2 > than internalEndBlock
dev->nShortOpCaches = YAFFS_MAX_SHORT_OP_CACHES;
}
- buf = dev->srCache = YMALLOC(srCacheBytes);
+ dev->srCache = YMALLOC(srCacheBytes);
+
+ buf = (__u8 *) dev->srCache;
if(dev->srCache)
memset(dev->srCache,0,srCacheBytes);