I have seen posts like this on StackOverflow which talk about using uname()
to get the current Kernel version number (stored in utsname.release). However that returns a string.
Is there a way to return the or check the Kernel version as a numerical value so that one can simply use if (version >= min_req_ver) { ... }
?
The only method I have seen is to include linux/version.h
and check LINUX_VERSION_CODE
however in CentOS for example, this version number is not updated when one runs a newer Kernel than the default. The uname()
function however does report the correct current Kernel version across Linux distros (on the ones I have tested) including in scenario such as using CentOS with a newer Kernel.