2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
5 * Copyright (C) 2002 Aleph One Ltd.
6 * for Toby Churchill Ltd and Brightstar Engineering
8 * Created by Charles Manning <charles@aleph1.co.uk>
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.
14 * This is the file system front-end to YAFFS that hooks it up to
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.
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.
32 const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.37 2005-01-06 23:28:34 charles Exp $";
33 extern const char *yaffs_guts_c_version;
36 #include <linux/config.h>
37 #include <linux/kernel.h>
38 #include <linux/module.h>
39 #include <linux/version.h>
40 #include <linux/slab.h>
41 #include <linux/init.h>
42 #include <linux/list.h>
44 #include <linux/proc_fs.h>
45 #include <linux/pagemap.h>
46 #include <linux/mtd/mtd.h>
47 #include <linux/interrupt.h>
48 #include <linux/string.h>
51 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
53 #include <linux/statfs.h> /* Added NCB 15-8-2003 */
54 #include <asm/statfs.h>
55 #define UnlockPage(p) unlock_page(p)
56 #define Page_Uptodate(page) test_bit(PG_uptodate, &(page)->flags)
57 //#define kdevname(x) cdevname(to_kdev_t(x))
58 #define kdevname(x) "(unavailable)" // temporary fix
62 #include <linux/locks.h>
67 #include <asm/uaccess.h>
70 #include "yaffs_guts.h"
75 unsigned yaffs_traceMask = YAFFS_TRACE_ALWAYS | YAFFS_TRACE_BAD_BLOCKS;
77 #ifdef CONFIG_YAFFS_RAM_ENABLED
78 #include "yaffs_nandemul.h"
79 // 2 MB of RAM for emulation
80 #define YAFFS_RAM_EMULATION_SIZE 0x200000
81 #endif //CONFIG_YAFFS_RAM_ENABLED
83 #ifdef CONFIG_YAFFS_MTD_ENABLED
84 #include <linux/mtd/mtd.h>
85 #include "yaffs_mtdif.h"
86 #endif //CONFIG_YAFFS_MTD_ENABLED
88 //#define T(x) printk x
92 #define yaffs_InodeToObject(iptr) ((yaffs_Object *)((iptr)->u.generic_ip))
93 #define yaffs_DentryToObject(dptr) yaffs_InodeToObject((dptr)->d_inode)
94 //NCB #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->u.generic_sbp)
96 //#if defined(CONFIG_KERNEL_2_5)
97 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
98 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->s_fs_info)
100 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->u.generic_sbp)
104 static void yaffs_put_super(struct super_block *sb);
106 static ssize_t yaffs_file_read(struct file *f, char *buf, size_t n, loff_t *pos);
107 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, loff_t *pos);
108 static int yaffs_file_flush(struct file* file);
110 static int yaffs_sync_object(struct file * file, struct dentry *dentry, int datasync);
112 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir);
114 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
115 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
116 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *n);
117 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *n);
119 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode);
120 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry);
122 static int yaffs_link(struct dentry *old_dentry, struct inode * dir, struct dentry * dentry);
123 static int yaffs_unlink(struct inode * dir, struct dentry *dentry);
124 static int yaffs_symlink(struct inode * dir, struct dentry *dentry, const char * symname);
125 static int yaffs_mkdir(struct inode * dir, struct dentry * dentry, int mode);
127 //#if defined(CONFIG_KERNEL_2_5)
128 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
129 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
131 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev);
133 static int yaffs_rename(struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry);
134 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr);
136 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
137 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
138 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf);
140 static int yaffs_statfs(struct super_block *sb, struct statfs *buf);
142 static void yaffs_read_inode (struct inode *inode);
144 //#if defined(CONFIG_KERNEL_2_5)
145 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
146 static struct super_block *yaffs_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data);
148 static struct super_block *yaffs_read_super(struct super_block * sb, void * data, int silent);
151 static void yaffs_put_inode (struct inode *inode);
152 static void yaffs_delete_inode(struct inode *);
153 static void yaffs_clear_inode(struct inode *);
155 static int yaffs_readpage(struct file *file, struct page * page);
156 static int yaffs_writepage(struct page *page);
157 static int yaffs_prepare_write(struct file *f, struct page *pg, unsigned offset, unsigned to);
158 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, unsigned to);
160 static int yaffs_readlink(struct dentry *dentry, char *buffer, int buflen);
161 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd);
166 static struct address_space_operations yaffs_file_address_operations = {
167 readpage: yaffs_readpage,
168 writepage: yaffs_writepage,
169 prepare_write: yaffs_prepare_write,
170 commit_write: yaffs_commit_write
174 static struct file_operations yaffs_file_operations = {
175 #ifdef CONFIG_YAFFS_USE_GENERIC_RW
176 read: generic_file_read,
177 write: generic_file_write,
179 read: yaffs_file_read,
180 write: yaffs_file_write,
182 mmap: generic_file_mmap,
183 flush: yaffs_file_flush,
184 fsync: yaffs_sync_object,
186 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
187 sendfile: generic_file_sendfile,
192 static struct inode_operations yaffs_file_inode_operations = {
193 setattr: yaffs_setattr,
197 struct inode_operations yaffs_symlink_inode_operations =
199 readlink: yaffs_readlink,
200 follow_link: yaffs_follow_link,
201 setattr: yaffs_setattr
204 static struct inode_operations yaffs_dir_inode_operations = {
205 create: yaffs_create,
206 lookup: yaffs_lookup,
208 unlink: yaffs_unlink,
209 symlink: yaffs_symlink,
213 rename: yaffs_rename,
214 setattr: yaffs_setattr,
217 static struct file_operations yaffs_dir_operations = {
218 read: generic_read_dir,
219 readdir: yaffs_readdir,
220 fsync: yaffs_sync_object,
224 static struct super_operations yaffs_super_ops = {
225 statfs: yaffs_statfs,
226 read_inode: yaffs_read_inode,
227 put_inode: yaffs_put_inode,
228 put_super: yaffs_put_super,
230 delete_inode: yaffs_delete_inode,
231 clear_inode: yaffs_clear_inode,
236 static void yaffs_GrossLock(yaffs_Device *dev)
238 T(YAFFS_TRACE_OS,("yaffs locking\n"));
240 down(&dev->grossLock);
243 static void yaffs_GrossUnlock(yaffs_Device *dev)
245 T(YAFFS_TRACE_OS,("yaffs unlocking\n"));
250 static int yaffs_readlink(struct dentry *dentry, char *buffer, int buflen)
252 unsigned char *alias;
255 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
258 yaffs_GrossLock(dev);
260 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
262 yaffs_GrossUnlock(dev);
267 ret = vfs_readlink(dentry, buffer, buflen, alias);
272 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd)
274 unsigned char *alias;
276 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
279 yaffs_GrossLock(dev);
281 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
283 yaffs_GrossUnlock(dev);
288 ret = vfs_follow_link(nd,alias);
294 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,yaffs_Object *obj);
297 * Lookup is used to find objects in the fs
299 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
300 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
302 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *n)
304 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry)
308 struct inode *inode = NULL; // NCB 2.5/2.6 needs NULL here
310 yaffs_Device *dev = yaffs_InodeToObject(dir)->myDev;
313 yaffs_GrossLock(dev);
316 T(YAFFS_TRACE_OS,("yaffs_lookup for %d:%s\n",yaffs_InodeToObject(dir)->objectId,dentry->d_name.name));
318 obj = yaffs_FindObjectByName(yaffs_InodeToObject(dir),dentry->d_name.name);
320 obj = yaffs_GetEquivalentObject(obj); // in case it was a hardlink
326 T(YAFFS_TRACE_OS,("yaffs_lookup found %d\n",obj->objectId));
328 inode = yaffs_get_inode(dir->i_sb, obj->st_mode,0,obj);
332 T(YAFFS_TRACE_OS,("yaffs_loookup dentry \n"));
333 /* #if 0 asserted by NCB for 2.5/6 compatability - falls through to d_add even if NULL inode */
335 //dget(dentry); // try to solve directory bug
338 yaffs_GrossUnlock(dev);
348 T(YAFFS_TRACE_OS,("yaffs_lookup not found\n"));
351 yaffs_GrossUnlock(dev);
353 /* added NCB for 2.5/6 compatability - forces add even if inode is NULL which creates dentry hash*/
357 // return (ERR_PTR(-EIO));
361 // For now put inode is just for debugging
362 // Put inode is called when the inode **structure** is put.
363 static void yaffs_put_inode(struct inode *inode)
365 T(YAFFS_TRACE_OS,("yaffs_put_inode: ino %d, count %d nlink %d\n",
366 (int)inode->i_ino, atomic_read(&inode->i_count), inode->i_nlink));
370 // clear is called to tell the fs to release any per-inode data it holds
371 static void yaffs_clear_inode(struct inode *inode)
376 obj = yaffs_InodeToObject(inode);
378 T(YAFFS_TRACE_OS,("yaffs_clear_inode: ino %d, count %d %s\n",(int)inode->i_ino, atomic_read(&inode->i_count),
379 obj ? "object exists" : "null object"));
384 yaffs_GrossLock(dev);
386 // Clear the association between the inode ant the yaffs_Object.
388 inode->u.generic_ip = NULL;
390 // If the object freeing was deferred, then the real free happens now.
391 // This should fix the inode inconsistency problem.
393 yaffs_HandleDeferedFree(obj);
395 yaffs_GrossUnlock(dev);
401 // delete is called when the link count is zero and the inode
402 // is put (ie. nobody wants to know about it anymore, time to
404 // NB Must call clear_inode()
405 static void yaffs_delete_inode(struct inode *inode)
407 yaffs_Object *obj = yaffs_InodeToObject(inode);
410 T(YAFFS_TRACE_OS,("yaffs_delete_inode: ino %d, count %d %s\n",(int)inode->i_ino, atomic_read(&inode->i_count),
411 obj ? "object exists" : "null object"));
416 yaffs_GrossLock(dev);
417 yaffs_DeleteFile(obj);
418 yaffs_GrossUnlock(dev);
424 static int yaffs_file_flush(struct file* file)
426 yaffs_Object *obj = yaffs_DentryToObject(file->f_dentry);
428 yaffs_Device *dev = obj->myDev;
430 T(YAFFS_TRACE_OS,("yaffs_file_flush object %d (%s)\n",obj->objectId,
431 obj->dirty ? "dirty" : "clean"));
433 yaffs_GrossLock(dev);
435 yaffs_FlushFile(obj,1);
437 yaffs_GrossUnlock(dev);
444 static int yaffs_readpage_nolock(struct file *f, struct page * pg)
449 unsigned char *pg_buf;
454 T(YAFFS_TRACE_OS,("yaffs_readpage at %08x, size %08x\n",
455 (unsigned)(pg->index << PAGE_CACHE_SHIFT), (unsigned)PAGE_CACHE_SIZE));
457 obj = yaffs_DentryToObject(f->f_dentry);
466 /* FIXME: Can kmap fail? */
468 yaffs_GrossLock(dev);
470 ret = yaffs_ReadDataFromFile(obj, pg_buf, pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE);
472 yaffs_GrossUnlock(dev);
474 if(ret >= 0) ret = 0;
477 ClearPageUptodate(pg);
484 flush_dcache_page(pg);
488 T(YAFFS_TRACE_OS,("yaffs_readpage done\n"));
492 static int yaffs_readpage_unlock(struct file *f, struct page *pg)
494 int ret = yaffs_readpage_nolock(f,pg);
499 static int yaffs_readpage(struct file *f, struct page * pg)
501 return yaffs_readpage_unlock(f,pg);
504 // writepage inspired by/stolen from smbfs
507 static int yaffs_writepage(struct page *page)
509 struct address_space *mapping = page->mapping;
511 unsigned long end_index;
519 inode = mapping->host;
523 end_index = inode->i_size >> PAGE_CACHE_SHIFT;
526 if (page->index < end_index)
528 nBytes = PAGE_CACHE_SIZE;
532 nBytes = inode->i_size & (PAGE_CACHE_SIZE-1);
534 // What's happening here?
535 ///* OK, are we completely out? */
536 //if (page->index >= end_index+1 || !offset)
544 obj = yaffs_InodeToObject(inode);
545 yaffs_GrossLock(obj->myDev);
548 nWritten = yaffs_WriteDataToFile(obj,buffer,page->index << PAGE_CACHE_SHIFT,nBytes);
550 yaffs_GrossUnlock(obj->myDev);
553 SetPageUptodate(page);
557 return (nWritten == nBytes) ? 0 : -ENOSPC;
562 static int yaffs_prepare_write(struct file *f, struct page *pg, unsigned offset, unsigned to)
565 T(YAFFS_TRACE_OS,("yaffs_prepair_write\n"));
566 if(!Page_Uptodate(pg) && (offset || to < PAGE_CACHE_SIZE))
567 return yaffs_readpage_nolock(f,pg);
573 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, unsigned to)
576 void *addr = page_address(pg) + offset;
577 loff_t pos = (((loff_t)pg->index) << PAGE_CACHE_SHIFT) + offset;
578 int nBytes = to - offset;
582 unsigned saddr = (unsigned)addr;
584 T(YAFFS_TRACE_OS,("yaffs_commit_write addr %x pos %x nBytes %d\n",saddr,spos,nBytes));
586 nWritten = yaffs_file_write(f,addr, nBytes, &pos);
588 if(nWritten != nBytes)
590 T(YAFFS_TRACE_OS,("yaffs_commit_write not same size nWritten %d nBytes %d\n",nWritten,nBytes));
592 ClearPageUptodate(pg);
599 T(YAFFS_TRACE_OS,("yaffs_commit_write returning %d\n",nWritten));
607 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object *obj)
611 inode->i_ino = obj->objectId;
612 inode->i_mode = obj->st_mode;
613 inode->i_uid = obj->st_uid;
614 inode->i_gid = obj->st_gid;
615 inode->i_blksize = inode->i_sb->s_blocksize;
616 //#if defined(CONFIG_KERNEL_2_5)
617 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
619 inode->i_rdev = old_decode_dev(obj->st_rdev);
620 inode->i_atime.tv_sec = (time_t)(obj->st_atime);
621 inode->i_atime.tv_nsec = 0;
622 inode->i_mtime.tv_sec = (time_t)obj->st_mtime;
623 inode->i_mtime.tv_nsec =0;
624 inode->i_ctime.tv_sec = (time_t)obj->st_ctime;
625 inode->i_ctime.tv_nsec = 0;
627 inode->i_rdev = obj->st_rdev;
628 inode->i_atime = obj->st_atime;
629 inode->i_mtime = obj->st_mtime;
630 inode->i_ctime = obj->st_ctime;
632 inode->i_size = yaffs_GetObjectFileLength(obj);
633 inode->i_blocks = (inode->i_size + 511) >> 9;
635 inode->i_nlink = yaffs_GetObjectLinkCount(obj);
637 T(YAFFS_TRACE_OS,("yaffs_FillInode mode %x uid %d gid %d size %d count %d\n",
638 inode->i_mode, inode->i_uid, inode->i_gid, (int)inode->i_size, atomic_read(&inode->i_count)));
640 switch (obj->st_mode & S_IFMT)
642 default: // fifo, device or socket
643 init_special_inode(inode, obj->st_mode,(dev_t)(obj->st_rdev));
645 case S_IFREG: // file
646 inode->i_op = &yaffs_file_inode_operations;
647 inode->i_fop = &yaffs_file_operations;
648 inode->i_mapping->a_ops = &yaffs_file_address_operations;
650 case S_IFDIR: // directory
651 inode->i_op = &yaffs_dir_inode_operations;
652 inode->i_fop = &yaffs_dir_operations;
654 case S_IFLNK: // symlink
655 inode->i_op = &yaffs_symlink_inode_operations;
660 inode->u.generic_ip = obj;
661 obj->myInode = inode;
666 T(YAFFS_TRACE_OS,("yaffs_FileInode invalid parameters\n"));
671 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,yaffs_Object *obj)
673 struct inode * inode;
675 T(YAFFS_TRACE_OS,("yaffs_get_inode for object %d\n",obj->objectId));
677 inode = iget(sb,obj->objectId);
679 // NB Side effect: iget calls back to yaffs_read_inode().
680 // iget also increments the inode's i_count
685 static ssize_t yaffs_file_read(struct file *f, char *buf, size_t n, loff_t *pos)
692 T(YAFFS_TRACE_OS,("yaffs_file_read\n"));
694 obj = yaffs_DentryToObject(f->f_dentry);
698 yaffs_GrossLock(dev);
700 inode = f->f_dentry->d_inode;
702 if (*pos < inode->i_size)
704 if (*pos + n > inode->i_size)
706 n = inode->i_size - *pos;
714 nRead = yaffs_ReadDataFromFile(obj,buf,*pos,n);
720 yaffs_GrossUnlock(dev);
724 T(YAFFS_TRACE_OS,("yaffs_file_read read %d bytes, %d read at %d\n",n,nRead,ipos));
730 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, loff_t *pos)
738 obj = yaffs_DentryToObject(f->f_dentry);
742 yaffs_GrossLock(dev);
744 inode = f->f_dentry->d_inode;
746 if(!S_ISBLK(inode->i_mode) && f->f_flags & O_APPEND)
748 ipos = inode->i_size;
758 T(YAFFS_TRACE_OS,("yaffs_file_write: hey obj is null!\n"));
762 T(YAFFS_TRACE_OS,("yaffs_file_write about to write writing %d bytes to object %d at %d\n",n,obj->objectId,ipos));
765 nWritten = yaffs_WriteDataToFile(obj,buf,ipos,n);
767 T(YAFFS_TRACE_OS,("yaffs_file_write writing %d bytes, %d written at %d\n",n,nWritten,ipos));
772 if(ipos > inode->i_size)
774 inode->i_size = ipos;
775 inode->i_blocks = (ipos + 511)>>9;
777 T(YAFFS_TRACE_OS,("yaffs_file_write size updated to %d bytes, %d blocks\n",ipos,(int)(inode->i_blocks)));
781 yaffs_GrossUnlock(dev);
783 return nWritten != n ? -ENOSPC : nWritten;
787 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
791 struct inode *inode = f->f_dentry->d_inode;
792 unsigned long offset, curoffs;
796 char name[YAFFS_MAX_NAME_LENGTH +1];
798 obj = yaffs_DentryToObject(f->f_dentry);
801 yaffs_GrossLock(dev);
805 T(YAFFS_TRACE_OS,("yaffs_readdir: starting at %d\n",(int)offset));
809 T(YAFFS_TRACE_OS,("yaffs_readdir: entry . ino %d \n",(int)inode->i_ino));
810 if(filldir(dirent,".",1,offset,inode->i_ino,DT_DIR) < 0)
819 T(YAFFS_TRACE_OS,("yaffs_readdir: entry .. ino %d \n",(int)f->f_dentry->d_parent->d_inode->i_ino));
820 if(filldir(dirent,"..",2,offset,f->f_dentry->d_parent->d_inode->i_ino,DT_DIR) < 0)
830 list_for_each(i,&obj->variant.directoryVariant.children)
833 if(curoffs >= offset)
835 l = list_entry(i, yaffs_Object,siblings);
837 yaffs_GetObjectName(l,name,YAFFS_MAX_NAME_LENGTH+1);
838 T(YAFFS_TRACE_OS,("yaffs_readdir: %s inode %d\n",name,yaffs_GetObjectInode(l)));
844 yaffs_GetObjectInode(l),
845 yaffs_GetObjectType(l))
859 yaffs_GrossUnlock(dev);
866 * File creation. Allocate an inode, and we're done..
868 //#if defined(CONFIG_KERNEL_2_5)
869 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
870 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
872 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev)
877 yaffs_Object *obj = NULL;
880 yaffs_Object *parent = yaffs_InodeToObject(dir);
886 T(YAFFS_TRACE_OS,("yaffs_mknod: parent object %d type %d\n",
887 parent->objectId,parent->variantType));
891 T(YAFFS_TRACE_OS,("yaffs_mknod: could not get parent object\n"));
895 T(YAFFS_TRACE_OS,("yaffs_mknod: making oject for %s, mode %x dev %x\n",
896 dentry->d_name.name, mode,rdev));
900 yaffs_GrossLock(dev);
902 switch (mode & S_IFMT)
905 // Special (socket, fifo, device...)
906 T(YAFFS_TRACE_OS,("yaffs_mknod: making special\n"));
907 obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,rdev);
909 case S_IFREG: // file
910 T(YAFFS_TRACE_OS,("yaffs_mknod: making file\n"));
911 obj = yaffs_MknodFile(parent,dentry->d_name.name,mode,current->uid, current->gid);
913 case S_IFDIR: // directory
914 T(YAFFS_TRACE_OS,("yaffs_mknod: making directory\n"));
915 obj = yaffs_MknodDirectory(parent,dentry->d_name.name,mode,current->uid, current->gid);
917 case S_IFLNK: // symlink
918 T(YAFFS_TRACE_OS,("yaffs_mknod: making file\n"));
919 obj = NULL; // Do we ever get here?
925 inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj);
926 d_instantiate(dentry, inode);
927 T(YAFFS_TRACE_OS,("yaffs_mknod created object %d count = %d\n",obj->objectId,atomic_read(&inode->i_count)));
932 T(YAFFS_TRACE_OS,("yaffs_mknod failed making object\n"));
936 yaffs_GrossUnlock(dev);
941 static int yaffs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
944 T(YAFFS_TRACE_OS,("yaffs_mkdir\n"));
945 retVal = yaffs_mknod(dir, dentry, mode | S_IFDIR, 0);
947 // attempt to fix dir bug - didn't work
956 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
957 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
958 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *n)
960 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode)
963 T(YAFFS_TRACE_OS,("yaffs_create\n"));
964 return yaffs_mknod(dir, dentry, mode | S_IFREG, 0);
968 static int yaffs_unlink(struct inode * dir, struct dentry *dentry)
975 T(YAFFS_TRACE_OS,("yaffs_unlink %d:%s\n",(int)(dir->i_ino),dentry->d_name.name));
977 dev = yaffs_InodeToObject(dir)->myDev;
979 yaffs_GrossLock(dev);
982 retVal = yaffs_Unlink(yaffs_InodeToObject(dir),dentry->d_name.name);
985 yaffs_GrossUnlock(dev);
987 if( retVal == YAFFS_OK)
989 dentry->d_inode->i_nlink--;
990 mark_inode_dirty(dentry->d_inode);
1003 static int yaffs_link(struct dentry *old_dentry, struct inode * dir, struct dentry * dentry)
1005 struct inode *inode = old_dentry->d_inode;
1006 yaffs_Object *obj = NULL;
1007 yaffs_Object *link=NULL;
1010 T(YAFFS_TRACE_OS,("yaffs_link\n"));
1012 obj = yaffs_InodeToObject(inode);
1015 yaffs_GrossLock(dev);
1017 if (!S_ISDIR(inode->i_mode)) // Don't link directories
1019 link = yaffs_Link(yaffs_InodeToObject(dir),dentry->d_name.name,obj);
1025 old_dentry->d_inode->i_nlink = yaffs_GetObjectLinkCount(obj);
1026 d_instantiate(dentry, old_dentry->d_inode);
1027 atomic_inc(&old_dentry->d_inode->i_count);
1028 T(YAFFS_TRACE_OS,("yaffs_link link count %d i_count %d\n",
1029 old_dentry->d_inode->i_nlink,atomic_read(&old_dentry->d_inode->i_count)));
1033 yaffs_GrossUnlock(dev);
1047 static int yaffs_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
1052 T(YAFFS_TRACE_OS,("yaffs_symlink\n"));
1054 dev = yaffs_InodeToObject(dir)->myDev;
1055 yaffs_GrossLock(dev);
1056 obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name,
1057 S_IFLNK | S_IRWXUGO, current->uid, current->gid,
1059 yaffs_GrossUnlock(dev);
1064 struct inode* inode;
1066 inode = yaffs_get_inode(dir->i_sb, obj->st_mode, 0, obj);
1067 d_instantiate(dentry, inode);
1068 T(YAFFS_TRACE_OS,("symlink created OK\n"));
1073 T(YAFFS_TRACE_OS,("symlink not created\n"));
1080 static int yaffs_sync_object(struct file * file, struct dentry *dentry, int datasync)
1086 obj = yaffs_DentryToObject(dentry);
1090 T(YAFFS_TRACE_OS,("yaffs_sync_object\n"));
1091 yaffs_GrossLock(dev);
1092 yaffs_FlushFile(obj,1);
1093 yaffs_GrossUnlock(dev);
1098 * The VFS layer already does all the dentry stuff for rename.
1100 * NB: POSIX says you can rename an object over an old object of the same name
1102 static int yaffs_rename(struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry)
1105 int retVal = YAFFS_FAIL;
1107 yaffs_Object *target;
1109 dev = yaffs_InodeToObject(old_dir)->myDev;
1111 yaffs_GrossLock(dev);
1113 // Check if the target is an existing directory that is not empty.
1114 target = yaffs_FindObjectByName(yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
1117 target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
1118 !list_empty(&target->variant.directoryVariant.children))
1120 retVal = YAFFS_FAIL;
1125 // Unlink the target if it exists
1126 removed = yaffs_Unlink(yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
1129 retVal = yaffs_RenameObject(yaffs_InodeToObject(old_dir),old_dentry->d_name.name,
1130 yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
1133 yaffs_GrossUnlock(dev);
1135 if(retVal == YAFFS_OK)
1137 if(removed == YAFFS_OK)
1139 new_dentry->d_inode->i_nlink--;
1140 mark_inode_dirty(new_dentry->d_inode);
1153 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr)
1155 struct inode *inode = dentry->d_inode;
1159 T(YAFFS_TRACE_OS,("yaffs_setattr of object %d\n",yaffs_InodeToObject(inode)->objectId));
1161 if((error = inode_change_ok(inode,attr)) == 0)
1164 dev = yaffs_InodeToObject(inode)->myDev;
1165 yaffs_GrossLock(dev);
1166 if(yaffs_SetAttributes(yaffs_InodeToObject(inode),attr) == YAFFS_OK)
1174 yaffs_GrossUnlock(dev);
1175 inode_setattr(inode,attr);
1180 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
1181 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1182 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf)
1184 static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
1187 yaffs_Device *dev = yaffs_SuperToDevice(sb);
1188 T(YAFFS_TRACE_OS,("yaffs_statfs\n"));
1190 yaffs_GrossLock(dev);
1192 buf->f_type = YAFFS_MAGIC;
1193 buf->f_bsize = sb->s_blocksize;
1194 buf->f_namelen = 255;
1195 buf->f_blocks = (dev->endBlock - dev->startBlock + 1) * YAFFS_CHUNKS_PER_BLOCK/
1196 (sb->s_blocksize/YAFFS_BYTES_PER_CHUNK);
1199 buf->f_bfree = yaffs_GetNumberOfFreeChunks(dev)/
1200 (sb->s_blocksize/YAFFS_BYTES_PER_CHUNK);
1201 buf->f_bavail = buf->f_bfree;
1203 yaffs_GrossUnlock(dev);
1207 static void yaffs_read_inode (struct inode *inode)
1209 // NB This is called as a side effect of other functions and
1210 // thus gross locking should always be in place already.
1213 yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb);
1215 T(YAFFS_TRACE_OS,("yaffs_read_inode for %d\n",(int)inode->i_ino));
1217 obj = yaffs_FindObjectByNumber(dev,inode->i_ino);
1219 yaffs_FillInodeFromObject(inode,obj);
1225 static yaffs_Device *yaffs_dev;
1226 static yaffs_Device *yaffsram_dev;
1230 static void yaffs_put_super(struct super_block *sb)
1232 yaffs_Device *dev = yaffs_SuperToDevice(sb);
1234 yaffs_GrossLock(dev);
1235 if(dev->putSuperFunc)
1237 dev->putSuperFunc(sb);
1239 yaffs_Deinitialise(dev);
1240 yaffs_GrossUnlock(dev);
1242 if(dev == yaffs_dev) yaffs_dev = NULL;
1243 if(dev == yaffsram_dev) yaffsram_dev = NULL;
1249 #ifdef CONFIG_YAFFS_MTD_ENABLED
1251 static void yaffs_MTDPutSuper(struct super_block *sb)
1254 struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
1261 put_mtd_device(mtd);
1267 static struct super_block *yaffs_internal_read_super(int useRam, struct super_block * sb, void * data, int silent)
1270 struct inode * inode;
1271 struct dentry * root;
1274 sb->s_magic = YAFFS_MAGIC;
1275 sb->s_op = &yaffs_super_ops;
1278 T(YAFFS_TRACE_OS,("yaffs: sb is NULL\n"));
1280 T(YAFFS_TRACE_OS,("yaffs: sb->s_dev is NULL\n"));
1281 else if(! kdevname(sb->s_dev))
1282 T(YAFFS_TRACE_OS,("yaffs: kdevname is NULL\n"));
1284 T(YAFFS_TRACE_OS,("yaffs: dev is %d name is \"%s\"\n", sb->s_dev, kdevname(sb->s_dev)));
1288 #ifdef CONFIG_YAFFS_USE_CHUNK_SIZE
1289 sb->s_blocksize = YAFFS_BYTES_PER_CHUNK;
1290 sb->s_blocksize_bits = YAFFS_CHUNK_SIZE_SHIFT;
1292 sb->s_blocksize = PAGE_CACHE_SIZE;
1293 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
1295 T(YAFFS_TRACE_OS,("yaffs_read_super: %s block size %d\n", useRam ? "RAM" : "MTD",(int)(sb->s_blocksize)));
1297 #ifdef CONFIG_YAFFS_DISABLE_WRITE_VERIFY
1298 T(YAFFS_TRACE_OS,("yaffs: Write verification disabled. All guarantees null and void\n"));
1306 #ifdef CONFIG_YAFFS_RAM_ENABLED
1307 // Set the yaffs_Device up for ram emulation
1309 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
1312 // Deep shit could not allocate device structure
1313 T(YAFFS_TRACE_OS,("yaffs_read_super: Failed trying to allocate yaffs_Device. Terminating debug.\n"));
1317 memset(dev,0,sizeof(yaffs_Device));
1318 dev->genericDevice = NULL; // Not used for RAM emulation.
1320 nBlocks = YAFFS_RAM_EMULATION_SIZE / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
1321 dev->startBlock = 1; // Don't use block 0
1322 dev->endBlock = nBlocks - 1;
1323 dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
1324 dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
1325 dev->nReservedBlocks = 5;
1327 dev->writeChunkToNAND = nandemul_WriteChunkToNAND;
1328 dev->readChunkFromNAND = nandemul_ReadChunkFromNAND;
1329 dev->eraseBlockInNAND = nandemul_EraseBlockInNAND;
1330 dev->initialiseNAND = nandemul_InitialiseNAND;
1339 #ifdef CONFIG_YAFFS_MTD_ENABLED
1340 struct mtd_info *mtd;
1342 T(YAFFS_TRACE_ALWAYS,( "yaffs: Attempting MTD mount on %u.%u, \"%s\"\n",
1343 MAJOR(sb->s_dev),MINOR(sb->s_dev),kdevname(sb->s_dev)));
1345 // Check it's an mtd device.....
1346 if(MAJOR(sb->s_dev) != MTD_BLOCK_MAJOR)
1348 return NULL; // This isn't an mtd device
1352 mtd = get_mtd_device(NULL, MINOR(sb->s_dev));
1355 T(YAFFS_TRACE_ALWAYS,( "yaffs: MTD device #%u doesn't appear to exist\n", MINOR(sb->s_dev)));
1360 if(mtd->type != MTD_NANDFLASH)
1362 T(YAFFS_TRACE_ALWAYS,( "yaffs: MTD device is not NAND it's type %d\n", mtd->type));
1366 //T(YAFFS_TRACE_OS,(KERN_DEBUG" erase %x\n",mtd->erase);
1367 //T(YAFFS_TRACE_OS,(KERN_DEBUG" read %x\n",mtd->read);
1368 //T(YAFFS_TRACE_OS,(KERN_DEBUG" write %x\n",mtd->write);
1369 //T(YAFFS_TRACE_OS,(KERN_DEBUG" readoob %x\n",mtd->read_oob);
1370 //T(YAFFS_TRACE_OS,(KERN_DEBUG" writeoob %x\n",mtd->write_oob);
1371 //T(YAFFS_TRACE_OS,(KERN_DEBUG" oobblock %x\n",mtd->oobblock);
1372 //T(YAFFS_TRACE_OS,(KERN_DEBUG" oobsize %x\n",mtd->oobsize);
1378 #ifndef CONFIG_YAFFS_USE_OLD_MTD
1385 T(YAFFS_TRACE_ALWAYS,( "yaffs: MTD device does not support required functions\n"));
1389 if(mtd->oobblock != YAFFS_BYTES_PER_CHUNK ||
1390 mtd->oobsize != YAFFS_BYTES_PER_SPARE)
1392 T(YAFFS_TRACE_ALWAYS,( "yaffs: MTD device does not support have the right page sizes\n"));
1397 // OK, so if we got here, we have an MTD that's NAND and looks
1398 // like it has the right capabilities
1399 // Set the yaffs_Device up for ram emulation
1401 //#if defined(CONFIG_KERNEL_2_5)
1402 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1403 sb->s_fs_info = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
1405 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
1409 // Deep shit could not allocate device structure
1410 T(YAFFS_TRACE_ALWAYS,("yaffs_read_super: Failed trying to allocate yaffs_Device. Terminating debug.\n"));
1414 memset(dev,0,sizeof(yaffs_Device));
1415 dev->genericDevice = mtd;
1417 // Set up the memory size parameters....
1419 nBlocks = mtd->size / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
1420 dev->startBlock = 1; // Don't use block 0
1421 dev->endBlock = nBlocks - 1;
1422 dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
1423 dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
1424 dev->nReservedBlocks = 5;
1425 dev->nShortOpCaches = 10; // Enable short op caching
1428 // ... and the functions.
1429 dev->writeChunkToNAND = nandmtd_WriteChunkToNAND;
1430 dev->readChunkFromNAND = nandmtd_ReadChunkFromNAND;
1431 dev->eraseBlockInNAND = nandmtd_EraseBlockInNAND;
1432 dev->initialiseNAND = nandmtd_InitialiseNAND;
1434 dev->putSuperFunc = yaffs_MTDPutSuper;
1436 #ifdef CONFIG_YAFFS_USE_NANDECC
1437 dev->useNANDECC = 1;
1445 init_MUTEX(&dev->grossLock);
1448 yaffs_GrossLock(dev);
1449 yaffs_GutsInitialise(yaffs_SuperToDevice(sb));
1451 T(YAFFS_TRACE_OS,("yaffs_read_super: guts initialised\n"));
1453 // Create root inode
1454 inode = yaffs_get_inode(sb, S_IFDIR | 0755, 0,yaffs_Root(yaffs_SuperToDevice(sb)));
1456 yaffs_GrossUnlock(dev);
1462 inode->i_op = & yaffs_dir_inode_operations;
1463 inode->i_fop = & yaffs_dir_operations;
1465 T(YAFFS_TRACE_OS,("yaffs_read_super: got root inode\n"));
1468 root = d_alloc_root(inode);
1470 T(YAFFS_TRACE_OS,("yaffs_read_super: d_alloc_root done\n"));
1478 T(YAFFS_TRACE_OS,("yaffs_read_super: done\n"));
1482 static int yaffs_internal_read_super_ram(struct super_block * sb, void * data, int silent)
1484 return yaffs_internal_read_super(1,sb,data,silent) ? 0 : -1;
1486 static int yaffs_internal_read_super_mtd(struct super_block * sb, void * data, int silent)
1488 return yaffs_internal_read_super(0,sb,data,silent) ? 0 : -1;
1492 #ifdef CONFIG_YAFFS_MTD_ENABLED
1493 //#if defined(CONFIG_KERNEL_2_5)
1494 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1495 static struct super_block *yaffs_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data)
1498 return get_sb_bdev(fs, flags, dev_name, data, yaffs_internal_read_super_mtd);
1501 /* changes NCB 2.5.70 */
1502 //static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
1503 static struct file_system_type yaffs_fs_type = {
1504 .owner = THIS_MODULE,
1506 .get_sb = yaffs_read_super,
1507 .kill_sb = kill_block_super,
1508 // .kill_sb = kill_litter_super,
1509 .fs_flags = FS_REQUIRES_DEV,
1512 static struct super_block *yaffs_read_super(struct super_block * sb, void * data, int silent)
1514 return yaffs_internal_read_super(0,sb,data,silent);
1517 static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
1521 #ifdef CONFIG_YAFFS_RAM_ENABLED
1523 //#if defined(CONFIG_KERNEL_2_5)
1524 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1525 static struct super_block *yaffs_ram_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data)
1528 return get_sb_bdev(fs, flags, dev_name, data, yaffs_internal_read_super_ram);
1531 /* changes NCB 2.5.70 */
1532 //static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
1533 static struct file_system_type yaffs_fs_type = {
1534 .owner = THIS_MODULE,
1536 .get_sb = yaffs_ram_read_super,
1537 .kill_sb = kill_block_super,
1538 // .kill_sb = kill_litter_super,
1539 .fs_flags = FS_SINGLE,
1542 static struct super_block *yaffs_ram_read_super(struct super_block * sb, void * data, int silent)
1544 return yaffs_internal_read_super(1,sb,data,silent);
1547 static DECLARE_FSTYPE(yaffs_ram_fs_type, "yaffsram", yaffs_ram_read_super, FS_SINGLE);
1549 #endif // CONFIG_YAFFS_RAM_ENABLED
1552 static struct proc_dir_entry *my_proc_entry;
1553 static struct proc_dir_entry *my_proc_ram_write_entry;
1555 static char * yaffs_dump_dev(char *buf,yaffs_Device *dev,char *name)
1557 buf +=sprintf(buf,"\nDevice %s\n",name);
1558 buf +=sprintf(buf,"startBlock......... %d\n",dev->startBlock);
1559 buf +=sprintf(buf,"endBlock........... %d\n",dev->endBlock);
1560 buf +=sprintf(buf,"chunkGroupBits..... %d\n",dev->chunkGroupBits);
1561 buf +=sprintf(buf,"chunkGroupSize..... %d\n",dev->chunkGroupSize);
1562 buf +=sprintf(buf,"nErasedBlocks...... %d\n",dev->nErasedBlocks);
1563 buf +=sprintf(buf,"nTnodesCreated..... %d\n",dev->nTnodesCreated);
1564 buf +=sprintf(buf,"nFreeTnodes........ %d\n",dev->nFreeTnodes);
1565 buf +=sprintf(buf,"nObjectsCreated.... %d\n",dev->nObjectsCreated);
1566 buf +=sprintf(buf,"nFreeObjects....... %d\n",dev->nFreeObjects);
1567 buf +=sprintf(buf,"nFreeChunks........ %d\n",dev->nFreeChunks);
1568 buf +=sprintf(buf,"nPageWrites........ %d\n",dev->nPageWrites);
1569 buf +=sprintf(buf,"nPageReads......... %d\n",dev->nPageReads);
1570 buf +=sprintf(buf,"nBlockErasures..... %d\n",dev->nBlockErasures);
1571 buf +=sprintf(buf,"nGCCopies.......... %d\n",dev->nGCCopies);
1572 buf +=sprintf(buf,"garbageCollections. %d\n",dev->garbageCollections);
1573 buf +=sprintf(buf,"passiveGCs......... %d\n",dev->passiveGarbageCollections);
1574 buf +=sprintf(buf,"nRetriedWrites..... %d\n",dev->nRetriedWrites);
1575 buf +=sprintf(buf,"nRetireBlocks...... %d\n",dev->nRetiredBlocks);
1576 buf +=sprintf(buf,"eccFixed........... %d\n",dev->eccFixed);
1577 buf +=sprintf(buf,"eccUnfixed......... %d\n",dev->eccUnfixed);
1578 buf +=sprintf(buf,"tagsEccFixed....... %d\n",dev->tagsEccFixed);
1579 buf +=sprintf(buf,"tagsEccUnfixed..... %d\n",dev->tagsEccUnfixed);
1580 buf +=sprintf(buf,"cacheHits.......... %d\n",dev->cacheHits);
1581 buf +=sprintf(buf,"nDeletedFiles...... %d\n",dev->nDeletedFiles);
1582 buf +=sprintf(buf,"nUnlinkedFiles..... %d\n",dev->nUnlinkedFiles);
1583 buf +=sprintf(buf,"nBackgroudDeletions %d\n",dev->nBackgroundDeletions);
1584 buf +=sprintf(buf,"useNANDECC......... %d\n",dev->useNANDECC);
1590 static int yaffs_proc_read(
1600 char my_buffer[3000];
1604 if (offset > 0) return 0;
1606 /* Fill the buffer and get its length */
1607 buf +=sprintf(buf,"YAFFS built:"__DATE__ " "__TIME__"\n%s\n%s\n", yaffs_fs_c_version,yaffs_guts_c_version);
1609 if(yaffs_dev) buf = yaffs_dump_dev(buf,yaffs_dev,"yaffs");
1610 if(yaffsram_dev) buf = yaffs_dump_dev(buf,yaffsram_dev,"yaffsram");
1613 strcpy(page,my_buffer);
1614 return strlen(my_buffer);
1618 static int yaffs_proc_ram_write(
1628 T(YAFFS_TRACE_OS,( "yaffs write size %d\n",count));
1632 static int __init init_yaffs_fs(void)
1636 yaffs_dev = yaffsram_dev = NULL;
1638 T(YAFFS_TRACE_OS,( "yaffs " __DATE__ " " __TIME__ " Initialisation\n"));
1639 #ifdef CONFIG_YAFFS_USE_GENERIC_RW
1640 T(YAFFS_TRACE_OS,( "yaffs is using generic read/write (caching)\n"));
1642 T(YAFFS_TRACE_OS,( "yaffs is using direct read/write (uncached)\n"));
1646 /* Install the proc_fs entry */
1647 my_proc_entry = create_proc_read_entry("yaffs",
1657 #ifdef CONFIG_YAFFS_RAM_ENABLED
1659 my_proc_ram_write_entry = create_proc_entry("yaffs_ram",
1663 if(!my_proc_ram_write_entry)
1669 my_proc_ram_write_entry->write_proc = yaffs_proc_ram_write;
1673 error = register_filesystem(&yaffs_ram_fs_type);
1678 #endif //CONFIG_YAFFS_RAM_ENABLED
1680 #ifdef CONFIG_YAFFS_MTD_ENABLED
1681 error = register_filesystem(&yaffs_fs_type);
1684 #ifdef CONFIG_YAFFS_RAM_ENABLED
1685 unregister_filesystem(&yaffs_ram_fs_type);
1686 #endif //CONFIG_YAFFS_RAM_ENABLED
1688 #endif // CONFIG_YAFFS_MTD_ENABLED
1693 static void __exit exit_yaffs_fs(void)
1695 T(YAFFS_TRACE_OS,( "yaffs " __DATE__ " " __TIME__ " Clean up\n"));
1697 remove_proc_entry("yaffs",&proc_root);
1699 #ifdef CONFIG_YAFFS_RAM_ENABLED
1700 unregister_filesystem(&yaffs_ram_fs_type);
1702 #ifdef CONFIG_YAFFS_MTD_ENABLED
1703 unregister_filesystem(&yaffs_fs_type);
1708 module_init(init_yaffs_fs)
1709 module_exit(exit_yaffs_fs)
1711 MODULE_DESCRIPTION("YAFFS - a NAND specific flash file system");
1712 MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002");
1713 MODULE_LICENSE("GPL");