9 #include <sys/sysinfo.h>
13 #include <mach/mach.h>
17 #include <sys/param.h>
18 #include <sys/mount.h>
23 #include <QStringList>
31 #define NEXT_STR() do { if (it == listend) \
33 LOG(VB_GENERAL, LOG_ALERT, listerror); \
37 ts = *it++; } while (false)
45 int fsid,
int groupid,
int blksize, int64_t total, int64_t used) :
46 m_hostname(std::move(
hostname)), m_path(std::move(path)), m_local(local), m_fsid(fsid),
47 m_grpid(groupid), m_blksize(blksize), m_total(total), m_used(used)
52 const QStringList::const_iterator& end)
101 list << QString::number(
m_local);
102 list << QString::number(
m_fsid);
103 list << QString::number(
m_grpid);
105 list << QString::number(
m_total);
106 list << QString::number(
m_used);
113 QStringList::const_iterator it = slist.constBegin();
118 const QStringList::const_iterator& listend)
120 QString listerror =
"FileSystemInfo: FromStringList, not enough items in list.";
140 QList<FileSystemInfo> fsInfos;
141 QStringList strlist(QString(
"QUERY_FREE_SPACE_LIST"));
154 QStringList::const_iterator it = strlist.cbegin();
155 for (
int i = 0; i < numdisks; i++)
158 fsInfos.append(fsInfo);
166 bool merge, int64_t fuzz)
170 for (
auto it1 = disks.begin(); it1 != disks.end(); ++it1)
172 if (it1->getFSysID() == -1)
174 it1->setFSysID(newid++);
176 it1->setPath(it1->getHostname().section(
".", 0, 0)
177 +
":" + it1->getPath());
180 for (
auto it2 = it1+1; it2 != disks.end(); ++it2)
182 if (it2->getFSysID() != -1)
185 int bSize = std::max(32, std::max(it1->getBlockSize(), it2->getBlockSize())
187 int64_t diffSize = it1->getTotalSpace() - it2->getTotalSpace();
188 int64_t diffUsed = it1->getUsedSpace() - it2->getUsedSpace();
191 diffSize = 0 - diffSize;
193 diffUsed = 0 - diffUsed;
195 if ((diffSize <= bSize) && (diffUsed <= fuzz))
197 it2->setFSysID(it1->getFSysID());
201 if (!it1->getHostname().contains(it2->getHostname()))
202 it1->setHostname(it1->getHostname()
203 +
"," + it2->getHostname());
204 it1->setPath(it1->getPath() +
","
205 + it2->getHostname().section(
".", 0, 0) +
":"
228 if (
statfs(
getPath().toLocal8Bit().constData(), &statbuf) == 0)
231 char *fstypename = statbuf.f_fstypename;
232 if ((!strcmp(fstypename,
"nfs")) ||
233 (!strcmp(fstypename,
"afpfs")) ||
234 (!strcmp(fstypename,
"smbfs")))
236 #elif defined(__linux__)
237 long fstype = statbuf.f_type;
238 if ((fstype == 0x6969) ||
239 (fstype == 0x517B) ||
240 (fstype == (
long)0xFF534D42))