kmod - Linux kernel module handling
Go to file
Lucas De Marchi 94f7683c5a modinfo: Allow to force arg as module name
If the Linux kernel or userspace sets an alias with the same name as a
module, they force the tools to use that. However in some situations it
may be desired to query the module itself. Getting the module
information through modinfo is one such situation. So, add a option to
modinfo to explicitly instruct it to handle the argument as a module
name.

Example, when trying to output information about the crc32 module that
is builtin:

	$ modinfo crc32
	filename:       /lib/modules/5.15.19-1-MANJARO/kernel/arch/x86/crypto/crc32-pclmul.ko.zst
	alias:          crypto-crc32-pclmul
	alias:          crc32-pclmul
	alias:          crypto-crc32
	alias:          crc32
	license:        GPL
	author:         Alexander Boyko <alexander_boyko@xyratex.com>
	srcversion:     B6B2FF9236731E69418A2E5
	alias:          cpu:type:x86,ven*fam*mod*:feature:*0081*
	depends:
	retpoline:      Y
	intree:         Y
	name:           crc32_pclmul
	vermagic:       5.15.19-1-MANJARO SMP preempt mod_unload
	sig_id:         PKCS#7
	signer:         Build time autogenerated kernel key
	sig_key:        77:FB:AA:BD:48:78:A4:C6:56:18:9A:7E:A6:F3:29:3E:C5:6B:E9:37
	sig_hashalgo:   sha512
	signature:      30:65:02:31:00:B0:D4:49:9D:1D:F1:71:4C:3C:BB:70:B2:3E:46:5D:
			38:5A:F1:00:95:FD:7A:96:C4:2C:24:35:A2:1B:0B:A8:1C:29:6F:02:
			7A:68:EE:BA:A4:1C:01:4B:86:39:15:3E:66:02:30:7F:7A:66:5E:F2:
			2F:98:73:3D:AD:96:66:81:8B:94:6E:F3:3F:44:0F:85:E1:73:3A:9E:
			F9:C4:BE:9B:88:02:BD:83:04:B9:2E:72:0B:93:BC:82:B6:A1:1B:6A:
			C2:ED:8C
	filename:       /lib/modules/5.15.19-1-MANJARO/kernel/crypto/crc32_generic.ko.zst
	alias:          crypto-crc32-generic
	alias:          crc32-generic
	alias:          crypto-crc32
	alias:          crc32
	license:        GPL
	description:    CRC32 calculations wrapper for lib/crc32
	author:         Alexander Boyko <alexander_boyko@xyratex.com>
	srcversion:     F08036C38DDB06BCD1E6091
	depends:
	retpoline:      Y
	intree:         Y
	name:           crc32_generic
	vermagic:       5.15.19-1-MANJARO SMP preempt mod_unload
	sig_id:         PKCS#7
	signer:         Build time autogenerated kernel key
	sig_key:        77:FB:AA:BD:48:78:A4:C6:56:18:9A:7E:A6:F3:29:3E:C5:6B:E9:37
	sig_hashalgo:   sha512
	signature:      30:65:02:31:00:E3:9E:C8:80:15:0E:D7:74:96:B5:25:EA:32:F7:DF:
			E9:FC:3C:82:D9:B9:B9:37:C5:20:8D:06:31:02:62:B3:54:E8:DF:F2:
			7E:E2:7C:A4:CF:49:17:CB:75:DF:2C:7A:2F:02:30:25:DE:7C:2A:2C:
			97:3F:65:16:76:B3:71:FB:62:DB:8F:F3:33:65:77:98:F3:57:ED:D7:
			87:78:FF:C2:04:55:70:00:10:63:1E:B2:FE:22:D8:E5:6D:5F:95:4E:
			7D:2C:6B

That is because the Linux kernel exports "crc32" as an alias to those modules,
besides being a module itself:

	$ grep crc32 /lib/modules/$(uname -r)/modules.builtin
	kernel/lib/crc32.ko
	$ $ grep "alias crc32 " /lib/modules/$(uname -r)/modules.alias
	alias crc32 crc32_pclmul
	alias crc32 crc32_generic

