[Ocfs2-tools-devel] [PATCH 5/5] Fswreck: Implement corruption code CLUSTER_ALLOC_BIT.
Tristan Ye
tristan.ye at oracle.com
Thu Mar 11 02:02:23 PST 2010
Simply corrupt the global bitmap by allocating a new cluster,
without actually using it later.
Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
fswreck/corrupt.c | 3 +++
fswreck/group.c | 21 +++++++++++++++++++++
fswreck/include/group.h | 2 ++
fswreck/main.c | 4 ++--
4 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/fswreck/corrupt.c b/fswreck/corrupt.c
index 8ea8513..a724268 100644
--- a/fswreck/corrupt.c
+++ b/fswreck/corrupt.c
@@ -334,6 +334,9 @@ void corrupt_group_desc(ocfs2_filesys *fs, enum fsck_type type,
case CLUSTER_GROUP_DESC:
func = mess_up_cluster_group_desc;
break;
+ case CLUSTER_ALLOC_BIT:
+ func = mess_up_cluster_alloc_bits;
+ break;
default:
FSWRK_FATAL("Invalid code=%d", type);
}
diff --git a/fswreck/group.c b/fswreck/group.c
index aa0298c..45a460b 100644
--- a/fswreck/group.c
+++ b/fswreck/group.c
@@ -296,3 +296,24 @@ void mess_up_cluster_group_desc(ocfs2_filesys *fs, enum fsck_type type,
if (buf)
ocfs2_free(&buf);
}
+
+/*
+ * Simply corrupt the global bitmap by allocating a new cluster, without
+ * actually using it later.
+ */
+void mess_up_cluster_alloc_bits(ocfs2_filesys *fs, enum fsck_type type,
+ uint16_t slotnum)
+{
+ errcode_t ret;
+ uint32_t n_clusters;
+ uint64_t blkno;
+
+ ret = ocfs2_new_clusters(fs, 1, 1, &blkno, &n_clusters);
+ if (ret) {
+ FSWRK_COM_FATAL(progname, ret);
+ ocfs2_free_clusters(fs, 1, blkno);
+ }
+
+ fprintf(stdout ,"Mark bits of global bitmap by unused "
+ "block#%"PRIu64".\n", blkno);
+}
diff --git a/fswreck/include/group.h b/fswreck/include/group.h
index 0af524a..b7e23ca 100644
--- a/fswreck/include/group.h
+++ b/fswreck/include/group.h
@@ -33,5 +33,7 @@ void mess_up_group_list(ocfs2_filesys *fs, enum fsck_type type,
uint16_t slotnum);
void mess_up_cluster_group_desc(ocfs2_filesys *fs, enum fsck_type type,
uint16_t slotnum);
+void mess_up_cluster_alloc_bits(ocfs2_filesys *fs, enum fsck_type type,
+ uint16_t slotnum);
#endif /* __GROUP_H */
diff --git a/fswreck/main.c b/fswreck/main.c
index e75e4de..76c3039 100644
--- a/fswreck/main.c
+++ b/fswreck/main.c
@@ -169,8 +169,8 @@ static struct prompt_code prompt_codes[NUM_FSCK_TYPE] = {
"Corrupt chain list's header blkno"),
define_prompt_code(CHAIN_BITS, corrupt_sys_file,
"Corrupt chain's total bits"),
- define_prompt_code(CLUSTER_ALLOC_BIT, NULL,
- "Unimplemented corrupt code"),
+ define_prompt_code(CLUSTER_ALLOC_BIT, corrupt_group_desc,
+ "Mark bits of global bitmap by unused clusters"),
define_prompt_code(CHAIN_I_CLUSTERS, corrupt_sys_file,
"Corrupt chain allocator's i_clusters"),
define_prompt_code(CHAIN_I_SIZE, corrupt_sys_file,
--
1.5.5
More information about the Ocfs2-tools-devel
mailing list