lkml.org 
[lkml]   [2019]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 10/14] perf data: Add perf_data__update_dir function
Date
Adding perf_data__update_dir function to update
size for every file within the perf.data directory.

Link: http://lkml.kernel.org/n/tip-3ii12l48u4tyvrzxo1797w7e@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/perf/util/data.c | 20 ++++++++++++++++++++
tools/perf/util/data.h | 1 +
2 files changed, 21 insertions(+)

diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 59c052454fac..fbe46dab8dbd 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -124,6 +124,26 @@ static int perf_data__open_dir(struct perf_data *data)
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)
{
struct stat st;
diff --git a/tools/perf/util/data.h b/tools/perf/util/data.h
index a1edf7e03a71..bd7affb69dba 100644
--- a/tools/perf/util/data.h
+++ b/tools/perf/util/data.h
@@ -78,4 +78,5 @@ int perf_data__switch(struct perf_data *data,

int perf_data__create_dir(struct perf_data *data, int nr);
void perf_data__free_dir(struct perf_data *data);
+int perf_data__update_dir(struct perf_data *data);
#endif /* __PERF_DATA_H */
--
2.17.2
\
 
 \ /
  Last update: 2019-02-03 16:31    [W:0.201 / U:1.364 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site