[PATCH] Update in-program help/usage info
authorJens Axboe <axboe@suse.de>
Thu, 22 Sep 2005 10:30:12 +0000 (12:30 +0200)
committerJens Axboe <axboe@suse.de>
Thu, 22 Sep 2005 10:30:12 +0000 (12:30 +0200)
README
blkparse.c
blktrace.c

diff --git a/README b/README
index 25ab20541249bfb64147ce4c20f56ea0423e0933..19c4178e06f8eb7405f28d4ab7c0bb2b5eee9292 100644 (file)
--- a/README
+++ b/README
@@ -48,6 +48,8 @@ $ blktrace -d <dev> [ -r relay_path ] [ -o output ] [ -k ] [ -w time ]
 
        -A Give the trace mask directly as a number.
 
+       -v Print program version info.
+
 $ blkparse -i <input> [ -o <output> ] [ -b rb_batch ] [ -s ] [ -t ] [ -q ]
                      [ -w start:stop ] [ -f output format ] [ -F format spec ]
 
@@ -99,6 +101,7 @@ $ blkparse -i <input> [ -o <output> ] [ -b rb_batch ] [ -s ] [ -t ] [ -q ]
                W       - Bounce
                X       - Split
 
+       -v Print program version info.
 
 If you want to do live tracing, you can pipe the data between blktrace
 and blkparse:
index 671e3bf060aa70683cdfb1603f1a2de733d2c66e..9369884d8969c4be29bcbdd21b77410fef03a797 100644 (file)
@@ -35,6 +35,8 @@
 #include "blktrace.h"
 #include "rbtree.h"
 
+static char blkparse_version[] = "0.90";
+
 #define SECONDS(x)             ((unsigned long long)(x) / 1000000000)
 #define NANO_SECONDS(x)                ((unsigned long long)(x) % 1000000000)
 #define DOUBLE_TO_NANO_ULL(d)  ((unsigned long long)((d) * 1000000000))
@@ -100,7 +102,7 @@ static struct per_process_info *ppi_hash[1 << PPI_HASH_SHIFT];
 static struct per_process_info *ppi_list;
 static int ppi_list_entries;
 
-#define S_OPTS "i:o:b:stqw:f:F:"
+#define S_OPTS "i:o:b:stqw:f:F:v"
 static struct option l_opts[] = {
        {
                .name = "input",
@@ -156,6 +158,12 @@ static struct option l_opts[] = {
                .flag = NULL,
                .val = 'F'
        },
+       {
+               .name = "version",
+               .has_arg = no_argument,
+               .flag = NULL,
+               .val = 'v'
+       },
 };
 
 /*
@@ -1712,11 +1720,26 @@ static int find_stopwatch_interval(char *string)
        return 0;
 }
 
+static char usage_str[] = \
+       "[ -i <input name> ] [-o <output name> [ -s ] [ -t ] [ -q ]\n" \
+       "[ -w start:stop ] [ -f output format ] [ -F format spec ] [ -v] \n\n" \
+       "\t-i Input file containing trace data, or '-' for stdin\n" \
+       "\t-o Output file. If not given, output is stdout\n" \
+       "\t-b stdin read batching\n" \
+       "\t-s Show per-program io statistics\n" \
+       "\t-t Track individual ios. Will tell you the time a request took\n" \
+       "\t   to get queued, to get dispatched, and to get completed\n" \
+       "\t-q Quiet. Don't display any stats at the end of the trace\n" \
+       "\t-w Only parse data between the given time interval in seconds.\n" \
+       "\t   If 'start' isn't given, blkparse defaults the start time to 0\n" \
+       "\t -f Output format. Customize the output format. The format field\n" \
+       "\t    identifies can be found in the documentation\n" \
+       "\t-F Format specification. Can be found in the documentation\n" \
+       "\t-v Print program version info\n\n";
+
 static void usage(char *prog)
 {
-       fprintf(stderr, "Usage: %s "
-               "[-i <name>] [-o <output>] [-s] [-w N[:n]] <name>...\n",
-               prog);
+       fprintf(stderr, "Usage: %s %s %s", prog, blkparse_version, usage_str);
 }
 
 int main(int argc, char *argv[])
@@ -1761,6 +1784,9 @@ int main(int argc, char *argv[])
                        if (add_format_spec(optarg) != 0)
                                return 1;
                        break;
+               case 'v':
+                       printf("%s version %s\n", argv[0], blkparse_version);
+                       return 0;
                default:
                        usage(argv[0]);
                        return 1;
index 3869163d5b1a5b7ac3bf3764e36c55b17a539a46..891b0a361c59f51813f9dd47ebc976847ff86243 100644 (file)
@@ -38,6 +38,8 @@
 
 #include "blktrace.h"
 
+static char blktrace_version[] = "0.90";
+
 #define BUF_SIZE       (128 *1024)
 #define BUF_NR         (4)
 
@@ -69,7 +71,7 @@ struct mask_map mask_maps[] = {
        DECLARE_MASK_MAP(PC),
 };
 
-#define S_OPTS "d:a:A:r:o:kw:"
+#define S_OPTS "d:a:A:r:o:kw:v"
 static struct option l_opts[] = {
        {
                .name = "dev",
@@ -113,6 +115,12 @@ static struct option l_opts[] = {
                .flag = NULL,
                .val = 'w'
        },
+       {
+               .name = "version",
+               .has_arg = no_argument,
+               .flag = NULL,
+               .val = 'v'
+       },
 };
 
 struct thread_information {
@@ -579,12 +587,22 @@ static void show_stats(void)
                printf("  Total:  %20lld events\n", events_processed);
        }
 }
-  
+
+static char usage_str[] = \
+       "-d <dev> [ -r relay path ] [ -o <output> ] [-k ] [ -w time ]\n" \
+       "[ -a action ] [ -A action mask ] [ -v ]\n\n" \
+       "\t-d Use specified device. May also be given last after options\n" \
+       "\t-r Path to mounted relayfs, defaults to /relay\n" \
+       "\t-o File(s) to send output to\n" \
+       "\t-k Kill a running trace\n" \
+       "\t-w Stop after defined time, in seconds\n" \
+       "\t-a Only trace specified actions. See documentation\n" \
+       "\t-A Give trace mask as a single value. See documentation\n" \
+       "\t-v Print program version info\n\n";
+
 static void show_usage(char *program)
 {
-       fprintf(stderr,"Usage: %s [-d <dev>] "
-                      "[-a <trace> [-a <trace>]] <dev>\n",
-               program);
+       fprintf(stderr, "Usage: %s %s %s",program, blktrace_version, usage_str);
 }
 
 static void handle_sigint(int sig)
@@ -646,7 +664,9 @@ int main(int argc, char *argv[])
                                return 1;
                        }
                        break;
-
+               case 'v':
+                       printf("%s version %s\n", argv[0], blktrace_version);
+                       return 0;
                default:
                        show_usage(argv[0]);
                        return 1;