Merge branch 'SIGAR-148' into sigar-1.6
This commit is contained in:
commit
d29ef6d6ac
|
@ -2192,8 +2192,22 @@ int sigar_disk_usage_get(sigar_t *sigar, const char *name,
|
|||
IOObjectRelease(service);
|
||||
IOObjectRelease(parent);
|
||||
|
||||
return SIGAR_OK;
|
||||
#elif defined(__FreeBSD__)
|
||||
/* XXX incomplete */
|
||||
struct sigar_statfs buf;
|
||||
|
||||
if (sigar_statfs(name, &buf) < 0) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
SIGAR_DISK_STATS_INIT(disk);
|
||||
|
||||
disk->reads = buf.f_syncreads + buf.f_asyncreads;
|
||||
disk->writes = buf.f_syncwrites + buf.f_asyncwrites;
|
||||
return SIGAR_OK;
|
||||
#else
|
||||
SIGAR_DISK_STATS_INIT(disk);
|
||||
return SIGAR_ENOTIMPL;
|
||||
#endif
|
||||
}
|
||||
|
@ -2202,36 +2216,15 @@ int sigar_file_system_usage_get(sigar_t *sigar,
|
|||
const char *dirname,
|
||||
sigar_file_system_usage_t *fsusage)
|
||||
{
|
||||
struct sigar_statfs buf;
|
||||
sigar_uint64_t val, bsize;
|
||||
int status = sigar_statvfs(sigar, dirname, fsusage);
|
||||
|
||||
if (sigar_statfs(dirname, &buf) < 0) {
|
||||
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);
|
||||
|
||||
#if defined(__FreeBSD__)
|
||||
fsusage->disk_reads = buf.f_syncreads + buf.f_asyncreads;
|
||||
fsusage->disk_writes = buf.f_syncwrites + buf.f_asyncwrites;
|
||||
fsusage->disk_read_bytes = SIGAR_FIELD_NOTIMPL;
|
||||
fsusage->disk_write_bytes = SIGAR_FIELD_NOTIMPL;
|
||||
fsusage->disk_queue = SIGAR_FIELD_NOTIMPL;
|
||||
#elif defined(DARWIN)
|
||||
sigar_disk_usage_get(sigar, dirname, &fsusage->disk);
|
||||
#else
|
||||
SIGAR_DISK_STATS_INIT(&fsusage->disk);
|
||||
#endif
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue