(SIGAR-148) use sigar_statvfs

This commit is contained in:
Doug MacEachern 2009-07-01 14:29:20 -07:00
parent 621f9ccb61
commit d3d35e937f
1 changed files with 3 additions and 14 deletions

View File

@ -2202,23 +2202,12 @@ 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 sigar_statfs buf; int status = sigar_statvfs(sigar, dirname, fsusage);
sigar_uint64_t val, bsize;
if (sigar_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);
#if defined(__FreeBSD__) #if defined(__FreeBSD__)