Fix free space reporting as per Mikhail Rileev's patch
[yaffs2.git] / yaffs_guts.c
index 7d9fd4122669909035080897c9dcb2bc2df35e9f..e949e319aa2fb1a5b60dad1ae117839c8b10fa93 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 const char *yaffs_guts_c_version =
-    "$Id: yaffs_guts.c,v 1.27 2005-12-20 04:02:18 charles Exp $";
+    "$Id: yaffs_guts.c,v 1.29 2006-02-08 22:29:14 charles Exp $";
 
 #include "yportenv.h"
 
@@ -335,6 +335,7 @@ static Y_INLINE int yaffs_StillSomeChunkBits(yaffs_Device * dev, int blk)
  
 static Y_INLINE int yaffs_HashFunction(int n)
 {
+       n = abs(n);
        return (n % YAFFS_NOBJECT_BUCKETS);
 }
 
@@ -2346,6 +2347,7 @@ static int yaffs_GarbageCollectBlock(yaffs_Device * dev, int block)
                                   ("yaffs: About to finally delete object %d"
                                    TENDSTR), object->objectId));
                                yaffs_DoGenericObjectDeletion(object);
+                               object->myDev->nDeletedFiles--;
                        }
 
                }
@@ -5690,6 +5692,8 @@ int yaffs_GetNumberOfFreeChunks(yaffs_Device * dev)
        nFree = yaffs_CountFreeChunks(dev);
 #endif
 
+       nFree += dev->nDeletedFiles;
+       
        /* Now count the number of dirty chunks in the cache and subtract those */
 
        {