Merge branch 'SIGAR-148' into sigar-1.6

This commit is contained in:
Doug MacEachern 2009-07-01 16:27:45 -07:00
commit 46427ad949
2 changed files with 8 additions and 38 deletions

View File

@ -1262,10 +1262,6 @@ int sigar_disk_usage_get(sigar_t *sigar, const char *name,
return SIGAR_OK; return SIGAR_OK;
} }
/* XXX this is exactly the same as linux and hpux, solaris is darn close */
#define SIGAR_FS_BLOCKS_TO_BYTES(val, bsize) ((val * bsize) >> 1)
int sigar_file_system_usage_get(sigar_t *sigar, int sigar_file_system_usage_get(sigar_t *sigar,
const char *dirname, const char *dirname,
sigar_file_system_usage_t *fsusage) sigar_file_system_usage_t *fsusage)
@ -1273,23 +1269,13 @@ int sigar_file_system_usage_get(sigar_t *sigar,
sigar_cache_entry_t *ent; sigar_cache_entry_t *ent;
struct stat sb; struct stat sb;
int status; int status;
struct statfs buf;
sigar_uint64_t val, bsize;
if (statfs((char *)dirname, &buf) != 0) { status = sigar_statvfs(sigar, dirname, fsusage);
return errno;
if (status != SIGAR_OK) {
return status;
} }
bsize = buf.f_bsize / 512;
val = buf.f_blocks;
fsusage->total = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
val = buf.f_bfree;
fsusage->free = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
val = buf.f_bavail;
fsusage->avail = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
fsusage->used = fsusage->total - fsusage->free;
fsusage->files = buf.f_files;
fsusage->free_files = buf.f_ffree;
fsusage->use_percent = sigar_file_system_usage_calc_used(sigar, fsusage); fsusage->use_percent = sigar_file_system_usage_calc_used(sigar, fsusage);
SIGAR_DISK_STATS_INIT(&fsusage->disk); SIGAR_DISK_STATS_INIT(&fsusage->disk);

View File

@ -639,33 +639,17 @@ int sigar_disk_usage_get(sigar_t *sigar, const char *name,
return SIGAR_ENOTIMPL; return SIGAR_ENOTIMPL;
} }
/* XXX this is exactly the same as linux and solaris is darn close */
#include <sys/vfs.h>
#define SIGAR_FS_BLOCKS_TO_BYTES(val, bsize) ((val * bsize) >> 1)
int sigar_file_system_usage_get(sigar_t *sigar, int sigar_file_system_usage_get(sigar_t *sigar,
const char *dirname, const char *dirname,
sigar_file_system_usage_t *fsusage) sigar_file_system_usage_t *fsusage)
{ {
struct statfs buf;
struct stat sb; struct stat sb;
sigar_uint64_t val, bsize; int status = sigar_statvfs(sigar, dirname, fsusage);
if (statfs(dirname, &buf) != 0) { if (status != SIGAR_OK) {
return errno; return status;
} }
bsize = buf.f_bsize / 512;
val = buf.f_blocks;
fsusage->total = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
val = buf.f_bfree;
fsusage->free = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
val = buf.f_bavail;
fsusage->avail = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
fsusage->used = fsusage->total - fsusage->free;
fsusage->files = buf.f_files;
fsusage->free_files = buf.f_ffree;
fsusage->use_percent = sigar_file_system_usage_calc_used(sigar, fsusage); fsusage->use_percent = sigar_file_system_usage_calc_used(sigar, fsusage);
SIGAR_DISK_STATS_INIT(&fsusage->disk); SIGAR_DISK_STATS_INIT(&fsusage->disk);