summaryrefslogtreecommitdiffstats
path: root/mboxd.c
diff options
context:
space:
mode:
Diffstat (limited to 'mboxd.c')
-rw-r--r--mboxd.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/mboxd.c b/mboxd.c
index 2026023..637f416 100644
--- a/mboxd.c
+++ b/mboxd.c
@@ -54,7 +54,8 @@ const char* USAGE =
"\t\t\t\t(default: fill the reserved memory region)\n"
"\t-w | --window-size\tThe window size (power of 2) in MB\n"
"\t\t\t\t(default: 1MB)\n"
- "\t-f | --flash\t\tSize of flash in [K|M] bytes\n\n";
+ "\t-f | --flash\t\tSize of flash in [K|M] bytes\n\n"
+ "\t-t | --trace\t\tFile to write trace data to (in blktrace format)\n\n";
static int dbus_init(struct mbox_context *context,
const struct transport_ops **ops)
@@ -236,6 +237,7 @@ static bool parse_cmdline(int argc, char **argv,
{ "window-num", optional_argument, 0, 'n' },
{ "verbose", no_argument, 0, 'v' },
{ "syslog", no_argument, 0, 's' },
+ { "trace", optional_argument, 0, 't' },
{ "version", no_argument, 0, 'V' },
{ "help", no_argument, 0, 'h' },
{ 0, 0, 0, 0 }
@@ -246,7 +248,7 @@ static bool parse_cmdline(int argc, char **argv,
context->current = NULL; /* No current window */
- while ((opt = getopt_long(argc, argv, "f:b:w::n::vsVh", long_options, NULL))
+ while ((opt = getopt_long(argc, argv, "f:b:w::n::vst::Vh", long_options, NULL))
!= -1) {
switch (opt) {
case 0:
@@ -309,6 +311,17 @@ static bool parse_cmdline(int argc, char **argv,
case 'V':
printf("%s V%s\n", THIS_NAME, PACKAGE_VERSION);
exit(0);
+ case 't':
+ context->blktracefd = open(argv[optind],
+ O_CREAT|O_TRUNC|O_WRONLY,
+ 0666);
+ printf("Recording blktrace output to %s\n",
+ argv[optind]);
+ if (context->blktracefd == -1) {
+ perror("Couldn't open blktrace file for writing");
+ exit(2);
+ }
+ break;
case 'h':
return false; /* This will print the usage message */
default:
@@ -480,6 +493,9 @@ cleanup_protocol:
cleanup_backend:
backend_free(&context->backend);
cleanup_context:
+ if (context->blktracefd)
+ close(context->blktracefd);
+
free(context);
return rc;
OpenPOWER on IntegriCloud