sfdisk: Read GPT type and attributes at scanning

The GPT type and attributes can be set since the commits 0529ebf (Add
support for setting the specific GPT type) and 0ffec31 (Add new job to
set the GPT partition attributes).

But these two data from existing partitions are not read and are missing
though.

This reads the GPT type and attributes data at scanning from the json
output, after the GPT name/label and uuid are read.
This commit is contained in:
Gaël PORTAY 2020-06-16 06:49:06 -04:00
parent 0ffec31e2b
commit 547fa609fe
1 changed files with 12 additions and 0 deletions

View File

@ -304,6 +304,18 @@ void SfdiskBackend::scanDevicePartitions(Device& d, const QJsonArray& jsonPartit
if (d.partitionTable()->type() == PartitionTable::TableType::gpt) {
part->setLabel(partitionObject[QLatin1String("name")].toString());
part->setUUID(partitionObject[QLatin1String("uuid")].toString());
part->setType(partitionObject[QLatin1String("type")].toString());
quint64 attrs = 0;
for (auto& attr: QStringList(partitionObject[QLatin1String("attrs")].toString().split(QLatin1Char(' '))))
if (attr.compare(QStringLiteral("RequiredPartition")) == 0)
attrs |= 0x0000000000000001;
else if (attr.compare(QStringLiteral("NoBlockIOProtocol")) == 0)
attrs |= 0x0000000000000002;
else if (attr.compare(QStringLiteral("LegacyBIOSBootable")) == 0)
attrs |= 0x0000000000000004;
else if (attr.startsWith(QStringLiteral("GUID:")))
attrs |= 1ULL << QStringRef(&attr, 5, attr.length() - 5).toULongLong();
part->setAttributes(attrs);
}
if (fs->supportGetUUID() != FileSystem::cmdSupportNone)