#include "zbxsysinfo.h"
#include "../sysinfo.h"
#include "inodes.h"
#include "zbxjson.h"
#include "zbxalgo.h"
static zbx_mntopt_t mntopts[] = {
{MNT_ASYNC, "asynchronous"},
#if defined(MNT_AUTOMOUNTED)
{MNT_AUTOMOUNTED, "automounted"},
#endif
#if defined(MNT_DISCARD)
{MNT_DISCARD, "discard"},
#endif
#if defined(MNT_EXTATTR)
{MNT_EXTATTR, "extattr"},
#endif
{MNT_IGNORE, "hidden"},
{MNT_LOG, "log"},
{MNT_NOATIME, "noatime"},
{MNT_NOCOREDUMP, "nocoredump"},
{MNT_NODEV, "nodev"},
{MNT_NODEVMTIME, "nodevmtime"},
{MNT_NOEXEC, "noexec"},
{MNT_NOSUID, "nosuid"},
{MNT_RDONLY, "read-only"},
#if defined(MNT_RELATIME)
{MNT_RELATIME, "relatime"},
#endif
{MNT_SOFTDEP, "soft dependencies"},
#if defined(MNT_SYMPERM)
{MNT_SYMPERM, "symperm"},
#endif
{MNT_SYNCHRONOUS, "synchronous"},
{MNT_UNION, "union"},
{MNT_EXPORTED, "NFS exported"},
{MNT_EXNORESPORT, "non-reserved ports"},
{MNT_EXPUBLIC, "WebNFS exports"},
{MNT_LOCAL, "local"},
{MNT_QUOTA, "with quotas"},
{0, NULL},
};
static int get_fs_size_stat(const char *fs, zbx_uint64_t *total, zbx_uint64_t *free,
zbx_uint64_t *used, double *pfree, double *pused, char **error)
{
#ifdef HAVE_SYS_STATVFS_H
# define ZBX_STATFS statvfs
# define ZBX_BSIZE f_frsize
#else
# define ZBX_STATFS statfs
# define ZBX_BSIZE f_bsize
#endif
struct ZBX_STATFS s;
if (0 != ZBX_STATFS(fs, &s))
{
*error = zbx_dsprintf(NULL, "Cannot obtain filesystem information: %s", zbx_strerror(errno));
zabbix_log(LOG_LEVEL_DEBUG,"%s failed with error: %s",__func__, *error);
return SYSINFO_RET_FAIL;
}
if (0 != ZBX_IS_TOP_BIT_SET(s.f_bavail))
s.f_bavail = 0;
if (NULL != total)
*total = (zbx_uint64_t)s.f_blocks * s.ZBX_BSIZE;
if (NULL != free)
*free = (zbx_uint64_t)s.f_bavail * s.ZBX_BSIZE;
if (NULL != used)
*used = (zbx_uint64_t)(s.f_blocks - s.f_bfree) * s.ZBX_BSIZE;