perf buildid-cache: Use lsdir() for looking up buildid caches
Use new lsdir() for looking up buildid caches. This changes logic a bit to ignore all dot files, since the build-id cache must not start with dot. Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> 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/20160511135217.23943.94596.stgit@devbox Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
c48903b816
commit
d65444d2fb
|
@ -365,39 +365,17 @@ static char *build_id_cache__dirname_from_path(const char *name,
|
||||||
int build_id_cache__list_build_ids(const char *pathname,
|
int build_id_cache__list_build_ids(const char *pathname,
|
||||||
struct strlist **result)
|
struct strlist **result)
|
||||||
{
|
{
|
||||||
struct strlist *list;
|
|
||||||
char *dir_name;
|
char *dir_name;
|
||||||
DIR *dir;
|
|
||||||
struct dirent *d;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
list = strlist__new(NULL, NULL);
|
|
||||||
dir_name = build_id_cache__dirname_from_path(pathname, false, false);
|
dir_name = build_id_cache__dirname_from_path(pathname, false, false);
|
||||||
if (!list || !dir_name) {
|
if (!dir_name)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* List up all dirents */
|
*result = lsdir(dir_name, lsdir_no_dot_filter);
|
||||||
dir = opendir(dir_name);
|
if (!*result)
|
||||||
if (!dir) {
|
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((d = readdir(dir)) != NULL) {
|
|
||||||
if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, ".."))
|
|
||||||
continue;
|
|
||||||
strlist__add(list, d->d_name);
|
|
||||||
}
|
|
||||||
closedir(dir);
|
|
||||||
|
|
||||||
out:
|
|
||||||
free(dir_name);
|
free(dir_name);
|
||||||
if (ret)
|
|
||||||
strlist__delete(list);
|
|
||||||
else
|
|
||||||
*result = list;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue