(SIGAR-148) use sigar_statvfs
This commit is contained in:
parent
b53121d071
commit
376409a403
|
@ -1058,7 +1058,6 @@ int sigar_thread_cpu_get(sigar_t *sigar,
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <mntent.h>
|
#include <mntent.h>
|
||||||
#include <sys/statfs.h>
|
|
||||||
|
|
||||||
int sigar_os_fs_type_get(sigar_file_system_t *fsp)
|
int sigar_os_fs_type_get(sigar_file_system_t *fsp)
|
||||||
{
|
{
|
||||||
|
@ -1458,31 +1457,16 @@ int sigar_disk_usage_get(sigar_t *sigar, const char *name,
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
#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;
|
int status = sigar_statvfs(sigar, dirname, fsusage);
|
||||||
sigar_uint64_t val, bsize;
|
|
||||||
|
if (status != SIGAR_OK) {
|
||||||
if (statfs(dirname, &buf) != 0) {
|
return status;
|
||||||
return errno;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
(void)sigar_disk_usage_get(sigar, dirname, &fsusage->disk);
|
(void)sigar_disk_usage_get(sigar, dirname, &fsusage->disk);
|
||||||
|
|
Loading…
Reference in New Issue