*** empty log message ***
[yaffs/.git] / yaffs_guts.h
index aadfa3f45ff3e8615b13b5f05a441af49d10c526..6130c4fd2343a343b224e022c7e83146d52c2d5f 100644 (file)
@@ -8,9 +8,13 @@
  * Created by Charles Manning <charles@aleph1.co.uk>\r
  *\r
  * This program is free software; you can redistribute it and/or modify\r
- * it under the terms of the GNU General Public License version 2 as\r
+ * it under the terms of the GNU Lesser General Public License version 2.1 as\r
  * published by the Free Software Foundation.\r
  *\r
+ *\r
+ * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.\r
+ *\r
+ * $Id: yaffs_guts.h,v 1.12 2002-11-26 01:15:37 charles Exp $\r
  */\r
 \r
 #ifndef __YAFFS_GUTS_H__\r
 #define YAFFS_OK       1\r
 #define YAFFS_FAIL  0\r
 \r
-// Y=0x59, A=0x41, S=0x53\r
+// Give us a Y=0x59, \r
+// Give us an A=0x41, \r
+// Give us an FF=0xFF \r
+// Give us an S=0x53\r
+// And what have we got... \r
 #define YAFFS_MAGIC                                    0x5941FF53\r
 \r
 #define YAFFS_NTNODES_LEVEL0           16\r
 #define YAFFS_NOBJECT_BUCKETS          256\r
 \r
 \r
-#define YAFFS_RESERVED_BLOCKS          5\r
+#define YAFFS_RESERVED_BLOCKS          8\r
 \r
 #define YAFFS_OBJECT_SPACE                     0x40000\r
 #define YAFFS_MAX_NAME_LENGTH          255\r
+#define YAFFS_SHORT_NAME_LENGTH                15\r
 \r
 #define YAFFS_MAX_ALIAS_LENGTH         159\r
 \r
 #define YAFFS_OBJECTID_ROOT                    1\r
 #define YAFFS_OBJECTID_LOSTNFOUND      2\r
+#define YAFFS_OBJECTID_UNLINKED                3\r
+\r
+#define YAFFS_N_CACHE_CHUNKS           10\r
+\r
+#ifdef CONFIG_YAFFS_WINCE\r
+\r
+// Force the short operation cache on for WinCE\r
+\r
+#define CONFIG_YAFFS_SHORT_OP_CACHE\r
+#endif\r
+\r
+\r
+// ChunkCache is used for short read/write operations.\r
+typedef struct\r
+{\r
+       struct yaffs_ObjectStruct *object;\r
+       int chunkId;\r
+       int lastUse;\r
+       int dirty;      \r
+       __u8 data[YAFFS_BYTES_PER_CHUNK];\r
+} yaffs_ChunkCache;\r
 \r
 // Tags structures in RAM\r
 // NB This uses bitfield. Bitfields should not stradle a u32 boundary otherwise\r
@@ -91,9 +121,7 @@ typedef struct
     __u8  tagByte1;\r
     __u8  tagByte2;\r
     __u8  tagByte3;\r
-    __u8  pageStatus; // Currently unused, but sort of set aside to distinguish\r
-                                 // unused - vs- used -vs- deleted chunks. We achieve this by\r
-                                         // using the objectId tags.\r
+    __u8  pageStatus;  // set to 0 to delete the chunk\r
     __u8  blockStatus;\r
     __u8  tagByte4;\r
     __u8  tagByte5;\r
@@ -159,17 +187,22 @@ typedef struct
 \r
        // Apply to everything  \r
        int   parentObjectId;\r
-       __u16 sum;      // checksum of name\r
+       __u16 sum__NoLongerUsed;        // checksum of name. Calc this off the name to prevent inconsistencies\r
        char  name[YAFFS_MAX_NAME_LENGTH + 1];\r
 \r
        // Thes following apply to directories, files, symlinks - not hard links\r
        __u32 st_mode;  // protection\r