With the new -m|--modname option it's possible to query the information about this (builtin)
module explicitly:

	$ modinfo --modname crc32
	name:           crc32
	filename:       (builtin)
	license:        GPL
	file:           lib/crc32
	description:    Various CRC32 calculations
	author:         Matt Domsch <Matt_Domsch@dell.com>

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
2022-02-20 20:58:25 -08:00
libkmod libkmod: Add lookup from module name 2022-02-20 20:58:11 -08:00
m4 build: Stop using dolt 2019-02-20 10:38:56 -08:00
man Support /usr/local for configuration files 2021-01-18 18:26:36 -08:00
shared shared: fix UNIQ definition 2020-12-27 16:40:08 -08:00
shell-completion/bash Remove references to systemd from the bash completion file 2014-05-05 01:52:04 -03:00
testsuite test-initstate: Check for negative value on error 2022-02-20 20:58:11 -08:00
tools modinfo: Allow to force arg as module name 2022-02-20 20:58:25 -08:00
.gitignore gitignore: ignore gtk-doc.make 2022-02-20 20:58:11 -08:00
.travis.yml ci: update travis distro 2020-12-03 19:34:04 -08:00
autogen.sh add Zstandard compression support 2020-09-10 21:55:01 -07:00
CODING-STYLE CODING-STYLE: add include order 2015-01-14 12:35:04 -02:00
configure.ac kmod 29 2021-05-20 16:02:57 -07:00
COPYING Clarify what licences apply where 2014-10-09 01:26:34 -03:00
Makefile.am kmod 29 2021-05-20 16:02:57 -07:00
NEWS kmod 29 2021-05-20 16:02:57 -07:00
README README: make github mirror official 2021-01-20 18:52:53 -08:00
README.md README: make github mirror official 2021-01-20 18:52:53 -08:00
TODO libkmod-module: check for NULL before accessing pointers 2018-04-05 14:54:43 -07:00

kmod - Linux kernel module handling

Coverity Scan Status

Information

Mailing list: linux-modules@vger.kernel.org (no subscription needed) https://lore.kernel.org/linux-modules/

Signed packages: http://www.kernel.org/pub/linux/utils/kernel/kmod/

Git: git://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git http://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git

Gitweb: http://git.kernel.org/?p=utils/kernel/kmod/kmod.git https://github.com/kmod-project/kmod

Irc: #kmod on irc.freenode.org

License: LGPLv2.1+ for libkmod, testsuite and helper libraries GPLv2+ for tools/*

OVERVIEW

kmod is a set of tools to handle common tasks with Linux kernel modules like insert, remove, list, check properties, resolve dependencies and aliases.

These tools are designed on top of libkmod, a library that is shipped with kmod. See libkmod/README for more details on this library and how to use it. The aim is to be compatible with tools, configurations and indexes from module-init-tools project.

Compilation and installation

In order to compiler the source code you need following software packages: - GCC compiler - GNU C library

Optional dependencies: - ZLIB library - LZMA library

Typical configuration: ./configure CFLAGS="-g -O2" --prefix=/usr
--sysconfdir=/etc --libdir=/usr/lib

Configure automatically searches for all required components and packages.

To compile and install run: make && make install

Hacking

Run 'autogen.sh' script before configure. If you want to accept the recommended flags, you just need to run 'autogen.sh c'. Note that the recommended flags require cython be installed to compile successfully.

Make sure to read the CODING-STYLE file and the other READMEs: libkmod/README and testsuite/README.

Compatibility with module-init-tools

kmod replaces module-init-tools, which is end-of-life. Most of its tools are rewritten on top of libkmod so it can be used as a drop in replacements. Somethings however were changed. Reasons vary from "the feature was already long deprecated on module-init-tools" to "it would be too much trouble to support it".

There are several features that are being added in kmod, but we don't keep track of them here.

modprobe

  • 'modprobe -l' was marked as deprecated and does not exist anymore

  • 'modprobe -t' is gone, together with 'modprobe -l'

  • modprobe doesn't parse configuration files with names not ending in '.alias' or '.conf'. modprobe used to warn about these files.

  • modprobe doesn't parse 'config' and 'include' commands in configuration files.

  • modprobe from m-i-t does not honour softdeps for install commands. E.g.: config:

      install bli "echo bli"
    

    install bla "echo bla" softdep bla pre: bli

    With m-i-t, the output of 'modprobe --show-depends bla' will be: install "echo bla"

    While with kmod: install "echo bli" install "echo bla"

  • kmod doesn't dump the configuration as is in the config files. Instead it dumps the configuration as it was parsed. Therefore, comments and file names are not dumped, but on the good side we know what the exact configuration kmod is using. We did this because if we only want to know the entire content of configuration files, it's enough to use find(1) in modprobe.d directories

depmod

  • there's no 'depmod -m' option: legacy modules.*map files are gone

lsmod

  • module-init-tools used /proc/modules to parse module info. kmod uses /sys/module/*, but there's a fallback to /proc/modules if the latter isn't available