Commit 386e0d83 authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

perf tools: Remove also guest kcore_dir with host kcore_dir

Copies of /proc/kallsyms, /proc/modules and an extract of /proc/kcore can
be stored in the perf.data output directory under the subdirectory named
kcore_dir. Guest machines will have their files also under subdirectories
beginning kcore_dir__ followed by the machine pid. Remove these also when
removing kcore_dir.
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Acked-by: default avatarIan Rogers <irogers@google.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: kvm@vger.kernel.org
Link: https://lore.kernel.org/r/20220711093218.10967-21-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 13a133b2
......@@ -200,7 +200,7 @@ static int rm_rf_depth_pat(const char *path, int depth, const char **pat)
return rmdir(path);
}
static int rm_rf_kcore_dir(const char *path)
static int rm_rf_a_kcore_dir(const char *path, const char *name)
{
char kcore_dir_path[PATH_MAX];
const char *pat[] = {
......@@ -210,11 +210,44 @@ static int rm_rf_kcore_dir(const char *path)
NULL,
};
snprintf(kcore_dir_path, sizeof(kcore_dir_path), "%s/kcore_dir", path);
snprintf(kcore_dir_path, sizeof(kcore_dir_path), "%s/%s", path, name);
return rm_rf_depth_pat(kcore_dir_path, 0, pat);
}
static bool kcore_dir_filter(const char *name __maybe_unused, struct dirent *d)
{
const char *pat[] = {
"kcore_dir",
"kcore_dir__[1-9]*",
NULL,
};
return match_pat(d->d_name, pat);
}
static int rm_rf_kcore_dir(const char *path)
{
struct strlist *kcore_dirs;
struct str_node *nd;
int ret;
kcore_dirs = lsdir(path, kcore_dir_filter);
if (!kcore_dirs)
return 0;
strlist__for_each_entry(nd, kcore_dirs) {
ret = rm_rf_a_kcore_dir(path, nd->s);
if (ret)
return ret;
}
strlist__delete(kcore_dirs);
return 0;
}
int rm_rf_perf_data(const char *path)
{
const char *pat[] = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment