*** empty log message ***
authorcharles <charles>
Fri, 23 Aug 2002 00:58:04 +0000 (00:58 +0000)
committercharles <charles>
Fri, 23 Aug 2002 00:58:04 +0000 (00:58 +0000)
Makefile
yaffs_fs.c

index ceea8f7c1b58a4f439bf9296120ba38b48a79afb..7642d476e3563dae1169b829bdeb0f117007cfc3 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -16,8 +16,8 @@
 ## comment out USE_xxxx if you don't want these features.
 
 KERNELDIR = /usr/src/kernel-headers-2.4.18
-USE_RAM_FOR_TEST = -DYAFFS_RAM_ENABLED
-USE_MTD = -DYAFFS_MTD_ENABLED
+USE_RAM_FOR_TEST = -DCONFIG_YAFFS_RAM_ENABLED
+USE_MTD = -DCONFIG_YAFFS_MTD_ENABLED
 YAFFS_CONFIGS = -DCONFIG_YAFFS_USE_GENERIC_RW
 
 CFLAGS = -D__KERNEL__ -DMODULE $(USE_RAM_FOR_TEST) $(USE_MTD) $(YAFFS_CONFIGS)  -I$(KERNELDIR)/include -O2 -Wall
index b0608f9198953893df6a591077b2753962a5b1d3..dc700987448cbbe974b66743cb7981d7c9771d99 100644 (file)
 
 #include "yaffs_guts.h"
 
-#ifdef YAFFS_RAM_ENABLED
+#ifdef CONFIG_YAFFS_RAM_ENABLED
 #include "yaffs_nandemul.h" 
 // 2 MB of RAM for emulation
 #define YAFFS_RAM_EMULATION_SIZE  0x200000
-#endif //YAFFS_RAM_ENABLED
+#endif //CONFIG_YAFFS_RAM_ENABLED
 
-#ifdef YAFFS_MTD_ENABLED
+#ifdef CONFIG_YAFFS_MTD_ENABLED
 #include <linux/mtd/mtd.h>
 #include "yaffs_mtdif.h"
-#endif //YAFFS_MTD_ENABLED
+#endif //CONFIG_YAFFS_MTD_ENABLED
 
 #define T(x) printk x
 
@@ -70,6 +70,7 @@ 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);
+static int yaffs_file_flush(struct file* file);
 
 static int yaffs_sync_object(struct file * file, struct dentry *dentry, int datasync);
 
@@ -102,7 +103,7 @@ static int yaffs_follow_link(struct dentry *dentry, struct nameidata *nd);
 
 
 static struct address_space_operations yaffs_file_address_operations = {
-       readpage:       yaffs_readpage,
+       readpage:               yaffs_readpage,
        prepare_write:  yaffs_prepare_write,
        commit_write:   yaffs_commit_write
 };
@@ -117,6 +118,7 @@ static struct file_operations yaffs_file_operations = {
        write:          yaffs_file_write,
 #endif
        mmap:           generic_file_mmap,
+       flush:          yaffs_file_flush,
        fsync:          yaffs_sync_object,
 };
 
@@ -243,11 +245,24 @@ 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));
+       // yaffs_FlushFile(yaffs_InodeToObject(inode));
        
 }
 
 
