summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hutchings <bhutchings@solarflare.com>2011-02-21 19:06:31 +0000
committerBen Hutchings <bhutchings@solarflare.com>2011-02-21 19:11:55 +0000
commite325c7791533df551575343d30938dd86a9df121 (patch)
tree45644e607a6b3082a52b5c09a633c27e73456128
parent764234c3324e0f4e21e767e211248ae29abbd20b (diff)
downloadethtool-e325c7791533df551575343d30938dd86a9df121.tar.gz
ethtool: Add --version option
Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
-rw-r--r--ethtool.8.in5
-rw-r--r--ethtool.c6
2 files changed, 11 insertions, 0 deletions
diff --git a/ethtool.8.in b/ethtool.8.in
index 133825b..8b04335 100644
--- a/ethtool.8.in
+++ b/ethtool.8.in
@@ -100,6 +100,8 @@ ethtool \- query or control network driver and hardware settings
.B ethtool \-h|\-\-help
+.B ethtool \-\-version
+
.B ethtool \-a|\-\-show\-pause
.I ethX
@@ -310,6 +312,9 @@ settings of the specified device.
.B \-h \-\-help
Shows a short help message.
.TP
+.B \-\-version
+Shows the ethtool version number.
+.TP
.B \-a \-\-show\-pause
Queries the specified Ethernet device for pause parameter information.
.TP
diff --git a/ethtool.c b/ethtool.c
index 32a97f6..e9cb2c9 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -115,6 +115,7 @@ static int do_permaddr(int fd, struct ifreq *ifr);
static int send_ioctl(int fd, struct ifreq *ifr);
static enum {
+ MODE_VERSION = -2,
MODE_HELP = -1,
MODE_GSET=0,
MODE_SSET,
@@ -264,6 +265,7 @@ static struct option {
{ "-P", "--show-permaddr", MODE_PERMADDR,
"Show permanent hardware address" },
{ "-h", "--help", MODE_HELP, "Show this help" },
+ { NULL, "--version", MODE_VERSION, "Show version number" },
{}
};
@@ -816,6 +818,10 @@ static void parse_cmdline(int argc, char **argp)
if (mode == MODE_HELP) {
show_usage();
exit(0);
+ } else if (mode == MODE_VERSION) {
+ fprintf(stdout,
+ PACKAGE " version " VERSION "\n");
+ exit(0);
} else if (!args[k].lng && argp[i][0] == '-') {
exit_bad_args();
} else {