#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
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);
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
};
write: yaffs_file_write,
#endif
mmap: generic_file_mmap,
+ flush: yaffs_file_flush,
fsync: yaffs_sync_object,
};
{
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)
{
SetPageError(pg);
ClearPageUptodate(pg);
}
+ else
+ {
+ SetPageUptodate(pg);
+ }
T((KERN_DEBUG"yaffs_commit_write returning %d\n",nWritten));
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)
{
}
-#ifdef YAFFS_MTD_ENABLED
+#ifdef CONFIG_YAFFS_MTD_ENABLED
static void yaffs_MTDPutSuper(struct super_block *sb)
{
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);
}
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",
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);
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)
{
}
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;
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;
}
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