Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1224094pxu; Mon, 23 Nov 2020 15:10:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUgBdDw0kmzSakGrLt1k90o5ZI4CyharFkGNeRa+O0TicwpF+5DrYbwAkehiQg17J494Nx X-Received: by 2002:a05:6402:b45:: with SMTP id bx5mr1381872edb.193.1606173037368; Mon, 23 Nov 2020 15:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606173037; cv=none; d=google.com; s=arc-20160816; b=JssfPHei2ZQwrTgWPJISYxO/8rG3LUIsEPtRUcKeOdU5tBxHxy5gFMVbCaaQYOjA22 QEXIwg9Drc0vytrRSIeS+e6szc11r0O+Hhkx0qCrfZdD4C7DYfRd1bnVYItOvZtCm7eU GgTXehas10oMGu6tZ2EteAabaGo097mjPn5gUC8A1hnvG55a0YX0a0MpRfzllxuR9u1z gA3Qo/6gKrRQVE+f+CEyn4+rLM0sPOOXng4cO1AIdyvmERjja+IwqEMcfowqVKZ7cWFQ Br7SigN/YTwKhvQpxYAynFWKARdRYrmPGOqLYt9uT5qNn1CJKgM/dTnOCTVPI38s5hW8 DqPQ== 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=kIq2n8MiHBMAauiqcRjqNSQim6nIWXCxI5QNxzh/7m4=; b=Z0hFwyYzTS8AY8xxgGGfQTPBrw22fQsMZqDjobqHeQRCLNS8u18cVskwEGsFh5LlgB W0BjHurpI3UAcchhx3Ic439ZMtljoYWvZYrb8gyIZTmIwkb+/u/PpKuwF0jynl3FJYLN doISGCAYJMo2MQHH6NnUcj+JfzX8qGh3Lu3X8KqwQsuAFwWpD+8HtkGeMFZYIH7bWjTd zNLmHe8uYHb6105Ioy33dX0BTm0qUw0Gib6aWo7Y4srCFMzrW0Qs62/ovA6Kf3UIjhJq Eh1hgL/Gj59kzsrbcChiknniIJoV0CVDOmOtTtOympbMbqll5cEg5EOoY4WI25/Hcl3W m86A== 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 e21si7502669ejx.94.2020.11.23.15.10.12; Mon, 23 Nov 2020 15:10:37 -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 S2387924AbgKWXGI convert rfc822-to-8bit (ORCPT + 99 others); Mon, 23 Nov 2020 18:06:08 -0500 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:25059 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387710AbgKWXGH (ORCPT ); Mon, 23 Nov 2020 18:06:07 -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-138-lNVJRUwEN-aj9WnsYi8PyQ-1; Mon, 23 Nov 2020 18:06:00 -0500 X-MC-Unique: lNVJRUwEN-aj9WnsYi8PyQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CF89A100A26D; Mon, 23 Nov 2020 23:05:57 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.195.242]) by smtp.corp.redhat.com (Postfix) with ESMTP id BCEA45D9CA; Mon, 23 Nov 2020 23:05:54 +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 10/25] perf tools: Add check for existing link in buildid dir Date: Tue, 24 Nov 2020 00:04:57 +0100 Message-Id: <20201123230512.2097312-11-jolsa@kernel.org> In-Reply-To: <20201123230512.2097312-1-jolsa@kernel.org> References: <20201123230512.2097312-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c index 2aacc8b29f7e..4a391f13f40d 100644 --- a/tools/perf/util/build-id.c +++ b/tools/perf/util/build-id.c @@ -755,8 +755,25 @@ 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]; + ssize_t len; + + len = readlink(linkname, path, sizeof(path) - 1); + if (len <= 0) { + pr_err("Cant read link: %s\n", linkname); + goto out_free; + } + path[len] = '\0'; + + 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