Consolidate unlinked file handling durinit init to take care of restored checkpoint...
authorcharles <charles>
Mon, 12 Jan 2009 00:53:47 +0000 (00:53 +0000)
committercharles <charles>
Mon, 12 Jan 2009 00:53:47 +0000 (00:53 +0000)
yaffs_guts.c

index ae6e342..5aca0d2 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 const char *yaffs_guts_c_version =
-    "$Id: yaffs_guts.c,v 1.70 2009-01-09 02:52:28 charles Exp $";
+    "$Id: yaffs_guts.c,v 1.71 2009-01-12 00:53:47 charles Exp $";
 
 #include "yportenv.h"
 
@@ -5514,6 +5514,35 @@ struct yaffs_ShadowFixerStruct {
        struct yaffs_ShadowFixerStruct *next;
 };
 
+
+static void yaffs_StripDeletedObjects(yaffs_Device *dev)
+{
+       /*
+       *  Sort out state of unlinked and deleted objects after scanning.
+       */
+       struct ylist_head *i;
+       struct ylist_head *n;
+       yaffs_Object *l;
+
+       /* Soft delete all the unlinked files */
+       ylist_for_each_safe(i, n,
+               &dev->unlinkedDir->variant.directoryVariant.children) {
+               if (i) {
+                       l = ylist_entry(i, yaffs_Object, siblings);
+                       yaffs_DestroyObject(l);
+               }
+       }
+       
+       ylist_for_each_safe(i, n,
+               &dev->deletedDir->variant.directoryVariant.children) {
+               if (i) {
+                       l = ylist_entry(i, yaffs_Object, siblings);
+                       yaffs_DestroyObject(l);
+               }
+       }
+
+}
+
 static int yaffs_Scan(yaffs_Device * dev)
 {
        yaffs_ExtendedTags tags;
@@ -5914,25 +5943,6 @@ static int yaffs_Scan(yaffs_Device * dev)
 
        yaffs_HardlinkFixup(dev,hardList);
        
-       /* Handle the unlinked files. Since they were left in an unlinked state we should
-         * just delete them.
-         */
-        {
-                struct ylist_head *i;
-                struct ylist_head *n;
-
-                yaffs_Object *l;
-                /* Soft delete all the unlinked files */
-                ylist_for_each_safe(i, n,
-                                   &dev->unlinkedDir->variant.directoryVariant.
-                                   children) {
-                        if (i) {
-                                l = ylist_entry(i, yaffs_Object, siblings);
-                                yaffs_DestroyObject(l);
-                        }
-                }
-       }
-
        /* Fix up any shadowed objects */
        {
                struct yaffs_ShadowFixerStruct *fixer;
@@ -6664,37 +6674,6 @@ static int yaffs_ScanBackwards(yaffs_Device * dev)
         */
        yaffs_HardlinkFixup(dev,hardList);
        
-       
-       /*
-        *  Sort out state of unlinked and deleted objects.
-        */
-        {
-                struct ylist_head *i;
-                struct ylist_head *n;
-
-                yaffs_Object *l;
-
-                /* Soft delete all the unlinked files */
-                ylist_for_each_safe(i, n,
-                                   &dev->unlinkedDir->variant.directoryVariant.
-                                   children) {
-                        if (i) {
-                                l = ylist_entry(i, yaffs_Object, siblings);
-                                yaffs_DestroyObject(l);
-                        }
-                }
-
-                /* Soft delete all the deletedDir files */
-                ylist_for_each_safe(i, n,
-                                   &dev->deletedDir->variant.directoryVariant.
-                                   children) {
-                        if (i) {
-                                l = ylist_entry(i, yaffs_Object, siblings);
-                                yaffs_DestroyObject(l);
-
-                        }
-               }
-       }
 
        yaffs_ReleaseTempBuffer(dev, chunkData, __LINE__);
        
@@ -7507,6 +7486,8 @@ int yaffs_GutsInitialise(yaffs_Device * dev)
                }else
                        if(!yaffs_Scan(dev))
                                init_failed = 1;
+
+               yaffs_StripDeletedObjects(dev);
        }
                
        if(init_failed){