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.29 2005-08-11 01:07:43 marty 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;
76 /*unsigned yaffs_traceMask = 0xFFFFFFFF; */
78 #ifdef CONFIG_YAFFS_YAFFS1
79 #include <linux/mtd/mtd.h>
80 #include "yaffs_mtdif.h"
81 #include "yaffs_mtdif2.h"
82 #endif /*CONFIG_YAFFS_YAFFS1 */
84 /*#define T(x) printk x */
86 #define yaffs_InodeToObject(iptr) ((yaffs_Object *)((iptr)->u.generic_ip))
87 #define yaffs_DentryToObject(dptr) yaffs_InodeToObject((dptr)->d_inode)
89 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
90 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->s_fs_info)
92 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->u.generic_sbp)
95 static void yaffs_put_super(struct super_block *sb);
97 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
100 static int yaffs_file_flush(struct file *file);
102 static int yaffs_sync_object(struct file *file, struct dentry *dentry,
105 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir);
107 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
108 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode,
109 struct nameidata *n);
110 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry,
111 struct nameidata *n);
113 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode);
114 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry);
116 static int yaffs_link(struct dentry *old_dentry, struct inode *dir,
117 struct dentry *dentry);
118 static int yaffs_unlink(struct inode *dir, struct dentry *dentry);
119 static int yaffs_symlink(struct inode *dir, struct dentry *dentry,
120 const char *symname);
121 static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode);
123 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
124 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
127 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
130 static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
131 struct inode *new_dir, struct dentry *new_dentry);
132 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr);
134 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
135 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf);
137 static int yaffs_statfs(struct super_block *sb, struct statfs *buf);
139 static void yaffs_read_inode(struct inode *inode);
141 static void yaffs_put_inode(struct inode *inode);
142 static void yaffs_delete_inode(struct inode *);
143 static void yaffs_clear_inode(struct inode *);
145 static int yaffs_readpage(struct file *file, struct page *page);
146 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
147 static int yaffs_writepage(struct page *page, struct writeback_control *wbc);
149 static int yaffs_writepage(struct page *page);
151 static int yaffs_prepare_write(struct file *f, struct page *pg,
152 unsigned offset, unsigned to);
153 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset,
156 static int yaffs_readlink(struct dentry *dentry, char __user * buffer,
158 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,
167 static struct file_operations yaffs_file_operations = {
168 .read = generic_file_read,
169 .write = generic_file_write,
170 .mmap = generic_file_mmap,
171 .flush = yaffs_file_flush,
172 .fsync = yaffs_sync_object,
175 static struct inode_operations yaffs_file_inode_operations = {
176 .setattr = yaffs_setattr,
179 static struct inode_operations yaffs_symlink_inode_operations = {
180 .readlink = yaffs_readlink,
181 .follow_link = yaffs_follow_link,
182 .setattr = yaffs_setattr,
185 static struct inode_operations yaffs_dir_inode_operations = {
186 .create = yaffs_create,
187 .lookup = yaffs_lookup,
189 .unlink = yaffs_unlink,
190 .symlink = yaffs_symlink,
191 .mkdir = yaffs_mkdir,
192 .rmdir = yaffs_unlink,
193 .mknod = yaffs_mknod,
194 .rename = yaffs_rename,
195 .setattr = yaffs_setattr,
198 static struct file_operations yaffs_dir_operations = {
199 .read = generic_read_dir,
200 .readdir = yaffs_readdir,
201 .fsync = yaffs_sync_object,
204 static struct super_operations yaffs_super_ops = {
205 .statfs = yaffs_statfs,
206 .read_inode = yaffs_read_inode,
207 .put_inode = yaffs_put_inode,
208 .put_super = yaffs_put_super,
209 .delete_inode = yaffs_delete_inode,
210 .clear_inode = yaffs_clear_inode,
213 static void yaffs_GrossLock(yaffs_Device * dev)
215 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs locking\n"));
217 down(&dev->grossLock);
220 static void yaffs_GrossUnlock(yaffs_Device * dev)
222 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs unlocking\n"));
227 static int yaffs_readlink(struct dentry *dentry, char __user * buffer,
230 unsigned char *alias;
233 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
235 yaffs_GrossLock(dev);
237 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
239 yaffs_GrossUnlock(dev);
244 ret = vfs_readlink(dentry, buffer, buflen, alias);
249 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd)
251 unsigned char *alias;
253 yaffs_Device *dev = yaffs_DentryToObject(dentry)->myDev;
255 yaffs_GrossLock(dev);
257 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
259 yaffs_GrossUnlock(dev);
264 ret = vfs_follow_link(nd, alias);
269 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,
273 * Lookup is used to find objects in the fs
275 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
277 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry,
280 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry)
284 struct inode *inode = NULL; /* NCB 2.5/2.6 needs NULL here */
286 yaffs_Device *dev = yaffs_InodeToObject(dir)->myDev;
288 yaffs_GrossLock(dev);
291 (KERN_DEBUG "yaffs_lookup for %d:%s\n",
292 yaffs_InodeToObject(dir)->objectId, dentry->d_name.name));
295 yaffs_FindObjectByName(yaffs_InodeToObject(dir),
296 dentry->d_name.name);
298 obj = yaffs_GetEquivalentObject(obj); /* in case it was a hardlink */
302 (KERN_DEBUG "yaffs_lookup found %d\n", obj->objectId));
304 inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj);
308 (KERN_DEBUG "yaffs_loookup dentry \n"));
309 /* #if 0 asserted by NCB for 2.5/6 compatability - falls through to
310 * d_add even if NULL inode */
312 /*dget(dentry); // try to solve directory bug */
313 d_add(dentry, inode);
315 yaffs_GrossUnlock(dev);
323 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_lookup not found\n"));
326 yaffs_GrossUnlock(dev);
328 /* added NCB for 2.5/6 compatability - forces add even if inode is
329 * NULL which creates dentry hash */
330 d_add(dentry, inode);
333 /* return (ERR_PTR(-EIO)); */
337 /* For now put inode is just for debugging
338 * Put inode is called when the inode **structure** is put.
340 static void yaffs_put_inode(struct inode *inode)
343 ("yaffs_put_inode: ino %d, count %d\n", (int)inode->i_ino,
344 atomic_read(&inode->i_count)));
348 /* clear is called to tell the fs to release any per-inode data it holds */
349 static void yaffs_clear_inode(struct inode *inode)
354 obj = yaffs_InodeToObject(inode);
357 ("yaffs_clear_inode: ino %d, count %d %s\n", (int)inode->i_ino,
358 atomic_read(&inode->i_count),
359 obj ? "object exists" : "null object"));
363 yaffs_GrossLock(dev);
365 /* Clear the association between the inode and
369 inode->u.generic_ip = NULL;
371 /* If the object freeing was deferred, then the real
373 * This should fix the inode inconsistency problem.
376 yaffs_HandleDeferedFree(obj);
378 yaffs_GrossUnlock(dev);
383 /* delete is called when the link count is zero and the inode
384 * is put (ie. nobody wants to know about it anymore, time to
386 * NB Must call clear_inode()
388 static void yaffs_delete_inode(struct inode *inode)
390 yaffs_Object *obj = yaffs_InodeToObject(inode);
394 ("yaffs_delete_inode: ino %d, count %d %s\n", (int)inode->i_ino,
395 atomic_read(&inode->i_count),
396 obj ? "object exists" : "null object"));
400 yaffs_GrossLock(dev);
401 yaffs_DeleteFile(obj);
402 yaffs_GrossUnlock(dev);
407 static int yaffs_file_flush(struct file *file)
409 yaffs_Object *obj = yaffs_DentryToObject(file->f_dentry);
411 yaffs_Device *dev = obj->myDev;
414 (KERN_DEBUG "yaffs_file_flush object %d (%s)\n", obj->objectId,
415 obj->dirty ? "dirty" : "clean"));
417 yaffs_GrossLock(dev);
419 yaffs_FlushFile(obj, 1);
421 yaffs_GrossUnlock(dev);
426 static int yaffs_readpage_nolock(struct file *f, struct page *pg)
428 /* Lifted from jffs2 */
431 unsigned char *pg_buf;
436 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_readpage at %08x, size %08x\n",
437 (unsigned)(pg->index << PAGE_CACHE_SHIFT),
438 (unsigned)PAGE_CACHE_SIZE));
440 obj = yaffs_DentryToObject(f->f_dentry);
444 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
445 BUG_ON(!PageLocked(pg));
452 /* FIXME: Can kmap fail? */
454 yaffs_GrossLock(dev);
457 yaffs_ReadDataFromFile(obj, pg_buf, pg->index << PAGE_CACHE_SHIFT,
460 yaffs_GrossUnlock(dev);
466 ClearPageUptodate(pg);
473 flush_dcache_page(pg);
476 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_readpage done\n"));
480 static int yaffs_readpage_unlock(struct file *f, struct page *pg)
482 int ret = yaffs_readpage_nolock(f, pg);
487 static int yaffs_readpage(struct file *f, struct page *pg)
489 return yaffs_readpage_unlock(f, pg);
492 /* writepage inspired by/stolen from smbfs */
494 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
495 static int yaffs_writepage(struct page *page, struct writeback_control *wbc)
497 static int yaffs_writepage(struct page *page)
500 struct address_space *mapping = page->mapping;
501 loff_t offset = (loff_t) page->index << PAGE_CACHE_SHIFT;
503 unsigned long end_index;
511 inode = mapping->host;
515 if (offset > inode->i_size) {
518 "yaffs_writepage at %08x, inode size = %08x!!!\n",
519 (unsigned)(page->index << PAGE_CACHE_SHIFT),
520 (unsigned)inode->i_size));
522 (KERN_DEBUG " -> don't care!!\n"));
527 end_index = inode->i_size >> PAGE_CACHE_SHIFT;
530 if (page->index < end_index) {
531 nBytes = PAGE_CACHE_SIZE;
533 nBytes = inode->i_size & (PAGE_CACHE_SIZE - 1);
540 obj = yaffs_InodeToObject(inode);
541 yaffs_GrossLock(obj->myDev);
544 (KERN_DEBUG "yaffs_writepage at %08x, size %08x\n",
545 (unsigned)(page->index << PAGE_CACHE_SHIFT), nBytes));
547 (KERN_DEBUG "writepag0: obj = %05x, ino = %05x\n",
548 (int)obj->variant.fileVariant.fileSize, (int)inode->i_size));
551 yaffs_WriteDataToFile(obj, buffer, page->index << PAGE_CACHE_SHIFT,
555 (KERN_DEBUG "writepag1: obj = %05x, ino = %05x\n",
556 (int)obj->variant.fileVariant.fileSize, (int)inode->i_size));
558 yaffs_GrossUnlock(obj->myDev);
561 SetPageUptodate(page);
565 return (nWritten == nBytes) ? 0 : -ENOSPC;
568 static int yaffs_prepare_write(struct file *f, struct page *pg,
569 unsigned offset, unsigned to)
572 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_prepair_write\n"));
573 if (!Page_Uptodate(pg) && (offset || to < PAGE_CACHE_SIZE))
574 return yaffs_readpage_nolock(f, pg);
580 static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset,
584 void *addr = page_address(pg) + offset;
585 loff_t pos = (((loff_t) pg->index) << PAGE_CACHE_SHIFT) + offset;
586 int nBytes = to - offset;
590 unsigned saddr = (unsigned)addr;
593 (KERN_DEBUG "yaffs_commit_write addr %x pos %x nBytes %d\n", saddr,
596 nWritten = yaffs_file_write(f, addr, nBytes, &pos);
598 if (nWritten != nBytes) {
601 "yaffs_commit_write not same size nWritten %d nBytes %d\n",
604 ClearPageUptodate(pg);
610 (KERN_DEBUG "yaffs_commit_write returning %d\n", nWritten));
616 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object * obj)
619 inode->i_ino = obj->objectId;
620 inode->i_mode = obj->yst_mode;
621 inode->i_uid = obj->yst_uid;
622 inode->i_gid = obj->yst_gid;
623 inode->i_blksize = inode->i_sb->s_blocksize;
624 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
626 inode->i_rdev = old_decode_dev(obj->yst_rdev);
627 inode->i_atime.tv_sec = (time_t) (obj->yst_atime);
628 inode->i_atime.tv_nsec = 0;
629 inode->i_mtime.tv_sec = (time_t) obj->yst_mtime;
630 inode->i_mtime.tv_nsec = 0;
631 inode->i_ctime.tv_sec = (time_t) obj->yst_ctime;
632 inode->i_ctime.tv_nsec = 0;
634 inode->i_rdev = obj->yst_rdev;
635 inode->i_atime = obj->yst_atime;
636 inode->i_mtime = obj->yst_mtime;
637 inode->i_ctime = obj->yst_ctime;
639 inode->i_size = yaffs_GetObjectFileLength(obj);
640 inode->i_blocks = (inode->i_size + 511) >> 9;
642 inode->i_nlink = yaffs_GetObjectLinkCount(obj);
646 "yaffs_FillInode mode %x uid %d gid %d size %d count %d\n",
647 inode->i_mode, inode->i_uid, inode->i_gid,
648 (int)inode->i_size, atomic_read(&inode->i_count)));
650 switch (obj->yst_mode & S_IFMT) {
651 default: /* fifo, device or socket */
652 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
653 init_special_inode(inode, obj->yst_mode,
654 old_decode_dev(obj->yst_rdev));
656 init_special_inode(inode, obj->yst_mode,
657 (dev_t) (obj->yst_rdev));
660 case S_IFREG: /* file */
661 inode->i_op = &yaffs_file_inode_operations;
662 inode->i_fop = &yaffs_file_operations;
663 inode->i_mapping->a_ops =
664 &yaffs_file_address_operations;
666 case S_IFDIR: /* directory */
667 inode->i_op = &yaffs_dir_inode_operations;
668 inode->i_fop = &yaffs_dir_operations;
670 case S_IFLNK: /* symlink */
671 inode->i_op = &yaffs_symlink_inode_operations;
675 inode->u.generic_ip = obj;
676 obj->myInode = inode;
680 (KERN_DEBUG "yaffs_FileInode invalid parameters\n"));
685 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,
692 (KERN_DEBUG "yaffs_get_inode for NULL super_block!!\n"));
699 (KERN_DEBUG "yaffs_get_inode for NULL object!!\n"));
705 (KERN_DEBUG "yaffs_get_inode for object %d\n", obj->objectId));
707 inode = iget(sb, obj->objectId);
709 /* NB Side effect: iget calls back to yaffs_read_inode(). */
710 /* iget also increments the inode's i_count */
715 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
723 obj = yaffs_DentryToObject(f->f_dentry);
727 yaffs_GrossLock(dev);
729 inode = f->f_dentry->d_inode;
731 if (!S_ISBLK(inode->i_mode) && f->f_flags & O_APPEND) {
732 ipos = inode->i_size;
739 (KERN_DEBUG "yaffs_file_write: hey obj is null!\n"));
743 "yaffs_file_write about to write writing %d bytes"
744 "to object %d at %d\n",
745 n, obj->objectId, ipos));
748 nWritten = yaffs_WriteDataToFile(obj, buf, ipos, n, 0);
751 (KERN_DEBUG "yaffs_file_write writing %d bytes, %d written at %d\n",
756 if (ipos > inode->i_size) {
757 inode->i_size = ipos;
758 inode->i_blocks = (ipos + 511) >> 9;
762 "yaffs_file_write size updated to %d bytes, "
764 ipos, (int)(inode->i_blocks)));
768 yaffs_GrossUnlock(dev);
770 return nWritten != n ? -ENOSPC : nWritten;
773 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
777 struct inode *inode = f->f_dentry->d_inode;
778 unsigned long offset, curoffs;
782 char name[YAFFS_MAX_NAME_LENGTH + 1];
784 obj = yaffs_DentryToObject(f->f_dentry);
787 yaffs_GrossLock(dev);
791 T(YAFFS_TRACE_OS, ("yaffs_readdir: starting at %d\n", (int)offset));
795 (KERN_DEBUG "yaffs_readdir: entry . ino %d \n",
797 if (filldir(dirent, ".", 1, offset, inode->i_ino, DT_DIR)
806 (KERN_DEBUG "yaffs_readdir: entry .. ino %d \n",
807 (int)f->f_dentry->d_parent->d_inode->i_ino));
809 (dirent, "..", 2, offset,
810 f->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) {
819 list_for_each(i, &obj->variant.directoryVariant.children) {
821 if (curoffs >= offset) {
822 l = list_entry(i, yaffs_Object, siblings);
824 yaffs_GetObjectName(l, name,
825 YAFFS_MAX_NAME_LENGTH + 1);
827 (KERN_DEBUG "yaffs_readdir: %s inode %d\n", name,
828 yaffs_GetObjectInode(l)));
834 yaffs_GetObjectInode(l),
835 yaffs_GetObjectType(l))
848 yaffs_GrossUnlock(dev);
854 * File creation. Allocate an inode, and we're done..
856 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
857 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
860 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
866 yaffs_Object *obj = NULL;
869 yaffs_Object *parent = yaffs_InodeToObject(dir);
872 uid_t uid = current->fsuid;
873 gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
877 (KERN_DEBUG "yaffs_mknod: parent object %d type %d\n",
878 parent->objectId, parent->variantType));
881 (KERN_DEBUG "yaffs_mknod: could not get parent object\n"));
885 T(YAFFS_TRACE_OS, ("yaffs_mknod: making oject for %s, "
887 dentry->d_name.name, mode, rdev));
891 yaffs_GrossLock(dev);
893 switch (mode & S_IFMT) {
895 /* Special (socket, fifo, device...) */
896 T(YAFFS_TRACE_OS, (KERN_DEBUG
897 "yaffs_mknod: making special\n"));
898 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
900 yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid,
901 gid, old_encode_dev(rdev));
904 yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid,
908 case S_IFREG: /* file */
909 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_mknod: making file\n"));
911 yaffs_MknodFile(parent, dentry->d_name.name, mode, uid,
914 case S_IFDIR: /* directory */
916 (KERN_DEBUG "yaffs_mknod: making directory\n"));
918 yaffs_MknodDirectory(parent, dentry->d_name.name, mode,
921 case S_IFLNK: /* symlink */
922 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_mknod: making file\n"));
923 obj = NULL; /* Do we ever get here? */
928 inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj);
929 d_instantiate(dentry, inode);
931 (KERN_DEBUG "yaffs_mknod created object %d count = %d\n",
932 obj->objectId, atomic_read(&inode->i_count)));
936 (KERN_DEBUG "yaffs_mknod failed making object\n"));
940 yaffs_GrossUnlock(dev);
945 static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
948 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_mkdir\n"));
949 retVal = yaffs_mknod(dir, dentry, mode | S_IFDIR, 0);
951 /* attempt to fix dir bug - didn't work */
959 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
960 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode,
963 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode)
966 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_create\n"));
967 return yaffs_mknod(dir, dentry, mode | S_IFREG, 0);
970 static int yaffs_unlink(struct inode *dir, struct dentry *dentry)
977 (KERN_DEBUG "yaffs_unlink %d:%s\n", (int)(dir->i_ino),
978 dentry->d_name.name));
980 dev = yaffs_InodeToObject(dir)->myDev;
982 yaffs_GrossLock(dev);
984 retVal = yaffs_Unlink(yaffs_InodeToObject(dir), dentry->d_name.name);
986 yaffs_GrossUnlock(dev);
988 if (retVal == YAFFS_OK) {
989 dentry->d_inode->i_nlink--;
990 mark_inode_dirty(dentry->d_inode);
1000 static int yaffs_link(struct dentry *old_dentry, struct inode *dir,
1001 struct dentry *dentry)
1003 struct inode *inode = old_dentry->d_inode;
1004 yaffs_Object *obj = NULL;
1005 yaffs_Object *link = NULL;
1008 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_link\n"));
1010 obj = yaffs_InodeToObject(inode);
1013 yaffs_GrossLock(dev);
1015 if (!S_ISDIR(inode->i_mode)) /* Don't link directories */
1018 yaffs_Link(yaffs_InodeToObject(dir), dentry->d_name.name,
1023 old_dentry->d_inode->i_nlink = yaffs_GetObjectLinkCount(obj);
1024 d_instantiate(dentry, old_dentry->d_inode);
1025 atomic_inc(&old_dentry->d_inode->i_count);
1027 (KERN_DEBUG "yaffs_link link count %d i_count %d\n",
1028 old_dentry->d_inode->i_nlink,
1029 atomic_read(&old_dentry->d_inode->i_count)));
1033 yaffs_GrossUnlock(dev);
1043 static int yaffs_symlink(struct inode *dir, struct dentry *dentry,
1044 const char *symname)
1048 uid_t uid = current->fsuid;
1049 gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
1051 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_symlink\n"));
1053 dev = yaffs_InodeToObject(dir)->myDev;
1054 yaffs_GrossLock(dev);
1055 obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name,
1056 S_IFLNK | S_IRWXUGO, uid, gid, symname);
1057 yaffs_GrossUnlock(dev);
1061 struct inode *inode;
1063 inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj);
1064 d_instantiate(dentry, inode);
1065 T(YAFFS_TRACE_OS, (KERN_DEBUG "symlink created OK\n"));
1068 T(YAFFS_TRACE_OS, (KERN_DEBUG "symlink not created\n"));
1075 static int yaffs_sync_object(struct file *file, struct dentry *dentry,
1082 obj = yaffs_DentryToObject(dentry);
1086 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_sync_object\n"));
1087 yaffs_GrossLock(dev);
1088 yaffs_FlushFile(obj, 1);
1089 yaffs_GrossUnlock(dev);
1094 * The VFS layer already does all the dentry stuff for rename.
1096 * NB: POSIX says you can rename an object over an old object of the same name
1098 static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
1099 struct inode *new_dir, struct dentry *new_dentry)
1102 int retVal = YAFFS_FAIL;
1104 yaffs_Object *target;
1106 dev = yaffs_InodeToObject(old_dir)->myDev;
1108 yaffs_GrossLock(dev);
1110 /* Check if the target is an existing directory that is not empty. */
1112 yaffs_FindObjectByName(yaffs_InodeToObject(new_dir),
1113 new_dentry->d_name.name);
1116 target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
1117 !list_empty(&target->variant.directoryVariant.children)) {
1118 retVal = YAFFS_FAIL;
1121 /* Now does unlinking internally using shadowing mechanism */
1124 yaffs_RenameObject(yaffs_InodeToObject(old_dir),
1125 old_dentry->d_name.name,
1126 yaffs_InodeToObject(new_dir),
1127 new_dentry->d_name.name);
1130 yaffs_GrossUnlock(dev);
1132 if (retVal == YAFFS_OK) {
1133 if (removed == YAFFS_OK) {
1134 new_dentry->d_inode->i_nlink--;
1135 mark_inode_dirty(new_dentry->d_inode);
1145 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr)
1147 struct inode *inode = dentry->d_inode;
1152 (KERN_DEBUG "yaffs_setattr of object %d\n",
1153 yaffs_InodeToObject(inode)->objectId));
1155 if ((error = inode_change_ok(inode, attr)) == 0) {
1157 dev = yaffs_InodeToObject(inode)->myDev;
1158 yaffs_GrossLock(dev);
1159 if (yaffs_SetAttributes(yaffs_InodeToObject(inode), attr) ==
1165 yaffs_GrossUnlock(dev);
1167 error = inode_setattr(inode, attr);
1172 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1173 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf)
1175 static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
1179 yaffs_Device *dev = yaffs_SuperToDevice(sb);
1180 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_statfs\n"));
1182 yaffs_GrossLock(dev);
1184 buf->f_type = YAFFS_MAGIC;
1185 buf->f_bsize = sb->s_blocksize;
1186 buf->f_namelen = 255;
1187 if (sb->s_blocksize > dev->nBytesPerChunk) {
1190 (dev->endBlock - dev->startBlock +
1191 1) * dev->nChunksPerBlock / (sb->s_blocksize /
1192 dev->nBytesPerChunk);
1194 yaffs_GetNumberOfFreeChunks(dev) / (sb->s_blocksize /
1195 dev->nBytesPerChunk);
1199 (dev->endBlock - dev->startBlock +
1200 1) * dev->nChunksPerBlock * (dev->nBytesPerChunk /
1203 yaffs_GetNumberOfFreeChunks(dev) * (dev->nBytesPerChunk /
1208 buf->f_bavail = buf->f_bfree;
1210 yaffs_GrossUnlock(dev);
1214 static void yaffs_read_inode(struct inode *inode)
1216 /* NB This is called as a side effect of other functions and
1217 * thus gross locking should always be in place already.
1221 yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb);
1224 (KERN_DEBUG "yaffs_read_inode for %d\n", (int)inode->i_ino));
1226 obj = yaffs_FindObjectByNumber(dev, inode->i_ino);
1228 yaffs_FillInodeFromObject(inode, obj);
1232 static LIST_HEAD(yaffs_dev_list);
1234 static void yaffs_put_super(struct super_block *sb)
1236 yaffs_Device *dev = yaffs_SuperToDevice(sb);
1238 yaffs_GrossLock(dev);
1239 if (dev->putSuperFunc) {
1240 dev->putSuperFunc(sb);
1242 yaffs_Deinitialise(dev);
1243 yaffs_GrossUnlock(dev);
1245 /* we assume this is protected by lock_kernel() in mount/umount */
1246 list_del(&dev->devList);
1251 #ifdef CONFIG_YAFFS_YAFFS1
1253 static void yaffs_MTDPutSuper(struct super_block *sb)
1256 struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
1262 put_mtd_device(mtd);
1267 static struct super_block *yaffs_internal_read_super(int yaffsVersion,
1268 struct super_block *sb,
1269 void *data, int silent)
1272 struct inode *inode = NULL;
1273 struct dentry *root;
1274 yaffs_Device *dev = 0;
1275 char devname_buf[BDEVNAME_SIZE + 1];
1276 struct mtd_info *mtd;
1279 sb->s_magic = YAFFS_MAGIC;
1280 sb->s_op = &yaffs_super_ops;
1283 printk(KERN_INFO "yaffs: sb is NULL\n");
1284 else if (!sb->s_dev)
1285 printk(KERN_INFO "yaffs: sb->s_dev is NULL\n");
1286 else if (!yaffs_devname(sb, devname_buf))
1287 printk(KERN_INFO "yaffs: devname is NULL\n");
1289 printk(KERN_INFO "yaffs: dev is %d name is \"%s\"\n",
1291 yaffs_devname(sb, devname_buf));
1293 sb->s_blocksize = PAGE_CACHE_SIZE;
1294 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
1295 T(YAFFS_TRACE_OS, ("yaffs_read_super: Using yaffs%d\n", yaffsVersion));
1297 ("yaffs_read_super: block size %d\n", (int)(sb->s_blocksize)));
1299 #ifdef CONFIG_YAFFS_DISABLE_WRITE_VERIFY
1301 ("yaffs: Write verification disabled. All guarantees "
1302 "null and void\n"));
1305 T(YAFFS_TRACE_ALWAYS, ("yaffs: Attempting MTD mount on %u.%u, "
1307 MAJOR(sb->s_dev), MINOR(sb->s_dev),
1308 yaffs_devname(sb, devname_buf)));
1310 /* Check it's an mtd device..... */
1311 if (MAJOR(sb->s_dev) != MTD_BLOCK_MAJOR) {
1312 return NULL; /* This isn't an mtd device */
1314 /* Get the device */
1315 mtd = get_mtd_device(NULL, MINOR(sb->s_dev));
1317 T(YAFFS_TRACE_ALWAYS,
1318 ("yaffs: MTD device #%u doesn't appear to exist\n",
1322 /* Check it's NAND */
1323 if (mtd->type != MTD_NANDFLASH) {
1324 T(YAFFS_TRACE_ALWAYS,
1325 ("yaffs: MTD device is not NAND it's type %d\n", mtd->type));
1329 T(YAFFS_TRACE_OS, (" erase %p\n", mtd->erase));
1330 T(YAFFS_TRACE_OS, (" read %p\n", mtd->read));
1331 T(YAFFS_TRACE_OS, (" write %p\n", mtd->write));
1332 T(YAFFS_TRACE_OS, (" readoob %p\n", mtd->read_oob));
1333 T(YAFFS_TRACE_OS, (" writeoob %p\n", mtd->write_oob));
1334 T(YAFFS_TRACE_OS, (" block_isbad %p\n", mtd->block_isbad));
1335 T(YAFFS_TRACE_OS, (" block_markbad %p\n", mtd->block_markbad));
1336 T(YAFFS_TRACE_OS, (" oobblock %d\n", mtd->oobblock));
1337 T(YAFFS_TRACE_OS, (" oobsize %d\n", mtd->oobsize));
1338 T(YAFFS_TRACE_OS, (" erasesize %d\n", mtd->erasesize));
1339 T(YAFFS_TRACE_OS, (" size %d\n", mtd->size));
1341 if (yaffsVersion == 2) {
1342 /* Check for version 2 style functions */
1344 !mtd->block_isbad ||
1345 !mtd->block_markbad ||
1349 !mtd->read_ecc || !mtd->read_oob || !mtd->write_oob) {
1350 T(YAFFS_TRACE_ALWAYS,
1351 ("yaffs: MTD device does not support required "
1356 if (mtd->oobblock < YAFFS_MIN_YAFFS2_CHUNK_SIZE ||
1357 mtd->oobsize < YAFFS_MIN_YAFFS2_SPARE_SIZE) {
1358 T(YAFFS_TRACE_ALWAYS,
1359 ("yaffs: MTD device does not support have the "
1360 "right page sizes\n"));
1364 /* Check for V1 style functions */
1369 !mtd->read_ecc || !mtd->read_oob || !mtd->write_oob) {
1370 T(YAFFS_TRACE_ALWAYS,
1371 ("yaffs: MTD device does not support required "
1376 if (mtd->oobblock != YAFFS_BYTES_PER_CHUNK ||
1377 mtd->oobsize != YAFFS_BYTES_PER_SPARE) {
1378 T(YAFFS_TRACE_ALWAYS,
1379 ("yaffs: MTD device does not support have the "
1380 "right page sizes\n"));
1385 /* OK, so if we got here, we have an MTD that's NAND and looks
1386 * like it has the right capabilities
1387 * Set the yaffs_Device up for mtd
1390 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1391 sb->s_fs_info = dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL);
1393 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL);
1396 /* Deep shit could not allocate device structure */
1397 T(YAFFS_TRACE_ALWAYS,
1398 ("yaffs_read_super: Failed trying to allocate "
1399 "yaffs_Device. \n"));
1403 memset(dev, 0, sizeof(yaffs_Device));
1404 dev->genericDevice = mtd;
1405 dev->name = mtd->name;
1407 /* Set up the memory size parameters.... */
1409 nBlocks = mtd->size / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
1410 dev->startBlock = 0;
1411 dev->endBlock = nBlocks - 1;
1412 dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
1413 dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
1414 dev->nReservedBlocks = 5;
1415 dev->nShortOpCaches = 10; /* Enable short op caching */
1417 /* ... and the functions. */
1418 if (yaffsVersion == 2) {
1419 dev->writeChunkWithTagsToNAND =
1420 nandmtd2_WriteChunkWithTagsToNAND;
1421 dev->readChunkWithTagsFromNAND =
1422 nandmtd2_ReadChunkWithTagsFromNAND;
1423 dev->markNANDBlockBad = nandmtd2_MarkNANDBlockBad;
1424 dev->queryNANDBlock = nandmtd2_QueryNANDBlock;
1425 dev->spareBuffer = YMALLOC(mtd->oobsize);
1427 dev->nBytesPerChunk = mtd->oobblock;
1428 dev->nChunksPerBlock = mtd->erasesize / mtd->oobblock;
1429 nBlocks = mtd->size / mtd->erasesize;
1430 dev->startBlock = 0;
1431 dev->endBlock = nBlocks - 1;
1433 dev->writeChunkToNAND = nandmtd_WriteChunkToNAND;
1434 dev->readChunkFromNAND = nandmtd_ReadChunkFromNAND;
1437 /* ... and common functions */
1438 dev->eraseBlockInNAND = nandmtd_EraseBlockInNAND;
1439 dev->initialiseNAND = nandmtd_InitialiseNAND;
1441 dev->putSuperFunc = yaffs_MTDPutSuper;
1443 #ifndef CONFIG_YAFFS_DOES_ECC
1444 dev->useNANDECC = 1;
1447 /* we assume this is protected by lock_kernel() in mount/umount */
1448 list_add_tail(&dev->devList, &yaffs_dev_list);
1450 init_MUTEX(&dev->grossLock);
1452 yaffs_GrossLock(dev);
1454 err = yaffs_GutsInitialise(dev);
1457 ("yaffs_read_super: guts initialised %s\n",
1458 (err == YAFFS_OK) ? "OK" : "FAILED"));
1460 /* Create root inode */
1461 if (err == YAFFS_OK)
1462 inode = yaffs_get_inode(sb, S_IFDIR | 0755, 0,
1465 yaffs_GrossUnlock(dev);
1470 inode->i_op = &yaffs_dir_inode_operations;
1471 inode->i_fop = &yaffs_dir_operations;
1473 T(YAFFS_TRACE_OS, ("yaffs_read_super: got root inode\n"));
1475 root = d_alloc_root(inode);
1477 T(YAFFS_TRACE_OS, ("yaffs_read_super: d_alloc_root done\n"));
1485 T(YAFFS_TRACE_OS, ("yaffs_read_super: done\n"));
1489 #ifdef CONFIG_YAFFS_YAFFS1
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,
1525 #endif /* CONFIG_YAFFS_YAFFS1 */
1527 #ifdef CONFIG_YAFFS_YAFFS2
1529 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1530 static int yaffs2_internal_read_super_mtd(struct super_block *sb, void *data,
1533 return yaffs_internal_read_super(2, sb, data, silent) ? 0 : -1;
1536 static struct super_block *yaffs2_read_super(struct file_system_type *fs,
1537 int flags, const char *dev_name,
1541 return get_sb_bdev(fs, flags, dev_name, data,
1542 yaffs2_internal_read_super_mtd);
1545 static struct file_system_type yaffs2_fs_type = {
1546 .owner = THIS_MODULE,
1548 .get_sb = yaffs2_read_super,
1549 .kill_sb = kill_block_super,
1550 .fs_flags = FS_REQUIRES_DEV,
1553 static struct super_block *yaffs2_read_super(struct super_block *sb,
1554 void *data, int silent)
1556 return yaffs_internal_read_super(2, sb, data, silent);
1559 static DECLARE_FSTYPE(yaffs2_fs_type, "yaffs2", yaffs2_read_super,
1563 #endif /* CONFIG_YAFFS_YAFFS2 */
1565 static struct proc_dir_entry *my_proc_entry;
1567 static char *yaffs_dump_dev(char *buf, yaffs_Device * dev)
1569 buf += sprintf(buf, "startBlock......... %d\n", dev->startBlock);
1570 buf += sprintf(buf, "endBlock........... %d\n", dev->endBlock);
1571 buf += sprintf(buf, "chunkGroupBits..... %d\n", dev->chunkGroupBits);
1572 buf += sprintf(buf, "chunkGroupSize..... %d\n", dev->chunkGroupSize);
1573 buf += sprintf(buf, "nErasedBlocks...... %d\n", dev->nErasedBlocks);
1574 buf += sprintf(buf, "nTnodesCreated..... %d\n", dev->nTnodesCreated);
1575 buf += sprintf(buf, "nFreeTnodes........ %d\n", dev->nFreeTnodes);
1576 buf += sprintf(buf, "nObjectsCreated.... %d\n", dev->nObjectsCreated);
1577 buf += sprintf(buf, "nFreeObjects....... %d\n", dev->nFreeObjects);
1578 buf += sprintf(buf, "nFreeChunks........ %d\n", dev->nFreeChunks);
1579 buf += sprintf(buf, "nPageWrites........ %d\n", dev->nPageWrites);
1580 buf += sprintf(buf, "nPageReads......... %d\n", dev->nPageReads);
1581 buf += sprintf(buf, "nBlockErasures..... %d\n", dev->nBlockErasures);
1582 buf += sprintf(buf, "nGCCopies.......... %d\n", dev->nGCCopies);
1584 sprintf(buf, "garbageCollections. %d\n", dev->garbageCollections);
1586 sprintf(buf, "passiveGCs......... %d\n",
1587 dev->passiveGarbageCollections);
1588 buf += sprintf(buf, "nRetriedWrites..... %d\n", dev->nRetriedWrites);
1589 buf += sprintf(buf, "nRetireBlocks...... %d\n", dev->nRetiredBlocks);
1590 buf += sprintf(buf, "eccFixed........... %d\n", dev->eccFixed);
1591 buf += sprintf(buf, "eccUnfixed......... %d\n", dev->eccUnfixed);
1592 buf += sprintf(buf, "tagsEccFixed....... %d\n", dev->tagsEccFixed);
1593 buf += sprintf(buf, "tagsEccUnfixed..... %d\n", dev->tagsEccUnfixed);
1594 buf += sprintf(buf, "cacheHits.......... %d\n", dev->cacheHits);
1595 buf += sprintf(buf, "nDeletedFiles...... %d\n", dev->nDeletedFiles);
1596 buf += sprintf(buf, "nUnlinkedFiles..... %d\n", dev->nUnlinkedFiles);
1598 sprintf(buf, "nBackgroudDeletions %d\n", dev->nBackgroundDeletions);
1599 buf += sprintf(buf, "useNANDECC......... %d\n", dev->useNANDECC);
1600 buf += sprintf(buf, "isYaffs2........... %d\n", dev->isYaffs2);
1605 static int yaffs_proc_read(char *page,
1607 off_t offset, int count, int *eof, void *data)
1609 struct list_head *item;
1614 /* Get proc_file_read() to step 'offset' by one on each sucessive call.
1615 * We use 'offset' (*ppos) to indicate where we are in devList.
1616 * This also assumes the user has posted a read buffer large
1617 * enough to hold the complete output; but that's life in /proc.
1622 /* Print header first */
1624 buf += sprintf(buf, "YAFFS built:" __DATE__ " " __TIME__
1625 "\n%s\n%s\n", yaffs_fs_c_version,
1626 yaffs_guts_c_version);
1629 /* hold lock_kernel while traversing yaffs_dev_list */
1632 /* Locate and print the Nth entry. Order N-squared but N is small. */
1633 list_for_each(item, &yaffs_dev_list) {
1634 yaffs_Device *dev = list_entry(item, yaffs_Device, devList);
1639 buf += sprintf(buf, "\nDevice %d \"%s\"\n", n, dev->name);
1640 buf = yaffs_dump_dev(buf, dev);
1645 return buf - page < count ? buf - page : count;
1648 /* Stuff to handle installation of file systems */
1649 struct file_system_to_install {
1650 struct file_system_type *fst;
1654 static struct file_system_to_install fs_to_install[] = {
1655 #ifdef CONFIG_YAFFS_YAFFS1
1656 {&yaffs_fs_type, 0},
1658 #ifdef CONFIG_YAFFS_YAFFS2
1659 {&yaffs2_fs_type, 0},
1664 static int __init init_yaffs_fs(void)
1667 struct file_system_to_install *fsinst;
1669 T(YAFFS_TRACE_ALWAYS,
1670 ("yaffs " __DATE__ " " __TIME__ " Installing. \n"));
1672 /* Install the proc_fs entry */
1673 my_proc_entry = create_proc_read_entry("yaffs",
1676 yaffs_proc_read, NULL);
1677 if (!my_proc_entry) {
1681 /* Now add the file system entries */
1683 fsinst = fs_to_install;
1685 while (fsinst->fst && !error) {
1686 error = register_filesystem(fsinst->fst);
1688 fsinst->installed = 1;
1693 /* Any errors? uninstall */
1695 fsinst = fs_to_install;
1697 while (fsinst->fst) {
1698 if (fsinst->installed) {
1699 unregister_filesystem(fsinst->fst);
1700 fsinst->installed = 0;
1709 static void __exit exit_yaffs_fs(void)
1712 struct file_system_to_install *fsinst;
1714 T(YAFFS_TRACE_ALWAYS, ("yaffs " __DATE__ " " __TIME__
1717 remove_proc_entry("yaffs", &proc_root);
1719 fsinst = fs_to_install;
1721 while (fsinst->fst) {
1722 if (fsinst->installed) {
1723 unregister_filesystem(fsinst->fst);
1724 fsinst->installed = 0;
1731 module_init(init_yaffs_fs)
1732 module_exit(exit_yaffs_fs)
1734 MODULE_DESCRIPTION("YAFFS2 - a NAND specific flash file system");
1735 MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002,2003,2004");
1736 MODULE_LICENSE("GPL");