Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp38387903rwd; Wed, 12 Jul 2023 07:06:01 -0700 (PDT) X-Google-Smtp-Source: APBJJlGmo9mkgZcS6RVaCai6q9bgD1xeirKaUkrg27dM/qq8eq5OnH+55WULnCWtk7nX/AGHHm/0 X-Received: by 2002:a17:90b:400a:b0:263:f5a5:fb98 with SMTP id ie10-20020a17090b400a00b00263f5a5fb98mr15410572pjb.28.1689170760873; Wed, 12 Jul 2023 07:06:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689170760; cv=none; d=google.com; s=arc-20160816; b=iVFARdiJKEcOwKVpF6xh1qzIwerTG2ke/30AWsBkIBtkTnc6Nq8Ql1p6MXVvDgYjy/ kCWmkzNgrU8YMmvpyeRdEkyLB+qIGu9fWPppCLPhCAJqCcAvgXq+pSc4hTuaJysiEfaS 2pFLWwho0cSReOGgNtHqElLbKKWiIWKpdcOOYZbNogB4Anau6HRWIWJv7XGs7Gqt9/gq +VDZghjv+d8ekmyklFABAKHC//rfaA4Mfnr3lNcddJl0KMlNOnfzVJ1DXdRZcihl6Isp hzaM8oIGBGWQkaK8lhGSGWl1TbQWXhRrIlr4MH3syI/xB+bX2w0sGzgEIZJqmqTLf5Dj XRPQ== 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; 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 rj3-20020a17090b3e8300b00262ee7c6cafsi3554701pjb.87.2023.07.12.07.05.48; Wed, 12 Jul 2023 07:06:00 -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; 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 S233236AbjGLOBl (ORCPT + 99 others); Wed, 12 Jul 2023 10:01:41 -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=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 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 Content-Transfer-Encoding: 8bit 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 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; -- 2.41.0