Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37081557rwd; Tue, 11 Jul 2023 09:11:29 -0700 (PDT) X-Google-Smtp-Source: APBJJlEUlfgZ9qnna+h9cRHfLJ5AfZpKsBCHxP53puIceE2FB4VI7W35qMN6MAxrxUyrScvBNIz9 X-Received: by 2002:a2e:b174:0:b0:2b5:1b80:263a with SMTP id a20-20020a2eb174000000b002b51b80263amr14814796ljm.47.1689091888989; Tue, 11 Jul 2023 09:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689091888; cv=none; d=google.com; s=arc-20160816; b=zmy3pTGT0ZKBWp7VY3dlnHHfm9qLeqTkvReKpoRAl9G/YnLWEXU9IzCStSUvxFOhuV FauvKELCmbfSZSch3MmOP3TJ1znpDsEPAx37RH5FluA/X2uCMV/a7VfAxWE8BgAk8PN4 tDWqSOVA25aK4UYNRSDHv3xWcpiqRIg0jaP7uN4+/lEr2Yr6Bs3muihQlKdJpYJIew1j QfCx36Qch1siYZXyMrqt61tax1eVFiJn2QLRiZWIvRKDRTnfGRH6SvAbm6YGMi828QtA l1cpUSPK5dmHf/tDCE/AmCMdrN9tk2COkuMlz23Z7+nfn4WVWPCV7Y/vSMsELDdxkvLC 0vvA== 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:dkim-signature; bh=QS7lsHabvgwvSyWCrGwNi2pl8kOLnGWh2IemNmy9SDU=; fh=AVdnBkCzYGOB5oRrOKcaACuRLonL9A4Pn6PwCHl69B0=; b=HgJ8TZ/Jza3977N+CoGJvu9LrBkcSeqe0YFXtYP/KQqi1CAqbC4Tp7Cl2Y0nii70aN bI4upDCLxFrcTmBf5FLnzkj+Oc7rlyO3n2vhlxIcxw/DftYONJcnO+40Qr9YJ75xz+oZ J94nLhNs44sBE2QktYPQq72vUNDICRlf/5sYUdBUlEU1rUDIQO5a69S6BEkAk0QoaiVR iSHeVskp2TcyQuHC8ZbRwXXXX3tP/5gF5HfgNzk18C4xx+bnSembpkqzttWW+Q956rEF UluMSHIlBeVbdach4Z9KNSbhA4M8qvYKTNTufuET2mv6dfqYXsRVu1Xc/xbHM28oowhq KxQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Ir23vwDK; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s5-20020a170906454500b00992ca771e3asi2366953ejq.48.2023.07.11.09.10.59; Tue, 11 Jul 2023 09:11:28 -0700 (PDT) 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=@suse.de header.s=susede2_rsa header.b=Ir23vwDK; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229742AbjGKPc0 (ORCPT + 99 others); Tue, 11 Jul 2023 11:32:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbjGKPcV (ORCPT ); Tue, 11 Jul 2023 11:32:21 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 822B810DF; Tue, 11 Jul 2023 08:32:20 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 35E1422725; Tue, 11 Jul 2023 15:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689089539; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QS7lsHabvgwvSyWCrGwNi2pl8kOLnGWh2IemNmy9SDU=; b=Ir23vwDKN1Gx1jDNFzxUd3DSmnFpSOUUrYKhQiyJq781piHpC6X9j6Ycdv5Pp6YFecIImw iVZAsGkq7m0UT2PRRo6PiLNI7D2bKoaM62MT4clgqXuuXZ4htSIinGdwoTSuUNr4DPqRyM 2Qw5SY/SWndZs/WnOYu821HRBmUceco= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689089539; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QS7lsHabvgwvSyWCrGwNi2pl8kOLnGWh2IemNmy9SDU=; b=Hsb/aoIiTB7oAYf7vrFrHOx/r2Y3rM3KdpOWa8zh2qojeImXY+EjkwTvregkwqS7D4fpHT yn6+ev1+m+IFvoDg== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id E75B92C142; Tue, 11 Jul 2023 15:32:18 +0000 (UTC) From: Michal Suchanek To: linux-modules@vger.kernel.org Cc: Michal Suchanek , Takashi Iwai , Lucas De Marchi , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Jiri Slaby , Jan Engelhardt , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] kmod: Add config command to show compile time configuration as JSON Date: Tue, 11 Jul 2023 17:31:18 +0200 Message-ID: <20230711153126.28876-4-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711153126.28876-1-msuchanek@suse.de> References: <20230711153126.28876-1-msuchanek@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Show prefix (where configuration files are searched/to be installed) and module compressions supported. Signed-off-by: Michal Suchanek --- man/kmod.xml | 6 ++++++ tools/kmod.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/man/kmod.xml b/man/kmod.xml index 0706ad58c2cc..f992a500f836 100644 --- a/man/kmod.xml +++ b/man/kmod.xml @@ -71,6 +71,12 @@ Show the help message. + + config + + Show compile time options in JSON. + + list diff --git a/tools/kmod.c b/tools/kmod.c index 55689c075ab1..5a13716955c1 100644 --- a/tools/kmod.c +++ b/tools/kmod.c @@ -37,9 +37,11 @@ static const struct option options[] = { }; static const struct kmod_cmd kmod_cmd_help; +static const struct kmod_cmd kmod_cmd_config; static const struct kmod_cmd *kmod_cmds[] = { &kmod_cmd_help, + &kmod_cmd_config, &kmod_cmd_list, &kmod_cmd_static_nodes, @@ -95,6 +97,43 @@ static const struct kmod_cmd kmod_cmd_help = { .help = "Show help message", }; +static const char *compressions[] = { +#ifdef ENABLE_ZSTD + "zstd", +#endif +#ifdef ENABLE_XZ + "xz", +#endif +#ifdef ENABLE_ZLIB + "gz", +#endif + NULL +}; + +static int kmod_config(int argc, char *argv[]) +{ + unsigned i; + printf("{\"prefix\":\"" PREFIX "\"" + ",\"module_signature\":[" +#ifdef ENABLE_OPENSSL + "\"PKCS#7\"," +#endif + "\"legacy\"]" + ",\"module_compression\":["); + for(i = 0; compressions[i]; i++) { + printf("%s\"%s\"", i ? "," : "", compressions[i]); + } + printf("]}\n"); + + return EXIT_SUCCESS; +} + +static const struct kmod_cmd kmod_cmd_config = { + .name = "config", + .cmd = kmod_config, + .help = "Show compile time options in JSON", +}; + static int handle_kmod_commands(int argc, char *argv[]) { const char *cmd; -- 2.41.0