Handle inband tags flag better
[yaffs2.git] / yaffs_vfs_multi.c
index 0252211dd3760ad4ce01b17113f53befd7dcc42f..09aed4afa45f62911d0c3337b1c7e4de154db711 100644 (file)
 #define YAFFS_NEW_FOLLOW_LINK 0
 #endif
 
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
+#define YAFFS_HAS_WRITE_SUPER
+#endif
+
+
 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19))
 #include <linux/config.h>
 #endif
@@ -171,6 +176,7 @@ static uint32_t YCALCBLOCKS(uint64_t partition_size, uint32_t block_size)
 #include "yaffs_linux.h"
 
 #include "yaffs_mtdif.h"
+#include "yaffs_packedtags2.h"
 
 unsigned int yaffs_trace_mask = YAFFS_TRACE_BAD_BLOCKS | YAFFS_TRACE_ALWAYS;
 unsigned int yaffs_wr_attempts = YAFFS_WR_ATTEMPTS;
@@ -1302,7 +1308,10 @@ static int yaffs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 }
 
 
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
+static int yaffs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
+                       bool dummy)
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0))
 static int yaffs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
                        struct nameidata *n)
 #elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
@@ -1316,8 +1325,10 @@ static int yaffs_create(struct inode *dir, struct dentry *dentry, int mode)
        return yaffs_mknod(dir, dentry, mode | S_IFREG, 0);
 }
 
-#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
-
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0))
+static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry,
+                                  unsigned int dummy)
+#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2, 5, 0))
 static struct dentry *yaffs_lookup(struct inode *dir, struct dentry *dentry,
                                   struct nameidata *n)
 #else
@@ -2419,6 +2430,7 @@ static int yaffs_do_sync_fs(struct super_block *sb, int request_checkpoint)
 }
 
 
+#ifdef YAFFS_HAS_WRITE_SUPER
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
 static void yaffs_write_super(struct super_block *sb)
 #else
@@ -2437,6 +2449,7 @@ static int yaffs_write_super(struct super_block *sb)
        return 0;
 #endif
 }
+#endif
 
 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
 static int yaffs_sync_fs(struct super_block *sb, int wait)
@@ -2473,7 +2486,9 @@ static const struct super_operations yaffs_super_ops = {
        .clear_inode = yaffs_clear_inode,
 #endif
        .sync_fs = yaffs_sync_fs,
+#ifdef YAFFS_HAS_WRITE_SUPER
        .write_super = yaffs_write_super,
+#endif
 };
 
 struct yaffs_options {
@@ -2590,6 +2605,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
        struct yaffs_param *param;
 
        int read_only = 0;
+       int inband_tags = 0;
 
        struct yaffs_options options;
 
@@ -2668,7 +2684,11 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
                yaffs_version = 1;
        }
 
-       if(yaffs_verify_mtd(mtd, yaffs_version, options.inband_tags) < 0)
+       if (mtd->oobavail < sizeof(struct yaffs_packed_tags2) ||
+           options.inband_tags)
+               inband_tags = 1;
+
+       if(yaffs_verify_mtd(mtd, yaffs_version, inband_tags) < 0)
                return NULL;
 
        /* OK, so if we got here, we have an MTD that's NAND and looks
@@ -2729,7 +2749,7 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
 
        param->n_reserved_blocks = 5;
        param->n_caches = (options.no_cache) ? 0 : 10;
-       param->inband_tags = options.inband_tags;
+       param->inband_tags = inband_tags;
 
        param->enable_xattr = 1;
        if (options.lazy_loading_overridden)
@@ -2744,6 +2764,10 @@ static struct super_block *yaffs_internal_read_super(int yaffs_version,
        param->refresh_period = 500;
        param->disable_summary = options.disable_summary;
 
+
+#ifdef CONFIG_YAFFS_DISABLE_BAD_BLOCK_MARKING
+       param->disable_bad_block_marking  = 1;
+#endif
        if (options.empty_lost_and_found_overridden)
                param->empty_lost_n_found = options.empty_lost_and_found;
 
@@ -2987,6 +3011,8 @@ static char *yaffs_dump_dev_part0(char *buf, struct yaffs_dev *dev)
                                param->empty_lost_n_found);
        buf += sprintf(buf, "disable_lazy_load.... %d\n",
                                param->disable_lazy_load);
+       buf += sprintf(buf, "disable_bad_block_mrk %d\n",
+                               param->disable_bad_block_marking);
        buf += sprintf(buf, "refresh_period....... %d\n",
                                param->refresh_period);
        buf += sprintf(buf, "n_caches............. %d\n", param->n_caches);