[ofa-general] [PATCH] opensm: add --version command line option

Sasha Khapyorsky sashak at voltaire.com
Wed Jun 25 06:57:02 PDT 2008


With this new '--version' option OpenSM will print its version and exit.

Signed-off-by: Sasha Khapyorsky <sashak at voltaire.com>
---
 opensm/man/opensm.8.in |    4 ++++
 opensm/opensm/main.c   |    6 ++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/opensm/man/opensm.8.in b/opensm/man/opensm.8.in
index d844590..964fbd3 100644
--- a/opensm/man/opensm.8.in
+++ b/opensm/man/opensm.8.in
@@ -5,6 +5,7 @@ opensm \- InfiniBand subnet manager and administration (SM/SA)
 
 .SH SYNOPSIS
 .B opensm
+[\-\-version]]
 [\-c(ache-options)] [\-g(uid)[=]<GUID in hex>] [\-l(mc) <LMC>]
 [\-p(riority) <PRIORITY>] [\-smkey <SM_Key>] [\-r(eassign_lids)]
 [\-R <engine name> | \-\-routing_engine <engine name>]
@@ -63,6 +64,9 @@ setup the subnet correctly.
 
 .PP
 .TP
+\fB\-\-version\fR
+Prints OpenSM version and exits.
+.TP
 \fB\-c\fR, \fB\-\-cache-options\fR
 Write out a list of all tunable OpenSM parameters,
 including their current values from the command line
diff --git a/opensm/opensm/main.c b/opensm/opensm/main.c
index 505ef57..248171a 100644
--- a/opensm/opensm/main.c
+++ b/opensm/opensm/main.c
@@ -126,6 +126,8 @@ static void show_usage(void)
 	printf("\n------- OpenSM - Usage and options ----------------------\n");
 	printf("Usage:   opensm [options]\n");
 	printf("Options:\n");
+	printf("--version\n"
+	       "          Prints OpenSM version and exits.\n\n");
 	printf("-F <file-name>, --config <file-name>\n"
 	       "          The name of the OpenSM config file. It has a same format\n"
 	       "          as opensm.opts option cache file. When not specified\n"
@@ -620,6 +622,7 @@ int main(int argc, char *argv[])
 	   2: optional
 	 */
 	const struct option long_option[] = {
+		{"version", 0, NULL, 12},
 		{"config", 1, NULL, 'F'},
 		{"debug", 1, NULL, 'd'},
 		{"guid", 1, NULL, 'g'},
@@ -696,6 +699,9 @@ int main(int argc, char *argv[])
 		next_option = getopt_long_only(argc, argv, short_option,
 					       long_option, NULL);
 		switch (next_option) {
+		case 12: /* --version - already printed above */
+			exit(0);
+			break;
 		case 'F':
 			if (config_file_done)
 				break;
-- 
1.5.5.1.178.g1f811




More information about the general mailing list