Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6535551rwp; Tue, 18 Jul 2023 01:43:46 -0700 (PDT) X-Google-Smtp-Source: APBJJlEx4c7nSvMC7rtyYAGsGfAFKg/axuMI+UGQYtblN1LFzvLcXob6/7DO81gFo4jfjo12Gu4S X-Received: by 2002:a17:906:3f09:b0:992:33ba:2eb4 with SMTP id c9-20020a1709063f0900b0099233ba2eb4mr10444305ejj.71.1689669825938; Tue, 18 Jul 2023 01:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689669825; cv=none; d=google.com; s=arc-20160816; b=AELJ5TKhD61HsxZN6D6zqlWAslTYunNWCNKIt4A96Htbb9S1uxzXRIwP1Ib1vnsCE+ 9qLRvy7uLZCRGJwWqO590vP0zhweOZt7J1iRxI+fD8jMGTsk7Cc23Q+MdD5jlTog6//x WBkIgAe8o8hcakLc2pMhfa/1K2jRHmST05wkh/OPm9YsH+DzOIatN16hNyJGYJ4l4VOe e24A0FzT6US3jYrDtayAVqyP8ANUs7qJiWGjii0TPUKIshAz9lcTG/C2w0M1QK9NvBuP 9msAupTutUWtMoMC4l0Y5a+waqM2MVm+FX8OTojTbTq/43RIkcSaYiQydsF8PUNAppNN BxNw== 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=eXnDRjq3rZ7qAZq+UqMms/Y0vqQUc265PT2KDbm8KQw=; fh=OEbhYwsvz/Vl5zXj7VkZDqxql9esXBQMJNUrXc1THlA=; b=SyWhIkMii+QUxG1upLDFqJRR97CrstSphQA/KjcYlaUoDOFZLFl9klznrkPvtGqugf P33F/xa7rPP3TqVZ3e6lGs2vT9Equ6Ag9dNmImz7e3a+6rGF99yIDLhd2cABT+eDd4JK cEleESp7sIdhMmkkWZKu2cLlL/TuDGXnxjij27isotGl4qGB9UFvY3C4el/iUHH1pklg 0wVxGPsysZGxnEJreBQ2faVdRVnEDcdJEJiVHekVK6HGVIocVFX4Wh/kE2xWgZyODKOJ J1jVxjFMCMI+iKCM2/AN5OLQDFzOQ0VAkdOFX3vom1nAHtlPEStWHRKBat9G3pgUL1P8 s9UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=CYgAngJu; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lh17-20020a170906f8d100b00992cd72e0b1si865104ejb.667.2023.07.18.01.43.20; Tue, 18 Jul 2023 01:43:45 -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=CYgAngJu; 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 S231515AbjGRIcf (ORCPT + 99 others); Tue, 18 Jul 2023 04:32:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230487AbjGRIcc (ORCPT ); Tue, 18 Jul 2023 04:32:32 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 068E3E4F; Tue, 18 Jul 2023 01:32:14 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D353A1FDBD; Tue, 18 Jul 2023 08:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689669132; 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=eXnDRjq3rZ7qAZq+UqMms/Y0vqQUc265PT2KDbm8KQw=; b=CYgAngJubicG3ekIqAcCjNcLsdJ77sSkFXuowyNksZI3JcdtCG5NIhlC2aT4zgIkgMR2hG VXTS+XRKHz1d/oJZvixClBSkifH3XSU6SorvDR4JXs//9gwuUUEjyQNcqf8AKcei9dGiKn Td5BkfSlnJN8ell9QxxgKWPXBMjO+1Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689669132; 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=eXnDRjq3rZ7qAZq+UqMms/Y0vqQUc265PT2KDbm8KQw=; b=RsMobXwCvjADUzioLz5t3PXYLHB1kwTTNuEpWAF9wdF1fXZCQNaL1OXC9uEg75/F/Bs+9J MXee/YrI/cIY9MAQ== 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 64D4C2C142; Tue, 18 Jul 2023 08:32:12 +0000 (UTC) Date: Tue, 18 Jul 2023 10:32:11 +0200 From: Michal =?iso-8859-1?Q?Such=E1nek?= To: Lucas De Marchi 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 , 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: <20230718083211.GT9196@kitsune.suse.cz> References: <20230711153126.28876-1-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=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Hello, On Mon, Jul 17, 2023 at 05:12:59PM -0300, Lucas De Marchi wrote: > On Mon, Jul 17, 2023 at 12:39:53PM +0200, Michal Suchanek wrote: > > modprobe.d is now searched under ${prefix}/lib, add ${module_directory} to > > specify the directory where to search for kernel modules. > > I was failing to see the relation of modprobe.d with the module > directory. Maybe reword this slightly? > > Now that modprobe.d is searched under ${prefix}/lib, allow a complete > transition to files only under ${prefix} by adding a ${module_directory} > configuration. This specifies the directory where to search for kernel > modules and should match the location where the kernel/distro installs > them. > > > > > 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. > > > > Signed-off-by: Michal Suchanek > > --- > > v4: Make the whole path configurable > > --- > > Makefile.am | 3 +- > > configure.ac | 7 ++ > > libkmod/libkmod.c | 4 +- > > man/Makefile.am | 1 + > > man/depmod.d.xml | 6 +- > > man/depmod.xml | 4 +- > > man/modinfo.xml | 2 +- > > man/modprobe.xml | 2 +- > > man/modules.dep.xml | 6 +- > > testsuite/module-playground/Makefile | 2 +- > > testsuite/setup-rootfs.sh | 109 +++++++++++++++------------ > > testsuite/test-depmod.c | 16 ++-- > > testsuite/test-testsuite.c | 8 +- > > tools/depmod.c | 6 +- > > tools/kmod.c | 1 + > > tools/modinfo.c | 4 +- > > tools/modprobe.c | 4 +- > > tools/static-nodes.c | 6 +- > > 18 files changed, 107 insertions(+), 84 deletions(-) > > > > diff --git a/Makefile.am b/Makefile.am > > index 7aa5bfa5638d..981574558c93 100644 > > --- a/Makefile.am > > +++ b/Makefile.am > > @@ -20,6 +20,7 @@ AM_CPPFLAGS = \ > > -I$(top_srcdir) \ > > -DSYSCONFDIR=\""$(sysconfdir)"\" \ > > -DPREFIX=\""$(prefix)"\" \ > > + -DMODULE_DIRECTORY=\""$(module_directory)"\" \ > > ${zlib_CFLAGS} > > > > AM_CFLAGS = $(OUR_CFLAGS) > > @@ -220,7 +221,7 @@ EXTRA_DIST += testsuite/setup-rootfs.sh > > MODULE_PLAYGROUND = testsuite/module-playground > > ROOTFS = testsuite/rootfs > > ROOTFS_PRISTINE = $(top_srcdir)/testsuite/rootfs-pristine > > -CREATE_ROOTFS = $(AM_V_GEN) $(top_srcdir)/testsuite/setup-rootfs.sh $(ROOTFS_PRISTINE) $(ROOTFS) $(MODULE_PLAYGROUND) $(top_builddir)/config.h $(sysconfdir) > > +CREATE_ROOTFS = $(AM_V_GEN) MODULE_DIRECTORY=$(module_directory) $(top_srcdir)/testsuite/setup-rootfs.sh $(ROOTFS_PRISTINE) $(ROOTFS) $(MODULE_PLAYGROUND) $(top_builddir)/config.h $(sysconfdir) > > > > build-module-playground: > > $(AM_V_GEN)if test "$(top_srcdir)" != "$(top_builddir)"; then \ > > diff --git a/configure.ac b/configure.ac > > index 6064dee77ae6..a195c8e6b554 100644 > > --- a/configure.ac > > +++ b/configure.ac > > @@ -84,6 +84,12 @@ 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_ARG_WITH([zstd], > > AS_HELP_STRING([--with-zstd], [handle Zstandard-compressed modules @<:@default=disabled@:>@]), > > [], [with_zstd=no]) > > @@ -304,6 +310,7 @@ AC_MSG_RESULT([ > > $PACKAGE $VERSION > > ======= > > > > + module_directory: ${module_directory} > > prefix: ${prefix} > > sysconfdir: ${sysconfdir} > > libdir: ${libdir} > > diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c > > index f3139c1cef97..d2ed8748c833 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 = "/lib/modules"; > > +static const char *dirname_default_prefix = MODULE_DIRECTORY; > > > > static char *get_kernel_release(const char *dirname) > > { > > @@ -231,7 +231,7 @@ static char *get_kernel_release(const char *dirname) > > /** > > * kmod_new: > > * @dirname: what to consider as linux module's directory, if NULL > > - * defaults to /lib/modules/`uname -r`. If it's relative, > > + * defaults to ${module_prefix}/lib/modules/`uname -r`. If it's relative, > > * it's treated as relative to the current working directory. > > * Otherwise, give an absolute dirname. > > * @config_paths: ordered array of paths (directories or files) where > > diff --git a/man/Makefile.am b/man/Makefile.am > > index ad07c30bbd24..25c2cc6fdf13 100644 > > --- a/man/Makefile.am > > +++ b/man/Makefile.am > > @@ -22,6 +22,7 @@ CLEANFILES = $(dist_man_MANS) > > else \ > > sed -e '/@PREFIX@/d' $< ; \ > > fi | \ > > + sed -e 's|@MODULE_DIRECTORY@|$(module_directory)|g' | \ > > $(XSLT) \ > > -o $@ \ > > --nonet \ > > diff --git a/man/depmod.d.xml b/man/depmod.d.xml > > index 431ebca6654b..676977c69a4f 100644 > > --- a/man/depmod.d.xml > > +++ b/man/depmod.d.xml > > @@ -70,7 +70,7 @@ > > > > > > > > - This allows you to specify the order in which /lib/modules > > + This allows you to specify the order in which @MODULE_DIRECTORY@ > > (or other configured module location) subdirectories will > > be processed by depmod. Directories are > > listed in order, with the highest priority given to the > > @@ -101,7 +101,7 @@ > > depmod command. It is possible to > > specify one kernel or all kernels using the * wildcard. > > modulesubdirectory is the > > - name of the subdirectory under /lib/modules (or other > > + name of the subdirectory under @MODULE_DIRECTORY@ (or other > > module location) where the target module is installed. > > > > > > @@ -110,7 +110,7 @@ > > specifying the following command: "override kmod * extra". > > This will ensure that any matching module name installed > > under the extra subdirectory within > > - /lib/modules (or other module location) will take priority > > + @MODULE_DIRECTORY@ (or other module location) will take priority > > over any likenamed module already provided by the kernel. > > > > > > diff --git a/man/depmod.xml b/man/depmod.xml > > index 3b0097184fd7..fce2a4a67a89 100644 > > --- a/man/depmod.xml > > +++ b/man/depmod.xml > > @@ -80,7 +80,7 @@ > > > > depmod creates a list of module dependencies by > > reading each module under > > - /lib/modules/version and > > + @MODULE_DIRECTORY@/version and > > determining what symbols it exports and what symbols it needs. By > > default, this list is written to modules.dep, and a > > binary hashed version named modules.dep.bin, in the > > @@ -141,7 +141,7 @@ > > > > > > If your modules are not currently in the (normal) directory > > - /lib/modules/version, > > + @MODULE_DIRECTORY@/version, > > but in a staging area, you can specify a > > basedir which is prepended to the > > directory name. This basedir is > > diff --git a/man/modinfo.xml b/man/modinfo.xml > > index 9fe0324a2527..b6c4d6045829 100644 > > --- a/man/modinfo.xml > > +++ b/man/modinfo.xml > > @@ -54,7 +54,7 @@ > > modinfo extracts information from the Linux Kernel > > modules given on the command line. If the module name is not a filename, > > then the > > - /lib/modules/version > > + @MODULE_DIRECTORY@/version > > directory is searched, as is also done by > > modprobe8 > > when loading kernel modules. > > diff --git a/man/modprobe.xml b/man/modprobe.xml > > index 91f9e27997cd..4d1fd59c000b 100644 > > --- a/man/modprobe.xml > > +++ b/man/modprobe.xml > > @@ -78,7 +78,7 @@ > > is no difference between _ and - in module names (automatic > > underscore conversion is performed). > > modprobe looks in the module directory > > - /lib/modules/`uname -r` for all > > + @MODULE_DIRECTORY@/`uname -r` for all > > the modules and other files, except for the optional > > configuration files in the > > /etc/modprobe.d directory > > diff --git a/man/modules.dep.xml b/man/modules.dep.xml > > index ed633694ec9e..8ef6d8b3536e 100644 > > --- a/man/modules.dep.xml > > +++ b/man/modules.dep.xml > > @@ -34,8 +34,8 @@ > > > > > > > > - /lib/modules/modules.dep > > - /lib/modules/modules.dep.bin > > + @MODULE_DIRECTORY@/modules.dep > > + @MODULE_DIRECTORY@/modules.dep.bin > > > > > > DESCRIPTION > > @@ -43,7 +43,7 @@ > > modules.dep.bin is a binary file generated by > > depmod listing the dependencies for > > every module in the directories under > > - /lib/modules/version. > > + @MODULE_DIRECTORY@/version. > > It is used by kmod tools such as modprobe and > > libkmod. > > > > diff --git a/testsuite/module-playground/Makefile b/testsuite/module-playground/Makefile > > index e6045b0dd932..a7ab09bea2bf 100644 > > --- a/testsuite/module-playground/Makefile > > +++ b/testsuite/module-playground/Makefile > > @@ -47,7 +47,7 @@ endif > > > > else > > # normal makefile > > -KDIR ?= /lib/modules/`uname -r`/build > > +KDIR ?= $(module_prefix)/lib/modules/`uname -r`/build > > KVER ?= `uname -r` > > ifeq ($(FAKE_BUILD),) > > FAKE_BUILD=0 > > diff --git a/testsuite/setup-rootfs.sh b/testsuite/setup-rootfs.sh > > index 4440ddcd6b4d..a780f9381b3c 100755 > > --- a/testsuite/setup-rootfs.sh > > +++ b/testsuite/setup-rootfs.sh > > @@ -16,6 +16,19 @@ create_rootfs() { > > cp -r "$ROOTFS_PRISTINE" "$ROOTFS" > > find "$ROOTFS" -type d -exec chmod +w {} \; > > find "$ROOTFS" -type f -name .gitignore -exec rm -f {} \; > > + if [ "$MODULE_DIRECTORY" != "/lib/modules" ] ; then > > + sed -i -e "s|/lib/modules|$MODULE_DIRECTORY|g" $(find "$ROOTFS" -name \*.txt -o -name \*.conf -o -name \*.dep) > > + sed -i -e "s|$MODULE_DIRECTORY/external|/lib/modules/external|g" $(find "$ROOTFS" -name \*.txt -o -name \*.conf -o -name \*.dep) > > why this second sed? These are 'external' modules not part of a kernel, the absolute path is used in modules.dep and reported in outputs. Moving these breaks the tests, and is beside the point. Thanks Michal