Remove obsolete pathDivider field
[yaffs2.git] / yaffs_packedtags2.c
index da1621fa81963c82feb9585c657a8b7afc233e6f..c6f7dcf3365035368a7c9b077ed0ede7ebb5a2db 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "yaffs_packedtags2.h"
 #include "yportenv.h"
+#include "yaffs_trace.h"
 #include "yaffs_tagsvalidity.h"
 
 /* This code packs a set of extended tags into a binary structure for
@@ -74,24 +75,21 @@ void yaffs_PackTags2TagsPart(yaffs_PackedTags2TagsPart *ptt,
                /* We save the parent object in the chunkId */
                ptt->chunkId = EXTRA_HEADER_INFO_FLAG
                        | t->extraParentObjectId;
-               if (t->extraIsShrinkHeader) {
+               if (t->extraIsShrinkHeader)
                        ptt->chunkId |= EXTRA_SHRINK_FLAG;
-               }
-               if (t->extraShadows) {
+               if (t->extraShadows)
                        ptt->chunkId |= EXTRA_SHADOWS_FLAG;
-               }
 
                ptt->objectId &= ~EXTRA_OBJECT_TYPE_MASK;
                ptt->objectId |=
                    (t->extraObjectType << EXTRA_OBJECT_TYPE_SHIFT);
 
-               if (t->extraObjectType == YAFFS_OBJECT_TYPE_HARDLINK) {
+               if (t->extraObjectType == YAFFS_OBJECT_TYPE_HARDLINK)
                        ptt->byteCount = t->extraEquivalentObjectId;
-               } else if (t->extraObjectType == YAFFS_OBJECT_TYPE_FILE) {
+               else if (t->extraObjectType == YAFFS_OBJECT_TYPE_FILE)
                        ptt->byteCount = t->extraFileLength;
-               } else {
+               else
                        ptt->byteCount = 0;
-               }
        }
 
        yaffs_DumpPackedTags2TagsPart(ptt);
@@ -99,17 +97,14 @@ void yaffs_PackTags2TagsPart(yaffs_PackedTags2TagsPart *ptt,
 }
 
 
-void yaffs_PackTags2(yaffs_PackedTags2 *pt, const yaffs_ExtendedTags *t)
+void yaffs_PackTags2(yaffs_PackedTags2 *pt, const yaffs_ExtendedTags *t, int tagsECC)
 {
        yaffs_PackTags2TagsPart(&pt->t, t);
 
-#ifndef YAFFS_IGNORE_TAGS_ECC
-       {
+       if(tagsECC)
                yaffs_ECCCalculateOther((unsigned char *)&pt->t,
                                        sizeof(yaffs_PackedTags2TagsPart),
                                        &pt->ecc);
-       }
-#endif
 }
 
 
@@ -148,11 +143,10 @@ void yaffs_UnpackTags2TagsPart(yaffs_ExtendedTags *t,
                            ptt->objectId >> EXTRA_OBJECT_TYPE_SHIFT;
                        t->objectId &= ~EXTRA_OBJECT_TYPE_MASK;
 
-                       if (t->extraObjectType == YAFFS_OBJECT_TYPE_HARDLINK) {
+                       if (t->extraObjectType == YAFFS_OBJECT_TYPE_HARDLINK)
                                t->extraEquivalentObjectId = ptt->byteCount;
-                       } else {
+                       else
                                t->extraFileLength = ptt->byteCount;
-                       }
                }
        }
 
@@ -162,27 +156,24 @@ void yaffs_UnpackTags2TagsPart(yaffs_ExtendedTags *t,
 }
 
 
-void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt)
+void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt, int tagsECC)
 {
 
        yaffs_ECCResult eccResult = YAFFS_ECC_RESULT_NO_ERROR;
 
-       if (pt->t.sequenceNumber != 0xFFFFFFFF) {
-               /* Page is in use */
-#ifndef YAFFS_IGNORE_TAGS_ECC
-               {
-                       yaffs_ECCOther ecc;
-                       int result;
-                       yaffs_ECCCalculateOther((unsigned char *)&pt->t,
-                                               sizeof
-                                               (yaffs_PackedTags2TagsPart),
-                                               &ecc);
-                       result =
-                           yaffs_ECCCorrectOther((unsigned char *)&pt->t,
-                                                 sizeof
-                                                 (yaffs_PackedTags2TagsPart),
-                                                 &pt->ecc, &ecc);
-                       switch (result) {
+       if (pt->t.sequenceNumber != 0xFFFFFFFF &&
+           tagsECC){
+               /* Chunk is in use and we need to do ECC */
+               
+               yaffs_ECCOther ecc;
+               int result;
+               yaffs_ECCCalculateOther((unsigned char *)&pt->t,
+                                       sizeof(yaffs_PackedTags2TagsPart),
+                                       &ecc);
+               result = yaffs_ECCCorrectOther((unsigned char *)&pt->t,
+                                               sizeof(yaffs_PackedTags2TagsPart),
+                                               &pt->ecc, &ecc);
+               switch (result) {
                        case 0:
                                eccResult = YAFFS_ECC_RESULT_NO_ERROR;
                                break;
@@ -194,9 +185,7 @@ void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt)
                                break;
                        default:
                                eccResult = YAFFS_ECC_RESULT_UNKNOWN;
-                       }
                }
-#endif
        }
 
        yaffs_UnpackTags2TagsPart(t, &pt->t);
@@ -205,6 +194,5 @@ void yaffs_UnpackTags2(yaffs_ExtendedTags *t, yaffs_PackedTags2 *pt)
 
        yaffs_DumpPackedTags2(pt);
        yaffs_DumpTags2(t);
-
 }