+\r
+#ifdef CONFIG_YAFFS_WINCE\r
+       __u32 notForWinCE[5];\r
+#else\r
        __u32 st_uid;   // user ID of owner\r
        __u32 st_gid;    // group ID of owner \r
        __u32 st_atime; // time of last access\r
        __u32 st_mtime; // time of last modification\r
        __u32 st_ctime; // time of last change\r
-       \r
+#endif\r
+\r
        // File size  applies to files only\r
        int fileSize; \r
                \r
@@ -180,8 +213,15 @@ typedef struct
        char alias[YAFFS_MAX_ALIAS_LENGTH + 1];\r
        \r
        __u32 st_rdev;  // device stuff for block and char devices (maj/min)\r
-       // Roowm to grow...\r
+       \r
+#ifdef CONFIG_YAFFS_WINCE\r
+       __u32 win_ctime[2];\r
+       __u32 win_atime[2];\r
+       __u32 win_mtime[2];\r
+       __u32 roomToGrow[6];\r
+#else\r
        __u32 roomToGrow[12];\r
+#endif\r
        \r
 } yaffs_ObjectHeader;\r
 \r
@@ -220,7 +260,7 @@ typedef struct
 {\r
        __u32 fileSize;\r
        __u32 scannedFileSize;\r
-       __u32 topLevel;\r
+       int   topLevel;\r
        yaffs_Tnode *top;\r
 } yaffs_FileStructure;\r
 \r
