[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20160429124527.11856.7511.stgit@devbox>
Date: Fri, 29 Apr 2016 21:45:27 +0900
From: Masami Hiramatsu <mhiramat@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: Masami Hiramatsu <mhiramat@...nel.org>,
linux-kernel@...r.kernel.org, Namhyung Kim <namhyung@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Hemant Kumar <hemant@...ux.vnet.ibm.com>,
Ananth N Mavinakayanahalli <ananth@...ux.vnet.ibm.com>
Subject: [PATCH perf/core v6 02/14] perf-buildid-cache: Use lsdir for looking up buildid caches
From: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
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 <masami.hiramatsu.pt@...achi.com>
Signed-off-by: Masami Hiramatsu <mhiramat@...nel.org>
---
tools/perf/util/build-id.c | 30 +++++-------------------------
1 file changed, 5 insertions(+), 25 deletions(-)
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
index 387581a..20b40f5 100644
--- a/tools/perf/util/build-id.c
+++ b/tools/perf/util/build-id.c
@@ -395,38 +395,18 @@ int build_id_cache__list_build_ids(const char *pathname,
{
struct strlist *list;
char *dir_name;
- DIR *dir;
- struct dirent *d;
int ret = 0;
- list = strlist__new(NULL, NULL);
dir_name = build_id_cache__dirname_from_path(pathname, false, false,
NULL);
- if (!list || !dir_name) {
- ret = -ENOMEM;
- goto out;
- }
+ if (!dir_name)
+ return -ENOMEM;
- /* List up all dirents */
- dir = opendir(dir_name);
- if (!dir) {
+ list = lsdir(dir_name, lsdir_no_dot_filter);
+ if (!list)
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:
+ *result = list;
free(dir_name);
- if (ret)
- strlist__delete(list);
- else
- *result = list;
return ret;
}
Powered by blists - more mailing lists