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?
The
srcversionis defined by thescripts/mod/modpostprogram. 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 toscripts/mod/modpost -a -m vmlinux you_module.o(you can look atscripts/Makefile.modpostfor the exact options). The output is then available indrivers/path/to/your_module.mod.cI recommend that you set the
config MODULE_SRCVERSION_ALLto y (available in theEnable loadable module supportsubmenu), 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 theMODULE_INFO(srcversion, "<hash>");field at the end of yourdrivers/path/to/your_module.mod.cfile to find the requested info.