I have a compiled version of a linux module, and then I have about 20+ variations of its source. Through various foolish mistakes, I've lost track of which version of the source was the actual one I used to make the module.
I noticed that modinfo <module name>
gives srcversion: <hash>
, and I found some explanation somewhere that says its the "Sum of the source that produced the module". Sounds perfect!
What do I do to my module sources to produce this hash?
ko files located in /lib/modules/… directory) in a Linux cloud server or desktop machine? You need to use the modinfo command to display information about a Linux Kernel module.
You need to use modinfo command to display or show information about a Linux Kernel loaded modules. Use the lsmod command to obtain list of loaded modules in the Linux kernel.
Description. The modinfo command extracts information from the Linux kernel modules given on the command line. If module name is not a file name, then the /lib/modules/kernel-version directory is searched — the same directory searched by modprobe when loading kernel modules.
To list all currently loaded modules in Linux, we can use the lsmod (list modules) command which reads the contents of /proc/modules like this.
The srcversion
is defined by the scripts/mod/modpost
program. I don't know the exact options that you have to give to modpost so that it outputs this field. It must be something similar to scripts/mod/modpost -a -m vmlinux you_module.o
(you can look at scripts/Makefile.modpost
for the exact options). The output is then available in drivers/path/to/your_module.mod.c
I recommend that you set the config MODULE_SRCVERSION_ALL
to y (available in the Enable loadable module support
submenu), so that srcversion is automatically produced for all the modules of your build. You can then switch between you variations of the source, rebuild your kernel with the new source variation (only your module should be rebuilt after the first build) and then directly look at the MODULE_INFO(srcversion, "<hash>");
field at the end of your drivers/path/to/your_module.mod.c
file to find the requested info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With