[Ocfs2-tools-devel] [PATCH 5/8] Mess up inode ECC
Goldwyn Rodrigues
rgoldwyn at gmail.com
Mon Aug 1 10:58:43 PDT 2011
Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.de>
---
fswreck/corrupt.c | 3 +++
fswreck/include/fsck_type.h | 1 +
fswreck/inode.c | 14 ++++++++++++--
fswreck/main.c | 2 ++
4 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/fswreck/corrupt.c b/fswreck/corrupt.c
index 03e1acd..86c2b47 100644
--- a/fswreck/corrupt.c
+++ b/fswreck/corrupt.c
@@ -124,6 +124,9 @@ void corrupt_file(ocfs2_filesys *fs, enum
fsck_type type, uint16_t slotnum)
case INODE_COUNT:
func = mess_up_inode_field;
break;
+ case INODE_INVALID_ECC:
+ func = mess_up_inode_field;
+ break;
case INODE_NOT_CONNECTED:
func = mess_up_inode_not_connected;
break;
diff --git a/fswreck/include/fsck_type.h b/fswreck/include/fsck_type.h
index e15940b..a5c3989 100644
--- a/fswreck/include/fsck_type.h
+++ b/fswreck/include/fsck_type.h
@@ -163,6 +163,7 @@ enum fsck_type
REFCOUNT_COUNT_INVALID,
DUP_CLUSTERS_ADD_REFCOUNT,
SUPERBLOCK_INVALID_ECC,
+ INODE_INVALID_ECC,
NUM_FSCK_TYPE
};
diff --git a/fswreck/inode.c b/fswreck/inode.c
index 56d9e1b..0fccc65 100644
--- a/fswreck/inode.c
+++ b/fswreck/inode.c
@@ -125,7 +125,7 @@ static void damage_inode(ocfs2_filesys *fs, uint64_t blkno,
case INODE_COUNT:
di->i_links_count = 0;
fprintf(stdout, "INODE_COUNT: "
- "Corrupte inode#%"PRIu64", set link count to 0\n",
+ "Corrupt inode#%"PRIu64", set link count to 0\n",
blkno);
break;
case REFCOUNT_FLAG_INVALID:
@@ -141,13 +141,23 @@ static void damage_inode(ocfs2_filesys *fs,
uint64_t blkno,
"whose i_refcount_loc has been messed up.\n",
blkno);
break;
+ case INODE_INVALID_ECC:
+ di->i_check.bc_ecc ^= 7;
+ di->i_check.bc_crc32e ^= 15;
+ fprintf(stdout, "INODE_INVALID_ECC: "
+ "Created an inode#%"PRIu64","
+ "with i_check messed up.\n",
+ blkno);
+ break;
default:
FSWRK_FATAL("Invalid type[%d]\n", type);
}
- ret = ocfs2_write_inode(fs, blkno, buf);
+ ocfs2_swap_inode_from_cpu(fs, di);
+ ret = io_write_block(fs->fs_io, blkno, 1, (char *)di);
if (ret)
FSWRK_COM_FATAL(progname, ret);
+ fs->fs_flags |= OCFS2_FLAG_CHANGED;
if (buf)
ocfs2_free(&buf);
diff --git a/fswreck/main.c b/fswreck/main.c
index 1fffd37..5584459 100644
--- a/fswreck/main.c
+++ b/fswreck/main.c
@@ -264,6 +264,8 @@ static struct prompt_code prompt_codes[NUM_FSCK_TYPE] = {
"Create a refcounted inode on a unsupported volume"),
define_prompt_code(REFCOUNT_LOC_INVALID, corrupt_file,
"Corrupt a refcounted file's refcount location"),
+ define_prompt_code(INODE_INVALID_ECC, corrupt_file,
+ "Corrupt an inode's ECC"),
define_prompt_code(RB_BLKNO, corrupt_refcount,
"Corrupt a refcount block's rf_blkno"),
define_prompt_code(RB_GEN, corrupt_refcount,
--
1.7.6
More information about the Ocfs2-tools-devel
mailing list