Add support for linux x.y versioning schema

Since linux 3.0, a valid version can have two digits

Signed-off-by: Ionut Biru <ibiru@archlinux.org>
This commit is contained in:
Ionut Biru
2011-10-22 21:58:30 +03:00
committed by Benoît Dejean
parent 0580b2fb2c
commit fcc1d9d957

View File

@@ -37,11 +37,15 @@ static void set_linux_version(glibtop *server)
{
struct utsname uts;
unsigned x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
int version_string_depth;
if (uname(&uts) == -1) /* failure most likely implies impending death */
glibtop_error_r(server, "uname() failed");
if (sscanf(uts.release, "%u.%u.%u", &x, &y, &z) < 3)
version_string_depth = sscanf(uts.release, "%d.%d.%d", &x, &y, &z);
if ((version_string_depth < 2) || /* Non-standard for all known kernels */
((version_string_depth < 3) && (x < 3))) /* Non-standard for 2.x.x kernels */
glibtop_warn_r(server,
"Non-standard uts for running kernel:\n"
"release %s=%u.%u.%u gives version code %d\n",