[Ocfs2-tools-devel] [PATCH 2/3] fsck.ocfs2: Print version

Sunil Mushran sunil.mushran at oracle.com
Fri Jul 24 17:04:26 PDT 2009


Patch to fix version print.

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
Signed-off-by: Joel Becker <joel.becker at oracle.com>
---
 fsck.ocfs2/Makefile |    2 ++
 fsck.ocfs2/fsck.c   |   26 +++++++-------------------
 2 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/fsck.ocfs2/Makefile b/fsck.ocfs2/Makefile
index 7f6e547..1ae64e8 100644
--- a/fsck.ocfs2/Makefile
+++ b/fsck.ocfs2/Makefile
@@ -5,6 +5,8 @@ include $(TOPDIR)/Preamble.make
 sbindir = $(root_sbindir)
 SBIN_PROGRAMS = fsck.ocfs2
 
+DEFINES += -DVERSION=\"$(VERSION)\"
+
 INCLUDES = -I$(TOPDIR)/include -Iinclude
 LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
 LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a
diff --git a/fsck.ocfs2/fsck.c b/fsck.ocfs2/fsck.c
index 37a6c49..ae1031f 100644
--- a/fsck.ocfs2/fsck.c
+++ b/fsck.ocfs2/fsck.c
@@ -53,6 +53,7 @@
 #include <string.h>
 #include <inttypes.h>
 #include <signal.h>
+#include <libgen.h>
 
 #include "ocfs2/ocfs2.h"
 
@@ -402,25 +403,9 @@ static void mark_magical_clusters(o2fsck_state *ost)
 		o2fsck_mark_clusters_allocated(ost, 0, cluster);
 }
 
-static void version(void)
+static void print_version(void)
 {
-	char url[] = "$URL$";
-       	char rev[] = "$Rev$";
-	char noise[] = "fsck.ocfs2/fsck.c";
-	char *found;
-
-	/* url =~ s/noise// :P */
-	found = strstr(url, noise);
-	if (found) {
-		char *rest = found + strlen(noise);
-		memcpy(found, rest, sizeof(url) - (found - url));
-	}
-
-	printf("fsck.ocfs2 version information from Subversion:\n"
-	       " %s\n"
-	       " %s\n", url, rev);
-
-	exit(FSCK_USAGE);
+	fprintf(stderr, "%s %s\n", whoami, VERSION);
 }
 
 static errcode_t open_and_check(o2fsck_state *ost, char *filename,
@@ -727,7 +712,8 @@ int main(int argc, char **argv)
 				break;
 
 			case 'V':
-				version();
+				print_version();
+				exit(FSCK_USAGE);
 				break;
 
 			case 'r':
@@ -758,6 +744,8 @@ int main(int argc, char **argv)
 
 	filename = argv[optind];
 
+	print_version();
+
 	if (ost->ost_skip_o2cb) {
 		fprintf(stdout, "\nWARNING: YOU HAVE DISABLED THE CLUSTER CHECK. "
 			"CONTINUE ONLY IF YOU\nARE ABSOLUTELY SURE THAT NO "
-- 
1.6.0.4




More information about the Ocfs2-tools-devel mailing list