[Ocfs2-tools-commits] zab commits r251 - in trunk/fsck.ocfs2: . include

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Thu Sep 23 19:39:29 CDT 2004


Author: zab
Date: 2004-09-23 19:39:27 -0500 (Thu, 23 Sep 2004)
New Revision: 251

Modified:
   trunk/fsck.ocfs2/fsck.c
   trunk/fsck.ocfs2/include/fsck.h
   trunk/fsck.ocfs2/pass1.c
Log:
o Add the little fsck hook that will skip fscks based on super block
  fields when we use them
o more strictly check feature_compat
o Check for and clear non-directory root dir inodes


Modified: trunk/fsck.ocfs2/fsck.c
===================================================================
--- trunk/fsck.ocfs2/fsck.c	2004-09-23 22:16:24 UTC (rev 250)
+++ trunk/fsck.ocfs2/fsck.c	2004-09-24 00:39:27 UTC (rev 251)
@@ -106,10 +106,19 @@
 	return 0;
 }
 
+void exit_if_skipping(o2fsck_state *ost)
+{
+	if (ost->ost_force)
+		return;
+
+	/* XXX do something with s_state, _mnt_count, checkinterval,
+	 * etc. */
+	return;
+}
+
 int main(int argc, char **argv)
 {
 	char *filename;
-	ocfs2_filesys *fs;
 	int64_t blkno, blksize;
 	o2fsck_state _ost, *ost = &_ost;
 	int c, ret, rw = OCFS2_FLAG_RW;
@@ -147,6 +156,10 @@
 				}
 				break;
 
+			case 'f':
+				ost->ost_force = 1;
+				break;
+
 			case 'n':
 				ost->ost_ask = 0;
 				ost->ost_answer = 0;
@@ -183,25 +196,41 @@
 	/* XXX we'll decide on a policy for using o_direct in the future.
 	 * for now we want to test against loopback files in ext3, say. */
 	ret = ocfs2_open(filename, rw | OCFS2_FLAG_BUFFERED, blkno,
-			 blksize, &fs);
+			 blksize, &ost->ost_fs);
 	if (ret) {
 		com_err(argv[0], ret,
 			"while opening file \"%s\"", filename);
 		goto out;
 	}
 
-	if (o2fsck_state_init(fs, argv[0], ost)) {
+	if (o2fsck_state_init(ost->ost_fs, argv[0], ost)) {
 		fprintf(stderr, "error allocating run-time state, exiting..\n");
 		return 1;
 	}
 
+	/* XXX do we want checking for different revisions of ocfs2? */
+
+	/* XXX worry about the journal */
+
 	/* XXX should be verifying super-block bits here. */
 
-	ret = o2fsck_pass1(fs, ost);
+	/* ocfs2_open() already checked _incompat and _ro_compat */
+	if (OCFS2_RAW_SB(ost->ost_fs->fs_super)->s_feature_compat &
+	    ~OCFS2_LIB_FEATURE_COMPAT_SUPP) {
+		com_err(argv[0], EXT2_ET_UNSUPP_FEATURE,
+		        "while checking _compat flags");
+		exit(FSCK_ERROR);
+	}
+
+	exit_if_skipping(ost);
+
+	/* XXX we don't use the bad blocks inode, do we? */
+
+	ret = o2fsck_pass1(ost);
 	if (ret)
 		com_err(argv[0], ret, "pass1 failed");
 
-	ret = ocfs2_close(fs);
+	ret = ocfs2_close(ost->ost_fs);
 	if (ret) {
 		com_err(argv[0], ret,
 			"while closing file \"%s\"", filename);

Modified: trunk/fsck.ocfs2/include/fsck.h
===================================================================
--- trunk/fsck.ocfs2/include/fsck.h	2004-09-23 22:16:24 UTC (rev 250)
+++ trunk/fsck.ocfs2/include/fsck.h	2004-09-24 00:39:27 UTC (rev 251)
@@ -25,6 +25,8 @@
 #define __O2FSCK_FSCK_H__
 
 typedef struct _o2fsck_state {
+	oc2fs_filesys 	*ost_fs;
+
 	ocfs2_bitmap	*ost_used_inodes;
 	ocfs2_bitmap	*ost_bad_inodes;
 	ocfs2_bitmap	*ost_dir_inodes;
@@ -33,10 +35,10 @@
 	ocfs2_bitmap	*ost_found_blocks;
 	ocfs2_bitmap	*ost_dup_blocks;
 
-	/* whether or not we should be asking questions of the user, and 
-	 * if not, what the answer should be instead. */
-	unsigned	ost_ask:1,
-			ost_answer:1;
+	/* flags */
+	unsigned	ost_ask:1,	/* confirm with the user */
+			ost_answer:1,	/* answer if we don't ask the user */
+			ost_force:1;	/* -f supplied; force check */
 } o2fsck_state;
 
 #endif /* __O2FSCK_FSCK_H__ */

Modified: trunk/fsck.ocfs2/pass1.c
===================================================================
--- trunk/fsck.ocfs2/pass1.c	2004-09-23 22:16:24 UTC (rev 250)
+++ trunk/fsck.ocfs2/pass1.c	2004-09-24 00:39:27 UTC (rev 251)
@@ -77,6 +77,16 @@
 		goto bad;
 	}
 
+	/* offer to clear a non-directory root inode so that 
+	 * pass3:check_root() can re-create it */
+	if ((di->i_blkno == fs->fs_root_blkno) &&
+	    should_fix(ost, FIX_DEFYES, "Root inode isn't a directory.")) {
+		di->i_dtime = 0ULL;
+		di->i_links_count = 0ULL;
+		/* icount_store(links_count) */
+		o2fsck_write_inode(fs, blkno, di);
+	}
+
 	if (di->i_dtime) {
 		if (should_fix(ost, FIX_DEFYES, 
 		    "Inode %llu is in use but has a non-zero dtime.", 
@@ -178,6 +188,7 @@
 	char *buf;
 	ocfs2_dinode *di;
 	ocfs2_inode_scan *scan;
+	ocfs2_filesys *fs = ost->ost_fs;
 
 	ret = ocfs2_malloc_block(fs->fs_io, &buf);
 	if (ret) {



More information about the Ocfs2-tools-commits mailing list