[Ocfs2-tools-commits] zab commits r367 - trunk/fsck.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Nov 5 14:50:17 CST 2004


Author: zab
Date: 2004-11-05 14:50:15 -0600 (Fri, 05 Nov 2004)
New Revision: 367

Modified:
   trunk/fsck.ocfs2/fsck.c
Log:
o direct com_err output to stdout


Modified: trunk/fsck.ocfs2/fsck.c
===================================================================
--- trunk/fsck.ocfs2/fsck.c	2004-11-05 20:38:25 UTC (rev 366)
+++ trunk/fsck.ocfs2/fsck.c	2004-11-05 20:50:15 UTC (rev 367)
@@ -224,7 +224,24 @@
 	printf("\n");
 }
 
+/* we like stdout so people can redirect trivially.  com_err uses stderr.  it
+ * is irritating to have reordering in the buffering between stdout and stderr.
+ * stdio forgot fdreopen(). */
+static void com_err_stdout(const char *who, long code, const char *fmt, 
+			   va_list ap)
+{
 
+	const struct error_table *et = &et_ocfs_error_table;
+	long offset = code - et->base;
+
+	if (code < et->base || offset >= et->n_msgs)
+		return;
+
+	fprintf(stdout, "%s: %s ", who, et->msgs[offset]);
+	vfprintf(stdout, fmt, ap);
+	fprintf(stdout, "\n");
+}
+
 int main(int argc, char **argv)
 {
 	char *filename;
@@ -242,6 +259,7 @@
 	blkno = 0;
 
 	initialize_ocfs_error_table();
+	set_com_err_hook(com_err_stdout);
 
 	while((c = getopt(argc, argv, "b:B:npvy")) != EOF) {
 		switch (c) {



More information about the Ocfs2-tools-commits mailing list