diff options
author | Jiri Olsa <jolsa@kernel.org> | 2019-03-08 08:47:37 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-03-11 10:56:03 -0400 |
commit | e8be135751f26aa5de63e517d375ecf69e9b20c3 (patch) | |
tree | bdf4f2c133b70f7052bfe63c73f7d1fda5224cd8 /tools/perf/util/data.c | |
parent | cd3dd8dd8ff62374d90cb3f2e54b8c94106c7810 (diff) |
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: Jiri 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.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/data.c')
-rw-r--r-- | tools/perf/util/data.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 18fa8d4614eb..5d0f26aef77f 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c | |||
@@ -124,6 +124,26 @@ out_err: | |||
124 | return ret; | 124 | return ret; |
125 | } | 125 | } |
126 | 126 | ||
127 | int perf_data__update_dir(struct perf_data *data) | ||
128 | { | ||
129 | int i; | ||
130 | |||
131 | if (WARN_ON(!data->is_dir)) | ||
132 | return -EINVAL; | ||
133 | |||
134 | for (i = 0; i < data->dir.nr; i++) { | ||
135 | struct perf_data_file *file = &data->dir.files[i]; | ||
136 | struct stat st; | ||
137 | |||
138 | if (fstat(file->fd, &st)) | ||
139 | return -1; | ||
140 | |||
141 | file->size = st.st_size; | ||
142 | } | ||
143 | |||
144 | return 0; | ||
145 | } | ||
146 | |||
127 | static bool check_pipe(struct perf_data *data) | 147 | static bool check_pipe(struct perf_data *data) |
128 | { | 148 | { |
129 | struct stat st; | 149 | struct stat st; |