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.32 2005-10-27 07:22:49 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 /* | 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",
608 nWritten == nBytes ? 0 : -1));
610 return nWritten == nBytes ? 0 : -1;
614 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object * obj)
617 inode->i_ino = obj->objectId;
618 inode->i_mode = obj->yst_mode;
619 inode->i_uid = obj->yst_uid;
620 inode->i_gid = obj->yst_gid;
621 inode->i_blksize = inode->i_sb->s_blocksize;
622 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
624 inode->i_rdev = old_decode_dev(obj->yst_rdev);
625 inode->i_atime.tv_sec = (time_t) (obj->yst_atime);
626 inode->i_atime.tv_nsec = 0;
627 inode->i_mtime.tv_sec = (time_t) obj->yst_mtime;
628 inode->i_mtime.tv_nsec = 0;
629 inode->i_ctime.tv_sec = (time_t) obj->yst_ctime;
630 inode->i_ctime.tv_nsec = 0;
632 inode->i_rdev = obj->yst_rdev;
633 inode->i_atime = obj->yst_atime;
634 inode->i_mtime = obj->yst_mtime;
635 inode->i_ctime = obj->yst_ctime;
637 inode->i_size = yaffs_GetObjectFileLength(obj);
638 inode->i_blocks = (inode->i_size + 511) >> 9;
640 inode->i_nlink = yaffs_GetObjectLinkCount(obj);
644 "yaffs_FillInode mode %x uid %d gid %d size %d count %d\n",
645 inode->i_mode, inode->i_uid, inode->i_gid,
646 (int)inode->i_size, atomic_read(&inode->i_count)));
648 switch (obj->yst_mode & S_IFMT) {
649 default: /* fifo, device or socket */
650 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
651 init_special_inode(inode, obj->yst_mode,
652 old_decode_dev(obj->yst_rdev));
654 init_special_inode(inode, obj->yst_mode,
655 (dev_t) (obj->yst_rdev));
658 case S_IFREG: /* file */
659 inode->i_op = &yaffs_file_inode_operations;
660 inode->i_fop = &yaffs_file_operations;
661 inode->i_mapping->a_ops =
662 &yaffs_file_address_operations;
664 case S_IFDIR: /* directory */
665 inode->i_op = &yaffs_dir_inode_operations;
666 inode->i_fop = &yaffs_dir_operations;
668 case S_IFLNK: /* symlink */
669 inode->i_op = &yaffs_symlink_inode_operations;
673 inode->u.generic_ip = obj;
674 obj->myInode = inode;
678 (KERN_DEBUG "yaffs_FileInode invalid parameters\n"));
683 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,
690 (KERN_DEBUG "yaffs_get_inode for NULL super_block!!\n"));
697 (KERN_DEBUG "yaffs_get_inode for NULL object!!\n"));
703 (KERN_DEBUG "yaffs_get_inode for object %d\n", obj->objectId));
705 inode = iget(sb, obj->objectId);
707 /* NB Side effect: iget calls back to yaffs_read_inode(). */
708 /* iget also increments the inode's i_count */
713 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n,
721 obj = yaffs_DentryToObject(f->f_dentry);
725 yaffs_GrossLock(dev);
727 inode = f->f_dentry->d_inode;
729 if (!S_ISBLK(inode->i_mode) && f->f_flags & O_APPEND) {
730 ipos = inode->i_size;
737 (KERN_DEBUG "yaffs_file_write: hey obj is null!\n"));
741 "yaffs_file_write about to write writing %d bytes"
742 "to object %d at %d\n",
743 n, obj->objectId, ipos));
746 nWritten = yaffs_WriteDataToFile(obj, buf, ipos, n, 0);
749 (KERN_DEBUG "yaffs_file_write writing %d bytes, %d written at %d\n",
754 if (ipos > inode->i_size) {
755 inode->i_size = ipos;
756 inode->i_blocks = (ipos + 511) >> 9;
760 "yaffs_file_write size updated to %d bytes, "
762 ipos, (int)(inode->i_blocks)));
766 yaffs_GrossUnlock(dev);
768 return nWritten != n ? -ENOSPC : nWritten;
771 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
775 struct inode *inode = f->f_dentry->d_inode;
776 unsigned long offset, curoffs;
780 char name[YAFFS_MAX_NAME_LENGTH + 1];
782 obj = yaffs_DentryToObject(f->f_dentry);
785 yaffs_GrossLock(dev);
789 T(YAFFS_TRACE_OS, ("yaffs_readdir: starting at %d\n", (int)offset));
793 (KERN_DEBUG "yaffs_readdir: entry . ino %d \n",
795 if (filldir(dirent, ".", 1, offset, inode->i_ino, DT_DIR)
804 (KERN_DEBUG "yaffs_readdir: entry .. ino %d \n",
805 (int)f->f_dentry->d_parent->d_inode->i_ino));
807 (dirent, "..", 2, offset,
808 f->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) {
817 list_for_each(i, &obj->variant.directoryVariant.children) {
819 if (curoffs >= offset) {
820 l = list_entry(i, yaffs_Object, siblings);
822 yaffs_GetObjectName(l, name,
823 YAFFS_MAX_NAME_LENGTH + 1);
825 (KERN_DEBUG "yaffs_readdir: %s inode %d\n", name,
826 yaffs_GetObjectInode(l)));
832 yaffs_GetObjectInode(l),
833 yaffs_GetObjectType(l))
846 yaffs_GrossUnlock(dev);
852 * File creation. Allocate an inode, and we're done..
854 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
855 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
858 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode,
864 yaffs_Object *obj = NULL;
867 yaffs_Object *parent = yaffs_InodeToObject(dir);
870 uid_t uid = current->fsuid;
871 gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
875 (KERN_DEBUG "yaffs_mknod: parent object %d type %d\n",
876 parent->objectId, parent->variantType));
879 (KERN_DEBUG "yaffs_mknod: could not get parent object\n"));
883 T(YAFFS_TRACE_OS, ("yaffs_mknod: making oject for %s, "
885 dentry->d_name.name, mode, rdev));
889 yaffs_GrossLock(dev);
891 switch (mode & S_IFMT) {
893 /* Special (socket, fifo, device...) */
894 T(YAFFS_TRACE_OS, (KERN_DEBUG
895 "yaffs_mknod: making special\n"));
896 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
898 yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid,
899 gid, old_encode_dev(rdev));
902 yaffs_MknodSpecial(parent, dentry->d_name.name, mode, uid,
906 case S_IFREG: /* file */
907 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_mknod: making file\n"));
909 yaffs_MknodFile(parent, dentry->d_name.name, mode, uid,
912 case S_IFDIR: /* directory */
914 (KERN_DEBUG "yaffs_mknod: making directory\n"));
916 yaffs_MknodDirectory(parent, dentry->d_name.name, mode,
919 case S_IFLNK: /* symlink */
920 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_mknod: making file\n"));
921 obj = NULL; /* Do we ever get here? */
926 inode = yaffs_get_inode(dir->i_sb, mode, rdev, obj);
927 d_instantiate(dentry, inode);
929 (KERN_DEBUG "yaffs_mknod created object %d count = %d\n",
930 obj->objectId, atomic_read(&inode->i_count)));
934 (KERN_DEBUG "yaffs_mknod failed making object\n"));
938 yaffs_GrossUnlock(dev);
943 static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
946 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_mkdir\n"));
947 retVal = yaffs_mknod(dir, dentry, mode | S_IFDIR, 0);
949 /* attempt to fix dir bug - didn't work */
957 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
958 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode,
961 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode)
964 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_create\n"));
965 return yaffs_mknod(dir, dentry, mode | S_IFREG, 0);
968 static int yaffs_unlink(struct inode *dir, struct dentry *dentry)
975 (KERN_DEBUG "yaffs_unlink %d:%s\n", (int)(dir->i_ino),
976 dentry->d_name.name));
978 dev = yaffs_InodeToObject(dir)->myDev;
980 yaffs_GrossLock(dev);
982 retVal = yaffs_Unlink(yaffs_InodeToObject(dir), dentry->d_name.name);
984 yaffs_GrossUnlock(dev);
986 if (retVal == YAFFS_OK) {
987 dentry->d_inode->i_nlink--;
988 mark_inode_dirty(dentry->d_inode);
998 static int yaffs_link(struct dentry *old_dentry, struct inode *dir,
999 struct dentry *dentry)
1001 struct inode *inode = old_dentry->d_inode;
1002 yaffs_Object *obj = NULL;
1003 yaffs_Object *link = NULL;
1006 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_link\n"));
1008 obj = yaffs_InodeToObject(inode);
1011 yaffs_GrossLock(dev);
1013 if (!S_ISDIR(inode->i_mode)) /* Don't link directories */
1016 yaffs_Link(yaffs_InodeToObject(dir), dentry->d_name.name,
1021 old_dentry->d_inode->i_nlink = yaffs_GetObjectLinkCount(obj);
1022 d_instantiate(dentry, old_dentry->d_inode);
1023 atomic_inc(&old_dentry->d_inode->i_count);
1025 (KERN_DEBUG "yaffs_link link count %d i_count %d\n",
1026 old_dentry->d_inode->i_nlink,
1027 atomic_read(&old_dentry->d_inode->i_count)));
1031 yaffs_GrossUnlock(dev);
1041 static int yaffs_symlink(struct inode *dir, struct dentry *dentry,
1042 const char *symname)
1046 uid_t uid = current->fsuid;
1047 gid_t gid = (dir->i_mode & S_ISGID) ? dir->i_gid : current->fsgid;
1049 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_symlink\n"));
1051 dev = yaffs_InodeToObject(dir)->myDev;
1052 yaffs_GrossLock(dev);
1053 obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name,
1054 S_IFLNK | S_IRWXUGO, uid, gid, symname);
1055 yaffs_GrossUnlock(dev);
1059 struct inode *inode;
1061 inode = yaffs_get_inode(dir->i_sb, obj->yst_mode, 0, obj);
1062 d_instantiate(dentry, inode);
1063 T(YAFFS_TRACE_OS, (KERN_DEBUG "symlink created OK\n"));
1066 T(YAFFS_TRACE_OS, (KERN_DEBUG "symlink not created\n"));
1073 static int yaffs_sync_object(struct file *file, struct dentry *dentry,
1080 obj = yaffs_DentryToObject(dentry);
1084 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_sync_object\n"));
1085 yaffs_GrossLock(dev);
1086 yaffs_FlushFile(obj, 1);
1087 yaffs_GrossUnlock(dev);
1092 * The VFS layer already does all the dentry stuff for rename.
1094 * NB: POSIX says you can rename an object over an old object of the same name
1096 static int yaffs_rename(struct inode *old_dir, struct dentry *old_dentry,
1097 struct inode *new_dir, struct dentry *new_dentry)
1100 int retVal = YAFFS_FAIL;
1101 yaffs_Object *target;
1103 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_rename\n"));
1104 dev = yaffs_InodeToObject(old_dir)->myDev;
1106 yaffs_GrossLock(dev);
1108 /* Check if the target is an existing directory that is not empty. */
1110 yaffs_FindObjectByName(yaffs_InodeToObject(new_dir),
1111 new_dentry->d_name.name);
1116 target->variantType == YAFFS_OBJECT_TYPE_DIRECTORY &&
1117 !list_empty(&target->variant.directoryVariant.children)) {
1119 T(YAFFS_TRACE_OS, (KERN_DEBUG "target is non-empty dir\n"));
1121 retVal = YAFFS_FAIL;
1124 /* Now does unlinking internally using shadowing mechanism */
1125 T(YAFFS_TRACE_OS, (KERN_DEBUG "calling yaffs_RenameObject\n"));
1128 yaffs_RenameObject(yaffs_InodeToObject(old_dir),
1129 old_dentry->d_name.name,
1130 yaffs_InodeToObject(new_dir),
1131 new_dentry->d_name.name);
1134 yaffs_GrossUnlock(dev);
1136 if (retVal == YAFFS_OK) {
1138 new_dentry->d_inode->i_nlink--;
1139 mark_inode_dirty(new_dentry->d_inode);
1149 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr)
1151 struct inode *inode = dentry->d_inode;
1156 (KERN_DEBUG "yaffs_setattr of object %d\n",
1157 yaffs_InodeToObject(inode)->objectId));
1159 if ((error = inode_change_ok(inode, attr)) == 0) {
1161 dev = yaffs_InodeToObject(inode)->myDev;
1162 yaffs_GrossLock(dev);
1163 if (yaffs_SetAttributes(yaffs_InodeToObject(inode), attr) ==
1169 yaffs_GrossUnlock(dev);
1171 error = inode_setattr(inode, attr);
1176 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1177 static int yaffs_statfs(struct super_block *sb, struct kstatfs *buf)
1179 static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
1183 yaffs_Device *dev = yaffs_SuperToDevice(sb);
1184 T(YAFFS_TRACE_OS, (KERN_DEBUG "yaffs_statfs\n"));
1186 yaffs_GrossLock(dev);
1188 buf->f_type = YAFFS_MAGIC;
1189 buf->f_bsize = sb->s_blocksize;
1190 buf->f_namelen = 255;
1191 if (sb->s_blocksize > dev->nBytesPerChunk) {
1194 (dev->endBlock - dev->startBlock +
1195 1) * dev->nChunksPerBlock / (sb->s_blocksize /
1196 dev->nBytesPerChunk);
1198 yaffs_GetNumberOfFreeChunks(dev) / (sb->s_blocksize /
1199 dev->nBytesPerChunk);
1203 (dev->endBlock - dev->startBlock +
1204 1) * dev->nChunksPerBlock * (dev->nBytesPerChunk /
1207 yaffs_GetNumberOfFreeChunks(dev) * (dev->nBytesPerChunk /
1212 buf->f_bavail = buf->f_bfree;
1214 yaffs_GrossUnlock(dev);
1218 static void yaffs_read_inode(struct inode *inode)
1220 /* NB This is called as a side effect of other functions and
1221 * thus gross locking should always be in place already.
1225 yaffs_Device *dev = yaffs_SuperToDevice(inode->i_sb);
1228 (KERN_DEBUG "yaffs_read_inode for %d\n", (int)inode->i_ino));
1230 obj = yaffs_FindObjectByNumber(dev, inode->i_ino);
1232 yaffs_FillInodeFromObject(inode, obj);
1236 static LIST_HEAD(yaffs_dev_list);
1238 static void yaffs_put_super(struct super_block *sb)
1240 yaffs_Device *dev = yaffs_SuperToDevice(sb);
1242 yaffs_GrossLock(dev);
1243 if (dev->putSuperFunc) {
1244 dev->putSuperFunc(sb);
1246 yaffs_Deinitialise(dev);
1247 yaffs_GrossUnlock(dev);
1249 /* we assume this is protected by lock_kernel() in mount/umount */
1250 list_del(&dev->devList);
1256 static void yaffs_MTDPutSuper(struct super_block *sb)
1259 struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
1265 put_mtd_device(mtd);
1269 static struct super_block *yaffs_internal_read_super(int yaffsVersion,
1270 struct super_block *sb,
1271 void *data, int silent)
1274 struct inode *inode = NULL;
1275 struct dentry *root;
1276 yaffs_Device *dev = 0;
1277 char devname_buf[BDEVNAME_SIZE + 1];
1278 struct mtd_info *mtd;
1281 sb->s_magic = YAFFS_MAGIC;
1282 sb->s_op = &yaffs_super_ops;
1285 printk(KERN_INFO "yaffs: sb is NULL\n");
1286 else if (!sb->s_dev)
1287 printk(KERN_INFO "yaffs: sb->s_dev is NULL\n");
1288 else if (!yaffs_devname(sb, devname_buf))
1289 printk(KERN_INFO "yaffs: devname is NULL\n");
1291 printk(KERN_INFO "yaffs: dev is %d name is \"%s\"\n",
1293 yaffs_devname(sb, devname_buf));
1295 sb->s_blocksize = PAGE_CACHE_SIZE;
1296 sb->s_blocksize_bits = PAGE_CACHE_SHIFT;
1297 T(YAFFS_TRACE_OS, ("yaffs_read_super: Using yaffs%d\n", yaffsVersion));
1299 ("yaffs_read_super: block size %d\n", (int)(sb->s_blocksize)));
1301 #ifdef CONFIG_YAFFS_DISABLE_WRITE_VERIFY
1303 ("yaffs: Write verification disabled. All guarantees "
1304 "null and void\n"));
1307 T(YAFFS_TRACE_ALWAYS, ("yaffs: Attempting MTD mount on %u.%u, "
1309 MAJOR(sb->s_dev), MINOR(sb->s_dev),
1310 yaffs_devname(sb, devname_buf)));
1312 /* Check it's an mtd device..... */
1313 if (MAJOR(sb->s_dev) != MTD_BLOCK_MAJOR) {
1314 return NULL; /* This isn't an mtd device */
1316 /* Get the device */
1317 mtd = get_mtd_device(NULL, MINOR(sb->s_dev));
1319 T(YAFFS_TRACE_ALWAYS,
1320 ("yaffs: MTD device #%u doesn't appear to exist\n",
1324 /* Check it's NAND */
1325 if (mtd->type != MTD_NANDFLASH) {
1326 T(YAFFS_TRACE_ALWAYS,
1327 ("yaffs: MTD device is not NAND it's type %d\n", mtd->type));
1331 T(YAFFS_TRACE_OS, (" erase %p\n", mtd->erase));
1332 T(YAFFS_TRACE_OS, (" read %p\n", mtd->read));
1333 T(YAFFS_TRACE_OS, (" write %p\n", mtd->write));
1334 T(YAFFS_TRACE_OS, (" readoob %p\n", mtd->read_oob));
1335 T(YAFFS_TRACE_OS, (" writeoob %p\n", mtd->write_oob));
1336 T(YAFFS_TRACE_OS, (" block_isbad %p\n", mtd->block_isbad));
1337 T(YAFFS_TRACE_OS, (" block_markbad %p\n", mtd->block_markbad));
1338 T(YAFFS_TRACE_OS, (" oobblock %d\n", mtd->oobblock));
1339 T(YAFFS_TRACE_OS, (" oobsize %d\n", mtd->oobsize));
1340 T(YAFFS_TRACE_OS, (" erasesize %d\n", mtd->erasesize));
1341 T(YAFFS_TRACE_OS, (" size %d\n", mtd->size));
1343 if (yaffsVersion == 2) {
1344 /* Check for version 2 style functions */
1346 !mtd->block_isbad ||
1347 !mtd->block_markbad ||
1351 !mtd->read_ecc || !mtd->read_oob || !mtd->write_oob) {
1352 T(YAFFS_TRACE_ALWAYS,
1353 ("yaffs: MTD device does not support required "
1358 if (mtd->oobblock < YAFFS_MIN_YAFFS2_CHUNK_SIZE ||
1359 mtd->oobsize < YAFFS_MIN_YAFFS2_SPARE_SIZE) {
1360 T(YAFFS_TRACE_ALWAYS,
1361 ("yaffs: MTD device does not support have the "
1362 "right page sizes\n"));
1366 /* Check for V1 style functions */
1371 !mtd->read_ecc || !mtd->read_oob || !mtd->write_oob) {
1372 T(YAFFS_TRACE_ALWAYS,
1373 ("yaffs: MTD device does not support required "
1378 if (mtd->oobblock != YAFFS_BYTES_PER_CHUNK ||
1379 mtd->oobsize != YAFFS_BYTES_PER_SPARE) {
1380 T(YAFFS_TRACE_ALWAYS,
1381 ("yaffs: MTD device does not support have the "
1382 "right page sizes\n"));
1387 /* OK, so if we got here, we have an MTD that's NAND and looks
1388 * like it has the right capabilities
1389 * Set the yaffs_Device up for mtd
1392 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1393 sb->s_fs_info = dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL);
1395 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device), GFP_KERNEL);
1398 /* Deep shit could not allocate device structure */
1399 T(YAFFS_TRACE_ALWAYS,
1400 ("yaffs_read_super: Failed trying to allocate "
1401 "yaffs_Device. \n"));
1405 memset(dev, 0, sizeof(yaffs_Device));
1406 dev->genericDevice = mtd;
1407 dev->name = mtd->name;
1409 /* Set up the memory size parameters.... */
1411 nBlocks = mtd->size / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
1412 dev->startBlock = 0;
1413 dev->endBlock = nBlocks - 1;
1414 dev->nChunksPerBlock = YAFFS_CHUNKS_PER_BLOCK;
1415 dev->nBytesPerChunk = YAFFS_BYTES_PER_CHUNK;
1416 dev->nReservedBlocks = 5;
1417 dev->nShortOpCaches = 10; /* Enable short op caching */
1419 /* ... and the functions. */
1420 if (yaffsVersion == 2) {
1421 dev->writeChunkWithTagsToNAND =
1422 nandmtd2_WriteChunkWithTagsToNAND;
1423 dev->readChunkWithTagsFromNAND =
1424 nandmtd2_ReadChunkWithTagsFromNAND;
1425 dev->markNANDBlockBad = nandmtd2_MarkNANDBlockBad;
1426 dev->queryNANDBlock = nandmtd2_QueryNANDBlock;
1427 dev->spareBuffer = YMALLOC(mtd->oobsize);
1429 dev->nBytesPerChunk = mtd->oobblock;
1430 dev->nChunksPerBlock = mtd->erasesize / mtd->oobblock;
1431 nBlocks = mtd->size / mtd->erasesize;
1432 dev->startBlock = 0;
1433 dev->endBlock = nBlocks - 1;
1435 dev->writeChunkToNAND = nandmtd_WriteChunkToNAND;
1436 dev->readChunkFromNAND = nandmtd_ReadChunkFromNAND;
1439 /* ... and common functions */
1440 dev->eraseBlockInNAND = nandmtd_EraseBlockInNAND;
1441 dev->initialiseNAND = nandmtd_InitialiseNAND;
1443 dev->putSuperFunc = yaffs_MTDPutSuper;
1445 #ifndef CONFIG_YAFFS_DOES_ECC
1446 dev->useNANDECC = 1;
1449 /* we assume this is protected by lock_kernel() in mount/umount */
1450 list_add_tail(&dev->devList, &yaffs_dev_list);
1452 init_MUTEX(&dev->grossLock);
1454 yaffs_GrossLock(dev);
1456 err = yaffs_GutsInitialise(dev);
1459 ("yaffs_read_super: guts initialised %s\n",
1460 (err == YAFFS_OK) ? "OK" : "FAILED"));
1462 /* Create root inode */
1463 if (err == YAFFS_OK)
1464 inode = yaffs_get_inode(sb, S_IFDIR | 0755, 0,
1467 yaffs_GrossUnlock(dev);
1472 inode->i_op = &yaffs_dir_inode_operations;
1473 inode->i_fop = &yaffs_dir_operations;
1475 T(YAFFS_TRACE_OS, ("yaffs_read_super: got root inode\n"));
1477 root = d_alloc_root(inode);
1479 T(YAFFS_TRACE_OS, ("yaffs_read_super: d_alloc_root done\n"));
1487 T(YAFFS_TRACE_OS, ("yaffs_read_super: done\n"));
1492 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
1493 static int yaffs_internal_read_super_mtd(struct super_block *sb, void *data,
1496 return yaffs_internal_read_super(1, sb, data, silent) ? 0 : -1;
1499 static struct super_block *yaffs_read_super(struct file_system_type *fs,
1500 int flags, const char *dev_name,
1504 return get_sb_bdev(fs, flags, dev_name, data,
1505 yaffs_internal_read_super_mtd);
1508 static struct file_system_type yaffs_fs_type = {
1509 .owner = THIS_MODULE,
1511 .get_sb = yaffs_read_super,
1512 .kill_sb = kill_block_super,
1513 .fs_flags = FS_REQUIRES_DEV,
1516 static struct super_block *yaffs_read_super(struct super_block *sb, void *data,
1519 return yaffs_internal_read_super(1, sb, data, silent);
1522 static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super,
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");