I maintains a test suites which need run in Linux kernel, so I have to adapt the code to many Linux systems Ubuntu 18.04/20.04/22.04, CentOS7/CentOS8, terrible work
Here is an example
memset(wlData, 0, fileStat.size);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0)
ret = kernel_read(fp, wlData, fileStat.size, &pos);
#else
ret = kernel_read(fp, pos, wlData, fileStat.size);
#endif
if (ret < 0 || ret != fileStat.size) {
printk("Read file failure\n");
goto err1;
}
So how can I exactly figure out from which Linux kernel version the interface kernel_read() changes it’s interface?
Currently I just run the test suite on a special Linux system for example Ubuntu 18.04, when compile failed I check the Linux kernel version of this Linux system, and added upper macro … I don’t think this a solution, it’s just a workaround …
Just looking at the kernel version is sub-optimal since distros pick commits from other kernel versions. For example, a distro could decide that they need this for whatever reason in an older kernel so that version check would be incorrect.
Maybe you could query Module.symvers at runtime but I’m not sure how reliable that information is.
Thanks for your tips, I realise the Linux project is maintained on github.com where I visit frequently, I used to think the Linux project might be periodically published on website linux.com or linux.org…
Now I can figure out the exactly kernel version from which the kernel interfaces/structures changed, thank you !