Adding checkpoint and robustness improvements
[yaffs2.git] / direct / yaffscfg2k.c
index cb960bcf7796686d90bb8289503b6a9844116e2b..6d5f542fc4b0d0754a959a86b523fcde770a0453 100644 (file)
@@ -1,6 +1,18 @@
 /*
- * YAFFS: Yet another FFS. A NAND-flash specific file system.
- * yaffscfg.c  The configuration for the "direct" use of yaffs.
+ * YAFFS: Yet Another Flash File System. A NAND-flash specific file system.
+ *
+ * Copyright (C) 2002-2007 Aleph One Ltd.
+ *   for Toby Churchill Ltd and Brightstar Engineering
+ *
+ * Created by Charles Manning <charles@aleph1.co.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+/*
+ * yaffscfg2k.c  The configuration for the "direct" use of yaffs.
  *
  * This file is intended to be modified to your requirements.
  * There is no need to redistribute this file.
 
 #include <errno.h>
 
-unsigned yaffs_traceMask = YAFFS_TRACE_SCAN |  YAFFS_TRACE_GC /*| YAFFS_TRACE_GC_DETAIL | YAFFS_TRACE_WRITE */ | YAFFS_TRACE_ERASE | YAFFS_TRACE_TRACING | YAFFS_TRACE_ALLOCATE | YAFFS_TRACE_CHECKPOINT;
-//unsigned yaffs_traceMask = ~0;
+unsigned yaffs_traceMask = 
+
+       YAFFS_TRACE_SCAN |  
+       YAFFS_TRACE_GC | YAFFS_TRACE_GC_DETAIL | 
+       YAFFS_TRACE_ERASE | 
+       YAFFS_TRACE_TRACING | 
+       YAFFS_TRACE_ALLOCATE | 
+       YAFFS_TRACE_CHECKPOINT |
+       YAFFS_TRACE_BAD_BLOCKS |
+       YAFFS_TRACE_VERIFY |
+       YAFFS_TRACE_VERIFY_NAND |
+       YAFFS_TRACE_VERIFY_FULL |
+//     (~0) |
+       
+       0;
+        
 
 
 void yaffsfs_SetError(int err)
@@ -36,6 +62,30 @@ __u32 yaffsfs_CurrentTime(void)
        return 0;
 }
 
+
+static int yaffs_kill_alloc = 0;
+static size_t total_malloced = 0;
+static size_t malloc_limit = 0 & 6000000;
+
+void *yaffs_malloc(size_t size)
+{
+       size_t this;
+       if(yaffs_kill_alloc)
+               return NULL;
+       if(malloc_limit && malloc_limit <(total_malloced + size) )
+               return NULL;
+
+       this = malloc(size);
+       if(this)
+               total_malloced += size;
+       return this;
+}
+
+void yaffs_free(void *ptr)
+{
+       free(ptr);
+}
+
 void yaffsfs_LocalInitialisation(void)
 {
        // Define locking semaphore.
@@ -129,9 +179,9 @@ int yaffs_StartUp(void)
        flashDev.nCheckpointReservedBlocks = 5;
        //flashDev.checkpointStartBlock = 1;
        //flashDev.checkpointEndBlock = 20;
-       flashDev.startBlock = 20; 
-       //flashDev.endBlock = 127; // Make it smaller
-       flashDev.endBlock = yflash_GetNumberOfBlocks()-1;
+       flashDev.startBlock = 0;
+       flashDev.endBlock = 200; // Make it smaller
+       //flashDev.endBlock = yflash_GetNumberOfBlocks()-1;
        flashDev.isYaffs2 = 1;
        flashDev.wideTnodesDisabled=0;
        flashDev.nShortOpCaches = 10; // Use caches