Add support for GTP partition labels.
This commit is contained in:
parent
9c7db501bf
commit
28fa6ac5a4
|
@ -141,14 +141,18 @@ public:
|
||||||
const Partitions& children() const override {
|
const Partitions& children() const override {
|
||||||
return m_Children; /**< @return the Partition's children. empty for non-extended. */
|
return m_Children; /**< @return the Partition's children. empty for non-extended. */
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& devicePath() const {
|
const QString& devicePath() const {
|
||||||
return m_DevicePath; /**< @return the Partition's device path, e.g. /dev/sdd */
|
return m_DevicePath; /**< @return the Partition's device path, e.g. /dev/sdd */
|
||||||
}
|
}
|
||||||
const QString& partitionPath() const {
|
const QString& partitionPath() const {
|
||||||
return m_PartitionPath; /**< @return the Partition's path, e.g. /dev/sdd1 */
|
return m_PartitionPath; /**< @return the Partition's path, e.g. /dev/sdd1 */
|
||||||
}
|
}
|
||||||
|
const QString& label() const {
|
||||||
|
return m_Label; /**< @return the GPT Partition label */
|
||||||
|
}
|
||||||
|
const QString& uuid() const {
|
||||||
|
return m_UUID; /**< @return the GPT Partition UUID */
|
||||||
|
}
|
||||||
qint64 firstSector() const {
|
qint64 firstSector() const {
|
||||||
return m_FirstSector; /**< @return the Partition's first sector on the Device */
|
return m_FirstSector; /**< @return the Partition's first sector on the Device */
|
||||||
}
|
}
|
||||||
|
@ -192,18 +196,15 @@ public:
|
||||||
PartitionTable::Flags availableFlags() const {
|
PartitionTable::Flags availableFlags() const {
|
||||||
return m_AvailableFlags; /**< @return the flags available for this Partition */
|
return m_AvailableFlags; /**< @return the flags available for this Partition */
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isMounted() const {
|
bool isMounted() const {
|
||||||
return m_IsMounted; /**< @return true if Partition is mounted */
|
return m_IsMounted; /**< @return true if Partition is mounted */
|
||||||
}
|
}
|
||||||
|
|
||||||
FileSystem& fileSystem() {
|
FileSystem& fileSystem() {
|
||||||
return *m_FileSystem; /**< @return the Partition's FileSystem */
|
return *m_FileSystem; /**< @return the Partition's FileSystem */
|
||||||
}
|
}
|
||||||
const FileSystem& fileSystem() const {
|
const FileSystem& fileSystem() const {
|
||||||
return *m_FileSystem; /**< @return the Partition's FileSystem */
|
return *m_FileSystem; /**< @return the Partition's FileSystem */
|
||||||
}
|
}
|
||||||
|
|
||||||
State state() const {
|
State state() const {
|
||||||
return m_State; /**< @return the Partition's state */
|
return m_State; /**< @return the Partition's state */
|
||||||
}
|
}
|
||||||
|
@ -225,6 +226,13 @@ public:
|
||||||
m_LastSector = s;
|
m_LastSector = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setLabel(const QString& s) {
|
||||||
|
m_Label = s; /**< @param s the new label */
|
||||||
|
}
|
||||||
|
void setUUID(const QString& s) {
|
||||||
|
m_UUID = s; /**< @param s the new UUID */
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void append(Partition* p) override {
|
void append(Partition* p) override {
|
||||||
m_Children.append(p);
|
m_Children.append(p);
|
||||||
|
@ -277,6 +285,8 @@ private:
|
||||||
qint64 m_FirstSector;
|
qint64 m_FirstSector;
|
||||||
qint64 m_LastSector;
|
qint64 m_LastSector;
|
||||||
QString m_DevicePath;
|
QString m_DevicePath;
|
||||||
|
QString m_Label;
|
||||||
|
QString m_UUID;
|
||||||
QString m_PartitionPath;
|
QString m_PartitionPath;
|
||||||
QString m_MountPoint;
|
QString m_MountPoint;
|
||||||
PartitionTable::Flags m_AvailableFlags;
|
PartitionTable::Flags m_AvailableFlags;
|
||||||
|
|
|
@ -61,7 +61,8 @@ ActionReply Scan::scandevice(const QVariantMap& args)
|
||||||
pedDisk->dev->bios_geom.heads *
|
pedDisk->dev->bios_geom.heads *
|
||||||
pedDisk->dev->bios_geom.cylinders - 1;
|
pedDisk->dev->bios_geom.cylinders - 1;
|
||||||
|
|
||||||
if (strcmp(pedDisk->type->name, "gpt") == 0) {
|
bool isGPT = strcmp(pedDisk->type->name, "gpt") == 0;
|
||||||
|
if (isGPT) {
|
||||||
GPTDiskData* gpt_disk_data = reinterpret_cast<GPTDiskData*>(pedDisk->disk_specific);
|
GPTDiskData* gpt_disk_data = reinterpret_cast<GPTDiskData*>(pedDisk->disk_specific);
|
||||||
PedGeometry* geom = reinterpret_cast<PedGeometry*>(&gpt_disk_data->data_area);
|
PedGeometry* geom = reinterpret_cast<PedGeometry*>(&gpt_disk_data->data_area);
|
||||||
|
|
||||||
|
@ -85,6 +86,7 @@ ActionReply Scan::scandevice(const QVariantMap& args)
|
||||||
QList<QVariant> partitionStart;
|
QList<QVariant> partitionStart;
|
||||||
QList<QVariant> partitionEnd;
|
QList<QVariant> partitionEnd;
|
||||||
QList<QVariant> partitionBusy;
|
QList<QVariant> partitionBusy;
|
||||||
|
QList<QVariant> partitionLabel;
|
||||||
QList<QVariant> availableFlags;
|
QList<QVariant> availableFlags;
|
||||||
QList<QVariant> activeFlags;
|
QList<QVariant> activeFlags;
|
||||||
|
|
||||||
|
@ -97,6 +99,10 @@ ActionReply Scan::scandevice(const QVariantMap& args)
|
||||||
partitionStart.append(pedPartition->geom.start);
|
partitionStart.append(pedPartition->geom.start);
|
||||||
partitionEnd.append(pedPartition->geom.end);
|
partitionEnd.append(pedPartition->geom.end);
|
||||||
partitionBusy.append(ped_partition_is_busy(pedPartition));
|
partitionBusy.append(ped_partition_is_busy(pedPartition));
|
||||||
|
if (isGPT)
|
||||||
|
partitionLabel.append(QLatin1String(ped_partition_get_name(pedPartition)));
|
||||||
|
else
|
||||||
|
partitionLabel.append(QLatin1String());
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// Get list of available flags
|
// Get list of available flags
|
||||||
|
@ -135,6 +141,7 @@ ActionReply Scan::scandevice(const QVariantMap& args)
|
||||||
reply.addData(QStringLiteral("partitionStart"), partitionStart);
|
reply.addData(QStringLiteral("partitionStart"), partitionStart);
|
||||||
reply.addData(QStringLiteral("partitionEnd"), partitionEnd);
|
reply.addData(QStringLiteral("partitionEnd"), partitionEnd);
|
||||||
reply.addData(QStringLiteral("partitionBusy"), partitionBusy);
|
reply.addData(QStringLiteral("partitionBusy"), partitionBusy);
|
||||||
|
reply.addData(QStringLiteral("partitionLabel"), partitionLabel);
|
||||||
|
|
||||||
return reply;
|
return reply;
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,8 +185,8 @@ Device* LibPartedBackend::scanDevice(const QString& deviceNode)
|
||||||
quint64 firstUsableSector = job->data()[QLatin1String("firstUsableSector")].toULongLong();
|
quint64 firstUsableSector = job->data()[QLatin1String("firstUsableSector")].toULongLong();
|
||||||
quint64 lastUsableSector = job->data()[QLatin1String("lastUsableSector")].toULongLong();
|
quint64 lastUsableSector = job->data()[QLatin1String("lastUsableSector")].toULongLong();
|
||||||
|
|
||||||
const PartitionTable::TableType type = PartitionTable::nameToTableType(typeName);
|
const PartitionTable::TableType tableType = PartitionTable::nameToTableType(typeName);
|
||||||
CoreBackend::setPartitionTableForDevice(*d, new PartitionTable(type, firstUsableSector, lastUsableSector));
|
CoreBackend::setPartitionTableForDevice(*d, new PartitionTable(tableType, firstUsableSector, lastUsableSector));
|
||||||
CoreBackend::setPartitionTableMaxPrimaries(*d->partitionTable(), maxPrimaryPartitionCount);
|
CoreBackend::setPartitionTableMaxPrimaries(*d->partitionTable(), maxPrimaryPartitionCount);
|
||||||
|
|
||||||
QList<QVariant> partitionPath = job->data()[QLatin1String("partitionPath")].toList();
|
QList<QVariant> partitionPath = job->data()[QLatin1String("partitionPath")].toList();
|
||||||
|
@ -194,6 +194,8 @@ Device* LibPartedBackend::scanDevice(const QString& deviceNode)
|
||||||
QList<QVariant> partitionStart = job->data()[QLatin1String("partitionStart")].toList();
|
QList<QVariant> partitionStart = job->data()[QLatin1String("partitionStart")].toList();
|
||||||
QList<QVariant> partitionEnd = job->data()[QLatin1String("partitionEnd")].toList();
|
QList<QVariant> partitionEnd = job->data()[QLatin1String("partitionEnd")].toList();
|
||||||
QList<QVariant> partitionBusy = job->data()[QLatin1String("partitionBusy")].toList();
|
QList<QVariant> partitionBusy = job->data()[QLatin1String("partitionBusy")].toList();
|
||||||
|
QList<QVariant> partitionLabel;
|
||||||
|
partitionLabel = job->data()[QLatin1String("partitionLabel")].toList();
|
||||||
|
|
||||||
quint32 totalPartitions = partitionPath.size();
|
quint32 totalPartitions = partitionPath.size();
|
||||||
QList<Partition*> partitions;
|
QList<Partition*> partitions;
|
||||||
|
@ -261,6 +263,10 @@ Device* LibPartedBackend::scanDevice(const QString& deviceNode)
|
||||||
if (fs->supportGetLabel() != FileSystem::cmdSupportNone)
|
if (fs->supportGetLabel() != FileSystem::cmdSupportNone)
|
||||||
fs->setLabel(fs->readLabel(part->deviceNode()));
|
fs->setLabel(fs->readLabel(part->deviceNode()));
|
||||||
|
|
||||||
|
// GPT partitions support partition labels and partition UUIDs
|
||||||
|
if(tableType == PartitionTable::TableType::gpt)
|
||||||
|
part->setLabel(partitionLabel[i].toString());
|
||||||
|
|
||||||
if (fs->supportGetUUID() != FileSystem::cmdSupportNone)
|
if (fs->supportGetUUID() != FileSystem::cmdSupportNone)
|
||||||
fs->setUUID(fs->readUUID(part->deviceNode()));
|
fs->setUUID(fs->readUUID(part->deviceNode()));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue