From 86c8c628577cf297f1b7f30797c613b64ca17c2a Mon Sep 17 00:00:00 2001 From: Adham Masarwah Date: Tue, 8 Jul 2014 11:15:57 +0300 Subject: [PATCH] Added -v flag to print version Updated the Help to contain -v / -h flags Signed-off-by: Adham Masarwah --- small_utils/vpd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/small_utils/vpd.c b/small_utils/vpd.c index bb76a98..930c94d 100644 --- a/small_utils/vpd.c +++ b/small_utils/vpd.c @@ -45,6 +45,7 @@ #include #include #include +#include "tools_version.h" /* pread is non-blocking, so we loop until we find data. Unfortunately, * we can loop forever if the HCA is crashed or if the wrong device is @@ -128,6 +129,8 @@ enum { #define VPD_FIELD_CHECKSUM "RV" #define VPD_FIELD_RW "RW" +#define VPD_TOOL_VERSON "2.0.0" + int pci_find_capability(int fd, int cap_id) { unsigned offset; @@ -550,7 +553,7 @@ int main(int argc, char **argv) do { - i=getopt(argc, argv, "mhnrt:"); + i=getopt(argc, argv, "mvhnrt:"); if (i<0) { break; } @@ -565,6 +568,9 @@ int main(int argc, char **argv) case 'h': rc = 0; goto usage; + case 'v': + print_version_string("mstvpd", VPD_TOOL_VERSON); + exit(0); case 'r': ignore_w=1; break; @@ -626,6 +632,8 @@ int main(int argc, char **argv) usage: fprintf(stderr, "Usage: %s [-m|-n] [-t ##] [-- keyword ...]\n", argv[0]); + fprintf(stderr, "-h\tPrint this help.\n"); + fprintf(stderr, "-v\tPrint tool version.\n"); fprintf(stderr, "-m\tDump raw VPD data to stdout.\n"); fprintf(stderr, "-n\tDo not validate check sum.\n"); fprintf(stderr, "-r\tDo not check and display the VPD_W tag in the vpd data.\n"); -- 2.46.0