Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3535268pxb; Mon, 9 Nov 2020 13:57:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDyzbyXE1h6mvcMsfVo5C8WGYGDk6qIfcwhVXmN/YPyNg4nwH4vjP10gqQZOT5D2qewh4f X-Received: by 2002:a50:c058:: with SMTP id u24mr17812041edd.28.1604959033576; Mon, 09 Nov 2020 13:57:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604959033; cv=none; d=google.com; s=arc-20160816; b=AesObiuuyrem5sQ4oHOWmR+/ZgZhfw+12xGD1anSy7GdcEV3Y4pmhsFEMwC2eOUynn wBOMChswkwcZ1cn4xyExVVhKSyTtrdW4gtp7usi0qoE+DQN6anDiwN+2kiRAYbBv44UH cViEBf4/Mwhq+Cb633dtSVGsXDeqrDlSN1Ar57uaj3L4VxiM2QjvgENETjES4OJcnpHN vcYtfI/0kPBWWDTx5nRL+z+xZItm6Viukn8Sqzw6KI37J8agFwMZXulEwj+8YC+lDASI Sm7/jCQy7lUZFk6s/zEk80keqC7evYSIgercyOba7ESWY/tCzqbWM+AF91sJoH7IAaFF +o0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=CAYket7AaDUNokgqMyYIArYxJaNzmnHdEu+xaM/ft0Y=; b=GTkfTFwbAtnjl1F5LR+p1u0Rv9phKakWkzfPFTLmPf+skIJt0eUg3xTrkvuVMpNpN9 xVLCAlRTi+XC9Ncp/5T7sSY+OM6Zo/zrV2D+ctUJ5CZa/xycrNQCNdNwU9fJYdlQzM6a sQe7n+wiJ1jNXf82TYWoJtP25vK3GJFQf/a6ybkkxioAktVuRVGnVeBrPug+4lm6ZrH4 W5WnqvLsK4+gxPTpYO6sRzx/Rh/5HUBo5Qui47aVlW7g6A7JeLbOKXjUV5uOh6nf2D6C ORNW/ElXYAEq5JDk+RwvK2pYlPGq0SWtdNVxEL6Dsc3cdVkJqjQdl/nXvyRgeCCXw9yb XHQQ== ARC-Authentication-Results: i=1; mx.google.com; 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 gf11si2476926ejb.494.2020.11.09.13.56.51; Mon, 09 Nov 2020 13:57:13 -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; 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 S1731433AbgKIVzE convert rfc822-to-8bit (ORCPT + 99 others); Mon, 9 Nov 2020 16:55:04 -0500 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:59973 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731378AbgKIVzC (ORCPT ); Mon, 9 Nov 2020 16:55:02 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-332-lRZeVI7TO1yXqibKYF5EYw-1; Mon, 09 Nov 2020 16:54:57 -0500 X-MC-Unique: lRZeVI7TO1yXqibKYF5EYw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6942D5F9C0; Mon, 9 Nov 2020 21:54:55 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C6766EF46; Mon, 9 Nov 2020 21:54:52 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Song Liu , Ian Rogers , Stephane Eranian , Alexey Budankov , Andi Kleen , Adrian Hunter Subject: [PATCH 09/24] perf tools: Add check for existing link in buildid dir Date: Mon, 9 Nov 2020 22:54:00 +0100 Message-Id: <20201109215415.400153-10-jolsa@kernel.org> In-Reply-To: <20201109215415.400153-1-jolsa@kernel.org> References: <20201109215415.400153-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jolsa@kernel.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: kernel.org Content-Transfer-Encoding: 8BIT Content-Type: text/plain; charset=WINDOWS-1252 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When adding new build id link we fail if the link is already there. Adding check for existing link and output debug message that the build id is already linked. Signed-off-by: Jiri Olsa --- tools/perf/util/build-id.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 7d9ecc37849c..ef9a31b54ba2 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -754,8 +754,21 @@ int build_id_cache__add_s(const char *sbuild_id, const char *name, tmp = dir_name + strlen(buildid_dir) - 5; memcpy(tmp, "../..", 5); - if (symlink(tmp, linkname) == 0) + if (symlink(tmp, linkname) == 0) { err = 0; + } else if (errno == EEXIST) { + char path[PATH_MAX]; + + if (readlink(linkname, path, sizeof(path)) == -1) { + pr_err("Cant read link: %s\n", linkname); + goto out_free; + } + if (strcmp(tmp, path)) { + pr_debug("build <%s> already linked to %s\n", + sbuild_id, linkname); + } + err = 0; + } /* Update SDT cache : error is just warned */ if (realname && -- 2.26.2