+static int yaffs_file_flush(struct file* file)
+{
+       yaffs_Object *obj = yaffs_DentryToObject(file->f_dentry);
+       
+       T((KERN_DEBUG"yaffs_file_flush object %d (%s)\n",obj->objectId,
+                               obj->dirty ? "dirty" : "clean"));
+
+    yaffs_FlushFile(obj);
+
+    return 0;
+}
+
+
 
 static int yaffs_readpage_nolock(struct file *f, struct page * pg)
 {
@@ -338,6 +353,10 @@ static int yaffs_commit_write(struct file *f, struct page *pg, unsigned offset,
                SetPageError(pg);
                ClearPageUptodate(pg);
        }
+       else
+       {
+               SetPageUptodate(pg);
+       }
 
        T((KERN_DEBUG"yaffs_commit_write returning %d\n",nWritten));
        
@@ -660,7 +679,7 @@ static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode)
 static int yaffs_unlink(struct inode * dir, struct dentry *dentry)
 {
        
-       T((KERN_DEBUG"yaffs_unlink\n"));
+       T((KERN_DEBUG"yaffs_unlink %d:%s\n",dir->i_ino,dentry->d_name.name));
        
        if(yaffs_Unlink(yaffs_InodeToObject(dir),dentry->d_name.name) == YAFFS_OK)
        {
@@ -815,7 +834,7 @@ static void yaffs_put_super(struct super_block *sb)
 }
 
 
-#ifdef YAFFS_MTD_ENABLED
+#ifdef CONFIG_YAFFS_MTD_ENABLED
 
 static void  yaffs_MTDPutSuper(struct super_block *sb)
 {
@@ -865,7 +884,7 @@ static struct super_block *yaffs_internal_read_super(int useRam, struct super_bl
        if(useRam)
        {
 
-#ifdef YAFFS_RAM_ENABLED
+#ifdef CONFIG_YAFFS_RAM_ENABLED
                // Set the yaffs_Device up for ram emulation
 
                sb->u.generic_sbp =     dev = kmalloc(sizeof(yaffs_Device),GFP_KERNEL);
@@ -893,7 +912,7 @@ static struct super_block *yaffs_internal_read_super(int useRam, struct super_bl
        }
        else
        {       
-#ifdef YAFFS_MTD_ENABLED
+#ifdef CONFIG_YAFFS_MTD_ENABLED
                struct mtd_info *mtd;
                
                printk(KERN_DEBUG "yaffs: Attempting MTD mount on %u.%u, \"%s\"\n",
@@ -999,7 +1018,7 @@ static struct super_block *yaffs_internal_read_super(int useRam, struct super_bl
        return sb;
 }
 
-#ifdef YAFFS_MTD_ENABLED
+#ifdef CONFIG_YAFFS_MTD_ENABLED
 static struct super_block *yaffs_read_super(struct super_block * sb, void * data, int silent)
 {
        return yaffs_internal_read_super(0,sb,data,silent);
@@ -1008,7 +1027,7 @@ static struct super_block *yaffs_read_super(struct super_block * sb, void * data
 static DECLARE_FSTYPE(yaffs_fs_type, "yaffs", yaffs_read_super, FS_REQUIRES_DEV);
 #endif
 
-#ifdef YAFFS_RAM_ENABLED
+#ifdef CONFIG_YAFFS_RAM_ENABLED
 
 static struct super_block *yaffs_ram_read_super(struct super_block * sb, void * data, int silent)
 {
@@ -1016,7 +1035,7 @@ static struct super_block *yaffs_ram_read_super(struct super_block * sb, void *
 }
 
 static DECLARE_FSTYPE(yaffs_ram_fs_type, "yaffsram", yaffs_ram_read_super, FS_SINGLE);
-#endif // YAFFS_RAM_ENABLED
+#endif // CONFIG_YAFFS_RAM_ENABLED
 
 
 static struct proc_dir_entry *my_proc_entry;
@@ -1069,24 +1088,24 @@ static int __init init_yaffs_fs(void)
        return -ENOMEM;
     }
 
-#ifdef YAFFS_RAM_ENABLED
+#ifdef CONFIG_YAFFS_RAM_ENABLED
 
     error = register_filesystem(&yaffs_ram_fs_type);
     if(error)
     {
        return error;
     }
-#endif //YAFFS_RAM_ENABLED
+#endif //CONFIG_YAFFS_RAM_ENABLED
 
-#ifdef YAFFS_MTD_ENABLED
+#ifdef CONFIG_YAFFS_MTD_ENABLED
        error = register_filesystem(&yaffs_fs_type);
        if(error)
        {
-#ifdef YAFFS_RAM_ENABLED
+#ifdef CONFIG_YAFFS_RAM_ENABLED
                unregister_filesystem(&yaffs_ram_fs_type);
-#endif //YAFFS_RAM_ENABLED
+#endif //CONFIG_YAFFS_RAM_ENABLED
        }
-#endif // YAFFS_MTD_ENABLED
+#endif // CONFIG_YAFFS_MTD_ENABLED
 
        return error;
 }
@@ -1097,10 +1116,10 @@ static void __exit exit_yaffs_fs(void)
 
     remove_proc_entry("yaffs",&proc_root);
     
-#ifdef YAFFS_RAM_ENABLED
+#ifdef CONFIG_YAFFS_RAM_ENABLED
        unregister_filesystem(&yaffs_ram_fs_type);
 #endif
-#ifdef YAFFS_MTD_ENABLED
+#ifdef CONFIG_YAFFS_MTD_ENABLED
        unregister_filesystem(&yaffs_fs_type);
 #endif