diff options
author | Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> | 2016-05-11 09:52:17 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-05-11 12:06:08 -0400 |
commit | d65444d2fba98dcd4fa028ffada39c36a46f0038 (patch) | |
tree | 9f72227d5a3282e19994cf8ee0ad81c4d66abdd7 | |
parent | c48903b816e6cdffb09b473352851bf199d0c582 (diff) |
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>
-rw-r--r-- | tools/perf/util/build-id.c | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index b6ecf87bc3e3..bff425e1232c 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c | |||
@@ -365,39 +365,17 @@ static char *build_id_cache__dirname_from_path(const char *name, | |||
365 | int build_id_cache__list_build_ids(const char *pathname, | 365 | int build_id_cache__list_build_ids(const char *pathname, |
366 | struct strlist **result) | 366 | struct strlist **result) |
367 | { | 367 | { |
368 | struct strlist *list; | ||
369 | char *dir_name; | 368 | char *dir_name; |
370 | DIR *dir; | ||
371 | struct dirent *d; | ||
372 | int ret = 0; | 369 | int ret = 0; |
373 | 370 | ||
374 | list = strlist__new(NULL, NULL); | ||
375 | dir_name = build_id_cache__dirname_from_path(pathname, false, false); | 371 | dir_name = build_id_cache__dirname_from_path(pathname, false, false); |
376 | if (!list || !dir_name) { | 372 | if (!dir_name) |
377 | ret = -ENOMEM; | 373 | return -ENOMEM; |
378 | goto out; | ||
379 | } | ||
380 | 374 | ||
381 | /* List up all dirents */ | 375 | *result = lsdir(dir_name, lsdir_no_dot_filter); |
382 | dir = opendir(dir_name); | 376 | if (!*result) |
383 | if (!dir) { | ||
384 | ret = -errno; | 377 | ret = -errno; |
385 | goto out; | ||
386 | } | ||
387 | |||
388 | while ((d = readdir(dir)) != NULL) { | ||
389 | if (!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) | ||
390 | continue; | ||
391 | strlist__add(list, d->d_name); | ||
392 | } | ||
393 | closedir(dir); | ||
394 | |||
395 | out: | ||
396 | free(dir_name); | 378 | free(dir_name); |
397 | if (ret) | ||
398 | strlist__delete(list); | ||
399 | else | ||
400 | *result = list; | ||
401 | 379 | ||
402 | return ret; | 380 | return ret; |
403 | } | 381 | } |