Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3266355lfo; Mon, 23 May 2022 00:18:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzd8Ipke1XbCcFuk/DmpNQqE+SSXxHmyfWzLvtwfVAo96v2Bery4rJmHcdTX83DUb/E0yNE X-Received: by 2002:a17:902:eb90:b0:161:b624:7acb with SMTP id q16-20020a170902eb9000b00161b6247acbmr16935051plg.93.1653290324932; Mon, 23 May 2022 00:18:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653290324; cv=none; d=google.com; s=arc-20160816; b=gznpeQKNo8tGrCn8k9XCRQAFuR2Vbb06vNl30ukcBnHrtGjbzdlhzgzrT1s5QJ+z8N kMG4vaY3JVUPvzkj+3zCN1SVzp9Grk88bJXDwf61au8794M+W+qB1k2xhaV7IIG7ny+s 8TPIq+5Q07pfOyhqlzgCWTNJEdlzPbrkhL0vOT6OhROMZcilqYTzdUIo+VMgkdjZmLeb NP2kpA5Kn5KAfWrTVs3kXF8KxSjQfJ+YfeU19cyjGz6Tvg7Qzgi2gqeH1ccoYVgvNryk 97LPGt2OHSEUIfojhBX8jjrNkpUH/PRYJSlQ5jdkh1fSHJ0MmFg0WB8IByMf0siAjAJ1 sWMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=6MnJDpgrKhiP2o9y2tHFFf/z8RIIWE8EOuu2fml30aU=; b=WB+OgqY5KuXr3tVamBsWMgLIg+0yehH0UsFh9pq5/ro2VueeNMj7iQf8vvLU+loTmF beZBuG+0DTVGHTHCb8uiI0gZ6lIVqut+3h+w1MePZUzUJkmQOZOnq/2xTqV+QGqdM/d2 DhLQBflrUu7nm1d8w8LfQu9OYsPBAXEVv1K//70h16J4vZj7/E7z5ypuqKfiT84hnvUN SDWmytZcOx8ZYvx1yfDKpQZWb2fKJg4SmjuVdHdyODHMSmO8wirVdHNqak17Kqcwmetv +YfQHhpNTZIktmpJxZKnrcNqDRfoXsWJsIUdeOPuk9DlTk53Fc6ttvNh09T60RMIfNMD f1oA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V3M0pSnl; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id u6-20020a655c06000000b003abada69f69si9395607pgr.282.2022.05.23.00.18.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 00:18:44 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V3M0pSnl; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8D08649254; Sun, 22 May 2022 23:35:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349772AbiETNYm (ORCPT + 99 others); Fri, 20 May 2022 09:24:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241528AbiETNYe (ORCPT ); Fri, 20 May 2022 09:24:34 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 089F814E2C7 for ; Fri, 20 May 2022 06:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653053066; x=1684589066; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l/5zgvFU2ybyvyyFUoqpvM63YLZE49DLKFEnrzYhU8o=; b=V3M0pSnl06wJolLg7UOC13DpX7oAQ33BiMo6OISsdZDvAFVCE+5q+hfR KLRNo0CZZAwq6/JNKobwiaL2okT2/4RLtdE/26plrYescXsz42yiggQxF 7wZ6RlnoGItRa7XWZuHbCadmw8JryFnzZ0yTsCKEUH+2yg5VFXHlUjQ2O pzsL7SYQTDabW7C7A4XGUywih0vMnauVg6Jo2y9w/ZA2EhFPYOyTcZcua MDWG6OseszUTWMSdTdXdi5Bku/i2+UPKjuZWaoFijFI2wIsUCblPABHHz dcU4hyD95g1TlKqSoBSNU941b+i/bB9bg8dp8nns9sxMsX3dhk9tEYQA8 Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10353"; a="335661025" X-IronPort-AV: E=Sophos;i="5.91,239,1647327600"; d="scan'208";a="335661025" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2022 06:24:25 -0700 X-IronPort-AV: E=Sophos;i="5.91,239,1647327600"; d="scan'208";a="715530821" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO ahunter-VirtualBox.home\044ger.corp.intel.com) ([10.252.38.124]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 May 2022 06:24:24 -0700 From: Adrian Hunter To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , linux-kernel@vger.kernel.org Subject: [PATCH 4/5] perf data: Add has_kcore_dir() Date: Fri, 20 May 2022 16:24:03 +0300 Message-Id: <20220520132404.25853-5-adrian.hunter@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220520132404.25853-1-adrian.hunter@intel.com> References: <20220520132404.25853-1-adrian.hunter@intel.com> MIME-Version: 1.0 Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a helper function has_kcore_dir(), so that perf inject can determine if it needs to keep the kcore_dir. Signed-off-by: Adrian Hunter --- tools/perf/util/data.c | 14 ++++++++++++++ tools/perf/util/data.h | 1 + 2 files changed, 15 insertions(+) diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index a5ace2bbc28d..caabeac24c69 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -479,6 +479,20 @@ int perf_data__make_kcore_dir(struct perf_data *data, char *buf, size_t buf_sz) return mkdir(buf, S_IRWXU); } +bool has_kcore_dir(const char *path) +{ + char *kcore_dir; + int ret; + + if (asprintf(&kcore_dir, "%s/kcore_dir", path) < 0) + return false; + + ret = access(kcore_dir, F_OK); + + free(kcore_dir); + return !ret; +} + char *perf_data__kallsyms_name(struct perf_data *data) { char *kallsyms_name; diff --git a/tools/perf/util/data.h b/tools/perf/util/data.h index 1402d9657ef2..7de53d6e2d7f 100644 --- a/tools/perf/util/data.h +++ b/tools/perf/util/data.h @@ -99,6 +99,7 @@ void perf_data__close_dir(struct perf_data *data); int perf_data__update_dir(struct perf_data *data); unsigned long perf_data__size(struct perf_data *data); int perf_data__make_kcore_dir(struct perf_data *data, char *buf, size_t buf_sz); +bool has_kcore_dir(const char *path); char *perf_data__kallsyms_name(struct perf_data *data); bool is_perf_data(const char *path); #endif /* __PERF_DATA_H */ -- 2.25.1