From patchwork Tue Jul 11 15:31:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Michal_Such=C3=A1nek?= X-Patchwork-Id: 118615 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp573635vqm; Tue, 11 Jul 2023 08:46:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlE6TfdcmWSNoHBw7l4scx3cfqungYzUKyk77R1tu9mfdk6shTDBb+RgEaNpsxSMp5YcRzu4 X-Received: by 2002:a05:6358:2495:b0:135:4997:55f with SMTP id m21-20020a056358249500b001354997055fmr11342031rwc.4.1689090399463; Tue, 11 Jul 2023 08:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689090399; cv=none; d=google.com; s=arc-20160816; b=U+Aln4gKXhJZGm2asektlzzVlrO7gxYDLpHkw571Fn2K/ODZmUcdIlwsZQI+S4/L08 dTSZ9qyqDvL5RfbiGNXhFVzkRsC/imBppYIB0t+zO4b4rgTf5gSzi82ZwSfWzrjUIv4R 2fZmPxRnBCGUN2DVYDmf2Q6OBSr0LoI4HaDWgiGcsF9ehRvIBcLwyS1Zb45jJ/wFFtg2 RggE3ESoIIXYJoHGNqwK9iejXEhVGVZbJ6rJDKOhfWKt/OzkPrQa9pCabW7b+kfT6s31 XJBElPyumxxeI27pyaiCwVmeWQcXb2du87QvUcJK8nLGkt1rVG+meWQwweYATlCieTIR Kk5A== 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 header.b="Hsb/aoIi"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s24-20020a656918000000b005429411d104si1579489pgq.897.2023.07.11.08.46.26; Tue, 11 Jul 2023 08:46:39 -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 header.b="Hsb/aoIi"; 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 S231516AbjGKPc0 (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_Koutn=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 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771139654913964627 X-GMAIL-MSGID: 1771139654913964627 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;