New has_sysfs function to avoid stating over and over '/sys' on each

2006-07-27  Benoît Dejean  <benoit@placenet.org>

        * glibtop_private.c: (has_sysfs):
        * glibtop_private.h:
        * netload.c: (glibtop_get_netload_s):
        * open.c: (set_linux_version):

        New has_sysfs function to avoid stating
        over and over '/sys' on each netload call.
This commit is contained in:
Benoît Dejean
2006-07-27 09:23:32 +00:00
committed by Benoît Dejean
parent 3345ef1704
commit d497c25081
5 changed files with 31 additions and 2 deletions

View File

@@ -163,3 +163,18 @@ check_cpu_line(glibtop *server, const char *line, unsigned i)
return g_str_has_prefix(line, start);
}
gboolean
has_sysfs(void)
{
static gboolean init;
static gboolean sysfs;
if (G_UNLIKELY(!init)) {
sysfs = g_file_test("/sys", G_FILE_TEST_IS_DIR);
init = TRUE;
}
return sysfs;
}