Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3766756pxb; Tue, 17 Nov 2020 03:03:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTYIvDIszHNaDHmaUrRCgXo0Os8hV0SlWW4rIwtzyuZUUtpSac5TXRhtM7KLz3gAyUfKDB X-Received: by 2002:a17:907:162a:: with SMTP id hb42mr977426ejc.251.1605611032413; Tue, 17 Nov 2020 03:03:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605611032; cv=none; d=google.com; s=arc-20160816; b=ZvrLyhd/E2y4I82m9w/Vh33o2ImOzxDYJQwcaGnBu3xB58R4DA2XFP7uVECbGS2ryN hHn9x9kJwjqUHoMGLjHVd/ba2VzisXs+q0siFyHSme5YEspafXph0NtDjOtXTUJEO5U8 jyqP2TngeVR5D/RaIMTUgAi2HTcj0hryl8bHsfBApzkW7Vttes4wh2YY75cjFbcao9Sy DfXsRQRUqZpSiWB9Ui8cEW73mdH4RprMJJ58k6PqLauBWV9PyWsXmQ9uGuYr7db/RWrl JEUAJgOLzNTtNzPxW9pxoo/rIJ6wY9o4MKdEtdFoCKM+jfMC9hNu1x8tOEYD6TelYjMR 0LCQ== 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=sEBhXo2ObCMCKP8doKIce4/+iF/F0QIdSmNK2XinJSgA/QlCBqQkE4/xXPB/ZItTiv w5G0z5HbWOxuZ+esGboTd5R94NtiPQ8AIQo7mBiLr6MhDES6LqzxQ7uZOswBMmMKbWJ0 tYPGa165MCXFXVhdZfnlprkcu404aj1yXffYTq7TU6m4YL51Hv+jazkgRnTgJRNBo1V/ e8mSr5MxWqjkyMu7mL4cqqikY/6P1zEzf+5UNghHSx0OXTc0rrbl0sRl9lYXkubwBaOQ urk24qMy2zlc4kQ03WChhGJ27hL9usG4/z3LqjogCJfvNVV5gRj328FSrF6NkB8smHfJ ptvg== 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 lx7si3228719ejb.619.2020.11.17.03.03.29; Tue, 17 Nov 2020 03:03:52 -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 S1728333AbgKQLBm convert rfc822-to-8bit (ORCPT + 99 others); Tue, 17 Nov 2020 06:01:42 -0500 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:56783 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727526AbgKQLBm (ORCPT ); Tue, 17 Nov 2020 06:01:42 -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-224-FMG3eFp6PmuR72ep-9Pd-Q-1; Tue, 17 Nov 2020 06:01:35 -0500 X-MC-Unique: FMG3eFp6PmuR72ep-9Pd-Q-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A9F97108E1A5; Tue, 17 Nov 2020 11:01:33 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFD7C5C1CF; Tue, 17 Nov 2020 11:01:30 +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: Tue, 17 Nov 2020 12:00:38 +0100 Message-Id: <20201117110053.1303113-10-jolsa@kernel.org> In-Reply-To: <20201117110053.1303113-1-jolsa@kernel.org> References: <20201117110053.1303113-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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