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.33 2004-09-19 08:14:50 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 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->s_fs_info)
98 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->u.generic_sbp)
102 static void yaffs_put_super(struct super_block *sb);
104 static ssize_t yaffs_file_read(struct file *f, char *buf, size_t n, loff_t *pos);
105 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, loff_t *pos);
106 static int yaffs_file_flush(struct file* file);
108 static int yaffs_sync_object(struct file * file, struct dentry *dentry, int datasync);
110 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir);
112 #if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
113 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *n);
114 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *n);
116 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode);
117 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry);
119 static int yaffs_link(struct dentry *old_dentry, struct inode * dir, struct dentry * dentry);
120 static int yaffs_unlink(struct inode * dir, struct dentry *dentry);
121 static int yaffs_symlink(struct inode * dir, struct dentry *dentry, const char * symname);
122 static int yaffs_mkdir(struct inode * dir, struct dentry * dentry, int mode);
124 #if defined(CONFIG_KERNEL_2_5)
125 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev);
127 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev);
129 static int yaffs_rename(struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry);
130 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr);
132 #if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
133 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf);
135 static int yaffs_statfs(struct super_block *sb, struct statfs *buf);
137 static void yaffs_read_inode (struct inode *inode);
139 #if defined(CONFIG_KERNEL_2_5)
140 static struct super_block *yaffs_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data);
142 static struct super_block *yaffs_read_super(struct super_block * sb, void * data, int silent);
145 static void yaffs_put_inode (struct inode *inode);
146 static void yaffs_delete_inode(struct inode *);
147 static void yaffs_clear_inode(struct inode *);
149 static int yaffs_readpage(struct file *file, struct page * page);
150 static int yaffs_writepage(struct page *page);
151 static int yaffs_prepare_write(struct file *f, struct page *pg, unsigned offset, unsigned to);
152 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, unsigned to);
154 static int yaffs_readlink(struct dentry *dentry, char *buffer, int buflen);
155 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd);
160 static struct address_space_operations yaffs_file_address_operations = {
161 readpage: yaffs_readpage,
162 writepage: yaffs_writepage,
163 prepare_write: yaffs_prepare_write,
164 commit_write: yaffs_commit_write
168 static struct file_operations yaffs_file_operations = {
169 #ifdef CONFIG_YAFFS_USE_GENERIC_RW
170 read: generic_file_read,
171 write: generic_file_write,
173 read: yaffs_file_read,
174 write: yaffs_file_write,
176 mmap: generic_file_mmap,
177 flush: yaffs_file_flush,
178 fsync: yaffs_sync_object,
182 static struct inode_operations yaffs_file_inode_operations = {
183 setattr: yaffs_setattr,
187 struct inode_operations yaffs_symlink_inode_operations =
189 readlink: yaffs_readlink,
190 follow_link: yaffs_follow_link,
191 setattr: yaffs_setattr
194 static struct inode_operations yaffs_dir_inode_operations = {
195 create: yaffs_create,
196 lookup: yaffs_lookup,
198 unlink: yaffs_unlink,
199 symlink: yaffs_symlink,
203 rename: yaffs_rename,
204 setattr: yaffs_setattr,
207 static struct file_operations yaffs_dir_operations = {
208 read: generic_read_dir,
209 readdir: yaffs_readdir,
210 fsync: yaffs_sync_object,
214 static struct super_operations yaffs_super_ops = {
215 statfs: yaffs_statfs,
216 read_inode: yaffs_read_inode,
217 put_inode: yaffs_put_inode,
218 put_super: yaffs_put_super,
220 delete_inode: yaffs_delete_inode,
221 clear_inode: yaffs_clear_inode,
226 static void yaffs_GrossLock(yaffs_Device *dev)
228 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs locking\n"));
230 down(&dev->grossLock);
233 static void yaffs_GrossUnlock(yaffs_Device *dev)
235 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs unlocking\n"));
240 static int yaffs_readlink(struct dentry *dentry, char *buffer, int buflen)
242 unsigned char *alias;
245 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
248 yaffs_GrossLock(dev);
250 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
252 yaffs_GrossUnlock(dev);
257 ret = vfs_readlink(dentry, buffer, buflen, alias);
262 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd)
264 unsigned char *alias;
266 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
269 yaffs_GrossLock(dev);
271 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
273 yaffs_GrossUnlock(dev);
278 ret = vfs_follow_link(nd,alias);
284 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,yaffs_Object *obj);
287 * Lookup is used to find objects in the fs
289 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
290 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
292 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry, struct nameidata *n)
294 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry)
298 struct inode *inode = NULL; // NCB 2.5/2.6 needs NULL here
300 yaffs_Device *dev = yaffs_InodeToObject(dir)->myDev;
303 yaffs_GrossLock(dev);
306 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_lookup for %d:%s\n",yaffs_InodeToObject(dir)->objectId,dentry->d_name.name));
308 obj = yaffs_FindObjectByName(yaffs_InodeToObject(dir),dentry->d_name.name);
310 obj = yaffs_GetEquivalentObject(obj); // in case it was a hardlink
316 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_lookup found %d\n",obj->objectId));
318 inode = yaffs_get_inode(dir->i_sb, obj->st_mode,0,obj);
322 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_loookup dentry \n"));
323 /* #if 0 asserted by NCB for 2.5/6 compatability - falls through to d_add even if NULL inode */
325 //dget(dentry); // try to solve directory bug
328 yaffs_GrossUnlock(dev);
338 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_lookup not found\n"));
341 yaffs_GrossUnlock(dev);
343 /* added NCB for 2.5/6 compatability - forces add even if inode is NULL which creates dentry hash*/
347 // return (ERR_PTR(-EIO));
351 // For now put inode is just for debugging
352 // Put inode is called when the inode **structure** is put.
353 static void yaffs_put_inode(struct inode *inode)
355 T(YAFFS_TRACE_OS,("yaffs_put_inode: ino %d, count %d\n",(int)inode->i_ino, atomic_read(&inode->i_count)));
359 // clear is called to tell the fs to release any per-inode data it holds
360 static void yaffs_clear_inode(struct inode *inode)
362 yaffs_Object *obj = yaffs_InodeToObject(inode);
364 T(YAFFS_TRACE_OS,("yaffs_clear_inode: ino %d, count %d %s\n",(int)inode->i_ino, atomic_read(&inode->i_count),
365 obj ? "object exists" : "null object"));
370 inode->u.generic_ip = NULL;
376 // delete is called when the link count is zero and the inode
377 // is put (ie. nobody wants to know about it anymore, time to
379 // NB Must call clear_inode()
380 static void yaffs_delete_inode(struct inode *inode)
382 yaffs_Object *obj = yaffs_InodeToObject(inode);
385 T(YAFFS_TRACE_OS,("yaffs_delete_inode: ino %d, count %d %s\n",(int)inode->i_ino, atomic_read(&inode->i_count),
386 obj ? "object exists" : "null object"));
391 yaffs_GrossLock(dev);
392 yaffs_DeleteFile(obj);
393 yaffs_GrossUnlock(dev);
399 static int yaffs_file_flush(struct file* file)
401 yaffs_Object *obj = yaffs_DentryToObject(file->f_dentry);
403 yaffs_Device *dev = obj->myDev;
405 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_flush object %d (%s)\n",obj->objectId,
406 obj->dirty ? "dirty" : "clean"));
408 yaffs_GrossLock(dev);
410 yaffs_FlushFile(obj,1);
412 yaffs_GrossUnlock(dev);
419 static int yaffs_readpage_nolock(struct file *f, struct page * pg)
424 unsigned char *pg_buf;
429 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readpage at %08x, size %08x\n",
430 (unsigned)(pg->index << PAGE_CACHE_SHIFT), (unsigned)PAGE_CACHE_SIZE));
432 obj = yaffs_DentryToObject(f->f_dentry);
441 /* FIXME: Can kmap fail? */
443 yaffs_GrossLock(dev);
445 ret = yaffs_ReadDataFromFile(obj, pg_buf, pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE);
447 yaffs_GrossUnlock(dev);
449 if(ret >= 0) ret = 0;
452 ClearPageUptodate(pg);
459 flush_dcache_page(pg);
463 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readpage done\n"));
467 static int yaffs_readpage_unlock(struct file *f, struct page *pg)
469 int ret = yaffs_readpage_nolock(f,pg);
474 static int yaffs_readpage(struct file *f, struct page * pg)
476 return yaffs_readpage_unlock(f,pg);
479 // writepage inspired by/stolen from smbfs
482 static int yaffs_writepage(struct page *page)
484 struct address_space *mapping = page->mapping;
486 unsigned long end_index;
494 inode = mapping->host;
498 end_index = inode->i_size >> PAGE_CACHE_SHIFT;
501 if (page->index < end_index)
503 nBytes = PAGE_CACHE_SIZE;
507 nBytes = inode->i_size & (PAGE_CACHE_SIZE-1);
509 // What's happening here?
510 ///* OK, are we completely out? */
511 //if (page->index >= end_index+1 || !offset)
519 obj = yaffs_InodeToObject(inode);
520 yaffs_GrossLock(obj->myDev);
523 nWritten = yaffs_WriteDataToFile(obj,buffer,page->index << PAGE_CACHE_SHIFT,nBytes);
525 yaffs_GrossUnlock(obj->myDev);
528 SetPageUptodate(page);
532 return (nWritten == nBytes) ? 0 : -ENOSPC;
537 static int yaffs_prepare_write(struct file *f, struct page *pg, unsigned offset, unsigned to)
540 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_prepair_write\n"));
541 if(!Page_Uptodate(pg) && (offset || to < PAGE_CACHE_SIZE))
542 return yaffs_readpage_nolock(f,pg);
548 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset, unsigned to)
551 void *addr = page_address(pg) + offset;
552 loff_t pos = (((loff_t)pg->index) << PAGE_CACHE_SHIFT) + offset;
553 int nBytes = to - offset;
557 unsigned saddr = (unsigned)addr;
559 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_commit_write addr %x pos %x nBytes %d\n",saddr,spos,nBytes));
561 nWritten = yaffs_file_write(f,addr, nBytes, &pos);
563 if(nWritten != nBytes)
565 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_commit_write not same size nWritten %d nBytes %d\n",nWritten,nBytes));
567 ClearPageUptodate(pg);
574 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_commit_write returning %d\n",nWritten));
582 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object *obj)
586 inode->i_ino = obj->objectId;
587 inode->i_mode = obj->st_mode;
588 inode->i_uid = obj->st_uid;
589 inode->i_gid = obj->st_gid;
590 inode->i_blksize = inode->i_sb->s_blocksize;
591 //#if defined(CONFIG_KERNEL_2_5)
592 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
594 inode->i_rdev = old_decode_dev(obj->st_rdev);
595 inode->i_atime.tv_sec = (time_t)(obj->st_atime);
596 inode->i_atime.tv_nsec = 0;
597 inode->i_mtime.tv_sec = (time_t)obj->st_mtime;
598 inode->i_mtime.tv_nsec =0;
599 inode->i_ctime.tv_sec = (time_t)obj->st_ctime;
600 inode->i_ctime.tv_nsec = 0;
602 inode->i_rdev = obj->st_rdev;
603 inode->i_atime = obj->st_atime;
604 inode->i_mtime = obj->st_mtime;
605 inode->i_ctime = obj->st_ctime;
607 inode->i_size = yaffs_GetObjectFileLength(obj);
608 inode->i_blocks = (inode->i_size + 511) >> 9;
610 inode->i_nlink = yaffs_GetObjectLinkCount(obj);
612 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_FillInode mode %x uid %d gid %d size %d count %d\n",
613 inode->i_mode, inode->i_uid, inode->i_gid, (int)inode->i_size, atomic_read(&inode->i_count)));
615 switch (obj->st_mode & S_IFMT)
617 default: // fifo, device or socket
618 init_special_inode(inode, obj->st_mode,(dev_t)(obj->st_rdev));
620 case S_IFREG: // file
621 inode->i_op = &yaffs_file_inode_operations;
622 inode->i_fop = &yaffs_file_operations;
623 inode->i_mapping->a_ops = &yaffs_file_address_operations;
625 case S_IFDIR: // directory
626 inode->i_op = &yaffs_dir_inode_operations;
627 inode->i_fop = &yaffs_dir_operations;
629 case S_IFLNK: // symlink
630 inode->i_op = &yaffs_symlink_inode_operations;
635 inode->u.generic_ip = obj;
636 obj->myInode = inode;
641 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_FileInode invalid parameters\n"));
646 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,yaffs_Object *obj)
648 struct inode * inode;
650 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_get_inode for object %d\n",obj->objectId));
652 inode = iget(sb,obj->objectId);
654 // NB Side effect: iget calls back to yaffs_read_inode().
655 // iget also increments the inode's i_count
660 static ssize_t yaffs_file_read(struct file *f, char *buf, size_t n, loff_t *pos)
667 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_read\n"));
669 obj = yaffs_DentryToObject(f->f_dentry);
673 yaffs_GrossLock(dev);
675 inode = f->f_dentry->d_inode;
677 if (*pos < inode->i_size)
679 if (*pos + n > inode->i_size)
681 n = inode->i_size - *pos;
689 nRead = yaffs_ReadDataFromFile(obj,buf,*pos,n);
695 yaffs_GrossUnlock(dev);
699 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_read read %d bytes, %d read at %d\n",n,nRead,ipos));
705 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, loff_t *pos)
713 obj = yaffs_DentryToObject(f->f_dentry);
717 yaffs_GrossLock(dev);
719 inode = f->f_dentry->d_inode;
721 if(!S_ISBLK(inode->i_mode) && f->f_flags & O_APPEND)
723 ipos = inode->i_size;
733 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write: hey obj is null!\n"));
737 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));
740 nWritten = yaffs_WriteDataToFile(obj,buf,ipos,n);
742 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write writing %d bytes, %d written at %d\n",n,nWritten,ipos));
747 if(ipos > inode->i_size)
749 inode->i_size = ipos;
750 inode->i_blocks = (ipos + 511)>>9;
752 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_file_write size updated to %d bytes, %d blocks\n",ipos,(int)(inode->i_blocks)));
756 yaffs_GrossUnlock(dev);
758 return nWritten != n ? -ENOSPC : nWritten;
762 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
766 struct inode *inode = f->f_dentry->d_inode;
767 unsigned long offset, curoffs;
771 char name[YAFFS_MAX_NAME_LENGTH +1];
773 obj = yaffs_DentryToObject(f->f_dentry);
776 yaffs_GrossLock(dev);
780 T(YAFFS_TRACE_OS,("yaffs_readdir: starting at %d\n",(int)offset));
784 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readdir: entry . ino %d \n",(int)inode->i_ino));
785 if(filldir(dirent,".",1,offset,inode->i_ino,DT_DIR) < 0)
794 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readdir: entry .. ino %d \n",(int)f->f_dentry->d_parent->d_inode->i_ino));
795 if(filldir(dirent,"..",2,offset,f->f_dentry->d_parent->d_inode->i_ino,DT_DIR) < 0)
805 list_for_each(i,&obj->variant.directoryVariant.children)
808 if(curoffs >= offset)
810 l = list_entry(i, yaffs_Object,siblings);
812 yaffs_GetObjectName(l,name,YAFFS_MAX_NAME_LENGTH+1);
813 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_readdir: %s inode %d\n",name,yaffs_GetObjectInode(l)));
819 yaffs_GetObjectInode(l),
820 yaffs_GetObjectType(l))
834 yaffs_GrossUnlock(dev);
841 * File creation. Allocate an inode, and we're done..
843 //#if defined(CONFIG_KERNEL_2_5)
844 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
845 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev)
847 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int rdev)
852 yaffs_Object *obj = NULL;
855 yaffs_Object *parent = yaffs_InodeToObject(dir);
861 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: parent object %d type %d\n",
862 parent->objectId,parent->variantType));
866 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: could not get parent object\n"));
870 T(YAFFS_TRACE_OS,("yaffs_mknod: making oject for %s, mode %x dev %x\n",
871 dentry->d_name.name, mode,rdev));
875 yaffs_GrossLock(dev);
877 switch (mode & S_IFMT)
880 // Special (socket, fifo, device...)
881 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making special\n"));
882 obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,rdev);
884 case S_IFREG: // file
885 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making file\n"));
886 obj = yaffs_MknodFile(parent,dentry->d_name.name,mode,current->uid, current->gid);
888 case S_IFDIR: // directory
889 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making directory\n"));
890 obj = yaffs_MknodDirectory(parent,dentry->d_name.name,mode,current->uid, current->gid);
892 case S_IFLNK: // symlink
893 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod: making file\n"));
894 obj = NULL; // Do we ever get here?
900 inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj);
901 d_instantiate(dentry, inode);
902 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod created object %d count = %d\n",obj->objectId,atomic_read(&inode->i_count)));
907 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mknod failed making object\n"));
911 yaffs_GrossUnlock(dev);
916 static int yaffs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
919 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_mkdir\n"));
920 retVal = yaffs_mknod(dir, dentry, mode | S_IFDIR, 0);
922 // attempt to fix dir bug - didn't work
931 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
932 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
933 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode, struct nameidata *n)
935 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode)
938 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_create\n"));
939 return yaffs_mknod(dir, dentry, mode | S_IFREG, 0);
943 static int yaffs_unlink(struct inode * dir, struct dentry *dentry)
950 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_unlink %d:%s\n",(int)(dir->i_ino),dentry->d_name.name));
952 dev = yaffs_InodeToObject(dir)->myDev;
954 yaffs_GrossLock(dev);
957 retVal = yaffs_Unlink(yaffs_InodeToObject(dir),dentry->d_name.name);
960 yaffs_GrossUnlock(dev);
962 if( retVal == YAFFS_OK)
964 dentry->d_inode->i_nlink--;
965 mark_inode_dirty(dentry->d_inode);
978 static int yaffs_link(struct dentry *old_dentry, struct inode * dir, struct dentry * dentry)
980 struct inode *inode = old_dentry->d_inode;
981 yaffs_Object *obj = NULL;
982 yaffs_Object *link=NULL;
985 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_link\n"));
987 obj = yaffs_InodeToObject(inode);
990 yaffs_GrossLock(dev);
992 if (!S_ISDIR(inode->i_mode)) // Don't link directories
994 link = yaffs_Link(yaffs_InodeToObject(dir),dentry->d_name.name,obj);
1000 old_dentry->d_inode->i_nlink = yaffs_GetObjectLinkCount(obj);
1001 d_instantiate(dentry, old_dentry->d_inode);
1002 atomic_inc(&old_dentry->d_inode->i_count);
1003 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_link link count %d i_count %d\n",
1004 old_dentry->d_inode->i_nlink,atomic_read(&old_dentry->d_inode->i_count)));
1008 yaffs_GrossUnlock(dev);
1022 static int yaffs_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
1027 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_symlink\n"));
1029 dev = yaffs_InodeToObject(dir)->myDev;
1030 yaffs_GrossLock(dev);
1031 obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name,
1032 S_IFLNK | S_IRWXUGO, current->uid, current->gid,
1034 yaffs_GrossUnlock(dev);
1039 struct inode* inode;
1041 inode = yaffs_get_inode(dir->i_sb, obj->st_mode, 0, obj);
1042 d_instantiate(dentry, inode);
1043 T(YAFFS_TRACE_OS,(KERN_DEBUG"symlink created OK\n"));
1048 T(YAFFS_TRACE_OS,(KERN_DEBUG"symlink not created\n"));
1055 static int yaffs_sync_object(struct file * file, struct dentry *dentry, int datasync)
1061 obj = yaffs_DentryToObject(dentry);
1065 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_sync_object\n"));
1066 yaffs_GrossLock(dev);
1067 yaffs_FlushFile(obj,1);
1068 yaffs_GrossUnlock(dev);
1073 * The VFS layer already does all the dentry stuff for rename.
1075 * NB: POSIX says you can rename an object over an old object of the same name
1077 static int yaffs_rename(struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry)
1080 int retVal = YAFFS_FAIL;
1082 yaffs_Object *target;
1084 dev = yaffs_InodeToObject(old_dir)->myDev;
1086 yaffs_GrossLock(dev);
1088 // Check if the target is an existing directory that is not empty.
1089 target = yaffs_FindObjectByName(yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
1092 target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
1093 !list_empty(&target->variant.directoryVariant.children))
1095 retVal = YAFFS_FAIL;
1100 // Unlink the target if it exists
1101 removed = yaffs_Unlink(yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
1104 retVal = yaffs_RenameObject(yaffs_InodeToObject(old_dir),old_dentry->d_name.name,
1105 yaffs_InodeToObject(new_dir),new_dentry->d_name.name);
1108 yaffs_GrossUnlock(dev);
1110 if(retVal == YAFFS_OK)
1112 if(removed == YAFFS_OK)
1114 new_dentry->d_inode->i_nlink--;
1115 mark_inode_dirty(new_dentry->d_inode);
1128 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr)
1130 struct inode *inode = dentry->d_inode;
1134 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_setattr of object %d\n",yaffs_InodeToObject(inode)->objectId));
1136 if((error = inode_change_ok(inode,attr)) == 0)
1139 dev = yaffs_InodeToObject(inode)->myDev;
1140 yaffs_GrossLock(dev);
1141 if(yaffs_SetAttributes(yaffs_InodeToObject(inode),attr) == YAFFS_OK)
1149 yaffs_GrossUnlock(dev);
1150 inode_setattr(inode,attr);
1155 //#if defined(CONFIG_KERNEL_2_5) /* Added NCB 185-8-2003 */
1156 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1157 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf)
1159 static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
1162 yaffs_Device *dev = yaffs_SuperToDevice(sb);
1163 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_statfs\n"));
1165 yaffs_GrossLock(dev);
1167 buf->f_type = YAFFS_MAGIC;
1168 buf->f_bsize = sb->s_blocksize;
1169 buf->f_namelen = 255;
1170 buf->f_blocks = (dev->endBlock - dev->startBlock + 1) * YAFFS_CHUNKS_PER_BLOCK/
1171 (sb->s_blocksize/YAFFS_BYTES_PER_CHUNK);
1174 buf->f_bfree = yaffs_GetNumberOfFreeChunks(dev)/
1175 (sb->s_blocksize/YAFFS_BYTES_PER_CHUNK);
1176 buf->f_bavail = buf->f_bfree;
1178 yaffs_GrossUnlock(dev);
1182 static void yaffs_read_inode (struct inode *inode)
1184 // NB This is called as a side effect of other functions and
1185 // thus gross locking should always be in place already.
1188 yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb);
1190 T(YAFFS_TRACE_OS,(KERN_DEBUG"yaffs_read_inode for %d\n",(int)inode->i_ino));
1192 obj = yaffs_FindObjectByNumber(dev,inode->i_ino);
1194 yaffs_FillInodeFromObject(inode,obj);
1200 static yaffs_Device *yaffs_dev;
1201 static yaffs_Device *yaffsram_dev;
1205 static void yaffs_put_super(struct super_block *sb)
1207 yaffs_Device *dev = yaffs_SuperToDevice(sb);
1209 yaffs_GrossLock(dev);
1210 if(dev->putSuperFunc)
1212 dev->putSuperFunc(sb);
1214 yaffs_Deinitialise(dev);
1215 yaffs_GrossUnlock(dev);
1217 if(dev == yaffs_dev) yaffs_dev = NULL;
1218 if(dev == yaffsram_dev) yaffsram_dev = NULL;
1224 #ifdef CONFIG_YAFFS_MTD_ENABLED
1226 static void yaffs_MTDPutSuper(struct super_block *sb)
1229 struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
1236 put_mtd_device(mtd);
1242 static struct super_block *yaffs_internal_read_super(int useRam, struct super_block * sb, void * data, int silent)
1245 struct inode * inode;
1246 struct dentry * root;
1249 sb->s_magic = YAFFS_MAGIC;
1250 sb->s_op = &yaffs_super_ops;
1253 printk(KERN_INFO"yaffs: sb is NULL\n");
1255 printk(KERN_INFO"yaffs: sb->s_dev is NULL\n");
1256 else if(! kdevname(sb->s_dev))
1257 printk(KERN_INFO"yaffs: kdevname is NULL\n");
1259 printk(KERN_INFO"yaffs: dev is %d name is \"%s\"\n", sb->s_dev, kdevname(sb->s_dev));
1263 #ifdef CONFIG_YAFFS_USE_CHUNK_SIZE
1264 sb->s_blocksize = YAFFS_BYTES_PER_CHUNK;
1265 sb->s_blocksize_bits = YAFFS_CHUNK_SIZE_SHIFT;
1267 sb->s_blocksize = PAGE_CACHE_SIZE;
1268 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
1270 T(YAFFS_TRACE_OS,("yaffs_read_super: %s block size %d\n", useRam ? "RAM" : "MTD",(int)(sb->s_blocksize)));
1272 #ifdef CONFIG_YAFFS_DISABLE_WRITE_VERIFY
1273 T(YAFFS_TRACE_OS,("yaffs: Write verification disabled. All guarantees null and void\n"));
1281 #ifdef CONFIG_YAFFS_RAM_ENABLED
1282 // Set the yaffs_Device up for ram emulation
1284 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
1287 // Deep shit could not allocate device structure
1288 printk(KERN_DEBUG"yaffs_read_super: Failed trying to allocate yaffs_Device. Terminating debug.\n");
1292 memset(dev,0,sizeof(yaffs_Device));
1293 dev->genericDevice = NULL; // Not used for RAM emulation.
1295 nBlocks = YAFFS_RAM_EMULATION_SIZE / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
1296 dev->startBlock = 1; // Don't use block 0
1297 dev->endBlock = nBlocks - 1;
1298 dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
1299 dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
1300 dev->nReservedBlocks = 5;
1302 dev->writeChunkToNAND = nandemul_WriteChunkToNAND;
1303 dev->readChunkFromNAND = nandemul_ReadChunkFromNAND;
1304 dev->eraseBlockInNAND = nandemul_EraseBlockInNAND;
1305 dev->initialiseNAND = nandemul_InitialiseNAND;
1314 #ifdef CONFIG_YAFFS_MTD_ENABLED
1315 struct mtd_info *mtd;
1317 printk(KERN_DEBUG "yaffs: Attempting MTD mount on %u.%u, \"%s\"\n",
1318 MAJOR(sb->s_dev),MINOR(sb->s_dev),kdevname(sb->s_dev));
1320 // Check it's an mtd device.....
1321 if(MAJOR(sb->s_dev) != MTD_BLOCK_MAJOR)
1323 return NULL; // This isn't an mtd device
1327 mtd = get_mtd_device(NULL, MINOR(sb->s_dev));
1330 printk(KERN_DEBUG "yaffs: MTD device #%u doesn't appear to exist\n", MINOR(sb->s_dev));
1335 if(mtd->type != MTD_NANDFLASH)
1337 printk(KERN_DEBUG "yaffs: MTD device is not NAND it's type %d\n", mtd->type);
1341 //printk(KERN_DEBUG" erase %x\n",mtd->erase);
1342 //printk(KERN_DEBUG" read %x\n",mtd->read);
1343 //printk(KERN_DEBUG" write %x\n",mtd->write);
1344 //printk(KERN_DEBUG" readoob %x\n",mtd->read_oob);
1345 //printk(KERN_DEBUG" writeoob %x\n",mtd->write_oob);
1346 //printk(KERN_DEBUG" oobblock %x\n",mtd->oobblock);
1347 //printk(KERN_DEBUG" oobsize %x\n",mtd->oobsize);
1353 #ifndef CONFIG_YAFFS_USE_OLD_MTD
1360 printk(KERN_DEBUG "yaffs: MTD device does not support required functions\n");
1364 if(mtd->oobblock != YAFFS_BYTES_PER_CHUNK ||
1365 mtd->oobsize != YAFFS_BYTES_PER_SPARE)
1367 printk(KERN_DEBUG "yaffs: MTD device does not support have the right page sizes\n");
1372 // OK, so if we got here, we have an MTD that's NAND and looks
1373 // like it has the right capabilities
1374 // Set the yaffs_Device up for ram emulation
1376 //#if defined(CONFIG_KERNEL_2_5)
1377 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1378 sb->s_fs_info = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
1380 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
1384 // Deep shit could not allocate device structure
1385 printk(KERN_DEBUG"yaffs_read_super: Failed trying to allocate yaffs_Device. Terminating debug.\n");
1389 memset(dev,0,sizeof(yaffs_Device));
1390 dev->genericDevice = mtd;
1392 // Set up the memory size parameters....
1394 nBlocks = mtd->size / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
1395 dev->startBlock = 1; // Don't use block 0
1396 dev->endBlock = nBlocks - 1;
1397 dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
1398 dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
1399 dev->nReservedBlocks = 5;
1400 dev->nShortOpCaches = 10; // Enable short op caching
1403 // ... and the functions.
1404 dev->writeChunkToNAND = nandmtd_WriteChunkToNAND;
1405 dev->readChunkFromNAND = nandmtd_ReadChunkFromNAND;
1406 dev->eraseBlockInNAND = nandmtd_EraseBlockInNAND;
1407 dev->initialiseNAND = nandmtd_InitialiseNAND;
1409 dev->putSuperFunc = yaffs_MTDPutSuper;
1411 #ifdef CONFIG_YAFFS_USE_NANDECC
1412 dev->useNANDECC = 1;
1420 init_MUTEX(&dev->grossLock);
1423 yaffs_GrossLock(dev);
1424 yaffs_GutsInitialise(yaffs_SuperToDevice(sb));
1426 T(YAFFS_TRACE_OS,("yaffs_read_super: guts initialised\n"));
1428 // Create root inode
1429 inode = yaffs_get_inode(sb, S_IFDIR | 0755, 0,yaffs_Root(yaffs_SuperToDevice(sb)));
1431 yaffs_GrossUnlock(dev);
1437 inode->i_op = & yaffs_dir_inode_operations;
1438 inode->i_fop = & yaffs_dir_operations;
1440 T(YAFFS_TRACE_OS,("yaffs_read_super: got root inode\n"));
1443 root = d_alloc_root(inode);
1445 T(YAFFS_TRACE_OS,("yaffs_read_super: d_alloc_root done\n"));
1453 T(YAFFS_TRACE_OS,("yaffs_read_super: done\n"));
1457 static int yaffs_internal_read_super_ram(struct super_block * sb, void * data, int silent)
1459 return yaffs_internal_read_super(1,sb,data,silent) ? 0 : -1;
1461 static int yaffs_internal_read_super_mtd(struct super_block * sb, void * data, int silent)
1463 return yaffs_internal_read_super(0,sb,data,silent) ? 0 : -1;
1467 #ifdef CONFIG_YAFFS_MTD_ENABLED
1468 //#if defined(CONFIG_KERNEL_2_5)
1469 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1470 static struct super_block *yaffs_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data)
1473 return get_sb_bdev(fs, flags, dev_name, data, yaffs_internal_read_super_mtd);
1476 /* changes NCB 2.5.70 */
1477 //static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
1478 static struct file_system_type yaffs_fs_type = {
1479 .owner = THIS_MODULE,
1481 .get_sb = yaffs_read_super,
1482 // .kill_sb = kill_block_super,
1483 .kill_sb = kill_litter_super,
1484 .fs_flags = FS_REQUIRES_DEV,
1487 static struct super_block *yaffs_read_super(struct super_block * sb, void * data, int silent)
1489 return yaffs_internal_read_super(0,sb,data,silent);
1492 static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
1496 #ifdef CONFIG_YAFFS_RAM_ENABLED
1498 //#if defined(CONFIG_KERNEL_2_5)
1499 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1500 static struct super_block *yaffs_ram_read_super(struct file_system_type * fs, int flags, const char *dev_name, void *data)
1503 return get_sb_bdev(fs, flags, dev_name, data, yaffs_internal_read_super_ram);
1506 /* changes NCB 2.5.70 */
1507 //static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
1508 static struct file_system_type yaffs_fs_type = {
1509 .owner = THIS_MODULE,
1511 .get_sb = yaffs_ram_read_super,
1512 // .kill_sb = kill_block_super,
1513 .kill_sb = kill_litter_super,
1514 .fs_flags = FS_SINGLE,
1517 static struct super_block *yaffs_ram_read_super(struct super_block * sb, void * data, int silent)
1519 return yaffs_internal_read_super(1,sb,data,silent);
1522 static DECLARE_FSTYPE(yaffs_ram_fs_type, "yaffsram", yaffs_ram_read_super, FS_SINGLE);
1524 #endif // CONFIG_YAFFS_RAM_ENABLED
1527 static struct proc_dir_entry *my_proc_entry;
1528 static struct proc_dir_entry *my_proc_ram_write_entry;
1530 static char * yaffs_dump_dev(char *buf,yaffs_Device *dev,char *name)
1532 buf +=sprintf(buf,"\nDevice %s\n",name);
1533 buf +=sprintf(buf,"startBlock......... %d\n",dev->startBlock);
1534 buf +=sprintf(buf,"endBlock........... %d\n",dev->endBlock);
1535 buf +=sprintf(buf,"chunkGroupBits..... %d\n",dev->chunkGroupBits);
1536 buf +=sprintf(buf,"chunkGroupSize..... %d\n",dev->chunkGroupSize);
1537 buf +=sprintf(buf,"nErasedBlocks...... %d\n",dev->nErasedBlocks);
1538 buf +=sprintf(buf,"nTnodesCreated..... %d\n",dev->nTnodesCreated);
1539 buf +=sprintf(buf,"nFreeTnodes........ %d\n",dev->nFreeTnodes);
1540 buf +=sprintf(buf,"nObjectsCreated.... %d\n",dev->nObjectsCreated);
1541 buf +=sprintf(buf,"nFreeObjects....... %d\n",dev->nFreeObjects);
1542 buf +=sprintf(buf,"nFreeChunks........ %d\n",dev->nFreeChunks);
1543 buf +=sprintf(buf,"nPageWrites........ %d\n",dev->nPageWrites);
1544 buf +=sprintf(buf,"nPageReads......... %d\n",dev->nPageReads);
1545 buf +=sprintf(buf,"nBlockErasures..... %d\n",dev->nBlockErasures);
1546 buf +=sprintf(buf,"nGCCopies.......... %d\n",dev->nGCCopies);
1547 buf +=sprintf(buf,"garbageCollections. %d\n",dev->garbageCollections);
1548 buf +=sprintf(buf,"passiveGCs......... %d\n",dev->passiveGarbageCollections);
1549 buf +=sprintf(buf,"nRetriedWrites..... %d\n",dev->nRetriedWrites);
1550 buf +=sprintf(buf,"nRetireBlocks...... %d\n",dev->nRetiredBlocks);
1551 buf +=sprintf(buf,"eccFixed........... %d\n",dev->eccFixed);
1552 buf +=sprintf(buf,"eccUnfixed......... %d\n",dev->eccUnfixed);
1553 buf +=sprintf(buf,"tagsEccFixed....... %d\n",dev->tagsEccFixed);
1554 buf +=sprintf(buf,"tagsEccUnfixed..... %d\n",dev->tagsEccUnfixed);
1555 buf +=sprintf(buf,"cacheHits.......... %d\n",dev->cacheHits);
1556 buf +=sprintf(buf,"nDeletedFiles...... %d\n",dev->nDeletedFiles);
1557 buf +=sprintf(buf,"nUnlinkedFiles..... %d\n",dev->nUnlinkedFiles);
1558 buf +=sprintf(buf,"nBackgroudDeletions %d\n",dev->nBackgroundDeletions);
1559 buf +=sprintf(buf,"useNANDECC......... %d\n",dev->useNANDECC);
1565 static int yaffs_proc_read(
1575 char my_buffer[3000];
1579 if (offset > 0) return 0;
1581 /* Fill the buffer and get its length */
1582 buf +=sprintf(buf,"YAFFS built:"__DATE__ " "__TIME__"\n%s\n%s\n", yaffs_fs_c_version,yaffs_guts_c_version);
1584 if(yaffs_dev) buf = yaffs_dump_dev(buf,yaffs_dev,"yaffs");
1585 if(yaffsram_dev) buf = yaffs_dump_dev(buf,yaffsram_dev,"yaffsram");
1588 strcpy(page,my_buffer);
1589 return strlen(my_buffer);
1593 static int yaffs_proc_ram_write(
1603 printk(KERN_DEBUG "yaffs write size %d\n",count);
1607 static int __init init_yaffs_fs(void)
1611 yaffs_dev = yaffsram_dev = NULL;
1613 printk(KERN_DEBUG "yaffs " __DATE__ " " __TIME__ " Initialisation\n");
1614 #ifdef CONFIG_YAFFS_USE_GENERIC_RW
1615 printk(KERN_DEBUG "yaffs is using generic read/write (caching)\n");
1617 printk(KERN_DEBUG "yaffs is using direct read/write (uncached)\n");
1621 /* Install the proc_fs entry */
1622 my_proc_entry = create_proc_read_entry("yaffs",
1632 #ifdef CONFIG_YAFFS_RAM_ENABLED
1634 my_proc_ram_write_entry = create_proc_entry("yaffs_ram",
1638 if(!my_proc_ram_write_entry)
1644 my_proc_ram_write_entry->write_proc = yaffs_proc_ram_write;
1648 error = register_filesystem(&yaffs_ram_fs_type);
1653 #endif //CONFIG_YAFFS_RAM_ENABLED
1655 #ifdef CONFIG_YAFFS_MTD_ENABLED
1656 error = register_filesystem(&yaffs_fs_type);
1659 #ifdef CONFIG_YAFFS_RAM_ENABLED
1660 unregister_filesystem(&yaffs_ram_fs_type);
1661 #endif //CONFIG_YAFFS_RAM_ENABLED
1663 #endif // CONFIG_YAFFS_MTD_ENABLED
1668 static void __exit exit_yaffs_fs(void)
1670 printk(KERN_DEBUG "yaffs " __DATE__ " " __TIME__ " Clean up\n");
1672 remove_proc_entry("yaffs",&proc_root);
1674 #ifdef CONFIG_YAFFS_RAM_ENABLED
1675 unregister_filesystem(&yaffs_ram_fs_type);
1677 #ifdef CONFIG_YAFFS_MTD_ENABLED
1678 unregister_filesystem(&yaffs_fs_type);
1683 module_init(init_yaffs_fs)
1684 module_exit(exit_yaffs_fs)
1686 MODULE_DESCRIPTION("YAFFS - a NAND specific flash file system");
1687 MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002");
1688 MODULE_LICENSE("GPL");