Commit c48903b8 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Arnaldo Carvalho de Melo

perf symbols: Use lsdir() for the search in kcore cache directory

Use lsdir() to search in kcore cache directory. This also avoids
checking hidden dot directory entries, because kcore cache directories
must always have the name from timestamps when taking the kcore
snapshots, and it never start with dot.
Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Cc: Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>
Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20160511135208.23943.68071.stgit@devboxSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent b5d8bbe8
...@@ -1608,25 +1608,27 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map, ...@@ -1608,25 +1608,27 @@ int dso__load_vmlinux_path(struct dso *dso, struct map *map,
return err; return err;
} }
static bool visible_dir_filter(const char *name, struct dirent *d)
{
if (d->d_type != DT_DIR)
return false;
return lsdir_no_dot_filter(name, d);
}
static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz) static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz)
{ {
char kallsyms_filename[PATH_MAX]; char kallsyms_filename[PATH_MAX];
struct dirent *dent;
int ret = -1; int ret = -1;
DIR *d; struct strlist *dirs;
struct str_node *nd;
d = opendir(dir); dirs = lsdir(dir, visible_dir_filter);
if (!d) if (!dirs)
return -1; return -1;
while (1) { strlist__for_each(nd, dirs) {
dent = readdir(d);
if (!dent)
break;
if (dent->d_type != DT_DIR)
continue;
scnprintf(kallsyms_filename, sizeof(kallsyms_filename), scnprintf(kallsyms_filename, sizeof(kallsyms_filename),
"%s/%s/kallsyms", dir, dent->d_name); "%s/%s/kallsyms", dir, nd->s);
if (!validate_kcore_addresses(kallsyms_filename, map)) { if (!validate_kcore_addresses(kallsyms_filename, map)) {
strlcpy(dir, kallsyms_filename, dir_sz); strlcpy(dir, kallsyms_filename, dir_sz);
ret = 0; ret = 0;
...@@ -1634,7 +1636,7 @@ static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz) ...@@ -1634,7 +1636,7 @@ static int find_matching_kcore(struct map *map, char *dir, size_t dir_sz)
} }
} }
closedir(d); strlist__delete(dirs);
return ret; return ret;
} }
......
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