From nobody Sun Feb 8 14:53:05 2026 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 E633CC001DF for ; Tue, 11 Jul 2023 15:32:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232450AbjGKPcY (ORCPT ); Tue, 11 Jul 2023 11:32:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232402AbjGKPcU (ORCPT ); Tue, 11 Jul 2023 11:32:20 -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 E2622133; Tue, 11 Jul 2023 08:32:19 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A543A22720; Tue, 11 Jul 2023 15:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689089538; 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=0bKfTtR4G4uL3jrD0uMXyxOPPr/sjYNuuin+JWTwmPg=; b=BcViP28ng5AYLIME7gvHNS5/ogh7wFI459TtyV7omXPjXYuwWZcyRJw50lbrvfzPzWdldg +NpUVFxIL4Nydq1mF+uCarQNYuqHKEctbulwARkCRi20rNi98nqnSQnVuiStnPKSF9DRvj 6Y6TkkCV+pM7g1aRff87nWZcmGCA4b4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689089538; 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=0bKfTtR4G4uL3jrD0uMXyxOPPr/sjYNuuin+JWTwmPg=; b=Uve+0m0Km99uOVm0ihyy4TbQkThEjpOH63RkxhdK5LjbdRl17P3QvYS9+k5YGaV12KlVXZ SCDJO/tSdohPLkBw== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 5C3532C143; Tue, 11 Jul 2023 15:32:18 +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 1/4] man/depmod.d: Fix incorrect /usr/lib search path Date: Tue, 11 Jul 2023 17:31:16 +0200 Message-ID: <20230711153126.28876-2-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711153126.28876-1-msuchanek@suse.de> References: <20230711153126.28876-1-msuchanek@suse.de> 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 reached. Aling the documentation with the code. Signed-off-by: Michal Suchanek --- 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 Sun Feb 8 14:53:05 2026 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 57C10C001E0 for ; Wed, 12 Jul 2023 14:01:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233370AbjGLOBh (ORCPT ); Wed, 12 Jul 2023 10:01:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232442AbjGLOB1 (ORCPT ); Wed, 12 Jul 2023 10:01:27 -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 0C9021BF0; Wed, 12 Jul 2023 07:01:13 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C0C3F2231D; Wed, 12 Jul 2023 14:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689170471; 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=bGxUMCnUo3cieQJBVkgOKt9HJbCcp45JISg8FNDoXAV6m8ZwGYH9byz1tbehmaWurbonH4 zKu2YmR/cEPE3rlOS/jEBMrqZcP3aCKXPG7y2/0vIeU5kJYIHTzRPNdN/hCiPi3xyyCUJx pxTqFdhqX7CE/CIGXooAyGSZV4qiuAc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689170471; 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=F+0kD2xn6dMhcPDtCY73CWeGbBTITK2W/pGd/coHszd++SxkQWawEXaxqwcpGETiMkiDI4 fXujHqPKqid278DA== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 5C1402C142; Wed, 12 Jul 2023 14:01:11 +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 v2 1/4] man/depmod.d: Fix incorrect /usr/lib search path Date: Wed, 12 Jul 2023 16:00:45 +0200 Message-ID: <20230712140103.5468-1-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711153126.28876-1-msuchanek@suse.de> References: <20230711153126.28876-1-msuchanek@suse.de> 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 Sun Feb 8 14:53:05 2026 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 B34DEEB64DA for ; Wed, 12 Jul 2023 14:01:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229931AbjGLOBr (ORCPT ); Wed, 12 Jul 2023 10:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231183AbjGLOB2 (ORCPT ); Wed, 12 Jul 2023 10:01:28 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86CF51BF2; Wed, 12 Jul 2023 07:01:13 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 094B01F88F; Wed, 12 Jul 2023 14:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689170472; 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=QkOJVLdlNmtcCiPnwgfWGNxDgX5+VIZYJYAOoBOKLEA=; b=2KknRwbyfHUuVQ3lEbF32zeruDcG+/MdmJe/pPjhkDMpbknbkss2cHJT+T3joO2XDPE2NK SsDx6PSdScL+nryssYlXWuarStVZHK9jV3wbM8PG6+tbgNj7dtoGMTI6xQOBc3D77sj537 hi84gE9E0iEYaRoizdPKraFQ8iK++VE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689170472; 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=QkOJVLdlNmtcCiPnwgfWGNxDgX5+VIZYJYAOoBOKLEA=; b=1o9F/EwdiotYKmOKXDiAFeKKLWEByhYLbm4rKxMHJKlH9iKN6AGhiunFilSS8CqKCuVh8K x6ON7AK2/BdWNaAg== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id BE3142C143; Wed, 12 Jul 2023 14:01:11 +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 v2 2/4] libkmod, depmod: Load modprobe.d, depmod.d from $prefix/lib. Date: Wed, 12 Jul 2023 16:00:46 +0200 Message-ID: <20230712140103.5468-2-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711153126.28876-1-msuchanek@suse.de> References: <20230711153126.28876-1-msuchanek@suse.de> 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 --- Makefile.am | 1 + libkmod/libkmod.c | 3 ++- man/Makefile.am | 9 +++++++-- man/depmod.d.xml | 1 + man/modprobe.d.xml | 1 + tools/depmod.c | 1 + 6 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8ba85c91a0f3..7aa5bfa5638d 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)"\" \ + -DPREFIX=3D\""$(prefix)"\" \ ${zlib_CFLAGS} =20 AM_CFLAGS =3D $(OUR_CFLAGS) diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index 2670f9a4611a..13c82b069e84 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", + PREFIX "/lib/modprobe.d", "/lib/modprobe.d", NULL }; @@ -237,7 +238,7 @@ 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 + * /usr/local/lib/modprobe.d and PREFIX/lib/modprobe.d. Giv= e an empty * vector if configuration should not be read. This array m= ust * be null terminated. * diff --git a/man/Makefile.am b/man/Makefile.am index 11514d52a190..ad07c30bbd24 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 [ -n '$(prefix)' ] ; then \ + sed -e 's|@PREFIX@|$(prefix)|g' $< ; \ + else \ + sed -e '/@PREFIX@/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..431ebca6654b 100644 --- a/man/depmod.d.xml +++ b/man/depmod.d.xml @@ -40,6 +40,7 @@ =20 /lib/depmod.d/*.conf + @PREFIX@/lib/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..e8a91d7668af 100644 --- a/man/modprobe.d.xml +++ b/man/modprobe.d.xml @@ -41,6 +41,7 @@ =20 /lib/modprobe.d/*.conf + @PREFIX@/lib/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..7e9339923809 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", + PREFIX "/lib/depmod.d", "/lib/depmod.d", NULL }; --=20 2.41.0 From nobody Sun Feb 8 14:53:05 2026 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 16BC6EB64DC for ; Tue, 11 Jul 2023 15:32:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230252AbjGKPcc (ORCPT ); Tue, 11 Jul 2023 11:32:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232416AbjGKPcW (ORCPT ); Tue, 11 Jul 2023 11:32:22 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7178610DD; Tue, 11 Jul 2023 08:32:20 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id E8BBD1FE69; Tue, 11 Jul 2023 15:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689089538; 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=Zi7pcLLSWwiwPJzQ1FjSFjmrtTNu/4ArWWuzhomcHJc=; b=11rlUDi0iRT+FZ1dJVq2XpnOoKesESjm/Sz/jXG81aNHOSVgoc00DdEHn8BE1KLgZ5/hZr XpIebYValJ/XH7l81ist0Q/klJr4RcXkldgdb+2Xqgp9C0hzsEBQpfPjO8Awf3lJQdgE4s wqZxUko6f9L6vVjQ9peIxhG9Sf2yrOE= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689089538; 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=Zi7pcLLSWwiwPJzQ1FjSFjmrtTNu/4ArWWuzhomcHJc=; b=lCK2GUpcORnC0BJBdv6ftKKI3DAAHHDyQyU8Yld7IgMcbXLUTODHNN5TclHAxNSXErasmH IIfVm2+DgnM2arBw== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id A49212C145; Tue, 11 Jul 2023 15:32:18 +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 2/4] libkmod, depmod: Load modprobe.d, depmod.d from $prefix/lib. Date: Tue, 11 Jul 2023 17:31:17 +0200 Message-ID: <20230711153126.28876-3-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711153126.28876-1-msuchanek@suse.de> References: <20230711153126.28876-1-msuchanek@suse.de> 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 seach directories. Cc: Takashi Iwai Signed-off-by: Michal Suchanek --- Makefile.am | 1 + libkmod/libkmod.c | 3 ++- man/Makefile.am | 9 +++++++-- man/depmod.d.xml | 1 + man/modprobe.d.xml | 1 + tools/depmod.c | 1 + 6 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index 8ba85c91a0f3..7aa5bfa5638d 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)"\" \ + -DPREFIX=3D\""$(prefix)"\" \ ${zlib_CFLAGS} =20 AM_CFLAGS =3D $(OUR_CFLAGS) diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index 2670f9a4611a..13c82b069e84 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", + PREFIX "/lib/modprobe.d", "/lib/modprobe.d", NULL }; @@ -237,7 +238,7 @@ 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 + * /usr/local/lib/modprobe.d and PREFIX/lib/modprobe.d. Giv= e an empty * vector if configuration should not be read. This array m= ust * be null terminated. * diff --git a/man/Makefile.am b/man/Makefile.am index 11514d52a190..ad07c30bbd24 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 [ -n '$(prefix)' ] ; then \ + sed -e 's|@PREFIX@|$(prefix)|g' $< ; \ + else \ + sed -e '/@PREFIX@/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..431ebca6654b 100644 --- a/man/depmod.d.xml +++ b/man/depmod.d.xml @@ -40,6 +40,7 @@ =20 /lib/depmod.d/*.conf + @PREFIX@/lib/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..e8a91d7668af 100644 --- a/man/modprobe.d.xml +++ b/man/modprobe.d.xml @@ -41,6 +41,7 @@ =20 /lib/modprobe.d/*.conf + @PREFIX@/lib/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..7e9339923809 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", + PREFIX "/lib/depmod.d", "/lib/depmod.d", NULL }; --=20 2.41.0 From nobody Sun Feb 8 14:53:05 2026 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 BAF8DEB64DA for ; Wed, 12 Jul 2023 14:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231932AbjGLOBo (ORCPT ); Wed, 12 Jul 2023 10:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232856AbjGLOB2 (ORCPT ); Wed, 12 Jul 2023 10:01:28 -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 9D0161BF5; Wed, 12 Jul 2023 07:01:13 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 5C39A1FE45; Wed, 12 Jul 2023 14:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689170472; 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=hbkrw+Y8Z1P5bMkowr2XXMkWBVqN2gEHuamxYK92xU4=; b=OscZ7he4/KK8vOpchq5n2waFvvi7aHK+q3JHNzvx/lBWoHe2ff3kXS3tToV272jJabsGy3 BIq6f0lL8qcnjRRzwO9ECwyRd9qNb/rD75HS1zbtwioYjvIyrTdVZFLgvSubRLWn9aMy11 FMaCnP4IPFoyYpI8kq4icpgpflAazkU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689170472; 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=hbkrw+Y8Z1P5bMkowr2XXMkWBVqN2gEHuamxYK92xU4=; b=JS3RRZ7OvztD1547G6OgoaSS9XJaCLOVyheGF8lYu81q67D9C0JSmAgqkvLULh9XHqUKrb OneKDXCbL6uM8iBQ== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 0A0982C145; Wed, 12 Jul 2023 14:01:12 +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 v2 3/4] kmod: Add config command to show compile time configuration as JSON Date: Wed, 12 Jul 2023 16:00:47 +0200 Message-ID: <20230712140103.5468-3-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711153126.28876-1-msuchanek@suse.de> References: <20230711153126.28876-1-msuchanek@suse.de> 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 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[] =3D { }; =20 static const struct kmod_cmd kmod_cmd_help; +static const struct kmod_cmd kmod_cmd_config; =20 static const struct kmod_cmd *kmod_cmds[] =3D { &kmod_cmd_help, + &kmod_cmd_config, &kmod_cmd_list, &kmod_cmd_static_nodes, =20 @@ -95,6 +97,43 @@ static const struct kmod_cmd kmod_cmd_help =3D { .help =3D "Show help message", }; =20 +static const char *compressions[] =3D { +#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 =3D 0; compressions[i]; i++) { + printf("%s\"%s\"", i ? "," : "", compressions[i]); + } + printf("]}\n"); + + return EXIT_SUCCESS; +} + +static const struct kmod_cmd kmod_cmd_config =3D { + .name =3D "config", + .cmd =3D kmod_config, + .help =3D "Show compile time options in JSON", +}; + static int handle_kmod_commands(int argc, char *argv[]) { const char *cmd; --=20 2.41.0 From nobody Sun Feb 8 14:53:05 2026 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 DC2D0C0015E for ; Tue, 11 Jul 2023 15:32:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232478AbjGKPc1 (ORCPT ); Tue, 11 Jul 2023 11:32:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231444AbjGKPcV (ORCPT ); Tue, 11 Jul 2023 11:32:21 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 822B810DF; Tue, 11 Jul 2023 08:32:20 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 35E1422725; Tue, 11 Jul 2023 15:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689089539; 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=QS7lsHabvgwvSyWCrGwNi2pl8kOLnGWh2IemNmy9SDU=; b=Ir23vwDKN1Gx1jDNFzxUd3DSmnFpSOUUrYKhQiyJq781piHpC6X9j6Ycdv5Pp6YFecIImw iVZAsGkq7m0UT2PRRo6PiLNI7D2bKoaM62MT4clgqXuuXZ4htSIinGdwoTSuUNr4DPqRyM 2Qw5SY/SWndZs/WnOYu821HRBmUceco= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689089539; 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=QS7lsHabvgwvSyWCrGwNi2pl8kOLnGWh2IemNmy9SDU=; b=Hsb/aoIiTB7oAYf7vrFrHOx/r2Y3rM3KdpOWa8zh2qojeImXY+EjkwTvregkwqS7D4fpHT yn6+ev1+m+IFvoDg== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id E75B92C142; Tue, 11 Jul 2023 15:32:18 +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 3/4] kmod: Add config command to show compile time configuration as JSON Date: Tue, 11 Jul 2023 17:31:18 +0200 Message-ID: <20230711153126.28876-4-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711153126.28876-1-msuchanek@suse.de> References: <20230711153126.28876-1-msuchanek@suse.de> 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 prefix (where configuration files are searched/to be installed) and module compressions supported. Signed-off-by: Michal Suchanek --- 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[] =3D { }; =20 static const struct kmod_cmd kmod_cmd_help; +static const struct kmod_cmd kmod_cmd_config; =20 static const struct kmod_cmd *kmod_cmds[] =3D { &kmod_cmd_help, + &kmod_cmd_config, &kmod_cmd_list, &kmod_cmd_static_nodes, =20 @@ -95,6 +97,43 @@ static const struct kmod_cmd kmod_cmd_help =3D { .help =3D "Show help message", }; =20 +static const char *compressions[] =3D { +#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 =3D 0; compressions[i]; i++) { + printf("%s\"%s\"", i ? "," : "", compressions[i]); + } + printf("]}\n"); + + return EXIT_SUCCESS; +} + +static const struct kmod_cmd kmod_cmd_config =3D { + .name =3D "config", + .cmd =3D kmod_config, + .help =3D "Show compile time options in JSON", +}; + static int handle_kmod_commands(int argc, char *argv[]) { const char *cmd; --=20 2.41.0 From nobody Sun Feb 8 14:53:05 2026 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 1E6F4EB64D9 for ; Wed, 12 Jul 2023 14:02:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232608AbjGLOB7 (ORCPT ); Wed, 12 Jul 2023 10:01:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232957AbjGLOBb (ORCPT ); Wed, 12 Jul 2023 10:01:31 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BB7B1BF1; Wed, 12 Jul 2023 07:01:13 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 964EA22450; Wed, 12 Jul 2023 14:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689170472; 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=yKKT8b8MHqmoYLni1cBtyDTxdtHtoiD2Tq7+6lDibIg=; b=cIQ5xqMHosipfJgd+XJ86f+a3pJG9z1p2QWXqsvJcDtCK6RzsuiOXa/Nr8CRdelx8sgVlg lCxbkggTnDUpCOlJZu4SO4+SUj13+KajvNwquY6617qHjMmWkKaoy+b4NI+nPA666o/oAy utfXwfDujJsaJE5MXNNRe6xRzn3op98= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689170472; 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=yKKT8b8MHqmoYLni1cBtyDTxdtHtoiD2Tq7+6lDibIg=; b=3Nn+PoeXHcGdcdG8s7wlX1F7860TOFfO5Ijz8YCrZaH2oEHwKdXwexh3WoN32maihsCbNr oF68m6Tf3rLNN+Dw== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 4DF6D2C15B; Wed, 12 Jul 2023 14:01:12 +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 v2 4/4] libkmod, depmod, modprobe: Search for kernel modules under ${module_prefix} Date: Wed, 12 Jul 2023 16:00:48 +0200 Message-ID: <20230712140103.5468-4-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711153126.28876-1-msuchanek@suse.de> References: <20230711153126.28876-1-msuchanek@suse.de> 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" modprobe.d is now searched under ${prefix}/lib, add ${module_prefix} to specify the directory where to search for kernel modules. 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 --- Makefile.am | 3 +- configure.ac | 7 ++ libkmod/libkmod.c | 6 +- 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, 108 insertions(+), 85 deletions(-) diff --git a/Makefile.am b/Makefile.am index 7aa5bfa5638d..96ae1edd7366 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,6 +20,7 @@ AM_CPPFLAGS =3D \ -I$(top_srcdir) \ -DSYSCONFDIR=3D\""$(sysconfdir)"\" \ -DPREFIX=3D\""$(prefix)"\" \ + -DMODULE_PREFIX=3D\""$(module_prefix)"\" \ ${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_PREFIX=3D$(module_prefix) $(top_srcdi= r)/testsuite/setup-rootfs.sh $(ROOTFS_PRISTINE) $(ROOTFS) $(MODULE_PLAYGROU= ND) $(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 6064dee77ae6..29d3ff8ae41d 100644 --- a/configure.ac +++ b/configure.ac @@ -84,6 +84,12 @@ AC_ARG_WITH([rootlibdir], [], [with_rootlibdir=3D$libdir]) AC_SUBST([rootlibdir], [$with_rootlibdir]) =20 +# Ideally this would be $prefix but default to empty for compatibility wit= h earlier versions +AC_ARG_WITH([module_prefix], + AS_HELP_STRING([--with-module-prefix=3DDIR], [directory in which t= o look for /lib/modules directory with kernel modules - typically '' or ${p= refix}]), + [], [with_module_prefix=3D]) +AC_SUBST([module_prefix], [$with_module_prefix]) + AC_ARG_WITH([zstd], AS_HELP_STRING([--with-zstd], [handle Zstandard-compressed modules @<:@de= fault=3Ddisabled@:>@]), [], [with_zstd=3Dno]) @@ -305,6 +311,7 @@ AC_MSG_RESULT([ =3D=3D=3D=3D=3D=3D=3D =20 prefix: ${prefix} + module_prefix: ${module_prefix} sysconfdir: ${sysconfdir} libdir: ${libdir} rootlibdir: ${rootlibdir} diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index 13c82b069e84..e41acae6f9fc 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_PREFIX "/lib/modules"; =20 static char *get_kernel_release(const char *dirname) { @@ -231,14 +231,14 @@ 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 * 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 PREFIX/lib/modprobe.d. Giv= e an empty + * /usr/local/lib/modprobe.d and ${module_prefix}/lib/modpr= obe.d. Give an empty * vector if configuration should not be read. This array m= ust * be null terminated. * diff --git a/man/Makefile.am b/man/Makefile.am index ad07c30bbd24..1a9a92f9c224 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -22,6 +22,7 @@ CLEANFILES =3D $(dist_man_MANS) else \ sed -e '/@PREFIX@/d' $< ; \ fi | \ + sed -e 's|@MODULE_PREFIX@|$(module_prefix)|g' | \ $(XSLT) \ -o $@ \ --nonet \ diff --git a/man/depmod.d.xml b/man/depmod.d.xml index 431ebca6654b..2583a8d8a5fc 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_PREFIX@/= lib/modules (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_PREFIX@/lib/modules (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_PREFIX@/lib/modules (or other module location) will ta= ke priority over any likenamed module already provided by the kernel. diff --git a/man/depmod.xml b/man/depmod.xml index 3b0097184fd7..9d9cf195a355 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_PREFIX@/lib/modules/versio= n 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_PREFIX@/lib/modules/= 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..d48c64560e9d 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_PREFIX@/lib/modules/versio= n 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..6e8bb8c9ce9e 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_PREFIX@/lib/modules/`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..9130ec392089 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_PREFIX@/lib/modules/modules.dep + @MODULE_PREFIX@/lib/modules/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_PREFIX@/lib/modules/versio= n. 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..db41da36fedf 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 [ -n "$MODULE_PREFIX" ] ; then + sed -i -e "s|/lib/modules|$MODULE_PREFIX/lib/modules|g" $(find "$ROOTFS"= -name \*.txt -o -name \*.conf -o -name \*.dep) + sed -i -e "s|$MODULE_PREFIX/lib/modules/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 + i=3D$(dirname $i) + lib=3D"$(dirname $i)" + up=3D"$(dirname $lib)$MODULE_PREFIX" + mkdir -p "$up" + mv "$lib" "$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_PREFIX/lib/modules/4.4.4/kern= el/crypto/"]=3D"mod-simple.ko" + ["test-depmod/search-order-simple$MODULE_PREFIX/lib/modules/4.4.4/upda= tes/"]=3D"mod-simple.ko" + ["test-depmod/search-order-same-prefix$MODULE_PREFIX/lib/modules/4.4.4= /foo/"]=3D"mod-simple.ko" + ["test-depmod/search-order-same-prefix$MODULE_PREFIX/lib/modules/4.4.4= /foobar/"]=3D"mod-simple.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-a.ko"]=3D"mod-loop-a.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-b.ko"]=3D"mod-loop-b.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-c.ko"]=3D"mod-loop-c.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-d.ko"]=3D"mod-loop-d.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-e.ko"]=3D"mod-loop-e.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-f.ko"]=3D"mod-loop-f.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-g.ko"]=3D"mod-loop-g.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-h.ko"]=3D"mod-loop-h.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-i.ko"]=3D"mod-loop-i.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-j.ko"]=3D"mod-loop-j.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-k.ko"]=3D"mod-loop-k.ko" + ["test-depmod/search-order-external-first$MODULE_PREFIX/lib/modules/4.= 4.4/foo/"]=3D"mod-simple.ko" + ["test-depmod/search-order-external-first$MODULE_PREFIX/lib/modules/4.= 4.4/foobar/"]=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_PREFIX/lib/modules/4.4= .4/foo/"]=3D"mod-simple.ko" + ["test-depmod/search-order-external-last$MODULE_PREFIX/lib/modules/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_PREFIX/lib/modules/4.4.4/fo= o/"]=3D"mod-simple.ko" + ["test-depmod/search-order-override$MODULE_PREFIX/lib/modules/4.4.4/ov= erride/"]=3D"mod-simple.ko" + ["test-dependencies$MODULE_PREFIX/lib/modules/4.0.20-kmod/kernel/fs/fo= o/"]=3D"mod-foo-b.ko" + ["test-dependencies$MODULE_PREFIX/lib/modules/4.0.20-kmod/kernel/"]=3D= "mod-foo-c.ko" + ["test-dependencies$MODULE_PREFIX/lib/modules/4.0.20-kmod/kernel/lib/"= ]=3D"mod-foo-a.ko" + ["test-dependencies$MODULE_PREFIX/lib/modules/4.0.20-kmod/kernel/fs/"]= =3D"mod-foo.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_PREFIX/lib/modules/4.4.4/kernel/mo= d-loop-a.ko"]=3D"mod-loop-a.ko" + ["test-modprobe/show-depends$MODULE_PREFIX/lib/modules/4.4.4/kernel/mo= d-loop-b.ko"]=3D"mod-loop-b.ko" + ["test-modprobe/show-depends$MODULE_PREFIX/lib/modules/4.4.4/kernel/mo= d-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_PREFIX/lib/modules/4.4.4/kernel/mo= d-loop-a.ko"]=3D"mod-loop-a.ko" + ["test-modprobe/softdep-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mo= d-loop-b.ko"]=3D"mod-loop-b.ko" + ["test-modprobe/install-cmd-loop$MODULE_PREFIX/lib/modules/4.4.4/kerne= l/mod-loop-a.ko"]=3D"mod-loop-a.ko" + ["test-modprobe/install-cmd-loop$MODULE_PREFIX/lib/modules/4.4.4/kerne= l/mod-loop-b.ko"]=3D"mod-loop-b.ko" + ["test-modprobe/force$MODULE_PREFIX/lib/modules/4.4.4/kernel/"]=3D"mod= -simple.ko" + ["test-modprobe/oldkernel$MODULE_PREFIX/lib/modules/3.3.3/kernel/"]=3D= "mod-simple.ko" + ["test-modprobe/oldkernel-force$MODULE_PREFIX/lib/modules/3.3.3/kernel= /"]=3D"mod-simple.ko" + ["test-modprobe/alias-to-none$MODULE_PREFIX/lib/modules/4.4.4/kernel/"= ]=3D"mod-simple.ko" + ["test-modprobe/module-param-kcmdline$MODULE_PREFIX/lib/modules/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_PREFIX/lib/modules/4.4.4= /kernel/drivers/block/cciss.ko"]=3D"mod-fake-cciss.ko" + ["test-depmod/modules-order-compressed$MODULE_PREFIX/lib/modules/4.4.4= /kernel/drivers/scsi/hpsa.ko"]=3D"mod-fake-hpsa.ko" + ["test-depmod/modules-order-compressed$MODULE_PREFIX/lib/modules/4.4.4= /kernel/drivers/scsi/scsi_mod.ko"]=3D"mod-fake-scsi-mod.ko" + ["test-depmod/modules-outdir$MODULE_PREFIX/lib/modules/4.4.4/kernel/dr= ivers/block/cciss.ko"]=3D"mod-fake-cciss.ko" + ["test-depmod/modules-outdir$MODULE_PREFIX/lib/modules/4.4.4/kernel/dr= ivers/scsi/hpsa.ko"]=3D"mod-fake-hpsa.ko" + ["test-depmod/modules-outdir$MODULE_PREFIX/lib/modules/4.4.4/kernel/dr= ivers/scsi/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_PREFIX/lib/modules/4.4.4/kernel/"]=3D"mod-s= imple.ko" + ["test-tools/remove$MODULE_PREFIX/lib/modules/4.4.4/kernel/"]=3D"mod-s= imple.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_PREFIX/lib/modules/4.4.4/= kernel/drivers/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_PREFIX/lib/modules/4.4.4/= kernel/drivers/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_PREFIX/lib/modules/4.4.4/= kernel/drivers/scsi/hpsa.ko" ) =20 attach_sha256_array=3D( diff --git a/testsuite/test-depmod.c b/testsuite/test-depmod.c index 93606947f18a..870f2667862b 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_PREFIX "/lib= /modules/" 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_PREFIX "/lib/modules/" MODULES_UNAME +#define MODULES_OUTDIR_LIB_MODULES_INPUT MODULES_OUTDIR_ROOTFS MODULE_PREF= IX "/lib/modules/" 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_= PREFIX "/lib/modules/" 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_PREFIX "/lib/modules/" 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_PREFIX "/lib/modules/" 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_PREFIX "/lib/modules/" 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_PREFIX "/lib/modules/" 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..903a0102105e 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_PREFIX "/lib/modules/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_PREFIX "/lib/modules/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_PREFIX "/lib/modules/a", F_OK) < 0) { ERR("access failed: %m\n"); return EXIT_FAILURE; } =20 - if (stat("/lib/modules/a", &st) < 0) { + if (stat(MODULE_PREFIX "/lib/modules/a", &st) < 0) { ERR("stat failed: %m\n"); return EXIT_FAILURE; } diff --git a/tools/depmod.c b/tools/depmod.c index 7e9339923809..686525b4adea 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_PREFIX/lib/modules= /$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_PREFIX "/lib/modules/%s", root ?: "", cfg.kversion); =20 cfg.outdirnamelen =3D snprintf(cfg.outdirname, PATH_MAX, - "%s/lib/modules/%s", + "%s" MODULE_PREFIX "/lib/modules/%s", out_root ?: (root ?: ""), cfg.kversion); =20 if (optind =3D=3D argc) diff --git a/tools/kmod.c b/tools/kmod.c index 5a13716955c1..4384752ab5bc 100644 --- a/tools/kmod.c +++ b/tools/kmod.c @@ -114,6 +114,7 @@ static int kmod_config(int argc, char *argv[]) { unsigned i; printf("{\"prefix\":\"" PREFIX "\"" + ",\"module_prefix\":\"" MODULE_PREFIX "\"" ",\"module_signature\":[" #ifdef ENABLE_OPENSSL "\"PKCS#7\"," diff --git a/tools/modinfo.c b/tools/modinfo.c index d0aab200af4e..c10ce7ec5ef3 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= _PREFIX "/lib/modules\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_PREFIX "/lib/modu= les/%s", root, kversion); dirname =3D dirname_buf; } diff --git a/tools/modprobe.c b/tools/modprobe.c index e891028349a8..f386c57275e0 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= _PREFIX "/lib/modules\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_PREFIX "/lib/modules/%s", root, kversion); dirname =3D dirname_buf; } diff --git a/tools/static-nodes.c b/tools/static-nodes.c index 8d2356da73f3..868af3b58ac7 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_PREFIX "/lib/modules/%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_PREFIX "/lib/modules/%s/modules.devn= ame not found - 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_PREFIX "/lib/modules/%s= /modules.devname - %m\n", kernel.release); ret =3D EXIT_FAILURE; } --=20 2.41.0 From nobody Sun Feb 8 14:53:05 2026 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 6ECB4EB64DD for ; Tue, 11 Jul 2023 15:32:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232512AbjGKPch (ORCPT ); Tue, 11 Jul 2023 11:32:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232441AbjGKPcY (ORCPT ); Tue, 11 Jul 2023 11:32:24 -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 DC4E9ED; Tue, 11 Jul 2023 08:32:20 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 85C3022726; Tue, 11 Jul 2023 15:32:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689089539; 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=yKKT8b8MHqmoYLni1cBtyDTxdtHtoiD2Tq7+6lDibIg=; b=EYR4zABLvcP3MVmWEWKnZ94svt78AjYYI82ALAJKTgbb9HGAw9uyddqVDmPCX2oJajnalg FP3QjFa6YXiM4zAe+GWzKhha5AzQIi9C9K6CdLhmzH5/+2Ht3AsPpXSfFDR3+um/HtNQpz Q8YXk5fCWSQMtCqw1z3ukRHzKWp/2/4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689089539; 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=yKKT8b8MHqmoYLni1cBtyDTxdtHtoiD2Tq7+6lDibIg=; b=X+kC8L/wiQ+J4Zz8oNVqfEvjthTboCOlpK9Y7pr3txTjKxnsc41p+S9bAuxA5QUV2cUCCO oPj06eWAZKVFzhBg== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id 362BC2C146; Tue, 11 Jul 2023 15:32:19 +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 4/4] libkmod, depmod, modprobe: Search for kernel modules under ${module_prefix} Date: Tue, 11 Jul 2023 17:31:19 +0200 Message-ID: <20230711153126.28876-5-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711153126.28876-1-msuchanek@suse.de> References: <20230711153126.28876-1-msuchanek@suse.de> 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" modprobe.d is now searched under ${prefix}/lib, add ${module_prefix} to specify the directory where to search for kernel modules. 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 --- Makefile.am | 3 +- configure.ac | 7 ++ libkmod/libkmod.c | 6 +- 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, 108 insertions(+), 85 deletions(-) diff --git a/Makefile.am b/Makefile.am index 7aa5bfa5638d..96ae1edd7366 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,6 +20,7 @@ AM_CPPFLAGS =3D \ -I$(top_srcdir) \ -DSYSCONFDIR=3D\""$(sysconfdir)"\" \ -DPREFIX=3D\""$(prefix)"\" \ + -DMODULE_PREFIX=3D\""$(module_prefix)"\" \ ${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_PREFIX=3D$(module_prefix) $(top_srcdi= r)/testsuite/setup-rootfs.sh $(ROOTFS_PRISTINE) $(ROOTFS) $(MODULE_PLAYGROU= ND) $(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 6064dee77ae6..29d3ff8ae41d 100644 --- a/configure.ac +++ b/configure.ac @@ -84,6 +84,12 @@ AC_ARG_WITH([rootlibdir], [], [with_rootlibdir=3D$libdir]) AC_SUBST([rootlibdir], [$with_rootlibdir]) =20 +# Ideally this would be $prefix but default to empty for compatibility wit= h earlier versions +AC_ARG_WITH([module_prefix], + AS_HELP_STRING([--with-module-prefix=3DDIR], [directory in which t= o look for /lib/modules directory with kernel modules - typically '' or ${p= refix}]), + [], [with_module_prefix=3D]) +AC_SUBST([module_prefix], [$with_module_prefix]) + AC_ARG_WITH([zstd], AS_HELP_STRING([--with-zstd], [handle Zstandard-compressed modules @<:@de= fault=3Ddisabled@:>@]), [], [with_zstd=3Dno]) @@ -305,6 +311,7 @@ AC_MSG_RESULT([ =3D=3D=3D=3D=3D=3D=3D =20 prefix: ${prefix} + module_prefix: ${module_prefix} sysconfdir: ${sysconfdir} libdir: ${libdir} rootlibdir: ${rootlibdir} diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index 13c82b069e84..e41acae6f9fc 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_PREFIX "/lib/modules"; =20 static char *get_kernel_release(const char *dirname) { @@ -231,14 +231,14 @@ 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 * 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 PREFIX/lib/modprobe.d. Giv= e an empty + * /usr/local/lib/modprobe.d and ${module_prefix}/lib/modpr= obe.d. Give an empty * vector if configuration should not be read. This array m= ust * be null terminated. * diff --git a/man/Makefile.am b/man/Makefile.am index ad07c30bbd24..1a9a92f9c224 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -22,6 +22,7 @@ CLEANFILES =3D $(dist_man_MANS) else \ sed -e '/@PREFIX@/d' $< ; \ fi | \ + sed -e 's|@MODULE_PREFIX@|$(module_prefix)|g' | \ $(XSLT) \ -o $@ \ --nonet \ diff --git a/man/depmod.d.xml b/man/depmod.d.xml index 431ebca6654b..2583a8d8a5fc 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_PREFIX@/= lib/modules (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_PREFIX@/lib/modules (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_PREFIX@/lib/modules (or other module location) will ta= ke priority over any likenamed module already provided by the kernel. diff --git a/man/depmod.xml b/man/depmod.xml index 3b0097184fd7..9d9cf195a355 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_PREFIX@/lib/modules/versio= n 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_PREFIX@/lib/modules/= 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..d48c64560e9d 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_PREFIX@/lib/modules/versio= n 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..6e8bb8c9ce9e 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_PREFIX@/lib/modules/`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..9130ec392089 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_PREFIX@/lib/modules/modules.dep + @MODULE_PREFIX@/lib/modules/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_PREFIX@/lib/modules/versio= n. 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..db41da36fedf 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 [ -n "$MODULE_PREFIX" ] ; then + sed -i -e "s|/lib/modules|$MODULE_PREFIX/lib/modules|g" $(find "$ROOTFS"= -name \*.txt -o -name \*.conf -o -name \*.dep) + sed -i -e "s|$MODULE_PREFIX/lib/modules/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 + i=3D$(dirname $i) + lib=3D"$(dirname $i)" + up=3D"$(dirname $lib)$MODULE_PREFIX" + mkdir -p "$up" + mv "$lib" "$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_PREFIX/lib/modules/4.4.4/kern= el/crypto/"]=3D"mod-simple.ko" + ["test-depmod/search-order-simple$MODULE_PREFIX/lib/modules/4.4.4/upda= tes/"]=3D"mod-simple.ko" + ["test-depmod/search-order-same-prefix$MODULE_PREFIX/lib/modules/4.4.4= /foo/"]=3D"mod-simple.ko" + ["test-depmod/search-order-same-prefix$MODULE_PREFIX/lib/modules/4.4.4= /foobar/"]=3D"mod-simple.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-a.ko"]=3D"mod-loop-a.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-b.ko"]=3D"mod-loop-b.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-c.ko"]=3D"mod-loop-c.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-d.ko"]=3D"mod-loop-d.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-e.ko"]=3D"mod-loop-e.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-f.ko"]=3D"mod-loop-f.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-g.ko"]=3D"mod-loop-g.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-h.ko"]=3D"mod-loop-h.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-i.ko"]=3D"mod-loop-i.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-j.ko"]=3D"mod-loop-j.ko" + ["test-depmod/detect-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mod-l= oop-k.ko"]=3D"mod-loop-k.ko" + ["test-depmod/search-order-external-first$MODULE_PREFIX/lib/modules/4.= 4.4/foo/"]=3D"mod-simple.ko" + ["test-depmod/search-order-external-first$MODULE_PREFIX/lib/modules/4.= 4.4/foobar/"]=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_PREFIX/lib/modules/4.4= .4/foo/"]=3D"mod-simple.ko" + ["test-depmod/search-order-external-last$MODULE_PREFIX/lib/modules/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_PREFIX/lib/modules/4.4.4/fo= o/"]=3D"mod-simple.ko" + ["test-depmod/search-order-override$MODULE_PREFIX/lib/modules/4.4.4/ov= erride/"]=3D"mod-simple.ko" + ["test-dependencies$MODULE_PREFIX/lib/modules/4.0.20-kmod/kernel/fs/fo= o/"]=3D"mod-foo-b.ko" + ["test-dependencies$MODULE_PREFIX/lib/modules/4.0.20-kmod/kernel/"]=3D= "mod-foo-c.ko" + ["test-dependencies$MODULE_PREFIX/lib/modules/4.0.20-kmod/kernel/lib/"= ]=3D"mod-foo-a.ko" + ["test-dependencies$MODULE_PREFIX/lib/modules/4.0.20-kmod/kernel/fs/"]= =3D"mod-foo.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_PREFIX/lib/modules/4.4.4/kernel/mo= d-loop-a.ko"]=3D"mod-loop-a.ko" + ["test-modprobe/show-depends$MODULE_PREFIX/lib/modules/4.4.4/kernel/mo= d-loop-b.ko"]=3D"mod-loop-b.ko" + ["test-modprobe/show-depends$MODULE_PREFIX/lib/modules/4.4.4/kernel/mo= d-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_PREFIX/lib/modules/4.4.4/kernel/mo= d-loop-a.ko"]=3D"mod-loop-a.ko" + ["test-modprobe/softdep-loop$MODULE_PREFIX/lib/modules/4.4.4/kernel/mo= d-loop-b.ko"]=3D"mod-loop-b.ko" + ["test-modprobe/install-cmd-loop$MODULE_PREFIX/lib/modules/4.4.4/kerne= l/mod-loop-a.ko"]=3D"mod-loop-a.ko" + ["test-modprobe/install-cmd-loop$MODULE_PREFIX/lib/modules/4.4.4/kerne= l/mod-loop-b.ko"]=3D"mod-loop-b.ko" + ["test-modprobe/force$MODULE_PREFIX/lib/modules/4.4.4/kernel/"]=3D"mod= -simple.ko" + ["test-modprobe/oldkernel$MODULE_PREFIX/lib/modules/3.3.3/kernel/"]=3D= "mod-simple.ko" + ["test-modprobe/oldkernel-force$MODULE_PREFIX/lib/modules/3.3.3/kernel= /"]=3D"mod-simple.ko" + ["test-modprobe/alias-to-none$MODULE_PREFIX/lib/modules/4.4.4/kernel/"= ]=3D"mod-simple.ko" + ["test-modprobe/module-param-kcmdline$MODULE_PREFIX/lib/modules/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_PREFIX/lib/modules/4.4.4= /kernel/drivers/block/cciss.ko"]=3D"mod-fake-cciss.ko" + ["test-depmod/modules-order-compressed$MODULE_PREFIX/lib/modules/4.4.4= /kernel/drivers/scsi/hpsa.ko"]=3D"mod-fake-hpsa.ko" + ["test-depmod/modules-order-compressed$MODULE_PREFIX/lib/modules/4.4.4= /kernel/drivers/scsi/scsi_mod.ko"]=3D"mod-fake-scsi-mod.ko" + ["test-depmod/modules-outdir$MODULE_PREFIX/lib/modules/4.4.4/kernel/dr= ivers/block/cciss.ko"]=3D"mod-fake-cciss.ko" + ["test-depmod/modules-outdir$MODULE_PREFIX/lib/modules/4.4.4/kernel/dr= ivers/scsi/hpsa.ko"]=3D"mod-fake-hpsa.ko" + ["test-depmod/modules-outdir$MODULE_PREFIX/lib/modules/4.4.4/kernel/dr= ivers/scsi/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_PREFIX/lib/modules/4.4.4/kernel/"]=3D"mod-s= imple.ko" + ["test-tools/remove$MODULE_PREFIX/lib/modules/4.4.4/kernel/"]=3D"mod-s= imple.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_PREFIX/lib/modules/4.4.4/= kernel/drivers/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_PREFIX/lib/modules/4.4.4/= kernel/drivers/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_PREFIX/lib/modules/4.4.4/= kernel/drivers/scsi/hpsa.ko" ) =20 attach_sha256_array=3D( diff --git a/testsuite/test-depmod.c b/testsuite/test-depmod.c index 93606947f18a..870f2667862b 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_PREFIX "/lib= /modules/" 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_PREFIX "/lib/modules/" MODULES_UNAME +#define MODULES_OUTDIR_LIB_MODULES_INPUT MODULES_OUTDIR_ROOTFS MODULE_PREF= IX "/lib/modules/" 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_= PREFIX "/lib/modules/" 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_PREFIX "/lib/modules/" 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_PREFIX "/lib/modules/" 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_PREFIX "/lib/modules/" 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_PREFIX "/lib/modules/" 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..903a0102105e 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_PREFIX "/lib/modules/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_PREFIX "/lib/modules/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_PREFIX "/lib/modules/a", F_OK) < 0) { ERR("access failed: %m\n"); return EXIT_FAILURE; } =20 - if (stat("/lib/modules/a", &st) < 0) { + if (stat(MODULE_PREFIX "/lib/modules/a", &st) < 0) { ERR("stat failed: %m\n"); return EXIT_FAILURE; } diff --git a/tools/depmod.c b/tools/depmod.c index 7e9339923809..686525b4adea 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_PREFIX/lib/modules= /$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_PREFIX "/lib/modules/%s", root ?: "", cfg.kversion); =20 cfg.outdirnamelen =3D snprintf(cfg.outdirname, PATH_MAX, - "%s/lib/modules/%s", + "%s" MODULE_PREFIX "/lib/modules/%s", out_root ?: (root ?: ""), cfg.kversion); =20 if (optind =3D=3D argc) diff --git a/tools/kmod.c b/tools/kmod.c index 5a13716955c1..4384752ab5bc 100644 --- a/tools/kmod.c +++ b/tools/kmod.c @@ -114,6 +114,7 @@ static int kmod_config(int argc, char *argv[]) { unsigned i; printf("{\"prefix\":\"" PREFIX "\"" + ",\"module_prefix\":\"" MODULE_PREFIX "\"" ",\"module_signature\":[" #ifdef ENABLE_OPENSSL "\"PKCS#7\"," diff --git a/tools/modinfo.c b/tools/modinfo.c index d0aab200af4e..c10ce7ec5ef3 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= _PREFIX "/lib/modules\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_PREFIX "/lib/modu= les/%s", root, kversion); dirname =3D dirname_buf; } diff --git a/tools/modprobe.c b/tools/modprobe.c index e891028349a8..f386c57275e0 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= _PREFIX "/lib/modules\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_PREFIX "/lib/modules/%s", root, kversion); dirname =3D dirname_buf; } diff --git a/tools/static-nodes.c b/tools/static-nodes.c index 8d2356da73f3..868af3b58ac7 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_PREFIX "/lib/modules/%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_PREFIX "/lib/modules/%s/modules.devn= ame not found - 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_PREFIX "/lib/modules/%s= /modules.devname - %m\n", kernel.release); ret =3D EXIT_FAILURE; } --=20 2.41.0 From nobody Sun Feb 8 14:53:05 2026 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 D114DEB64DC for ; Tue, 11 Jul 2023 15:35:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231726AbjGKPfH (ORCPT ); Tue, 11 Jul 2023 11:35:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230099AbjGKPfE (ORCPT ); Tue, 11 Jul 2023 11:35: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 8BAF7ED; Tue, 11 Jul 2023 08:35:03 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 490741FEC5; Tue, 11 Jul 2023 15:35:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1689089701; 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=GphF7AY62AISo2U3bJWb8pTQ4C+Mrfr5BrDuaVD87rY=; b=MOYDbv9rU8NEWqmF/OGJ48V9KpzB6QrHrcYTWjiETksZkisRkJD6749oIyNQO0jTM/ZUH6 IdhasSRGMt49DQogne5qD38RyruUz0rtP9N1H51YNmDTbZ1GAgLpjf6Afghtizh7fLnbDI JQtaCcFjNeVZIYhGSVCngBSliOGu0dw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1689089701; 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=GphF7AY62AISo2U3bJWb8pTQ4C+Mrfr5BrDuaVD87rY=; b=0/NCsbIAanjTCrMmysmJz4GufYTdB0IjyBKPU8RxMzKiFX3XF9872g0N2XXqlgpkvWHgZ0 7/pgy4WSfZ0RWSDQ== Received: from kitsune.suse.cz (kitsune.suse.cz [10.100.12.127]) by relay2.suse.de (Postfix) with ESMTP id E4A3C2C142; Tue, 11 Jul 2023 15:35:00 +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] depmod: Handle installing modules under a prefix Date: Tue, 11 Jul 2023 17:34:54 +0200 Message-ID: <20230711153457.29497-1-msuchanek@suse.de> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230711153126.28876-1-msuchanek@suse.de> References: <20230711153126.28876-1-msuchanek@suse.de> 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 not shipping any files in / ustside of usr. The path under which kernel modules are instaleld is hardcoded to /lib which conflicts with this goal. When kmod provides the config command use it to determine the correct module installation prefix. On kmod that does not provide the command / is used as before. Signed-off-by: Michal Suchanek --- Makefile | 4 +++- scripts/depmod.sh | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 47690c28456a..b05d696f06bd 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_PREFIX :=3D $(shell kmod config | jq -r .module_prefi= x) + +MODLIB =3D $(INSTALL_MOD_PATH)$(KERNEL_MODULE_PREFIX)/lib/modules/$(KERNEL= RELEASE) export MODLIB =20 PHONY +=3D prepare0 diff --git a/scripts/depmod.sh b/scripts/depmod.sh index 3643b4f896ed..88ac79056153 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_PREFIX/lib/modules/$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_PREFIX/lib/modules/$KERNELRELEASE/modu= les.dep" -o \ + -e "$tmp_dir$KERNEL_MODULE_PREFIX/lib/modules/$KERNELRELEASE/modules.dep= .bin"; then 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_PREFIX/lib/modules/99.98.$KERN= ELRELEASE" ln -s "$KERNELRELEASE" "$symlink" KERNELRELEASE=3D99.98.$KERNELRELEASE fi --=20 2.41.0