Make bigger RAM emulation
[yaffs2.git] / yaffs_fs.c
1 /*
2  * YAFFS: Yet another FFS. A NAND-flash specific file system.
3  * yaffs_fs.c
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 General Public License version 2 as
12  * published by the Free Software Foundation.
13  *
14  * This is the file system front-end to YAFFS that hooks it up to
15  * the VFS.
16  *
17  * Special notes: 
18  * >> sb->u.generic_sbp points to the yaffs_Device associated with this superblock
19  * >> inode->u.generic_ip points to the associated yaffs_Object.
20  *
21  *
22  * Acknowledgements:
23  * * Luc van OostenRyck for numerous patches.
24  * * Nick Bane for numerous patches.
25  * * Nick Bane for 2.5/2.6 integration.
26  * * Andras Toth for mknod rdev issue.
27  * * Michael Fischer for finding the problem with inode inconsistency.
28  * * Some code bodily lifted from JFFS2.
29  */
30
31
32 const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.4 2005-04-24 09:20:24 charles Exp $";
33 extern const char *yaffs_guts_c_version;
34
35
36
37 #include <linux/config.h>
38 #include <linux/kernel.h>
39 #include <linux/module.h>
40 #include <linux/version.h>
41 #include <linux/slab.h>
42 #include <linux/init.h>
43 #include <linux/list.h>
44 #include <linux/fs.h>
45 #include <linux/proc_fs.h>
46 #include <linux/pagemap.h>
47 #include <linux/mtd/mtd.h>
48 #include <linux/interrupt.h>
49 #include <linux/string.h>
50
51
52 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
53
54 #include <linux/statfs.h>       /* Added NCB 15-8-2003 */
55 #include <asm/statfs.h>
56 #define UnlockPage(p) unlock_page(p)
57 #define Page_Uptodate(page)     test_bit(PG_uptodate, &(page)->flags)
58 //#define kdevname(x) cdevname(to_kdev_t(x))
59 #define kdevname(x) "(unavailable)"     // temporary fix
60
61 #else
62
63 #include <linux/locks.h>
64
65 #endif
66
67 #include <asm/uaccess.h>
68
69 #include "yportenv.h"
70 #include "yaffs_guts.h"
71
72
73
74
75 unsigned yaffs_traceMask = YAFFS_TRACE_ALWAYS | YAFFS_TRACE_BAD_BLOCKS;
76 //unsigned yaffs_traceMask = 0xFFFFFFFF;
77
78
79 #ifdef CONFIG_YAFFS_RAM_ENABLED
80 #include "yaffs_nandemul.h" 
81 // 2 MB of RAM for emulation
82 #define YAFFS_RAM_EMULATION_SIZE  0x200000
83 #endif //CONFIG_YAFFS_RAM_ENABLED
84
85 #if CONFIG_YAFFS2_RAM_ENABLED
86 #include "yaffs_nandemul2k.h"
87 #endif
88
89 #ifdef CONFIG_YAFFS_MTD_ENABLED
90 #include <linux/mtd/mtd.h>
91 #include "yaffs_mtdif.h"
92 #include "yaffs_mtdif2.h"
93 #endif //CONFIG_YAFFS_MTD_ENABLED
94
95 //#define T(x) printk x
96
97
98
99 #define yaffs_InodeToObject(iptr) ((yaffs_Object *)((iptr)->u.generic_ip))
100 #define yaffs_DentryToObject(dptr) yaffs_InodeToObject((dptr)->d_inode)
101 //NCB #define yaffs_SuperToDevice(sb)   ((yaffs_Device *)sb->u.generic_sbp)
102
103 //#if defined(CONFIG_KERNEL_2_5)
104 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
105 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->s_fs_info)
106 #else
107 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->u.generic_sbp)
108 #endif
109
110
111 static void yaffs_put_super(struct super_block *sb);
112
113 #if 0
114 static ssize_t yaffs_file_read(struct file *f, char *buf, size_t n, loff_t *pos);
115 #endif
116
117 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, loff_t *pos);
118
119 static int yaffs_file_flush(struct file* file);
120
121 static int yaffs_sync_object(struct file * file, struct dentry *dentry, int datasync);
122
123 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir);
124
125 //#if defined(CONFIG_KERNEL_2_5)        /* Added NCB 185-8-2003 */
126 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
127 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *n);
128 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *n);
129 #else
130 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode);
131 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry);
132 #endif
133 static int yaffs_link(struct dentry *old_dentry, struct inode * dir, struct dentry * dentry);
134 static int yaffs_unlink(struct inode * dir, struct dentry *dentry);
135 static int yaffs_symlink(struct inode * dir, struct dentry *dentry, const char * symname);
136 static int yaffs_mkdir(struct inode * dir, struct dentry * dentry, int mode);
137
138 //#if defined(CONFIG_KERNEL_2_5)
139 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
140 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
141 #else
142 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev);
143 #endif
144 static int yaffs_rename(struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry);
145 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr);
146
147 //#if defined(CONFIG_KERNEL_2_5)        /* Added NCB 185-8-2003 */
148 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
149 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf);
150 #else
151 static int yaffs_statfs(struct super_block *sb, struct statfs *buf);
152 #endif
153 static void yaffs_read_inode (struct inode *inode);
154
155 //#if defined(CONFIG_KERNEL_2_5)
156 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
157 static struct super_block *yaffs_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data);
158 #else
159 static struct super_block *yaffs_read_super(struct super_block * sb, void * data, int silent);
160 #endif
161
162 static void yaffs_put_inode (struct inode *inode);
163 static void yaffs_delete_inode(struct inode *);
164 static void yaffs_clear_inode(struct inode *);
165
166 static int yaffs_readpage(struct file *file, struct page * page);
167 static int yaffs_writepage(struct page *page);
168 static int yaffs_prepare_write(struct file *f, struct page *pg, unsigned offset, unsigned to);
169 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, unsigned to);
170
171 static int yaffs_readlink(struct dentry *dentry, char *buffer, int buflen);
172 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd);
173
174
175
176
177 static struct address_space_operations yaffs_file_address_operations = {
178         readpage:               yaffs_readpage,
179         writepage:              yaffs_writepage,
180         prepare_write:  yaffs_prepare_write,
181         commit_write:   yaffs_commit_write
182 };
183
184
185 static struct file_operations yaffs_file_operations = {
186
187         read:           generic_file_read,
188         write:          generic_file_write,
189
190         mmap:           generic_file_mmap,
191         flush:          yaffs_file_flush,
192         fsync:          yaffs_sync_object,
193 };
194
195
196 static struct inode_operations yaffs_file_inode_operations = {
197         setattr:        yaffs_setattr,
198 };
199
200
201 struct inode_operations yaffs_symlink_inode_operations =
202 {       
203         readlink:       yaffs_readlink,
204         follow_link:    yaffs_follow_link,
205         setattr:        yaffs_setattr
206 };
207
208 static struct inode_operations yaffs_dir_inode_operations = {
209         create:         yaffs_create,
210         lookup:         yaffs_lookup,
211         link:           yaffs_link,
212         unlink:         yaffs_unlink,   
213         symlink:        yaffs_symlink,
214         mkdir:          yaffs_mkdir,
215         rmdir:          yaffs_unlink,
216         mknod:          yaffs_mknod,
217         rename:         yaffs_rename,
218         setattr:        yaffs_setattr,
219 };
220
221 static struct file_operations yaffs_dir_operations = {
222         read:           generic_read_dir,
223         readdir:        yaffs_readdir,
224         fsync:          yaffs_sync_object,
225 };
226
227
228 static struct super_operations yaffs_super_ops = {
229         statfs:                 yaffs_statfs,
230         read_inode:             yaffs_read_inode,
231         put_inode:              yaffs_put_inode,
232         put_super:              yaffs_put_super,
233 //      remount_fs:
234         delete_inode:           yaffs_delete_inode,
235         clear_inode:            yaffs_clear_inode,
236 };
237
238
239
240 static void yaffs_GrossLock(yaffs_Device *dev)
241 {
242         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs locking\n"));
243
244         down(&dev->grossLock);
245 }
246
247 static void yaffs_GrossUnlock(yaffs_Device *dev)
248 {
249         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs unlocking\n"));
250         up(&dev->grossLock);
251
252 }
253
254 static int yaffs_readlink(struct dentry *dentry, char *buffer, int buflen)
255 {
256         unsigned char *alias;
257         int ret;
258
259         yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
260
261
262         yaffs_GrossLock(dev);
263         
264         alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
265         
266         yaffs_GrossUnlock(dev);
267         
268         if(!alias)
269                 return -ENOMEM;
270
271         ret = vfs_readlink(dentry, buffer, buflen, alias);
272         kfree(alias);
273         return ret;
274 }
275
276 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd)
277 {
278         unsigned char *alias;
279         int ret;
280         yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
281
282
283         yaffs_GrossLock(dev);
284
285         alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
286         
287         yaffs_GrossUnlock(dev);
288         
289         if(!alias)
290                 return -ENOMEM;
291
292         ret = vfs_follow_link(nd,alias);
293         kfree(alias);
294         return ret;
295 }
296
297
298 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,yaffs_Object *obj);
299
300 /*
301  * Lookup is used to find objects in the fs
302  */
303 //#if defined(CONFIG_KERNEL_2_5)        /* Added NCB 185-8-2003 */
304 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
305
306 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *n)
307 #else
308 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry)
309 #endif
310 {
311         yaffs_Object *obj;
312         struct inode *inode = NULL; // NCB 2.5/2.6 needs NULL here
313         
314         yaffs_Device *dev = yaffs_InodeToObject(dir)->myDev;
315
316
317         yaffs_GrossLock(dev);
318
319         
320         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_lookup for %d:%s\n",yaffs_InodeToObject(dir)->objectId,dentry->d_name.name));
321         
322         obj = yaffs_FindObjectByName(yaffs_InodeToObject(dir),dentry->d_name.name);
323         
324         obj = yaffs_GetEquivalentObject(obj); // in case it was a hardlink
325         
326
327         
328         if(obj)
329         {
330                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_lookup found %d\n",obj->objectId));
331                 
332                 inode = yaffs_get_inode(dir->i_sb, obj->st_mode,0,obj);
333                 
334                 if(inode)
335                 {
336                         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_loookup dentry \n"));
337 /* #if 0 asserted by NCB for 2.5/6 compatability - falls through to d_add even if NULL inode */ 
338 #if 0
339                         //dget(dentry); // try to solve directory bug
340                         d_add(dentry,inode);
341                         
342                         yaffs_GrossUnlock(dev);
343
344                         // return dentry;
345                         return NULL;
346 #endif
347                 }
348
349         }
350         else
351         {
352                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_lookup not found\n"));
353                 
354         }
355         yaffs_GrossUnlock(dev);
356
357 /* added NCB for 2.5/6 compatability - forces add even if inode is NULL which creates dentry hash*/     
358         d_add(dentry,inode);
359         
360         return NULL;
361         //      return (ERR_PTR(-EIO));
362         
363 }
364
365 // For now put inode is just for debugging
366 // Put inode is called when the inode **structure** is put.
367 static void yaffs_put_inode(struct inode *inode)
368 {
369         T(YAFFS_TRACE_OS,("yaffs_put_inode: ino %d, count %d\n",(int)inode->i_ino, atomic_read(&inode->i_count)));
370         
371 }
372
373 // clear is called to tell the fs to release any per-inode data it holds
374 static void yaffs_clear_inode(struct inode *inode)
375 {
376         yaffs_Object *obj;
377         yaffs_Device *dev;
378         
379         obj = yaffs_InodeToObject(inode);
380         
381         T(YAFFS_TRACE_OS,("yaffs_clear_inode: ino %d, count %d %s\n",(int)inode->i_ino, atomic_read(&inode->i_count),
382                 obj ? "object exists" : "null object"));        
383
384         if(obj)
385         {
386                 dev = obj->myDev;
387                 yaffs_GrossLock(dev);
388                 
389                 // Clear the association between the inode ant the yaffs_Object.
390                 obj->myInode = NULL;
391                 inode->u.generic_ip = NULL;
392                 
393                 // If the object freeing was deferred, then the real free happens now.
394                 // This should fix the inode inconsistency problem.
395                 
396                 yaffs_HandleDeferedFree(obj);
397                 
398                 yaffs_GrossUnlock(dev);
399         }
400         
401         
402 }
403
404 // delete is called when the link count is zero and the inode
405 // is put (ie. nobody wants to know about it anymore, time to
406 // delete the file).
407 // NB Must call clear_inode()
408 static void yaffs_delete_inode(struct inode *inode)
409 {
410         yaffs_Object *obj = yaffs_InodeToObject(inode);
411         yaffs_Device *dev;
412
413         T(YAFFS_TRACE_OS,("yaffs_delete_inode: ino %d, count %d %s\n",(int)inode->i_ino, atomic_read(&inode->i_count),
414                 obj ? "object exists" : "null object"));
415         
416         if(obj)
417         {
418                 dev = obj->myDev;
419                 yaffs_GrossLock(dev);
420                 yaffs_DeleteFile(obj);
421                 yaffs_GrossUnlock(dev);
422         }
423         clear_inode(inode);
424 }
425
426
427 static int yaffs_file_flush(struct file* file)
428 {
429         yaffs_Object *obj = yaffs_DentryToObject(file->f_dentry);
430         
431         yaffs_Device *dev = obj->myDev;
432         
433         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_flush object %d (%s)\n",obj->objectId,
434                                 obj->dirty ? "dirty" : "clean"));
435
436         yaffs_GrossLock(dev);
437         
438     yaffs_FlushFile(obj,1);
439
440         yaffs_GrossUnlock(dev);
441
442     return 0;
443 }
444
445
446
447 static int yaffs_readpage_nolock(struct file *f, struct page * pg)
448 {
449         // Lifted from jffs2
450         
451         yaffs_Object *obj;
452         unsigned char *pg_buf;
453         int ret;
454
455         yaffs_Device *dev;
456
457         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readpage at %08x, size %08x\n",
458                       (unsigned)(pg->index << PAGE_CACHE_SHIFT), (unsigned)PAGE_CACHE_SIZE));
459
460         obj  = yaffs_DentryToObject(f->f_dentry);
461
462         dev = obj->myDev;
463         
464         
465         if (!PageLocked(pg))
466                 PAGE_BUG(pg);
467
468         pg_buf = kmap(pg);
469         /* FIXME: Can kmap fail? */
470
471         yaffs_GrossLock(dev);
472         
473         ret = yaffs_ReadDataFromFile(obj, pg_buf, pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE);
474
475         yaffs_GrossUnlock(dev);
476         
477         if(ret >= 0) ret = 0;
478
479         if (ret) {
480                 ClearPageUptodate(pg);
481                 SetPageError(pg);
482         } else {
483                 SetPageUptodate(pg);
484                 ClearPageError(pg);
485         }
486
487         flush_dcache_page(pg);
488         kunmap(pg);
489
490
491         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readpage done\n"));
492         return ret;
493 }
494
495 static int yaffs_readpage_unlock(struct file *f, struct page *pg)
496 {
497         int ret = yaffs_readpage_nolock(f,pg);
498         UnlockPage(pg);
499         return ret;
500 }
501
502 static int yaffs_readpage(struct file *f, struct page * pg)
503 {
504         return yaffs_readpage_unlock(f,pg);
505 }
506
507 // writepage inspired by/stolen from smbfs
508 //
509
510 static int yaffs_writepage(struct page *page)
511 {
512         struct address_space *mapping = page->mapping;
513         struct inode *inode;
514         unsigned long end_index;
515         char *buffer;
516         yaffs_Object *obj;
517         int nWritten = 0;
518         unsigned nBytes;
519
520         if (!mapping)
521                 BUG();
522         inode = mapping->host;
523         if (!inode)
524                 BUG();
525
526         end_index = inode->i_size >> PAGE_CACHE_SHIFT;
527
528         /* easy case */
529         if (page->index < end_index)
530         {
531                 nBytes = PAGE_CACHE_SIZE;
532         }
533         else
534         {
535                 nBytes = inode->i_size & (PAGE_CACHE_SIZE-1);
536         }
537         //  What's happening here?
538         ///* OK, are we completely out? */
539         //if (page->index >= end_index+1 || !offset)
540         //      return -EIO;
541
542         get_page(page);
543
544
545         buffer = kmap(page);
546
547         obj = yaffs_InodeToObject(inode);
548         yaffs_GrossLock(obj->myDev);
549
550
551         nWritten = yaffs_WriteDataToFile(obj,buffer,page->index << PAGE_CACHE_SHIFT,nBytes);
552
553         yaffs_GrossUnlock(obj->myDev);
554         
555         kunmap(page);
556         SetPageUptodate(page);
557         UnlockPage(page);
558         put_page(page);
559
560         return (nWritten == nBytes) ? 0  : -ENOSPC;
561 }
562
563
564
565 static int yaffs_prepare_write(struct file *f, struct page *pg, unsigned offset, unsigned to)
566 {
567
568         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_prepair_write\n"));
569         if(!Page_Uptodate(pg) && (offset || to < PAGE_CACHE_SIZE))
570                 return  yaffs_readpage_nolock(f,pg);    
571
572         return 0;
573         
574 }
575
576 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, unsigned to)
577 {
578
579         void *addr = page_address(pg) + offset;
580         loff_t pos = (((loff_t)pg->index) << PAGE_CACHE_SHIFT) + offset;
581         int nBytes = to - offset;
582         int nWritten;
583         
584         unsigned spos = pos;
585         unsigned saddr = (unsigned)addr;
586
587         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_commit_write addr %x pos %x nBytes %d\n",saddr,spos,nBytes));
588         
589         nWritten = yaffs_file_write(f,addr, nBytes, &pos);
590         
591         if(nWritten != nBytes)
592         {
593                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_commit_write not same size nWritten %d  nBytes %d\n",nWritten,nBytes));
594                 SetPageError(pg);
595                 ClearPageUptodate(pg);
596         }
597         else
598         {
599                 SetPageUptodate(pg);
600         }
601
602         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_commit_write returning %d\n",nWritten));
603         
604         return nWritten;
605
606 }
607
608
609
610 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object *obj)
611 {
612         if (inode && obj) 
613         {
614                 inode->i_ino = obj->objectId;
615                 inode->i_mode = obj->st_mode;
616                 inode->i_uid = obj->st_uid;
617                 inode->i_gid = obj->st_gid;
618                 inode->i_blksize = inode->i_sb->s_blocksize;
619 //#if defined(CONFIG_KERNEL_2_5)
620 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
621
622                 inode->i_rdev = old_decode_dev(obj->st_rdev);
623                 inode->i_atime.tv_sec = (time_t)(obj->st_atime);
624                 inode->i_atime.tv_nsec = 0;
625                 inode->i_mtime.tv_sec = (time_t)obj->st_mtime;
626                 inode->i_mtime.tv_nsec =0;
627                 inode->i_ctime.tv_sec = (time_t)obj->st_ctime;
628                 inode->i_ctime.tv_nsec = 0;
629 #else
630                 inode->i_rdev = obj->st_rdev;
631                 inode->i_atime = obj->st_atime;
632                 inode->i_mtime = obj->st_mtime;
633                 inode->i_ctime = obj->st_ctime;
634 #endif
635                 inode->i_size = yaffs_GetObjectFileLength(obj);
636                 inode->i_blocks = (inode->i_size + 511) >> 9;
637
638                 inode->i_nlink = yaffs_GetObjectLinkCount(obj);
639                 
640                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_FillInode mode %x uid %d gid %d size %d count %d\n",
641                                 inode->i_mode, inode->i_uid, inode->i_gid, (int)inode->i_size, atomic_read(&inode->i_count)));
642                 
643                 switch (obj->st_mode & S_IFMT) 
644                 {
645                         default: // fifo, device or socket
646 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
647                                init_special_inode(inode, obj->st_mode,old_decode_dev(obj->st_rdev));
648 #else
649                                  init_special_inode(inode, obj->st_mode,(dev_t)(obj->st_rdev));
650 #endif                          break;
651                         case S_IFREG:   // file         
652                                 inode->i_op = &yaffs_file_inode_operations;
653                                 inode->i_fop = &yaffs_file_operations;
654                                 inode->i_mapping->a_ops = &yaffs_file_address_operations;
655                                 break;
656                         case S_IFDIR:   // directory
657                                 inode->i_op = &yaffs_dir_inode_operations;
658                                 inode->i_fop = &yaffs_dir_operations;
659                                 break;
660                         case S_IFLNK:   // symlink
661                                 inode->i_op = &yaffs_symlink_inode_operations;
662                                 break;
663                 }
664                 
665                 
666                 inode->u.generic_ip = obj;
667                 obj->myInode = inode;
668                 
669         }
670         else
671         {
672                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_FileInode invalid parameters\n"));
673         }
674
675 }
676
677 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,yaffs_Object *obj)
678 {
679         struct inode * inode;
680         
681         if(!sb)
682         {
683           T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_get_inode for NULL super_block!!\n"));
684           return NULL;
685           
686         }
687         
688         if(!obj)
689         {
690           T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_get_inode for NULL object!!\n"));
691           return NULL;
692           
693         }
694         
695         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_get_inode for object %d\n",obj->objectId));
696
697         inode = iget(sb,obj->objectId);
698
699         // NB Side effect: iget calls back to yaffs_read_inode().
700         // iget also increments the inode's i_count
701         
702         return inode;
703 }
704
705 #if 0
706
707 // No longer used because we use generic rw */
708 static ssize_t yaffs_file_read(struct file *f, char *buf, size_t n, loff_t *pos)
709 {
710         yaffs_Object *obj;
711         int nRead,ipos;
712         struct inode *inode;
713         yaffs_Device *dev;
714         
715         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_read\n"));
716
717         obj  = yaffs_DentryToObject(f->f_dentry);
718         
719         dev = obj->myDev;
720         
721         yaffs_GrossLock(dev);
722         
723         inode = f->f_dentry->d_inode;
724         
725         if (*pos < inode->i_size) 
726         {
727                         if (*pos + n > inode->i_size)
728                         {
729                                 n = inode->i_size - *pos;
730                         }
731         }
732         else
733         {
734                 n = 0;
735         }
736         
737         nRead = yaffs_ReadDataFromFile(obj,buf,*pos,n);
738         if(nRead > 0)
739         {
740                 f->f_pos += nRead;
741         }
742         
743         yaffs_GrossUnlock(dev);
744         
745         ipos = *pos;
746         
747         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_read read %d bytes, %d read at %d\n",n,nRead,ipos));
748         return nRead;
749         
750 }
751
752 #endif
753
754 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, loff_t *pos)
755 {
756         yaffs_Object *obj;
757         int nWritten,ipos;
758         struct inode *inode;
759         yaffs_Device *dev;
760         
761         
762         obj  = yaffs_DentryToObject(f->f_dentry);
763         
764         dev = obj->myDev;
765         
766         yaffs_GrossLock(dev);
767
768         inode = f->f_dentry->d_inode;
769
770         if(!S_ISBLK(inode->i_mode) && f->f_flags & O_APPEND)
771         {
772                 ipos = inode->i_size;
773         }
774         else
775         {
776                 ipos = *pos;
777         }
778         
779         
780         if(!obj)
781         {
782                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write: hey obj is null!\n"));
783         }
784         else
785         {
786                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write about to write writing %d bytes to object %d at %d\n",n,obj->objectId,ipos));
787         }
788
789         nWritten = yaffs_WriteDataToFile(obj,buf,ipos,n);
790
791         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write writing %d bytes, %d written at %d\n",n,nWritten,ipos));
792         if(nWritten > 0)
793         {
794                 ipos += nWritten;
795                 *pos = ipos;
796                 if(ipos > inode->i_size)
797                 {
798                         inode->i_size = ipos;
799                         inode->i_blocks = (ipos + 511)>>9;
800                         
801                         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write size updated to %d bytes, %d blocks\n",ipos,(int)(inode->i_blocks)));
802                 }
803                 
804         }
805         yaffs_GrossUnlock(dev);
806         
807         return nWritten != n ? -ENOSPC : nWritten;
808 }
809
810
811
812 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
813 {
814         yaffs_Object *obj;
815         yaffs_Device *dev;
816         struct inode *inode = f->f_dentry->d_inode;
817         unsigned long offset, curoffs;
818         struct list_head *i;    
819         yaffs_Object *l;
820         
821         char name[YAFFS_MAX_NAME_LENGTH +1];
822                 
823         obj =  yaffs_DentryToObject(f->f_dentry);
824         dev = obj->myDev;
825         
826         yaffs_GrossLock(dev);
827         
828         offset = f->f_pos;
829         
830         T(YAFFS_TRACE_OS,("yaffs_readdir: starting at %d\n",(int)offset));
831         
832         if(offset == 0)
833         {
834         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readdir: entry . ino %d \n",(int)inode->i_ino));
835                 if(filldir(dirent,".",1,offset,inode->i_ino,DT_DIR) < 0)
836                 {
837                         goto out;
838                 }
839                 offset++;
840                 f->f_pos++;
841         }
842         if(offset == 1)
843         {
844                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readdir: entry .. ino %d \n",(int)f->f_dentry->d_parent->d_inode->i_ino));
845                 if(filldir(dirent,"..",2,offset,f->f_dentry->d_parent->d_inode->i_ino,DT_DIR) < 0)
846                 {
847                         goto out;
848                 }
849                 offset++;
850                 f->f_pos++;
851         }
852         
853         curoffs = 1;
854         
855         list_for_each(i,&obj->variant.directoryVariant.children)
856         {
857                 curoffs++;
858                 if(curoffs >= offset)
859                 {               
860                         l = list_entry(i, yaffs_Object,siblings);
861                         
862                         yaffs_GetObjectName(l,name,YAFFS_MAX_NAME_LENGTH+1); 
863                         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readdir: %s inode %d\n",name,yaffs_GetObjectInode(l)));
864                         
865                         if(filldir(dirent,
866                                            name,
867                                            strlen(name),
868                                            offset,
869                                            yaffs_GetObjectInode(l),
870                                            yaffs_GetObjectType(l))
871                                            < 0)
872                         {
873                                 goto up_and_out;
874                         }
875                         
876                         offset++;
877                         f->f_pos++;        
878                 }
879         }
880
881   up_and_out:
882   out:
883   
884     yaffs_GrossUnlock(dev);
885     
886         return 0;
887 }
888
889
890 /*
891  * File creation. Allocate an inode, and we're done..
892  */
893 //#if defined(CONFIG_KERNEL_2_5)
894 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
895 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
896 #else
897 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev)
898 #endif
899 {
900         struct inode *inode;
901         
902         yaffs_Object *obj = NULL;
903         yaffs_Device *dev;
904         
905         yaffs_Object *parent = yaffs_InodeToObject(dir);
906         
907         int error = -ENOSPC;
908
909         if(parent)
910         {
911                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: parent object %d type %d\n",
912                                          parent->objectId,parent->variantType));
913         }
914         else
915         {
916                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: could not get parent object\n"));
917                 return -EPERM;
918         }
919         
920         T(YAFFS_TRACE_OS,("yaffs_mknod: making oject for %s, mode %x dev %x\n",
921                                         dentry->d_name.name, mode,rdev));
922
923         dev = parent->myDev;
924         
925         yaffs_GrossLock(dev);
926
927         switch (mode & S_IFMT) 
928         {
929                 default:
930                         // Special (socket, fifo, device...)
931                         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making special\n"));
932 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
933                         obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,old_encode_dev(rdev));
934 #else
935                         obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,rdev);
936 #endif                  break;
937                 case S_IFREG:   // file         
938                         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making file\n"));
939                         obj = yaffs_MknodFile(parent,dentry->d_name.name,mode,current->uid, current->gid);
940                         break;
941                 case S_IFDIR:   // directory
942                         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making directory\n"));
943                         obj = yaffs_MknodDirectory(parent,dentry->d_name.name,mode,current->uid, current->gid);
944                         break;
945                 case S_IFLNK:   // symlink
946                         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making file\n"));
947                         obj = NULL; // Do we ever get here?
948                         break;
949         }
950         
951         if(obj)
952         {
953                 inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj);
954                 d_instantiate(dentry, inode);
955                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod created object %d count = %d\n",obj->objectId,atomic_read(&inode->i_count)));
956                 error = 0;
957         }
958         else
959         {
960                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod failed making object\n"));
961                 error = -ENOMEM;
962         }
963
964         yaffs_GrossUnlock(dev);
965
966         return error;
967 }
968
969 static int yaffs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
970 {
971         int retVal;
972         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mkdir\n"));
973         retVal =  yaffs_mknod(dir, dentry, mode | S_IFDIR, 0);
974 #if 0
975  // attempt to fix dir bug - didn't work
976         if(!retVal)
977         {
978                 dget(dentry);
979         }
980 #endif
981         return retVal;
982 }
983
984 //#if defined(CONFIG_KERNEL_2_5)        /* Added NCB 185-8-2003 */
985 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
986 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *n)
987 #else
988 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode)
989 #endif
990 {
991         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_create\n"));
992         return yaffs_mknod(dir, dentry, mode | S_IFREG, 0);
993 }
994
995
996 static int yaffs_unlink(struct inode * dir, struct dentry *dentry)
997 {
998         int retVal;
999         
1000         yaffs_Device *dev;
1001         
1002         
1003         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_unlink %d:%s\n",(int)(dir->i_ino),dentry->d_name.name));
1004         
1005         dev = yaffs_InodeToObject(dir)->myDev;
1006         
1007         yaffs_GrossLock(dev);
1008         
1009         
1010         retVal = yaffs_Unlink(yaffs_InodeToObject(dir),dentry->d_name.name);
1011         
1012         
1013         yaffs_GrossUnlock(dev);
1014         
1015         if( retVal == YAFFS_OK)
1016         {
1017                 dentry->d_inode->i_nlink--;
1018                 mark_inode_dirty(dentry->d_inode);
1019                 return 0;
1020         }
1021         else
1022         {
1023                 return -ENOTEMPTY;
1024         }
1025 }
1026
1027
1028 /*
1029  * Create a link...
1030  */
1031 static int yaffs_link(struct dentry *old_dentry, struct inode * dir, struct dentry * dentry)
1032 {
1033         struct inode *inode = old_dentry->d_inode;
1034         yaffs_Object *obj = NULL;
1035         yaffs_Object *link=NULL;
1036         yaffs_Device *dev;
1037         
1038         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_link\n"));
1039         
1040         obj = yaffs_InodeToObject(inode);
1041         dev = obj->myDev;
1042         
1043         yaffs_GrossLock(dev);
1044
1045         if (!S_ISDIR(inode->i_mode))    // Don't link directories
1046         {
1047                 link = yaffs_Link(yaffs_InodeToObject(dir),dentry->d_name.name,obj);
1048         }
1049         
1050
1051         if(link)
1052         {
1053                 old_dentry->d_inode->i_nlink =  yaffs_GetObjectLinkCount(obj);
1054                 d_instantiate(dentry, old_dentry->d_inode);
1055                 atomic_inc(&old_dentry->d_inode->i_count);
1056                 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_link link count %d i_count %d\n",    
1057                         old_dentry->d_inode->i_nlink,atomic_read(&old_dentry->d_inode->i_count)));
1058         
1059         }
1060         
1061         yaffs_GrossUnlock(dev);
1062         
1063
1064         if(link)
1065         {
1066         
1067                 return 0;
1068         }
1069         
1070         
1071         return -EPERM; 
1072 }
1073
1074
1075 static int yaffs_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
1076 {
1077         yaffs_Object *obj;
1078         yaffs_Device *dev;
1079         
1080         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_symlink\n"));
1081         
1082         dev = yaffs_InodeToObject(dir)->myDev;
1083         yaffs_GrossLock(dev);
1084         obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name, 
1085                                                          S_IFLNK | S_IRWXUGO, current->uid, current->gid,
1086                                                          symname);
1087         yaffs_GrossUnlock(dev);
1088
1089         if(obj)
1090         {
1091
1092                 struct inode* inode;
1093         
1094                 inode = yaffs_get_inode(dir->i_sb, obj->st_mode, 0, obj);
1095                 d_instantiate(dentry, inode);
1096                 T(YAFFS_TRACE_OS,(KERN_DEBUG"symlink created OK\n"));
1097                 return 0;
1098         }
1099         else
1100         {
1101                 T(YAFFS_TRACE_OS,(KERN_DEBUG"symlink not created\n"));
1102
1103         }
1104         
1105         return -ENOMEM;
1106 }
1107
1108 static int yaffs_sync_object(struct file * file, struct dentry *dentry, int datasync)
1109 {
1110
1111         yaffs_Object *obj;
1112         yaffs_Device *dev;
1113         
1114         obj = yaffs_DentryToObject(dentry);
1115
1116         dev = obj->myDev;
1117         
1118         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_sync_object\n"));
1119         yaffs_GrossLock(dev);
1120         yaffs_FlushFile(obj,1);
1121         yaffs_GrossUnlock(dev);
1122         return 0;
1123 }
1124
1125 /*
1126  * The VFS layer already does all the dentry stuff for rename.
1127  *
1128  * NB: POSIX says you can rename an object over an old object of the same name
1129  */
1130 static int yaffs_rename(struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry)
1131 {
1132         yaffs_Device *dev;
1133         int retVal = YAFFS_FAIL;
1134         int removed = 0;
1135         yaffs_Object *target;
1136         
1137         dev = yaffs_InodeToObject(old_dir)->myDev;
1138
1139         yaffs_GrossLock(dev);
1140         
1141         // Check if the target is an existing directory that is not empty.
1142         target = yaffs_FindObjectByName(yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
1143         
1144         if(target &&
1145            target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
1146            !list_empty(&target->variant.directoryVariant.children))
1147         {
1148                 retVal = YAFFS_FAIL;
1149         }
1150         else
1151         {
1152            
1153                 // Unlink the target if it exists
1154                 removed = yaffs_Unlink(yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
1155
1156         
1157                 retVal =  yaffs_RenameObject(yaffs_InodeToObject(old_dir),old_dentry->d_name.name,
1158                                                                         yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
1159                                                                         
1160         }
1161         yaffs_GrossUnlock(dev);
1162         
1163         if(retVal == YAFFS_OK)
1164         {
1165                 if(removed == YAFFS_OK)
1166                 {
1167                         new_dentry->d_inode->i_nlink--;
1168                         mark_inode_dirty(new_dentry->d_inode);
1169                 }
1170                 
1171                 return 0;
1172         }
1173         else
1174         {
1175                 return -ENOTEMPTY;
1176         }
1177         
1178
1179 }
1180
1181 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr)
1182 {
1183         struct inode *inode = dentry->d_inode;
1184         int error;
1185         yaffs_Device *dev;
1186         
1187         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_setattr of object %d\n",yaffs_InodeToObject(inode)->objectId));
1188         
1189         if((error = inode_change_ok(inode,attr)) == 0)
1190         {
1191         
1192                 dev = yaffs_InodeToObject(inode)->myDev;
1193                 yaffs_GrossLock(dev);
1194                 if(yaffs_SetAttributes(yaffs_InodeToObject(inode),attr) == YAFFS_OK)
1195                 {
1196                         error = 0;
1197                 }
1198                 else
1199                 {
1200                         error = -EPERM;
1201                 }
1202                 yaffs_GrossUnlock(dev);
1203                 inode_setattr(inode,attr);
1204         }
1205         return error;
1206 }
1207
1208 //#if defined(CONFIG_KERNEL_2_5)        /* Added NCB 185-8-2003 */
1209 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1210 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf)
1211 #else
1212 static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
1213 #endif
1214 {
1215         yaffs_Device *dev = yaffs_SuperToDevice(sb);
1216         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_statfs\n"));
1217
1218         yaffs_GrossLock(dev);
1219         
1220         buf->f_type = YAFFS_MAGIC;
1221         buf->f_bsize = sb->s_blocksize;
1222         buf->f_namelen = 255;
1223         buf->f_blocks = (dev->endBlock - dev->startBlock + 1) * YAFFS_CHUNKS_PER_BLOCK/
1224                                                 (sb->s_blocksize/YAFFS_BYTES_PER_CHUNK);
1225         buf->f_files = 0;
1226         buf->f_ffree = 0;
1227         buf->f_bfree = yaffs_GetNumberOfFreeChunks(dev)/
1228                                                 (sb->s_blocksize/YAFFS_BYTES_PER_CHUNK);
1229         buf->f_bavail =  buf->f_bfree;
1230         
1231         yaffs_GrossUnlock(dev);
1232         return 0;
1233 }
1234
1235 static void yaffs_read_inode (struct inode *inode)
1236 {
1237         // NB This is called as a side effect of other functions and
1238         // thus gross locking should always be in place already.
1239         
1240         yaffs_Object *obj ; 
1241         yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb);
1242         
1243         T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_read_inode for %d\n",(int)inode->i_ino));
1244
1245         obj  = yaffs_FindObjectByNumber(dev,inode->i_ino);
1246         
1247         yaffs_FillInodeFromObject(inode,obj);
1248
1249 }
1250
1251
1252
1253 // Todo
1254 // Currently we only can report a single partition. Need to use lists here
1255 static yaffs_Device *yaffs_dev;
1256 static yaffs_Device *yaffsram_dev;
1257
1258
1259
1260 static void yaffs_put_super(struct super_block *sb)
1261 {
1262         yaffs_Device *dev = yaffs_SuperToDevice(sb);
1263         
1264         yaffs_GrossLock(dev);
1265         if(dev->putSuperFunc)
1266         {
1267                  dev->putSuperFunc(sb);
1268         }
1269         yaffs_Deinitialise(dev);
1270         yaffs_GrossUnlock(dev);
1271
1272         if(dev == yaffs_dev) yaffs_dev = NULL;
1273         if(dev == yaffsram_dev) yaffsram_dev = NULL;
1274                 
1275         kfree(dev);
1276 }
1277
1278
1279 #ifdef CONFIG_YAFFS_MTD_ENABLED
1280
1281 static void  yaffs_MTDPutSuper(struct super_block *sb)
1282 {
1283         
1284         struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
1285         
1286         if(mtd->sync)
1287         {
1288                 mtd->sync(mtd);
1289         }
1290         
1291         put_mtd_device(mtd);
1292 }
1293
1294 #endif
1295
1296
1297 static struct super_block *yaffs_internal_read_super(int yaffsVersion,int useRam, struct super_block * sb, void * data, int silent)
1298 {
1299         int nBlocks;
1300         struct inode * inode = NULL;
1301         struct dentry * root;
1302         yaffs_Device *dev;
1303         int err;
1304         
1305         sb->s_magic = YAFFS_MAGIC;
1306         sb->s_op = &yaffs_super_ops;
1307         
1308         if(!sb)
1309                 printk(KERN_INFO"yaffs: sb is NULL\n");
1310         else if(!sb->s_dev)
1311                 printk(KERN_INFO"yaffs: sb->s_dev is NULL\n");
1312         else if(! kdevname(sb->s_dev))
1313                 printk(KERN_INFO"yaffs: kdevname is NULL\n");
1314         else
1315                 printk(KERN_INFO"yaffs: dev is %d name is \"%s\"\n", sb->s_dev, kdevname(sb->s_dev));
1316
1317         
1318
1319 #ifdef CONFIG_YAFFS_USE_CHUNK_SIZE
1320         sb->s_blocksize = YAFFS_BYTES_PER_CHUNK;
1321         sb->s_blocksize_bits = YAFFS_CHUNK_SIZE_SHIFT;
1322 #else
1323         sb->s_blocksize = PAGE_CACHE_SIZE;
1324         sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
1325 #endif
1326         T(YAFFS_TRACE_OS,("yaffs_read_super: Using yaffs%d\n",yaffsVersion));
1327         T(YAFFS_TRACE_OS,("yaffs_read_super: %s block size %d\n", useRam ? "RAM" : "MTD",(int)(sb->s_blocksize)));
1328
1329 #ifdef CONFIG_YAFFS_DISABLE_WRITE_VERIFY
1330         T(YAFFS_TRACE_OS,("yaffs: Write verification disabled. All guarantees null and void\n"));
1331 #endif
1332
1333
1334         
1335         if(useRam)
1336         {
1337
1338 #ifdef CONFIG_YAFFS_RAM_ENABLED
1339                 // Set the yaffs_Device up for ram emulation
1340
1341                 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
1342                 if(!dev)
1343                 {
1344                         // Deep shit could not allocate device structure
1345                         T(YAFFS_TRACE_OS,("yaffs_read_super: Failed trying to allocate yaffs_Device.\n"));
1346                         return NULL;
1347                 }
1348
1349                 memset(dev,0,sizeof(yaffs_Device));
1350                 dev->genericDevice = NULL; // Not used for RAM emulation.
1351
1352                 nBlocks = YAFFS_RAM_EMULATION_SIZE / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
1353                 dev->startBlock = 1;  // Don't use block 0
1354                 dev->endBlock = nBlocks - 1;
1355                 dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
1356                 dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
1357                 dev->nReservedBlocks = 5;
1358                 
1359                 if(yaffsVersion == 2)
1360                 {
1361                         dev->writeChunkWithTagsToNAND  = nandemul2k_WriteChunkWithTagsToNAND;
1362                         dev->readChunkWithTagsFromNAND = nandemul2k_ReadChunkWithTagsFromNAND;
1363                         dev->markNANDBlockBad          = nandemul2k_MarkNANDBlockBad;
1364                         dev->queryNANDBlock            = nandemul2k_QueryNANDBlock;
1365                         dev->eraseBlockInNAND          = nandemul2k_EraseBlockInNAND;
1366                         dev->initialiseNAND            = nandemul2k_InitialiseNAND;
1367                         dev->isYaffs2 = 1;
1368                         dev->nChunksPerBlock = nandemul2k_GetChunksPerBlock();
1369                         dev->nBytesPerChunk =  nandemul2k_GetBytesPerChunk();;
1370                         nBlocks = nandemul2k_GetNumberOfBlocks();
1371                         dev->startBlock = 1;  // Don't use block 0
1372                         dev->endBlock = nBlocks - 1;
1373                 }
1374                 else
1375                 {
1376                         dev->writeChunkToNAND = nandemul_WriteChunkToNAND;
1377                         dev->readChunkFromNAND = nandemul_ReadChunkFromNAND;
1378                         dev->eraseBlockInNAND = nandemul_EraseBlockInNAND;
1379                         dev->initialiseNAND = nandemul_InitialiseNAND;
1380                         dev->isYaffs2 = 0;
1381                 }
1382                 
1383                 yaffsram_dev = dev;
1384                 
1385 #endif
1386
1387         }
1388         else
1389         {       
1390 #ifdef CONFIG_YAFFS_MTD_ENABLED
1391                 struct mtd_info *mtd;
1392                 
1393                 T(YAFFS_TRACE_ALWAYS,("yaffs: Attempting MTD mount on %u.%u, \"%s\"\n",
1394                  MAJOR(sb->s_dev),MINOR(sb->s_dev),kdevname(sb->s_dev)));
1395                         
1396                 // Check it's an mtd device.....
1397                 if(MAJOR(sb->s_dev) != MTD_BLOCK_MAJOR)
1398                 {
1399                         return NULL; // This isn't an mtd device
1400                 } 
1401                 
1402                 // Get the device
1403                 mtd = get_mtd_device(NULL, MINOR(sb->s_dev));
1404                 if (!mtd) 
1405                 {
1406                         T(YAFFS_TRACE_ALWAYS,("yaffs: MTD device #%u doesn't appear to exist\n", MINOR(sb->s_dev)));
1407                         return NULL;
1408                 }
1409                 
1410                 // Check it's NAND
1411                 if(mtd->type != MTD_NANDFLASH)
1412                 {
1413                         T(YAFFS_TRACE_ALWAYS,("yaffs: MTD device is not NAND it's type %d\n", mtd->type));
1414                         return NULL;
1415                 }
1416
1417                 T(YAFFS_TRACE_OS,(" erase %x\n",mtd->erase));
1418                 T(YAFFS_TRACE_OS,(" read %x\n",mtd->read));
1419                 T(YAFFS_TRACE_OS,(" write %x\n",mtd->write));
1420                 T(YAFFS_TRACE_OS,(" readoob %x\n",mtd->read_oob));
1421                 T(YAFFS_TRACE_OS,(" writeoob %x\n",mtd->write_oob));
1422                 T(YAFFS_TRACE_OS,(" block_isbad %x\n",mtd->block_isbad));
1423                 T(YAFFS_TRACE_OS,(" block_markbad %x\n",mtd->block_markbad));
1424                 T(YAFFS_TRACE_OS,(" oobblock %d\n",mtd->oobblock));
1425                 T(YAFFS_TRACE_OS,(" oobsize %d\n",mtd->oobsize));
1426                 T(YAFFS_TRACE_OS,(" erasesize %d\n",mtd->erasesize));
1427                 T(YAFFS_TRACE_OS,(" size %d\n",mtd->size));
1428
1429                 if(yaffsVersion == 2)
1430                 {
1431                         // Check for version 2 style functions
1432                         if(!mtd->erase ||
1433                            !mtd->block_isbad ||
1434                            !mtd->block_markbad ||
1435                            !mtd->read  ||
1436                            !mtd->write ||
1437 #ifndef CONFIG_YAFFS_USE_OLD_MTD
1438                            !mtd->write_ecc ||
1439                            !mtd->read_ecc ||
1440 #endif
1441                            !mtd->read_oob ||
1442                            !mtd->write_oob )
1443                         {
1444                                 T(YAFFS_TRACE_ALWAYS,("yaffs: MTD device does not support required functions\n"));;
1445                                 return NULL;
1446                         }
1447                 
1448                         if(mtd->oobblock < YAFFS_MIN_YAFFS2_CHUNK_SIZE ||
1449                            mtd->oobsize < YAFFS_MIN_YAFFS2_SPARE_SIZE)
1450                         {
1451                                 T(YAFFS_TRACE_ALWAYS,("yaffs: MTD device does not support have the right page sizes\n"));
1452                                 return NULL;
1453                         }               }
1454                 else
1455                 {
1456                         // Check for V1 style functions
1457                         if(!mtd->erase ||
1458                            !mtd->read  ||
1459                            !mtd->write ||
1460 #ifndef CONFIG_YAFFS_USE_OLD_MTD
1461                            !mtd->write_ecc ||
1462                            !mtd->read_ecc ||
1463 #endif
1464                            !mtd->read_oob ||
1465                            !mtd->write_oob )
1466                         {
1467                                 T(YAFFS_TRACE_ALWAYS,("yaffs: MTD device does not support required functions\n"));;
1468                                 return NULL;
1469                         }
1470                 
1471                         if(mtd->oobblock != YAFFS_BYTES_PER_CHUNK ||
1472                            mtd->oobsize != YAFFS_BYTES_PER_SPARE)
1473                         {
1474                                 T(YAFFS_TRACE_ALWAYS,("yaffs: MTD device does not support have the right page sizes\n"));
1475                                 return NULL;
1476                         }
1477                 }
1478                    
1479
1480                         // OK, so if we got here, we have an MTD that's NAND and looks 
1481                         // like it has the right capabilities
1482                         // Set the yaffs_Device up for mtd
1483
1484 //#if defined(CONFIG_KERNEL_2_5)
1485 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1486                 sb->s_fs_info = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
1487 #else
1488                 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
1489 #endif
1490                 if(!dev)
1491                 {
1492                         // Deep shit could not allocate device structure
1493                         T(YAFFS_TRACE_ALWAYS,("yaffs_read_super: Failed trying to allocate yaffs_Device. \n"));
1494                         return NULL;
1495                 }
1496
1497                 memset(dev,0,sizeof(yaffs_Device));
1498                 dev->genericDevice = mtd; 
1499
1500                 // Set up the memory size parameters....
1501                 
1502                 nBlocks = mtd->size / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
1503                 dev->startBlock = 1;  // Don't use block 0
1504                 dev->endBlock = nBlocks - 1;
1505                 dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
1506                 dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
1507                 dev->nReservedBlocks = 5;
1508                 dev->nShortOpCaches = 10; // Enable short op caching
1509                 
1510
1511                 // ... and the functions.
1512                 if(yaffsVersion == 2)
1513                 {
1514                         dev->writeChunkWithTagsToNAND = nandmtd2_WriteChunkWithTagsToNAND;
1515                         dev->readChunkWithTagsFromNAND = nandmtd2_ReadChunkWithTagsFromNAND;
1516                         dev->markNANDBlockBad = nandmtd2_MarkNANDBlockBad;
1517                         dev->queryNANDBlock = nandmtd2_QueryNANDBlock;
1518                         dev->spareBuffer = YMALLOC(mtd->oobsize);
1519                         dev->isYaffs2 = 1;
1520                         dev->nBytesPerChunk = mtd->oobblock;
1521                         dev->nChunksPerBlock = mtd->erasesize / mtd->oobblock;
1522                         nBlocks = mtd->size / mtd->erasesize;
1523                         dev->startBlock = 1;  // Don't use block 0
1524                         dev->endBlock = nBlocks - 1;
1525                 }
1526                 else
1527                 {
1528                         dev->writeChunkToNAND = nandmtd_WriteChunkToNAND;
1529                         dev->readChunkFromNAND = nandmtd_ReadChunkFromNAND;
1530                         dev->isYaffs2 = 0;
1531                 }
1532                 // ... and common functions
1533                 dev->eraseBlockInNAND = nandmtd_EraseBlockInNAND;
1534                 dev->initialiseNAND = nandmtd_InitialiseNAND;
1535                 
1536                 dev->putSuperFunc = yaffs_MTDPutSuper;
1537                 
1538 #ifdef CONFIG_YAFFS_USE_NANDECC
1539                 dev->useNANDECC = 1;
1540 #endif
1541
1542                 yaffs_dev = dev;
1543                 
1544 #endif
1545         }
1546
1547         init_MUTEX(&dev->grossLock);
1548         
1549         
1550         yaffs_GrossLock(dev);
1551         
1552         err = yaffs_GutsInitialise(dev);
1553
1554         T(YAFFS_TRACE_OS,("yaffs_read_super: guts initialised %s\n", (err == YAFFS_OK) ? "OK" : "FAILED"));
1555
1556         // Create root inode
1557         if(err == YAFFS_OK)
1558           inode = yaffs_get_inode(sb, S_IFDIR | 0755, 0,yaffs_Root(dev));
1559
1560         yaffs_GrossUnlock(dev);
1561
1562         if (!inode)
1563                 return NULL;
1564                 
1565 // added NCB
1566         inode->i_op = & yaffs_dir_inode_operations;
1567         inode->i_fop = & yaffs_dir_operations;
1568
1569         T(YAFFS_TRACE_OS,("yaffs_read_super: got root inode\n"));
1570                 
1571
1572         root = d_alloc_root(inode);
1573
1574         T(YAFFS_TRACE_OS,("yaffs_read_super: d_alloc_root done\n"));
1575
1576         if (!root) {
1577                 iput(inode);
1578                 return NULL;
1579         }
1580         sb->s_root = root;
1581
1582         T(YAFFS_TRACE_OS,("yaffs_read_super: done\n"));
1583         return sb;
1584 }
1585
1586
1587 static int yaffs_internal_read_super_ram(struct super_block * sb, void * data, int silent)
1588 {
1589          return yaffs_internal_read_super(1,1,sb,data,silent) ? 0 : -1;
1590 }
1591 static int yaffs_internal_read_super_mtd(struct super_block * sb, void * data, int silent)
1592 {
1593          return yaffs_internal_read_super(1,0,sb,data,silent) ? 0 : -1;
1594 }
1595
1596 static int yaffs2_internal_read_super_ram(struct super_block * sb, void * data, int silent)
1597 {
1598          return yaffs_internal_read_super(2,1,sb,data,silent) ? 0 : -1;
1599 }
1600 static int yaffs2_internal_read_super_mtd(struct super_block * sb, void * data, int silent)
1601 {
1602          return yaffs_internal_read_super(2,0,sb,data,silent) ? 0 : -1;
1603 }
1604
1605
1606
1607 #ifdef CONFIG_YAFFS_MTD_ENABLED
1608 //#if defined(CONFIG_KERNEL_2_5)
1609 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1610 static struct super_block *yaffs_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data)
1611 {
1612
1613     return get_sb_bdev(fs, flags, dev_name, data, yaffs_internal_read_super_mtd);
1614 }
1615
1616 /* changes NCB 2.5.70 */
1617 //static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
1618 static struct file_system_type yaffs_fs_type = {
1619         .owner          = THIS_MODULE,
1620         .name           = "yaffs",
1621         .get_sb         = yaffs_read_super,
1622         .kill_sb        = kill_block_super,
1623 //      .kill_sb        = kill_litter_super,
1624         .fs_flags       = FS_REQUIRES_DEV,
1625 };
1626 #else
1627 static struct super_block *yaffs_read_super(struct super_block * sb, void * data, int silent)
1628 {
1629         return yaffs_internal_read_super(1,0,sb,data,silent);
1630 }
1631
1632 static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
1633 #endif
1634
1635 #endif // CONFIG_YAFFS_MTD_ENABLED
1636
1637 #ifdef CONFIG_YAFFS2_MTD_ENABLED
1638
1639 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1640 static struct super_block *yaffs2_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data)
1641 {
1642
1643     return get_sb_bdev(fs, flags, dev_name, data, yaffs2_internal_read_super_mtd);
1644 }
1645
1646 /* changes NCB 2.5.70 */
1647 //static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
1648 static struct file_system_type yaffs2_fs_type = {
1649         .owner          = THIS_MODULE,
1650         .name           = "yaffs2",
1651         .get_sb         = yaffs2_read_super,
1652         .kill_sb        = kill_block_super,
1653 //      .kill_sb        = kill_litter_super,
1654         .fs_flags       = FS_REQUIRES_DEV,
1655 };
1656 #else
1657 static struct super_block *yaffs2_read_super(struct super_block * sb, void * data, int silent)
1658 {
1659         return yaffs_internal_read_super(2,0,sb,data,silent);
1660 }
1661
1662 static DECLARE_FSTYPE(yaffs2_fs_type, "yaffs2", yaffs2_read_super, FS_REQUIRES_DEV);
1663 #endif
1664
1665 #endif // CONFIG_YAFFS2_MTD_ENABLED
1666
1667
1668 #ifdef CONFIG_YAFFS_RAM_ENABLED
1669
1670 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1671 static struct super_block *yaffs_ram_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data)
1672 {
1673
1674     return get_sb_bdev(fs, flags, dev_name, data, yaffs_internal_read_super_ram);
1675 }
1676
1677
1678 static struct file_system_type yaffs_ram_fs_type = {
1679         .owner          = THIS_MODULE,
1680         .name           = "yaffsram",
1681         .get_sb         = yaffs_ram_read_super,
1682         .kill_sb        = kill_block_super,
1683 //      .kill_sb        = kill_litter_super,
1684         .fs_flags       = FS_SINGLE,
1685 };
1686 #else
1687 static struct super_block *yaffs_ram_read_super(struct super_block * sb, void * data, int silent)
1688 {
1689         return yaffs_internal_read_super(1,1,sb,data,silent);
1690 }
1691
1692 static DECLARE_FSTYPE(yaffs_ram_fs_type, "yaffsram", yaffs_ram_read_super, FS_SINGLE);
1693 #endif
1694
1695 #endif // CONFIG_YAFFS_RAM_ENABLED
1696
1697 #ifdef CONFIG_YAFFS2_RAM_ENABLED
1698
1699 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1700 static struct super_block *yaffs2_ram_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data)
1701 {
1702
1703     return get_sb_bdev(fs, flags, dev_name, data, yaffs2_internal_read_super_ram);
1704 }
1705
1706
1707 static struct file_system_type yaffs2_ram_fs_type = {
1708         .owner          = THIS_MODULE,
1709         .name           = "yaffs2ram",
1710         .get_sb         = yaffs2_ram_read_super,
1711         .kill_sb        = kill_block_super,
1712 //      .kill_sb        = kill_litter_super,
1713         .fs_flags       = FS_SINGLE,
1714 };
1715 #else
1716 static struct super_block *yaffs2_ram_read_super(struct super_block * sb, void * data, int silent)
1717 {
1718         return yaffs_internal_read_super(2,1,sb,data,silent);
1719 }
1720
1721 static DECLARE_FSTYPE(yaffs2_ram_fs_type, "yaffs2ram", yaffs2_ram_read_super, FS_SINGLE);
1722 #endif
1723
1724 #endif // CONFIG_YAFFS2_RAM_ENABLED
1725
1726
1727
1728 static struct proc_dir_entry *my_proc_entry;
1729 static struct proc_dir_entry *my_proc_ram_write_entry;
1730
1731 static char * yaffs_dump_dev(char *buf,yaffs_Device *dev,char *name)
1732 {
1733         buf +=sprintf(buf,"\nDevice %s\n",name);
1734         buf +=sprintf(buf,"startBlock......... %d\n",dev->startBlock);
1735         buf +=sprintf(buf,"endBlock........... %d\n",dev->endBlock);
1736         buf +=sprintf(buf,"chunkGroupBits..... %d\n",dev->chunkGroupBits);
1737         buf +=sprintf(buf,"chunkGroupSize..... %d\n",dev->chunkGroupSize);
1738         buf +=sprintf(buf,"nErasedBlocks...... %d\n",dev->nErasedBlocks);
1739         buf +=sprintf(buf,"nTnodesCreated..... %d\n",dev->nTnodesCreated);
1740         buf +=sprintf(buf,"nFreeTnodes........ %d\n",dev->nFreeTnodes);
1741         buf +=sprintf(buf,"nObjectsCreated.... %d\n",dev->nObjectsCreated);
1742         buf +=sprintf(buf,"nFreeObjects....... %d\n",dev->nFreeObjects);
1743         buf +=sprintf(buf,"nFreeChunks........ %d\n",dev->nFreeChunks);
1744         buf +=sprintf(buf,"nPageWrites........ %d\n",dev->nPageWrites);
1745         buf +=sprintf(buf,"nPageReads......... %d\n",dev->nPageReads);
1746         buf +=sprintf(buf,"nBlockErasures..... %d\n",dev->nBlockErasures);
1747         buf +=sprintf(buf,"nGCCopies.......... %d\n",dev->nGCCopies);
1748         buf +=sprintf(buf,"garbageCollections. %d\n",dev->garbageCollections);
1749         buf +=sprintf(buf,"passiveGCs......... %d\n",dev->passiveGarbageCollections);
1750         buf +=sprintf(buf,"nRetriedWrites..... %d\n",dev->nRetriedWrites);
1751         buf +=sprintf(buf,"nRetireBlocks...... %d\n",dev->nRetiredBlocks);
1752         buf +=sprintf(buf,"eccFixed........... %d\n",dev->eccFixed);
1753         buf +=sprintf(buf,"eccUnfixed......... %d\n",dev->eccUnfixed);
1754         buf +=sprintf(buf,"tagsEccFixed....... %d\n",dev->tagsEccFixed);
1755         buf +=sprintf(buf,"tagsEccUnfixed..... %d\n",dev->tagsEccUnfixed);
1756         buf +=sprintf(buf,"cacheHits.......... %d\n",dev->cacheHits);
1757         buf +=sprintf(buf,"nDeletedFiles...... %d\n",dev->nDeletedFiles);
1758         buf +=sprintf(buf,"nUnlinkedFiles..... %d\n",dev->nUnlinkedFiles);
1759         buf +=sprintf(buf,"nBackgroudDeletions %d\n",dev->nBackgroundDeletions);
1760         buf +=sprintf(buf,"useNANDECC......... %d\n",dev->useNANDECC);
1761         buf +=sprintf(buf,"isYaffs2........... %d\n",dev->isYaffs2);
1762
1763         
1764         return buf;     
1765 }
1766
1767 static int  yaffs_proc_read(
1768         char *page,
1769         char **start,
1770         off_t offset,
1771         int count,
1772         int *eof,
1773         void *data
1774         )
1775 {
1776
1777         char my_buffer[3000];
1778         char *buf;
1779         buf = my_buffer;
1780
1781         if (offset > 0) return 0;
1782
1783         /* Fill the buffer and get its length */
1784         buf +=sprintf(buf,"YAFFS built:"__DATE__ " "__TIME__"\n%s\n%s\n", yaffs_fs_c_version,yaffs_guts_c_version);
1785         
1786         if(yaffs_dev) buf = yaffs_dump_dev(buf,yaffs_dev,"yaffs");
1787         if(yaffsram_dev) buf = yaffs_dump_dev(buf,yaffsram_dev,"yaffsram");
1788         
1789
1790         strcpy(page,my_buffer);
1791         return strlen(my_buffer);
1792 }
1793
1794
1795 static int  yaffs_proc_ram_write(
1796         char *page,
1797         char **start,
1798         off_t offset,
1799         int count,
1800         int *eof,
1801         void *data
1802         )
1803 {
1804
1805         printk(KERN_DEBUG "yaffs write size %d\n",count);
1806         return count;
1807 }
1808
1809
1810
1811 // Stuff to handle installation of file systems
1812 struct file_system_to_install
1813 {
1814    struct file_system_type *fst;
1815    int installed;
1816 };
1817
1818 static struct file_system_to_install fs_to_install[] =
1819 {
1820 #ifdef CONFIG_YAFFS_RAM_ENABLED
1821      { &yaffs_ram_fs_type, 0},
1822 #endif
1823 #ifdef CONFIG_YAFFS2_RAM_ENABLED
1824      { &yaffs2_ram_fs_type,0},
1825 #endif
1826 #ifdef CONFIG_YAFFS_MTD_ENABLED
1827      { &yaffs_fs_type,0},
1828 #endif
1829 #ifdef CONFIG_YAFFS2_MTD_ENABLED
1830      { &yaffs2_fs_type,0},
1831 #endif
1832      { NULL,0}
1833 };
1834
1835 static int __init init_yaffs_fs(void)
1836 {
1837         int error = 0;
1838         struct file_system_to_install *fsinst;  
1839         
1840         yaffs_dev = yaffsram_dev = NULL;
1841         
1842    T(YAFFS_TRACE_ALWAYS,("yaffs " __DATE__ " " __TIME__ " Installing. \n"));
1843
1844
1845
1846     /* Install the proc_fs entry */
1847     my_proc_entry = create_proc_read_entry("yaffs",
1848                                            S_IRUGO | S_IFREG,
1849                                            &proc_root,
1850                                            yaffs_proc_read,
1851                                            NULL);
1852     if(!my_proc_entry)
1853     {
1854        return -ENOMEM;
1855     }
1856     
1857     
1858
1859     // Now add the file system entries
1860     
1861     fsinst = fs_to_install;
1862     
1863     while(fsinst->fst && !error)
1864     {
1865       error = register_filesystem(fsinst->fst);
1866       if(!error)
1867       {
1868           fsinst->installed = 1;
1869       }
1870       fsinst++;
1871     }
1872    
1873     // Any errors? uninstall 
1874     if(error)
1875     {
1876             fsinst = fs_to_install;
1877             
1878             while(fsinst->fst)
1879             {
1880               if(fsinst->installed)
1881               {
1882                 unregister_filesystem(fsinst->fst);
1883                 fsinst->installed = 0;
1884               }
1885               fsinst++;
1886             }
1887     }
1888     
1889     return error;
1890 }
1891
1892 static void __exit exit_yaffs_fs(void)
1893 {
1894
1895    struct file_system_to_install *fsinst;
1896    
1897    T(YAFFS_TRACE_ALWAYS,("yaffs " __DATE__ " " __TIME__ " removing. \n"));
1898
1899    remove_proc_entry("yaffs",&proc_root);
1900     
1901     fsinst = fs_to_install;
1902     
1903     while(fsinst->fst)
1904     {
1905       if(fsinst->installed)
1906       {
1907         unregister_filesystem(fsinst->fst);
1908         fsinst->installed = 0;
1909       }
1910       fsinst++;
1911     }
1912
1913 }
1914
1915 module_init(init_yaffs_fs)
1916 module_exit(exit_yaffs_fs)
1917
1918 MODULE_DESCRIPTION("YAFFS2 - a NAND specific flash file system");
1919 MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002,2003,2004");
1920 MODULE_LICENSE("GPL");
1921
1922