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 * >> 2.4: sb->u.generic_sbp points to the yaffs_Device associated with
20 * >> 2.6: sb->s_fs_info points to the yaffs_Device associated with this
22 * >> inode->u.generic_ip points to the associated yaffs_Object.
25 * * Luc van OostenRyck for numerous patches.
26 * * Nick Bane for numerous patches.
27 * * Nick Bane for 2.5/2.6 integration.
28 * * Andras Toth for mknod rdev issue.
29 * * Michael Fischer for finding the problem with inode inconsistency.
30 * * Some code bodily lifted from JFFS2.
33 const char *yaffs_fs_c_version =
34 "$Id: yaffs_fs.c,v 1.31 2005-09-21 01:14:03 charles Exp $";
35 extern const char *yaffs_guts_c_version;
37 #include <linux/config.h>
38 #include <linux/kernel.h>
39 #include <linux/module.h>
40 #include <linux/version.h>
41 #include <linux/slab.h>
42 #include <linux/init.h>
43 #include <linux/list.h>
45 #include <linux/proc_fs.h>
46 #include <linux/smp_lock.h>
47 #include <linux/pagemap.h>
48 #include <linux/mtd/mtd.h>
49 #include <linux/interrupt.h>
50 #include <linux/string.h>
52 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
54 #include <linux/statfs.h> /* Added NCB 15-8-2003 */
55 #include <asm/statfs.h>
56 #define UnlockPage(p) unlock_page(p)
57 #define Page_Uptodate(page) test_bit(PG_uptodate, &(page)->flags)
59 /* FIXME: use sb->s_id instead ? */
60 #define yaffs_devname(sb, buf) bdevname(sb->s_bdev, buf)
64 #include <linux/locks.h>
65 #define BDEVNAME_SIZE 0
66 #define yaffs_devname(sb, buf) kdevname(sb->s_dev)
70 #include <asm/uaccess.h>
73 #include "yaffs_guts.h"
75 unsigned yaffs_traceMask = YAFFS_TRACE_ALWAYS | YAFFS_TRACE_BAD_BLOCKS /* | 0xFFFFFFFF */;
77 #include <linux/mtd/mtd.h>
78 #include "yaffs_mtdif.h"
79 #include "yaffs_mtdif2.h"
81 /*#define T(x) printk x */
83 #define yaffs_InodeToObject(iptr) ((yaffs_Object *)((iptr)->u.generic_ip))
84 #define yaffs_DentryToObject(dptr) yaffs_InodeToObject((dptr)->d_inode)
86 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
87 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->s_fs_info)
89 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->u.generic_sbp)
92 static void yaffs_put_super(struct super_block *sb);
94 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
97 static int yaffs_file_flush(struct file *file);
99 static int yaffs_sync_object(struct file *file, struct dentry *dentry,
102 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir);
104 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
105 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode,
106 struct nameidata *n);
107 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry,
108 struct nameidata *n);
110 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode);
111 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry);
113 static int yaffs_link(struct dentry *old_dentry, struct inode *dir,
114 struct dentry *dentry);
115 static int yaffs_unlink(struct inode *dir, struct dentry *dentry);
116 static int yaffs_symlink(struct inode *dir, struct dentry *dentry,
117 const char *symname);
118 static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
120 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
121 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
124 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
127 static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
128 struct inode *new_dir, struct dentry *new_dentry);
129 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr);
131 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
132 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf);
134 static int yaffs_statfs(struct super_block *sb, struct statfs *buf);
136 static void yaffs_read_inode(struct inode *inode);
138 static void yaffs_put_inode(struct inode *inode);
139 static void yaffs_delete_inode(struct inode *);
140 static void yaffs_clear_inode(struct inode *);
142 static int yaffs_readpage(struct file *file, struct page *page);
143 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
144 static int yaffs_writepage(struct page *page, struct writeback_control *wbc);
146 static int yaffs_writepage(struct page *page);
148 static int yaffs_prepare_write(struct file *f, struct page *pg,
149 unsigned offset, unsigned to);
150 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset,
153 static int yaffs_readlink(struct dentry *dentry, char __user * buffer,
155 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd);
157 static struct address_space_operations yaffs_file_address_operations = {
158 .readpage = yaffs_readpage,
159 .writepage = yaffs_writepage,
160 .prepare_write = yaffs_prepare_write,
161 .commit_write = yaffs_commit_write,
164 static struct file_operations yaffs_file_operations = {
165 .read = generic_file_read,
166 .write = generic_file_write,
167 .mmap = generic_file_mmap,
168 .flush = yaffs_file_flush,
169 .fsync = yaffs_sync_object,
172 static struct inode_operations yaffs_file_inode_operations = {
173 .setattr = yaffs_setattr,
176 static struct inode_operations yaffs_symlink_inode_operations = {
177 .readlink = yaffs_readlink,
178 .follow_link = yaffs_follow_link,
179 .setattr = yaffs_setattr,
182 static struct inode_operations yaffs_dir_inode_operations = {
183 .create = yaffs_create,
184 .lookup = yaffs_lookup,
186 .unlink = yaffs_unlink,
187 .symlink = yaffs_symlink,
188 .mkdir = yaffs_mkdir,
189 .rmdir = yaffs_unlink,
190 .mknod = yaffs_mknod,
191 .rename = yaffs_rename,
192 .setattr = yaffs_setattr,
195 static struct file_operations yaffs_dir_operations = {
196 .read = generic_read_dir,
197 .readdir = yaffs_readdir,
198 .fsync = yaffs_sync_object,
201 static struct super_operations yaffs_super_ops = {
202 .statfs = yaffs_statfs,
203 .read_inode = yaffs_read_inode,
204 .put_inode = yaffs_put_inode,
205 .put_super = yaffs_put_super,
206 .delete_inode = yaffs_delete_inode,
207 .clear_inode = yaffs_clear_inode,
210 static void yaffs_GrossLock(yaffs_Device * dev)
212 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs locking\n"));
214 down(&dev->grossLock);
217 static void yaffs_GrossUnlock(yaffs_Device * dev)
219 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs unlocking\n"));
224 static int yaffs_readlink(struct dentry *dentry, char __user * buffer,
227 unsigned char *alias;
230 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
232 yaffs_GrossLock(dev);
234 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
236 yaffs_GrossUnlock(dev);
241 ret = vfs_readlink(dentry, buffer, buflen, alias);
246 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd)
248 unsigned char *alias;
250 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
252 yaffs_GrossLock(dev);
254 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
256 yaffs_GrossUnlock(dev);
261 ret = vfs_follow_link(nd, alias);
266 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,
270 * Lookup is used to find objects in the fs
272 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
274 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry,
277 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry)
281 struct inode *inode = NULL; /* NCB 2.5/2.6 needs NULL here */
283 yaffs_Device *dev = yaffs_InodeToObject(dir)->myDev;
285 yaffs_GrossLock(dev);
288 (KERN_DEBUG "yaffs_lookup for %d:%s\n",
289 yaffs_InodeToObject(dir)->objectId, dentry->d_name.name));
292 yaffs_FindObjectByName(yaffs_InodeToObject(dir),
293 dentry->d_name.name);
295 obj = yaffs_GetEquivalentObject(obj); /* in case it was a hardlink */
299 (KERN_DEBUG "yaffs_lookup found %d\n", obj->objectId));
301 inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj);
305 (KERN_DEBUG "yaffs_loookup dentry \n"));
306 /* #if 0 asserted by NCB for 2.5/6 compatability - falls through to
307 * d_add even if NULL inode */
309 /*dget(dentry); // try to solve directory bug */
310 d_add(dentry, inode);
312 yaffs_GrossUnlock(dev);
320 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_lookup not found\n"));
323 yaffs_GrossUnlock(dev);
325 /* added NCB for 2.5/6 compatability - forces add even if inode is
326 * NULL which creates dentry hash */
327 d_add(dentry, inode);
330 /* return (ERR_PTR(-EIO)); */
334 /* For now put inode is just for debugging
335 * Put inode is called when the inode **structure** is put.
337 static void yaffs_put_inode(struct inode *inode)
340 ("yaffs_put_inode: ino %d, count %d\n", (int)inode->i_ino,
341 atomic_read(&inode->i_count)));
345 /* clear is called to tell the fs to release any per-inode data it holds */
346 static void yaffs_clear_inode(struct inode *inode)
351 obj = yaffs_InodeToObject(inode);
354 ("yaffs_clear_inode: ino %d, count %d %s\n", (int)inode->i_ino,
355 atomic_read(&inode->i_count),
356 obj ? "object exists" : "null object"));
360 yaffs_GrossLock(dev);
362 /* Clear the association between the inode and
366 inode->u.generic_ip = NULL;
368 /* If the object freeing was deferred, then the real
370 * This should fix the inode inconsistency problem.
373 yaffs_HandleDeferedFree(obj);
375 yaffs_GrossUnlock(dev);
380 /* delete is called when the link count is zero and the inode
381 * is put (ie. nobody wants to know about it anymore, time to
383 * NB Must call clear_inode()
385 static void yaffs_delete_inode(struct inode *inode)
387 yaffs_Object *obj = yaffs_InodeToObject(inode);
391 ("yaffs_delete_inode: ino %d, count %d %s\n", (int)inode->i_ino,
392 atomic_read(&inode->i_count),
393 obj ? "object exists" : "null object"));
397 yaffs_GrossLock(dev);
398 yaffs_DeleteFile(obj);
399 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;
411 (KERN_DEBUG "yaffs_file_flush object %d (%s)\n", obj->objectId,
412 obj->dirty ? "dirty" : "clean"));
414 yaffs_GrossLock(dev);
416 yaffs_FlushFile(obj, 1);
418 yaffs_GrossUnlock(dev);
423 static int yaffs_readpage_nolock(struct file *f, struct page *pg)
425 /* Lifted from jffs2 */
428 unsigned char *pg_buf;
433 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_readpage at %08x, size %08x\n",
434 (unsigned)(pg->index << PAGE_CACHE_SHIFT),
435 (unsigned)PAGE_CACHE_SIZE));
437 obj = yaffs_DentryToObject(f->f_dentry);
441 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
442 BUG_ON(!PageLocked(pg));
449 /* FIXME: Can kmap fail? */
451 yaffs_GrossLock(dev);
454 yaffs_ReadDataFromFile(obj, pg_buf, pg->index << PAGE_CACHE_SHIFT,
457 yaffs_GrossUnlock(dev);
463 ClearPageUptodate(pg);
470 flush_dcache_page(pg);
473 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_readpage done\n"));
477 static int yaffs_readpage_unlock(struct file *f, struct page *pg)
479 int ret = yaffs_readpage_nolock(f, pg);
484 static int yaffs_readpage(struct file *f, struct page *pg)
486 return yaffs_readpage_unlock(f, pg);
489 /* writepage inspired by/stolen from smbfs */
491 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
492 static int yaffs_writepage(struct page *page, struct writeback_control *wbc)
494 static int yaffs_writepage(struct page *page)
497 struct address_space *mapping = page->mapping;
498 loff_t offset = (loff_t) page->index << PAGE_CACHE_SHIFT;
500 unsigned long end_index;
508 inode = mapping->host;
512 if (offset > inode->i_size) {
515 "yaffs_writepage at %08x, inode size = %08x!!!\n",
516 (unsigned)(page->index << PAGE_CACHE_SHIFT),
517 (unsigned)inode->i_size));
519 (KERN_DEBUG " -> don't care!!\n"));
524 end_index = inode->i_size >> PAGE_CACHE_SHIFT;
527 if (page->index < end_index) {
528 nBytes = PAGE_CACHE_SIZE;
530 nBytes = inode->i_size & (PAGE_CACHE_SIZE - 1);
537 obj = yaffs_InodeToObject(inode);
538 yaffs_GrossLock(obj->myDev);
541 (KERN_DEBUG "yaffs_writepage at %08x, size %08x\n",
542 (unsigned)(page->index << PAGE_CACHE_SHIFT), nBytes));
544 (KERN_DEBUG "writepag0: obj = %05x, ino = %05x\n",
545 (int)obj->variant.fileVariant.fileSize, (int)inode->i_size));
548 yaffs_WriteDataToFile(obj, buffer, page->index << PAGE_CACHE_SHIFT,
552 (KERN_DEBUG "writepag1: obj = %05x, ino = %05x\n",
553 (int)obj->variant.fileVariant.fileSize, (int)inode->i_size));
555 yaffs_GrossUnlock(obj->myDev);
558 SetPageUptodate(page);
562 return (nWritten == nBytes) ? 0 : -ENOSPC;
565 static int yaffs_prepare_write(struct file *f, struct page *pg,
566 unsigned offset, unsigned to)
569 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_prepair_write\n"));
570 if (!Page_Uptodate(pg) && (offset || to < PAGE_CACHE_SIZE))
571 return yaffs_readpage_nolock(f, pg);
577 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset,
581 void *addr = page_address(pg) + offset;
582 loff_t pos = (((loff_t) pg->index) << PAGE_CACHE_SHIFT) + offset;
583 int nBytes = to - offset;
587 unsigned saddr = (unsigned)addr;
590 (KERN_DEBUG "yaffs_commit_write addr %x pos %x nBytes %d\n", saddr,
593 nWritten = yaffs_file_write(f, addr, nBytes, &pos);
595 if (nWritten != nBytes) {
598 "yaffs_commit_write not same size nWritten %d nBytes %d\n",
601 ClearPageUptodate(pg);
607 (KERN_DEBUG "yaffs_commit_write returning %d\n", nWritten));
613 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object * obj)
616 inode->i_ino = obj->objectId;
617 inode->i_mode = obj->yst_mode;
618 inode->i_uid = obj->yst_uid;
619 inode->i_gid = obj->yst_gid;
620 inode->i_blksize = inode->i_sb->s_blocksize;
621 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
623 inode->i_rdev = old_decode_dev(obj->yst_rdev);
624 inode->i_atime.tv_sec = (time_t) (obj->yst_atime);
625 inode->i_atime.tv_nsec = 0;
626 inode->i_mtime.tv_sec = (time_t) obj->yst_mtime;
627 inode->i_mtime.tv_nsec = 0;
628 inode->i_ctime.tv_sec = (time_t) obj->yst_ctime;
629 inode->i_ctime.tv_nsec = 0;
631 inode->i_rdev = obj->yst_rdev;
632 inode->i_atime = obj->yst_atime;
633 inode->i_mtime = obj->yst_mtime;
634 inode->i_ctime = obj->yst_ctime;
636 inode->i_size = yaffs_GetObjectFileLength(obj);
637 inode->i_blocks = (inode->i_size + 511) >> 9;
639 inode->i_nlink = yaffs_GetObjectLinkCount(obj);
643 "yaffs_FillInode mode %x uid %d gid %d size %d count %d\n",
644 inode->i_mode, inode->i_uid, inode->i_gid,
645 (int)inode->i_size, atomic_read(&inode->i_count)));
647 switch (obj->yst_mode & S_IFMT) {
648 default: /* fifo, device or socket */
649 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
650 init_special_inode(inode, obj->yst_mode,
651 old_decode_dev(obj->yst_rdev));
653 init_special_inode(inode, obj->yst_mode,
654 (dev_t) (obj->yst_rdev));
657 case S_IFREG: /* file */
658 inode->i_op = &yaffs_file_inode_operations;
659 inode->i_fop = &yaffs_file_operations;
660 inode->i_mapping->a_ops =
661 &yaffs_file_address_operations;
663 case S_IFDIR: /* directory */
664 inode->i_op = &yaffs_dir_inode_operations;
665 inode->i_fop = &yaffs_dir_operations;
667 case S_IFLNK: /* symlink */
668 inode->i_op = &yaffs_symlink_inode_operations;
672 inode->u.generic_ip = obj;
673 obj->myInode = inode;
677 (KERN_DEBUG "yaffs_FileInode invalid parameters\n"));
682 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,
689 (KERN_DEBUG "yaffs_get_inode for NULL super_block!!\n"));
696 (KERN_DEBUG "yaffs_get_inode for NULL object!!\n"));
702 (KERN_DEBUG "yaffs_get_inode for object %d\n", obj->objectId));
704 inode = iget(sb, obj->objectId);
706 /* NB Side effect: iget calls back to yaffs_read_inode(). */
707 /* iget also increments the inode's i_count */
712 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
720 obj = yaffs_DentryToObject(f->f_dentry);
724 yaffs_GrossLock(dev);
726 inode = f->f_dentry->d_inode;
728 if (!S_ISBLK(inode->i_mode) && f->f_flags & O_APPEND) {
729 ipos = inode->i_size;
736 (KERN_DEBUG "yaffs_file_write: hey obj is null!\n"));
740 "yaffs_file_write about to write writing %d bytes"
741 "to object %d at %d\n",
742 n, obj->objectId, ipos));
745 nWritten = yaffs_WriteDataToFile(obj, buf, ipos, n, 0);
748 (KERN_DEBUG "yaffs_file_write writing %d bytes, %d written at %d\n",
753 if (ipos > inode->i_size) {
754 inode->i_size = ipos;
755 inode->i_blocks = (ipos + 511) >> 9;
759 "yaffs_file_write size updated to %d bytes, "
761 ipos, (int)(inode->i_blocks)));
765 yaffs_GrossUnlock(dev);
767 return nWritten != n ? -ENOSPC : nWritten;
770 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
774 struct inode *inode = f->f_dentry->d_inode;
775 unsigned long offset, curoffs;
779 char name[YAFFS_MAX_NAME_LENGTH + 1];
781 obj = yaffs_DentryToObject(f->f_dentry);
784 yaffs_GrossLock(dev);
788 T(YAFFS_TRACE_OS, ("yaffs_readdir: starting at %d\n", (int)offset));
792 (KERN_DEBUG "yaffs_readdir: entry . ino %d \n",
794 if (filldir(dirent, ".", 1, offset, inode->i_ino, DT_DIR)
803 (KERN_DEBUG "yaffs_readdir: entry .. ino %d \n",
804 (int)f->f_dentry->d_parent->d_inode->i_ino));
806 (dirent, "..", 2, offset,
807 f->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) {
816 list_for_each(i, &obj->variant.directoryVariant.children) {
818 if (curoffs >= offset) {
819 l = list_entry(i, yaffs_Object, siblings);
821 yaffs_GetObjectName(l, name,
822 YAFFS_MAX_NAME_LENGTH + 1);
824 (KERN_DEBUG "yaffs_readdir: %s inode %d\n", name,
825 yaffs_GetObjectInode(l)));
831 yaffs_GetObjectInode(l),
832 yaffs_GetObjectType(l))
845 yaffs_GrossUnlock(dev);
851 * File creation. Allocate an inode, and we're done..
853 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
854 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
857 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
863 yaffs_Object *obj = NULL;
866 yaffs_Object *parent = yaffs_InodeToObject(dir);
869 uid_t uid = current->fsuid;
870 gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
874 (KERN_DEBUG "yaffs_mknod: parent object %d type %d\n",
875 parent->objectId, parent->variantType));
878 (KERN_DEBUG "yaffs_mknod: could not get parent object\n"));
882 T(YAFFS_TRACE_OS, ("yaffs_mknod: making oject for %s, "
884 dentry->d_name.name, mode, rdev));
888 yaffs_GrossLock(dev);
890 switch (mode & S_IFMT) {
892 /* Special (socket, fifo, device...) */
893 T(YAFFS_TRACE_OS, (KERN_DEBUG
894 "yaffs_mknod: making special\n"));
895 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
897 yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid,
898 gid, old_encode_dev(rdev));
901 yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid,
905 case S_IFREG: /* file */
906 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_mknod: making file\n"));
908 yaffs_MknodFile(parent, dentry->d_name.name, mode, uid,
911 case S_IFDIR: /* directory */
913 (KERN_DEBUG "yaffs_mknod: making directory\n"));
915 yaffs_MknodDirectory(parent, dentry->d_name.name, mode,
918 case S_IFLNK: /* symlink */
919 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_mknod: making file\n"));
920 obj = NULL; /* Do we ever get here? */
925 inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj);
926 d_instantiate(dentry, inode);
928 (KERN_DEBUG "yaffs_mknod created object %d count = %d\n",
929 obj->objectId, atomic_read(&inode->i_count)));
933 (KERN_DEBUG "yaffs_mknod failed making object\n"));
937 yaffs_GrossUnlock(dev);
942 static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
945 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_mkdir\n"));
946 retVal = yaffs_mknod(dir, dentry, mode | S_IFDIR, 0);
948 /* attempt to fix dir bug - didn't work */
956 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
957 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode,
960 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode)
963 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_create\n"));
964 return yaffs_mknod(dir, dentry, mode | S_IFREG, 0);
967 static int yaffs_unlink(struct inode *dir, struct dentry *dentry)
974 (KERN_DEBUG "yaffs_unlink %d:%s\n", (int)(dir->i_ino),
975 dentry->d_name.name));
977 dev = yaffs_InodeToObject(dir)->myDev;
979 yaffs_GrossLock(dev);
981 retVal = yaffs_Unlink(yaffs_InodeToObject(dir), dentry->d_name.name);
983 yaffs_GrossUnlock(dev);
985 if (retVal == YAFFS_OK) {
986 dentry->d_inode->i_nlink--;
987 mark_inode_dirty(dentry->d_inode);
997 static int yaffs_link(struct dentry *old_dentry, struct inode *dir,
998 struct dentry *dentry)
1000 struct inode *inode = old_dentry->d_inode;
1001 yaffs_Object *obj = NULL;
1002 yaffs_Object *link = NULL;
1005 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_link\n"));
1007 obj = yaffs_InodeToObject(inode);
1010 yaffs_GrossLock(dev);
1012 if (!S_ISDIR(inode->i_mode)) /* Don't link directories */
1015 yaffs_Link(yaffs_InodeToObject(dir), dentry->d_name.name,
1020 old_dentry->d_inode->i_nlink = yaffs_GetObjectLinkCount(obj);
1021 d_instantiate(dentry, old_dentry->d_inode);
1022 atomic_inc(&old_dentry->d_inode->i_count);
1024 (KERN_DEBUG "yaffs_link link count %d i_count %d\n",
1025 old_dentry->d_inode->i_nlink,
1026 atomic_read(&old_dentry->d_inode->i_count)));
1030 yaffs_GrossUnlock(dev);
1040 static int yaffs_symlink(struct inode *dir, struct dentry *dentry,
1041 const char *symname)
1045 uid_t uid = current->fsuid;
1046 gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
1048 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_symlink\n"));
1050 dev = yaffs_InodeToObject(dir)->myDev;
1051 yaffs_GrossLock(dev);
1052 obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name,
1053 S_IFLNK | S_IRWXUGO, uid, gid, symname);
1054 yaffs_GrossUnlock(dev);
1058 struct inode *inode;
1060 inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj);
1061 d_instantiate(dentry, inode);
1062 T(YAFFS_TRACE_OS, (KERN_DEBUG "symlink created OK\n"));
1065 T(YAFFS_TRACE_OS, (KERN_DEBUG "symlink not created\n"));
1072 static int yaffs_sync_object(struct file *file, struct dentry *dentry,
1079 obj = yaffs_DentryToObject(dentry);
1083 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_sync_object\n"));
1084 yaffs_GrossLock(dev);
1085 yaffs_FlushFile(obj, 1);
1086 yaffs_GrossUnlock(dev);
1091 * The VFS layer already does all the dentry stuff for rename.
1093 * NB: POSIX says you can rename an object over an old object of the same name
1095 static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
1096 struct inode *new_dir, struct dentry *new_dentry)
1099 int retVal = YAFFS_FAIL;
1100 yaffs_Object *target;
1102 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_rename\n"));
1103 dev = yaffs_InodeToObject(old_dir)->myDev;
1105 yaffs_GrossLock(dev);
1107 /* Check if the target is an existing directory that is not empty. */
1109 yaffs_FindObjectByName(yaffs_InodeToObject(new_dir),
1110 new_dentry->d_name.name);
1115 target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
1116 !list_empty(&target->variant.directoryVariant.children)) {
1118 T(YAFFS_TRACE_OS, (KERN_DEBUG "target is non-empty dir\n"));
1120 retVal = YAFFS_FAIL;
1123 /* Now does unlinking internally using shadowing mechanism */
1124 T(YAFFS_TRACE_OS, (KERN_DEBUG "calling yaffs_RenameObject\n"));
1127 yaffs_RenameObject(yaffs_InodeToObject(old_dir),
1128 old_dentry->d_name.name,
1129 yaffs_InodeToObject(new_dir),
1130 new_dentry->d_name.name);
1133 yaffs_GrossUnlock(dev);
1135 if (retVal == YAFFS_OK) {
1137 new_dentry->d_inode->i_nlink--;
1138 mark_inode_dirty(new_dentry->d_inode);
1148 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr)
1150 struct inode *inode = dentry->d_inode;
1155 (KERN_DEBUG "yaffs_setattr of object %d\n",
1156 yaffs_InodeToObject(inode)->objectId));
1158 if ((error = inode_change_ok(inode, attr)) == 0) {
1160 dev = yaffs_InodeToObject(inode)->myDev;
1161 yaffs_GrossLock(dev);
1162 if (yaffs_SetAttributes(yaffs_InodeToObject(inode), attr) ==
1168 yaffs_GrossUnlock(dev);
1170 error = inode_setattr(inode, attr);
1175 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1176 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf)
1178 static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
1182 yaffs_Device *dev = yaffs_SuperToDevice(sb);
1183 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_statfs\n"));
1185 yaffs_GrossLock(dev);
1187 buf->f_type = YAFFS_MAGIC;
1188 buf->f_bsize = sb->s_blocksize;
1189 buf->f_namelen = 255;
1190 if (sb->s_blocksize > dev->nBytesPerChunk) {
1193 (dev->endBlock - dev->startBlock +
1194 1) * dev->nChunksPerBlock / (sb->s_blocksize /
1195 dev->nBytesPerChunk);
1197 yaffs_GetNumberOfFreeChunks(dev) / (sb->s_blocksize /
1198 dev->nBytesPerChunk);
1202 (dev->endBlock - dev->startBlock +
1203 1) * dev->nChunksPerBlock * (dev->nBytesPerChunk /
1206 yaffs_GetNumberOfFreeChunks(dev) * (dev->nBytesPerChunk /
1211 buf->f_bavail = buf->f_bfree;
1213 yaffs_GrossUnlock(dev);
1217 static void yaffs_read_inode(struct inode *inode)
1219 /* NB This is called as a side effect of other functions and
1220 * thus gross locking should always be in place already.
1224 yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb);
1227 (KERN_DEBUG "yaffs_read_inode for %d\n", (int)inode->i_ino));
1229 obj = yaffs_FindObjectByNumber(dev, inode->i_ino);
1231 yaffs_FillInodeFromObject(inode, obj);
1235 static LIST_HEAD(yaffs_dev_list);
1237 static void yaffs_put_super(struct super_block *sb)
1239 yaffs_Device *dev = yaffs_SuperToDevice(sb);
1241 yaffs_GrossLock(dev);
1242 if (dev->putSuperFunc) {
1243 dev->putSuperFunc(sb);
1245 yaffs_Deinitialise(dev);
1246 yaffs_GrossUnlock(dev);
1248 /* we assume this is protected by lock_kernel() in mount/umount */
1249 list_del(&dev->devList);
1255 static void yaffs_MTDPutSuper(struct super_block *sb)
1258 struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
1264 put_mtd_device(mtd);
1268 static struct super_block *yaffs_internal_read_super(int yaffsVersion,
1269 struct super_block *sb,
1270 void *data, int silent)
1273 struct inode *inode = NULL;
1274 struct dentry *root;
1275 yaffs_Device *dev = 0;
1276 char devname_buf[BDEVNAME_SIZE + 1];
1277 struct mtd_info *mtd;
1280 sb->s_magic = YAFFS_MAGIC;
1281 sb->s_op = &yaffs_super_ops;
1284 printk(KERN_INFO "yaffs: sb is NULL\n");
1285 else if (!sb->s_dev)
1286 printk(KERN_INFO "yaffs: sb->s_dev is NULL\n");
1287 else if (!yaffs_devname(sb, devname_buf))
1288 printk(KERN_INFO "yaffs: devname is NULL\n");
1290 printk(KERN_INFO "yaffs: dev is %d name is \"%s\"\n",
1292 yaffs_devname(sb, devname_buf));
1294 sb->s_blocksize = PAGE_CACHE_SIZE;
1295 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
1296 T(YAFFS_TRACE_OS, ("yaffs_read_super: Using yaffs%d\n", yaffsVersion));
1298 ("yaffs_read_super: block size %d\n", (int)(sb->s_blocksize)));
1300 #ifdef CONFIG_YAFFS_DISABLE_WRITE_VERIFY
1302 ("yaffs: Write verification disabled. All guarantees "
1303 "null and void\n"));
1306 T(YAFFS_TRACE_ALWAYS, ("yaffs: Attempting MTD mount on %u.%u, "
1308 MAJOR(sb->s_dev), MINOR(sb->s_dev),
1309 yaffs_devname(sb, devname_buf)));
1311 /* Check it's an mtd device..... */
1312 if (MAJOR(sb->s_dev) != MTD_BLOCK_MAJOR) {
1313 return NULL; /* This isn't an mtd device */
1315 /* Get the device */
1316 mtd = get_mtd_device(NULL, MINOR(sb->s_dev));
1318 T(YAFFS_TRACE_ALWAYS,
1319 ("yaffs: MTD device #%u doesn't appear to exist\n",
1323 /* Check it's NAND */
1324 if (mtd->type != MTD_NANDFLASH) {
1325 T(YAFFS_TRACE_ALWAYS,
1326 ("yaffs: MTD device is not NAND it's type %d\n", mtd->type));
1330 T(YAFFS_TRACE_OS, (" erase %p\n", mtd->erase));
1331 T(YAFFS_TRACE_OS, (" read %p\n", mtd->read));
1332 T(YAFFS_TRACE_OS, (" write %p\n", mtd->write));
1333 T(YAFFS_TRACE_OS, (" readoob %p\n", mtd->read_oob));
1334 T(YAFFS_TRACE_OS, (" writeoob %p\n", mtd->write_oob));
1335 T(YAFFS_TRACE_OS, (" block_isbad %p\n", mtd->block_isbad));
1336 T(YAFFS_TRACE_OS, (" block_markbad %p\n", mtd->block_markbad));
1337 T(YAFFS_TRACE_OS, (" oobblock %d\n", mtd->oobblock));
1338 T(YAFFS_TRACE_OS, (" oobsize %d\n", mtd->oobsize));
1339 T(YAFFS_TRACE_OS, (" erasesize %d\n", mtd->erasesize));
1340 T(YAFFS_TRACE_OS, (" size %d\n", mtd->size));
1342 if (yaffsVersion == 2) {
1343 /* Check for version 2 style functions */
1345 !mtd->block_isbad ||
1346 !mtd->block_markbad ||
1350 !mtd->read_ecc || !mtd->read_oob || !mtd->write_oob) {
1351 T(YAFFS_TRACE_ALWAYS,
1352 ("yaffs: MTD device does not support required "
1357 if (mtd->oobblock < YAFFS_MIN_YAFFS2_CHUNK_SIZE ||
1358 mtd->oobsize < YAFFS_MIN_YAFFS2_SPARE_SIZE) {
1359 T(YAFFS_TRACE_ALWAYS,
1360 ("yaffs: MTD device does not support have the "
1361 "right page sizes\n"));
1365 /* Check for V1 style functions */
1370 !mtd->read_ecc || !mtd->read_oob || !mtd->write_oob) {
1371 T(YAFFS_TRACE_ALWAYS,
1372 ("yaffs: MTD device does not support required "
1377 if (mtd->oobblock != YAFFS_BYTES_PER_CHUNK ||
1378 mtd->oobsize != YAFFS_BYTES_PER_SPARE) {
1379 T(YAFFS_TRACE_ALWAYS,
1380 ("yaffs: MTD device does not support have the "
1381 "right page sizes\n"));
1386 /* OK, so if we got here, we have an MTD that's NAND and looks
1387 * like it has the right capabilities
1388 * Set the yaffs_Device up for mtd
1391 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1392 sb->s_fs_info = dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL);
1394 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL);
1397 /* Deep shit could not allocate device structure */
1398 T(YAFFS_TRACE_ALWAYS,
1399 ("yaffs_read_super: Failed trying to allocate "
1400 "yaffs_Device. \n"));
1404 memset(dev, 0, sizeof(yaffs_Device));
1405 dev->genericDevice = mtd;
1406 dev->name = mtd->name;
1408 /* Set up the memory size parameters.... */
1410 nBlocks = mtd->size / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
1411 dev->startBlock = 0;
1412 dev->endBlock = nBlocks - 1;
1413 dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
1414 dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
1415 dev->nReservedBlocks = 5;
1416 dev->nShortOpCaches = 10; /* Enable short op caching */
1418 /* ... and the functions. */
1419 if (yaffsVersion == 2) {
1420 dev->writeChunkWithTagsToNAND =
1421 nandmtd2_WriteChunkWithTagsToNAND;
1422 dev->readChunkWithTagsFromNAND =
1423 nandmtd2_ReadChunkWithTagsFromNAND;
1424 dev->markNANDBlockBad = nandmtd2_MarkNANDBlockBad;
1425 dev->queryNANDBlock = nandmtd2_QueryNANDBlock;
1426 dev->spareBuffer = YMALLOC(mtd->oobsize);
1428 dev->nBytesPerChunk = mtd->oobblock;
1429 dev->nChunksPerBlock = mtd->erasesize / mtd->oobblock;
1430 nBlocks = mtd->size / mtd->erasesize;
1431 dev->startBlock = 0;
1432 dev->endBlock = nBlocks - 1;
1434 dev->writeChunkToNAND = nandmtd_WriteChunkToNAND;
1435 dev->readChunkFromNAND = nandmtd_ReadChunkFromNAND;
1438 /* ... and common functions */
1439 dev->eraseBlockInNAND = nandmtd_EraseBlockInNAND;
1440 dev->initialiseNAND = nandmtd_InitialiseNAND;
1442 dev->putSuperFunc = yaffs_MTDPutSuper;
1444 #ifndef CONFIG_YAFFS_DOES_ECC
1445 dev->useNANDECC = 1;
1448 /* we assume this is protected by lock_kernel() in mount/umount */
1449 list_add_tail(&dev->devList, &yaffs_dev_list);
1451 init_MUTEX(&dev->grossLock);
1453 yaffs_GrossLock(dev);
1455 err = yaffs_GutsInitialise(dev);
1458 ("yaffs_read_super: guts initialised %s\n",
1459 (err == YAFFS_OK) ? "OK" : "FAILED"));
1461 /* Create root inode */
1462 if (err == YAFFS_OK)
1463 inode = yaffs_get_inode(sb, S_IFDIR | 0755, 0,
1466 yaffs_GrossUnlock(dev);
1471 inode->i_op = &yaffs_dir_inode_operations;
1472 inode->i_fop = &yaffs_dir_operations;
1474 T(YAFFS_TRACE_OS, ("yaffs_read_super: got root inode\n"));
1476 root = d_alloc_root(inode);
1478 T(YAFFS_TRACE_OS, ("yaffs_read_super: d_alloc_root done\n"));
1486 T(YAFFS_TRACE_OS, ("yaffs_read_super: done\n"));
1491 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1492 static int yaffs_internal_read_super_mtd(struct super_block *sb, void *data,
1495 return yaffs_internal_read_super(1, sb, data, silent) ? 0 : -1;
1498 static struct super_block *yaffs_read_super(struct file_system_type *fs,
1499 int flags, const char *dev_name,
1503 return get_sb_bdev(fs, flags, dev_name, data,
1504 yaffs_internal_read_super_mtd);
1507 static struct file_system_type yaffs_fs_type = {
1508 .owner = THIS_MODULE,
1510 .get_sb = yaffs_read_super,
1511 .kill_sb = kill_block_super,
1512 .fs_flags = FS_REQUIRES_DEV,
1515 static struct super_block *yaffs_read_super(struct super_block *sb, void *data,
1518 return yaffs_internal_read_super(1, sb, data, silent);
1521 static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super,
1526 #ifdef CONFIG_YAFFS_YAFFS2
1528 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1529 static int yaffs2_internal_read_super_mtd(struct super_block *sb, void *data,
1532 return yaffs_internal_read_super(2, sb, data, silent) ? 0 : -1;
1535 static struct super_block *yaffs2_read_super(struct file_system_type *fs,
1536 int flags, const char *dev_name,
1540 return get_sb_bdev(fs, flags, dev_name, data,
1541 yaffs2_internal_read_super_mtd);
1544 static struct file_system_type yaffs2_fs_type = {
1545 .owner = THIS_MODULE,
1547 .get_sb = yaffs2_read_super,
1548 .kill_sb = kill_block_super,
1549 .fs_flags = FS_REQUIRES_DEV,
1552 static struct super_block *yaffs2_read_super(struct super_block *sb,
1553 void *data, int silent)
1555 return yaffs_internal_read_super(2, sb, data, silent);
1558 static DECLARE_FSTYPE(yaffs2_fs_type, "yaffs2", yaffs2_read_super,
1562 #endif /* CONFIG_YAFFS_YAFFS2 */
1564 static struct proc_dir_entry *my_proc_entry;
1566 static char *yaffs_dump_dev(char *buf, yaffs_Device * dev)
1568 buf += sprintf(buf, "startBlock......... %d\n", dev->startBlock);
1569 buf += sprintf(buf, "endBlock........... %d\n", dev->endBlock);
1570 buf += sprintf(buf, "chunkGroupBits..... %d\n", dev->chunkGroupBits);
1571 buf += sprintf(buf, "chunkGroupSize..... %d\n", dev->chunkGroupSize);
1572 buf += sprintf(buf, "nErasedBlocks...... %d\n", dev->nErasedBlocks);
1573 buf += sprintf(buf, "nTnodesCreated..... %d\n", dev->nTnodesCreated);
1574 buf += sprintf(buf, "nFreeTnodes........ %d\n", dev->nFreeTnodes);
1575 buf += sprintf(buf, "nObjectsCreated.... %d\n", dev->nObjectsCreated);
1576 buf += sprintf(buf, "nFreeObjects....... %d\n", dev->nFreeObjects);
1577 buf += sprintf(buf, "nFreeChunks........ %d\n", dev->nFreeChunks);
1578 buf += sprintf(buf, "nPageWrites........ %d\n", dev->nPageWrites);
1579 buf += sprintf(buf, "nPageReads......... %d\n", dev->nPageReads);
1580 buf += sprintf(buf, "nBlockErasures..... %d\n", dev->nBlockErasures);
1581 buf += sprintf(buf, "nGCCopies.......... %d\n", dev->nGCCopies);
1583 sprintf(buf, "garbageCollections. %d\n", dev->garbageCollections);
1585 sprintf(buf, "passiveGCs......... %d\n",
1586 dev->passiveGarbageCollections);
1587 buf += sprintf(buf, "nRetriedWrites..... %d\n", dev->nRetriedWrites);
1588 buf += sprintf(buf, "nRetireBlocks...... %d\n", dev->nRetiredBlocks);
1589 buf += sprintf(buf, "eccFixed........... %d\n", dev->eccFixed);
1590 buf += sprintf(buf, "eccUnfixed......... %d\n", dev->eccUnfixed);
1591 buf += sprintf(buf, "tagsEccFixed....... %d\n", dev->tagsEccFixed);
1592 buf += sprintf(buf, "tagsEccUnfixed..... %d\n", dev->tagsEccUnfixed);
1593 buf += sprintf(buf, "cacheHits.......... %d\n", dev->cacheHits);
1594 buf += sprintf(buf, "nDeletedFiles...... %d\n", dev->nDeletedFiles);
1595 buf += sprintf(buf, "nUnlinkedFiles..... %d\n", dev->nUnlinkedFiles);
1597 sprintf(buf, "nBackgroudDeletions %d\n", dev->nBackgroundDeletions);
1598 buf += sprintf(buf, "useNANDECC......... %d\n", dev->useNANDECC);
1599 buf += sprintf(buf, "isYaffs2........... %d\n", dev->isYaffs2);
1604 static int yaffs_proc_read(char *page,
1606 off_t offset, int count, int *eof, void *data)
1608 struct list_head *item;
1613 /* Get proc_file_read() to step 'offset' by one on each sucessive call.
1614 * We use 'offset' (*ppos) to indicate where we are in devList.
1615 * This also assumes the user has posted a read buffer large
1616 * enough to hold the complete output; but that's life in /proc.
1621 /* Print header first */
1623 buf += sprintf(buf, "YAFFS built:" __DATE__ " " __TIME__
1624 "\n%s\n%s\n", yaffs_fs_c_version,
1625 yaffs_guts_c_version);
1628 /* hold lock_kernel while traversing yaffs_dev_list */
1631 /* Locate and print the Nth entry. Order N-squared but N is small. */
1632 list_for_each(item, &yaffs_dev_list) {
1633 yaffs_Device *dev = list_entry(item, yaffs_Device, devList);
1638 buf += sprintf(buf, "\nDevice %d \"%s\"\n", n, dev->name);
1639 buf = yaffs_dump_dev(buf, dev);
1644 return buf - page < count ? buf - page : count;
1647 /* Stuff to handle installation of file systems */
1648 struct file_system_to_install {
1649 struct file_system_type *fst;
1653 static struct file_system_to_install fs_to_install[] = {
1654 //#ifdef CONFIG_YAFFS_YAFFS1
1655 {&yaffs_fs_type, 0},
1657 //#ifdef CONFIG_YAFFS_YAFFS2
1658 {&yaffs2_fs_type, 0},
1663 static int __init init_yaffs_fs(void)
1666 struct file_system_to_install *fsinst;
1668 T(YAFFS_TRACE_ALWAYS,
1669 ("yaffs " __DATE__ " " __TIME__ " Installing. \n"));
1671 /* Install the proc_fs entry */
1672 my_proc_entry = create_proc_read_entry("yaffs",
1675 yaffs_proc_read, NULL);
1676 if (!my_proc_entry) {
1680 /* Now add the file system entries */
1682 fsinst = fs_to_install;
1684 while (fsinst->fst && !error) {
1685 error = register_filesystem(fsinst->fst);
1687 fsinst->installed = 1;
1692 /* Any errors? uninstall */
1694 fsinst = fs_to_install;
1696 while (fsinst->fst) {
1697 if (fsinst->installed) {
1698 unregister_filesystem(fsinst->fst);
1699 fsinst->installed = 0;
1708 static void __exit exit_yaffs_fs(void)
1711 struct file_system_to_install *fsinst;
1713 T(YAFFS_TRACE_ALWAYS, ("yaffs " __DATE__ " " __TIME__
1716 remove_proc_entry("yaffs", &proc_root);
1718 fsinst = fs_to_install;
1720 while (fsinst->fst) {
1721 if (fsinst->installed) {
1722 unregister_filesystem(fsinst->fst);
1723 fsinst->installed = 0;
1730 module_init(init_yaffs_fs)
1731 module_exit(exit_yaffs_fs)
1733 MODULE_DESCRIPTION("YAFFS2 - a NAND specific flash file system");
1734 MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002,2003,2004");
1735 MODULE_LICENSE("GPL");