removing test file
[yaffs/.git] / yaffs_fs.c
index de113037ddb33ee1bd3ac6beae32a3ce0ee38e3c..c3f57d7723bc2757030bdd3ef993fc47e9fd37b7 100644 (file)
@@ -43,7 +43,7 @@
 #include "yaffs_nandemul.h" 
 // 2 MB of RAM for emulation
 #define YAFFS_RAM_EMULATION_SIZE  0x200000
-#endif // YAFFS_RAM_ENABLED
+#endif //YAFFS_RAM_ENABLED
 
 #ifdef YAFFS_MTD_ENABLED
 #include <linux/mtd/mtd.h>
@@ -60,6 +60,8 @@
 
 
 
+static void yaffs_put_super(struct super_block *sb);
+
 static ssize_t yaffs_file_read(struct file *f, char *buf, size_t n, loff_t *pos);
 static ssize_t yaffs_file_write(struct file *f, const char *buf, size_t n, loff_t *pos);
 
@@ -128,6 +130,7 @@ static struct super_operations yaffs_super_ops = {
        statfs:                 yaffs_statfs,
        read_inode:             yaffs_read_inode,
        put_inode:              yaffs_put_inode,
+       put_super:              yaffs_put_super,
 //     read_inode:
 //     remount_fs:
 //     clear_inode:
@@ -177,6 +180,9 @@ static struct dentry * yaffs_lookup(struct inode *dir, struct dentry *dentry)
 static void yaffs_put_inode(struct inode *inode)
 {
        T(("yaffs_put_inode: ino %d, count %d\n",(int)inode->i_ino, atomic_read(&inode->i_count)));
+       
+       yaffs_FlushFile(yaffs_InodeToObject(inode));
+       
 }
 
 #ifdef YAFFS_ADDRESS_OPS
@@ -609,7 +615,7 @@ static int yaffs_statfs(struct super_block *sb, struct statfs *buf)
        buf->f_blocks = yaffs_SuperToDevice(sb)->nBlocks * YAFFS_CHUNKS_PER_BLOCK;
        buf->f_files = 0;
        buf->f_ffree = 0;
-       buf->f_bavail = yaffs_GetNumberOfFreeChunks(yaffs_SuperToDevice(sb));
+       buf->f_bavail = buf->f_bfree = yaffs_GetNumberOfFreeChunks(yaffs_SuperToDevice(sb));
        return 0;
 }
 
@@ -626,6 +632,34 @@ static void yaffs_read_inode (struct inode *inode)
 }
 
 
+static void yaffs_put_super(struct super_block *sb)
+{
+       yaffs_Device *dev = yaffs_SuperToDevice(sb);
+       
+       if(dev->putSuperFunc)
+       {
+                dev->putSuperFunc(sb);
+       }
+}
+
+
+#ifdef YAFFS_MTD_ENABLED
+
+static void  yaffs_MTDPutSuper(struct super_block *sb)
+{
+       
+       struct mtd_info *mtd = yaffs_SuperToDevice(sb)->genericDevice;
+       
+       if(mtd->sync)
+       {
+               mtd->sync(mtd);
+       }
+       
+       put_mtd_device(mtd);
+}
+
+#endif
+
 static struct super_block *yaffs_internal_read_super(int useRam, struct super_block * sb, void * data, int silent)
 {
        struct inode * inode;
@@ -653,7 +687,7 @@ static struct super_block *yaffs_internal_read_super(int useRam, struct super_bl
        if(useRam)
        {
 
-#if YAFFS_RAM_ENABLED
+#ifdef YAFFS_RAM_ENABLED
                // Set the yaffs_Device up for ram emulation
 
                sb->u.generic_sbp =     dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
@@ -675,6 +709,7 @@ static struct super_block *yaffs_internal_read_super(int useRam, struct super_bl
                dev->readChunkFromNAND = nandemul_ReadChunkFromNAND;
                dev->eraseBlockInNAND = nandemul_EraseBlockInNAND;
                dev->initialiseNAND = nandemul_InitialiseNAND;
+               
 #endif
 
        }
@@ -744,7 +779,8 @@ static struct super_block *yaffs_internal_read_super(int useRam, struct super_bl
 
                // Set up the memory size parameters....
                
-               dev->nBlocks = YAFFS_RAM_EMULATION_SIZE / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
+// NCB         dev->nBlocks = YAFFS_RAM_EMULATION_SIZE / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
+               dev->nBlocks = mtd->size / (YAFFS_CHUNKS_PER_BLOCK * YAFFS_BYTES_PER_CHUNK);
                dev->startBlock = 1;  // Don't use block 0
                dev->endBlock = dev->nBlocks - 1;
 
@@ -754,6 +790,7 @@ static struct super_block *yaffs_internal_read_super(int useRam, struct super_bl
                dev->eraseBlockInNAND = nandmtd_EraseBlockInNAND;
                dev->initialiseNAND = nandmtd_InitialiseNAND;
                
+               dev->putSuperFunc = yaffs_MTDPutSuper;
 #endif
        }
 
@@ -876,10 +913,10 @@ static void __exit exit_yaffs_fs(void)
     remove_proc_entry("yaffs",&proc_root);
     
 #ifdef YAFFS_RAM_ENABLED
-       unregister_filesystem(&yaffs_fs_type);
+       unregister_filesystem(&yaffs_ram_fs_type);
 #endif
 #ifdef YAFFS_MTD_ENABLED
-       unregister_filesystem(&yaffs_ram_fs_type);
+       unregister_filesystem(&yaffs_fs_type);
 #endif
 
 }