diff --git a/src/core/device.h b/src/core/device.h index 5425539..d74184b 100644 --- a/src/core/device.h +++ b/src/core/device.h @@ -57,7 +57,6 @@ public: RAID_Device, /* software RAID device */ }; -protected: explicit Device(std::shared_ptr d_ptr, const QString& name, const QString& deviceNode, const qint64 logicalSectorSize, const qint64 totalLogicalSectors, const QString& iconName = QString(), Device::Type type = Device::Type::Disk_Device); public: diff --git a/src/jobs/setfilesystemlabeljob.cpp b/src/jobs/setfilesystemlabeljob.cpp index ea1402b..640e275 100644 --- a/src/jobs/setfilesystemlabeljob.cpp +++ b/src/jobs/setfilesystemlabeljob.cpp @@ -18,6 +18,13 @@ #include "jobs/setfilesystemlabeljob.h" +#include "backend/corebackend.h" +#include "backend/corebackendmanager.h" +#include "backend/corebackenddevice.h" +#include "backend/corebackendpartitiontable.h" + +#include "core/device_p.h" +#include "core/operationstack.h" #include "core/partition.h" #include "fs/filesystem.h" @@ -26,6 +33,8 @@ #include +#include + /** Creates a new SetFileSystemLabelJob @param p the Partition the FileSystem whose label is to be set is on @param newlabel the new label @@ -61,7 +70,15 @@ bool SetFileSystemLabelJob::run(Report& parent) partition().fileSystem().setLabel(label()); } - // FIXME: need to commit to device + // A hack to reread partition table (commit() should be called even on non DiskDevices) + Device dev(std::make_shared(), QString(), QString(), 0, 0, QString(), Device::Type::Unknown_Device); + std::unique_ptr backendDevice = CoreBackendManager::self()->backend()->openDevice(dev); + if (backendDevice) { + std::unique_ptr backendPartitionTable = backendDevice->openPartitionTable(); + + if (backendPartitionTable) + backendPartitionTable->commit(); + } jobFinished(*report, rval); diff --git a/src/plugins/sfdisk/sfdiskpartitiontable.cpp b/src/plugins/sfdisk/sfdiskpartitiontable.cpp index a33dbc9..0c6ea3d 100644 --- a/src/plugins/sfdisk/sfdiskpartitiontable.cpp +++ b/src/plugins/sfdisk/sfdiskpartitiontable.cpp @@ -28,8 +28,6 @@ #include "util/report.h" #include "util/externalcommand.h" -#include - #include #include #include @@ -54,9 +52,9 @@ bool SfdiskPartitionTable::open() bool SfdiskPartitionTable::commit(quint32 timeout) { - if ( !(ExternalCommand(QStringLiteral("udevadm"), { QStringLiteral("settle"), QStringLiteral("--timeout=") + QString::number(timeout) }).run() && - ExternalCommand(QStringLiteral("blockdev"), { QStringLiteral("--rereadpt"), m_device->deviceNode() }).run())) - sleep(1); + ExternalCommand(QStringLiteral("udevadm"), { QStringLiteral("settle"), QStringLiteral("--timeout=") + QString::number(timeout) }).run(); + ExternalCommand(QStringLiteral("blockdev"), { QStringLiteral("--rereadpt"), m_device->deviceNode() }).run(); + ExternalCommand(QStringLiteral("udevadm"), { QStringLiteral("trigger") }).run(); return true; }