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.
This commit is contained in:
@@ -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>
|
2005-08-03 Benoît Dejean <TazForEver@dlfp.org>
|
||||||
|
|
||||||
* netload.c: (glibtop_get_netload_s):
|
* netload.c: (glibtop_get_netload_s):
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/cpu.h>
|
#include <glibtop/cpu.h>
|
||||||
#include <glibtop/open.h>
|
#include <glibtop/open.h>
|
||||||
|
#include <glibtop/error.h>
|
||||||
|
|
||||||
#include "glibtop_private.h"
|
#include "glibtop_private.h"
|
||||||
|
|
||||||
@@ -33,27 +34,27 @@
|
|||||||
*/
|
*/
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
static unsigned get_linux_version(void) {
|
static void set_linux_version(glibtop *server)
|
||||||
|
{
|
||||||
static unsigned linux_version_code = 0;
|
|
||||||
|
|
||||||
if(!linux_version_code) {
|
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
unsigned x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
|
unsigned x = 0, y = 0, z = 0; /* cleared in case sscanf() < 3 */
|
||||||
|
|
||||||
if (uname(&uts) == -1) /* failure most likely implies impending death */
|
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)
|
if (sscanf(uts.release, "%u.%u.%u", &x, &y, &z) < 3)
|
||||||
fprintf(stderr, /* *very* unlikely to happen by accident */
|
glibtop_warn_r(server,
|
||||||
"Non-standard uts for running kernel:\n"
|
"Non-standard uts for running kernel:\n"
|
||||||
"release %s=%u.%u.%u gives version code %d\n",
|
"release %s=%u.%u.%u gives version code %d\n",
|
||||||
uts.release, x, y, z, LINUX_VERSION_CODE(x,y,z));
|
uts.release, x, y, z, LINUX_VERSION_CODE(x,y,z));
|
||||||
|
|
||||||
linux_version_code = 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.");
|
||||||
|
|
||||||
return linux_version_code;
|
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->name = program_name;
|
||||||
|
|
||||||
server->os_version_code = get_linux_version();
|
set_linux_version(server);
|
||||||
|
|
||||||
file_to_buffer(server, buffer, FILENAME);
|
file_to_buffer(server, buffer, FILENAME);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user