: Added new flag. (_glibtop_get_fsusage_read_write): Changed prototype.

* fsusage.c: (_glibtop_get_fsusage_read_write) : Added new flag.
	(_glibtop_get_fsusage_read_write): Changed prototype. Returns TRUE on
	success, then _glibtop_get_fsusage_read_write is set.

	Added comment to locate Linux code.

	* mountlist.c: (read_filesystem_list): Dropped unused need_fs_type parameter.
	This is now default.
	Fixed possible leak.

	(ignore_mount_entry): Added "usbfs" to ignored FS.

	(glibtop_get_mountlist_s): Updated.
This commit is contained in:
Benoît Dejean
2004-09-19 21:02:10 +00:00
parent 86fd7f23c4
commit 601cfef32f
3 changed files with 46 additions and 18 deletions

View File

@@ -1,3 +1,19 @@
2004-09-19 Benoît Dejean <tazforever@dlfp.org>
* fsusage.c: (_glibtop_get_fsusage_read_write) : Added new flag.
(_glibtop_get_fsusage_read_write): Changed prototype. Returns TRUE on
success, then _glibtop_get_fsusage_read_write is set.
Added comment to locate Linux code.
* mountlist.c: (read_filesystem_list): Dropped unused need_fs_type parameter.
This is now default.
Fixed possible leak.
(ignore_mount_entry): Added "usbfs" to ignored FS.
(glibtop_get_mountlist_s): Updated.
2004-08-22 Benoît Dejean <tazforever@dlfp.org> 2004-08-22 Benoît Dejean <tazforever@dlfp.org>
* mountlist.c: (read_filesystem_list): Merged FreeBSD Marcus' patch. * mountlist.c: (read_filesystem_list): Merged FreeBSD Marcus' patch.

View File

@@ -108,6 +108,8 @@ static const unsigned long _glibtop_sysdeps_fsusage =
+ (1L << GLIBTOP_FSUSAGE_BAVAIL) + (1L << GLIBTOP_FSUSAGE_FILES) + (1L << GLIBTOP_FSUSAGE_BAVAIL) + (1L << GLIBTOP_FSUSAGE_FILES)
+ (1L << GLIBTOP_FSUSAGE_FFREE) + (1L << GLIBTOP_FSUSAGE_BLOCK_SIZE); + (1L << GLIBTOP_FSUSAGE_FFREE) + (1L << GLIBTOP_FSUSAGE_BLOCK_SIZE);
static const unsigned long _glibtop_sysdeps_fsusage_read_write =
(1L << GLIBTOP_FSUSAGE_READ) + (1L << GLIBTOP_FSUSAGE_WRITE);
/* /*
@@ -119,24 +121,30 @@ static const unsigned long _glibtop_sysdeps_fsusage =
* function full of #something where everything is mixed. * function full of #something where everything is mixed.
* These functions are private. * These functions are private.
* *
* void _glibtop_<arch>_get_fsusage_read_write(glibtop*server, * gboolean _glibtop_<arch>_get_fsusage_read_write(glibtop*server,
* glibtop_fsusage *buf, * glibtop_fsusage *buf,
* const char *path); * const char *path);
* *
* TODO: split this file properly, is possible * TODO: split this file properly, is possible
*/ */
#ifdef linux #ifdef linux
void _glibtop_linux_get_fsusage_read_write(glibtop *server, gboolean _glibtop_linux_get_fsusage_read_write(glibtop *server,
glibtop_fsusage *buf, glibtop_fsusage *buf,
const char *path); const char *path);
#define _glibtop_get_fsusage_read_write(S, B, P) \ #define _glibtop_get_fsusage_read_write(S, B, P) \
_glibtop_linux_get_fsusage_read_write(S, B, P) _glibtop_linux_get_fsusage_read_write(S, B, P)
#else /* default fallback */ #else /* default fallback */
#warning glibtop_get_fsusage .read .write are not implemented. #warning glibtop_get_fsusage .read .write are not implemented.
#define _glibtop_get_fsusage_read_write(S, B, P) ((void)0) static inline gboolean
_glibtop_get_fsusage_read_write(glibtop *server,
glibtop_fsusage *buf,
const char *path)
{
return FALSE;
}
#endif #endif
/* end _glibtop_get_fsusage_read_write */ /* end _glibtop_get_fsusage_read_write */
@@ -147,7 +155,7 @@ void
glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf,
const char *path) const char *path)
{ {
#if defined STAT_STATFS3_OSF1 #if defined STAT_STATFS3_OSF1
struct statfs fsd; struct statfs fsd;
#elif defined STAT_STATFS2_FS_DATA /* Ultrix */ #elif defined STAT_STATFS2_FS_DATA /* Ultrix */
struct fs_data fsd; struct fs_data fsd;
@@ -165,8 +173,6 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf,
memset (buf, 0, sizeof (glibtop_fsusage)); memset (buf, 0, sizeof (glibtop_fsusage));
_glibtop_get_fsusage_read_write(server, buf, path);
#ifdef STAT_STATFS3_OSF1 #ifdef STAT_STATFS3_OSF1
if (statfs (path, &fsd, sizeof (struct statfs)) != 0) if (statfs (path, &fsd, sizeof (struct statfs)) != 0)
@@ -245,6 +251,7 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf,
#endif /* STAT_STATFS4 */ #endif /* STAT_STATFS4 */
#ifdef STAT_STATVFS /* SVR4 */ #ifdef STAT_STATVFS /* SVR4 */
/* Linux */
if (statvfs (path, &fsd) < 0) if (statvfs (path, &fsd) < 0)
return; return;
@@ -258,6 +265,7 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf,
#if !defined STAT_STATFS2_FS_DATA && !defined STAT_READ_FILSYS #if !defined STAT_STATFS2_FS_DATA && !defined STAT_READ_FILSYS
/* !Ultrix && !SVR2 */ /* !Ultrix && !SVR2 */
/* Linux */
buf->blocks = PROPAGATE_ALL_ONES (fsd.f_blocks); buf->blocks = PROPAGATE_ALL_ONES (fsd.f_blocks);
buf->bfree = PROPAGATE_ALL_ONES (fsd.f_bfree); buf->bfree = PROPAGATE_ALL_ONES (fsd.f_bfree);
@@ -268,7 +276,10 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf,
#endif /* not STAT_STATFS2_FS_DATA && not STAT_READ_FILSYS */ #endif /* not STAT_STATFS2_FS_DATA && not STAT_READ_FILSYS */
buf->flags= _glibtop_sysdeps_fsusage; buf->flags = _glibtop_sysdeps_fsusage;
if(_glibtop_get_fsusage_read_write(server, buf, path))
buf->flags |= _glibtop_sysdeps_fsusage_read_write;
} }
#if defined _AIX && defined _I386 #if defined _AIX && defined _I386

