trace-cmd split: Copy trace_clock from input handler to output handler

When splitting a trace file, the clock is needed to create a output file
from the input file. But the output descriptor clock is never set, and the
clock returned from retrieving the descriptor is NULL (unless you are
root, in which case the code will read the machine trace clock instead,
and continue as if nothing was wrong). This caused a failure, and once
again, trace-cmd split, errored out without failure, but just did not
append all the data.

Although this fixes the commit listed below, the problem was there before,
as the code before that commit tried to read the clock from the file
system, but just wouldn't error out if it couldn't read it.

Add a new function to retrieve the trace_clock from the input handle, to
be used to pass it to the output handle before appending the CPU data.

Link: https://lore.kernel.org/linux-trace-devel/20210622171338.6447f199@gandalf.local.home

Reported-by: Julia Lawall <julia.lawall@inria.fr>
Fixes: 72670886 ("trace-cmd: Save only the selected clock in the trace.dat file")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
4 files changed