[Ocfs2-tools-devel] [PATCH 4/5] Fswreck: Implement code DIR_DOTDOT.

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


Corrupt dir's dotdot entry's ino by increasing the number
by 10.

Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
 fswreck/corrupt.c     |    3 +++
 fswreck/dir.c         |   17 +++++++++++++++++
 fswreck/include/dir.h |    2 ++
 fswreck/main.c        |    4 ++--
 4 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/fswreck/corrupt.c b/fswreck/corrupt.c
index 911387a..8ea8513 100644
--- a/fswreck/corrupt.c
+++ b/fswreck/corrupt.c
@@ -163,6 +163,9 @@ void corrupt_file(ocfs2_filesys *fs, enum fsck_type type, uint16_t slotnum)
 	case DIRENT_DOT_EXCESS:
 		func = mess_up_dir_dot;
 		break;
+	case DIR_DOTDOT:
+		func = mess_up_dir_dotdot;
+		break;
 	case DIRENT_ZERO:
 		func = mess_up_dir_ent;
 		break;
diff --git a/fswreck/dir.c b/fswreck/dir.c
index 37874ea..66309fd 100644
--- a/fswreck/dir.c
+++ b/fswreck/dir.c
@@ -289,6 +289,13 @@ static void damage_dir_content(ocfs2_filesys *fs, uint64_t dir,
 			"to %"PRIu64"\n",
 			dir, tmp_no - OCFS2_DIR_PAD, tmp_no);
 		break;
+	case DIR_DOTDOT:
+		corrupt_dirent_ino(fs, dir, "..", &tmp_no, 10);
+		fprintf(stdout, "DIR_DOTDOT: "
+			"Corrupt directory#%"PRIu64
+			", change dotdot inode from %"PRIu64" to %"PRIu64".\n",
+			dir, tmp_no - 10, tmp_no);
+		break;
 	case DIRENT_ZERO:
 		memset(name, 0, 1);
 		ret = ocfs2_link(fs, dir, name, dir + 100, OCFS2_FT_DIR);
@@ -393,6 +400,16 @@ void mess_up_dir_dot(ocfs2_filesys *fs, enum fsck_type type, uint64_t blkno)
 	return;
 }
 
+void mess_up_dir_dotdot(ocfs2_filesys *fs, enum fsck_type type, uint64_t blkno)
+{
+	uint64_t tmp_blkno;
+
+	create_directory(fs, blkno, &tmp_blkno);
+	damage_dir_content(fs, tmp_blkno, type);
+
+	return;
+}
+
 void mess_up_dir_ent(ocfs2_filesys *fs, enum fsck_type type, uint64_t blkno)
 {
 	uint64_t tmp_blkno;
diff --git a/fswreck/include/dir.h b/fswreck/include/dir.h
index e6f009d..a7ddec0 100644
--- a/fswreck/include/dir.h
+++ b/fswreck/include/dir.h
@@ -27,6 +27,8 @@
 
 void mess_up_dir_inode(ocfs2_filesys *fs, enum fsck_type type, uint64_t blkno);
 void mess_up_dir_dot(ocfs2_filesys *fs, enum fsck_type type, uint64_t blkno);
+void mess_up_dir_dotdot(ocfs2_filesys *fs, enum fsck_type type,
+			uint64_t blkno);
 void mess_up_dir_ent(ocfs2_filesys *fs, enum fsck_type type, uint64_t blkno);
 void mess_up_dir_parent_dup(ocfs2_filesys *fs, enum fsck_type type,
 			    uint64_t blkno);
diff --git a/fswreck/main.c b/fswreck/main.c
index abba71e..e75e4de 100644
--- a/fswreck/main.c
+++ b/fswreck/main.c
@@ -113,8 +113,8 @@ static struct prompt_code prompt_codes[NUM_FSCK_TYPE] = {
 			   "Corrupt root inode, change its i_mode to 0"),
 	define_prompt_code(LOSTFOUND_MISSING, corrupt_file,
 			   "Corrupt root inode, change its i_mode to 0"),
-	define_prompt_code(DIR_DOTDOT, NULL,
-			   "Unimplemented corrupt code"),
+	define_prompt_code(DIR_DOTDOT, corrupt_file,
+			   "Corrupt dir's dotdot entry's ino it points to"),
 	define_prompt_code(DIR_ZERO, corrupt_file,
 			   "Corrupt directory, empty its content"),
 	define_prompt_code(DIRENT_DOTTY_DUP, corrupt_file,
-- 
1.5.5




More information about the Ocfs2-tools-devel mailing list