@@ -316,7 +316,7 @@ int tracecmd_append_options(struct tracecmd_output *handle);
void tracecmd_output_close(struct tracecmd_output *handle);
void tracecmd_output_free(struct tracecmd_output *handle);
struct tracecmd_output *tracecmd_copy(struct tracecmd_input *ihandle, const char *file,
- enum tracecmd_file_states state);
+ enum tracecmd_file_states state, const char *compression);
int tracecmd_write_cpu_data(struct tracecmd_output *handle,
int cpus, char * const *cpu_data_files);
@@ -1999,20 +1999,23 @@ struct tracecmd_output *tracecmd_create_init_file_override(const char *output_fi
* @ihandle: input handle of the trace.dat file to copy
* @file: the trace.dat file to create
* @state: what data will be copied from the source handle
+ * @compression: compression of the output file, can be one of:
+ * NULL - inherit compression from the input file
+ * "any" - compress the output file with the best available algorithm
+ * "none" - do not compress the output file
+ * algorithm_name - compress the output file with specified algorithm
*
* Reads the header information and creates a new trace data file
* with the same characteristics (events and all) and returns
* tracecmd_output handle to this new file.
*/
struct tracecmd_output *tracecmd_copy(struct tracecmd_input *ihandle, const char *file,
- enum tracecmd_file_states state)
+ enum tracecmd_file_states state, const char *compression)
{
enum tracecmd_file_states fstate;
struct tracecmd_output *handle;
- const char *compr_name = NULL;
- tracecmd_get_file_compress_proto(ihandle, &compr_name, NULL);
- handle = create_file(file, ihandle, NULL, NULL, &all_event_list, compr_name);
+ handle = create_file(file, ihandle, NULL, NULL, &all_event_list, compression);
if (!handle)
return NULL;
@@ -125,7 +125,7 @@ void trace_restore (int argc, char **argv)
if (tracecmd_read_headers(ihandle, TRACECMD_FILE_CMD_LINES) < 0)
die("error reading file %s headers", input);
- handle = tracecmd_copy(ihandle, output, TRACECMD_FILE_CMD_LINES);
+ handle = tracecmd_copy(ihandle, output, TRACECMD_FILE_CMD_LINES, NULL);
tracecmd_close(ihandle);
} else
handle = tracecmd_create_init_file(output, NULL);
@@ -345,7 +345,7 @@ static double parse_file(struct tracecmd_input *handle,
dir = dirname(output);
base = basename(output);
- ohandle = tracecmd_copy(handle, output_file, TRACECMD_FILE_CMD_LINES);
+ ohandle = tracecmd_copy(handle, output_file, TRACECMD_FILE_CMD_LINES, NULL);
cpus = tracecmd_cpus(handle);
cpu_data = malloc(sizeof(*cpu_data) * cpus);
Added compression parameter to the tracecmd_copy() API, which allows to select the compression of the created output file. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- lib/trace-cmd/include/private/trace-cmd-private.h | 2 +- lib/trace-cmd/trace-output.c | 11 +++++++---- tracecmd/trace-restore.c | 2 +- tracecmd/trace-split.c | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-)