Implemented a linux-only fsusage sysdeps.
svn path=/trunk/; revision=2683
This commit is contained in:
@@ -67,6 +67,7 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
|
|||||||
libgtop_have_sysinfo=yes
|
libgtop_have_sysinfo=yes
|
||||||
libgtop_need_server=no
|
libgtop_need_server=no
|
||||||
libgtop_sysdeps_private_mountlist=yes
|
libgtop_sysdeps_private_mountlist=yes
|
||||||
|
libgtop_sysdeps_private_fsusage=yes
|
||||||
;;
|
;;
|
||||||
netbsd*|openbsd*|bsdi*)
|
netbsd*|openbsd*|bsdi*)
|
||||||
libgtop_sysdeps_dir=bsd
|
libgtop_sysdeps_dir=bsd
|
||||||
@@ -320,5 +321,6 @@ main (void)
|
|||||||
|
|
||||||
AM_CONDITIONAL(NEED_LIBGTOP, test x$libgtop_need_server = xyes)
|
AM_CONDITIONAL(NEED_LIBGTOP, test x$libgtop_need_server = xyes)
|
||||||
AM_CONDITIONAL(LIBGTOP_SYSDEPS_PRIVATE_MOUNTLIST, test x$libgtop_sysdeps_private_mountlist = xyes)
|
AM_CONDITIONAL(LIBGTOP_SYSDEPS_PRIVATE_MOUNTLIST, test x$libgtop_sysdeps_private_mountlist = xyes)
|
||||||
|
AM_CONDITIONAL(LIBGTOP_SYSDEPS_PRIVATE_FSUSAGE, test x$libgtop_sysdeps_private_fsusage = xyes)
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ INCLUDES = @INCLUDES@
|
|||||||
noinst_LTLIBRARIES = libgtop_common-2.0.la libgtop_suid_common-2.0.la
|
noinst_LTLIBRARIES = libgtop_common-2.0.la libgtop_suid_common-2.0.la
|
||||||
|
|
||||||
libgtop_common_2_0_la_SOURCES = error.c gnuslib.c \
|
libgtop_common_2_0_la_SOURCES = error.c gnuslib.c \
|
||||||
fsusage.c \
|
|
||||||
procargs.c \
|
procargs.c \
|
||||||
default.c
|
default.c
|
||||||
|
|
||||||
@@ -12,6 +11,10 @@ if !LIBGTOP_SYSDEPS_PRIVATE_MOUNTLIST
|
|||||||
libgtop_common_2_0_la_SOURCES += mountlist.c
|
libgtop_common_2_0_la_SOURCES += mountlist.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if !LIBGTOP_SYSDEPS_PRIVATE_FSUSAGE
|
||||||
|
libgtop_common_2_0_la_SOURCES += fsusage.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
# libgtop_common_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
|
# libgtop_common_2_0_la_LDFLAGS = $(LT_VERSION_INFO)
|
||||||
libgtop_common_2_0_la_LIBADD = $(LIBGTOP_EXTRA_LIBS)
|
libgtop_common_2_0_la_LIBADD = $(LIBGTOP_EXTRA_LIBS)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <glibtop.h>
|
#include <glibtop.h>
|
||||||
#include <glibtop/fsusage.h>
|
#include <glibtop/fsusage.h>
|
||||||
|
#include <glibtop/error.h>
|
||||||
|
|
||||||
#include "glibtop_private.h"
|
#include "glibtop_private.h"
|
||||||
|
|
||||||
@@ -10,15 +11,11 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <linux/kdev_t.h>
|
#include <linux/kdev_t.h>
|
||||||
|
#include <sys/statvfs.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void
|
|
||||||
_glibtop_linux_get_fsusage_read_write(glibtop *server,
|
|
||||||
glibtop_fsusage *buf,
|
|
||||||
const char *path);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Linux 2.6.x
|
* Linux 2.6.x
|
||||||
@@ -127,10 +124,8 @@ static void linux_2_4_0(glibtop *server, glibtop_fsusage *buf, const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
static void
|
||||||
_glibtop_linux_get_fsusage_read_write(glibtop *server,
|
get_fsusage_read_write(glibtop *server, glibtop_fsusage *buf, const char *path)
|
||||||
glibtop_fsusage *buf,
|
|
||||||
const char *path)
|
|
||||||
{
|
{
|
||||||
if(server->os_version_code >= LINUX_VERSION_CODE(2, 6, 0))
|
if(server->os_version_code >= LINUX_VERSION_CODE(2, 6, 0))
|
||||||
{
|
{
|
||||||
@@ -141,3 +136,39 @@ _glibtop_linux_get_fsusage_read_write(glibtop *server,
|
|||||||
linux_2_4_0(server, buf, path);
|
linux_2_4_0(server, buf, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* the following comes from sysdeps/common/mountlist.c if copyright matters...
|
||||||
|
*/
|
||||||
|
|
||||||
|
static const unsigned long _glibtop_sysdeps_fsusage =
|
||||||
|
(1L << GLIBTOP_FSUSAGE_BLOCKS) + (1L << GLIBTOP_FSUSAGE_BFREE)
|
||||||
|
+ (1L << GLIBTOP_FSUSAGE_BAVAIL) + (1L << GLIBTOP_FSUSAGE_FILES)
|
||||||
|
+ (1L << GLIBTOP_FSUSAGE_FFREE) + (1L << GLIBTOP_FSUSAGE_BLOCK_SIZE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
glibtop_get_fsusage_s(glibtop *server, glibtop_fsusage *buf, const char *path)
|
||||||
|
{
|
||||||
|
struct statvfs fsd;
|
||||||
|
|
||||||
|
glibtop_init_r(&server, 0, 0);
|
||||||
|
memset(buf, 0, sizeof(glibtop_fsusage));
|
||||||
|
|
||||||
|
if (statvfs(path, &fsd) < 0) {
|
||||||
|
glibtop_warn_r(server, "statvfs '%s' failed", path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf->blocks = fsd.f_blocks;
|
||||||
|
buf->bfree = fsd.f_bfree;
|
||||||
|
buf->bavail = (fsd.f_bavail > fsd.f_bfree) ? 0 : fsd.f_bavail;
|
||||||
|
buf->files = fsd.f_files;
|
||||||
|
buf->ffree = fsd.f_ffree;
|
||||||
|
buf->block_size = fsd.f_bsize;
|
||||||
|
buf->flags = _glibtop_sysdeps_fsusage;
|
||||||
|
|
||||||
|
/* setting additional flags is delegated */
|
||||||
|
get_fsusage_read_write(server, buf, path);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user