From nobody Fri Sep 5 09:20:51 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40CC6EB64DA for ; Tue, 18 Jul 2023 12:03:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232230AbjGRMDh (ORCPT ); Tue, 18 Jul 2023 08:03:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231603AbjGRMD3 (ORCPT ); Tue, 18 Jul 2023 08:03:29 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93896E47; Tue, 18 Jul 2023 05:03:27 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 44A0B218EE; Tue, 18 Jul 2023 12:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689681806; 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=VG3nbQZ6NQlPAmYzpmo6KoCjwuY3FXsibXeDJl7sMQM=; b=lTrh5HE3QZv5mu8b5Ytjm53UsTjwxmdJXanRewoKmSbJN24dQqbuMqfhMYWeHgvbViNcDB M+//oXkd7rJY+dVTdqdEubM3GCCZtelXUNQ5W7cq6ZOj+qzcjqLYSHEfdyGboOvgEQ7K8b yemZJtS5cx+14bgzWi4Ud8xb2u8pnJE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689681806; 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=VG3nbQZ6NQlPAmYzpmo6KoCjwuY3FXsibXeDJl7sMQM=; b=svYsuHjD3AqEe3A9+vR3sCejz0Mq2M3b8oE9C3L0wq4+p2+G3cW+GVjFdGDgvTx7ZVJd8I m0EVY4KErmmORzDw== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id EECE32C143; Tue, 18 Jul 2023 12:03:25 +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 v5 1/5] configure: Detect openssl sm3 support Date: Tue, 18 Jul 2023 14:01:52 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Older openssl versions do not support sm3. The code has an option to disable the sm3 hash but the lack of openssl support is not detected automatically. Signed-off-by: Michal Suchanek --- configure.ac | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/configure.ac b/configure.ac index 6064dee77ae6..331cc8a1ffd5 100644 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,13 @@ AC_ARG_WITH([openssl], AS_IF([test "x$with_openssl" !=3D "xno"], [ PKG_CHECK_MODULES([libcrypto], [libcrypto >=3D 1.1.0], [LIBS=3D"$LIBS $li= bcrypto_LIBS"]) AC_DEFINE([ENABLE_OPENSSL], [1], [Enable openssl for modinfo.]) + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include + int nid =3D NID_sm3;]])], [ + AC_MSG_NOTICE([openssl supports sm3]) + ], [ + AC_MSG_NOTICE([openssl sm3 support not detected]) + CPPFLAGS=3D"$CPPFLAGS -DOPENSSL_NO_SM3" + ]) ], [ AC_MSG_NOTICE([openssl support not requested]) ]) --=20 2.41.0 From nobody Fri Sep 5 09:20:51 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 884DFEB64DC for ; Tue, 18 Jul 2023 12:03:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229887AbjGRMDj (ORCPT ); Tue, 18 Jul 2023 08:03:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231663AbjGRMD3 (ORCPT ); Tue, 18 Jul 2023 08:03:29 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0C5410F1; Tue, 18 Jul 2023 05:03:27 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 8D7E12192D; Tue, 18 Jul 2023 12:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689681806; 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=5MYNN4aTAxMD2vJ3pBJF0snRIYTMXy8161K7Aou3d2k=; b=RaOKGH9Yf2JjduOFlsgCSBaxWhkZKD1p7e4XwMvfX4DpQXDj0YdqMNNZl912zv+guii11H quc7aaoyRoi4zBVV4Wtpq7iqIaVXHJ2G7orN3nokq0HYZZjBpxeOq9gsLZhv3tnegJC1UY c1t642WEyT0QGCbQ9L9Pu34N0uia3pQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689681806; 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=5MYNN4aTAxMD2vJ3pBJF0snRIYTMXy8161K7Aou3d2k=; b=uSxwIX7B6QqkQxgiVI71tiKeC4IGjUIEMWDOLDp5V4h78xbuK+QeA/5NdZ4M4GTJS0WMlw Cp985pSvnHfdluAA== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 428222C145; Tue, 18 Jul 2023 12:03:26 +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 v5 2/5] man/depmod.d: Fix incorrect /usr/lib search path Date: Tue, 18 Jul 2023 14:01:53 +0200 Message-ID: <9c5a6356b1a111eb6e17ddb110494b7f1d1b44c0.1689681454.git.msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" depmod searches /lib/depmod.d but the man page says /usr/lib/depmod.d is searched. Align the documentation with the code. Signed-off-by: Michal Suchanek --- v2: Fix commit message typo --- man/depmod.d.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/depmod.d.xml b/man/depmod.d.xml index 76548e92a312..8d3d821cddc8 100644 --- a/man/depmod.d.xml +++ b/man/depmod.d.xml @@ -39,7 +39,7 @@ =20 - /usr/lib/depmod.d/*.conf + /lib/depmod.d/*.conf /usr/local/lib/depmod.d/*.conf /run/depmod.d/*.conf /etc/depmod.d/*.conf --=20 2.41.0 From nobody Fri Sep 5 09:20:51 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23529EB64DA for ; Tue, 18 Jul 2023 12:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230432AbjGRMDm (ORCPT ); Tue, 18 Jul 2023 08:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231949AbjGRMDa (ORCPT ); Tue, 18 Jul 2023 08:03:30 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 234061AC; Tue, 18 Jul 2023 05:03:28 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id CAF6721941; Tue, 18 Jul 2023 12:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689681806; 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=CvlHBvqzPVM+nrKUqZQDh23criIIq4TPNlulM1tUKbU=; b=uILsdidTecf92JYgECvLrQhnFdQY+6FmWuA1D/Gdx4V07v+kaeQvFC4us9MpJdrCjL2ePC 0viN1qkGD2EYl8K8FZihOaylqZyuNnv3LcgSItVl7omZnZC4jeiWp3ZawiiWDF5Pb2vHXW QiM67Yi3lvwxKzCNeFwyJaG4zOXFSl8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689681806; 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=CvlHBvqzPVM+nrKUqZQDh23criIIq4TPNlulM1tUKbU=; b=z/ARLjsbrKOj94fNaoMqeUwPJ/r6tWDKQvjSlelPBgTpGKHnQewT4jDPitwbE4HFxUsAhl i5yiKzWM/QaOwJDg== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 8BC872C146; Tue, 18 Jul 2023 12:03:26 +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 v5 3/5] libkmod, depmod: Load modprobe.d, depmod.d from ${prefix}/lib. Date: Tue, 18 Jul 2023 14:01:54 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is an ongoing effort to limit use of files outside of /usr (or ${prefix} on general). Currently all modprobe.d paths are hardcoded to outside of $prefix. Teach kmod to load modprobe.d from ${prefix}/lib. On some distributions /usr/lib and /lib are the same directory because of a compatibility symlink, and it is possible to craft configuration files with sideeffects that would behave differently when loaded twice. However, the override semantic ensures that one 'overrides' the other, and only one configuration file of the same name is loaded from any of the search directories. Signed-off-by: Michal Suchanek --- v2: Fix commit message typo v3: Fix modprobe.d path list in code comment v5: Add distconfdir --- Makefile.am | 1 + configure.ac | 5 +++++ libkmod/libkmod.c | 7 ++++--- man/Makefile.am | 9 +++++++-- man/depmod.d.xml | 1 + man/modprobe.d.xml | 1 + tools/depmod.c | 1 + 7 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8ba85c91a0f3..14eb07e63cea 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,6 +19,7 @@ AM_CPPFLAGS =3D \ -include $(top_builddir)/config.h \ -I$(top_srcdir) \ -DSYSCONFDIR=3D\""$(sysconfdir)"\" \ + -DDISTCONFDIR=3D\""$(distconfdir)"\" \ ${zlib_CFLAGS} =20 AM_CFLAGS =3D $(OUR_CFLAGS) diff --git a/configure.ac b/configure.ac index 331cc8a1ffd5..728f88a56704 100644 --- a/configure.ac +++ b/configure.ac @@ -79,6 +79,10 @@ AC_COMPILE_IFELSE( # --with- ##################################################################### =20 +AC_ARG_WITH([distconfdir], AS_HELP_STRING([--with-distconfdir=3DDIR], [dir= ectory to search for distribution configuration files]), + [], [with_distconfdir=3D'${prefix}/lib']) +AC_SUBST([distconfdir], [$with_distconfdir]) + AC_ARG_WITH([rootlibdir], AS_HELP_STRING([--with-rootlibdir=3DDIR], [rootfs directory to ins= tall shared libraries]), [], [with_rootlibdir=3D$libdir]) @@ -313,6 +317,7 @@ AC_MSG_RESULT([ =20 prefix: ${prefix} sysconfdir: ${sysconfdir} + distconfdir: ${distconfdir} libdir: ${libdir} rootlibdir: ${rootlibdir} includedir: ${includedir} diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index 2670f9a4611a..09e6041461b0 100644 --- a/libkmod/libkmod.c +++ b/libkmod/libkmod.c @@ -65,6 +65,7 @@ static const char *const default_config_paths[] =3D { SYSCONFDIR "/modprobe.d", "/run/modprobe.d", "/usr/local/lib/modprobe.d", + DISTCONFDIR "/modprobe.d", "/lib/modprobe.d", NULL }; @@ -237,9 +238,9 @@ static char *get_kernel_release(const char *dirname) * to load from user-defined configuration parameters such = as * alias, blacklists, commands (install, remove). If NULL * defaults to /etc/modprobe.d, /run/modprobe.d, - * /usr/local/lib/modprobe.d and /lib/modprobe.d. Give an e= mpty - * vector if configuration should not be read. This array m= ust - * be null terminated. + * /usr/local/lib/modprobe.d, DISTCONFDIR/modprobe.d, and + * /lib/modprobe.d. Give an empty vector if configuration s= hould + * not be read. This array must be null terminated. * * Create kmod library context. This reads the kmod configuration * and fills in the default values. diff --git a/man/Makefile.am b/man/Makefile.am index 11514d52a190..2fea8e46bf2f 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -17,9 +17,14 @@ EXTRA_DIST =3D $(MAN5:%.5=3D%.xml) $(MAN8:%.8=3D%.xml) CLEANFILES =3D $(dist_man_MANS) =20 %.5 %.8: %.xml - $(AM_V_XSLT)$(XSLT) \ + $(AM_V_XSLT)if [ '$(distconfdir)' !=3D '/lib' ] ; then \ + sed -e 's|@DISTCONFDIR@|$(distconfdir)|g' $< ; \ + else \ + sed -e '/@DISTCONFDIR@/d' $< ; \ + fi | \ + $(XSLT) \ -o $@ \ --nonet \ --stringparam man.output.quietly 1 \ --param funcsynopsis.style "'ansi'" \ - http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl = $< + http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl - diff --git a/man/depmod.d.xml b/man/depmod.d.xml index 8d3d821cddc8..f282a39cc840 100644 --- a/man/depmod.d.xml +++ b/man/depmod.d.xml @@ -40,6 +40,7 @@ =20 /lib/depmod.d/*.conf + @DISTCONFDIR@/depmod.d/*.conf /usr/local/lib/depmod.d/*.conf /run/depmod.d/*.conf /etc/depmod.d/*.conf diff --git a/man/modprobe.d.xml b/man/modprobe.d.xml index 0ab3e9110a7e..2bf6537f07e6 100644 --- a/man/modprobe.d.xml +++ b/man/modprobe.d.xml @@ -41,6 +41,7 @@ =20 /lib/modprobe.d/*.conf + @DISTCONFDIR@/modprobe.d/*.conf /usr/local/lib/modprobe.d/*.conf /run/modprobe.d/*.conf /etc/modprobe.d/*.conf diff --git a/tools/depmod.c b/tools/depmod.c index 1d1d41db860f..630fef9c8fb0 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -54,6 +54,7 @@ static const char *const default_cfg_paths[] =3D { SYSCONFDIR "/depmod.d", "/run/depmod.d", "/usr/local/lib/depmod.d", + DISTCONFDIR "/depmod.d", "/lib/depmod.d", NULL }; --=20 2.41.0 From nobody Fri Sep 5 09:20:51 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42601EB64DA for ; Tue, 18 Jul 2023 12:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232238AbjGRMDp (ORCPT ); Tue, 18 Jul 2023 08:03:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232018AbjGRMDa (ORCPT ); Tue, 18 Jul 2023 08:03:30 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F78B10F5; Tue, 18 Jul 2023 05:03:28 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 176BD1FDB9; Tue, 18 Jul 2023 12:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689681807; 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=KcavZlTXNr5DDwygCINQcHq1XhLMqp354UXQuIuczEw=; b=BtAQsJkCTuJZQLLaotPySYX6YkhuVG98Bvhmzs5zpl14/3RgadNS6KMaKzQwt4Fu1435iM 7PSDwYkkTHH+KMLUPAys1lkbJWnn4JPmqYPLJy55QvuTMkVkd/D3164Z65XI7L2OwPrHCJ BJ4U8p0bduCP8Kx5WUPNfUK+znAHym8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689681807; 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=KcavZlTXNr5DDwygCINQcHq1XhLMqp354UXQuIuczEw=; b=YcTlvotKxmSD8cmKZsvcUf64LQkPsQsvzOivjn+7yVeE7rwsG/t2MjOSA7Zo+3OacpnDxK bitcATWVQ19NcBDw== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id CA4D92C149; Tue, 18 Jul 2023 12:03:26 +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 v5 4/5] kmod: Add pkgconfig file with kmod compile time configuration Date: Tue, 18 Jul 2023 14:01:55 +0200 Message-ID: <468b3f572d3b84f25bb53ec8fcb15ed4871914d4.1689681454.git.msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Show distconfdir (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 v5: add distconfdir, switch to pkgconfig --- Makefile.am | 2 +- configure.ac | 11 +++++++++++ tools/kmod.pc.in | 9 +++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 tools/kmod.pc.in diff --git a/Makefile.am b/Makefile.am index 14eb07e63cea..6d0b2decfef3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -96,7 +96,7 @@ libkmod_libkmod_internal_la_DEPENDENCIES =3D $(libkmod_l= ibkmod_la_DEPENDENCIES) libkmod_libkmod_internal_la_LIBADD =3D $(libkmod_libkmod_la_LIBADD) =20 pkgconfigdir =3D $(libdir)/pkgconfig -pkgconfig_DATA =3D libkmod/libkmod.pc +pkgconfig_DATA =3D libkmod/libkmod.pc tools/kmod.pc =20 bashcompletiondir=3D@bashcompletiondir@ dist_bashcompletion_DATA =3D \ diff --git a/configure.ac b/configure.ac index 728f88a56704..b4584d6cdc67 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,9 @@ LT_INIT([disable-static pic-only]) AS_IF([test "x$enable_static" =3D "xyes"], [AC_MSG_ERROR([--enable-static = is not supported by kmod])]) AS_IF([test "x$enable_largefile" =3D "xno"], [AC_MSG_ERROR([--disable-larg= efile is not supported by kmod])]) =20 +module_compressions=3D"" +module_signatures=3D"legacy" + ##################################################################### # Program checks and configurations ##################################################################### @@ -94,6 +97,7 @@ AC_ARG_WITH([zstd], AS_IF([test "x$with_zstd" !=3D "xno"], [ PKG_CHECK_MODULES([libzstd], [libzstd >=3D 1.4.4], [LIBS=3D"$LIBS $libzst= d_LIBS"]) AC_DEFINE([ENABLE_ZSTD], [1], [Enable Zstandard for modules.]) + module_compressions=3D"zstd $module_compressions" ], [ AC_MSG_NOTICE([Zstandard support not requested]) ]) @@ -105,6 +109,7 @@ AC_ARG_WITH([xz], AS_IF([test "x$with_xz" !=3D "xno"], [ PKG_CHECK_MODULES([liblzma], [liblzma >=3D 4.99], [LIBS=3D"$LIBS $liblzma= _LIBS"]) AC_DEFINE([ENABLE_XZ], [1], [Enable Xz for modules.]) + module_compressions=3D"xz $module_compressions" ], [ AC_MSG_NOTICE([Xz support not requested]) ]) @@ -116,6 +121,7 @@ AC_ARG_WITH([zlib], AS_IF([test "x$with_zlib" !=3D "xno"], [ PKG_CHECK_MODULES([zlib], [zlib], [LIBS=3D"$LIBS $zlib_LIBS"]) AC_DEFINE([ENABLE_ZLIB], [1], [Enable zlib for modules.]) + module_compressions=3D"gzip $module_compressions" ], [ AC_MSG_NOTICE([zlib support not requested]) ]) @@ -134,6 +140,7 @@ AS_IF([test "x$with_openssl" !=3D "xno"], [ AC_MSG_NOTICE([openssl sm3 support not detected]) CPPFLAGS=3D"$CPPFLAGS -DOPENSSL_NO_SM3" ]) + module_signatures=3D"PKCS7 $module_signatures" ], [ AC_MSG_NOTICE([openssl support not requested]) ]) @@ -298,6 +305,9 @@ AC_DEFINE_UNQUOTED(KMOD_FEATURES, ["$with_features"], [= Features in this build]) # Generate files from *.in ##################################################################### =20 +AC_SUBST([module_compressions], $module_compressions) +AC_SUBST([module_signatures], $module_signatures) + AC_CONFIG_FILES([ Makefile man/Makefile @@ -305,6 +315,7 @@ AC_CONFIG_FILES([ libkmod/docs/version.xml libkmod/libkmod.pc libkmod/python/kmod/version.py + tools/kmod.pc ]) =20 =20 diff --git a/tools/kmod.pc.in b/tools/kmod.pc.in new file mode 100644 index 000000000000..2595980a6b35 --- /dev/null +++ b/tools/kmod.pc.in @@ -0,0 +1,9 @@ +prefix=3D@prefix@ +sysconfdir=3D@sysconfdir@ +distconfdir=3D@distconfdir@ +module_compressions=3D@module_compressions@ +module_signatures=3D@module_signatures@ + +Name: kmod +Description: Tools to deal with kernel modules +Version: @VERSION@ --=20 2.41.0 From nobody Fri Sep 5 09:20:51 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0DCE3EB64DC for ; Tue, 18 Jul 2023 12:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232276AbjGRMDr (ORCPT ); Tue, 18 Jul 2023 08:03:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232206AbjGRMDc (ORCPT ); Tue, 18 Jul 2023 08:03:32 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C50851B0; Tue, 18 Jul 2023 05:03:28 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 56CF02195D; Tue, 18 Jul 2023 12:03:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689681807; 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=94ENOqrP3gjCaN4ue+ssInaGNH9u+l8JScazVP+e3Wc=; b=X4BesYsnaruWo9HWO2pFsmQG/Jvb/04wK95lcGVKdRqzYCcCO0jHWVOpv9zOmlHp0/KuBB jOXfGXS4MoV4RhmZjeZaKYgOlE25yB9qeloUIriBS4tN4h/kHs4QXdNmoYRk1k9u4K00b/ ikhbmzrxBWWJ882pjYbLZkbFThtHuLw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689681807; 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=94ENOqrP3gjCaN4ue+ssInaGNH9u+l8JScazVP+e3Wc=; b=6z5UmO8MyMdIwRThIwHVIBMW5zumvObcqiZljWcvL+yKUjfO82nOuHm7r+2HUvEyeU3SAc 1uA122wHSeoORJCA== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 15FD12C14B; Tue, 18 Jul 2023 12:03:27 +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 v5 5/5] libkmod, depmod, modprobe: Make directory for kernel modules configurable Date: Tue, 18 Jul 2023 14:01:56 +0200 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 v5: More verbose commit message --- 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.pc.in | 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 6d0b2decfef3..019aa749fdf1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,6 +20,7 @@ AM_CPPFLAGS =3D \ -I$(top_srcdir) \ -DSYSCONFDIR=3D\""$(sysconfdir)"\" \ -DDISTCONFDIR=3D\""$(distconfdir)"\" \ + -DMODULE_DIRECTORY=3D\""$(module_directory)"\" \ ${zlib_CFLAGS} =20 AM_CFLAGS =3D $(OUR_CFLAGS) @@ -220,7 +221,7 @@ EXTRA_DIST +=3D testsuite/setup-rootfs.sh MODULE_PLAYGROUND =3D testsuite/module-playground ROOTFS =3D testsuite/rootfs ROOTFS_PRISTINE =3D $(top_srcdir)/testsuite/rootfs-pristine -CREATE_ROOTFS =3D $(AM_V_GEN) $(top_srcdir)/testsuite/setup-rootfs.sh $(RO= OTFS_PRISTINE) $(ROOTFS) $(MODULE_PLAYGROUND) $(top_builddir)/config.h $(sy= sconfdir) +CREATE_ROOTFS =3D $(AM_V_GEN) MODULE_DIRECTORY=3D$(module_directory) $(top= _srcdir)/testsuite/setup-rootfs.sh $(ROOTFS_PRISTINE) $(ROOTFS) $(MODULE_PL= AYGROUND) $(top_builddir)/config.h $(sysconfdir) =20 build-module-playground: $(AM_V_GEN)if test "$(top_srcdir)" !=3D "$(top_builddir)"; then \ diff --git a/configure.ac b/configure.ac index b4584d6cdc67..4051dc9249e2 100644 --- a/configure.ac +++ b/configure.ac @@ -91,6 +91,12 @@ AC_ARG_WITH([rootlibdir], [], [with_rootlibdir=3D$libdir]) AC_SUBST([rootlibdir], [$with_rootlibdir]) =20 +# Ideally this would be $prefix/lib/modules but default to /lib/modules fo= r compatibility with earlier versions +AC_ARG_WITH([module_directory], + AS_HELP_STRING([--with-module-directory=3DDIR], [directory in whic= h to look for kernel modules - typically '/lib/modules' or '${prefix}/lib/m= odules']), + [], [with_module_directory=3D/lib/modules]) +AC_SUBST([module_directory], [$with_module_directory]) + AC_ARG_WITH([zstd], AS_HELP_STRING([--with-zstd], [handle Zstandard-compressed modules @<:@de= fault=3Ddisabled@:>@]), [], [with_zstd=3Dno]) @@ -326,6 +332,7 @@ AC_MSG_RESULT([ $PACKAGE $VERSION =3D=3D=3D=3D=3D=3D=3D =20 + module_directory: ${module_directory} prefix: ${prefix} sysconfdir: ${sysconfdir} distconfdir: ${distconfdir} diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index 09e6041461b0..63719e886de8 100644 --- a/libkmod/libkmod.c +++ b/libkmod/libkmod.c @@ -209,7 +209,7 @@ static int log_priority(const char *priority) return 0; } =20 -static const char *dirname_default_prefix =3D "/lib/modules"; +static const char *dirname_default_prefix =3D MODULE_DIRECTORY; =20 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 2fea8e46bf2f..f550091a216a 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -22,6 +22,7 @@ CLEANFILES =3D $(dist_man_MANS) else \ sed -e '/@DISTCONFDIR@/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 f282a39cc840..b07e6a2bd4fe 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_DIRECTOR= Y@ (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 priori= ty 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, a= nd 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 file= name, 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 @@ =20 - /lib/modules/modules.dep - /lib/modules/modules.dep.bin + @MODULE_DIRECTORY@/modules.dep + @MODULE_DIRECTORY@/modules.dep.bin =20 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-playgr= ound/Makefile index e6045b0dd932..a7ab09bea2bf 100644 --- a/testsuite/module-playground/Makefile +++ b/testsuite/module-playground/Makefile @@ -47,7 +47,7 @@ endif =20 else # normal makefile -KDIR ?=3D /lib/modules/`uname -r`/build +KDIR ?=3D $(module_prefix)/lib/modules/`uname -r`/build KVER ?=3D `uname -r` ifeq ($(FAKE_BUILD),) FAKE_BUILD=3D0 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" !=3D "/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) + for i in "$ROOTFS"/*/lib/modules/* "$ROOTFS"/*/*/lib/modules/* ; do + version=3D"$(basename $i)" + [ $version !=3D 'external' ] || continue + mod=3D"$(dirname $i)" + lib=3D"$(dirname $mod)" + up=3D"$(dirname $lib)$MODULE_DIRECTORY" + mkdir -p "$up" + mv "$i" "$up" + done + fi =20 if [ "$SYSCONFDIR" !=3D "/etc" ]; then find "$ROOTFS" -type d -name etc -printf "%h\n" | while read -r e; do @@ -32,57 +45,57 @@ feature_enabled() { =20 declare -A map map=3D( - ["test-depmod/search-order-simple/lib/modules/4.4.4/kernel/crypto/"]= =3D"mod-simple.ko" - ["test-depmod/search-order-simple/lib/modules/4.4.4/updates/"]=3D"mod-= simple.ko" - ["test-depmod/search-order-same-prefix/lib/modules/4.4.4/foo/"]=3D"mod= -simple.ko" - ["test-depmod/search-order-same-prefix/lib/modules/4.4.4/foobar/"]=3D"= mod-simple.ko" - ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-a.ko"]=3D"= mod-loop-a.ko" - ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-b.ko"]=3D"= mod-loop-b.ko" - ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-c.ko"]=3D"= mod-loop-c.ko" - ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-d.ko"]=3D"= mod-loop-d.ko" - ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-e.ko"]=3D"= mod-loop-e.ko" - ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-f.ko"]=3D"= mod-loop-f.ko" - ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-g.ko"]=3D"= mod-loop-g.ko" - ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-h.ko"]=3D"= mod-loop-h.ko" - ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-i.ko"]=3D"= mod-loop-i.ko" - ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-j.ko"]=3D"= mod-loop-j.ko" - ["test-depmod/detect-loop/lib/modules/4.4.4/kernel/mod-loop-k.ko"]=3D"= mod-loop-k.ko" - ["test-depmod/search-order-external-first/lib/modules/4.4.4/foo/"]=3D"= mod-simple.ko" - ["test-depmod/search-order-external-first/lib/modules/4.4.4/foobar/"]= =3D"mod-simple.ko" + ["test-depmod/search-order-simple$MODULE_DIRECTORY/4.4.4/kernel/crypto= /"]=3D"mod-simple.ko" + ["test-depmod/search-order-simple$MODULE_DIRECTORY/4.4.4/updates/"]=3D= "mod-simple.ko" + ["test-depmod/search-order-same-prefix$MODULE_DIRECTORY/4.4.4/foo/"]= =3D"mod-simple.ko" + ["test-depmod/search-order-same-prefix$MODULE_DIRECTORY/4.4.4/foobar/"= ]=3D"mod-simple.ko" + ["test-depmod/detect-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-a.ko"= ]=3D"mod-loop-a.ko" + ["test-depmod/detect-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-b.ko"= ]=3D"mod-loop-b.ko" + ["test-depmod/detect-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-c.ko"= ]=3D"mod-loop-c.ko" + ["test-depmod/detect-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-d.ko"= ]=3D"mod-loop-d.ko" + ["test-depmod/detect-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-e.ko"= ]=3D"mod-loop-e.ko" + ["test-depmod/detect-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-f.ko"= ]=3D"mod-loop-f.ko" + ["test-depmod/detect-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-g.ko"= ]=3D"mod-loop-g.ko" + ["test-depmod/detect-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-h.ko"= ]=3D"mod-loop-h.ko" + ["test-depmod/detect-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-i.ko"= ]=3D"mod-loop-i.ko" + ["test-depmod/detect-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-j.ko"= ]=3D"mod-loop-j.ko" + ["test-depmod/detect-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-k.ko"= ]=3D"mod-loop-k.ko" + ["test-depmod/search-order-external-first$MODULE_DIRECTORY/4.4.4/foo/"= ]=3D"mod-simple.ko" + ["test-depmod/search-order-external-first$MODULE_DIRECTORY/4.4.4/fooba= r/"]=3D"mod-simple.ko" ["test-depmod/search-order-external-first/lib/modules/external/"]=3D"m= od-simple.ko" - ["test-depmod/search-order-external-last/lib/modules/4.4.4/foo/"]=3D"m= od-simple.ko" - ["test-depmod/search-order-external-last/lib/modules/4.4.4/foobar/"]= =3D"mod-simple.ko" + ["test-depmod/search-order-external-last$MODULE_DIRECTORY/4.4.4/foo/"]= =3D"mod-simple.ko" + ["test-depmod/search-order-external-last$MODULE_DIRECTORY/4.4.4/foobar= /"]=3D"mod-simple.ko" ["test-depmod/search-order-external-last/lib/modules/external/"]=3D"mo= d-simple.ko" - ["test-depmod/search-order-override/lib/modules/4.4.4/foo/"]=3D"mod-si= mple.ko" - ["test-depmod/search-order-override/lib/modules/4.4.4/override/"]=3D"m= od-simple.ko" - ["test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/foo/"]=3D"mod-fo= o-b.ko" - ["test-dependencies/lib/modules/4.0.20-kmod/kernel/"]=3D"mod-foo-c.ko" - ["test-dependencies/lib/modules/4.0.20-kmod/kernel/lib/"]=3D"mod-foo-a= .ko" - ["test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/"]=3D"mod-foo.ko" + ["test-depmod/search-order-override$MODULE_DIRECTORY/4.4.4/foo/"]=3D"m= od-simple.ko" + ["test-depmod/search-order-override$MODULE_DIRECTORY/4.4.4/override/"]= =3D"mod-simple.ko" + ["test-dependencies$MODULE_DIRECTORY/4.0.20-kmod/kernel/fs/foo/"]=3D"m= od-foo-b.ko" + ["test-dependencies$MODULE_DIRECTORY/4.0.20-kmod/kernel/"]=3D"mod-foo-= c.ko" + ["test-dependencies$MODULE_DIRECTORY/4.0.20-kmod/kernel/lib/"]=3D"mod-= foo-a.ko" + ["test-dependencies$MODULE_DIRECTORY/4.0.20-kmod/kernel/fs/"]=3D"mod-f= oo.ko" ["test-init/"]=3D"mod-simple.ko" ["test-remove/"]=3D"mod-simple.ko" - ["test-modprobe/show-depends/lib/modules/4.4.4/kernel/mod-loop-a.ko"]= =3D"mod-loop-a.ko" - ["test-modprobe/show-depends/lib/modules/4.4.4/kernel/mod-loop-b.ko"]= =3D"mod-loop-b.ko" - ["test-modprobe/show-depends/lib/modules/4.4.4/kernel/mod-simple.ko"]= =3D"mod-simple.ko" + ["test-modprobe/show-depends$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-a.= ko"]=3D"mod-loop-a.ko" + ["test-modprobe/show-depends$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-b.= ko"]=3D"mod-loop-b.ko" + ["test-modprobe/show-depends$MODULE_DIRECTORY/4.4.4/kernel/mod-simple.= ko"]=3D"mod-simple.ko" ["test-modprobe/show-exports/mod-loop-a.ko"]=3D"mod-loop-a.ko" - ["test-modprobe/softdep-loop/lib/modules/4.4.4/kernel/mod-loop-a.ko"]= =3D"mod-loop-a.ko" - ["test-modprobe/softdep-loop/lib/modules/4.4.4/kernel/mod-loop-b.ko"]= =3D"mod-loop-b.ko" - ["test-modprobe/install-cmd-loop/lib/modules/4.4.4/kernel/mod-loop-a.k= o"]=3D"mod-loop-a.ko" - ["test-modprobe/install-cmd-loop/lib/modules/4.4.4/kernel/mod-loop-b.k= o"]=3D"mod-loop-b.ko" - ["test-modprobe/force/lib/modules/4.4.4/kernel/"]=3D"mod-simple.ko" - ["test-modprobe/oldkernel/lib/modules/3.3.3/kernel/"]=3D"mod-simple.ko" - ["test-modprobe/oldkernel-force/lib/modules/3.3.3/kernel/"]=3D"mod-sim= ple.ko" - ["test-modprobe/alias-to-none/lib/modules/4.4.4/kernel/"]=3D"mod-simpl= e.ko" - ["test-modprobe/module-param-kcmdline/lib/modules/4.4.4/kernel/"]=3D"m= od-simple.ko" + ["test-modprobe/softdep-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-a.= ko"]=3D"mod-loop-a.ko" + ["test-modprobe/softdep-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loop-b.= ko"]=3D"mod-loop-b.ko" + ["test-modprobe/install-cmd-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loo= p-a.ko"]=3D"mod-loop-a.ko" + ["test-modprobe/install-cmd-loop$MODULE_DIRECTORY/4.4.4/kernel/mod-loo= p-b.ko"]=3D"mod-loop-b.ko" + ["test-modprobe/force$MODULE_DIRECTORY/4.4.4/kernel/"]=3D"mod-simple.k= o" + ["test-modprobe/oldkernel$MODULE_DIRECTORY/3.3.3/kernel/"]=3D"mod-simp= le.ko" + ["test-modprobe/oldkernel-force$MODULE_DIRECTORY/3.3.3/kernel/"]=3D"mo= d-simple.ko" + ["test-modprobe/alias-to-none$MODULE_DIRECTORY/4.4.4/kernel/"]=3D"mod-= simple.ko" + ["test-modprobe/module-param-kcmdline$MODULE_DIRECTORY/4.4.4/kernel/"]= =3D"mod-simple.ko" ["test-modprobe/external/lib/modules/external/"]=3D"mod-simple.ko" ["test-modprobe/module-from-abspath/home/foo/"]=3D"mod-simple.ko" ["test-modprobe/module-from-relpath/home/foo/"]=3D"mod-simple.ko" - ["test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/driver= s/block/cciss.ko"]=3D"mod-fake-cciss.ko" - ["test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/driver= s/scsi/hpsa.ko"]=3D"mod-fake-hpsa.ko" - ["test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/driver= s/scsi/scsi_mod.ko"]=3D"mod-fake-scsi-mod.ko" - ["test-depmod/modules-outdir/lib/modules/4.4.4/kernel/drivers/block/cc= iss.ko"]=3D"mod-fake-cciss.ko" - ["test-depmod/modules-outdir/lib/modules/4.4.4/kernel/drivers/scsi/hps= a.ko"]=3D"mod-fake-hpsa.ko" - ["test-depmod/modules-outdir/lib/modules/4.4.4/kernel/drivers/scsi/scs= i_mod.ko"]=3D"mod-fake-scsi-mod.ko" + ["test-depmod/modules-order-compressed$MODULE_DIRECTORY/4.4.4/kernel/d= rivers/block/cciss.ko"]=3D"mod-fake-cciss.ko" + ["test-depmod/modules-order-compressed$MODULE_DIRECTORY/4.4.4/kernel/d= rivers/scsi/hpsa.ko"]=3D"mod-fake-hpsa.ko" + ["test-depmod/modules-order-compressed$MODULE_DIRECTORY/4.4.4/kernel/d= rivers/scsi/scsi_mod.ko"]=3D"mod-fake-scsi-mod.ko" + ["test-depmod/modules-outdir$MODULE_DIRECTORY/4.4.4/kernel/drivers/blo= ck/cciss.ko"]=3D"mod-fake-cciss.ko" + ["test-depmod/modules-outdir$MODULE_DIRECTORY/4.4.4/kernel/drivers/scs= i/hpsa.ko"]=3D"mod-fake-hpsa.ko" + ["test-depmod/modules-outdir$MODULE_DIRECTORY/4.4.4/kernel/drivers/scs= i/scsi_mod.ko"]=3D"mod-fake-scsi-mod.ko" ["test-modinfo/mod-simple-i386.ko"]=3D"mod-simple-i386.ko" ["test-modinfo/mod-simple-x86_64.ko"]=3D"mod-simple-x86_64.ko" ["test-modinfo/mod-simple-sparc64.ko"]=3D"mod-simple-sparc64.ko" @@ -90,20 +103,20 @@ map=3D( ["test-modinfo/mod-simple-sha256.ko"]=3D"mod-simple.ko" ["test-modinfo/mod-simple-pkcs7.ko"]=3D"mod-simple.ko" ["test-modinfo/external/lib/modules/external/mod-simple.ko"]=3D"mod-si= mple.ko" - ["test-tools/insert/lib/modules/4.4.4/kernel/"]=3D"mod-simple.ko" - ["test-tools/remove/lib/modules/4.4.4/kernel/"]=3D"mod-simple.ko" + ["test-tools/insert$MODULE_DIRECTORY/4.4.4/kernel/"]=3D"mod-simple.ko" + ["test-tools/remove$MODULE_DIRECTORY/4.4.4/kernel/"]=3D"mod-simple.ko" ) =20 gzip_array=3D( - "test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers= /block/cciss.ko" + "test-depmod/modules-order-compressed$MODULE_DIRECTORY/4.4.4/kernel/dr= ivers/block/cciss.ko" ) =20 xz_array=3D( - "test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers= /scsi/scsi_mod.ko" + "test-depmod/modules-order-compressed$MODULE_DIRECTORY/4.4.4/kernel/dr= ivers/scsi/scsi_mod.ko" ) =20 zstd_array=3D( - "test-depmod/modules-order-compressed/lib/modules/4.4.4/kernel/drivers= /scsi/hpsa.ko" + "test-depmod/modules-order-compressed$MODULE_DIRECTORY/4.4.4/kernel/dr= ivers/scsi/hpsa.ko" ) =20 attach_sha256_array=3D( diff --git a/testsuite/test-depmod.c b/testsuite/test-depmod.c index 93606947f18a..c96dbf0a62be 100644 --- a/testsuite/test-depmod.c +++ b/testsuite/test-depmod.c @@ -27,7 +27,7 @@ =20 #define MODULES_UNAME "4.4.4" #define MODULES_ORDER_ROOTFS TESTSUITE_ROOTFS "test-depmod/modules-order-c= ompressed" -#define MODULES_ORDER_LIB_MODULES MODULES_ORDER_ROOTFS "/lib/modules/" MOD= ULES_UNAME +#define MODULES_ORDER_LIB_MODULES MODULES_ORDER_ROOTFS MODULE_DIRECTORY "/= " MODULES_UNAME static noreturn int depmod_modules_order_for_compressed(const struct test = *t) { const char *progname =3D ABS_TOP_BUILDDIR "/tools/depmod"; @@ -55,8 +55,8 @@ DEFINE_TEST(depmod_modules_order_for_compressed, }); =20 #define MODULES_OUTDIR_ROOTFS TESTSUITE_ROOTFS "test-depmod/modules-outdir" -#define MODULES_OUTDIR_LIB_MODULES_OUTPUT MODULES_OUTDIR_ROOTFS "/outdir/l= ib/modules/" MODULES_UNAME -#define MODULES_OUTDIR_LIB_MODULES_INPUT MODULES_OUTDIR_ROOTFS "/lib/modul= es/" MODULES_UNAME +#define MODULES_OUTDIR_LIB_MODULES_OUTPUT MODULES_OUTDIR_ROOTFS "/outdir" = MODULE_DIRECTORY "/" MODULES_UNAME +#define MODULES_OUTDIR_LIB_MODULES_INPUT MODULES_OUTDIR_ROOTFS MODULE_DIRE= CTORY "/" MODULES_UNAME static noreturn int depmod_modules_outdir(const struct test *t) { const char *progname =3D ABS_TOP_BUILDDIR "/tools/depmod"; @@ -87,7 +87,7 @@ DEFINE_TEST(depmod_modules_outdir, }); =20 #define SEARCH_ORDER_SIMPLE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-or= der-simple" -#define SEARCH_ORDER_SIMPLE_LIB_MODULES SEARCH_ORDER_SIMPLE_ROOTFS "/lib/m= odules/" MODULES_UNAME +#define SEARCH_ORDER_SIMPLE_LIB_MODULES SEARCH_ORDER_SIMPLE_ROOTFS MODULE_= DIRECTORY "/" MODULES_UNAME static noreturn int depmod_search_order_simple(const struct test *t) { const char *progname =3D ABS_TOP_BUILDDIR "/tools/depmod"; @@ -114,7 +114,7 @@ DEFINE_TEST(depmod_search_order_simple, }); =20 #define SEARCH_ORDER_SAME_PREFIX_ROOTFS TESTSUITE_ROOTFS "test-depmod/sear= ch-order-same-prefix" -#define SEARCH_ORDER_SAME_PREFIX_LIB_MODULES SEARCH_ORDER_SAME_PREFIX_ROOT= FS "/lib/modules/" MODULES_UNAME +#define SEARCH_ORDER_SAME_PREFIX_LIB_MODULES SEARCH_ORDER_SAME_PREFIX_ROOT= FS MODULE_DIRECTORY "/" MODULES_UNAME static noreturn int depmod_search_order_same_prefix(const struct test *t) { const char *progname =3D ABS_TOP_BUILDDIR "/tools/depmod"; @@ -164,7 +164,7 @@ DEFINE_TEST(depmod_detect_loop, }); =20 #define SEARCH_ORDER_EXTERNAL_FIRST_ROOTFS TESTSUITE_ROOTFS "test-depmod/s= earch-order-external-first" -#define SEARCH_ORDER_EXTERNAL_FIRST_LIB_MODULES SEARCH_ORDER_EXTERNAL_FIRS= T_ROOTFS "/lib/modules/" MODULES_UNAME +#define SEARCH_ORDER_EXTERNAL_FIRST_LIB_MODULES SEARCH_ORDER_EXTERNAL_FIRS= T_ROOTFS MODULE_DIRECTORY "/" MODULES_UNAME static noreturn int depmod_search_order_external_first(const struct test *= t) { const char *progname =3D ABS_TOP_BUILDDIR "/tools/depmod"; @@ -191,7 +191,7 @@ DEFINE_TEST(depmod_search_order_external_first, }); =20 #define SEARCH_ORDER_EXTERNAL_LAST_ROOTFS TESTSUITE_ROOTFS "test-depmod/se= arch-order-external-last" -#define SEARCH_ORDER_EXTERNAL_LAST_LIB_MODULES SEARCH_ORDER_EXTERNAL_LAST_= ROOTFS "/lib/modules/" MODULES_UNAME +#define SEARCH_ORDER_EXTERNAL_LAST_LIB_MODULES SEARCH_ORDER_EXTERNAL_LAST_= ROOTFS MODULE_DIRECTORY "/" MODULES_UNAME static noreturn int depmod_search_order_external_last(const struct test *t) { const char *progname =3D ABS_TOP_BUILDDIR "/tools/depmod"; @@ -218,7 +218,7 @@ DEFINE_TEST(depmod_search_order_external_last, }); =20 #define SEARCH_ORDER_OVERRIDE_ROOTFS TESTSUITE_ROOTFS "test-depmod/search-= order-override" -#define SEARCH_ORDER_OVERRIDE_LIB_MODULES SEARCH_ORDER_OVERRIDE_ROOTFS "/l= ib/modules/" MODULES_UNAME +#define SEARCH_ORDER_OVERRIDE_LIB_MODULES SEARCH_ORDER_OVERRIDE_ROOTFS MOD= ULE_DIRECTORY "/" MODULES_UNAME static noreturn int depmod_search_order_override(const struct test *t) { const char *progname =3D ABS_TOP_BUILDDIR "/tools/depmod"; diff --git a/testsuite/test-testsuite.c b/testsuite/test-testsuite.c index 56e73609f204..c77c4bbc04eb 100644 --- a/testsuite/test-testsuite.c +++ b/testsuite/test-testsuite.c @@ -64,7 +64,7 @@ static int testsuite_rootfs_fopen(const struct test *t) char s[100]; int n; =20 - fp =3D fopen("/lib/modules/a", "r"); + fp =3D fopen(MODULE_DIRECTORY "/a", "r"); if (fp =3D=3D NULL) return EXIT_FAILURE;; =20 @@ -89,7 +89,7 @@ static int testsuite_rootfs_open(const struct test *t) char buf[100]; int fd, done; =20 - fd =3D open("/lib/modules/a", O_RDONLY); + fd =3D open(MODULE_DIRECTORY "/a", O_RDONLY); if (fd < 0) return EXIT_FAILURE; =20 @@ -121,12 +121,12 @@ static int testsuite_rootfs_stat_access(const struct = test *t) { struct stat st; =20 - if (access("/lib/modules/a", F_OK) < 0) { + if (access(MODULE_DIRECTORY "/a", F_OK) < 0) { ERR("access failed: %m\n"); return EXIT_FAILURE; } =20 - if (stat("/lib/modules/a", &st) < 0) { + if (stat(MODULE_DIRECTORY "/a", &st) < 0) { ERR("stat failed: %m\n"); return EXIT_FAILURE; } diff --git a/tools/depmod.c b/tools/depmod.c index 630fef9c8fb0..7f7c4b74d216 100644 --- a/tools/depmod.c +++ b/tools/depmod.c @@ -911,7 +911,7 @@ struct vertex; struct mod { struct kmod_module *kmod; char *path; - const char *relpath; /* path relative to '$ROOT/lib/modules/$VER/' */ + const char *relpath; /* path relative to '$ROOT$MODULE_DIRECTORY/$VER/' */ char *uncrelpath; /* same as relpath but ending in .ko */ struct kmod_list *info_list; struct kmod_list *dep_sym_list; @@ -3024,11 +3024,11 @@ static int do_depmod(int argc, char *argv[]) } =20 cfg.dirnamelen =3D snprintf(cfg.dirname, PATH_MAX, - "%s/lib/modules/%s", + "%s" MODULE_DIRECTORY "/%s", root ?: "", cfg.kversion); =20 cfg.outdirnamelen =3D snprintf(cfg.outdirname, PATH_MAX, - "%s/lib/modules/%s", + "%s" MODULE_DIRECTORY "/%s", out_root ?: (root ?: ""), cfg.kversion); =20 if (optind =3D=3D argc) diff --git a/tools/kmod.pc.in b/tools/kmod.pc.in index 2595980a6b35..97215c8ed48f 100644 --- a/tools/kmod.pc.in +++ b/tools/kmod.pc.in @@ -1,6 +1,7 @@ prefix=3D@prefix@ sysconfdir=3D@sysconfdir@ distconfdir=3D@distconfdir@ +module_directory=3D@module_directory@ module_compressions=3D@module_compressions@ module_signatures=3D@module_signatures@ =20 diff --git a/tools/modinfo.c b/tools/modinfo.c index d0aab200af4e..cacc32dc4c40 100644 --- a/tools/modinfo.c +++ b/tools/modinfo.c @@ -367,7 +367,7 @@ static void help(void) "\t-m, --modname Handle argument as module name instead of= alias or filename\n" "\t-F, --field=3DFIELD Print only provided FIELD\n" "\t-k, --set-version=3DVERSION Use VERSION instead of `uname -r`\n" - "\t-b, --basedir=3DDIR Use DIR as filesystem root for /lib/mod= ules\n" + "\t-b, --basedir=3DDIR Use DIR as filesystem root for " MODULE= _DIRECTORY "\n" "\t-V, --version Show version\n" "\t-h, --help Show this help\n", program_invocation_short_name); @@ -462,7 +462,7 @@ static int do_modinfo(int argc, char *argv[]) } kversion =3D u.release; } - snprintf(dirname_buf, sizeof(dirname_buf), "%s/lib/modules/%s", + snprintf(dirname_buf, sizeof(dirname_buf), "%s" MODULE_DIRECTORY "/%s", root, kversion); dirname =3D dirname_buf; } diff --git a/tools/modprobe.c b/tools/modprobe.c index e891028349a8..5306bef250da 100644 --- a/tools/modprobe.c +++ b/tools/modprobe.c @@ -142,7 +142,7 @@ static void help(void) "\t-n, --show Same as --dry-run\n" =20 "\t-C, --config=3DFILE Use FILE instead of default search path= s\n" - "\t-d, --dirname=3DDIR Use DIR as filesystem root for /lib/mod= ules\n" + "\t-d, --dirname=3DDIR Use DIR as filesystem root for " MODULE= _DIRECTORY "\n" "\t-S, --set-version=3DVERSION Use VERSION instead of `uname -r`\n" =20 "\t-s, --syslog print to syslog, not stderr\n" @@ -999,7 +999,7 @@ static int do_modprobe(int argc, char **orig_argv) kversion =3D u.release; } snprintf(dirname_buf, sizeof(dirname_buf), - "%s/lib/modules/%s", root, + "%s" MODULE_DIRECTORY "/%s", root, kversion); dirname =3D dirname_buf; } diff --git a/tools/static-nodes.c b/tools/static-nodes.c index 8d2356da73f3..5ef3743e967b 100644 --- a/tools/static-nodes.c +++ b/tools/static-nodes.c @@ -212,15 +212,15 @@ static int do_static_nodes(int argc, char *argv[]) goto finish; } =20 - snprintf(modules, sizeof(modules), "/lib/modules/%s/modules.devname", ker= nel.release); + snprintf(modules, sizeof(modules), MODULE_DIRECTORY "/%s/modules.devname"= , kernel.release); in =3D fopen(modules, "re"); if (in =3D=3D NULL) { if (errno =3D=3D ENOENT) { - fprintf(stderr, "Warning: /lib/modules/%s/modules.devname not found - i= gnoring\n", + fprintf(stderr, "Warning: " MODULE_DIRECTORY "/%s/modules.devname not f= ound - ignoring\n", kernel.release); ret =3D EXIT_SUCCESS; } else { - fprintf(stderr, "Error: could not open /lib/modules/%s/modules.devname = - %m\n", + fprintf(stderr, "Error: could not open " MODULE_DIRECTORY "/%s/modules.= devname - %m\n", kernel.release); ret =3D EXIT_FAILURE; } --=20 2.41.0 From nobody Fri Sep 5 09:20:51 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FCB3EB64DD for ; Tue, 18 Jul 2023 12:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231637AbjGRMEp (ORCPT ); Tue, 18 Jul 2023 08:04:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjGRMEn (ORCPT ); Tue, 18 Jul 2023 08:04:43 -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 CD8F619A0; Tue, 18 Jul 2023 05:04:13 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 0EFC0218E8; Tue, 18 Jul 2023 12:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689681832; 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=vcCkWnZUOHY/Sf1BWe3lgRRDTuoQCOqXBJxqBFvSUCI=; b=2YYugYC+Enel0PrgKJcncUJBkqbIDEOuHK7wgiHXmk2CX9K8zQEoed4m95jRTv/VjQj23N JphtDrJcqdJvH+svaQE3grLyf9x0kTdLCKvslKmENk2HcDxnDBsCRPuM2620D6ZvrDhv4f pNFN6Ppu2xTUJqwCpQdnf8XTjt0NPCs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689681832; 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=vcCkWnZUOHY/Sf1BWe3lgRRDTuoQCOqXBJxqBFvSUCI=; b=PJoqenbvlmnXp9+Glk6cu66+zfOK29pIMidnd+UiFuBSAPNIlwIIVUfRxv3Y6b7Z2N3w/c BQ8fkgAKvwEwskAQ== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id BE74C2C142; Tue, 18 Jul 2023 12:03:51 +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 v5] depmod: Handle installing modules under a prefix Date: Tue, 18 Jul 2023 14:03:47 +0200 Message-ID: <20230718120348.383-1-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Some distributions aim at shipping all files in /usr. The path under which kernel modules are installed is hardcoded to /lib which conflicts with this goal. When kmod provides the config command, use it to determine the correct module installation path. With kmod that does not provide the config command /lib/modules is used as before. Signed-off-by: Michal Suchanek --- v2: Avoid error on systems with kmod that does not support config command v3: More verbose commit message v4: - Document jq requirement - fix bashism - Update to getting full module path, not just additional prefix v5: switch to pkgconfig --- Makefile | 4 +++- scripts/depmod.sh | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 47690c28456a..1620d224ad9c 100644 --- a/Makefile +++ b/Makefile @@ -1165,7 +1165,9 @@ export INSTALL_DTBS_PATH ?=3D $(INSTALL_PATH)/dtbs/$(= KERNELRELEASE) # makefile but the argument can be passed to make if needed. # =20 -MODLIB =3D $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE) +export KERNEL_MODULE_DIRECTORY :=3D $(shell pkg-config --print-variables k= mod 2>/dev/null | grep '^module_directory$$' >/dev/null && pkg-config --var= iable=3Dmodule_directory kmod || echo /lib/modules) + +MODLIB =3D $(INSTALL_MOD_PATH)$(KERNEL_MODULE_DIRECTORY)/$(KERNELRELEASE) export MODLIB =20 PHONY +=3D prepare0 diff --git a/scripts/depmod.sh b/scripts/depmod.sh index 3643b4f896ed..06961f990fcb 100755 --- a/scripts/depmod.sh +++ b/scripts/depmod.sh @@ -27,16 +27,16 @@ fi # numbers, so we cheat with a symlink here depmod_hack_needed=3Dtrue tmp_dir=3D$(mktemp -d ${TMPDIR:-/tmp}/depmod.XXXXXX) -mkdir -p "$tmp_dir/lib/modules/$KERNELRELEASE" +mkdir -p "$tmp_dir$KERNEL_MODULE_DIRECTORY/$KERNELRELEASE" if "$DEPMOD" -b "$tmp_dir" $KERNELRELEASE 2>/dev/null; then - if test -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep" -o \ - -e "$tmp_dir/lib/modules/$KERNELRELEASE/modules.dep.bin"; then + if test -e "$tmp_dir$KERNEL_MODULE_DIRECTORY/$KERNELRELEASE/modules.dep" = -o \ + -e "$tmp_dir$KERNEL_MODULE_DIRECTORY/$KERNELRELEASE/modules.dep.bin"; th= en depmod_hack_needed=3Dfalse fi fi rm -rf "$tmp_dir" if $depmod_hack_needed; then - symlink=3D"$INSTALL_MOD_PATH/lib/modules/99.98.$KERNELRELEASE" + symlink=3D"$INSTALL_MOD_PATH$KERNEL_MODULE_DIRECTORY/99.98.$KERNELRELEASE" ln -s "$KERNELRELEASE" "$symlink" KERNELRELEASE=3D99.98.$KERNELRELEASE fi --=20 2.41.0