2 * YAFFS: Yet another FFS. A NAND-flash specific file system.
5 * Copyright (C) 2002 Aleph One Ltd.
6 * for Toby Churchill Ltd and Brightstar Engineering
8 * Created by Charles Manning <charles@aleph1.co.uk>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
14 * This is the file system front-end to YAFFS that hooks it up to
18 * >> sb->u.generic_sbp points to the yaffs_Device associated with this superblock
19 * >> inode->u.generic_ip points to the associated yaffs_Object.
23 #include <linux/config.h>
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/version.h>
27 #include <linux/slab.h>
28 #include <linux/init.h>
29 #include <linux/list.h>
31 #include <linux/proc_fs.h>
32 #include <linux/pagemap.h>
33 #include <linux/mtd/mtd.h>
34 #include <linux/interrupt.h>
35 #include <linux/string.h>
36 #include <linux/locks.h>
38 #include <asm/uaccess.h>
40 #include "yaffs_guts.h"
42 #ifdef YAFFS_RAM_ENABLED
43 #include "yaffs_nandemul.h"
44 // 2 MB of RAM for emulation
45 #define YAFFS_RAM_EMULATION_SIZE 0x200000
46 #endif //YAFFS_RAM_ENABLED
48 #ifdef YAFFS_MTD_ENABLED
49 #include <linux/mtd/mtd.h>
50 #include "yaffs_mtdif.h"
51 #endif //YAFFS_MTD_ENABLED
57 #define yaffs_InodeToObject(iptr) ((yaffs_Object *)((iptr)->u.generic_ip))
58 #define yaffs_DentryToObject(dptr) yaffs_InodeToObject((dptr)->d_inode)
59 #define yaffs_SuperToDevice(sb) ((yaffs_Device *)sb->u.generic_sbp)
63 static void yaffs_put_super(struct super_block *sb);
65 static ssize_t yaffs_file_read(struct file *f, char *buf, size_t n, loff_t *pos);
66 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, loff_t *pos);
68 static int yaffs_sync_object(struct file * file, struct dentry *dentry, int datasync);
70 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir);
72 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode);
73 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry);
74 static int yaffs_link(struct dentry *old_dentry, struct inode * dir, struct dentry * dentry);
75 static int yaffs_unlink(struct inode * dir, struct dentry *dentry);
76 static int yaffs_symlink(struct inode * dir, struct dentry *dentry, const char * symname);
77 static int yaffs_mkdir(struct inode * dir, struct dentry * dentry, int mode);
78 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev);
79 static int yaffs_rename(struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry);
80 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr);
82 static int yaffs_statfs(struct super_block *sb, struct statfs *buf);
83 static void yaffs_read_inode (struct inode *inode);
84 static struct super_block *yaffs_read_super(struct super_block * sb, void * data, int silent);
85 static void yaffs_put_inode (struct inode *inode);
86 static int yaffs_readpage(struct file *file, struct page * page);
89 static int yaffs_readlink(struct dentry *dentry, char *buffer, int buflen);
90 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd);
96 static struct address_space_operations yaffs_file_address_operations = {
97 readpage: yaffs_readpage,
98 // prepare_write: yaffs_prepare_write,
99 // commit_write: yaffs_commit_write
103 static struct file_operations yaffs_file_operations = {
104 read: yaffs_file_read,
105 write: yaffs_file_write,
106 mmap: generic_file_mmap,
107 fsync: yaffs_sync_object,
111 static struct inode_operations yaffs_file_inode_operations = {
112 setattr: yaffs_setattr,
116 struct inode_operations yaffs_symlink_inode_operations =
118 readlink: yaffs_readlink,
119 follow_link: yaffs_follow_link,
120 setattr: yaffs_setattr
123 static struct inode_operations yaffs_dir_inode_operations = {
124 create: yaffs_create,
125 lookup: yaffs_lookup,
127 unlink: yaffs_unlink,
128 symlink: yaffs_symlink,
132 rename: yaffs_rename,
133 setattr: yaffs_setattr,
136 static struct file_operations yaffs_dir_operations = {
137 read: generic_read_dir,
138 readdir: yaffs_readdir,
139 fsync: yaffs_sync_object,
143 static struct super_operations yaffs_super_ops = {
144 statfs: yaffs_statfs,
145 read_inode: yaffs_read_inode,
146 put_inode: yaffs_put_inode,
147 put_super: yaffs_put_super,
157 static int yaffs_readlink(struct dentry *dentry, char *buffer, int buflen)
159 unsigned char *alias;
162 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
167 ret = vfs_readlink(dentry, buffer, buflen, alias);
172 static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd)
174 unsigned char *alias;
176 alias = yaffs_GetSymlinkAlias(yaffs_DentryToObject(dentry));
181 ret = vfs_follow_link(nd,alias);
187 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,yaffs_Object *obj);
190 * Lookup is used to find objects in the fs
192 static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry)
198 T((KERN_DEBUG"yaffs_lookup for %d:%s\n",yaffs_InodeToObject(dir)->objectId,dentry->d_name.name));
200 obj = yaffs_FindObjectByName(yaffs_InodeToObject(dir),dentry->d_name.name);
202 obj = yaffs_GetEquivalentObject(obj); // in case it was a hardlink
206 T((KERN_DEBUG"yaffs_lookup found %d\n",obj->objectId));
208 inode = yaffs_get_inode(dir->i_sb, obj->st_mode,0,obj);
212 T((KERN_DEBUG"yaffs_loookup looks good\n"));
213 dget(dentry); // try to solve directory bug
221 T((KERN_DEBUG"yaffs_lookup not found\n"));
228 // For now put inode is just for debugging
229 static void yaffs_put_inode(struct inode *inode)
231 T(("yaffs_put_inode: ino %d, count %d\n",(int)inode->i_ino, atomic_read(&inode->i_count)));
233 yaffs_FlushFile(yaffs_InodeToObject(inode));
239 static int yaffs_readpage(struct file *f, struct page * pg)
242 unsigned char *pg_buf;
245 T((KERN_DEBUG"yaffs_readpage at %08x, size %08x\n",
246 pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE));
248 obj = yaffs_DentryToObject(f->f_dentry);
256 /* FIXME: Can kmap fail? */
258 ret = yaffs_ReadDataFromFile(obj, pg_buf, pg->index << PAGE_CACHE_SHIFT, PAGE_CACHE_SIZE);
260 if(ret >= 0) ret = 0;
263 ClearPageUptodate(pg);
270 flush_dcache_page(pg);
277 T((KERN_DEBUG"yaffs_readpage done\n"));
281 #ifdef YAFFS_ADDRESS_OPS
283 static int yaffs_prepare_write(struct file *file, struct page *page, unsigned offset, unsigned to)
285 T((KERN_DEBUG"yaffs_prepare_write\n"));
291 static int yaffs_commit_write(struct file *file, struct page *page, unsigned offset, unsigned to)
294 struct inode *inode = page->mapping->host;
295 loff_t pos = ((loff_t)page->index << PAGE_CACHE_SHIFT) + to;
297 T((KERN_DEBUG"yaffs_commit_write\n"));
302 #endif //YAFFS_ADDRESS_OPS
305 static void yaffs_FillInodeFromObject(struct inode *inode, yaffs_Object *obj)
309 inode->i_ino = obj->objectId;
310 inode->i_mode = obj->st_mode;
311 inode->i_uid = obj->st_uid;
312 inode->i_gid = obj->st_gid;
313 inode->i_blksize = YAFFS_BYTES_PER_CHUNK;
315 inode->i_rdev = obj->st_rdev;;
316 inode->i_atime = obj->st_atime;
317 inode->i_mtime = obj->st_mtime;
318 inode->i_ctime = obj->st_ctime;
319 inode->i_size = yaffs_GetObjectFileLength(obj);
320 inode->i_nlink = yaffs_GetObjectLinkCount(obj);
322 T((KERN_DEBUG"yaffs_FillInode mode %x uid %d gid %d size %d count %d\n",
323 inode->i_mode, inode->i_uid, inode->i_gid, (int)inode->i_size, atomic_read(&inode->i_count)));
325 switch (obj->st_mode & S_IFMT)
327 default: // fifo, device or socket
328 init_special_inode(inode, obj->st_mode, obj->st_rdev);
330 case S_IFREG: // file
331 inode->i_op = &yaffs_file_inode_operations;
332 inode->i_fop = &yaffs_file_operations;
333 inode->i_mapping->a_ops = &yaffs_file_address_operations;
335 case S_IFDIR: // directory
336 inode->i_op = &yaffs_dir_inode_operations;
337 inode->i_fop = &yaffs_dir_operations;
339 case S_IFLNK: // symlink
340 inode->i_op = &yaffs_symlink_inode_operations;
345 inode->u.generic_ip = obj;
350 T((KERN_DEBUG"yaffs_FileInode invalid parameters\n"));
355 struct inode *yaffs_get_inode(struct super_block *sb, int mode, int dev,yaffs_Object *obj)
357 struct inode * inode;
359 T((KERN_DEBUG"yaffs_get_inode for object %d\n",obj->objectId));
361 inode = iget(sb,obj->objectId);
363 // No need to call this since iget calls it via the read_inode callback
364 // yaffs_FillInodeFromObject(inode,obj);
369 static ssize_t yaffs_file_read(struct file *f, char *buf, size_t n, loff_t *pos)
375 T((KERN_DEBUG"yaffs_file_read\n"));
377 obj = yaffs_DentryToObject(f->f_dentry);
378 inode = f->f_dentry->d_inode;
380 if (*pos < inode->i_size)
382 if (*pos + n > inode->i_size)
384 n = inode->i_size - *pos;
392 nRead = yaffs_ReadDataFromFile(obj,buf,*pos,n);
398 T((KERN_DEBUG"yaffs_file_read read %d bytes, %d read at %d\n",n,nRead,ipos));
403 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, loff_t *pos)
409 obj = yaffs_DentryToObject(f->f_dentry);
410 inode = f->f_dentry->d_inode;
411 nWritten = yaffs_WriteDataToFile(obj,buf,*pos,n);
413 T((KERN_DEBUG"yaffs_file_write writing %d bytes, %d written at %d\n",n,nWritten,ipos));
418 if(*pos > inode->i_size)
420 inode->i_size = *pos;
421 T((KERN_DEBUG"yaffs_file_write size updated to %d\n",ipos));
429 static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir)
432 struct inode *inode = f->f_dentry->d_inode;
433 unsigned long offset, curoffs;
437 char name[YAFFS_MAX_NAME_LENGTH +1];
439 obj = yaffs_DentryToObject(f->f_dentry);
443 T(("yaffs_readdir: starting at %d\n",(int)offset));
447 T((KERN_DEBUG"yaffs_readdir: entry . ino %d \n",(int)inode->i_ino));
448 if(filldir(dirent,".",1,offset,inode->i_ino,DT_DIR) < 0)
457 T((KERN_DEBUG"yaffs_readdir: entry .. ino %d \n",(int)f->f_dentry->d_parent->d_inode->i_ino));
458 if(filldir(dirent,"..",2,offset,f->f_dentry->d_parent->d_inode->i_ino,DT_DIR) < 0)
471 list_for_each(i,&obj->variant.directoryVariant.children)
474 if(curoffs >= offset)
476 l = list_entry(i, yaffs_Object,siblings);
478 yaffs_GetObjectName(l,name,YAFFS_MAX_NAME_LENGTH+1);
479 T((KERN_DEBUG"yaffs_readdir: %s inode %d\n",name,yaffs_GetObjectInode(l)));
485 yaffs_GetObjectInode(l),
486 yaffs_GetObjectType(l))
507 * File creation. Allocate an inode, and we're done..
509 static int yaffs_mknod(struct inode *dir, struct dentry *dentry, int mode, int dev)
513 yaffs_Object *obj = NULL;
514 yaffs_Object *parent = yaffs_InodeToObject(dir);
520 T((KERN_DEBUG"yaffs_mknod: parent object %d type %d\n",
521 parent->objectId,parent->variantType));
525 T((KERN_DEBUG"yaffs_mknod: could not get parent object\n"));
529 T(("yaffs_mknod: making oject for %s, mode %x dev %x\n",
530 dentry->d_name.name, mode,dev));
532 switch (mode & S_IFMT)
535 // Special (socket, fifo, device...)
536 T((KERN_DEBUG"yaffs_mknod: making special\n"));
537 obj = yaffs_MknodSpecial(parent,dentry->d_name.name,mode,current->uid, current->gid,dev);
539 case S_IFREG: // file
540 T((KERN_DEBUG"yaffs_mknod: making file\n"));
541 obj = yaffs_MknodFile(parent,dentry->d_name.name,mode,current->uid, current->gid);
543 case S_IFDIR: // directory
544 T((KERN_DEBUG"yaffs_mknod: making directory\n"));
545 obj = yaffs_MknodDirectory(parent,dentry->d_name.name,mode,current->uid, current->gid);
547 case S_IFLNK: // symlink
548 T((KERN_DEBUG"yaffs_mknod: making file\n"));
549 obj = NULL; // Do we ever get here?
555 inode = yaffs_get_inode(dir->i_sb, mode, dev, obj);
556 d_instantiate(dentry, inode);
557 T((KERN_DEBUG"yaffs_mknod created object %d count = %d\n",obj->objectId,atomic_read(&inode->i_count)));
562 T((KERN_DEBUG"yaffs_mknod failed making object\n"));
570 static int yaffs_mkdir(struct inode * dir, struct dentry * dentry, int mode)
573 T((KERN_DEBUG"yaffs_mkdir\n"));
574 retVal = yaffs_mknod(dir, dentry, mode | S_IFDIR, 0);
576 // attempt to fix dir bug - didn't work
585 static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode)
587 T((KERN_DEBUG"yaffs_create\n"));
588 return yaffs_mknod(dir, dentry, mode | S_IFREG, 0);
592 static int yaffs_unlink(struct inode * dir, struct dentry *dentry)
595 T((KERN_DEBUG"yaffs_unlink\n"));
597 if(yaffs_Unlink(yaffs_InodeToObject(dir),dentry->d_name.name) == YAFFS_OK)
611 static int yaffs_link(struct dentry *old_dentry, struct inode * dir, struct dentry * dentry)
613 struct inode *inode = old_dentry->d_inode;
614 yaffs_Object *obj = NULL;
615 yaffs_Object *link=NULL;
617 T((KERN_DEBUG"yaffs_link\n"));
619 obj = yaffs_InodeToObject(inode);
621 link = yaffs_Link(yaffs_InodeToObject(dir),dentry->d_name.name,obj);
633 static int yaffs_symlink(struct inode * dir, struct dentry *dentry, const char * symname)
637 T((KERN_DEBUG"yaffs_symlink\n"));
639 obj = yaffs_MknodSymLink(yaffs_InodeToObject(dir), dentry->d_name.name,
640 S_IFLNK | S_IRWXUGO, current->uid, current->gid,
645 T((KERN_DEBUG"symlink created OK\n"));
650 T((KERN_DEBUG"symlink not created\n"));
657 static int yaffs_sync_object(struct file * file, struct dentry *dentry, int datasync)
660 T((KERN_DEBUG"yaffs_sync_object\n"));
661 yaffs_FlushFile(yaffs_DentryToObject(dentry));
666 * The VFS layer already does all the dentry stuff for rename.
668 static int yaffs_rename(struct inode * old_dir, struct dentry *old_dentry, struct inode * new_dir,struct dentry *new_dentry)
672 if( yaffs_RenameObject(yaffs_InodeToObject(old_dir),old_dentry->d_name.name,
673 yaffs_InodeToObject(new_dir),new_dentry->d_name.name) == YAFFS_OK)
685 static int yaffs_setattr(struct dentry *dentry, struct iattr *attr)
687 struct inode *inode = dentry->d_inode;
690 T((KERN_DEBUG"yaffs_setattr\n"));
692 if((error = inode_change_ok(inode,attr)) == 0)
695 if(yaffs_SetAttributes(yaffs_InodeToObject(inode),attr) == YAFFS_OK)
704 inode_setattr(inode,attr);
709 static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
711 T((KERN_DEBUG"yaffs_statfs\n"));
713 buf->f_type = YAFFS_MAGIC;
714 buf->f_bsize = YAFFS_BYTES_PER_CHUNK;
715 buf->f_namelen = 255;
716 buf->f_blocks = yaffs_SuperToDevice(sb)->nBlocks * YAFFS_CHUNKS_PER_BLOCK;
719 buf->f_bavail = buf->f_bfree = yaffs_GetNumberOfFreeChunks(yaffs_SuperToDevice(sb));
723 static void yaffs_read_inode (struct inode *inode)
728 T((KERN_DEBUG"yaffs_read_inode for %d\n",(int)inode->i_ino));
730 obj = yaffs_FindObjectByNumber(yaffs_SuperToDevice(inode->i_sb),inode->i_ino);
732 yaffs_FillInodeFromObject(inode,obj);
736 static void yaffs_put_super(struct super_block *sb)
738 yaffs_Device *dev = yaffs_SuperToDevice(sb);
740 if(dev->putSuperFunc)
742 dev->putSuperFunc(sb);
747 #ifdef YAFFS_MTD_ENABLED
749 static void yaffs_MTDPutSuper(struct super_block *sb)
752 struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
764 static struct super_block *yaffs_internal_read_super(int useRam, struct super_block * sb, void * data, int silent)
766 struct inode * inode;
767 struct dentry * root;
771 T(("yaffs_read_super: %s\n", useRam ? "RAM" : "MTD"));
772 sb->s_blocksize = YAFFS_BYTES_PER_CHUNK;
773 sb->s_blocksize_bits = YAFFS_CHUNK_SIZE_SHIFT;
774 sb->s_magic = YAFFS_MAGIC;
775 sb->s_op = &yaffs_super_ops;
778 printk(KERN_INFO"yaffs: sb is NULL\n");
780 printk(KERN_INFO"yaffs: sb->s_dev is NULL\n");
781 else if(! kdevname(sb->s_dev))
782 printk(KERN_INFO"yaffs: kdevname is NULL\n");
784 printk(KERN_INFO"yaffs: dev is %d name is \"%s\"\n", sb->s_dev, kdevname(sb->s_dev));
791 #ifdef YAFFS_RAM_ENABLED
792 // Set the yaffs_Device up for ram emulation
794 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
797 // Deep shit could not allocate device structure
798 printk(KERN_DEBUG"yaffs_read_super: Failed trying to allocate yaffs_Device. Terminating debug.\n");
802 memset(dev,0,sizeof(yaffs_Device));
803 dev->genericDevice = NULL; // Not used for RAM emulation.
805 dev->nBlocks = YAFFS_RAM_EMULATION_SIZE / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
806 dev->startBlock = 1; // Don't use block 0
807 dev->endBlock = dev->nBlocks - 1;
809 dev->writeChunkToNAND = nandemul_WriteChunkToNAND;
810 dev->readChunkFromNAND = nandemul_ReadChunkFromNAND;
811 dev->eraseBlockInNAND = nandemul_EraseBlockInNAND;
812 dev->initialiseNAND = nandemul_InitialiseNAND;
819 #ifdef YAFFS_MTD_ENABLED
820 struct mtd_info *mtd;
822 printk(KERN_DEBUG "yaffs: Attempting MTD mount on %u.%u, \"%s\"\n",
823 MAJOR(sb->s_dev),MINOR(sb->s_dev),kdevname(sb->s_dev));
825 // Hope it's a NAND mtd
826 mtd = get_mtd_device(NULL, MINOR(sb->s_dev));
829 printk(KERN_DEBUG "yaffs: MTD device #%u doesn't appear to exist\n", MINOR(sb->s_dev));
833 if(mtd->type != MTD_NANDFLASH)
835 printk(KERN_DEBUG "yaffs: MTD device is not NAND it's type %d\n", mtd->type);
839 printk(KERN_DEBUG" erase %x\n",mtd->erase);
840 printk(KERN_DEBUG" read %x\n",mtd->read);
841 printk(KERN_DEBUG" write %x\n",mtd->write);
842 printk(KERN_DEBUG" readoob %x\n",mtd->read_oob);
843 printk(KERN_DEBUG" writeoob %x\n",mtd->write_oob);
844 printk(KERN_DEBUG" oobblock %x\n",mtd->oobblock);
845 printk(KERN_DEBUG" oobsize %x\n",mtd->oobsize);
854 printk(KERN_DEBUG "yaffs: MTD device does not support required functions\n");
858 if(mtd->oobblock != YAFFS_BYTES_PER_CHUNK ||
859 mtd->oobsize != YAFFS_BYTES_PER_SPARE)
861 printk(KERN_DEBUG "yaffs: MTD device does not support have the right page sizes\n");
866 // OK, so if we got here, we have an MTD that's NAND and looks
867 // like it has the right capabilities
868 // Set the yaffs_Device up for ram emulation
870 sb->u.generic_sbp = dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
873 // Deep shit could not allocate device structure
874 printk(KERN_DEBUG"yaffs_read_super: Failed trying to allocate yaffs_Device. Terminating debug.\n");
878 memset(dev,0,sizeof(yaffs_Device));
879 dev->genericDevice = mtd;
881 // Set up the memory size parameters....
883 // NCB dev->nBlocks = YAFFS_RAM_EMULATION_SIZE / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
884 dev->nBlocks = mtd->size / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
885 dev->startBlock = 1; // Don't use block 0
886 dev->endBlock = dev->nBlocks - 1;
888 // ... and the functions.
889 dev->writeChunkToNAND = nandmtd_WriteChunkToNAND;
890 dev->readChunkFromNAND = nandmtd_ReadChunkFromNAND;
891 dev->eraseBlockInNAND = nandmtd_EraseBlockInNAND;
892 dev->initialiseNAND = nandmtd_InitialiseNAND;
894 dev->putSuperFunc = yaffs_MTDPutSuper;
900 yaffs_GutsInitialise(yaffs_SuperToDevice(sb));
901 T(("yaffs_read_super: guts initialised\n"));
904 inode = yaffs_get_inode(sb, S_IFDIR | 0755, 0,yaffs_Root(yaffs_SuperToDevice(sb)));
908 T(("yaffs_read_super: got root inode\n"));
911 root = d_alloc_root(inode);
913 T(("yaffs_read_super: d_alloc_root done\n"));
921 T(("yaffs_read_super: done\n"));
925 #ifdef YAFFS_MTD_ENABLED
926 static struct super_block *yaffs_read_super(struct super_block * sb, void * data, int silent)
928 return yaffs_internal_read_super(0,sb,data,silent);
931 static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
934 #ifdef YAFFS_RAM_ENABLED
936 static struct super_block *yaffs_ram_read_super(struct super_block * sb, void * data, int silent)
938 return yaffs_internal_read_super(1,sb,data,silent);
941 static DECLARE_FSTYPE(yaffs_ram_fs_type, "yaffsram", yaffs_ram_read_super, FS_SINGLE);
942 #endif // YAFFS_RAM_ENABLED
945 static struct proc_dir_entry *my_proc_entry;
948 static int yaffs_proc_read(
958 static char my_buffer[1000];
960 if (offset > 0) return 0;
962 /* Fill the buffer and get its length */
964 "YAFFS built:"__DATE__ " "__TIME__"\n"
968 strcpy(page,my_buffer);
969 return strlen(my_buffer);
972 static int __init init_yaffs_fs(void)
976 printk(KERN_DEBUG "yaffs " __DATE__ " " __TIME__ " Initialisation\n");
977 /* Install the proc_fs entry */
978 my_proc_entry = create_proc_read_entry("yaffs",
988 #ifdef YAFFS_RAM_ENABLED
990 error = register_filesystem(&yaffs_ram_fs_type);
995 #endif //YAFFS_RAM_ENABLED
997 #ifdef YAFFS_MTD_ENABLED
998 error = register_filesystem(&yaffs_fs_type);
1001 #ifdef YAFFS_RAM_ENABLED
1002 unregister_filesystem(&yaffs_ram_fs_type);
1003 #endif //YAFFS_RAM_ENABLED
1005 #endif // YAFFS_MTD_ENABLED
1010 static void __exit exit_yaffs_fs(void)
1012 printk(KERN_DEBUG "yaffs " __DATE__ " " __TIME__ " Clean up\n");
1014 remove_proc_entry("yaffs",&proc_root);
1016 #ifdef YAFFS_RAM_ENABLED
1017 unregister_filesystem(&yaffs_ram_fs_type);
1019 #ifdef YAFFS_MTD_ENABLED
1020 unregister_filesystem(&yaffs_fs_type);
1025 module_init(init_yaffs_fs)
1026 module_exit(exit_yaffs_fs)
1028 MODULE_DESCRIPTION("YAFFS - a NAND specific flash file system");
1029 MODULE_AUTHOR("Charles Manning, Aleph One Ltd., 2002");
1030 MODULE_LICENSE("GPL");