shithub: lwext4

Download patch

ref: 0be3cc00469822f2cb3ef03cf4901a2083a22edc
parent: e957027243c30367446a1a8963b7e86019f034fb
author: gkostka <kostka.grzegorz@gmail.com>
date: Tue Oct 21 14:44:21 EDT 2014

Feature checker functions refactoring

--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -211,7 +211,7 @@
 
 #if CONFIG_DIR_INDEX_ENABLE
         /* Initialize directory index if supported */
-        if (ext4_sb_check_feature_compatible(&mp->fs.sb,
+        if (ext4_sb_has_feature_compatible(&mp->fs.sb,
                 EXT4_FEATURE_COMPAT_DIR_INDEX)) {
             rc = ext4_dir_dx_init(child);
             if (rc != EOK)
--- a/lwext4/ext4_dir.c
+++ b/lwext4/ext4_dir.c
@@ -296,7 +296,7 @@
 
 #if CONFIG_DIR_INDEX_ENABLE
     /* Index adding (if allowed) */
-    if ((ext4_sb_check_feature_compatible(&fs->sb,
+    if ((ext4_sb_has_feature_compatible(&fs->sb,
             EXT4_FEATURE_COMPAT_DIR_INDEX)) &&
             (ext4_inode_has_flag(parent->inode, EXT4_INODE_FLAG_INDEX))) {
         int rc = ext4_dir_dx_add_entry(parent, child, name);
@@ -387,7 +387,7 @@
 
 #if CONFIG_DIR_INDEX_ENABLE
     /* Index search */
-    if ((ext4_sb_check_feature_compatible(sb,
+    if ((ext4_sb_has_feature_compatible(sb,
             EXT4_FEATURE_COMPAT_DIR_INDEX)) &&
             (ext4_inode_has_flag(parent->inode, EXT4_INODE_FLAG_INDEX))) {
         int rc = ext4_dir_dx_find_entry(result, parent, name_len,
--- a/lwext4/ext4_fs.c
+++ b/lwext4/ext4_fs.c
@@ -511,7 +511,7 @@
     uint16_t crc = 0;
 
     /* Compute the checksum only if the filesystem supports it */
-    if (ext4_sb_check_read_only(sb,
+    if (ext4_sb_has_feature_read_only(sb,
             EXT4_FEATURE_RO_COMPAT_GDT_CSUM)) {
         uint8_t  *base = (uint8_t  *)bg;
         uint8_t  *checksum = (uint8_t  *)&bg->checksum;
@@ -534,7 +534,7 @@
         offset += sizeof(bg->checksum);
 
         /* Checksum of the rest of block group descriptor */
-        if ((ext4_sb_check_feature_incompatible(sb,
+        if ((ext4_sb_has_feature_incompatible(sb,
                 EXT4_FEATURE_INCOMPAT_64BIT)) &&
                 (offset < ext4_sb_get_desc_size(sb)))
 
@@ -701,7 +701,7 @@
 
 #if CONFIG_EXTENT_ENABLE
     /* Initialize extents if needed */
-    if (ext4_sb_check_feature_incompatible(
+    if (ext4_sb_has_feature_incompatible(
             &fs->sb, EXT4_FEATURE_INCOMPAT_EXTENTS)) {
         ext4_inode_set_flag(inode, EXT4_INODE_FLAG_EXTENTS);
 
@@ -732,7 +732,7 @@
     uint32_t suboffset;
 #if CONFIG_EXTENT_ENABLE
     /* For extents must be data block destroyed by other way */
-    if ((ext4_sb_check_feature_incompatible(&fs->sb,
+    if ((ext4_sb_has_feature_incompatible(&fs->sb,
             EXT4_FEATURE_INCOMPAT_EXTENTS)) &&
             (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))){
         /* Data structures are released during truncate operation... */
@@ -894,7 +894,7 @@
     if (old_size % block_size != 0)
         old_blocks_count++;
 #if CONFIG_EXTENT_ENABLE
-    if ((ext4_sb_check_feature_incompatible(sb,
+    if ((ext4_sb_has_feature_incompatible(sb,
             EXT4_FEATURE_INCOMPAT_EXTENTS)) &&
             (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))) {
 
@@ -939,7 +939,7 @@
     uint32_t current_block;
 #if CONFIG_EXTENT_ENABLE
     /* Handle i-node using extents */
-    if ((ext4_sb_check_feature_incompatible(&fs->sb,
+    if ((ext4_sb_has_feature_incompatible(&fs->sb,
             EXT4_FEATURE_INCOMPAT_EXTENTS)) &&
             (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))) {
 
@@ -1040,7 +1040,7 @@
 
 #if CONFIG_EXTENT_ENABLE
     /* Handle inode using extents */
-    if ((ext4_sb_check_feature_incompatible(&fs->sb,
+    if ((ext4_sb_has_feature_incompatible(&fs->sb,
             EXT4_FEATURE_INCOMPAT_EXTENTS)) &&
             (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))) {
         /* Not reachable */
@@ -1198,7 +1198,7 @@
     struct ext4_fs *fs = inode_ref->fs;
 
     /* Extents are handled otherwise = there is not support in this function */
-    ext4_assert(!(ext4_sb_check_feature_incompatible(&fs->sb,
+    ext4_assert(!(ext4_sb_has_feature_incompatible(&fs->sb,
             EXT4_FEATURE_INCOMPAT_EXTENTS) &&
             (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))));
 
@@ -1296,7 +1296,7 @@
 {
 #if CONFIG_EXTENT_ENABLE
     /* Handle extents separately */
-    if ((ext4_sb_check_feature_incompatible(&inode_ref->fs->sb,
+    if ((ext4_sb_has_feature_incompatible(&inode_ref->fs->sb,
             EXT4_FEATURE_INCOMPAT_EXTENTS)) &&
             (ext4_inode_has_flag(inode_ref->inode, EXT4_INODE_FLAG_EXTENTS))){
         return ext4_extent_append_block(inode_ref, iblock, fblock, true);
--- a/lwext4/ext4_inode.c
+++ b/lwext4/ext4_inode.c
@@ -174,7 +174,7 @@
 {
     uint64_t count = to_le32(inode->blocks_count_lo);
 
-    if (ext4_sb_check_read_only(sb,
+    if (ext4_sb_has_feature_read_only(sb,
             EXT4_FEATURE_RO_COMPAT_HUGE_FILE)) {
 
         /* 48-bit field */
@@ -207,7 +207,7 @@
     }
 
     /* Check if there can be used huge files (many blocks) */
-    if (!ext4_sb_check_read_only(sb,
+    if (!ext4_sb_has_feature_read_only(sb,
             EXT4_FEATURE_RO_COMPAT_HUGE_FILE))
         return EINVAL;
 
--- a/lwext4/ext4_super.c
+++ b/lwext4/ext4_super.c
@@ -154,7 +154,7 @@
 
 bool ext4_sb_is_super_in_bg(struct ext4_sblock *s, uint32_t group)
 {
-    if (ext4_sb_check_read_only(s,
+    if (ext4_sb_has_feature_read_only(s,
             EXT4_FEATURE_RO_COMPAT_SPARSE_SUPER) &&
             !ext4_sb_sparse(group))
         return false;
--- a/lwext4/ext4_super.h
+++ b/lwext4/ext4_super.h
@@ -110,7 +110,7 @@
  * @param   s superblock descriptor
  * @param   v feature to check
  * @return  true if feature is supported*/
-static inline bool ext4_sb_check_feature_compatible(struct ext4_sblock *s,
+static inline bool ext4_sb_has_feature_compatible(struct ext4_sblock *s,
     uint32_t v)
 {
     return to_le32(s->features_compatible) & v;
@@ -121,7 +121,7 @@
  * @param   s superblock descriptor
  * @param   v feature to check
  * @return  true if feature is supported*/
-static inline bool ext4_sb_check_feature_incompatible(struct ext4_sblock *s,
+static inline bool ext4_sb_has_feature_incompatible(struct ext4_sblock *s,
     uint32_t v)
 {
     return to_le32(s->features_incompatible) & v;
@@ -132,7 +132,8 @@
  * @param   s superblock descriptor
  * @param   v flag to check
  * @return  true if flag is supported*/
-static inline bool ext4_sb_check_read_only(struct ext4_sblock *s, uint32_t v)
+static inline bool ext4_sb_has_feature_read_only(struct ext4_sblock *s,
+        uint32_t v)
 {
     return to_le32(s->features_read_only) & v;
 }