Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp687056pxu; Thu, 26 Nov 2020 09:04:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6toUFCgVgDFieLxWSoVIlDQTXRbhw8U3P2UgUPTt9WugjHgDGPiOhva9shtteSeFV0jAm X-Received: by 2002:a17:906:6897:: with SMTP id n23mr3773899ejr.458.1606410295673; Thu, 26 Nov 2020 09:04:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606410295; cv=none; d=google.com; s=arc-20160816; b=aU1fitjQVzs9oVqnWUSFa4LmjTjp9N1NvnEeAhOi/VoKkdUSwjfSl1AZNheJnZvgCH 3XcqTHKKlIIoUJi1uNAyMW46JAvk6czg8a1uPBYf7b1wkbposASFkaCUuO7PIWYn8eCt r7vgxkG+bicbZyXYhC2nH3+e2IGcDHQe3Vn/JEcbH4bzvPf2LbuuTIoOzWaHi3KhqBTH UtzVikSppCjoGDm/ytiGjtDKB30N6t1kUTpZDHx7ZE3OAad2b/XQF/hRnOMUhJhGgdH/ yr7dKvOKYyMmHJWsCrx6Amj1db7ZSP/AlSPBuvBmM3tnaPcz2A1lOgMTTYdlyzCWrWTX jkYQ== 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=twPB0KhqahDVPQdyEvgiEdcngDYs8zyf1Q8nyi8rTNQAjT6Y3g4U2W+4l+vA9sHnVH 03tusyH+Upqp4qfQZ1UIsXQEFEryBBS85gyxA8fPG0sBmDVeO28spfzLLe1ovU0AP6Jn sF7qUp7XWZ23n9qo/udHx7U1Y4ackaFW51dFgjhCdXthbB+ZAlH/ZmgD38FI0TEqnnrC ya7XuEsPPylPvWu9CJSuknaiANdiiKfF57ZbTX9xI0SB16TOSFhriejGtwdOW0+mtbLZ 8jGW33oyQSeaJPNfUy+WqFpCDod0Y2WrbKV4V7zrIQ+5+rSEXkzi8c2xa8tqoXmvmD6J yZuQ== 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 w10si3449662ejn.255.2020.11.26.09.04.19; Thu, 26 Nov 2020 09:04:55 -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 S2391569AbgKZRB1 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 26 Nov 2020 12:01:27 -0500 Received: from us-smtp-delivery-44.mimecast.com ([205.139.111.44]:25184 "EHLO us-smtp-delivery-44.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391546AbgKZRB0 (ORCPT ); Thu, 26 Nov 2020 12:01:26 -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-400-IgkUvxY2O5Cokf8xBUzdlw-1; Thu, 26 Nov 2020 12:01:19 -0500 X-MC-Unique: IgkUvxY2O5Cokf8xBUzdlw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42871192D7B1; Thu, 26 Nov 2020 17:01:15 +0000 (UTC) Received: from krava.redhat.com (unknown [10.40.192.133]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A39460BFA; Thu, 26 Nov 2020 17:01:12 +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: Thu, 26 Nov 2020 18:00:11 +0100 Message-Id: <20201126170026.2619053-11-jolsa@kernel.org> In-Reply-To: <20201126170026.2619053-1-jolsa@kernel.org> References: <20201126170026.2619053-1-jolsa@kernel.org> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 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