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 * * Some code bodily lifted from JFFS2.
31 const char *yaffs_fs_c_version = "$Id: yaffs_fs.c,v 1.34 2004-09-20 22:00:20 charles Exp $";
32 extern const char *yaffs_guts_c_version;
35 #include <linux/config.h>
36 #include <linux/kernel.h>
37 #include <linux/module.h>
38 #include <linux/version.h>
39 #include <linux/slab.h>
40 #include <linux/init.h>
41 #include <linux/list.h>
43 #include <linux/proc_fs.h>
44 #include <linux/pagemap.h>
45 #include <linux/mtd/mtd.h>
46 #include <linux/interrupt.h>
47 #include <linux/string.h>
50 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
52 #include <linux/statfs.h> /* Added NCB 15-8-2003 */
53 #include <asm/statfs.h>
54 #define UnlockPage(p) unlock_page(p)
55 #define Page_Uptodate(page) test_bit(PG_uptodate, &(page)->flags)
56 //#define kdevname(x) cdevname(to_kdev_t(x))
57 #define kdevname(x) "(unavailable)" // temporary fix
61 #include <linux/locks.h>
66 #include <asm/uaccess.h>
69 #include "yaffs_guts.h"
74 unsigned yaffs_traceMask = YAFFS_TRACE_ALWAYS | YAFFS_TRACE_BAD_BLOCKS;
76 #ifdef CONFIG_YAFFS_RAM_ENABLED
77 #include "yaffs_nandemul.h"
78 // 2 MB of RAM for emulation
79 #define YAFFS_RAM_EMULATION_SIZE 0x200000
80 #endif //CONFIG_YAFFS_RAM_ENABLED
82 #ifdef CONFIG_YAFFS_MTD_ENABLED
83 #include <linux/mtd/mtd.h>
84 #include "yaffs_mtdif.h"
85 #endif //CONFIG_YAFFS_MTD_ENABLED
87 //#define T(x) printk x
91 #define yaffs_InodeToObject(iptr) ((yaffs_Object *)((iptr)->u.generic_ip))
92 #define yaffs_DentryToObject(dptr) yaffs_InodeToObject((dptr)->d_inode)
93 //NCB #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->u.generic_sbp)
95 //#if defined(CONFIG_KERNEL_2_5)
96 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
97 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->s_fs_info)
99 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->u.generic_sbp)
103 static void yaffs_put_super(struct super_block *sb);
105 static ssize_t yaffs_file_read(struct file *f, char *buf, size_t n, loff_t *pos);
106 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, loff_t *pos);
107 static int yaffs_file_flush(struct file* file);
109 static int yaffs_sync_object(struct file * file, struct dentry *dentry, int datasync);
111 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir);
113 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
114 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
115 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *n);
116 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *n);
118 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode);
119 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry);
121 static int yaffs_link(struct dentry *old_dentry, struct inode * dir, struct dentry * dentry);
122 static int yaffs_unlink(struct inode * dir, struct dentry *dentry);
123 static int yaffs_symlink(struct inode * dir, struct dentry *dentry, const char * symname);
124 static int yaffs_mkdir(struct inode * dir, struct dentry * dentry, int mode);
126 //#if defined(CONFIG_KERNEL_2_5)
127 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
128 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
130 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev);
132 static int yaffs_rename(struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry);
133 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr);
135 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
136 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
137 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf);
139 static int yaffs_statfs(struct super_block *sb, struct statfs *buf);
141 static void yaffs_read_inode (struct inode *inode);
143 //#if defined(CONFIG_KERNEL_2_5)
144 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
145 static struct super_block *yaffs_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data);
147 static struct super_block *yaffs_read_super(struct super_block * sb, void * data, int silent);
150 static void yaffs_put_inode (struct inode *inode);
151 static void yaffs_delete_inode(struct inode *);
152 static void yaffs_clear_inode(struct inode *);
154 static int yaffs_readpage(struct file *file, struct page * page);
155 static int yaffs_writepage(struct page *page);
156 static int yaffs_prepare_write(struct file *f, struct page *pg, unsigned offset, unsigned to);
157 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, unsigned to);
159 static int yaffs_readlink(struct dentry *dentry, char *buffer, int buflen);
160 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd);
165 static struct address_space_operations yaffs_file_address_operations = {
166 readpage: yaffs_readpage,
167 writepage: yaffs_writepage,
168 prepare_write: yaffs_prepare_write,
169 commit_write: yaffs_commit_write
173 static struct file_operations yaffs_file_operations = {
174 #ifdef CONFIG_YAFFS_USE_GENERIC_RW
175 read: generic_file_read,
176 write: generic_file_write,
178 read: yaffs_file_read,
179 write: yaffs_file_write,
181 mmap: generic_file_mmap,
182 flush: yaffs_file_flush,
183 fsync: yaffs_sync_object,
187 static struct inode_operations yaffs_file_inode_operations = {
188 setattr: yaffs_setattr,
192 struct inode_operations yaffs_symlink_inode_operations =
194 readlink: yaffs_readlink,
195 follow_link: yaffs_follow_link,
196 setattr: yaffs_setattr
199 static struct inode_operations yaffs_dir_inode_operations = {
200 create: yaffs_create,
201 lookup: yaffs_lookup,
203 unlink: yaffs_unlink,
204 symlink: yaffs_symlink,
208 rename: yaffs_rename,
209 setattr: yaffs_setattr,
212 static struct file_operations yaffs_dir_operations = {
213 read: generic_read_dir,
214 readdir: yaffs_readdir,
215 fsync: yaffs_sync_object,
219 static struct super_operations yaffs_super_ops = {
220 statfs: yaffs_statfs,
221 read_inode: yaffs_read_inode,
222 put_inode: yaffs_put_inode,
223 put_super: yaffs_put_super,
225 delete_inode: yaffs_delete_inode,
226 clear_inode: yaffs_clear_inode,
231 static void yaffs_GrossLock(yaffs_Device *dev)
233 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs locking\n"));
235 down(&dev->grossLock);
238 static void yaffs_GrossUnlock(yaffs_Device *dev)
240 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs unlocking\n"));
245 static int yaffs_readlink(struct dentry *dentry, char *buffer, int buflen)
247 unsigned char *alias;
250 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
253 yaffs_GrossLock(dev);
255 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
257 yaffs_GrossUnlock(dev);
262 ret = vfs_readlink(dentry, buffer, buflen, alias);
267 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd)
269 unsigned char *alias;
271 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
274 yaffs_GrossLock(dev);
276 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
278 yaffs_GrossUnlock(dev);
283 ret = vfs_follow_link(nd,alias);
289 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,yaffs_Object *obj);
292 * Lookup is used to find objects in the fs
294 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
295 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
297 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *n)
299 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry)
303 struct inode *inode = NULL; // NCB 2.5/2.6 needs NULL here
305 yaffs_Device *dev = yaffs_InodeToObject(dir)->myDev;
308 yaffs_GrossLock(dev);
311 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_lookup for %d:%s\n",yaffs_InodeToObject(dir)->objectId,dentry->d_name.name));
313 obj = yaffs_FindObjectByName(yaffs_InodeToObject(dir),dentry->d_name.name);
315 obj = yaffs_GetEquivalentObject(obj); // in case it was a hardlink
321 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_lookup found %d\n",obj->objectId));
323 inode = yaffs_get_inode(dir->i_sb, obj->st_mode,0,obj);
327 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_loookup dentry \n"));
328 /* #if 0 asserted by NCB for 2.5/6 compatability - falls through to d_add even if NULL inode */
330 //dget(dentry); // try to solve directory bug
333 yaffs_GrossUnlock(dev);
343 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_lookup not found\n"));
346 yaffs_GrossUnlock(dev);
348 /* added NCB for 2.5/6 compatability - forces add even if inode is NULL which creates dentry hash*/
352 // return (ERR_PTR(-EIO));
356 // For now put inode is just for debugging
357 // Put inode is called when the inode **structure** is put.
358 static void yaffs_put_inode(struct inode *inode)
360 T(YAFFS_TRACE_OS,("yaffs_put_inode: ino %d, count %d\n",(int)inode->i_ino, atomic_read(&inode->i_count)));
364 // clear is called to tell the fs to release any per-inode data it holds
365 static void yaffs_clear_inode(struct inode *inode)
367 yaffs_Object *obj = yaffs_InodeToObject(inode);
369 T(YAFFS_TRACE_OS,("yaffs_clear_inode: ino %d, count %d %s\n",(int)inode->i_ino, atomic_read(&inode->i_count),
370 obj ? "object exists" : "null object"));
375 inode->u.generic_ip = NULL;
381 // delete is called when the link count is zero and the inode
382 // is put (ie. nobody wants to know about it anymore, time to
384 // NB Must call clear_inode()
385 static void yaffs_delete_inode(struct inode *inode)
387 yaffs_Object *obj = yaffs_InodeToObject(inode);
390 T(YAFFS_TRACE_OS,("yaffs_delete_inode: ino %d, count %d %s\n",(int)inode->i_ino, atomic_read(&inode->i_count),
391 obj ? "object exists" : "null object"));
396 yaffs_GrossLock(dev);
397 yaffs_DeleteFile(obj);
398 yaffs_GrossUnlock(dev);
404 static int yaffs_file_flush(struct file* file)
406 yaffs_Object *obj = yaffs_DentryToObject(file->f_dentry);
408 yaffs_Device *dev = obj->myDev;
410 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_flush object %d (%s)\n",obj->objectId,
411 obj->dirty ? "dirty" : "clean"));
413 yaffs_GrossLock(dev);
415 yaffs_FlushFile(obj,1);
417 yaffs_GrossUnlock(dev);
424 static int yaffs_readpage_nolock(struct file *f, struct page * pg)
429 unsigned char *pg_buf;
434 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readpage at %08x, size %08x\n",
435 (unsigned)(pg->index << PAGE_CACHE_SHIFT), (unsigned)PAGE_CACHE_SIZE));
437 obj = yaffs_DentryToObject(f->f_dentry);
446 /* FIXME: Can kmap fail? */
448 yaffs_GrossLock(dev);
450 ret = yaffs_ReadDataFromFile(obj, pg_buf, pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE);
452 yaffs_GrossUnlock(dev);
454 if(ret >= 0) ret = 0;
457 ClearPageUptodate(pg);
464 flush_dcache_page(pg);
468 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readpage done\n"));
472 static int yaffs_readpage_unlock(struct file *f, struct page *pg)
474 int ret = yaffs_readpage_nolock(f,pg);
479 static int yaffs_readpage(struct file *f, struct page * pg)
481 return yaffs_readpage_unlock(f,pg);
484 // writepage inspired by/stolen from smbfs
487 static int yaffs_writepage(struct page *page)
489 struct address_space *mapping = page->mapping;
491 unsigned long end_index;
499 inode = mapping->host;
503 end_index = inode->i_size >> PAGE_CACHE_SHIFT;
506 if (page->index < end_index)
508 nBytes = PAGE_CACHE_SIZE;
512 nBytes = inode->i_size & (PAGE_CACHE_SIZE-1);
514 // What's happening here?
515 ///* OK, are we completely out? */
516 //if (page->index >= end_index+1 || !offset)
524 obj = yaffs_InodeToObject(inode);
525 yaffs_GrossLock(obj->myDev);
528 nWritten = yaffs_WriteDataToFile(obj,buffer,page->index << PAGE_CACHE_SHIFT,nBytes);
530 yaffs_GrossUnlock(obj->myDev);
533 SetPageUptodate(page);
537 return (nWritten == nBytes) ? 0 : -ENOSPC;
542 static int yaffs_prepare_write(struct file *f, struct page *pg, unsigned offset, unsigned to)
545 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_prepair_write\n"));
546 if(!Page_Uptodate(pg) && (offset || to < PAGE_CACHE_SIZE))
547 return yaffs_readpage_nolock(f,pg);
553 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, unsigned to)
556 void *addr = page_address(pg) + offset;
557 loff_t pos = (((loff_t)pg->index) << PAGE_CACHE_SHIFT) + offset;
558 int nBytes = to - offset;
562 unsigned saddr = (unsigned)addr;
564 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_commit_write addr %x pos %x nBytes %d\n",saddr,spos,nBytes));
566 nWritten = yaffs_file_write(f,addr, nBytes, &pos);
568 if(nWritten != nBytes)
570 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_commit_write not same size nWritten %d nBytes %d\n",nWritten,nBytes));
572 ClearPageUptodate(pg);
579 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_commit_write returning %d\n",nWritten));
587 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object *obj)
591 inode->i_ino = obj->objectId;
592 inode->i_mode = obj->st_mode;
593 inode->i_uid = obj->st_uid;
594 inode->i_gid = obj->st_gid;
595 inode->i_blksize = inode->i_sb->s_blocksize;
596 //#if defined(CONFIG_KERNEL_2_5)
597 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
599 inode->i_rdev = old_decode_dev(obj->st_rdev);
600 inode->i_atime.tv_sec = (time_t)(obj->st_atime);
601 inode->i_atime.tv_nsec = 0;
602 inode->i_mtime.tv_sec = (time_t)obj->st_mtime;
603 inode->i_mtime.tv_nsec =0;
604 inode->i_ctime.tv_sec = (time_t)obj->st_ctime;
605 inode->i_ctime.tv_nsec = 0;
607 inode->i_rdev = obj->st_rdev;
608 inode->i_atime = obj->st_atime;
609 inode->i_mtime = obj->st_mtime;
610 inode->i_ctime = obj->st_ctime;
612 inode->i_size = yaffs_GetObjectFileLength(obj);
613 inode->i_blocks = (inode->i_size + 511) >> 9;
615 inode->i_nlink = yaffs_GetObjectLinkCount(obj);
617 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_FillInode mode %x uid %d gid %d size %d count %d\n",
618 inode->i_mode, inode->i_uid, inode->i_gid, (int)inode->i_size, atomic_read(&inode->i_count)));
620 switch (obj->st_mode & S_IFMT)
622 default: // fifo, device or socket
623 init_special_inode(inode, obj->st_mode,(dev_t)(obj->st_rdev));
625 case S_IFREG: // file
626 inode->i_op = &yaffs_file_inode_operations;
627 inode->i_fop = &yaffs_file_operations;
628 inode->i_mapping->a_ops = &yaffs_file_address_operations;
630 case S_IFDIR: // directory
631 inode->i_op = &yaffs_dir_inode_operations;
632 inode->i_fop = &yaffs_dir_operations;
634 case S_IFLNK: // symlink
635 inode->i_op = &yaffs_symlink_inode_operations;
640 inode->u.generic_ip = obj;
641 obj->myInode = inode;
646 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_FileInode invalid parameters\n"));
651 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,yaffs_Object *obj)
653 struct inode * inode;
655 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_get_inode for object %d\n",obj->objectId));
657 inode = iget(sb,obj->objectId);
659 // NB Side effect: iget calls back to yaffs_read_inode().
660 // iget also increments the inode's i_count
665 static ssize_t yaffs_file_read(struct file *f, char *buf, size_t n, loff_t *pos)
672 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_read\n"));
674 obj = yaffs_DentryToObject(f->f_dentry);
678 yaffs_GrossLock(dev);
680 inode = f->f_dentry->d_inode;
682 if (*pos < inode->i_size)
684 if (*pos + n > inode->i_size)
686 n = inode->i_size - *pos;
694 nRead = yaffs_ReadDataFromFile(obj,buf,*pos,n);
700 yaffs_GrossUnlock(dev);
704 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_read read %d bytes, %d read at %d\n",n,nRead,ipos));
710 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, loff_t *pos)
718 obj = yaffs_DentryToObject(f->f_dentry);
722 yaffs_GrossLock(dev);
724 inode = f->f_dentry->d_inode;
726 if(!S_ISBLK(inode->i_mode) && f->f_flags & O_APPEND)
728 ipos = inode->i_size;
738 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write: hey obj is null!\n"));
742 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));
745 nWritten = yaffs_WriteDataToFile(obj,buf,ipos,n);
747 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write writing %d bytes, %d written at %d\n",n,nWritten,ipos));
752 if(ipos > inode->i_size)
754 inode->i_size = ipos;
755 inode->i_blocks = (ipos + 511)>>9;
757 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write size updated to %d bytes, %d blocks\n",ipos,(int)(inode->i_blocks)));
761 yaffs_GrossUnlock(dev);
763 return nWritten != n ? -ENOSPC : nWritten;
767 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
771 struct inode *inode = f->f_dentry->d_inode;
772 unsigned long offset, curoffs;
776 char name[YAFFS_MAX_NAME_LENGTH +1];
778 obj = yaffs_DentryToObject(f->f_dentry);
781 yaffs_GrossLock(dev);
785 T(YAFFS_TRACE_OS,("yaffs_readdir: starting at %d\n",(int)offset));
789 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readdir: entry . ino %d \n",(int)inode->i_ino));
790 if(filldir(dirent,".",1,offset,inode->i_ino,DT_DIR) < 0)
799 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readdir: entry .. ino %d \n",(int)f->f_dentry->d_parent->d_inode->i_ino));
800 if(filldir(dirent,"..",2,offset,f->f_dentry->d_parent->d_inode->i_ino,DT_DIR) < 0)
810 list_for_each(i,&obj->variant.directoryVariant.children)
813 if(curoffs >= offset)
815 l = list_entry(i, yaffs_Object,siblings);
817 yaffs_GetObjectName(l,name,YAFFS_MAX_NAME_LENGTH+1);
818 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readdir: %s inode %d\n",name,yaffs_GetObjectInode(l)));
824 yaffs_GetObjectInode(l),
825 yaffs_GetObjectType(l))
839 yaffs_GrossUnlock(dev);
846 * File creation. Allocate an inode, and we're done..
848 //#if defined(CONFIG_KERNEL_2_5)
849 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
850 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
852 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev)
857 yaffs_Object *obj = NULL;
860 yaffs_Object *parent = yaffs_InodeToObject(dir);
866 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: parent object %d type %d\n",
867 parent->objectId,parent->variantType));
871 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: could not get parent object\n"));
875 T(YAFFS_TRACE_OS,("yaffs_mknod: making oject for %s, mode %x dev %x\n",
876 dentry->d_name.name, mode,rdev));
880 yaffs_GrossLock(dev);
882 switch (mode & S_IFMT)
885 // Special (socket, fifo, device...)
886 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making special\n"));
887 obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,rdev);
889 case S_IFREG: // file
890 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making file\n"));
891 obj = yaffs_MknodFile(parent,dentry->d_name.name,mode,current->uid, current->gid);
893 case S_IFDIR: // directory
894 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making directory\n"));
895 obj = yaffs_MknodDirectory(parent,dentry->d_name.name,mode,current->uid, current->gid);
897 case S_IFLNK: // symlink
898 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making file\n"));
899 obj = NULL; // Do we ever get here?
905 inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj);
906 d_instantiate(dentry, inode);
907 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod created object %d count = %d\n",obj->objectId,atomic_read(&inode->i_count)));
912 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod failed making object\n"));
916 yaffs_GrossUnlock(dev);
921 static int yaffs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
924 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mkdir\n"));
925 retVal = yaffs_mknod(dir, dentry, mode | S_IFDIR, 0);
927 // attempt to fix dir bug - didn't work
936 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
937 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
938 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *n)
940 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode)
943 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_create\n"));
944 return yaffs_mknod(dir, dentry, mode | S_IFREG, 0);
948 static int yaffs_unlink(struct inode * dir, struct dentry *dentry)
955 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_unlink %d:%s\n",(int)(dir->i_ino),dentry->d_name.name));
957 dev = yaffs_InodeToObject(dir)->myDev;
959 yaffs_GrossLock(dev);
962 retVal = yaffs_Unlink(yaffs_InodeToObject(dir),dentry->d_name.name);
965 yaffs_GrossUnlock(dev);
967 if( retVal == YAFFS_OK)
969 dentry->d_inode->i_nlink--;
970 mark_inode_dirty(dentry->d_inode);
983 static int yaffs_link(struct dentry *old_dentry, struct inode * dir, struct dentry * dentry)
985 struct inode *inode = old_dentry->d_inode;
986 yaffs_Object *obj = NULL;
987 yaffs_Object *link=NULL;
990 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_link\n"));
992 obj = yaffs_InodeToObject(inode);
995 yaffs_GrossLock(dev);
997 if (!S_ISDIR(inode->i_mode)) // Don't link directories
999 link = yaffs_Link(yaffs_InodeToObject(dir),dentry->d_name.name,obj);
1005 old_dentry->d_inode->i_nlink = yaffs_GetObjectLinkCount(obj);
1006 d_instantiate(dentry, old_dentry->d_inode);
1007 atomic_inc(&old_dentry->d_inode->i_count);
1008 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_link link count %d i_count %d\n",
1009 old_dentry->d_inode->i_nlink,atomic_read(&old_dentry->d_inode->i_count)));
1013 yaffs_GrossUnlock(dev);
1027 static int yaffs_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
1032 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_symlink\n"));
1034 dev = yaffs_InodeToObject(dir)->myDev;
1035 yaffs_GrossLock(dev);
1036 obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name,
1037 S_IFLNK | S_IRWXUGO, current->uid, current->gid,
1039 yaffs_GrossUnlock(dev);
1044 struct inode* inode;
1046 inode = yaffs_get_inode(dir->i_sb, obj->st_mode, 0, obj);
1047 d_instantiate(dentry, inode);
1048 T(YAFFS_TRACE_OS,(KERN_DEBUG"symlink created OK\n"));
1053 T(YAFFS_TRACE_OS,(KERN_DEBUG"symlink not created\n"));
1060 static int yaffs_sync_object(struct file * file, struct dentry *dentry, int datasync)
1066 obj = yaffs_DentryToObject(dentry);
1070 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_sync_object\n"));
1071 yaffs_GrossLock(dev);
1072 yaffs_FlushFile(obj,1);
1073 yaffs_GrossUnlock(dev);
1078 * The VFS layer already does all the dentry stuff for rename.
1080 * NB: POSIX says you can rename an object over an old object of the same name
1082 static int yaffs_rename(struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry)
1085 int retVal = YAFFS_FAIL;
1087 yaffs_Object *target;
1089 dev = yaffs_InodeToObject(old_dir)->myDev;
1091 yaffs_GrossLock(dev);
1093 // Check if the target is an existing directory that is not empty.
1094 target = yaffs_FindObjectByName(yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
1097 target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
1098 !list_empty(&target->variant.directoryVariant.children))
1100 retVal = YAFFS_FAIL;
1105 // Unlink the target if it exists
1106 removed = yaffs_Unlink(yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
1109 retVal = yaffs_RenameObject(yaffs_InodeToObject(old_dir),old_dentry->d_name.name,
1110 yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
1113 yaffs_GrossUnlock(dev);
1115 if(retVal == YAFFS_OK)
1117 if(removed == YAFFS_OK)
1119 new_dentry->d_inode->i_nlink--;
1120 mark_inode_dirty(new_dentry->d_inode);
1133 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr)
1135 struct inode *inode = dentry->d_inode;
1139 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_setattr of object %d\n",yaffs_InodeToObject(inode)->objectId));
1141 if((error = inode_change_ok(inode,attr)) == 0)
1144 dev = yaffs_InodeToObject(inode)->myDev;
1145 yaffs_GrossLock(dev);
1146 if(yaffs_SetAttributes(yaffs_InodeToObject(inode),attr) == YAFFS_OK)
1154 yaffs_GrossUnlock(dev);
1155 inode_setattr(inode,attr);
1160 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
1161 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1162 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf)
1164 static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
1167 yaffs_Device *dev = yaffs_SuperToDevice(sb);
1168 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_statfs\n"));
1170 yaffs_GrossLock(dev);
1172 buf->f_type = YAFFS_MAGIC;
1173 buf->f_bsize = sb->s_blocksize;
1174 buf->f_namelen = 255;
1175 buf->f_blocks = (dev->endBlock - dev->startBlock + 1) * YAFFS_CHUNKS_PER_BLOCK/
1176 (sb->s_blocksize/YAFFS_BYTES_PER_CHUNK);
1179 buf->f_bfree = yaffs_GetNumberOfFreeChunks(dev)/
1180 (sb->s_blocksize/YAFFS_BYTES_PER_CHUNK);
1181 buf->f_bavail = buf->f_bfree;
1183 yaffs_GrossUnlock(dev);
1187 static void yaffs_read_inode (struct inode *inode)
1189 // NB This is called as a side effect of other functions and
1190 // thus gross locking should always be in place already.
1193 yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb);
1195 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_read_inode for %d\n",(int)inode->i_ino));
1197 obj = yaffs_FindObjectByNumber(dev,inode->i_ino);
1199 yaffs_FillInodeFromObject(inode,obj);
1205 static yaffs_Device *yaffs_dev;
1206 static yaffs_Device *yaffsram_dev;
1210 static void yaffs_put_super(struct super_block *sb)
1212 yaffs_Device *dev = yaffs_SuperToDevice(sb);
1214 yaffs_GrossLock(dev);
1215 if(dev->putSuperFunc)
1217 dev->putSuperFunc(sb);
1219 yaffs_Deinitialise(dev);
1220 yaffs_GrossUnlock(dev);
1222 if(dev == yaffs_dev) yaffs_dev = NULL;
1223 if(dev == yaffsram_dev) yaffsram_dev = NULL;
1229 #ifdef CONFIG_YAFFS_MTD_ENABLED
1231 static void yaffs_MTDPutSuper(struct super_block *sb)
1234 struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
1241 put_mtd_device(mtd);
1247 static struct super_block *yaffs_internal_read_super(int useRam, struct super_block * sb, void * data, int silent)
1250 struct inode * inode;
1251 struct dentry * root;
1254 sb->s_magic = YAFFS_MAGIC;
1255 sb->s_op = &yaffs_super_ops;
1258 printk(KERN_INFO"yaffs: sb is NULL\n");
1260 printk(KERN_INFO"yaffs: sb->s_dev is NULL\n");
1261 else if(! kdevname(sb->s_dev))
1262 printk(KERN_INFO"yaffs: kdevname is NULL\n");
1264 printk(KERN_INFO"yaffs: dev is %d name is \"%s\"\n", sb->s_dev, kdevname(sb->s_dev));
1268 #ifdef CONFIG_YAFFS_USE_CHUNK_SIZE
1269 sb->s_blocksize = YAFFS_BYTES_PER_CHUNK;
1270 sb->s_blocksize_bits = YAFFS_CHUNK_SIZE_SHIFT;
1272 sb->s_blocksize = PAGE_CACHE_SIZE;
1273 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
1275 T(YAFFS_TRACE_OS,("yaffs_read_super: %s block size %d\n", useRam ? "RAM" : "MTD",(int)(sb->s_blocksize)));
1277 #ifdef CONFIG_YAFFS_DISABLE_WRITE_VERIFY
1278 T(YAFFS_TRACE_OS,("yaffs: Write verification disabled. All guarantees null and void\n"));
1286 #ifdef CONFIG_YAFFS_RAM_ENABLED
1287 // Set the yaffs_Device up for ram emulation
1289 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
1292 // Deep shit could not allocate device structure
1293 printk(KERN_DEBUG"yaffs_read_super: Failed trying to allocate yaffs_Device. Terminating debug.\n");
1297 memset(dev,0,sizeof(yaffs_Device));
1298 dev->genericDevice = NULL; // Not used for RAM emulation.
1300 nBlocks = YAFFS_RAM_EMULATION_SIZE / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
1301 dev->startBlock = 1; // Don't use block 0
1302 dev->endBlock = nBlocks - 1;
1303 dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
1304 dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
1305 dev->nReservedBlocks = 5;
1307 dev->writeChunkToNAND = nandemul_WriteChunkToNAND;
1308 dev->readChunkFromNAND = nandemul_ReadChunkFromNAND;
1309 dev->eraseBlockInNAND = nandemul_EraseBlockInNAND;
1310 dev->initialiseNAND = nandemul_InitialiseNAND;
1319 #ifdef CONFIG_YAFFS_MTD_ENABLED
1320 struct mtd_info *mtd;
1322 printk(KERN_DEBUG "yaffs: Attempting MTD mount on %u.%u, \"%s\"\n",
1323 MAJOR(sb->s_dev),MINOR(sb->s_dev),kdevname(sb->s_dev));
1325 // Check it's an mtd device.....
1326 if(MAJOR(sb->s_dev) != MTD_BLOCK_MAJOR)
1328 return NULL; // This isn't an mtd device
1332 mtd = get_mtd_device(NULL, MINOR(sb->s_dev));
1335 printk(KERN_DEBUG "yaffs: MTD device #%u doesn't appear to exist\n", MINOR(sb->s_dev));
1340 if(mtd->type != MTD_NANDFLASH)
1342 printk(KERN_DEBUG "yaffs: MTD device is not NAND it's type %d\n", mtd->type);
1346 //printk(KERN_DEBUG" erase %x\n",mtd->erase);
1347 //printk(KERN_DEBUG" read %x\n",mtd->read);
1348 //printk(KERN_DEBUG" write %x\n",mtd->write);
1349 //printk(KERN_DEBUG" readoob %x\n",mtd->read_oob);
1350 //printk(KERN_DEBUG" writeoob %x\n",mtd->write_oob);
1351 //printk(KERN_DEBUG" oobblock %x\n",mtd->oobblock);
1352 //printk(KERN_DEBUG" oobsize %x\n",mtd->oobsize);
1358 #ifndef CONFIG_YAFFS_USE_OLD_MTD
1365 printk(KERN_DEBUG "yaffs: MTD device does not support required functions\n");
1369 if(mtd->oobblock != YAFFS_BYTES_PER_CHUNK ||
1370 mtd->oobsize != YAFFS_BYTES_PER_SPARE)
1372 printk(KERN_DEBUG "yaffs: MTD device does not support have the right page sizes\n");
1377 // OK, so if we got here, we have an MTD that's NAND and looks
1378 // like it has the right capabilities
1379 // Set the yaffs_Device up for ram emulation
1381 //#if defined(CONFIG_KERNEL_2_5)
1382 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1383 sb->s_fs_info = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
1385 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
1389 // Deep shit could not allocate device structure
1390 printk(KERN_DEBUG"yaffs_read_super: Failed trying to allocate yaffs_Device. Terminating debug.\n");
1394 memset(dev,0,sizeof(yaffs_Device));
1395 dev->genericDevice = mtd;
1397 // Set up the memory size parameters....
1399 nBlocks = mtd->size / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
1400 dev->startBlock = 1; // Don't use block 0
1401 dev->endBlock = nBlocks - 1;
1402 dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
1403 dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
1404 dev->nReservedBlocks = 5;
1405 dev->nShortOpCaches = 10; // Enable short op caching
1408 // ... and the functions.
1409 dev->writeChunkToNAND = nandmtd_WriteChunkToNAND;
1410 dev->readChunkFromNAND = nandmtd_ReadChunkFromNAND;
1411 dev->eraseBlockInNAND = nandmtd_EraseBlockInNAND;
1412 dev->initialiseNAND = nandmtd_InitialiseNAND;
1414 dev->putSuperFunc = yaffs_MTDPutSuper;
1416 #ifdef CONFIG_YAFFS_USE_NANDECC
1417 dev->useNANDECC = 1;
1425 init_MUTEX(&dev->grossLock);
1428 yaffs_GrossLock(dev);
1429 yaffs_GutsInitialise(yaffs_SuperToDevice(sb));
1431 T(YAFFS_TRACE_OS,("yaffs_read_super: guts initialised\n"));
1433 // Create root inode
1434 inode = yaffs_get_inode(sb, S_IFDIR | 0755, 0,yaffs_Root(yaffs_SuperToDevice(sb)));
1436 yaffs_GrossUnlock(dev);
1442 inode->i_op = & yaffs_dir_inode_operations;
1443 inode->i_fop = & yaffs_dir_operations;
1445 T(YAFFS_TRACE_OS,("yaffs_read_super: got root inode\n"));
1448 root = d_alloc_root(inode);
1450 T(YAFFS_TRACE_OS,("yaffs_read_super: d_alloc_root done\n"));
1458 T(YAFFS_TRACE_OS,("yaffs_read_super: done\n"));
1462 static int yaffs_internal_read_super_ram(struct super_block * sb, void * data, int silent)
1464 return yaffs_internal_read_super(1,sb,data,silent) ? 0 : -1;
1466 static int yaffs_internal_read_super_mtd(struct super_block * sb, void * data, int silent)
1468 return yaffs_internal_read_super(0,sb,data,silent) ? 0 : -1;
1472 #ifdef CONFIG_YAFFS_MTD_ENABLED
1473 //#if defined(CONFIG_KERNEL_2_5)
1474 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1475 static struct super_block *yaffs_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data)
1478 return get_sb_bdev(fs, flags, dev_name, data, yaffs_internal_read_super_mtd);
1481 /* changes NCB 2.5.70 */
1482 //static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
1483 static struct file_system_type yaffs_fs_type = {
1484 .owner = THIS_MODULE,
1486 .get_sb = yaffs_read_super,
1487 // .kill_sb = kill_block_super,
1488 .kill_sb = kill_litter_super,
1489 .fs_flags = FS_REQUIRES_DEV,
1492 static struct super_block *yaffs_read_super(struct super_block * sb, void * data, int silent)
1494 return yaffs_internal_read_super(0,sb,data,silent);
1497 static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
1501 #ifdef CONFIG_YAFFS_RAM_ENABLED
1503 //#if defined(CONFIG_KERNEL_2_5)
1504 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1505 static struct super_block *yaffs_ram_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data)
1508 return get_sb_bdev(fs, flags, dev_name, data, yaffs_internal_read_super_ram);
1511 /* changes NCB 2.5.70 */
1512 //static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
1513 static struct file_system_type yaffs_fs_type = {
1514 .owner = THIS_MODULE,
1516 .get_sb = yaffs_ram_read_super,
1517 // .kill_sb = kill_block_super,
1518 .kill_sb = kill_litter_super,
1519 .fs_flags = FS_SINGLE,
1522 static struct super_block *yaffs_ram_read_super(struct super_block * sb, void * data, int silent)
1524 return yaffs_internal_read_super(1,sb,data,silent);
1527 static DECLARE_FSTYPE(yaffs_ram_fs_type, "yaffsram", yaffs_ram_read_super, FS_SINGLE);
1529 #endif // CONFIG_YAFFS_RAM_ENABLED
1532 static struct proc_dir_entry *my_proc_entry;
1533 static struct proc_dir_entry *my_proc_ram_write_entry;
1535 static char * yaffs_dump_dev(char *buf,yaffs_Device *dev,char *name)
1537 buf +=sprintf(buf,"\nDevice %s\n",name);
1538 buf +=sprintf(buf,"startBlock......... %d\n",dev->startBlock);
1539 buf +=sprintf(buf,"endBlock........... %d\n",dev->endBlock);
1540 buf +=sprintf(buf,"chunkGroupBits..... %d\n",dev->chunkGroupBits);
1541 buf +=sprintf(buf,"chunkGroupSize..... %d\n",dev->chunkGroupSize);
1542 buf +=sprintf(buf,"nErasedBlocks...... %d\n",dev->nErasedBlocks);
1543 buf +=sprintf(buf,"nTnodesCreated..... %d\n",dev->nTnodesCreated);
1544 buf +=sprintf(buf,"nFreeTnodes........ %d\n",dev->nFreeTnodes);
1545 buf +=sprintf(buf,"nObjectsCreated.... %d\n",dev->nObjectsCreated);
1546 buf +=sprintf(buf,"nFreeObjects....... %d\n",dev->nFreeObjects);
1547 buf +=sprintf(buf,"nFreeChunks........ %d\n",dev->nFreeChunks);
1548 buf +=sprintf(buf,"nPageWrites........ %d\n",dev->nPageWrites);
1549 buf +=sprintf(buf,"nPageReads......... %d\n",dev->nPageReads);
1550 buf +=sprintf(buf,"nBlockErasures..... %d\n",dev->nBlockErasures);
1551 buf +=sprintf(buf,"nGCCopies.......... %d\n",dev->nGCCopies);
1552 buf +=sprintf(buf,"garbageCollections. %d\n",dev->garbageCollections);
1553 buf +=sprintf(buf,"passiveGCs......... %d\n",dev->passiveGarbageCollections);
1554 buf +=sprintf(buf,"nRetriedWrites..... %d\n",dev->nRetriedWrites);
1555 buf +=sprintf(buf,"nRetireBlocks...... %d\n",dev->nRetiredBlocks);
1556 buf +=sprintf(buf,"eccFixed........... %d\n",dev->eccFixed);
1557 buf +=sprintf(buf,"eccUnfixed......... %d\n",dev->eccUnfixed);
1558 buf +=sprintf(buf,"tagsEccFixed....... %d\n",dev->tagsEccFixed);
1559 buf +=sprintf(buf,"tagsEccUnfixed..... %d\n",dev->tagsEccUnfixed);
1560 buf +=sprintf(buf,"cacheHits.......... %d\n",dev->cacheHits);
1561 buf +=sprintf(buf,"nDeletedFiles...... %d\n",dev->nDeletedFiles);
1562 buf +=sprintf(buf,"nUnlinkedFiles..... %d\n",dev->nUnlinkedFiles);
1563 buf +=sprintf(buf,"nBackgroudDeletions %d\n",dev->nBackgroundDeletions);
1564 buf +=sprintf(buf,"useNANDECC......... %d\n",dev->useNANDECC);
1570 static int yaffs_proc_read(
1580 char my_buffer[3000];
1584 if (offset > 0) return 0;
1586 /* Fill the buffer and get its length */
1587 buf +=sprintf(buf,"YAFFS built:"__DATE__ " "__TIME__"\n%s\n%s\n", yaffs_fs_c_version,yaffs_guts_c_version);
1589 if(yaffs_dev) buf = yaffs_dump_dev(buf,yaffs_dev,"yaffs");
1590 if(yaffsram_dev) buf = yaffs_dump_dev(buf,yaffsram_dev,"yaffsram");
1593 strcpy(page,my_buffer);
1594 return strlen(my_buffer);
1598 static int yaffs_proc_ram_write(
1608 printk(KERN_DEBUG "yaffs write size %d\n",count);
1612 static int __init init_yaffs_fs(void)
1616 yaffs_dev = yaffsram_dev = NULL;
1618 printk(KERN_DEBUG "yaffs " __DATE__ " " __TIME__ " Initialisation\n");
1619 #ifdef CONFIG_YAFFS_USE_GENERIC_RW
1620 printk(KERN_DEBUG "yaffs is using generic read/write (caching)\n");
1622 printk(KERN_DEBUG "yaffs is using direct read/write (uncached)\n");
1626 /* Install the proc_fs entry */
1627 my_proc_entry = create_proc_read_entry("yaffs",
1637 #ifdef CONFIG_YAFFS_RAM_ENABLED
1639 my_proc_ram_write_entry = create_proc_entry("yaffs_ram",
1643 if(!my_proc_ram_write_entry)
1649 my_proc_ram_write_entry->write_proc = yaffs_proc_ram_write;
1653 error = register_filesystem(&yaffs_ram_fs_type);
1658 #endif //CONFIG_YAFFS_RAM_ENABLED
1660 #ifdef CONFIG_YAFFS_MTD_ENABLED
1661 error = register_filesystem(&yaffs_fs_type);
1664 #ifdef CONFIG_YAFFS_RAM_ENABLED
1665 unregister_filesystem(&yaffs_ram_fs_type);
1666 #endif //CONFIG_YAFFS_RAM_ENABLED
1668 #endif // CONFIG_YAFFS_MTD_ENABLED
1673 static void __exit exit_yaffs_fs(void)
1675 printk(KERN_DEBUG "yaffs " __DATE__ " " __TIME__ " Clean up\n");
1677 remove_proc_entry("yaffs",&proc_root);
1679 #ifdef CONFIG_YAFFS_RAM_ENABLED
1680 unregister_filesystem(&yaffs_ram_fs_type);
1682 #ifdef CONFIG_YAFFS_MTD_ENABLED
1683 unregister_filesystem(&yaffs_fs_type);
1688 module_init(init_yaffs_fs)
1689 module_exit(exit_yaffs_fs)
1691 MODULE_DESCRIPTION("YAFFS - a NAND specific flash file system");
1692 MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002");
1693 MODULE_LICENSE("GPL");