From patchwork Wed Jul 12 14:00:47 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: 119205 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1174299vqm; Wed, 12 Jul 2023 07:06:02 -0700 (PDT) X-Google-Smtp-Source: APBJJlF64DcKRPO8wDL4MTtw4b6cpTQfnx40IGiZgTQbY+JNqTJzZyjg+fB9MOoknWIuc5ZFOf75 X-Received: by 2002:a05:6358:5e0c:b0:133:84c:a085 with SMTP id q12-20020a0563585e0c00b00133084ca085mr18209588rwn.1.1689170762092; Wed, 12 Jul 2023 07:06:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689170762; cv=none; d=google.com; s=arc-20160816; b=NHmBPYvOFnkQIMpKIx4eem3/aZBVvhJy/DBDY81iT1vidWdzabfnvI9LLzv3ha5Mby qu/SZd90wUQJ60VS2eXJDOG8Oecg2Df4r7hv3soDJ2SNZWIGhITgcvwJ9H0n4tqCKjEF 6u8E6owEMrewS0zJkEpYvRtaCDLh3K4TfeGwcP5AESEidRVpgUmgz69zFm2ic8U8Dgza qhmodTXy4XIxvv2XScPR+mrRKtRc2x9HTJ5CvLkOcm5biXxjTEGSw+rD64xyFd8++6RP tcDEbeN96iPfK/J4r2kmswPtUvioHH4brHZnDl1/g+3F3cMieZSOcb23q1myjvWu0pmu vC0Q== 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=hbkrw+Y8Z1P5bMkowr2XXMkWBVqN2gEHuamxYK92xU4=; fh=AVdnBkCzYGOB5oRrOKcaACuRLonL9A4Pn6PwCHl69B0=; b=P3ceuee9RVsfaxzGOfeGGT1nkdW4YU8tddE9fv70ocxB7oLnoMUeqyltn+sKe1VtUy zI0Ao12QYNOg7iM1e9583aMukNw0oBa5l93GyR3+ZD7t+HhfCyAC8JJgAZ2lF5CLNUW7 G/a1N4ko4/Yu/vM/FqgSq12FmEK9kNvEQDszBc4N6t7wRnvvzpttJv6kWfXIjtD0NtFn sdD6n4wXB9X5aO+xsSjf7KJr+w+Sudzm/nXjJkLXFNXe1eBRNYXrlRN1heOn9BvnoaxA egRAsKIowpOgSz9K/IyadOhAVCEvNay5T+X7ijdR4blZfe7D08cB2/+8f1zv6f9HdxWe pfUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OscZ7he4; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 s2-20020a637702000000b005576ebe803bsi3224524pgc.319.2023.07.12.07.05.48; Wed, 12 Jul 2023 07:06:02 -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=OscZ7he4; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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 S233446AbjGLOBo (ORCPT + 99 others); Wed, 12 Jul 2023 10:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232856AbjGLOB2 (ORCPT ); Wed, 12 Jul 2023 10:01:28 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D0161BF5; Wed, 12 Jul 2023 07:01:13 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 5C39A1FE45; Wed, 12 Jul 2023 14:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689170472; 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=hbkrw+Y8Z1P5bMkowr2XXMkWBVqN2gEHuamxYK92xU4=; b=OscZ7he4/KK8vOpchq5n2waFvvi7aHK+q3JHNzvx/lBWoHe2ff3kXS3tToV272jJabsGy3 BIq6f0lL8qcnjRRzwO9ECwyRd9qNb/rD75HS1zbtwioYjvIyrTdVZFLgvSubRLWn9aMy11 FMaCnP4IPFoyYpI8kq4icpgpflAazkU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689170472; 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=hbkrw+Y8Z1P5bMkowr2XXMkWBVqN2gEHuamxYK92xU4=; b=JS3RRZ7OvztD1547G6OgoaSS9XJaCLOVyheGF8lYu81q67D9C0JSmAgqkvLULh9XHqUKrb OneKDXCbL6uM8iBQ== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 0A0982C145; Wed, 12 Jul 2023 14:01:12 +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 kmod v2 3/4] kmod: Add config command to show compile time configuration as JSON Date: Wed, 12 Jul 2023 16:00:47 +0200 Message-ID: <20230712140103.5468-3-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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, 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: 1771223920823606220 Show prefix (where configuration files are searched/to be installed), module compressions, and module signatures supported. Signed-off-by: Michal Suchanek --- v2: mention module signature in commit message --- 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;