Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754352AbbGOJTI (ORCPT ); Wed, 15 Jul 2015 05:19:08 -0400 Received: from mail4.hitachi.co.jp ([133.145.228.5]:50107 "EHLO mail4.hitachi.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754333AbbGOJTD (ORCPT ); Wed, 15 Jul 2015 05:19:03 -0400 Subject: [RFC PATCH perf/core v2 08/16] perf-buildid-cache: Use lsdir for looking up buildid caches From: Masami Hiramatsu To: Arnaldo Carvalho de Melo Cc: Peter Zijlstra , linux-kernel@vger.kernel.org, Adrian Hunter , Ingo Molnar , Paul Mackerras , Jiri Olsa , Namhyung Kim , Borislav Petkov , Hemant Kumar Date: Wed, 15 Jul 2015 18:14:48 +0900 Message-ID: <20150715091448.8915.40410.stgit@localhost.localdomain> In-Reply-To: <20150715091352.8915.87480.stgit@localhost.localdomain> References: <20150715091352.8915.87480.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1605 Lines: 64 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 --- 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 8c40133..02a5e0d 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -342,38 +342,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(true, 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; } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/