Add support for setting the specific GPT type
The GPT partition layout defines the type of the partition using a UUID[1]. The type of the partition is not related to the underlying filesystem but to its functionality: rootfs, home, var, swap, esp... The UUID 4f68bce3-e8cd-4db1-96e7-fbcaf984b709 defines the root partition (/), the UUID 933ac7e1-2eb4-4f13-b844-0e14e2aef915 defines the home partition (/home), the UUID 4d21b016-b534-45c2-a9fb-5c16e091fd2d defines the variable partition (/var)... Also, the UUIDs may vary depending on the architecture (x86, x86_64, arm or aarch64). KPMcore guesses the type depending on the underlying filesystem. This commit enables the setting of a more specific GPT type if it is specified through the method Partition::setType(). It falls back to the previous guess type if the type is left unset. [1]: https://systemd.io/DISCOVERABLE_PARTITIONS/
This commit is contained in:
parent
59269f63df
commit
0529ebfb01
|
@ -125,6 +125,9 @@ public:
|
|||
const QString& label() const {
|
||||
return m_Label; /**< @return the GPT Partition label */
|
||||
}
|
||||
const QString& type() const {
|
||||
return m_Type; /**< @return the GPT Partition type */
|
||||
}
|
||||
const QString& uuid() const {
|
||||
return m_UUID; /**< @return the GPT Partition UUID */
|
||||
}
|
||||
|
@ -210,6 +213,9 @@ public:
|
|||
void setLabel(const QString& s) {
|
||||
m_Label = s; /**< @param s the new label */
|
||||
}
|
||||
void setType(const QString& s) {
|
||||
m_Type = s; /**< @param s the new type */
|
||||
}
|
||||
void setUUID(const QString& s) {
|
||||
m_UUID = s; /**< @param s the new UUID */
|
||||
}
|
||||
|
@ -266,6 +272,7 @@ private:
|
|||
qint64 m_LastSector;
|
||||
QString m_DevicePath;
|
||||
QString m_Label;
|
||||
QString m_Type;
|
||||
QString m_UUID;
|
||||
QString m_PartitionPath;
|
||||
QString m_MountPoint;
|
||||
|
|
|
@ -215,7 +215,9 @@ static QLatin1String getPartitionType(FileSystem::Type t, PartitionTable::TableT
|
|||
|
||||
bool SfdiskPartitionTable::setPartitionSystemType(Report& report, const Partition& partition)
|
||||
{
|
||||
QString partitionType = getPartitionType(partition.fileSystem().type(), m_device->partitionTable()->type());
|
||||
QString partitionType = partition.type();
|
||||
if (partitionType.isEmpty())
|
||||
partitionType = getPartitionType(partition.fileSystem().type(), m_device->partitionTable()->type());
|
||||
if (partitionType.isEmpty())
|
||||
return true;
|
||||
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--part-type"), m_device->deviceNode(), QString::number(partition.number()),
|
||||
|
|
Loading…
Reference in New Issue