Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1154153pxu; Fri, 27 Nov 2020 00:37:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzb6QOEF+VVao6Uqh2NmcaF+wklx2EXfaaBRC70MS78cajInEwOzcKl8bbcczkKKs7ur7Gy X-Received: by 2002:a17:906:6947:: with SMTP id c7mr6523519ejs.533.1606466278274; Fri, 27 Nov 2020 00:37:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606466278; cv=none; d=google.com; s=arc-20160816; b=dEGRLss2gI9PGLRd0hTDojmJoOihkwH3K4oTtVRCnrzzQ8UNG9d/XDN7zbNlUCRhiN 4ihAoEO5JHjvxb59ydlP8sjedF8bVjQYXrcjYDQU4YVG0AhjEFPGnGxvSx856kzaD1wK tH5elg6Fz9sC4d9tHSvUb0Vm3YJWLfWvZxwyYs+u2RsMlPxpvXBP7LAUV88eYG/ei+DZ ga5dPgZ/I6mSdvpUbQvBehGvjhavm5sh4j3K4xrYtyWc/8zlegqvuLbdQUDKM0gOmj+l 9utIRAe+rAJ6Ejl94JltmC2ec4Au0+NKDtuSBBQc5HA0Ug+Z3y64b+lmQANQDrJOf+op Eh6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5PGjYAmaSJ7JzdBUsPibdM5CSZrZUg3kj4s7hkSk4A4=; b=NHvyD8deF4Rd6YkH6ZJRNFMYg8DtmxeLa3fAgWotpTrc3y8CRTHOUePqzjoCFHKDqo ehZUmwKkGjaNXCYae8mtpwhhxnf1qh+Suk3nbuFbBHKcLddt+k8CmtJcq3Vg0QeRS5ZM Navpq0opSIqTeHC1V0PfB2AJ6ZNd1o3hpKeGHuaPFlfGKx7wt6pMNTMCpFduS4FDmv5d YHz9m0livfgQAYLQNhOthkj+VlZZzCPWgd4GUm2NwE1ZvSWohhW15T4rlKmX+OwPr6Cf 1CWHFkgImIZpYw1wGWOLLCTzNhMrw5/Q6w7JjriSmT25DsEEJvPM/Vn8P13iG/dq+b2P Vc3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xHtHqSlA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s3si4642408ejc.65.2020.11.27.00.37.36; Fri, 27 Nov 2020 00:37:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xHtHqSlA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391744AbgKZRvl (ORCPT + 99 others); Thu, 26 Nov 2020 12:51:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:44868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391741AbgKZRvk (ORCPT ); Thu, 26 Nov 2020 12:51:40 -0500 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A4B9420665; Thu, 26 Nov 2020 17:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606413099; bh=gZ9qg9LQpXvKPlB4tlTS2cx56/Nkhs90eRgyWc22/R8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xHtHqSlA2oXWFzgw8iu3A3pmabY12hk5Xj6fcY11uqNOHIyTWE3oX84a4p11zOmfW R3tXZ5nzYgRvteguGf0fFKKFaxzuiox5kX5MQJct5raKY9LAekR+OZoN/L1Zv/h8Ud 3G8us4/3Jiaqc/jXauqueygqcx+OODSqApAM7PUY= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 72B2B40E29; Thu, 26 Nov 2020 14:51:37 -0300 (-03) Date: Thu, 26 Nov 2020 14:51:37 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: Ian Rogers , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: Re: [PATCH 20/25] perf tools: Add is_perf_data function Message-ID: <20201126175137.GE70905@kernel.org> References: <20201126170026.2619053-1-jolsa@kernel.org> <20201126170026.2619053-21-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126170026.2619053-21-jolsa@kernel.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Thu, Nov 26, 2020 at 06:00:21PM +0100, Jiri Olsa escreveu: > Adding is_perf_data function that returns true if > the given path is perf data file. It will be used > in following patches. Thanks, applied. - Arnaldo > Acked-by: Ian Rogers > Signed-off-by: Jiri Olsa > --- > tools/perf/util/data.c | 19 +++++++++++++++++++ > tools/perf/util/data.h | 1 + > 2 files changed, 20 insertions(+) > > diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c > index 05bbcb663c41..f29af4fc3d09 100644 > --- a/tools/perf/util/data.c > +++ b/tools/perf/util/data.c > @@ -492,3 +492,22 @@ char *perf_data__kallsyms_name(struct perf_data *data) > > return kallsyms_name; > } > + > +bool is_perf_data(const char *path) > +{ > + bool ret = false; > + FILE *file; > + u64 magic; > + > + file = fopen(path, "r"); > + if (!file) > + return false; > + > + if (fread(&magic, 1, 8, file) < 8) > + goto out; > + > + ret = is_perf_magic(magic); > +out: > + fclose(file); > + return ret; > +} > diff --git a/tools/perf/util/data.h b/tools/perf/util/data.h > index c563fcbb0288..62a3e66fbee8 100644 > --- a/tools/perf/util/data.h > +++ b/tools/perf/util/data.h > @@ -98,4 +98,5 @@ 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); > char *perf_data__kallsyms_name(struct perf_data *data); > +bool is_perf_data(const char *path); > #endif /* __PERF_DATA_H */ > -- > 2.26.2 > -- - Arnaldo