[Ocfs2-tools-commits] smushran commits r473 - trunk/fswreck

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Dec 9 16:51:39 CST 2004


Author: smushran
Date: 2004-12-09 16:51:37 -0600 (Thu, 09 Dec 2004)
New Revision: 473

Modified:
   trunk/fswreck/chain.c
   trunk/fswreck/corrupt.c
   trunk/fswreck/main.c
Log:
corrupt codes 8-12 implemented

Modified: trunk/fswreck/chain.c
===================================================================
--- trunk/fswreck/chain.c	2004-12-09 19:57:34 UTC (rev 472)
+++ trunk/fswreck/chain.c	2004-12-09 22:51:37 UTC (rev 473)
@@ -39,6 +39,8 @@
 	ocfs2_chain_list *cl;
 	ocfs2_chain_rec *cr;
 	int i;
+	uint32_t tmp1, tmp2;
+	uint64_t tmpblk;
 
 	ret = ocfs2_malloc_block(fs->fs_io, &buf);
 	if (ret)
@@ -58,55 +60,103 @@
 
 	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 last chain from the inode */
+	case 3: /* delink the last chain from the inode */
 		fprintf(stdout, "Corrupt #%02d: Delink group descriptor "
-			"at block#%"PRIu64"\n", code, blkno);
-		if (!cl->cl_next_free_rec) {
-			fprintf(stdout, "No chains to delink\n");
-			goto bail;
-		} else {
-			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 = 1234567890;
-			cl->cl_next_free_rec = i;
-		}
+			"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: Increase chainlist count "
-			"at block#%"PRIu64" from %u to %u\n", code, blkno,
-			cl->cl_count, (cl->cl_count + 123));
-		cl->cl_count += 123;
+	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: Increase chainlist nextfree "
-			"at block#%"PRIu64" from %u to %u\n", code, blkno,
+	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 6:
-		/* corrupt id1.bitmap1.i_total/i_used */
-		fprintf(stdout, "Corrupt #%02d: Increase bitmap total "
-			"at block#%"PRIu64" from %u to %u\n", code, blkno,
+	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: Decrease bitmap used "
-			"at block#%"PRIu64" from %u to %u\n", code, blkno,
+		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);
 	}

Modified: trunk/fswreck/corrupt.c
===================================================================
--- trunk/fswreck/corrupt.c	2004-12-09 19:57:34 UTC (rev 472)
+++ trunk/fswreck/corrupt.c	2004-12-09 22:51:37 UTC (rev 473)
@@ -43,19 +43,24 @@
 	case 4:
 	case 5:
 	case 6:
+	case 7:
+	case 8:
+	case 10:
+	case 11:
+	case 12:
 		snprintf(sysfile, sizeof(sysfile),
 			 sysfile_info[GLOBAL_BITMAP_SYSTEM_INODE].name);
 		break;
 #ifdef _LATER_
-	case 1:
+	case X:
 		snprintf(sysfile, sizeof(sysfile),
 			 sysfile_info[GLOBAL_INODE_ALLOC_SYSTEM_INODE].name);
 		break;
-	case 2: 
+	case Y: 
 		snprintf(sysfile, sizeof(sysfile),
 			 sysfile_info[EXTENT_ALLOC_SYSTEM_INODE].name, nodenum);
 		break;
-	case 3:
+	case Z:
 		snprintf(sysfile, sizeof(sysfile),
 			 sysfile_info[INODE_ALLOC_SYSTEM_INODE].name, nodenum);
 		break;

Modified: trunk/fswreck/main.c
===================================================================
--- trunk/fswreck/main.c	2004-12-09 19:57:34 UTC (rev 472)
+++ trunk/fswreck/main.c	2004-12-09 22:51:37 UTC (rev 473)
@@ -25,7 +25,7 @@
 
 #include <main.h>
 
-#define MAX_CORRUPT		6
+#define MAX_CORRUPT		12
 
 char *progname = NULL;
 char *device = NULL;
@@ -37,13 +37,20 @@
 };
 
 struct corrupt_funcs cf[] = {
-	{ NULL },		/* 0 */
-	{ NULL },		/* 1 */
-	{ NULL },		/* 2 */
-	{ &corrupt_chains },	/* 3 */
-	{ &corrupt_chains },	/* 4 */
-	{ &corrupt_chains },	/* 5 */
-	{ &corrupt_chains }	/* 6 */
+	{ NULL },		/* 00 */
+	{ NULL },		/* 01 */
+	{ NULL },		/* 02 */
+				/* Following relates to the Global bitmap: */
+	{ &corrupt_chains },	/* 03 - Delink the last chain from the inode */
+	{ &corrupt_chains },	/* 04 - Corrupt cl_count */
+	{ &corrupt_chains },	/* 05 - Corrupt cl_next_free_rec */
+	{ NULL },		/* 06 */
+	{ &corrupt_chains },	/* 07 - Corrupt id1.bitmap1.i_total/i_used */
+	{ &corrupt_chains },	/* 08 - Corrupt c_blkno of the first record with a number larger than volume size */
+	{ NULL },		/* 09 */
+	{ &corrupt_chains },	/* 10 - Corrupt c_blkno of the first record with an unaligned number */
+	{ &corrupt_chains },	/* 11 - Corrupt c_blkno of the first record with 0 */
+	{ &corrupt_chains }	/* 12 - Corrupt c_total/c_free of the first record */
 };
 
 /*
@@ -111,7 +118,7 @@
 			if (ind <= MAX_CORRUPT)
 				corrupt[ind] = 1;
 			else {
-				printf("booo\n");
+				fprintf(stderr, "Invalid corrupt code:%d\n", ind);
 				return -1;
 			}
 			break;
@@ -177,7 +184,7 @@
 			if (cf[i].func)
 				cf[i].func(fs, i, nodenum);
 			else
-				printf("Unimplemented corrupt code = %d\n", i);
+				fprintf(stderr, "Unimplemented corrupt code = %d\n", i);
 		}
 	}
 



More information about the Ocfs2-tools-commits mailing list