diff options
| author | Jiri Olsa <jolsa@kernel.org> | 2019-02-24 14:06:39 -0500 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-02-25 08:33:51 -0500 |
| commit | c69e4c37b37c816c7dbd307a6e7d2d2a5cfe8788 (patch) | |
| tree | 2ed05057fddaee776be2ce96ad69643a2cd06b9f /tools | |
| parent | cdb6b0235f170a5ffcd74731178efc064bd4d24a (diff) | |
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@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>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/perf/util/util.c | 11 | ||||
| -rw-r--r-- | tools/perf/util/util.h | 1 |
2 files changed, 12 insertions, 0 deletions
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) | |||
| 202 | return rmdir(path); | 202 | return rmdir(path); |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | int rm_rf_perf_data(const char *path) | ||
| 206 | { | ||
| 207 | const char *pat[] = { | ||
| 208 | "header", | ||
| 209 | "data.*", | ||
| 210 | NULL, | ||
| 211 | }; | ||
| 212 | |||
| 213 | return rm_rf_depth_pat(path, 0, pat); | ||
| 214 | } | ||
| 215 | |||
| 205 | int rm_rf(const char *path) | 216 | int rm_rf(const char *path) |
| 206 | { | 217 | { |
| 207 | return rm_rf_depth_pat(path, INT_MAX, NULL); | 218 | 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; | |||
| 31 | 31 | ||
| 32 | int mkdir_p(char *path, mode_t mode); | 32 | int mkdir_p(char *path, mode_t mode); |
| 33 | int rm_rf(const char *path); | 33 | int rm_rf(const char *path); |
| 34 | int rm_rf_perf_data(const char *path); | ||
| 34 | struct strlist *lsdir(const char *name, bool (*filter)(const char *, struct dirent *)); | 35 | struct strlist *lsdir(const char *name, bool (*filter)(const char *, struct dirent *)); |
| 35 | bool lsdir_no_dot_filter(const char *name, struct dirent *d); | 36 | bool lsdir_no_dot_filter(const char *name, struct dirent *d); |
| 36 | int copyfile(const char *from, const char *to); | 37 | int copyfile(const char *from, const char *to); |
