From 52724a0ef233f639c2fc6588bbc1cc05be74a422 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 22 Sep 2005 12:30:12 +0200 Subject: [PATCH] [PATCH] Update in-program help/usage info --- README | 3 +++ blkparse.c | 34 ++++++++++++++++++++++++++++++---- blktrace.c | 32 ++++++++++++++++++++++++++------ 3 files changed, 59 insertions(+), 10 deletions(-) diff --git a/README b/README index 25ab205..19c4178 100644 --- a/README +++ b/README @@ -48,6 +48,8 @@ $ blktrace -d [ -r relay_path ] [ -o output ] [ -k ] [ -w time ] -A Give the trace mask directly as a number. + -v Print program version info. + $ blkparse -i [ -o ] [ -b rb_batch ] [ -s ] [ -t ] [ -q ] [ -w start:stop ] [ -f output format ] [ -F format spec ] @@ -99,6 +101,7 @@ $ blkparse -i [ -o ] [ -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: diff --git a/blkparse.c b/blkparse.c index 671e3bf..9369884 100644 --- a/blkparse.c +++ b/blkparse.c @@ -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 ] [-o [ -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 ] [-o ] [-s] [-w N[:n]] ...\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; diff --git a/blktrace.c b/blktrace.c index 3869163..891b0a3 100644 --- a/blktrace.c +++ b/blktrace.c @@ -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 [ -r relay path ] [ -o ] [-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 ] " - "[-a [-a ]] \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; -- 2.25.1