*** empty log message ***
[yaffs2.git] / yaffs_guts.h
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system. 
3  * yaffs_guts.h: Configuration etc for yaffs_guts
4  *
5  * Copyright (C) 2002 Aleph One Ltd.
6  *   for Toby Churchill Ltd and Brightstar Engineering
7  *
8  * Created by Charles Manning <charles@aleph1.co.uk>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU Lesser General Public License version 2.1 as
12  * published by the Free Software Foundation.
13  *
14  *
15  * Note: Only YAFFS headers are LGPL, YAFFS C code is covered by GPL.
16  *
17  * $Id: yaffs_guts.h,v 1.1 2004-11-03 08:14:07 charles Exp $
18  */
19
20 #ifndef __YAFFS_GUTS_H__
21 #define __YAFFS_GUTS_H__
22
23 #include "devextras.h"
24 #include "yportenv.h"
25
26 #define YAFFS_OK        1
27 #define YAFFS_FAIL  0
28
29 // Give us a Y=0x59, 
30 // Give us an A=0x41, 
31 // Give us an FF=0xFF 
32 // Give us an S=0x53
33 // And what have we got... 
34 #define YAFFS_MAGIC                                     0x5941FF53
35
36 #define YAFFS_NTNODES_LEVEL0            16
37 #define YAFFS_TNODES_LEVEL0_BITS        4
38 #define YAFFS_TNODES_LEVEL0_MASK        0xf
39
40 #define YAFFS_NTNODES_INTERNAL          (YAFFS_NTNODES_LEVEL0 / 2)
41 #define YAFFS_TNODES_INTERNAL_BITS      (YAFFS_TNODES_LEVEL0_BITS - 1)
42 #define YAFFS_TNODES_INTERNAL_MASK      0x7
43 #define YAFFS_TNODES_MAX_LEVEL          6
44
45 #ifndef CONFIG_YAFFS_NO_YAFFS1
46 #define YAFFS_BYTES_PER_SPARE           16
47 #define YAFFS_BYTES_PER_CHUNK           512
48 #define YAFFS_CHUNK_SIZE_SHIFT          9
49 #define YAFFS_CHUNKS_PER_BLOCK          32
50 #define YAFFS_BYTES_PER_BLOCK           (YAFFS_CHUNKS_PER_BLOCK*YAFFS_BYTES_PER_CHUNK)
51 #endif
52
53 #define YAFFS_MAX_CHUNK_ID                      0x000FFFFF
54
55 #define YAFFS_UNUSED_OBJECT_ID          0x0003FFFF
56
57 #define YAFFS_ALLOCATION_NOBJECTS       100
58 #define YAFFS_ALLOCATION_NTNODES        100
59 #define YAFFS_ALLOCATION_NLINKS         100
60
61 #define YAFFS_NOBJECT_BUCKETS           256
62
63
64 #define YAFFS_OBJECT_SPACE                      0x40000
65
66 #ifdef CONFIG_YAFFS_UNICODE
67 #define YAFFS_MAX_NAME_LENGTH           127
68 #define YAFFS_MAX_ALIAS_LENGTH          79
69 #else
70 #define YAFFS_MAX_NAME_LENGTH           255
71 #define YAFFS_MAX_ALIAS_LENGTH          159
72 #endif
73
74 #define YAFFS_SHORT_NAME_LENGTH         15
75
76
77 #define YAFFS_OBJECTID_ROOT                     1
78 #define YAFFS_OBJECTID_LOSTNFOUND       2
79 #define YAFFS_OBJECTID_UNLINKED         3
80 #define YAFFS_OBJECTID_DELETED          4
81
82 #define YAFFS_MAX_SHORT_OP_CACHES       20
83
84 #define YAFFS_N_TEMP_BUFFERS            4
85
86 // Sequence numbers are used in YAFFS2 to determine block allocation order.
87 // The range is limited slightly to help distinguish bad numbers from good.
88 // This also allows us to perhaps in the future use special numbers for
89 // special purposes.
90 // EFFFFF00 allows the allocation of 8 blocks per second (~1Mbytes) for 15 years, 
91 // and is a larger number than the lifetime of a 2GB device.
92
93 #define YAFFS_LOWEST_SEQUENCE_NUMBER    0x00001000
94 #define YAFFS_HIGHEST_SEQUENCE_NUMBER   0xEFFFFF00
95
96
97 // ChunkCache is used for short read/write operations.
98 typedef struct
99 {
100         struct yaffs_ObjectStruct *object;
101         int chunkId;
102         int lastUse;
103         int dirty;      
104         int nBytes;     // Only valid if the cache is dirty
105         int locked; // Can't push out or flush while locked..
106 #ifdef YAFFS2_DEFINES
107         __u8 *data;
108 #else
109         __u8 data[YAFFS_BYTES_PER_CHUNK];
110 #endif
111 } yaffs_ChunkCache;
112
113
114 #ifndef CONFIG_YAFFS_NO_YAFFS1
115 // Tags structures in RAM
116 // NB This uses bitfield. Bitfields should not straddle a u32 boundary otherwise
117 // the structure size will get blown out.
118
119 typedef struct
120 {   
121         unsigned chunkId:20;
122     unsigned serialNumber:2;
123     unsigned byteCount:10;
124     unsigned objectId:18;
125     unsigned ecc:12;
126     unsigned unusedStuff:2;
127
128 } yaffs_Tags;
129
130 typedef union
131 {
132     yaffs_Tags asTags;
133     __u8       asBytes[8];
134 } yaffs_TagsUnion;
135
136 #endif
137
138 typedef enum
139 {
140         YAFFS_ECC_RESULT_UNKNOWN,
141         YAFFS_ECC_RESULT_NO_ERROR,
142         YAFFS_ECC_RESULT_FIXED,
143         YAFFS_ECC_RESULT_UNFIXED
144 } yaffs_ECCResult;
145
146 typedef struct
147 {
148
149         unsigned validMarker0;
150         unsigned chunkUsed;                 //  Status of the chunk: used or unused
151         unsigned objectId;                      // If 0 then this is not part of an object (unused)
152         unsigned chunkId;                       // If 0 then this is a header
153         unsigned byteCount;                 // Only valid for data chunks
154         // The following stuff only has meaning when we read
155         yaffs_ECCResult eccResult;  // Only valid when we read.
156         unsigned blockBad;                      // Only valid on reading
157
158         // YAFFS 1 stuff        
159         unsigned chunkDeleted;          // The chunk is marked deleted
160         unsigned serialNumber;          // Yaffs1 2-bit serial number
161         
162         // YAFFS2 stuff
163         unsigned sequenceNumber;        // The sequence number of this block
164
165         unsigned validMarker1;
166         
167 } yaffs_ExtendedTags;
168
169 #ifndef CONFIG_YAFFS_NO_YAFFS1
170 // Spare structure
171 typedef struct
172 {
173     __u8  tagByte0;
174     __u8  tagByte1;
175     __u8  tagByte2;
176     __u8  tagByte3;
177     __u8  pageStatus;   // set to 0 to delete the chunk
178     __u8  blockStatus;
179     __u8  tagByte4;
180     __u8  tagByte5;
181     __u8  ecc1[3];
182     __u8  tagByte6;
183     __u8  tagByte7;
184     __u8  ecc2[3];
185 } yaffs_Spare;
186
187 //Special structure for passing through to mtd
188 struct yaffs_NANDSpare {
189         yaffs_Spare     spare;
190         int             eccres1;
191         int             eccres2;
192 };
193 #endif
194
195
196 // Block data in RAM
197
198 typedef enum {
199         YAFFS_BLOCK_STATE_UNKNOWN       = 0,
200 #ifndef YAFFS2_DEFINES
201         YAFFS_BLOCK_STATE_SCANNING,
202 #else
203         YAFFS_BLOCK_STATE_NEEDS_SCANNING,// The block might have something on it (ie it is allocating or full, perhaps empty)
204                                                                         // but it needs to be scanned to determine its true state.
205                                                                         // This state is only valid during yaffs_Scan.
206                                                                         // NB We tolerate empty because the pre-scanner might be incapable of deciding
207                                                                         // However, if this state is returned on a YAFFS2 device, then we expect a sequence number
208                                                                         
209 #endif  
210         YAFFS_BLOCK_STATE_EMPTY,                // This block is empty
211         
212         YAFFS_BLOCK_STATE_ALLOCATING,   // This block is partially allocated. 
213                                                                         // This is the one currently being used for page
214                                                                         // allocation. Should never be more than one of these
215                                                         
216
217         YAFFS_BLOCK_STATE_FULL,                 // All the pages in this block have been allocated.
218                                                                         // At least one page holds valid data.
219                                                          
220         YAFFS_BLOCK_STATE_DIRTY,                // All pages have been allocated and deleted. 
221                                                                         // Erase me, reuse me.
222                                                                         
223         YAFFS_BLOCK_STATE_COLLECTING,   // This block is being garbage collected
224                                                         
225         YAFFS_BLOCK_STATE_DEAD                  // This block has failed and is not in use
226
227 } yaffs_BlockState;
228
229
230
231
232 typedef struct
233 {
234
235         int   softDeletions:8;  // number of soft deleted pages
236     int   pagesInUse:8;         // number of pages in use
237     __u32 blockState:4;         // One of the above block states
238     __u32 needsRetiring:1;      // Data has failed on this block, need to get valid data off
239                                                 // and retire the block.
240 #ifndef CONFIG_YAFFS_NO_YAFFS2
241         __u32 hasShrinkHeader:1;// This block has at least one object header that does a shrink
242         __u32 sequenceNumber;   // block sequence number for yaffs2
243 #endif
244
245 } yaffs_BlockInfo;
246
247
248 //////////////////// Object structure ///////////////////////////
249 // This is the object structure as stored on NAND
250
251 typedef enum
252 {
253         YAFFS_OBJECT_TYPE_UNKNOWN,
254         YAFFS_OBJECT_TYPE_FILE,
255         YAFFS_OBJECT_TYPE_SYMLINK,
256         YAFFS_OBJECT_TYPE_DIRECTORY,
257         YAFFS_OBJECT_TYPE_HARDLINK,
258         YAFFS_OBJECT_TYPE_SPECIAL
259 } yaffs_ObjectType;
260
261 typedef struct
262 {
263         yaffs_ObjectType type;
264
265         // Apply to everything  
266         int   parentObjectId;
267         __u16 sum__NoLongerUsed;        // checksum of name. Calc this off the name to prevent inconsistencies
268         YCHAR  name[YAFFS_MAX_NAME_LENGTH + 1];
269
270         // Thes following apply to directories, files, symlinks - not hard links
271         __u32 st_mode;  // protection
272
273 #ifdef CONFIG_YAFFS_WINCE
274         __u32 notForWinCE[5];
275 #else
276         __u32 st_uid;   // user ID of owner
277         __u32 st_gid;    // group ID of owner 
278         __u32 st_atime; // time of last access
279         __u32 st_mtime; // time of last modification
280         __u32 st_ctime; // time of last change
281 #endif
282
283         // File size  applies to files only
284         int fileSize; 
285                 
286         // Equivalent object id applies to hard links only.
287         int  equivalentObjectId;
288         
289         // Alias is for symlinks only.
290         YCHAR alias[YAFFS_MAX_ALIAS_LENGTH + 1];
291         
292         __u32 st_rdev;  // device stuff for block and char devices (maj/min)
293         
294 #ifdef CONFIG_YAFFS_WINCE
295         __u32 win_ctime[2];
296         __u32 win_atime[2];
297         __u32 win_mtime[2];
298         __u32 roomToGrow[5];
299 #else
300         __u32 roomToGrow[11];
301 #endif
302
303         // isShrink applies to bject headers written when we shrink the file (ie resize)
304         __u32 isShrink;
305         
306 } yaffs_ObjectHeader;
307
308
309
310 ////////////////////  Tnode ///////////////////////////
311
312 union yaffs_Tnode_union
313 {
314 #ifdef CONFIG_YAFFS_TNODE_LIST_DEBUG
315         union yaffs_Tnode_union *internal[YAFFS_NTNODES_INTERNAL+1];
316 #else
317         union yaffs_Tnode_union *internal[YAFFS_NTNODES_INTERNAL];
318 #endif
319         __u16 level0[YAFFS_NTNODES_LEVEL0];
320         
321 };
322
323 typedef union yaffs_Tnode_union yaffs_Tnode;
324
325 struct yaffs_TnodeList_struct
326 {
327         struct yaffs_TnodeList_struct *next;
328         yaffs_Tnode *tnodes;
329 };
330
331 typedef struct yaffs_TnodeList_struct yaffs_TnodeList;
332
333
334
335 ///////////////////  Object ////////////////////////////////
336 // An object can be one of:
337 // - a directory (no data, has children links
338 // - a regular file (data.... not prunes :->).
339 // - a symlink [symbolic link] (the alias).
340 // - a hard link
341
342
343 typedef struct 
344 {
345         __u32 fileSize;
346         __u32 scannedFileSize;
347         int   topLevel;
348         yaffs_Tnode *top;
349 } yaffs_FileStructure;
350
351 typedef struct
352 {
353         struct list_head children; // list of child links
354 } yaffs_DirectoryStructure;
355
356 typedef struct
357 {
358         YCHAR *alias;
359 } yaffs_SymLinkStructure;
360
361 typedef struct
362 {
363         struct yaffs_ObjectStruct *equivalentObject;
364         __u32   equivalentObjectId;
365 } yaffs_HardLinkStructure;
366
367 typedef union
368 {
369         yaffs_FileStructure fileVariant;
370         yaffs_DirectoryStructure directoryVariant;
371         yaffs_SymLinkStructure symLinkVariant;
372         yaffs_HardLinkStructure hardLinkVariant;
373 } yaffs_ObjectVariant;
374
375
376 struct  yaffs_ObjectStruct
377 {
378         __u8 deleted: 1;                // This should only apply to unlinked files.
379         __u8 softDeleted: 1;    // it has also been soft deleted
380         __u8 unlinked: 1;               // An unlinked file. The file should be in the unlinked pseudo directory.
381         __u8 fake:1;                    // A fake object has no presence on NAND.
382         __u8 renameAllowed:1;
383         __u8 unlinkAllowed:1;
384         __u8 dirty:1;                   // the object needs to be written to flash
385         __u8 valid:1;                   // When the file system is being loaded up, this 
386                                                         // object might be created before the data
387                                                         // is available (ie. file data records appear before the header).
388         __u8 serial;                    // serial number of chunk in NAND. Store here so we don't have to
389                                                         // read back the old one to update.
390         __u16 sum;                              // sum of the name to speed searching
391         
392         struct yaffs_DeviceStruct *myDev; // The device I'm on
393         
394                                                                 
395         struct list_head hashLink;      // list of objects in this hash bucket
396                                                         
397
398         struct list_head hardLinks; // all the equivalent hard linked objects
399                                                                 // live on this list
400         // directory structure stuff
401         struct yaffs_ObjectStruct  *parent;     //my parent directory
402         struct list_head siblings;      // siblings in a directory
403                                                                 // also used for linking up the free list
404                 
405         // Where's my data in NAND?
406         int chunkId;            // where it lives
407
408         int nDataChunks;        
409         
410         __u32 objectId;         // the object id value
411         
412         
413         __u32 st_mode;          // protection
414
415 #ifdef CONFIG_YAFFS_SHORT_NAMES_IN_RAM
416         YCHAR shortName[YAFFS_SHORT_NAME_LENGTH+1];
417 #endif
418
419 #ifndef __KERNEL__
420         __u32 inUse;
421 #endif
422
423 #ifdef CONFIG_YAFFS_WINCE
424         __u32 win_ctime[2];
425         __u32 win_mtime[2];
426         __u32 win_atime[2];
427 #else
428         __u32 st_uid;           // user ID of owner
429         __u32 st_gid;           // group ID of owner 
430         __u32 st_atime;         // time of last access
431         __u32 st_mtime;         // time of last modification
432         __u32 st_ctime;         // time of last change
433 #endif
434
435         __u32 st_rdev;      // device stuff for block and char devices
436
437
438
439 #ifdef __KERNEL__
440         struct inode *myInode;
441 #endif
442
443
444         
445         yaffs_ObjectType variantType;
446         
447         yaffs_ObjectVariant variant;
448         
449 };
450
451
452
453 typedef struct yaffs_ObjectStruct yaffs_Object;
454
455
456 struct yaffs_ObjectList_struct
457 {
458         yaffs_Object *objects;
459         struct yaffs_ObjectList_struct *next;
460 };
461
462 typedef struct yaffs_ObjectList_struct yaffs_ObjectList;
463
464 typedef struct
465 {
466         struct list_head list;
467         int count;
468 } yaffs_ObjectBucket;
469
470 ///////////////////// Temporary buffers ////////////////////
471 //
472 // These are chunk-sized working buffers. Each device has a few
473
474 typedef struct {
475         __u8 *buffer;
476         int line; // track from whence this buffer was allocated
477         int maxLine;
478 } yaffs_TempBuffer;
479
480 //////////////////// Device ////////////////////////////////
481
482 struct yaffs_DeviceStruct
483 {
484         // Entry parameters set up way early. Yaffs sets up the rest.
485         int   nBytesPerChunk;    // Should be a power of 2 >= 512
486         int       nChunksPerBlock;       // does not need to be a power of 2
487         int   nBytesPerSpare;    // spare area size
488         int   startBlock;                // Start block we're allowed to use
489         int   endBlock;                  // End block we're allowed to use
490         int   nReservedBlocks;   // We want this tuneable so that we can reduce
491                                                          // reserved blocks on NOR and RAM.
492         
493         int   nShortOpCaches;   // If <= 0, then short op caching is disabled, else
494                                                         // the number of short op caches (don't use too many).
495                                                         
496         int useHeaderFileSize; // Flag to determine if we should use file sizes from the header 
497
498         int   useNANDECC;               // Flag to decide whether or not to use NANDECC
499         
500         
501         void *genericDevice; // Pointer to device context
502                                                  // On an mtd this holds the mtd pointer.
503
504         // NAND access functions (Must be set before calling YAFFS)
505         
506 #ifndef CONFIG_YAFFS_NO_YAFFS1
507         int (*writeChunkToNAND)(struct yaffs_DeviceStruct *dev,int chunkInNAND, const __u8 *data, const yaffs_Spare *spare);
508         int (*readChunkFromNAND)(struct yaffs_DeviceStruct *dev,int chunkInNAND, __u8 *data, yaffs_Spare *spare);
509 //      int (*eraseBlockInNAND)(struct yaffs_DeviceStruct *dev,int blockInNAND);        
510 //      int (*initialiseNAND)(struct yaffs_DeviceStruct *dev);
511 #endif
512 #ifndef CONFIG_YAFFS_NO_YAFFS2
513         int (*writeChunkWithTagsToNAND)(struct yaffs_DeviceStruct *dev,int chunkInNAND, const __u8 *data, yaffs_ExtendedTags *tags);
514         int (*readChunkWithTagsFromNAND)(struct yaffs_DeviceStruct *dev,int chunkInNAND, __u8 *data, yaffs_ExtendedTags *tags);
515         int (*eraseBlockInNAND)(struct yaffs_DeviceStruct *dev,int blockInNAND);        
516         int (*initialiseNAND)(struct yaffs_DeviceStruct *dev);
517         int (*markNANDBlockBad)(struct yaffs_DeviceStruct *dev, int blockNo);
518         int (*queryNANDBlock)(struct yaffs_DeviceStruct *dev, int blockNo, yaffs_BlockState *state, int *sequenceNumber);
519 #endif
520
521         int isYaffs2;
522
523         // End of stuff that must be set before initialisation.
524         
525         // Runtime parameters. Set up by YAFFS.
526         
527         __u16 chunkGroupBits; // 0 for devices <= 32MB. else log2(nchunks) - 16
528         __u16 chunkGroupSize; // == 2^^chunkGroupBits
529         
530 #ifdef __KERNEL__
531
532         struct semaphore sem;// Semaphore for waiting on erasure.
533         struct semaphore grossLock; // Gross locking semaphore
534
535 #endif  
536 #ifdef __KERNEL__
537         void (*putSuperFunc)(struct super_block *sb);
538 #endif
539
540         int isMounted;
541         
542         // Block Info
543         yaffs_BlockInfo *blockInfo;
544         __u8 *chunkBits;   // bitmap of chunks in use
545         int   chunkBitmapStride; // Number of bytes of chunkBits per block. 
546                                                          //     Must be consistent with nChunksPerBlock.
547
548
549         int   nErasedBlocks;
550         int   allocationBlock;                  // Current block being allocated off
551         __u32 allocationPage;
552         int   allocationBlockFinder;    // Used to search for next allocation block
553         
554         // Runtime state
555         int   nTnodesCreated;   
556         yaffs_Tnode *freeTnodes;
557         int  nFreeTnodes;
558         yaffs_TnodeList *allocatedTnodeList;
559
560
561         int   nObjectsCreated;
562         yaffs_Object *freeObjects;
563         int   nFreeObjects;
564
565         yaffs_ObjectList *allocatedObjectList;
566
567         yaffs_ObjectBucket objectBucket[YAFFS_NOBJECT_BUCKETS];
568
569         int       nFreeChunks;
570                 
571         int   currentDirtyChecker;      // Used to find current dirtiest block
572         
573         __u32  *gcCleanupList; // objects to delete at the end of a GC. 
574         
575         // Operations since mount
576         int nPageWrites;
577         int nPageReads;
578         int nBlockErasures;
579         int nErasureFailures;
580         int nGCCopies;
581         int garbageCollections;
582         int passiveGarbageCollections;
583         int nRetriedWrites;
584         int nRetiredBlocks;
585         int eccFixed;
586         int eccUnfixed;
587         int tagsEccFixed;
588         int tagsEccUnfixed;
589         int nDeletions;
590         int nUnmarkedDeletions;
591         
592         yaffs_Object *rootDir;
593         yaffs_Object *lostNFoundDir;
594         
595         // Buffer areas for storing data to recover from write failures
596 //      __u8            bufferedData[YAFFS_CHUNKS_PER_BLOCK][YAFFS_BYTES_PER_CHUNK];
597 //      yaffs_Spare bufferedSpare[YAFFS_CHUNKS_PER_BLOCK];
598         int bufferedBlock;      // Which block is buffered here?
599         int doingBufferedBlockRewrite;
600
601         yaffs_ChunkCache *srCache;
602         int srLastUse;
603
604         int cacheHits;
605
606         // Stuff for background deletion and unlinked files.
607         yaffs_Object *unlinkedDir;              // Directory where unlinked and deleted files live.
608         yaffs_Object *deletedDir;               // Directory where deleted objects are sent to disappear.
609         yaffs_Object *unlinkedDeletion; // Current file being background deleted.
610         int nDeletedFiles;                              // Count of files awaiting deletion;
611         int nUnlinkedFiles;                             // Count of unlinked files. 
612         int nBackgroundDeletions;                       // Count of background deletions.       
613         
614         //__u8 *localBuffer;
615         
616         yaffs_TempBuffer tempBuffer[YAFFS_N_TEMP_BUFFERS];
617         int maxTemp;
618         int unmanagedTempAllocations;
619         int unmanagedTempDeallocations;
620         
621         // yaffs2 runtime stuff
622         unsigned sequenceNumber;                //Sequence number of currently allocating block
623         unsigned oldestDirtySequence;
624         
625 };
626
627 typedef struct yaffs_DeviceStruct yaffs_Device;
628
629
630 // Function to manipulate block info
631 static  Y_INLINE yaffs_BlockInfo* yaffs_GetBlockInfo(yaffs_Device *dev, int blk)
632 {
633         if(blk < dev->startBlock || blk > dev->endBlock)
634         {
635                 T(YAFFS_TRACE_ERROR,(TSTR("**>> yaffs: getBlockInfo block %d is not valid" TENDSTR),blk));
636                 YBUG();
637         }
638         return &dev->blockInfo[blk - dev->startBlock];
639 }
640
641
642 //////////// YAFFS Functions //////////////////
643
644 int yaffs_GutsInitialise(yaffs_Device *dev);
645 void yaffs_Deinitialise(yaffs_Device *dev);
646
647 int yaffs_GetNumberOfFreeChunks(yaffs_Device *dev);
648
649
650 // Rename
651 int yaffs_RenameObject(yaffs_Object *oldDir, const YCHAR *oldName, yaffs_Object *newDir, const YCHAR *newName);
652
653 // generic Object functions
654 int yaffs_Unlink(yaffs_Object *dir, const YCHAR *name);
655 int yaffs_DeleteFile(yaffs_Object *obj);
656
657 // Object access functions.
658 int yaffs_GetObjectName(yaffs_Object *obj,YCHAR *name,int buffSize);
659 int yaffs_GetObjectFileLength(yaffs_Object *obj);
660 int yaffs_GetObjectInode(yaffs_Object *obj);
661 unsigned yaffs_GetObjectType(yaffs_Object *obj);
662 int yaffs_GetObjectLinkCount(yaffs_Object *obj);
663
664 // Change inode attributes
665 int yaffs_SetAttributes(yaffs_Object *obj, struct iattr *attr);
666 int yaffs_GetAttributes(yaffs_Object *obj, struct iattr *attr);
667
668 // File operations
669 int yaffs_ReadDataFromFile(yaffs_Object *obj, __u8 *buffer, __u32 offset, int nBytes);
670 int yaffs_WriteDataToFile(yaffs_Object *obj, const __u8 *buffer, __u32 offset, int nBytes);
671 int yaffs_ResizeFile(yaffs_Object *obj, int newSize);
672
673 yaffs_Object *yaffs_MknodFile(yaffs_Object *parent,const YCHAR *name, __u32 mode, __u32 uid, __u32 gid);
674 int yaffs_FlushFile(yaffs_Object *obj,int updateTime);
675
676
677 // Directory operations
678 yaffs_Object *yaffs_MknodDirectory(yaffs_Object *parent,const YCHAR *name, __u32 mode, __u32 uid, __u32 gid);
679 yaffs_Object *yaffs_FindObjectByName(yaffs_Object *theDir,const YCHAR *name);
680 int yaffs_ApplyToDirectoryChildren(yaffs_Object *theDir,int (*fn)(yaffs_Object *));
681
682 yaffs_Object *yaffs_FindObjectByNumber(yaffs_Device *dev,__u32 number);
683
684 // Link operations
685 yaffs_Object *yaffs_Link(yaffs_Object *parent, const YCHAR *name, yaffs_Object *equivalentObject);
686
687 yaffs_Object *yaffs_GetEquivalentObject(yaffs_Object *obj);
688
689 // Symlink operations
690 yaffs_Object *yaffs_MknodSymLink(yaffs_Object *parent, const YCHAR *name, __u32 mode,  __u32 uid, __u32 gid, const YCHAR *alias);
691 YCHAR *yaffs_GetSymlinkAlias(yaffs_Object *obj);
692
693 // Special inodes (fifos, sockets and devices)
694 yaffs_Object *yaffs_MknodSpecial(yaffs_Object *parent,const YCHAR *name, __u32 mode, __u32 uid, __u32 gid,__u32 rdev);
695
696
697 // Special directories
698 yaffs_Object *yaffs_Root(yaffs_Device *dev);
699 yaffs_Object *yaffs_LostNFound(yaffs_Device *dev);
700
701 #ifdef CONFIG_YAFFS_WINCE
702 // CONFIG_YAFFS_WINCE special stuff
703 void  yfsd_WinFileTimeNow(__u32 target[2]);
704 #endif
705
706
707 // Debug dump 
708 int yaffs_DumpObject(yaffs_Object *obj);
709
710
711 void yaffs_GutsTest(yaffs_Device *dev);
712
713
714 void yaffs_InitialiseTags(yaffs_ExtendedTags *tags);
715 void yaffs_DeleteChunk(yaffs_Device *dev,int chunkId,int markNAND,int lyn);
716 int yaffs_CheckFF(__u8 *buffer,int nBytes);
717
718 #endif
719