Clear out some redundant code, treat bad ECC chunk as deleted
authorcharles <charles>
Mon, 21 Jul 2008 01:03:19 +0000 (01:03 +0000)
committercharles <charles>
Mon, 21 Jul 2008 01:03:19 +0000 (01:03 +0000)
direct/Makefile
direct/yaffs_fileem.c
direct/yaffs_fileem2k.c
yaffs_guts.c

index a65312fd4855c458e482cb927d8cee3d98880127..e816df1a6b0fc767d8c7c666744e5c58e77e8c8f 100644 (file)
@@ -14,7 +14,7 @@
 #
 # NB Warning this Makefile does not include header dependencies.
 #
 #
 # NB Warning this Makefile does not include header dependencies.
 #
-# $Id: Makefile,v 1.17 2008-07-02 20:17:41 charles Exp $
+# $Id: Makefile,v 1.18 2008-07-21 01:03:19 charles Exp $
 
 #EXTRA_COMPILE_FLAGS = -DYAFFS_IGNORE_TAGS_ECC
 
 
 #EXTRA_COMPILE_FLAGS = -DYAFFS_IGNORE_TAGS_ECC
 
@@ -30,7 +30,7 @@ CFLAGS +=    -Wall -g $(EXTRA_COMPILE_FLAGS)
 DIRECTTESTOBJS = dtest.o yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
                 yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
                 yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
 DIRECTTESTOBJS = dtest.o yaffscfg2k.o yaffs_ecc.o yaffs_fileem.o yaffs_fileem2k.o yaffsfs.o yaffs_guts.o \
                 yaffs_packedtags1.o yaffs_ramdisk.o yaffs_ramem2k.o \
                 yaffs_tagscompat.o yaffs_packedtags2.o yaffs_tagsvalidity.o yaffs_nand.o \
-                yaffs_checkptrw.o  yaffs_qsort.o \
+                yaffs_checkptrw.o  yaffs_qsort.o
 #               yaffs_checkptrwtest.o\
                 
 
 #               yaffs_checkptrwtest.o\
                 
 
index 30128d9d4cc675ab47d2a98f8e5857eae0d671c4..c2ae5e1e5e46346c963e5c7e9f5fe068cf38b39d 100644 (file)
@@ -16,7 +16,7 @@
  * This is only intended as test code to test persistence etc.
  */
 
  * This is only intended as test code to test persistence etc.
  */
 
-const char *yaffs_flashif_c_version = "$Id: yaffs_fileem.c,v 1.3 2007-02-14 01:09:06 wookey Exp $";
+const char *yaffs_flashif_c_version = "$Id: yaffs_fileem.c,v 1.4 2008-07-21 01:03:19 charles Exp $";
 
 
 #include "yportenv.h"
 
 
 #include "yportenv.h"
@@ -83,7 +83,7 @@ static int  CheckInit(yaffs_Device *dev)
        
        filedisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024);
        
        
        filedisk.nBlocks = (SIZE_IN_MB * 1024 * 1024)/(16 * 1024);
        