@@ -251,6 +291,8 @@ typedef union
 \r
 struct  yaffs_ObjectStruct\r
 {\r
+       __u8 deleted: 1;                // This should only apply to unlinked files.\r
+       __u8 unlinked: 1;               // An unlinked file. The file should be in the unlinked pseudo directory.\r
        __u8 fake:1;                    // A fake object has no presence on NAND.\r
        __u8 renameAllowed:1;\r
        __u8 unlinkAllowed:1;\r
@@ -278,23 +320,40 @@ struct  yaffs_ObjectStruct
        // Where's my data in NAND?\r
        int chunkId;            // where it lives\r
 \r
-       int nDataChunks;        // really only for debugging.\r
+       int nDataChunks;        \r
        \r
        __u32 objectId;         // the object id value\r
        \r
        \r
        __u32 st_mode;          // protection\r
+\r
+#ifdef CONFIG_YAFFS_SHORT_NAMES_IN_RAM\r
+       char shortName[YAFFS_SHORT_NAME_LENGTH+1];\r
+#endif\r
+\r
+#ifdef CONFIG_YAFFS_WINCE\r
+       __u32 inUse;\r
+\r
+       __u32 win_ctime[2];\r
+       __u32 win_mtime[2];\r
+       __u32 win_atime[2];\r
+#else\r
        __u32 st_uid;           // user ID of owner\r
        __u32 st_gid;           // group ID of owner \r
        __u32 st_atime;         // time of last access\r
        __u32 st_mtime;         // time of last modification\r
        __u32 st_ctime;         // time of last change\r
        __u32 st_rdev;      // device stuff for block and char devices\r
+#endif\r
 \r
-#ifdef WIN32\r
-       __u32 inUse;\r
+\r
+\r
+\r
+#ifdef __KERNEL__\r
+       struct inode *myInode;\r
 #endif\r
 \r
+\r
        \r
        yaffs_ObjectType variantType;\r
        \r
@@ -318,7 +377,7 @@ typedef struct yaffs_ObjectList_struct yaffs_ObjectList;
 typedef struct\r
 {\r
        struct list_head list;\r
-       __u32 count;\r
+       int count;\r
 } yaffs_ObjectBucket;\r
 \r
 \r
@@ -327,9 +386,8 @@ typedef struct
 struct yaffs_DeviceStruct\r
 {\r
        // Entry parameters set up way early. Yaffs sets up the rest.\r
-       __u32 nBlocks;          // Size of whole device in blocks\r
-       __u32 startBlock;       // Start block we're allowed to use\r
-       __u32 endBlock;         // End block we're allowed to use\r
+       int   startBlock;       // Start block we're allowed to use\r
+       int   endBlock;         // End block we're allowed to use\r
        __u16 chunkGroupBits; // 0 for devices <= 32MB. else log2(nchunks) - 16\r
        __u16 chunkGroupSize; // == 2^^chunkGroupBits\r
        \r
@@ -388,8 +446,13 @@ struct yaffs_DeviceStruct
        int nPageReads;\r
        int nBlockErasures;\r
        int nGCCopies;\r
+       int garbageCollections;\r
        int nRetriedWrites;\r
        int nRetiredBlocks;\r
+       int eccFixed;\r
+       int eccUnfixed;\r
+       int tagsEccFixed;\r
+       int tagsEccUnfixed;\r
        \r
        yaffs_Object *rootDir;\r
        yaffs_Object *lostNFoundDir;\r
@@ -401,7 +464,21 @@ struct yaffs_DeviceStruct
        int doingBufferedBlockRewrite;\r
        \r
        int blockSelectedForGC;\r
+\r
+#ifdef CONFIG_YAFFS_SHORT_OP_CACHE\r
+       yaffs_ChunkCache srCache[YAFFS_N_CACHE_CHUNKS];\r
+       int srLastUse;\r
+#endif\r
+       int cacheHits;\r
+\r
+       // Stuff for background deletion and unlinked files.\r
+       yaffs_Object *unlinkedDir;              // Directory where unlinked and deleted files live.\r
+       yaffs_Object *unlinkedDeletion; // Current file being background deleted.\r
+       int nDeletedFiles;                              // Count of files awaiting deletion;\r
+       int nUnlinkedFiles;                             // Count of unlinked files. \r
+       int nBackgroundDeletions;                       // Count of background deletions.       \r
        \r
+       __u8 *localBuffer;\r
        \r
 };\r
 \r
@@ -422,6 +499,7 @@ int yaffs_RenameObject(yaffs_Object *oldDir, const char *oldName, yaffs_Object *
 \r
 // generic Object functions\r
 int yaffs_Unlink(yaffs_Object *dir, const char *name);\r
+int yaffs_DeleteFile(yaffs_Object *obj);\r
 \r
 // Object access functions.\r
 int yaffs_GetObjectName(yaffs_Object *obj,char *name,int buffSize);\r
@@ -448,7 +526,7 @@ yaffs_Object *yaffs_MknodDirectory(yaffs_Object *parent,const char *name, __u32
 yaffs_Object *yaffs_FindObjectByName(yaffs_Object *theDir,const char *name);\r
 int yaffs_ApplyToDirectoryChildren(yaffs_Object *theDir,int (*fn)(yaffs_Object *));\r
 \r
-yaffs_Object *yaffs_FindObjectByNumber(yaffs_Device *dev,int number);\r
+yaffs_Object *yaffs_FindObjectByNumber(yaffs_Device *dev,__u32 number);\r
 \r
 // Link operations\r
 yaffs_Object *yaffs_Link(yaffs_Object *parent, const char *name, yaffs_Object *equivalentObject);\r
@@ -467,6 +545,11 @@ yaffs_Object *yaffs_MknodSpecial(yaffs_Object *parent,const char *name, __u32 mo
 yaffs_Object *yaffs_Root(yaffs_Device *dev);\r
 yaffs_Object *yaffs_LostNFound(yaffs_Device *dev);\r
 \r
+#ifdef CONFIG_YAFFS_WINCE\r
+// CONFIG_YAFFS_WINCE special stuff\r
+void  yfsd_WinFileTimeNow(__u32 target[2]);\r
+#endif\r
+\r
 \r
 // Debug dump \r
 int yaffs_DumpObject(yaffs_Object *obj);\r