diff options
author | Benoît Dejean <bdejean@src.gnome.org> | 2004-09-19 21:02:10 +0000 |
---|---|---|
committer | Benoît Dejean <bdejean@src.gnome.org> | 2004-09-19 21:02:10 +0000 |
commit | 601cfef32f45082a567ea976a40c70445e573af6 (patch) | |
tree | 83ef584c27df3790e252561baddaf1862a6f9b18 /sysdeps | |
parent | 86fd7f23c45822df3833f80a6c0af080cb969f8d (diff) | |
download | libgtop-601cfef32f45082a567ea976a40c70445e573af6.tar.gz |
: 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.
Diffstat (limited to 'sysdeps')
-rw-r--r-- | sysdeps/common/ChangeLog | 16 | ||||
-rw-r--r-- | sysdeps/common/fsusage.c | 33 | ||||
-rw-r--r-- | sysdeps/common/mountlist.c | 15 |
3 files changed, 46 insertions, 18 deletions
diff --git a/sysdeps/common/ChangeLog b/sysdeps/common/ChangeLog index ad6c9da6..f1e6a31c 100644 --- a/sysdeps/common/ChangeLog +++ b/sysdeps/common/ChangeLog @@ -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> * mountlist.c: (read_filesystem_list): Merged FreeBSD Marcus' patch. diff --git a/sysdeps/common/fsusage.c b/sysdeps/common/fsusage.c index b680afc8..0da0cf52 100644 --- a/sysdeps/common/fsusage.c +++ b/sysdeps/common/fsusage.c @@ -108,6 +108,8 @@ static const unsigned long _glibtop_sysdeps_fsusage = + (1L << GLIBTOP_FSUSAGE_BAVAIL) + (1L << GLIBTOP_FSUSAGE_FILES) + (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. * These functions are private. * - * void _glibtop_<arch>_get_fsusage_read_write(glibtop*server, - * glibtop_fsusage *buf, - * const char *path); + * gboolean _glibtop_<arch>_get_fsusage_read_write(glibtop*server, + * glibtop_fsusage *buf, + * const char *path); * * TODO: split this file properly, is possible */ #ifdef linux -void _glibtop_linux_get_fsusage_read_write(glibtop *server, - glibtop_fsusage *buf, - const char *path); +gboolean _glibtop_linux_get_fsusage_read_write(glibtop *server, + glibtop_fsusage *buf, + const char *path); #define _glibtop_get_fsusage_read_write(S, B, P) \ _glibtop_linux_get_fsusage_read_write(S, B, P) #else /* default fallback */ #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 /* end _glibtop_get_fsusage_read_write */ @@ -147,7 +155,7 @@ void glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, const char *path) { -#if defined STAT_STATFS3_OSF1 +#if defined STAT_STATFS3_OSF1 struct statfs fsd; #elif defined STAT_STATFS2_FS_DATA /* Ultrix */ struct fs_data fsd; @@ -165,8 +173,6 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, memset (buf, 0, sizeof (glibtop_fsusage)); - _glibtop_get_fsusage_read_write(server, buf, path); - #ifdef STAT_STATFS3_OSF1 if (statfs (path, &fsd, sizeof (struct statfs)) != 0) @@ -245,6 +251,7 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, #endif /* STAT_STATFS4 */ #ifdef STAT_STATVFS /* SVR4 */ + /* Linux */ if (statvfs (path, &fsd) < 0) return; @@ -258,6 +265,7 @@ glibtop_get_fsusage_s (glibtop *server, glibtop_fsusage *buf, #if !defined STAT_STATFS2_FS_DATA && !defined STAT_READ_FILSYS /* !Ultrix && !SVR2 */ + /* Linux */ buf->blocks = PROPAGATE_ALL_ONES (fsd.f_blocks); 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 */ - 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 diff --git a/sysdeps/common/mountlist.c b/sysdeps/common/mountlist.c index 2b769843..0d1e44a7 100644 --- a/sysdeps/common/mountlist.c +++ b/sysdeps/common/mountlist.c @@ -33,7 +33,7 @@ #include <glibtop.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 #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. 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 * -read_filesystem_list (gboolean need_fs_type) +read_filesystem_list (void) { struct mount_entry *mount_list; struct mount_entry *me; @@ -396,9 +394,8 @@ read_filesystem_list (gboolean need_fs_type) #endif me->me_mountdir = g_strdup (mnt.mt_filsys); me->me_dev = (dev_t) -1; /* Magic; means not known yet. */ - me->me_type = g_strdup (""); + #ifdef GETFSTYP /* SVR3. */ - if (need_fs_type) { struct statfs fsd; char typebuf[FSTYPSZ]; @@ -407,7 +404,10 @@ read_filesystem_list (gboolean need_fs_type) && sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1) me->me_type = g_strdup (typebuf); } +#else + me->me_type = g_strdup (""); #endif + me->me_next = NULL; /* Add to the linked list. */ @@ -530,6 +530,7 @@ static gboolean ignore_mount_entry(const struct mount_entry *me) "procfs", "autofs", "sysfs", + "usbfs", "none", "devpts", "usbdevfs", @@ -563,7 +564,7 @@ glibtop_get_mountlist_s (glibtop *server, glibtop_mountlist *buf, int all_fs) /* Read filesystem list. */ - if((entries = read_filesystem_list (TRUE)) == NULL) + if((entries = read_filesystem_list ()) == NULL) return NULL; for (cur = &entries[0]; cur != NULL; cur = next) { |