Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

modinfo srcversion: How do I generate this from my source?

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?

like image 229
Ryley Avatar asked Aug 12 '10 16:08

Ryley


People also ask

How do I view a .KO file?

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.

How do I find my kernel modules?

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.

What does Modinfo command do?

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.

How do I find loaded modules in Linux?

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.


1 Answers

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.

like image 82
Longfield Avatar answered Sep 27 '22 22:09

Longfield