Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2714056rwp; Fri, 14 Jul 2023 10:07:50 -0700 (PDT) X-Google-Smtp-Source: APBJJlGi+NxEHfDq14iyq53fvO9vYt9WXHm/ryWI4rgCVcIEpJVEkgsCed6hektfyRWJSMmXTpnw X-Received: by 2002:a17:906:71cf:b0:97e:aace:b6bc with SMTP id i15-20020a17090671cf00b0097eaaceb6bcmr4240485ejk.53.1689354470531; Fri, 14 Jul 2023 10:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689354470; cv=none; d=google.com; s=arc-20160816; b=GF1VOr/a94H8PqMQyuQ/G6hYcxwR/C/10cDWVfpEJ0x068xzXS3PywB22TkUAJOidC +XQnE1FkjgNsK4qm+jysxNzB6XSu99U2GinYW5bp0MQ1pVxMGhwUxYqOVmMoaoaLQ07N rlCpzHN1LKvkAAh2H4c+2UdQ0hDkcA64NFOAZ7lJt1YSoJN0sQg6xt9s87aMuvekDF0R lvhVv4n0WiRbSNzvyEVY38D+3WlsAaRGU4bVtWwN5GlAIlcZWxLegyyJntx0lvkvkTbY KRhRQKKRcVw4p4gSuXSZzrVQ+NHrPabSR7q/+h/pnWoso+vXYC2hnVPkKl3bPJsji6fb sd2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=3GpL3SAU4UYjxuI87qVTDXsPz5t7JNfto7bmoN8MBNc=; fh=HDztna6PbmjtuJh8EtYkhtVXFnuILxPdrwf1Wy9pp6k=; b=kSlt/Nh+pj0b/G4uJKZDSnyS2llu9sDU0k12Dam0FLSw8gWiPhLDMpmW9sw42OSgAI Gp2LMu/SFVIAGOVJghDcmoaQ5MamWM8b79zNK8AtoKR33sLZy4x7sc3Ou9GSu3BB73F/ Wql7oJcjWPrNnOwEtMl2pnaGmWLFGk5IdhiNoW8YIjSajgTkV37n6tkcaxEz+fjIrUhZ vzMJaYffg8325Ad6qXSPlEzfO809pNtWoHUV72knoi3klruv/xfDjbqphhtHfkI92icP BLR1hr3fVNsHxiI7fHTUxYITCvl5Hdbd4VS3mpTxp0WPZaspr1eN5Ijl3zKtFjsJ5C5d DCHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=P94IF4rv; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=pHz0RJu4; 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 a6-20020a1709062b0600b0098885a739f2si1095204ejg.657.2023.07.14.10.07.14; Fri, 14 Jul 2023 10:07:50 -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=P94IF4rv; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=pHz0RJu4; 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 S235667AbjGNQ6F (ORCPT + 99 others); Fri, 14 Jul 2023 12:58:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229706AbjGNQ6E (ORCPT ); Fri, 14 Jul 2023 12:58:04 -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 1FCE8358E; Fri, 14 Jul 2023 09:58:03 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9EC031F750; Fri, 14 Jul 2023 16:58:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689353881; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3GpL3SAU4UYjxuI87qVTDXsPz5t7JNfto7bmoN8MBNc=; b=P94IF4rvbaGL6Y0u4KZ1FyLbRjYenZq9wdX/Bo35qp5GuZ6sSXskRyjJSrmYmJQwfaqUs+ sXQedZsnImNBOwJfLUqAzzKoOUdQ1keZ7FStY96P+A+Gmmi/WAAgmJrO1VwYlZ9dMmDKe/ M+5LxT0odIOqOgYb+Y+Ag6zSldSGMH4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689353881; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=3GpL3SAU4UYjxuI87qVTDXsPz5t7JNfto7bmoN8MBNc=; b=pHz0RJu4wxUdHnoFijoc/IefLA59NKobliL7o5TvzftLGlLdx6+5M0ytBWkubqUFRsRNF4 dKSx/mdTS4awYDCA== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 55D8A2C142; Fri, 14 Jul 2023 16:58:01 +0000 (UTC) Date: Fri, 14 Jul 2023 18:58:00 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Nicolas Schier Cc: linux-modules@vger.kernel.org, Takashi Iwai , Lucas De Marchi , Michal =?iso-8859-1?Q?Koutn=FD?= , Jiri Slaby , Jan Engelhardt , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH kmod v2 3/4] kmod: Add config command to show compile time configuration as JSON Message-ID: <20230714165800.GO9196@kitsune.suse.cz> References: <20230711153126.28876-1-msuchanek@suse.de> <20230712140103.5468-3-msuchanek@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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 On Fri, Jul 14, 2023 at 05:26:43PM +0200, Nicolas Schier wrote: > On Wed, Jul 12, 2023 at 04:00:47PM +0200 Michal Suchanek wrote: > > 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 > > If kmod could show selected configs without some (JSON) syntax > around, it could simplify its proposed use in kbuild. E.g.: > > kmod config prefix 2>/dev/null > > instead of > > kmod config &>/dev/null && kmod config | jq -r .prefix Which would no longer hold for whole module directory: kmod config &>/dev/null && kmod config | jq -r .module_directory || echo /lib/modules vs kmod config module_directory &>/dev/null && kmod config module_directory || echo /lib/modules Also JSON has standardized syntax for lists and users that can parse JSON directly can load the whole configuration at once without several calls to kmod config or pkg-config. Thanks Michal