Get btrfs used capacity from btrfs filesystem show --raw
It's output looks like: Label: 'test' uuid: d23f3138-c8ea-449e-9155-015ce4f6e2e6 Total devices 1 FS bytes used 131072 devid 1 size 981467136 used 252706816 path /dev/sdb1 FS bytes used number is actual data on btrfs volume. However, to resize successfully we need to know actual space used by data and metadata. That's why we read size from devid (i.e. 252706816). Btrfs volumes can span over multiple devices, so we must make sure that we are reading devid corresponding to the correct device node. BUG: 353333
This commit is contained in:
parent
58013d54fe
commit
20bb8eba7e
|
@ -105,10 +105,10 @@ qint64 btrfs::maxLabelLength() const
|
|||
|
||||
qint64 btrfs::readUsedCapacity(const QString& deviceNode) const
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("btrfs-debug-tree"), QStringList() << deviceNode);
|
||||
ExternalCommand cmd(QStringLiteral("btrfs"), QStringList() << QStringLiteral("filesystem") << QStringLiteral("show") << QStringLiteral("--raw") << deviceNode);
|
||||
|
||||
if (cmd.run()) {
|
||||
QRegExp rxBytesUsed(QStringLiteral(" bytes used (\\d+)"));
|
||||
QRegExp rxBytesUsed(QStringLiteral(" used (\\d+) path ") + deviceNode);
|
||||
|
||||
if (rxBytesUsed.indexIn(cmd.output()) != -1)
|
||||
return rxBytesUsed.cap(1).toLongLong();
|
||||
|
|
Loading…
Reference in New Issue