Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753220AbcD0Shk (ORCPT ); Wed, 27 Apr 2016 14:37:40 -0400 Received: from mail.kernel.org ([198.145.29.136]:42414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753085AbcD0Shi (ORCPT ); Wed, 27 Apr 2016 14:37:38 -0400 From: Masami Hiramatsu To: Arnaldo Carvalho de Melo Cc: Masami Hiramatsu , linux-kernel@vger.kernel.org, Namhyung Kim , Peter Zijlstra , Ingo Molnar , Hemant Kumar , Ananth N Mavinakayanahalli Subject: [PATCH perf/core v5 03/15] perf-buildid-cache: Use lsdir for looking up buildid caches Date: Thu, 28 Apr 2016 03:37:33 +0900 Message-Id: <20160427183733.23446.14297.stgit@devbox> X-Mailer: git-send-email 2.1.0 In-Reply-To: <20160427183701.23446.15293.stgit@devbox> References: <20160427183701.23446.15293.stgit@devbox> 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: 1470 Lines: 60 From: Masami Hiramatsu 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 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 b035483..848e05f 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -400,38 +400,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; }