* 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
__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
\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
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
{\r
__u32 fileSize;\r
__u32 scannedFileSize;\r
- __u32 topLevel;\r
+ int topLevel;\r
yaffs_Tnode *top;\r
} yaffs_FileStructure;\r
\r
\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
// 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
typedef struct\r
{\r
struct list_head list;\r
- __u32 count;\r
+ int count;\r
} yaffs_ObjectBucket;\r
\r
\r
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
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
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
\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
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
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