Added a helper function, internal to the library, for updating CPU instance offset in the trace file. This allows to reuse the logic inside the library, will be used in the tracecmd_copy API. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@xxxxxxxxx> --- lib/trace-cmd/include/trace-cmd-local.h | 2 ++ lib/trace-cmd/trace-output.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/trace-cmd/include/trace-cmd-local.h b/lib/trace-cmd/include/trace-cmd-local.h index e8c7968f..14908f3c 100644 --- a/lib/trace-cmd/include/trace-cmd-local.h +++ b/lib/trace-cmd/include/trace-cmd-local.h @@ -72,4 +72,6 @@ struct cpu_data_source { int out_write_cpu_data(struct tracecmd_output *handle, int cpus, struct cpu_data_source *data); +int out_update_buffer_cpu_offset(struct tracecmd_output *handle, const char *name); + #endif /* _TRACE_CMD_LOCAL_H */ diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c index a3ccfba5..9933224c 100644 --- a/lib/trace-cmd/trace-output.c +++ b/lib/trace-cmd/trace-output.c @@ -1853,8 +1853,7 @@ int tracecmd_append_cpu_data(struct tracecmd_output *handle, return tracecmd_write_cpu_data(handle, cpus, cpu_data_files); } -int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle, - const char *name, int cpus, char * const *cpu_data_files) +__hidden int out_update_buffer_cpu_offset(struct tracecmd_output *handle, const char *name) { tsize_t b_offset; tsize_t offset; @@ -1883,6 +1882,14 @@ int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle, tracecmd_warning("could not seek to %lld\n", offset); return -1; } + return 0; +} + +int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle, + const char *name, int cpus, char * const *cpu_data_files) +{ + if (out_update_buffer_cpu_offset(handle, name)) + return -1; return tracecmd_write_cpu_data(handle, cpus, cpu_data_files); } -- 2.31.1