@@ -980,17 +980,27 @@ out_free:
static int select_file_version(struct tracecmd_output *handle,
struct tracecmd_input *ihandle)
{
+ const char *cname = NULL;
+ const char *cver = NULL;
+
if (ihandle) {
handle->file_version = tracecmd_get_in_file_version(ihandle);
- } else {
- handle->compress = tracecmd_compress_alloc(NULL, NULL, handle->fd,
- handle->pevent, handle->msg_handle);
- if (handle->compress)
- handle->file_version = 7;
- else
- handle->file_version = 6;
+ if (!tracecmd_get_file_compress_proto(ihandle, &cname, &cver)) {
+ handle->compress = tracecmd_compress_alloc(cname, cver, handle->fd,
+ handle->pevent, handle->msg_handle);
+ if (!handle->compress)
+ return -1;
+ }
+ return 0;
}
+ handle->compress = tracecmd_compress_alloc(NULL, NULL, handle->fd,
+ handle->pevent, handle->msg_handle);
+ if (handle->compress)
+ handle->file_version = 7;
+ else
+ handle->file_version = 6;
+
return 0;
}
@@ -1645,6 +1655,8 @@ struct tracecmd_output *tracecmd_get_output_handle_fd(int fd)
{
struct tracecmd_output *handle = NULL;
struct tracecmd_input *ihandle;
+ const char *cname = NULL;
+ const char *cver = NULL;
int fd2;
/* Move the file descriptor to the beginning */
@@ -1682,6 +1694,12 @@ struct tracecmd_output *tracecmd_get_output_handle_fd(int fd)
handle->file_version = tracecmd_get_in_file_version(ihandle);
list_head_init(&handle->options);
+ if (!tracecmd_get_file_compress_proto(ihandle, &cname, &cver)) {
+ handle->compress = tracecmd_compress_alloc(cname, cver, handle->fd,
+ handle->pevent, handle->msg_handle);
+ if (!handle->compress)
+ goto out_free;
+ }
tracecmd_close(ihandle);
return handle;
When a new trace file output handler is allocated, based on given trace file input handler - use the same compression algorithm. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- lib/trace-cmd/trace-output.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-)