Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp2885165ima; Sun, 3 Feb 2019 08:44:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN5zTuxxMjtBSIqZg/F6+Hvlf4Moh6wDjYC2GDi1ftqFS1WwFhplTWx4tKGFcL3M484zZivX X-Received: by 2002:a62:7c47:: with SMTP id x68mr48210770pfc.209.1549212292370; Sun, 03 Feb 2019 08:44:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549212292; cv=none; d=google.com; s=arc-20160816; b=1EmWQVcfWYv/E6w6RHUQlZRTp+4yDYWRJ7BZiqrf+WiVmAzbvM4Ubac+VGcDXz7N3o DiRbRsKUn2qVAiJyuvZBI4WVkHYtAHP1oWUUpl3JSsFip3MaAhXsVlznV8tJWoLKhDPH brTUqwcjNkV6aiOoMJysqDIqljf9uqcab0pYTWint8Vop3Ea+8uwTHjNdRnlg9SKyLGZ HYvKC38SRacPM14IvBQCCHX9pqj7tJmERt5c/UvPLWfQg9CJ7F6M5Qk+ZwFJfDgbDmbf otM/YwUmo4YRHmkxcZqmO/Yhf086OuRVYytIGJ5YA4r0IxUAJVjcgBLOuhlxGXHbWSFq fMgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=3ZAasglt/bBc/A/j/Ebo6JpuDDpdn9FQ5y9goKw08uE=; b=uHvO0QvVwwQll2LhELS7PbeWxhm+LEcpWegTX9bB2+WWjBCxZUkzOcw8/dLC+jyPK3 65cBiFEHu3TlfiAheSJo7bXruy9SRNg4U/Tdmm+VSXubTo2zHF2cTljRgn+zKnM1AHS2 TUQ6LoL/8RTsAtqWaInNo+N4QyaW0R9VxQbpRA6+EOSHNZnEbbeT64kB22OATfUkqvlb 7IKyX0V5AKdHnjGpypcRMEQtN5Tb8CEAk8sXPff7+RvO2xF3wzrw9GmXxlPrQZIfQxVM qYfeaip7rlNQy9HjLGSZ0IcXhoZgLILDyV4oHgaheJT6OswTyChvRrc+SSj3C2SGeqeB NZNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 128si3836355pfe.4.2019.02.03.08.44.36; Sun, 03 Feb 2019 08:44:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728560AbfBCPaz (ORCPT + 99 others); Sun, 3 Feb 2019 10:30:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33112 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728266AbfBCPax (ORCPT ); Sun, 3 Feb 2019 10:30:53 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA62213BF60; Sun, 3 Feb 2019 15:30:52 +0000 (UTC) Received: from krava.redhat.com (ovpn-204-46.brq.redhat.com [10.40.204.46]) by smtp.corp.redhat.com (Postfix) with ESMTP id E688F5C238; Sun, 3 Feb 2019 15:30:49 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Adrian Hunter , Andi Kleen , Stephane Eranian , Alexey Budankov Subject: [PATCH 10/14] perf data: Add perf_data__update_dir function Date: Sun, 3 Feb 2019 16:30:14 +0100 Message-Id: <20190203153018.9650-11-jolsa@kernel.org> In-Reply-To: <20190203153018.9650-1-jolsa@kernel.org> References: <20190203153018.9650-1-jolsa@kernel.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Sun, 03 Feb 2019 15:30:53 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Adding perf_data__update_dir function to update size for every file within the perf.data directory. Link: http://lkml.kernel.org/n/tip-3ii12l48u4tyvrzxo1797w7e@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/util/data.c | 20 ++++++++++++++++++++ tools/perf/util/data.h | 1 + 2 files changed, 21 insertions(+) diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 59c052454fac..fbe46dab8dbd 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -124,6 +124,26 @@ static int perf_data__open_dir(struct perf_data *data) return ret; } +int perf_data__update_dir(struct perf_data *data) +{ + int i; + + if (WARN_ON(!data->is_dir)) + return -EINVAL; + + for (i = 0; i < data->dir.nr; i++) { + struct perf_data_file *file = &data->dir.files[i]; + struct stat st; + + if (fstat(file->fd, &st)) + return -1; + + file->size = st.st_size; + } + + return 0; +} + static bool check_pipe(struct perf_data *data) { struct stat st; diff --git a/tools/perf/util/data.h b/tools/perf/util/data.h index a1edf7e03a71..bd7affb69dba 100644 --- a/tools/perf/util/data.h +++ b/tools/perf/util/data.h @@ -78,4 +78,5 @@ int perf_data__switch(struct perf_data *data, int perf_data__create_dir(struct perf_data *data, int nr); void perf_data__free_dir(struct perf_data *data); +int perf_data__update_dir(struct perf_data *data); #endif /* __PERF_DATA_H */ -- 2.17.2