From 708285f0d2deb7557ad2ce14d85594e88aca369d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Dejean?= Date: Wed, 3 Aug 2005 22:39:17 +0000 Subject: Reworked a bit. Warn on 2.6 without /sys. * open.c: (set_linux_version), (glibtop_open_s): Reworked a bit. Warn on 2.6 without /sys. --- sysdeps/linux/ChangeLog | 7 +++++++ sysdeps/linux/open.c | 33 +++++++++++++++++---------------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog index aabdded4..9a933d5b 100644 --- a/sysdeps/linux/ChangeLog +++ b/sysdeps/linux/ChangeLog @@ -1,3 +1,10 @@ +2005-08-04 Benoît Dejean + + * open.c: (set_linux_version), (glibtop_open_s): + + Reworked a bit. + Warn on 2.6 without /sys. + 2005-08-03 Benoît Dejean * netload.c: (glibtop_get_netload_s): diff --git a/sysdeps/linux/open.c b/sysdeps/linux/open.c index 2db429df..30d245e9 100644 --- a/sysdeps/linux/open.c +++ b/sysdeps/linux/open.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "glibtop_private.h" @@ -33,27 +34,27 @@ */ #include -static unsigned get_linux_version(void) { - - static unsigned linux_version_code = 0; - - if(!linux_version_code) { +static void set_linux_version(glibtop *server) +{ struct utsname uts; unsigned x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */ if (uname(&uts) == -1) /* failure most likely implies impending death */ - exit(1); + glibtop_error_r(server, "uname() failed"); if (sscanf(uts.release, "%u.%u.%u", &x, &y, &z) < 3) - fprintf(stderr, /* *very* unlikely to happen by accident */ - "Non-standard uts for running kernel:\n" - "release %s=%u.%u.%u gives version code %d\n", - uts.release, x, y, z, LINUX_VERSION_CODE(x,y,z)); - - linux_version_code = LINUX_VERSION_CODE(x, y, z); - } - - return linux_version_code; + glibtop_warn_r(server, + "Non-standard uts for running kernel:\n" + "release %s=%u.%u.%u gives version code %d\n", + uts.release, x, y, z, LINUX_VERSION_CODE(x,y,z)); + + if (LINUX_VERSION_CODE(x, y, z) >= LINUX_VERSION_CODE(2, 6, 0) + && !g_file_test("/sys", G_FILE_TEST_IS_DIR)) + glibtop_warn_r(server, + "You're running a 2.6 kernel without /sys." + "You should mount it."); + + server->os_version_code = LINUX_VERSION_CODE(x, y, z); } /* ======================================================= */ @@ -71,7 +72,7 @@ glibtop_open_s (glibtop *server, const char *program_name, server->name = program_name; - server->os_version_code = get_linux_version(); + set_linux_version(server); file_to_buffer(server, buffer, FILENAME); -- cgit v1.2.1