From 0529ebfb01b8b9d79f264bcfbdfd3f1cde0aaeac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20PORTAY?= Date: Thu, 19 Mar 2020 08:15:13 -0400 Subject: [PATCH 1/2] 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/ --- src/core/partition.h | 7 +++++++ src/plugins/sfdisk/sfdiskpartitiontable.cpp | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/partition.h b/src/core/partition.h index 7b6c0f8..36d64b0 100644 --- a/src/core/partition.h +++ b/src/core/partition.h @@ -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; diff --git a/src/plugins/sfdisk/sfdiskpartitiontable.cpp b/src/plugins/sfdisk/sfdiskpartitiontable.cpp index 5ed36ac..796e042 100644 --- a/src/plugins/sfdisk/sfdiskpartitiontable.cpp +++ b/src/plugins/sfdisk/sfdiskpartitiontable.cpp @@ -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()), From 4fdaf6b1c87e861861798a1892cb9425123634aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 22 Mar 2020 01:49:25 +0000 Subject: [PATCH 2/2] Bump soversion of kpmcore. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 189cd84..dfc878f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ set(VERSION_MAJOR "4") set(VERSION_MINOR "1") set(VERSION_RELEASE "0") set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE}) -set(SOVERSION "9") +set(SOVERSION "10") add_definitions(-D'VERSION="${VERSION}"') #" set(CMAKE_CXX_STANDARD 14)