shithub: lwext4

Download patch

ref: 25ae70a7469ac86bcd1dafcd30a5c1934955bd32
parent: 1a812a02d49e19f5299bff04705a37d23c366be2
author: ngkaho1234 <[email protected]>
date: Thu Oct 29 13:56:21 EDT 2015

FIX: fake inode checksum failing message.

--- a/lwext4/ext4_fs.c
+++ b/lwext4/ext4_fs.c
@@ -731,8 +731,10 @@
 #define ext4_fs_verify_inode_csum(...) true
 #endif
 
-int ext4_fs_get_inode_ref(struct ext4_fs *fs, uint32_t index,
-			  struct ext4_inode_ref *ref)
+static int
+__ext4_fs_get_inode_ref(struct ext4_fs *fs, uint32_t index,
+			struct ext4_inode_ref *ref,
+			bool initialized)
 {
 	/* Compute number of i-nodes, that fits in one data block */
 	uint32_t inodes_per_group = ext4_get32(&fs->sb, inodes_per_group);
@@ -786,7 +788,7 @@
 	ref->fs = fs;
 	ref->dirty = false;
 
-	if (!ext4_fs_verify_inode_csum(ref)) {
+	if (initialized && !ext4_fs_verify_inode_csum(ref)) {
 		ext4_dbg(DEBUG_FS,
 			DBG_WARN "Inode checksum failed."
 			"Inode: %" PRIu32"\n",
@@ -796,6 +798,12 @@
 	return EOK;
 }
 
+int ext4_fs_get_inode_ref(struct ext4_fs *fs, uint32_t index,
+			  struct ext4_inode_ref *ref)
+{
+	return __ext4_fs_get_inode_ref(fs, index, ref, true);
+}
+
 int ext4_fs_put_inode_ref(struct ext4_inode_ref *ref)
 {
 	/* Check if reference modified */
@@ -861,7 +869,7 @@
 		return rc;
 
 	/* Load i-node from on-disk i-node table */
-	rc = ext4_fs_get_inode_ref(fs, index, inode_ref);
+	rc = __ext4_fs_get_inode_ref(fs, index, inode_ref, false);
 	if (rc != EOK) {
 		ext4_ialloc_free_inode(fs, index, is_dir);
 		return rc;