View File

@@ -33,7 +33,7 @@
#include <glibtop.h> #include <glibtop.h>
#include <glibtop/mountlist.h> #include <glibtop/mountlist.h>
static struct mount_entry *read_filesystem_list (gboolean need_fs_type); static struct mount_entry *read_filesystem_list (void);
#ifdef HAVE_SYS_PARAM_H #ifdef HAVE_SYS_PARAM_H
#include <sys/param.h> #include <sys/param.h>
@@ -207,12 +207,10 @@ fstype_to_string (int t)
/* Return a list of the currently mounted filesystems, or NULL on error. /* Return a list of the currently mounted filesystems, or NULL on error.
Add each entry to the tail of the list so that they stay in order. Add each entry to the tail of the list so that they stay in order.
If NEED_FS_TYPE is nonzero, ensure that the filesystem type fields in
the returned list are valid. Otherwise, they might not be.
*/ */
static struct mount_entry * static struct mount_entry *
read_filesystem_list (gboolean need_fs_type) read_filesystem_list (void)
{ {
struct mount_entry *mount_list; struct mount_entry *mount_list;
struct mount_entry *me; struct mount_entry *me;
@@ -396,9 +394,8 @@ read_filesystem_list (gboolean need_fs_type)
#endif #endif
me->me_mountdir = g_strdup (mnt.mt_filsys); me->me_mountdir = g_strdup (mnt.mt_filsys);
me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ me->me_dev = (dev_t) -1; /* Magic; means not known yet. */
me->me_type = g_strdup ("");
#ifdef GETFSTYP /* SVR3. */ #ifdef GETFSTYP /* SVR3. */
if (need_fs_type)
{ {
struct statfs fsd; struct statfs fsd;
char typebuf[FSTYPSZ]; char typebuf[FSTYPSZ];
@@ -407,7 +404,10 @@ read_filesystem_list (gboolean need_fs_type)
&& sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1) && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
me->me_type = g_strdup (typebuf); me->me_type = g_strdup (typebuf);
} }
#else
me->me_type = g_strdup ("");
#endif #endif
me->me_next = NULL; me->me_next = NULL;
/* Add to the linked list. */ /* Add to the linked list. */
@@ -530,6 +530,7 @@ static gboolean ignore_mount_entry(const struct mount_entry *me)
"procfs", "procfs",
"autofs", "autofs",
"sysfs", "sysfs",
"usbfs",
"none", "none",
"devpts", "devpts",
"usbdevfs", "usbdevfs",
@@ -563,7 +564,7 @@ glibtop_get_mountlist_s (glibtop *server, glibtop_mountlist *buf, int all_fs)
/* Read filesystem list. */ /* Read filesystem list. */
if((entries = read_filesystem_list (TRUE)) == NULL) if((entries = read_filesystem_list ()) == NULL)
return NULL; return NULL;
for (cur = &entries[0]; cur != NULL; cur = next) { for (cur = &entries[0]; cur != NULL; cur = next) {