fix compile on OpenBSD and older FreeBSD
This commit is contained in:
parent
26872fdda0
commit
64a6f41925
|
@ -64,7 +64,13 @@
|
||||||
#include "sigar.h"
|
#include "sigar.h"
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
#if defined(__FreeBSD__) || defined(__OpenBSD__)
|
||||||
|
# include <sys/param.h>
|
||||||
|
# include <sys/mount.h>
|
||||||
|
#else
|
||||||
# include <sys/statvfs.h>
|
# include <sys/statvfs.h>
|
||||||
|
# define HAVE_STATVFS
|
||||||
|
#endif
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#define SIGAR_FS_BLOCKS_TO_BYTES(val, bsize) ((val * bsize) >> 1)
|
#define SIGAR_FS_BLOCKS_TO_BYTES(val, bsize) ((val * bsize) >> 1)
|
||||||
|
@ -73,8 +79,9 @@ int sigar_statvfs(sigar_t *sigar,
|
||||||
const char *dirname,
|
const char *dirname,
|
||||||
sigar_file_system_usage_t *fsusage)
|
sigar_file_system_usage_t *fsusage)
|
||||||
{
|
{
|
||||||
struct statvfs buf;
|
|
||||||
sigar_uint64_t val, bsize;
|
sigar_uint64_t val, bsize;
|
||||||
|
#ifdef HAVE_STATVFS
|
||||||
|
struct statvfs buf;
|
||||||
int status =
|
int status =
|
||||||
# if defined(__sun) && !defined(_LP64)
|
# if defined(__sun) && !defined(_LP64)
|
||||||
/* http://bugs.opensolaris.org/view_bug.do?bug_id=4462986 */
|
/* http://bugs.opensolaris.org/view_bug.do?bug_id=4462986 */
|
||||||
|
@ -82,12 +89,20 @@ int sigar_statvfs(sigar_t *sigar,
|
||||||
# else
|
# else
|
||||||
statvfs(dirname, &buf);
|
statvfs(dirname, &buf);
|
||||||
# endif
|
# endif
|
||||||
|
#else
|
||||||
|
struct statfs buf;
|
||||||
|
int status = statfs(dirname, &buf);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_STATVFS
|
||||||
bsize = buf.f_frsize / 512;
|
bsize = buf.f_frsize / 512;
|
||||||
|
#else
|
||||||
|
bsize = buf.f_bsize / 512;
|
||||||
|
#endif
|
||||||
val = buf.f_blocks;
|
val = buf.f_blocks;
|
||||||
fsusage->total = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
fsusage->total = SIGAR_FS_BLOCKS_TO_BYTES(val, bsize);
|
||||||
val = buf.f_bfree;
|
val = buf.f_bfree;
|
||||||
|
|
Loading…
Reference in New Issue