+#endif
+
+// New garbage collector
+// If we're very low on erased blocks then we do aggressive garbage collection
+// otherwise we do "passive" garbage collection.
+// Aggressive gc looks further (whole array) and will accept dirtier blocks.
+// Passive gc only inspects smaller areas and will only accept cleaner blocks.
+//
+// The idea is to help clear out space in a more spread-out manner.
+// Dunno if it really does anything useful.
+//
+static int yaffs_CheckGarbageCollection(yaffs_Device *dev)
+{
+ int block;
+ int aggressive=0;
+
+ //yaffs_DoUnlinkedFileDeletion(dev);
+
+ if(dev->nErasedBlocks <= (dev->nReservedBlocks + 1))
+ {
+ aggressive = 1;
+ }
+
+ block = yaffs_FindDirtiestBlock(dev,aggressive);
+
+ if(block >= 0)
+ {
+ dev->garbageCollections++;
+ if(!aggressive)
+ {
+ dev->passiveGarbageCollections++;
+ }
+
+ T(YAFFS_TRACE_GC,(TSTR("yaffs: GC erasedBlocks %d aggressive %d" TENDSTR),dev->nErasedBlocks,aggressive));
+
+ return yaffs_GarbageCollectBlock(dev,block);
+ }
+
+ return aggressive ? YAFFS_FAIL : YAFFS_OK;
+}