Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6646330rwp; Tue, 18 Jul 2023 03:55:21 -0700 (PDT) X-Google-Smtp-Source: APBJJlENLlYwiKzzrdznPTOL0vXPN7vBJumePOLbCryrAoqVYhwIsBW3y/H+I5zgzWYu3ALufIet X-Received: by 2002:a50:fc0b:0:b0:51d:961a:b27a with SMTP id i11-20020a50fc0b000000b0051d961ab27amr13314088edr.7.1689677720891; Tue, 18 Jul 2023 03:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689677720; cv=none; d=google.com; s=arc-20160816; b=zRgRI7rXTdh3HRcx3dokIYasS4/dVfcAGD80AxFt8gyTD16yAPXKgTGnzIQr/19cT3 SY6A7DbgFE8SdmpdkYULal1mFgp6edJsWNf0VMLIYvIPOJiwuV8J3PW+/IdOOnIdDbel L+61OjQrocm9G8BY8xxRU5Tu17UWKnspjaWAm3skiuYg/bIUx6de1VHjwi4guBJujrY3 D+Zx49Q1ahu28CSjU+OuWhCkzpzMCWaoLfBB3L0GWEnhWsXLNmeTH0OT2757BN+CXT9p KaxGwn5VFI5rQJDp3gVdeX9HXlFUuyn6YKrOZDh8d+ze3QoFlvftXXpkxy5WZ/kWNin1 z3OA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature; bh=mc7MYWCMdjDk82AAtNUDHoR9pgSZ/a28mairNor7U38=; fh=osrFv9NYlMUPZNYHLxGA+QcrTwVGCoeLQZcEEEWoxUM=; b=OZVd9w1M8tbyhnnAAZH54VB6212o2rlmabgpE4Lwo2PgUpbTDktb8Vx7g+J9QOZs5s yN7IpX4ecfb3SWJz4MIc7PoOp56FQ1vFEuGbcU7+tN4XjB5LbJuVPJYnAn2/9CHA+Ibc 71XvE5OwiIJdC0V67jojvPDYFfyGE2c9XJIpeA9A02anU4nr5Jdp+JIG2xVJvUD5XTkZ o79S0mLOUsEKBWv3v3ocGPRJAFCd7zw9h1t1xlIVo7H+ale18sxhIHN+5hrbBAe03aOq 5IZ3UOvyJyBObDUHXp0rJBoK7Xihloqgo+kVIQgNfsaUZNon233pLis/OHgc9wI4x9GH kPSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=c4ounMS2; 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 n4-20020a05640206c400b0051d8114ae0fsi1033647edy.530.2023.07.18.03.54.56; Tue, 18 Jul 2023 03:55:20 -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=c4ounMS2; 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 S231223AbjGRKaG (ORCPT + 99 others); Tue, 18 Jul 2023 06:30:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbjGRKaD (ORCPT ); Tue, 18 Jul 2023 06:30:03 -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 13F831A8; Tue, 18 Jul 2023 03:30:02 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id C64241FDBD; Tue, 18 Jul 2023 10:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689676200; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mc7MYWCMdjDk82AAtNUDHoR9pgSZ/a28mairNor7U38=; b=c4ounMS2WnnLyLMS4AYpwPWy9xDfyGDL6TPP69XVV4rE/L+jCDp6yzJWcv87HGEvauNYLP 2uTAVfxxIr5AlQI5UYVrMqamHJVh2jDQIro8tnQrRQkRaztokMh2eCrT+l9es+jVywjlGE tX+nEsQWHmQB33K5helobLrAT3+vjNA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689676200; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mc7MYWCMdjDk82AAtNUDHoR9pgSZ/a28mairNor7U38=; b=Ch8ztUIaKOf8m7xsAk2F9NJUimRMoOZOtDivQyFsh6l8riXlOqLgDTgCNTHtE2uV+TbSl7 6iOKIjpV7fwt+LCg== 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 4316F2C142; Tue, 18 Jul 2023 10:30:00 +0000 (UTC) Date: Tue, 18 Jul 2023 12:29:59 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Jan Engelhardt Cc: linux-modules@vger.kernel.org, Takashi Iwai , Lucas De Marchi , Michal =?iso-8859-1?Q?Koutn=FD?= , Jiri Slaby , Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH kmod v4 4/4] libkmod, depmod, modprobe: Make directory for kernel modules configurable Message-ID: <20230718102958.GW9196@kitsune.suse.cz> References: <20230711153126.28876-1-msuchanek@suse.de> <76o21q7n-8qo8-37p6-oqno-q08nqpos471@vanv.qr> <20230718084300.GU9196@kitsune.suse.cz> <81n281ns-s8on-rsrn-pp61-q28pn42ns531@vanv.qr> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <81n281ns-s8on-rsrn-pp61-q28pn42ns531@vanv.qr> 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 Tue, Jul 18, 2023 at 11:41:32AM +0200, Jan Engelhardt wrote: > > On Tuesday 2023-07-18 10:43, Michal Such?nek wrote: > >> >With this distributions that do not want to ship files in /lib can also > >> >move kernel modules to /usr while others can keep them in /lib. > >> > >> This patch breaks kernel builds/installation / bisecting [when the > >> system has a kmod ./configure'd --with-module-directory=/usr/lib/modules] > > > >It might be nice to provide backwads compatibility with earlier > >configurations. > > > >However, if it comes at the cost of making the implementation more > >complex and future maintenance more difficult it might not be such a > >great idea. So far I have not seen a proposal how to do it nicely. > > > > diff --git a/configure.ac b/configure.ac > index a195c8e..7fde927 100644 > --- a/configure.ac > +++ b/configure.ac > @@ -84,11 +84,7 @@ AC_ARG_WITH([rootlibdir], > [], [with_rootlibdir=$libdir]) > AC_SUBST([rootlibdir], [$with_rootlibdir]) > > -# Ideally this would be $prefix/lib/modules but default to /lib/modules for compatibility with earlier versions > -AC_ARG_WITH([module_directory], > - AS_HELP_STRING([--with-module-directory=DIR], [directory in which to look for kernel modules - typically '/lib/modules' or '${prefix}/lib/modules']), > - [], [with_module_directory=/lib/modules]) > -AC_SUBST([module_directory], [$with_module_directory]) > +AC_SUBST([module_directory], [/lib/modules]) > > AC_ARG_WITH([zstd], > AS_HELP_STRING([--with-zstd], [handle Zstandard-compressed modules @<:@default=disabled@:>@]), > diff --git a/libkmod/libkmod-internal.h b/libkmod/libkmod-internal.h > index 4a4af58..e2f9c95 100644 > --- a/libkmod/libkmod-internal.h > +++ b/libkmod/libkmod-internal.h > @@ -199,3 +199,5 @@ void kmod_module_signature_info_free(struct kmod_signature_info *sig_info) __att > > /* libkmod-builtin.c */ > ssize_t kmod_builtin_get_modinfo(struct kmod_ctx *ctx, const char *modname, char ***modinfo) __attribute__((nonnull(1, 2, 3))); > + > +extern const char *dirname_default_prefix; > diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c > index d2ed874..b426cde 100644 > --- a/libkmod/libkmod.c > +++ b/libkmod/libkmod.c > @@ -209,7 +209,7 @@ static int log_priority(const char *priority) > return 0; > } > > -static const char *dirname_default_prefix = MODULE_DIRECTORY; > +const char *dirname_default_prefix = MODULE_DIRECTORY; > > static char *get_kernel_release(const char *dirname) > { > diff --git a/tools/depmod.c b/tools/depmod.c > index 22bc1d8..929060f 100644 > --- a/tools/depmod.c > +++ b/tools/depmod.c > @@ -65,6 +65,7 @@ static const struct option cmdopts[] = { > { "quick", no_argument, 0, 'A' }, > { "basedir", required_argument, 0, 'b' }, > { "outdir", required_argument, 0, 'o' }, > + { "modulesdir", required_argument, 0, 'M' }, > { "config", required_argument, 0, 'C' }, > { "symvers", required_argument, 0, 'E' }, > { "filesyms", required_argument, 0, 'F' }, > @@ -2943,6 +2944,9 @@ static int do_depmod(int argc, char *argv[]) > free(out_root); > out_root = path_make_absolute_cwd(optarg); > break; > + case 'M': > + dirname_default_prefix = optarg; > + break; > case 'C': { > size_t bytes = sizeof(char *) * (n_config_paths + 2); > void *tmp = realloc(config_paths, bytes); That breaks kmod for the usrmerged distributions, though. It might be fine to provide an option to override the build-time default. Still the build-time default has to match where the modules are placed in the distribution for things to work correctly out of the box. Note: it will work either way at the times the module directory can be accessed through the lib -> usr/lib compatibility symlink. The default needs to be correct for the cases when the symlink is not provided. So you could do make DEPMOD='depmod -M /lib/modules' to build an old kernel but you could equally do make DEPMOD='/path/to/special/depmod' If you needed make DEPMOD='depmod -M /usr/lib/modules' to build an usrmerged kernel on usrmerged distribution then this whole exercise is pointless. kmod cannot find the usrmerged modules then. Thanks Michal