From patchwork Tue Feb 28 09:32:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 62373 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2916116wrd; Tue, 28 Feb 2023 01:44:43 -0800 (PST) X-Google-Smtp-Source: AK7set8kP+7vo8ZZodX4GNKO6n1WsW4UjOJ/+aQPkSYeA8y2pry8Mog6sIxXuWKZOe2vsQfWqys6 X-Received: by 2002:a05:6a20:7d86:b0:cd:832c:f9c6 with SMTP id v6-20020a056a207d8600b000cd832cf9c6mr3551346pzj.1.1677577483018; Tue, 28 Feb 2023 01:44:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677577483; cv=none; d=google.com; s=arc-20160816; b=jafdCZG+ylO+egRZhr5sfiySz8G+yStOaWalBjnm3optsJJPztx/OjgdjGZGRX0+eb dQneXpRNkbXlKntJ97ylcQkEGmQSxjvE0hLWsSMIFoawKzzI4TeyiT2xdWCqLXN+RUdX 3P3mPfKA4Nd7E8oWdgENoxboO69bJn8HWodVYlbVEW3eKBPiK4ObWyvf8c4f+KCR7xPu QPU5vYDjRuTeEgAWNNYsnwXcbN348NwTflsPyAghz4UHfnOm99z/HIznOKGXPd6coGbl 9Sn6UVfuxN2v8aLsDa5ATOu4QNRnHh/dvejkaU4nikOSvLjYvZ4PoCKJybWMm0gcG712 kUDg== 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 :dkim-signature; bh=21ZcV3iop64YVxmHDxSZ9xcbaXWaQmOe/vXsohNTMmc=; b=yYvipEmkR9soAe8tgyq+ZxKaBlczdIG9rkWcrGqdCEIYVAl0rCOhVxPtzqAnIBxldZ xP3wRYK88itoRut+9zvo/1NlJek2ftiwZSWVtOF1qCamgwBWcmWJzVqfsfSdsWfuz3Dz 95ytmOTbwVIxG8zeLSTvpn5/jrRSwpbHvyCTdQOX7X5/30jknX7LrK5AHXpi49xfRin9 ZvRHViv1FOkBlYrlz13HQ1ur7HTNCMvo8fOxIdFstbSu1fsVT2msvOSAj+ddKLNxzXBs HBQyUMF/YwEVZJRuAVoCTwWj3XN1Aay+so1BPPaClPIKLTanry247TPPLLN6oOOKNoLL MsiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m6kPxmfU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 64-20020a630043000000b004f2200cade5si9508105pga.359.2023.02.28.01.44.30; Tue, 28 Feb 2023 01:44:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=m6kPxmfU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229549AbjB1JdT (ORCPT + 99 others); Tue, 28 Feb 2023 04:33:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231355AbjB1JdP (ORCPT ); Tue, 28 Feb 2023 04:33:15 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA6AA1FF6; Tue, 28 Feb 2023 01:33:07 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 725F2B80E12; Tue, 28 Feb 2023 09:33:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB3D7C433EF; Tue, 28 Feb 2023 09:32:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1677576785; bh=QJB3wPU2HWgjAFGuMz7NkbXXZcNkRHN6drkDJ+SyIYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m6kPxmfUjqBPyP1zjk/AUvq0/knP93c2G+bJV20AAk00Bn5Qy1ceLoPdeWzhhd66V C9PoDgaO8rIzmIHx+zhN6nkA+kRPYAwGKfC1VDZEgYNjMAhQbGB0eypPdGJFHD2N2y vaePjn5SoDDn0dEkIf75C8Pfa7RvzbalnvALHj9mvgHJy8WdgTPhm9JEmabCzuuo/k fDGJm19tk2+IfAuCsGapu6TbdLHo4eP/EqBsqwW6qqkL/Lc0+Fv/y1RTxYHDh8tlHE GkDspDLRDbIm19taZ2SguntVqk7d/0F/NViAB3I+CONr1oBs9FaKr8W63nBjkqhJNr LtdzQ20YTBC/w== From: Jiri Olsa To: Alexei Starovoitov , Andrii Nakryiko , Hao Luo , Andrew Morton , Alexander Viro , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Matthew Wilcox Cc: bpf@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-perf-users@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Daniel Borkmann , Namhyung Kim Subject: [PATCH RFC v2 bpf-next 4/9] libbpf: Allow to resolve binary path in current directory Date: Tue, 28 Feb 2023 10:32:01 +0100 Message-Id: <20230228093206.821563-5-jolsa@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230228093206.821563-1-jolsa@kernel.org> References: <20230228093206.821563-1-jolsa@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759067486846765363?= X-GMAIL-MSGID: =?utf-8?q?1759067486846765363?= Try to resolve uprobe/usdt binary path also in current directory, it's used in the test code in following changes. Signed-off-by: Jiri Olsa --- tools/lib/bpf/libbpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 05c4db355f28..f72115e8b7f9 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -10727,17 +10727,19 @@ static const char *arch_specific_lib_paths(void) /* Get full path to program/shared library. */ static int resolve_full_path(const char *file, char *result, size_t result_sz) { - const char *search_paths[3] = {}; + const char *search_paths[4] = {}; int i, perm; if (str_has_sfx(file, ".so") || strstr(file, ".so.")) { search_paths[0] = getenv("LD_LIBRARY_PATH"); search_paths[1] = "/usr/lib64:/usr/lib"; search_paths[2] = arch_specific_lib_paths(); + search_paths[3] = "."; perm = R_OK; } else { search_paths[0] = getenv("PATH"); search_paths[1] = "/usr/bin:/usr/sbin"; + search_paths[2] = "."; perm = R_OK | X_OK; }