(SIGAR-148) use sigar_statvfs
This commit is contained in:
parent
94b3f884a2
commit
b53121d071
|
@ -1352,8 +1352,6 @@ int sigar_file_system_list_get(sigar_t *sigar,
|
||||||
return SIGAR_OK;
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <sys/statvfs.h>
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char device[PATH_MAX];
|
char device[PATH_MAX];
|
||||||
char name[8];
|
char name[8];
|
||||||
|
@ -1716,29 +1714,16 @@ int sigar_disk_usage_get(sigar_t *sigar, const char *name,
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
#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 statvfs buf;
|
int status = sigar_statvfs(sigar, dirname, fsusage);
|
||||||
sigar_uint64_t val, bsize;
|
|
||||||
|
|
||||||
if (statvfs(dirname, &buf) != 0) {
|
if (status != SIGAR_OK) {
|
||||||
return errno;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
bsize = buf.f_frsize / 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_usage_get(sigar, dirname, &fsusage->disk);
|
sigar_disk_usage_get(sigar, dirname, &fsusage->disk);
|
||||||
|
|
Loading…
Reference in New Issue