-       filedisk.handle = open("yaffsemfile", O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
+       filedisk.handle = open("emfile512-0", O_RDWR | O_CREAT, S_IREAD | S_IWRITE);
        
        if(filedisk.handle < 0)
        {
        
        if(filedisk.handle < 0)
        {
index 82a00a255b91b0417c6ac7a79705855f803d8dad..db90496eea148277f617c0e3aba7d0cc270b598a 100644 (file)
@@ -16,7 +16,7 @@
  * This is only intended as test code to test persistence etc.
  */
 
  * This is only intended as test code to test persistence etc.
  */
 
-const char *yaffs_flashif2_c_version = "$Id: yaffs_fileem2k.c,v 1.14 2008-07-02 20:17:41 charles Exp $";
+const char *yaffs_flashif2_c_version = "$Id: yaffs_fileem2k.c,v 1.15 2008-07-21 01:03:19 charles Exp $";
 
 
 #include "yportenv.h"
 
 
 #include "yportenv.h"
@@ -71,7 +71,7 @@ static __u8 localBuffer[PAGE_SIZE];
 
 static char *NToName(char *buf,int n)
 {
 
 static char *NToName(char *buf,int n)
 {
-       sprintf(buf,"emfile2k%d",n);
+       sprintf(buf,"emfile2k-%d",n);
        return buf;
 }
 
        return buf;
 }
 
index d4ecda3c035e74375bf4db24e147ed495b4fa882..595bbc663faede2152344a40ed89e247a7cf0da3 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 const char *yaffs_guts_c_version =
  */
 
 const char *yaffs_guts_c_version =
-    "$Id: yaffs_guts.c,v 1.58 2008-07-03 20:06:05 charles Exp $";
+    "$Id: yaffs_guts.c,v 1.59 2008-07-21 01:03:19 charles Exp $";
 
 #include "yportenv.h"
 
 
 #include "yportenv.h"
 
@@ -5474,7 +5474,6 @@ static int yaffs_Scan(yaffs_Device * dev)
        __u8 *chunkData;
 
        
        __u8 *chunkData;
 
        
-       //TODO  Throw all the yaffs2 stuuf out of yaffs_Scan since it is only for yaffs1 format.
        
        T(YAFFS_TRACE_SCAN,
          (TSTR("yaffs_Scan starts  intstartblk %d intendblk %d..." TENDSTR),
        
        T(YAFFS_TRACE_SCAN,
          (TSTR("yaffs_Scan starts  intstartblk %d intendblk %d..." TENDSTR),
@@ -5540,7 +5539,7 @@ static int yaffs_Scan(yaffs_Device * dev)
 
                        /* Let's have a good look at this chunk... */
 
 
                        /* Let's have a good look at this chunk... */
 
-                       if (!dev->isYaffs2 && tags.chunkDeleted) {
+                       if (tags.eccResult == YAFFS_ECC_RESULT_UNFIXED || tags.chunkDeleted) {
                                /* YAFFS1 only...
                                 * A deleted chunk
                                 */
                                /* YAFFS1 only...
                                 * A deleted chunk
                                 */
@@ -5569,17 +5568,6 @@ static int yaffs_Scan(yaffs_Device * dev)
                                        dev->allocationBlockFinder = blk;       
                                        /* Set it to here to encourage the allocator to go forth from here. */
                                        
                                        dev->allocationBlockFinder = blk;       
                                        /* Set it to here to encourage the allocator to go forth from here. */
                                        
-                                       /* Yaffs2 sanity check:
-                                        * This should be the one with the highest sequence number
-                                        */
-                                       if (dev->isYaffs2
-                                           && (dev->sequenceNumber !=
-                                               bi->sequenceNumber)) {
-                                               T(YAFFS_TRACE_ALWAYS,
-                                                 (TSTR
-                                                  ("yaffs: Allocation block %d was not highest sequence id: block seq = %d, dev seq = %d"
-                                                   TENDSTR), blk,bi->sequenceNumber,dev->sequenceNumber));
-                                       }
                                }
 
                                dev->nFreeChunks += (dev->nChunksPerBlock - c);
                                }
 
                                dev->nFreeChunks += (dev->nChunksPerBlock - c);
@@ -5677,9 +5665,7 @@ static int yaffs_Scan(yaffs_Device * dev)
                                        unsigned existingSerial = in->serial;
                                        unsigned newSerial = tags.serialNumber;
 
                                        unsigned existingSerial = in->serial;
                                        unsigned newSerial = tags.serialNumber;
 
-                                       if (dev->isYaffs2 ||
-                                           ((existingSerial + 1) & 3) ==
-                                           newSerial) {
+                                       if (((existingSerial + 1) & 3) == newSerial) {
                                                /* Use new one - destroy the exisiting one */
                                                yaffs_DeleteChunk(dev,
                                                                  in->hdrChunk,
                                                /* Use new one - destroy the exisiting one */
                                                yaffs_DeleteChunk(dev,
                                                                  in->hdrChunk,
@@ -5793,15 +5779,6 @@ static int yaffs_Scan(yaffs_Device * dev)
                                                /* Todo got a problem */
                                                break;
                                        case YAFFS_OBJECT_TYPE_FILE:
                                                /* Todo got a problem */
                                                break;
                                        case YAFFS_OBJECT_TYPE_FILE:
-                                               if (dev->isYaffs2
-                                                   && oh->isShrink) {
-                                                       /* Prune back the shrunken chunks */
-                                                       yaffs_PruneResizedChunks
-                                                           (in, oh->fileSize);
-                                                       /* Mark the block as having a shrinkHeader */
-                                                       bi->hasShrinkHeader = 1;
-                                               }
-
                                                if (dev->useHeaderFileSize)
 
                                                        in->variant.fileVariant.
                                                if (dev->useHeaderFileSize)
 
                                                        in->variant.fileVariant.
@@ -6074,8 +6051,7 @@ static int yaffs_ScanBackwards(yaffs_Device * dev)
                } else if (state == YAFFS_BLOCK_STATE_NEEDS_SCANNING) {
 
                        /* Determine the highest sequence number */
                } else if (state == YAFFS_BLOCK_STATE_NEEDS_SCANNING) {
 
                        /* Determine the highest sequence number */
-                       if (dev->isYaffs2 &&
-                           sequenceNumber >= YAFFS_LOWEST_SEQUENCE_NUMBER &&
+                       if (sequenceNumber >= YAFFS_LOWEST_SEQUENCE_NUMBER &&
                            sequenceNumber < YAFFS_HIGHEST_SEQUENCE_NUMBER) {
 
                                blockIndex[nBlocksToScan].seq = sequenceNumber;
                            sequenceNumber < YAFFS_HIGHEST_SEQUENCE_NUMBER) {
 
                                blockIndex[nBlocksToScan].seq = sequenceNumber;
@@ -6086,7 +6062,7 @@ static int yaffs_ScanBackwards(yaffs_Device * dev)
                                if (sequenceNumber >= dev->sequenceNumber) {
                                        dev->sequenceNumber = sequenceNumber;
                                }
                                if (sequenceNumber >= dev->sequenceNumber) {
                                        dev->sequenceNumber = sequenceNumber;
                                }
-                       } else if (dev->isYaffs2) {
+                       } else {
                                /* TODO: Nasty sequence number! */
                                T(YAFFS_TRACE_SCAN,
                                  (TSTR
                                /* TODO: Nasty sequence number! */
                                T(YAFFS_TRACE_SCAN,
                                  (TSTR
@@ -6212,11 +6188,11 @@ static int yaffs_ScanBackwards(yaffs_Device * dev)
                                                         * had a write failure, so set up for retirement.
                                                         */
                                                  
                                                         * had a write failure, so set up for retirement.
                                                         */
                                                  
-                                                        bi->needsRetiring = 1;
+                                                        /* bi->needsRetiring = 1; ??? TODO */
                                                         bi->gcPrioritise = 1;
                                                                                                         
                                                         T(YAFFS_TRACE_ALWAYS,
                                                         bi->gcPrioritise = 1;
                                                                                                         
                                                         T(YAFFS_TRACE_ALWAYS,
-                                                        (TSTR("Partially written block %d being set for retirement" TENDSTR),
+                                                        (TSTR("Partially written block %d detected" TENDSTR),
                                                         blk));
                                                }
 
                                                         blk));
                                                }