From patchwork Mon Jul 17 10:39:52 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: 121203 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1036109vqt; Mon, 17 Jul 2023 04:04:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlGwek8OEZ/CsS3JfsDLwl+/fFMcwk+T5OCYNvuHzU9kUw1Dzs0FXKE9Bx4NSjUPtQWUejsM X-Received: by 2002:aa7:d88a:0:b0:51d:914a:9f43 with SMTP id u10-20020aa7d88a000000b0051d914a9f43mr10514166edq.36.1689591863545; Mon, 17 Jul 2023 04:04:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689591863; cv=none; d=google.com; s=arc-20160816; b=m3UvEkH0gCfkXbOMDvmMTCd4BHBeqkBheX7ztTotXVRZjDMHHVIKh8aO/BTDLq/E0V Oce0/cqEJyZ6AA7oHmbj2Tm+UFt2jbZn+4rFbqYWfvBMJWcGcPK7CTXrrluemvTuVDvQ c2FSifo4p14CYnYbV1L0C8sY6zq8Djx66HmeBQkXBQ3HcQpP3h3IQAEuB9MEfgqpBWlo XCp2Yg1WkZDNhMz3LBFcfnO72Pp+oEf/1QY7dJpbR7+Pb540Hv+JXvnLLqYqeeTSBu+y 6V05mPOBV5jQ290zwjL4JuHUslh/bSFPzPeRxycisbqJ6ZgK1i/Zs7u1GY/UDadL1heS vHbg== 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=hVsH0ru6iCq/4+npZ6IZoOzlEjBX5Fl88+GmHlp+UOY=; fh=AVdnBkCzYGOB5oRrOKcaACuRLonL9A4Pn6PwCHl69B0=; b=kJYx+esT7+cKM2eh7X9pd1Ss/7K1kfO9bf+yMw8jmA9OtE78pRngAuzPoKkSwC/xJE cEb6t0WdDp2F8FldczEiZ5kon18Xch4zDC57gPlFjkt5R642+mmk20C81DkyhGuX6Xn3 EcekVm5sTV499nfTzV1L30ZT/wOrffWenzR5KHp7D1sKhCYhTrUReoLHVxzuLsuddIbU tBb7jfBQPysoxdMW3uLrtqiPTH8PFv6dnvnnALzSP8oGOp5FWKD22WlrTNy4vkxdCvVB ED8gd/lU7DT/CoRo6lNAPN5e1FW0uEAKdLinDMS6HB3rtFKAS8buQNADBOtgHpoCxbLA TBCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=GvuChp5d; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=YBjEXmPx; 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 v26-20020a056402185a00b0051e33b22db7si13417185edy.497.2023.07.17.04.03.59; Mon, 17 Jul 2023 04:04:23 -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=GvuChp5d; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=YBjEXmPx; 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 S230274AbjGQKkS (ORCPT + 99 others); Mon, 17 Jul 2023 06:40:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230014AbjGQKkH (ORCPT ); Mon, 17 Jul 2023 06:40:07 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FF32C0; Mon, 17 Jul 2023 03:40:05 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 8819221958; Mon, 17 Jul 2023 10:40:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689590404; 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=hVsH0ru6iCq/4+npZ6IZoOzlEjBX5Fl88+GmHlp+UOY=; b=GvuChp5d5XY58JX7F9pYSRZqnwHghZNqZaQ1ZAeF8tGVxQwvwOHOu8xM1OMWDUpTlpbpCG c/O1nagNibhnQqO33IgbX/iiIScNqAj6e2nAe0gCQ+P7GkFGUeURBcLciLNZEXjH+ObQKs C7A7Om3VwtQvDbfQ2akmZAVxSuWHFiA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689590404; 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=hVsH0ru6iCq/4+npZ6IZoOzlEjBX5Fl88+GmHlp+UOY=; b=YBjEXmPxNuZj/Nk5drOQURoKWwf6It1X81oQzXQJISZVIBYFe8T+0GZyoY0tlseEa9GTqx Y/RiKiPPPpRS5BCw== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 2545B2C146; Mon, 17 Jul 2023 10:40:04 +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 v4 3/4] kmod: Add config command to show compile time configuration as JSON Date: Mon, 17 Jul 2023 12:39:52 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: 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 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: 1771665477709426520 Show prefix (where system configuration files are searched/to be installed), sysconfdir (where user configuration files are searched), module compressions, and module signatures supported. Signed-off-by: Michal Suchanek --- v2: mention module signature in commit message v3: add sysconfdir --- man/kmod.xml | 6 ++++++ tools/kmod.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 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..a684c1d24284 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,44 @@ 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 "\"" + ",\"sysconfdir\":\"" SYSCONFDIR "\"" + ",\"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;