shithub: lwext4

Download patch

ref: 2aa6b585955b0133b6191f7a387e41ead358f136
parent: 79c8c98207d3267e94ca7cbf2c720c1f86951b85
author: ngkaho1234 <[email protected]>
date: Tue Oct 27 05:49:31 EDT 2015

FIX: directory HTree node checksum is not assigned correctly.

--- a/lwext4/ext4_dir_idx.c
+++ b/lwext4/ext4_dir_idx.c
@@ -401,6 +401,7 @@
 	if (ext4_sb_has_feature_read_only(sb,
 					  EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
 		entry_space -= sizeof(struct ext4_directory_dx_tail);
+
 	uint16_t root_limit =
 	    entry_space / sizeof(struct ext4_directory_dx_entry);
 
@@ -498,6 +499,9 @@
 	uint32_t entry_space = block_size;
 	entry_space -= 2 * sizeof(struct ext4_directory_dx_dot_entry);
 	entry_space -= sizeof(struct ext4_directory_dx_root_info);
+	if (ext4_sb_has_feature_read_only(sb,
+					  EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
+		entry_space -= sizeof(struct ext4_directory_dx_tail);
 	entry_space = entry_space / sizeof(struct ext4_directory_dx_entry);
 
 	uint16_t limit = ext4_dir_dx_countlimit_get_limit(
@@ -613,6 +617,10 @@
 		uint16_t entry_space =
 		    ext4_sb_get_block_size(&inode_ref->fs->sb) -
 		    sizeof(struct ext4_fake_directory_entry);
+
+		if (ext4_sb_has_feature_read_only(&inode_ref->fs->sb,
+						  EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
+			entry_space -= sizeof(struct ext4_directory_dx_tail);
 
 		entry_space =
 		    entry_space / sizeof(struct ext4_directory_dx_entry);