partitionmanager: implement used capacity for ZFS

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2021-11-16 20:46:12 +02:00
parent 057106bf68
commit 978fa4d01f
2 changed files with 26 additions and 1 deletions

View file

@ -49,6 +49,7 @@ namespace FS
{ {
m_SetLabel = findExternal("zpool", QStringList(), 2) ? cmdSupportFileSystem : cmdSupportNone; m_SetLabel = findExternal("zpool", QStringList(), 2) ? cmdSupportFileSystem : cmdSupportNone;
m_GetUsed = findExternal("zfs", QStringList(), 2) ? cmdSupportFileSystem : cmdSupportNone;
m_GetLabel = cmdSupportCore; m_GetLabel = cmdSupportCore;
m_Backup = cmdSupportCore; m_Backup = cmdSupportCore;
m_GetUUID = cmdSupportCore; m_GetUUID = cmdSupportCore;
@ -57,7 +58,7 @@ namespace FS
bool zfs::supportToolFound() const bool zfs::supportToolFound() const
{ {
return return
// m_GetUsed != cmdSupportNone && m_GetUsed != cmdSupportNone &&
m_GetLabel != cmdSupportNone && m_GetLabel != cmdSupportNone &&
m_SetLabel != cmdSupportNone && m_SetLabel != cmdSupportNone &&
// m_Create != cmdSupportNone && // m_Create != cmdSupportNone &&
@ -86,6 +87,28 @@ namespace FS
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB); return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
} }
qint64 zfs::maxLabelLength() const
{
// for reference:
// https://www.freebsd.org/cgi/man.cgi?query=zfs
return (256 * 50);
}
qint64 zfs::readUsedCapacity(const QString& deviceNode) const
{
Q_UNUSED(deviceNode)
qint64 result = -1;
ExternalCommand cmd("zfs", QStringList() << "list" << "-H" << "-p" << "-o" << "used" << this->label());
if (cmd.start() && cmd.waitFor()) {
bool ok = false;
result = cmd.output().toLongLong(&ok);
if (!ok) {
result = -1;
}
}
return result;
}
bool zfs::remove(Report& report, const QString& deviceNode) const bool zfs::remove(Report& report, const QString& deviceNode) const
{ {
Q_UNUSED(deviceNode) Q_UNUSED(deviceNode)

View file

@ -44,6 +44,7 @@ namespace FS
public: public:
static void init(); static void init();
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
virtual bool remove(Report& report, const QString& deviceNode) const; virtual bool remove(Report& report, const QString& deviceNode) const;
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel); virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
@ -62,6 +63,7 @@ namespace FS
virtual qint64 minCapacity() const; virtual qint64 minCapacity() const;
virtual qint64 maxCapacity() const; virtual qint64 maxCapacity() const;
virtual qint64 maxLabelLength() const;
virtual SupportTool supportToolName() const; virtual SupportTool supportToolName() const;
virtual bool supportToolFound() const; virtual bool supportToolFound() const;