[stgt] [PATCH] add --version arg to tgt, tgtadm
Alexander Nezhinsky
alexandern at Voltaire.COM
Tue Jan 25 18:44:09 CET 2011
Added --version, -V arg to tgtd and tgtadm, to print version and exit.
Useful for scripts, e.g. to quickly check that tgtd and tgtadm versions match.
Signed-off-by: Alexander Nezhinsky <alexandern at voltaire.com>
---
usr/tgtadm.c | 12 +++++++++++-
usr/tgtd.c | 14 +++++++++++---
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/usr/tgtadm.c b/usr/tgtadm.c
index 149767e..e81a419 100644
--- a/usr/tgtadm.c
+++ b/usr/tgtadm.c
@@ -90,6 +90,7 @@ static const char * tgtadm_strerror(int err)
struct option const long_options[] = {
{"debug", no_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'},
+ {"version", no_argument, NULL, 'V'},
{"lld", required_argument, NULL, 'L'},
{"op", required_argument, NULL, 'o'},
{"mode", required_argument, NULL, 'm'},
@@ -116,7 +117,7 @@ struct option const long_options[] = {
{NULL, 0, NULL, 0},
};
-static char *short_options = "dhL:o:m:t:s:c:l:n:v:b:E:f:T:I:u:p:H:P:B:Y:O:C:";
+static char *short_options = "dhVL:o:m:t:s:c:l:n:v:b:E:f:T:I:u:p:H:P:B:Y:O:C:";
static void usage(int status)
{
@@ -176,6 +177,12 @@ Report bugs to <stgt at vger.kernel.org>.\n", TGT_VERSION);
exit(status == 0 ? 0 : EINVAL);
}
+static void version(void)
+{
+ printf("%s\n", TGT_VERSION);
+ exit(0);
+}
+
/* default port to use for the mgmt channel */
static short int control_port = 0;
@@ -527,6 +534,9 @@ int main(int argc, char **argv)
case 'C':
control_port = strtol(optarg, NULL, 10);
break;
+ case 'V':
+ version();
+ break;
case 'd':
debug = 1;
break;
diff --git a/usr/tgtd.c b/usr/tgtd.c
index 13ff65c..c3abca8 100644
--- a/usr/tgtd.c
+++ b/usr/tgtd.c
@@ -55,11 +55,12 @@ static struct option const long_options[] =
{"foreground", no_argument, 0, 'f'},
{"control-port", required_argument, 0, 'C'},
{"debug", required_argument, 0, 'd'},
+ {"version", no_argument, 0, 'V'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0},
};
-static char *short_options = "fC:d:h";
+static char *short_options = "fC:d:Vh";
static void usage(int status)
{
@@ -72,12 +73,19 @@ Target framework daemon, version %s\n\
-f, --foreground make the program run in the foreground\n\
-C, --control-port NNNN use port NNNN for the mgmt channel\n\
-d, --debug debuglevel print debugging information\n\
+ -V, --version print version and exit\n\
-h, --help display this help and exit\n\
", TGT_VERSION);
}
exit(status);
}
+static void version(void)
+{
+ printf("%s\n", TGT_VERSION);
+ exit(0);
+}
+
/* Default TGT mgmt port */
short int control_port = 0;
@@ -459,8 +467,8 @@ int main(int argc, char **argv)
case 'd':
is_debug = atoi(optarg);
break;
- case 'v':
- exit(0);
+ case 'V':
+ version();
break;
case 'h':
usage(0);
--
1.6.5.5
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
More information about the stgt
mailing list