perf tools: Add rm_rf_perf_data function
authorJiri Olsa <jolsa@kernel.org>
Sun, 24 Feb 2019 19:06:39 +0000 (20:06 +0100)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 25 Feb 2019 13:33:51 +0000 (10:33 -0300)
To remove perf.data including the directory, with checking on expected
files and no other directories inside.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Suggested-by: Andi Kleen <ak@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Budankov <alexey.budankov@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/20190224190656.30163-4-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/util.c
tools/perf/util/util.h

index 02b7a38f98ce156966b52cb8884e930db68a588d..706818693086d98bf2d714f43fa63ad6b0237aa9 100644 (file)
@@ -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);
index ece040b799f6ead3614d6061d60dbe3c17c2cac4..01c538027c6f513ec452e5b133aba5476581d2f0 100644 (file)
@@ -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);