shithub: lwext4

Download patch

ref: a7423d5e9195369d137c6adfe20e45826e161215
parent: 5da1e5389cf9e3e02237979df962f7c9aaeb25c6
author: gkostka <kostka.grzegorz@gmail.com>
date: Fri Oct 24 15:42:39 EDT 2014

Updated directory links increment/decrement

--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -211,6 +211,7 @@
 
         /*New empty directory. Two links (. and ..) */
         ext4_inode_set_links_count(child->inode, 2);
+
 #if CONFIG_DIR_INDEX_ENABLE
         /* Initialize directory index if supported */
         if (ext4_sb_has_feature_compatible(&mp->fs.sb,
@@ -226,10 +227,9 @@
 #endif
 
         ext4_fs_inode_links_count_inc(parent);
-
-        parent->dirty = true;
         child->dirty = true;
-        return EOK;
+        parent->dirty = true;
+
     }
 
     return EOK;
@@ -284,6 +284,7 @@
 
     return EOK;
 }
+
 
 /****************************************************************************/
 
--- a/lwext4/ext4_fs.c
+++ b/lwext4/ext4_fs.c
@@ -691,6 +691,7 @@
         mode = 0777;
         mode |= EXT4_INODE_MODE_DIRECTORY;
         ext4_inode_set_mode(&fs->sb, inode, mode);
+        ext4_inode_set_links_count(inode, 0);
 
     } else {
         /*
@@ -701,9 +702,10 @@
         mode = 0666;
         mode |= EXT4_INODE_MODE_FILE;
         ext4_inode_set_mode(&fs->sb, inode, mode);
+        ext4_inode_set_links_count(inode, 1);
     }
 
-    ext4_inode_set_links_count(inode, 0);
+
     ext4_inode_set_uid(inode, 0);
     ext4_inode_set_gid(inode, 0);
     ext4_inode_set_size(inode, 0);