Merge commit 'e50e654bca8df8254c15849c793f9279adcb1182' into master
Commit e50e654bca8d ("Add --trace support (in blktrace format)") is a broken
version of commit ef0c8360065e ("Add --trace support (in blktrace
format)") that appears in master's linear history. Merging e50e654bca8d
preserves the ability to bisect the openbmc/openbmc respository.
The merge was performed as below, which discards any changes performed
in e50e654bca8d:
> $ git merge -s ours e50e654bca8df8254c15849c793f9279adcb1182
Change-Id: I134be5a54303a561ed3ef21813b1e220c0dbd0a6
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
diff --git a/mboxd.c b/mboxd.c
index 3f78410..637f416 100644
--- a/mboxd.c
+++ b/mboxd.c
@@ -248,7 +248,7 @@
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:
@@ -315,8 +315,8 @@
context->blktracefd = open(argv[optind],
O_CREAT|O_TRUNC|O_WRONLY,
0666);
- MSG_INFO("Recording blktrace output to %s\n",
- argv[optind]);
+ printf("Recording blktrace output to %s\n",
+ argv[optind]);
if (context->blktracefd == -1) {
perror("Couldn't open blktrace file for writing");
exit(2);
@@ -493,6 +493,9 @@
cleanup_backend:
backend_free(&context->backend);
cleanup_context:
+ if (context->blktracefd)
+ close(context->blktracefd);
+
free(context);
return rc;
diff --git a/protocol.c b/protocol.c
index 8f2f742..ab1c332 100644
--- a/protocol.c
+++ b/protocol.c
@@ -195,12 +195,13 @@
trace->cpu = 0;
trace->error = 0;
trace->pdu_len = 0;
- write(context->blktracefd, &trace, sizeof(trace));
+ write(context->blktracefd, trace, sizeof(*trace));
trace->sequence++;
trace->time = blktrace_gettime() - context->blktrace_start;
trace->action &= ~BLK_TA_QUEUE;
trace->action |= BLK_TA_ISSUE;
- write(context->blktracefd, &trace, sizeof(trace));}
+ write(context->blktracefd, trace, sizeof(*trace));
+}
static void blktrace_flush_done(struct mbox_context *context)
{
@@ -213,7 +214,7 @@
trace->time = blktrace_gettime() - context->blktrace_start;
trace->action &= ~BLK_TA_ISSUE;
trace->action |= BLK_TA_COMPLETE;
- write(context->blktracefd, &trace, sizeof(trace));
+ write(context->blktracefd, trace, sizeof(*trace));
}
static void blktrace_window_start(struct mbox_context *context)
@@ -246,17 +247,17 @@
trace->sector = context->current->flash_offset / 512;
trace->bytes = context->current->size;
- write(context->blktracefd, &trace, sizeof(trace));
+ write(context->blktracefd, trace, sizeof(*trace));
trace->sequence++;
trace->action &= ~BLK_TA_QUEUE;
trace->action |= BLK_TA_ISSUE;
- write(context->blktracefd, &trace, sizeof(trace));
+ write(context->blktracefd, trace, sizeof(*trace));
trace->sequence++;
trace->time = blktrace_gettime() - context->blktrace_start;
trace->action &= ~BLK_TA_ISSUE;
trace->action |= BLK_TA_COMPLETE;
- write(context->blktracefd, &trace, sizeof(trace));
+ write(context->blktracefd, trace, sizeof(*trace));
}
static int protocol_v1_create_window(struct mbox_context *context,