Commit e8be1357 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

perf data: Add perf_data__update_dir() function

Add perf_data__update_dir() to update the size for every file within the
perf.data directory.
Signed-off-by: default avatarJiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20190308134745.5057-4-jolsa@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent cd3dd8dd
...@@ -124,6 +124,26 @@ int perf_data__open_dir(struct perf_data *data) ...@@ -124,6 +124,26 @@ int perf_data__open_dir(struct perf_data *data)
return ret; return ret;
} }
int perf_data__update_dir(struct perf_data *data)
{
int i;
if (WARN_ON(!data->is_dir))
return -EINVAL;
for (i = 0; i < data->dir.nr; i++) {
struct perf_data_file *file = &data->dir.files[i];
struct stat st;
if (fstat(file->fd, &st))
return -1;
file->size = st.st_size;
}
return 0;
}
static bool check_pipe(struct perf_data *data) static bool check_pipe(struct perf_data *data)
{ {
struct stat st; struct stat st;
......
...@@ -79,4 +79,5 @@ int perf_data__switch(struct perf_data *data, ...@@ -79,4 +79,5 @@ int perf_data__switch(struct perf_data *data,
int perf_data__create_dir(struct perf_data *data, int nr); int perf_data__create_dir(struct perf_data *data, int nr);
int perf_data__open_dir(struct perf_data *data); int perf_data__open_dir(struct perf_data *data);
void perf_data__close_dir(struct perf_data *data); void perf_data__close_dir(struct perf_data *data);
int perf_data__update_dir(struct perf_data *data);
#endif /* __PERF_DATA_H */ #endif /* __PERF_DATA_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment