summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoît Dejean <bdejean@src.gnome.org>2005-08-03 22:39:17 +0000
committerBenoît Dejean <bdejean@src.gnome.org>2005-08-03 22:39:17 +0000
commit708285f0d2deb7557ad2ce14d85594e88aca369d (patch)
treec835f0b6ea21e386a3c0ec97a815d9c4296bf731
parenta0493a0ff181b950c94e6475ccb6aed512a770e4 (diff)
downloadlibgtop-708285f0d2deb7557ad2ce14d85594e88aca369d.tar.gz
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.
-rw-r--r--sysdeps/linux/ChangeLog7
-rw-r--r--sysdeps/linux/open.c33
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 <TazForEver@dlfp.org>
+
+ * open.c: (set_linux_version), (glibtop_open_s):
+
+ Reworked a bit.
+ Warn on 2.6 without /sys.
+
2005-08-03 Benoît Dejean <TazForEver@dlfp.org>
* 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 <glibtop.h>
#include <glibtop/cpu.h>
#include <glibtop/open.h>
+#include <glibtop/error.h>
#include "glibtop_private.h"
@@ -33,27 +34,27 @@
*/
#include <sys/utsname.h>
-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);