Add extra config options
authorgkostka <kostka.grzegorz@gmail.com>
Wed, 29 Oct 2014 01:38:12 +0000 (01:38 +0000)
committergkostka <kostka.grzegorz@gmail.com>
Wed, 29 Oct 2014 01:38:12 +0000 (01:38 +0000)
lwext4/ext4_config.h
lwext4/ext4_fs.c

index 1d4872821b37ac1114cf481c5cb0c2dfb9d5512c..c358deef3cfba1a67308e8fc26be81a0c7fe6113 100644 (file)
 #include <config.h>
 #endif
 
+/*****************************************************************************/
 
-/**@brief   Enable directory indexing feature (EXT3 feature)*/
-#ifndef CONFIG_DIR_INDEX_ENABLE
-#define CONFIG_DIR_INDEX_ENABLE     1
+#define F_SET_EXT2    2
+#define F_SET_EXT3    3
+#define F_SET_EXT4    4
+
+#ifndef CONFIG_EXT_FEATURE_SET_LVL
+#define CONFIG_EXT_FEATURE_SET_LVL  F_SET_EXT4
 #endif
 
-/**@brief   Enable extents feature (EXT4 feature)*/
-#ifndef CONFIG_EXTENT_ENABLE
-#define CONFIG_EXTENT_ENABLE        1
+/*****************************************************************************/
+
+#if CONFIG_EXT_FEATURE_SET_LVL == F_SET_EXT2
+    #define CONFIG_DIR_INDEX_ENABLE     0
+    #define CONFIG_EXTENT_ENABLE        0
+
+    /*Superblock feature flag*/
+    #define CONFIG_FEATURE_COMPAT_SUPP    EXT2_FEATURE_COMPAT_SUPP
+    #define CONFIG_FEATURE_INCOMPAT_SUPP  EXT2_FEATURE_INCOMPAT_SUPP
+    #define CONFIG_FEATURE_RO_COMPAT_SUPP EXT2_FEATURE_RO_COMPAT_SUPP
+#elif CONFIG_EXT_FEATURE_SET_LVL == F_SET_EXT3
+    #define CONFIG_DIR_INDEX_ENABLE     1
+    #define CONFIG_EXTENT_ENABLE        0
+
+    /*Superblock feature flag*/
+    #define CONFIG_FEATURE_COMPAT_SUPP    EXT3_FEATURE_COMPAT_SUPP
+    #define CONFIG_FEATURE_INCOMPAT_SUPP  EXT3_FEATURE_INCOMPAT_SUPP
+    #define CONFIG_FEATURE_RO_COMPAT_SUPP EXT3_FEATURE_RO_COMPAT_SUPP
+#elif CONFIG_EXT_FEATURE_SET_LVL == F_SET_EXT4
+    #define CONFIG_DIR_INDEX_ENABLE     1
+    #define CONFIG_EXTENT_ENABLE        1
+
+    /*Superblock feature flag*/
+    #define CONFIG_FEATURE_COMPAT_SUPP    EXT4_FEATURE_COMPAT_SUPP
+    #define CONFIG_FEATURE_INCOMPAT_SUPP  EXT4_FEATURE_INCOMPAT_SUPP
+    #define CONFIG_FEATURE_RO_COMPAT_SUPP EXT4_FEATURE_RO_COMPAT_SUPP
+#else
+#define "Unsupported CONFIG_EXT_FEATURE_SET_LVL"
 #endif
 
 
+/*****************************************************************************/
+
 /**@brief   Enable directory indexing comb sort*/
 #ifndef CONFIG_DIR_INDEX_COMB_SORT
-#define CONFIG_DIR_INDEX_COMB_SORT     1
+#define CONFIG_DIR_INDEX_COMB_SORT  1
 #endif
 
 
index 2fedb8050e4cdcef5a8f3974472ef48c64a2439d..5edfda550619e36ce62ba2e33b3436512a41898f 100644 (file)
@@ -287,7 +287,7 @@ int ext4_fs_check_features(struct ext4_fs *fs, bool *read_only)
 
     /*Check features_incompatible*/
     v = (ext4_get32(&fs->sb, features_incompatible) &
-            (~EXT4_FEATURE_INCOMPAT_SUPP));
+            (~CONFIG_FEATURE_INCOMPAT_SUPP));
     if (v){
         ext4_dprintf(EXT4_DEBUG_FS,
                 "\nERROR sblock features_incompatible. Unsupported:\n");
@@ -298,7 +298,7 @@ int ext4_fs_check_features(struct ext4_fs *fs, bool *read_only)
 
     /*Check features_read_only*/
     v = (ext4_get32(&fs->sb, features_read_only) &
-            (~EXT4_FEATURE_RO_COMPAT_SUPP));
+            (~CONFIG_FEATURE_RO_COMPAT_SUPP));
     if (v){
         ext4_dprintf(EXT4_DEBUG_FS,
                 "\nERROR sblock features_read_only . Unsupported:\n");
@@ -859,8 +859,9 @@ int ext4_fs_free_inode(struct ext4_inode_ref *inode_ref)
 
         ext4_inode_set_indirect_block(inode_ref->inode, 2, 0);
     }
-
+#if CONFIG_EXTENT_ENABLE
     finish:
+#endif
     /* Mark inode dirty for writing to the physical device */
     inode_ref->dirty = true;