diff --git a/README b/README index d7d1fbf..7fd803b 100644 --- a/README +++ b/README @@ -38,7 +38,7 @@ Usage ----- $ blktrace -d [ -r debug_path ] [ -o output ] [ -k ] [ -w time ] - [ -a action ] [ -A action mask ] + [ -e events] [ -a action ] [ -A action mask ] -d Use specified device. May also be given last after options. -r Path to mounted debugfs, defaults to /sys/kernel/debug. @@ -46,6 +46,7 @@ $ blktrace -d [ -r debug_path ] [ -o output ] [ -k ] [ -w time ] -D Directory to prepend to output file names. -k Kill running trace. -w Stop after defined time, in seconds. + -e Stop after defined captured trace events. -a Only trace specific actions (use more -a options to add actions). Available actions are: diff --git a/blktrace.c b/blktrace.c index 038b2cb..58d3064 100644 --- a/blktrace.c +++ b/blktrace.c @@ -282,6 +282,7 @@ static int pagesize; static int act_mask = ~0U; static int kill_running_trace; static int stop_watch; +static unsigned long long events; static int piped_output; static char *debugfs_path = "/sys/kernel/debug"; @@ -329,7 +330,9 @@ static int *cl_fds; static int (*handle_pfds)(struct tracer *, int, int); static int (*handle_list)(struct tracer_devpath_head *, struct list_head *); -#define S_OPTS "d:a:A:r:o:kw:vVb:n:D:lh:p:sI:" +static void stop_tracers(void); + +#define S_OPTS "d:a:A:e:r:o:kw:vVb:n:D:lh:p:sI:" static struct option l_opts[] = { { .name = "dev", @@ -355,6 +358,12 @@ static struct option l_opts[] = { .flag = NULL, .val = 'A' }, + { + .name = "events", + .has_arg = required_argument, + .flag = NULL, + .val = 'e' + }, { .name = "relay", .has_arg = required_argument, @@ -444,6 +453,7 @@ static char usage_str[] = "\n\n" \ "[ -o | --output=]\n" \ "[ -D | --output-dir=\n" \ "[ -w