[Ocfs2-tools-devel] [PATCH 1/5] Fswreck: Remove unused codes in old fashion.

Tristan Ye tristan.ye at oracle.com
Thu Mar 11 02:02:19 PST 2010


function corrupt_chains() and mess_up_chains() served fswreck in an old
fashion, which was using numeric codes for corruption, while now it was
no long used after new fsck codes being introduced, we therefore need to
remove such redundant codes.

Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
 fswreck/chain.c           |  147 ---------------------------------------------
 fswreck/corrupt.c         |   52 ----------------
 fswreck/include/chain.h   |    1 -
 fswreck/include/corrupt.h |    1 -
 4 files changed, 0 insertions(+), 201 deletions(-)

diff --git a/fswreck/chain.c b/fswreck/chain.c
index 4a3c793..d49646b 100644
--- a/fswreck/chain.c
+++ b/fswreck/chain.c
@@ -26,153 +26,6 @@
 
 extern char *progname;
 
-/*
- * mess_up_chains()
- *
- */
-void mess_up_chains(ocfs2_filesys *fs, uint64_t blkno, int code)
-{
-	errcode_t ret;
-	char *buf = NULL;
-	struct ocfs2_dinode *di;
-	struct ocfs2_chain_list *cl;
-	struct ocfs2_chain_rec *cr;
-	int i;
-	uint32_t tmp1, tmp2;
-	uint64_t tmpblk;
-
-	ret = ocfs2_malloc_block(fs->fs_io, &buf);
-	if (ret)
-		FSWRK_COM_FATAL(progname, ret);
-
-	ret = ocfs2_read_inode(fs, blkno, buf);
-	if (ret)
-		FSWRK_COM_FATAL(progname, ret);
-
-	di = (struct ocfs2_dinode *)buf;
-
-	if (!(di->i_flags & OCFS2_BITMAP_FL))
-		FSWRK_FATAL("not a bitmap");
-
-	if (!(di->i_flags & OCFS2_CHAIN_FL))
-		FSWRK_FATAL("not a chain group");
-
-	cl = &(di->id2.i_chain);
-
-	if (!cl->cl_next_free_rec) {
-		fprintf(stdout, "No chains found at block#%"PRIu64"\n", blkno);
-		goto bail;
-	}
-
-	switch (code) {
-	case 3: /* delink the last chain from the inode */
-		fprintf(stdout, "Corrupt #%02d: Delink group descriptor "
-			"in block#%"PRIu64"\n", code, blkno);
-
-		i = cl->cl_next_free_rec - 1;
-		cr = &(cl->cl_recs[i]);
-		fprintf(stdout, "Delinking ind=%d, block#=%"PRIu64", "
-			"free=%u, total=%u\n", i, cr->c_blkno,
-			cr->c_free, cr->c_total);
-		cr->c_free = 12345;
-		cr->c_total = 67890;
-		cr->c_blkno = ocfs2_clusters_to_blocks(fs, fs->fs_super->i_clusters);
-		cr->c_blkno += 1; /* 1 more block than the fs size */
-		cl->cl_next_free_rec = i;
-		break;
-
-	case 4: /* corrupt cl_count */
-		fprintf(stdout, "Corrupt #%02d: Modified cl_count "
-			"in block#%"PRIu64" from %u to %u\n", code, blkno,
-			cl->cl_count, (cl->cl_count + 100));
-		cl->cl_count += 100;
-		break;
-
-	case 5: /* corrupt cl_next_free_rec */
-		fprintf(stdout, "Corrupt #%02d: Modified cl_next_free_rec "
-			"in block#%"PRIu64" from %u to %u\n", code, blkno,
-			cl->cl_next_free_rec, (cl->cl_next_free_rec + 10));
-		cl->cl_next_free_rec += 10;
-		break;
-
-	case 7: /* corrupt id1.bitmap1.i_total/i_used */
-		fprintf(stdout, "Corrupt #%02d: Modified bitmap total "
-			"in block#%"PRIu64" from %u to %u\n", code, blkno,
-			di->id1.bitmap1.i_total, di->id1.bitmap1.i_total + 10);
-		fprintf(stdout, "Corrupt #%02d: Modified bitmap used "
-			"in block#%"PRIu64" from %u to %u\n", code, blkno,
-			di->id1.bitmap1.i_used, 0);
-		di->id1.bitmap1.i_total += 10;
-		di->id1.bitmap1.i_used = 0;
-		break;
-
-	case 8: /* Corrupt c_blkno of the first record with a number larger than volume size */
-		cr = &(cl->cl_recs[0]);
-		tmpblk = ocfs2_clusters_to_blocks(fs, fs->fs_super->i_clusters);
-		tmpblk++; /* 1 more block than the fs size */
-
-		fprintf(stdout, "Corrupt #%02d: Modified c_blkno in "
-			"block#%"PRIu64" from %"PRIu64" to %"PRIu64"\n",
-			code, blkno, cr->c_blkno, tmpblk);
-
-		cr->c_blkno = tmpblk;
-		break;
-
-	case 10: /* Corrupt c_blkno of the first record with an unaligned number */
-		cr = &(cl->cl_recs[0]);
-		tmpblk = 1234567;
-
-		fprintf(stdout, "Corrupt #%02d: Modified c_blkno in "
-			"block#%"PRIu64" from %"PRIu64" to %"PRIu64"\n",
-			code, blkno, cr->c_blkno, tmpblk);
-
-		cr->c_blkno = tmpblk;
-		break;
-
-	case 11: /* Corrupt c_blkno of the first record with 0 */
-		cr = &(cl->cl_recs[0]);
-		tmpblk = 0;
-
-		fprintf(stdout, "Corrupt #%02d: Modified c_blkno in "
-			"block#%"PRIu64" from %"PRIu64" to %"PRIu64"\n",
-			code, blkno, cr->c_blkno, tmpblk);
-
-		cr->c_blkno = tmpblk;
-		break;
-
-	case 12: /* corrupt c_total and c_free of the first record */
-		cr = &(cl->cl_recs[0]);
-		tmp1 = (cr->c_total >= 100) ? (cr->c_total - 100) : 0;
-		tmp2 = (cr->c_free >= 100) ? (cr->c_free - 100) : 0;
-
-		fprintf(stdout, "Corrupt #%02d: Modified c_total "
-			"in block#%"PRIu64" for chain ind=%d from %u to %u\n",
-			code, blkno, 0, cr->c_total, tmp1);
-		fprintf(stdout, "Corrupt #%02d: Modified c_free "
-			"in block#%"PRIu64" for chain ind=%d from %u to %u\n",
-			code, blkno, 0, cr->c_free, tmp2);
-
-		cr->c_total = tmp1;
-		cr->c_free = tmp2;
-		break;
-
-	default:
-		FSWRK_FATAL("Invalid code=%d", code);
-	}
-
-	ret = ocfs2_write_inode(fs, blkno, buf);
-	if (ret)
-		FSWRK_COM_FATAL(progname, ret);
-
-	fprintf(stdout, "Corrupt #%02d: Finito\n", code);
-
-bail:
-	if (buf)
-		ocfs2_free(&buf);
-
-	return ;
-}
-
 static void mess_up_sys_file(ocfs2_filesys *fs, uint64_t blkno,
 				enum fsck_type type)
 {
diff --git a/fswreck/corrupt.c b/fswreck/corrupt.c
index 8f943c0..a088898 100644
--- a/fswreck/corrupt.c
+++ b/fswreck/corrupt.c
@@ -28,58 +28,6 @@
 
 extern char *progname;
 
-/*
- * corrupt_chains()
- *
- */
-void corrupt_chains(ocfs2_filesys *fs, int code, uint16_t slotnum)
-{
-	errcode_t ret;
-	uint64_t blkno;
-	struct ocfs2_super_block *sb = OCFS2_RAW_SB(fs->fs_super);
-	char sysfile[40];
-
-	switch (code) {
-	case 3:
-	case 4:
-	case 5:
-	case 6:
-	case 7:
-	case 8:
-	case 10:
-	case 11:
-	case 12:
-		snprintf(sysfile, sizeof(sysfile),
-			 ocfs2_system_inodes[GLOBAL_BITMAP_SYSTEM_INODE].si_name);
-		break;
-#ifdef _LATER_
-	case X:
-		snprintf(sysfile, sizeof(sysfile),
-			 ocfs2_system_inodes[GLOBAL_INODE_ALLOC_SYSTEM_INODE].si_name);
-		break;
-	case Y: 
-		snprintf(sysfile, sizeof(sysfile),
-			 ocfs2_system_inodes[EXTENT_ALLOC_SYSTEM_INODE].si_name, slotnum);
-		break;
-	case Z:
-		snprintf(sysfile, sizeof(sysfile),
-			 ocfs2_system_inodes[INODE_ALLOC_SYSTEM_INODE].si_name, slotnum);
-		break;
-#endif
-	default:
-		FSWRK_FATAL("Invalid code=%d", code);
-	}
-
-	ret = ocfs2_lookup(fs, sb->s_system_dir_blkno, sysfile,
-			   strlen(sysfile), NULL, &blkno);
-	if (ret)
-		FSWRK_FATAL();
-
-	mess_up_chains(fs, blkno, code);
-
-	return ;
-}
-
 static void create_named_directory(ocfs2_filesys *fs, char *dirname,
 				   uint64_t *blkno)
 {
diff --git a/fswreck/include/chain.h b/fswreck/include/chain.h
index c74c018..8fbbcfa 100644
--- a/fswreck/include/chain.h
+++ b/fswreck/include/chain.h
@@ -25,7 +25,6 @@
 #ifndef __CHAIN_H__
 #define __CHAIN_H__
 
-void mess_up_chains(ocfs2_filesys *fs, uint64_t blkno, int code);
 void mess_up_chains_list(ocfs2_filesys *fs, enum fsck_type type,
 			 uint16_t slotnum);
 void mess_up_chains_rec(ocfs2_filesys *fs, enum fsck_type type,
diff --git a/fswreck/include/corrupt.h b/fswreck/include/corrupt.h
index 3aebb28..ae7917c 100644
--- a/fswreck/include/corrupt.h
+++ b/fswreck/include/corrupt.h
@@ -25,7 +25,6 @@
 #ifndef __CORRUPT_H
 #define __CORRUPT_H
 
-void corrupt_chains(ocfs2_filesys *fs, int code, uint16_t slotnum);
 void corrupt_file(ocfs2_filesys *fs, enum fsck_type type, uint16_t slotnum);
 void corrupt_sys_file(ocfs2_filesys *fs, enum fsck_type type, uint16_t slotnum);
 void corrupt_group_desc(ocfs2_filesys *fs, enum fsck_type type,
-- 
1.5.5




More information about the Ocfs2-tools-devel mailing list