[Ocfs2-tools-commits] zab commits r558 - in trunk: fsck.ocfs2 libocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Jan 17 17:13:59 CST 2005


Author: zab
Date: 2005-01-17 17:13:57 -0600 (Mon, 17 Jan 2005)
New Revision: 558

Modified:
   trunk/fsck.ocfs2/fsck.c
   trunk/libocfs2/ocfs2_err.et.in
   trunk/libocfs2/unix_io.c
Log:
o mark pointed out that fsck was giving nonsensical error messages when it 
  couldn't open the given device.  this at least cleans up the case where
  the device name simply wasn't found.  we might want to add more 
  errno->com_err translations.


Modified: trunk/fsck.ocfs2/fsck.c
===================================================================
--- trunk/fsck.ocfs2/fsck.c	2005-01-17 22:48:53 UTC (rev 557)
+++ trunk/fsck.ocfs2/fsck.c	2005-01-17 23:13:57 UTC (rev 558)
@@ -67,6 +67,8 @@
 
 int verbose = 0;
 
+static char *whoami = "fsck.ocfs2";
+
 static void print_usage(void)
 {
 	fprintf(stderr,
@@ -102,8 +104,7 @@
 extern int opterr, optind;
 extern char *optarg;
 
-static errcode_t o2fsck_state_init(ocfs2_filesys *fs, const char *whoami, 
-				    o2fsck_state *ost)
+static errcode_t o2fsck_state_init(ocfs2_filesys *fs, o2fsck_state *ost)
 {
 	errcode_t ret;
 
@@ -156,7 +157,6 @@
 	ocfs2_dinode *di = ost->ost_fs->fs_super;
 	ocfs2_super_block *sb = OCFS2_RAW_SB(di);
 	errcode_t ret = 0;
-	const char *whoami = __FUNCTION__;
 
 	if (sb->s_max_nodes == 0) {
 		printf("The superblock max_nodes field is set to 0.\n");
@@ -341,17 +341,19 @@
 				uint64_t blksize)
 {
 	errcode_t ret;
-	const char *whoami = __FUNCTION__;
 
 	ret = ocfs2_open(filename, open_flags, blkno, blksize, &ost->ost_fs);
 	if (ret) {
-		com_err(whoami, ret, "while opening file \"%s\"", filename);
+		com_err(whoami, ret, "while opening \"%s\"", filename);
 		goto out;
 	}
 
 	ret = check_superblock(ost);
-	if (ret)
+	if (ret) {
+		printf("fsck saw unrecoverable errors in the super block and "
+		       "will not continue.\n");
 		goto out;
+	}
 
 out:
 	return ret;
@@ -363,7 +365,6 @@
 {	
 	int replayed = 0, should = 0;
 	errcode_t ret = 0;
-	const char *whoami = __FUNCTION__;
 
 	ret = o2fsck_should_replay_journals(ost->ost_fs, &should);
 	if (ret)
@@ -401,12 +402,6 @@
 	}
 
 	ret = open_and_check(ost, filename, open_flags, blkno, blksize);
-	if (ret) {
-		printf("fsck saw unrecoverable errors while "
-		       "re-opening the super block and will not "
-		       "continue.\n");
-		goto out;
-	}
 out:
 	return ret;
 }
@@ -524,8 +519,6 @@
 
 	ret = open_and_check(ost, filename, open_flags, blkno, blksize);
 	if (ret) {
-		printf("fsck saw unrecoverable errors in the super block and "
-		       "will not continue.\n");
 		fsck_mask |= FSCK_ERROR;
 		goto out;
 	}
@@ -552,7 +545,7 @@
 
 	/* allocate all this junk after we've replayed the journal and the
 	 * sb should be stable */
-	if (o2fsck_state_init(ost->ost_fs, argv[0], ost)) {
+	if (o2fsck_state_init(ost->ost_fs, ost)) {
 		fprintf(stderr, "error allocating run-time state, exiting..\n");
 		fsck_mask |= FSCK_ERROR;
 		goto out;
@@ -577,31 +570,31 @@
 	 * are fatal.  these can be fixed over time. */
 	ret = o2fsck_pass0(ost);
 	if (ret) {
-		com_err(argv[0], ret, "while performing pass 0");
+		com_err(whoami, ret, "while performing pass 0");
 		goto done;
 	}
 
 	ret = o2fsck_pass1(ost);
 	if (ret) {
-		com_err(argv[0], ret, "while performing pass 1");
+		com_err(whoami, ret, "while performing pass 1");
 		goto done;
 	}
 
 	ret = o2fsck_pass2(ost);
 	if (ret) {
-		com_err(argv[0], ret, "while performing pass 2");
+		com_err(whoami, ret, "while performing pass 2");
 		goto done;
 	}
 
 	ret = o2fsck_pass3(ost);
 	if (ret) {
-		com_err(argv[0], ret, "while performing pass 3");
+		com_err(whoami, ret, "while performing pass 3");
 		goto done;
 	}
 
 	ret = o2fsck_pass4(ost);
 	if (ret) {
-		com_err(argv[0], ret, "while performing pass 4");
+		com_err(whoami, ret, "while performing pass 4");
 		goto done;
 	}
 
@@ -616,13 +609,13 @@
 	if (ost->ost_fs->fs_flags & OCFS2_FLAG_RW) {
 		ret = write_out_superblock(ost);
 		if (ret)
-			com_err(argv[0], ret, "while writing back the "
+			com_err(whoami, ret, "while writing back the "
 				"superblock");
 	}
 
 	ret = ocfs2_close(ost->ost_fs);
 	if (ret) {
-		com_err(argv[0], ret, "while closing file \"%s\"", filename);
+		com_err(whoami, ret, "while closing file \"%s\"", filename);
 		/* XXX I wonder about this error.. */
 		fsck_mask |= FSCK_ERROR;
 	} 

Modified: trunk/libocfs2/ocfs2_err.et.in
===================================================================
--- trunk/libocfs2/ocfs2_err.et.in	2005-01-17 22:48:53 UTC (rev 557)
+++ trunk/libocfs2/ocfs2_err.et.in	2005-01-17 23:13:57 UTC (rev 558)
@@ -24,6 +24,9 @@
 ec	OCFS2_ET_BASE,
 	"OCFS2 Library version @VERSION@"
 
+ec	OCFS2_ET_NAMED_DEVICE_NOT_FOUND,
+	"Device name specified was not found"
+
 ec	OCFS2_ET_BAD_DEVICE_NAME,
 	"Illegal or malformed device name"
 

Modified: trunk/libocfs2/unix_io.c
===================================================================
--- trunk/libocfs2/unix_io.c	2005-01-17 22:48:53 UTC (rev 557)
+++ trunk/libocfs2/unix_io.c	2005-01-17 23:13:57 UTC (rev 558)
@@ -103,10 +103,13 @@
 		chan->io_flags |= O_DIRECT;
 	chan->io_error = 0;
 
-	ret = OCFS2_ET_IO;
 	chan->io_fd = open64(name, chan->io_flags);
 	if (chan->io_fd < 0) {
-		chan->io_error = errno;
+		/* chan will be freed, don't bother with chan->io_error */
+		if (errno == ENOENT)
+			ret = OCFS2_ET_NAMED_DEVICE_NOT_FOUND;
+		else
+			ret = OCFS2_ET_IO;
 		goto out_name;
 	}
 



More information about the Ocfs2-tools-commits mailing list