[Ocfs2-tools-devel] [PATCH 1/3] Ocfs2-tools: Implement new prompt codes of inline-data for fswreck.
Tristan Ye
tristan.ye at oracle.com
Tue Jun 30 21:58:04 PDT 2009
After adding new prompt codes for inline-data in fsck.ocfs2, we also
want fswreck to support such kind of corruptions.
Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
fswreck/corrupt.c | 8 +++++++-
fswreck/include/fsck_type.h | 2 ++
fswreck/include/inode.h | 2 +-
fswreck/inode.c | 36 +++++++++++++++++++++++++++---------
fswreck/main.c | 7 +++++--
5 files changed, 42 insertions(+), 13 deletions(-)
diff --git a/fswreck/corrupt.c b/fswreck/corrupt.c
index 29eca1a..151d308 100644
--- a/fswreck/corrupt.c
+++ b/fswreck/corrupt.c
@@ -238,7 +238,13 @@ void corrupt_file(ocfs2_filesys *fs, enum fsck_type type, uint16_t slotnum)
func = mess_up_inline_flag;
break;
case INLINE_DATA_COUNT_INVALID:
- func = mess_up_inline_count;
+ func = mess_up_inline_inode;
+ break;
+ case INODE_INLINE_SIZE:
+ func = mess_up_inline_inode;
+ break;
+ case INODE_INLINE_CLUSTERS:
+ func = mess_up_inline_inode;
break;
case DUPLICATE_CLUSTERS:
func = mess_up_dup_clusters;
diff --git a/fswreck/include/fsck_type.h b/fswreck/include/fsck_type.h
index 20056b4..968b38a 100644
--- a/fswreck/include/fsck_type.h
+++ b/fswreck/include/fsck_type.h
@@ -117,6 +117,8 @@ enum fsck_type
CLUSTER_GROUP_DESC,
INLINE_DATA_FLAG_INVALID,
INLINE_DATA_COUNT_INVALID,
+ INODE_INLINE_SIZE,
+ INODE_INLINE_CLUSTERS,
DUPLICATE_CLUSTERS,
NUM_FSCK_TYPE
};
diff --git a/fswreck/include/inode.h b/fswreck/include/inode.h
index f55ec4f..8d01ae7 100644
--- a/fswreck/include/inode.h
+++ b/fswreck/include/inode.h
@@ -35,7 +35,7 @@ void mess_up_inode_alloc(ocfs2_filesys *fs, enum fsck_type type,
uint16_t slotnum);
void mess_up_inline_flag(ocfs2_filesys *fs, enum fsck_type type,
uint64_t blkno);
-void mess_up_inline_count(ocfs2_filesys *fs, enum fsck_type type,
+void mess_up_inline_inode(ocfs2_filesys *fs, enum fsck_type type,
uint64_t blkno);
void mess_up_dup_clusters(ocfs2_filesys *fs, enum fsck_type type,
uint64_t blkno);
diff --git a/fswreck/inode.c b/fswreck/inode.c
index 70e849e..a66ff3f 100644
--- a/fswreck/inode.c
+++ b/fswreck/inode.c
@@ -275,7 +275,7 @@ void mess_up_inline_flag(ocfs2_filesys *fs, enum fsck_type type, uint64_t blkno)
return;
}
-void mess_up_inline_count(ocfs2_filesys *fs, enum fsck_type type, uint64_t blkno)
+void mess_up_inline_inode(ocfs2_filesys *fs, enum fsck_type type, uint64_t blkno)
{
int i;
errcode_t ret;
@@ -313,18 +313,36 @@ void mess_up_inline_count(ocfs2_filesys *fs, enum fsck_type type, uint64_t blkno
if (!(di->i_dyn_features & OCFS2_INLINE_DATA_FL))
di->i_dyn_features |= OCFS2_INLINE_DATA_FL;
- di->id2.i_data.id_count = 0;
- di->i_size = max_inline_sz + 1;
- di->i_clusters = 1;
+ switch (type) {
+ case INLINE_DATA_COUNT_INVALID:
+ di->id2.i_data.id_count = 0;
+ fprintf(stdout, "INLINE_DATA_COUNT_INVALID: "
+ "Create an inlined inode#%"PRIu64"(%s),"
+ "whose id_count has been messed up.\n",
+ inline_blkno, file_type);
+ break;
+ case INODE_INLINE_SIZE:
+ di->i_size = max_inline_sz + 1;
+ fprintf(stdout, "INODE_INLINE_SIZE: "
+ "Create an inlined inode#%"PRIu64"(%s),"
+ "whose i_size has been messed up.\n",
+ inline_blkno, file_type);
+ break;
+ case INODE_INLINE_CLUSTERS:
+ di->i_clusters = 1;
+ fprintf(stdout, "INODE_INLINE_CLUSTERS: "
+ "Create an inlined inode#%"PRIu64"(%s),"
+ "whose i_clusters has been messed up.\n",
+ inline_blkno, file_type);
+ break;
+
+ default:
+ FSWRK_FATAL("Invalid type[%d]\n", type);
+ }
ret = ocfs2_write_inode(fs, inline_blkno, buf);
if (ret)
FSWRK_COM_FATAL(progname, ret);
-
- fprintf(stdout, "INLINE_DATA_COUNT_INVALID: "
- "Create an inlined inode#%"PRIu64"(%s),"
- "whose id_count, i_size and i_clusters "
- "been messed up\n", inline_blkno, file_type);
}
if (buf)
diff --git a/fswreck/main.c b/fswreck/main.c
index ea15fb7..ecd254b 100644
--- a/fswreck/main.c
+++ b/fswreck/main.c
@@ -140,8 +140,11 @@ static struct prompt_code prompt_codes[NUM_FSCK_TYPE] = {
define_prompt_code(INLINE_DATA_FLAG_INVALID, corrupt_file,
"Create an inlined inode on a unsupported volume"),
define_prompt_code(INLINE_DATA_COUNT_INVALID, corrupt_file,
- "Corrupt inlined inode's id_count, "
- "i_size and i_clusters"),
+ "Corrupt inlined inode's id_count"),
+ define_prompt_code(INODE_INLINE_SIZE, corrupt_file,
+ "Corrupt inlined inode's i_size"),
+ define_prompt_code(INODE_INLINE_CLUSTERS, corrupt_file,
+ "Corrupt inlined inode's i_clusters"),
define_prompt_code(DUPLICATE_CLUSTERS, corrupt_file,
"Allocate same cluster to different files"),
define_prompt_code(CHAIN_COUNT, corrupt_sys_file,
--
1.5.5
More information about the Ocfs2-tools-devel
mailing list