[tip:perf/core] perf tools: Add rm_rf_perf_data function
From: tip-bot for Jiri Olsa
Date: Thu Feb 28 2019 - 03:02:56 EST
Commit-ID: c69e4c37b37c816c7dbd307a6e7d2d2a5cfe8788
Gitweb: https://git.kernel.org/tip/c69e4c37b37c816c7dbd307a6e7d2d2a5cfe8788
Author: Jiri Olsa <jolsa@xxxxxxxxxx>
AuthorDate: Sun, 24 Feb 2019 20:06:39 +0100
Committer: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
CommitDate: Mon, 25 Feb 2019 10:33:51 -0300
perf tools: Add rm_rf_perf_data function
To remove perf.data including the directory, with checking on expected
files and no other directories inside.
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
Suggested-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
Cc: Alexey Budankov <alexey.budankov@xxxxxxxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Stephane Eranian <eranian@xxxxxxxxxx>
Link: http://lkml.kernel.org/r/20190224190656.30163-4-jolsa@xxxxxxxxxx
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/util.c | 11 +++++++++++
tools/perf/util/util.h | 1 +
2 files changed, 12 insertions(+)
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 02b7a38f98ce..706818693086 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -202,6 +202,17 @@ static int rm_rf_depth_pat(const char *path, int depth, const char **pat)
return rmdir(path);
}
+int rm_rf_perf_data(const char *path)
+{
+ const char *pat[] = {
+ "header",
+ "data.*",
+ NULL,
+ };
+
+ return rm_rf_depth_pat(path, 0, pat);
+}
+
int rm_rf(const char *path)
{
return rm_rf_depth_pat(path, INT_MAX, NULL);
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index ece040b799f6..01c538027c6f 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -31,6 +31,7 @@ struct strlist;
int mkdir_p(char *path, mode_t mode);
int rm_rf(const char *path);
+int rm_rf_perf_data(const char *path);
struct strlist *lsdir(const char *name, bool (*filter)(const char *, struct dirent *));
bool lsdir_no_dot_filter(const char *name, struct dirent *d);
int copyfile(const char *from, const char *to);