From 58f2decdf84225fa640035e5e82a22ecf7870ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 12 Nov 2017 13:07:39 +0000 Subject: [PATCH 1/5] Support newer f2fs-tools versions. BUG: 386771 --- src/fs/f2fs.cpp | 11 +++++++++++ src/fs/f2fs.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/src/fs/f2fs.cpp b/src/fs/f2fs.cpp index 23d80aa..298ec71 100644 --- a/src/fs/f2fs.cpp +++ b/src/fs/f2fs.cpp @@ -43,6 +43,7 @@ FileSystem::CommandSupportType f2fs::m_Backup = FileSystem::cmdSupportNone; FileSystem::CommandSupportType f2fs::m_SetLabel = FileSystem::cmdSupportNone; FileSystem::CommandSupportType f2fs::m_UpdateUUID = FileSystem::cmdSupportNone; FileSystem::CommandSupportType f2fs::m_GetUUID = FileSystem::cmdSupportNone; +bool f2fs::oldVersion = false; // 1.8.x or older f2fs::f2fs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) : FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::F2fs) @@ -54,6 +55,11 @@ void f2fs::init() m_Create = findExternal(QStringLiteral("mkfs.f2fs")) ? cmdSupportFileSystem : cmdSupportNone; m_Check = findExternal(QStringLiteral("fsck.f2fs")) ? cmdSupportFileSystem : cmdSupportNone; + if (m_Create == cmdSupportFileSystem) { + ExternalCommand cmd(QStringLiteral("mkfs.f2fs"), {}); + oldVersion = cmd.run(-1) && !cmd.output().contains(QStringLiteral("-f")); + } + m_GetLabel = cmdSupportCore; // m_SetLabel = findExternal(QStringLiteral("nilfs-tune")) ? cmdSupportFileSystem : cmdSupportNone; // m_UpdateUUID = findExternal(QStringLiteral("nilfs-tune")) ? cmdSupportFileSystem : cmdSupportNone; @@ -115,6 +121,11 @@ bool f2fs::check(Report& report, const QString& deviceNode) const bool f2fs::create(Report& report, const QString& deviceNode) { + QStringList args; + if (oldVersion) + args << deviceNode; + else + args << QStringLiteral("-f") << deviceNode; ExternalCommand cmd(report, QStringLiteral("mkfs.f2fs"), { deviceNode }); return cmd.run(-1) && cmd.exitCode() == 0; } diff --git a/src/fs/f2fs.h b/src/fs/f2fs.h index ab65cf9..550d67d 100644 --- a/src/fs/f2fs.h +++ b/src/fs/f2fs.h @@ -110,6 +110,10 @@ public: static CommandSupportType m_SetLabel; static CommandSupportType m_UpdateUUID; static CommandSupportType m_GetUUID; + +private: + static bool oldVersion; + }; } From fad8a3568e443dc42af003e83484541693397c25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 12 Nov 2017 14:45:49 +0000 Subject: [PATCH 2/5] Fix the previous commit. FileSystem::create is never called if createWithLabel is available. --- src/fs/f2fs.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/fs/f2fs.cpp b/src/fs/f2fs.cpp index 298ec71..c4fdaf1 100644 --- a/src/fs/f2fs.cpp +++ b/src/fs/f2fs.cpp @@ -121,18 +121,17 @@ bool f2fs::check(Report& report, const QString& deviceNode) const bool f2fs::create(Report& report, const QString& deviceNode) { - QStringList args; - if (oldVersion) - args << deviceNode; - else - args << QStringLiteral("-f") << deviceNode; - ExternalCommand cmd(report, QStringLiteral("mkfs.f2fs"), { deviceNode }); - return cmd.run(-1) && cmd.exitCode() == 0; + return createWithLabel(report, deviceNode, QString()); } bool f2fs::createWithLabel(Report& report, const QString& deviceNode, const QString& label) { - ExternalCommand cmd(report, QStringLiteral("mkfs.f2fs"), { QStringLiteral("-l"), label, deviceNode }); + QStringList args; + if (oldVersion) + args << QStringLiteral("-l") << label << deviceNode; + else + args << QStringLiteral("-f") << QStringLiteral("-l") << label << deviceNode; + ExternalCommand cmd(report, QStringLiteral("mkfs.f2fs"), args); return cmd.run(-1) && cmd.exitCode() == 0; } From be7ba11f17ce6e49be34e2392e271275af932f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 12 Nov 2017 14:55:55 +0000 Subject: [PATCH 3/5] Remove unnecessary semicolons. --- src/fs/filesystem.cpp | 64 +++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/fs/filesystem.cpp b/src/fs/filesystem.cpp index 66d6535..bbc6ae8 100644 --- a/src/fs/filesystem.cpp +++ b/src/fs/filesystem.cpp @@ -94,7 +94,7 @@ FileSystem::FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused */ qint64 FileSystem::readUsedCapacity(const QString& deviceNode) const { - Q_UNUSED(deviceNode); + Q_UNUSED(deviceNode) return -1; } @@ -202,7 +202,7 @@ bool FileSystem::createWithLabel(Report& report, const QString& deviceNode, cons */ void FileSystem::scan(const QString& deviceNode) { - Q_UNUSED(deviceNode); + Q_UNUSED(deviceNode) } /** Resize a FileSystem to a given new length @@ -229,10 +229,10 @@ bool FileSystem::resize(Report& report, const QString& deviceNode, qint64 newLen */ bool FileSystem::resizeOnline(Report& report, const QString& deviceNode, const QString& mountPoint, qint64 newLength) const { - Q_UNUSED(report); - Q_UNUSED(deviceNode); - Q_UNUSED(mountPoint); - Q_UNUSED(newLength); + Q_UNUSED(report) + Q_UNUSED(deviceNode) + Q_UNUSED(mountPoint) + Q_UNUSED(newLength) return true; } @@ -245,9 +245,9 @@ bool FileSystem::resizeOnline(Report& report, const QString& deviceNode, const Q */ bool FileSystem::move(Report& report, const QString& deviceNode, qint64 newStartSector) const { - Q_UNUSED(report); - Q_UNUSED(deviceNode); - Q_UNUSED(newStartSector); + Q_UNUSED(report) + Q_UNUSED(deviceNode) + Q_UNUSED(newStartSector) return true; } @@ -260,9 +260,9 @@ bool FileSystem::move(Report& report, const QString& deviceNode, qint64 newStart */ bool FileSystem::writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) { - Q_UNUSED(report); - Q_UNUSED(deviceNode); - Q_UNUSED(newLabel); + Q_UNUSED(report) + Q_UNUSED(deviceNode) + Q_UNUSED(newLabel) return true; } @@ -276,10 +276,10 @@ bool FileSystem::writeLabel(Report& report, const QString& deviceNode, const QSt */ bool FileSystem::writeLabelOnline(Report& report, const QString& deviceNode, const QString& mountPoint, const QString& newLabel) { - Q_UNUSED(report); - Q_UNUSED(deviceNode); - Q_UNUSED(mountPoint); - Q_UNUSED(newLabel); + Q_UNUSED(report) + Q_UNUSED(deviceNode) + Q_UNUSED(mountPoint) + Q_UNUSED(newLabel) return true; } @@ -292,9 +292,9 @@ bool FileSystem::writeLabelOnline(Report& report, const QString& deviceNode, con */ bool FileSystem::copy(Report& report, const QString& targetDeviceNode, const QString& sourceDeviceNode) const { - Q_UNUSED(report); - Q_UNUSED(targetDeviceNode); - Q_UNUSED(sourceDeviceNode); + Q_UNUSED(report) + Q_UNUSED(targetDeviceNode) + Q_UNUSED(sourceDeviceNode) return true; } @@ -308,10 +308,10 @@ bool FileSystem::copy(Report& report, const QString& targetDeviceNode, const QSt */ bool FileSystem::backup(Report& report, const Device& sourceDevice, const QString& deviceNode, const QString& filename) const { - Q_UNUSED(report); - Q_UNUSED(sourceDevice); - Q_UNUSED(deviceNode); - Q_UNUSED(filename); + Q_UNUSED(report) + Q_UNUSED(sourceDevice) + Q_UNUSED(deviceNode) + Q_UNUSED(filename) return false; } @@ -323,8 +323,8 @@ bool FileSystem::backup(Report& report, const Device& sourceDevice, const QStrin */ bool FileSystem::remove(Report& report, const QString& deviceNode) const { - Q_UNUSED(report); - Q_UNUSED(deviceNode); + Q_UNUSED(report) + Q_UNUSED(deviceNode) return true; } @@ -336,8 +336,8 @@ bool FileSystem::remove(Report& report, const QString& deviceNode) const */ bool FileSystem::check(Report& report, const QString& deviceNode) const { - Q_UNUSED(report); - Q_UNUSED(deviceNode); + Q_UNUSED(report) + Q_UNUSED(deviceNode) return true; } @@ -349,8 +349,8 @@ bool FileSystem::check(Report& report, const QString& deviceNode) const */ bool FileSystem::updateUUID(Report& report, const QString& deviceNode) const { - Q_UNUSED(report); - Q_UNUSED(deviceNode); + Q_UNUSED(report) + Q_UNUSED(deviceNode) return true; } @@ -372,8 +372,8 @@ QString FileSystem::readUUID(const QString& deviceNode) const */ bool FileSystem::updateBootSector(Report& report, const QString& deviceNode) const { - Q_UNUSED(report); - Q_UNUSED(deviceNode); + Q_UNUSED(report) + Q_UNUSED(deviceNode) return true; } @@ -507,7 +507,7 @@ void FileSystem::move(qint64 newStartSector) } bool FileSystem::canMount(const QString& deviceNode, const QString& mountPoint) const { - Q_UNUSED(deviceNode); + Q_UNUSED(deviceNode) // cannot mount if we have no mount points return !mountPoint.isEmpty(); } From f1a695bdac926a46896eb57a07b8c8719255091c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Mon, 13 Nov 2017 19:34:52 +0000 Subject: [PATCH 4/5] Add support for growing f2fs file system. --- src/fs/f2fs.cpp | 11 +++++++++-- src/fs/f2fs.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/fs/f2fs.cpp b/src/fs/f2fs.cpp index c4fdaf1..3bf3d73 100644 --- a/src/fs/f2fs.cpp +++ b/src/fs/f2fs.cpp @@ -64,7 +64,7 @@ void f2fs::init() // m_SetLabel = findExternal(QStringLiteral("nilfs-tune")) ? cmdSupportFileSystem : cmdSupportNone; // m_UpdateUUID = findExternal(QStringLiteral("nilfs-tune")) ? cmdSupportFileSystem : cmdSupportNone; -// m_Grow = (m_Check != cmdSupportNone && findExternal(QStringLiteral("nilfs-resize"))) ? cmdSupportFileSystem : cmdSupportNone; + m_Grow = (m_Check != cmdSupportNone && findExternal(QStringLiteral("resize.f2fs"))) ? cmdSupportFileSystem : cmdSupportNone; // m_GetUsed = findExternal(QStringLiteral("nilfs-tune")) ? cmdSupportFileSystem : cmdSupportNone; // m_Shrink = (m_Grow != cmdSupportNone && m_GetUsed != cmdSupportNone) ? cmdSupportFileSystem : cmdSupportNone; @@ -85,7 +85,7 @@ bool f2fs::supportToolFound() const m_Create != cmdSupportNone && m_Check != cmdSupportNone && // m_UpdateUUID != cmdSupportNone && -// m_Grow != cmdSupportNone && + m_Grow != cmdSupportNone && // m_Shrink != cmdSupportNone && m_Copy != cmdSupportNone && m_Move != cmdSupportNone && @@ -135,4 +135,11 @@ bool f2fs::createWithLabel(Report& report, const QString& deviceNode, const QStr return cmd.run(-1) && cmd.exitCode() == 0; } +bool f2fs::resize(Report& report, const QString& deviceNode, qint64 length) const +{ + Q_UNUSED(length) + ExternalCommand cmd(report, QStringLiteral("resize.f2fs"), { deviceNode }); + return cmd.run(-1) && cmd.exitCode() == 0; +} + } diff --git a/src/fs/f2fs.h b/src/fs/f2fs.h index 550d67d..280fe82 100644 --- a/src/fs/f2fs.h +++ b/src/fs/f2fs.h @@ -47,7 +47,7 @@ public: bool create(Report& report, const QString& deviceNode) override; bool createWithLabel(Report& report, const QString& deviceNode, const QString& label) override; // qint64 readUsedCapacity(const QString& deviceNode) const override; -// bool resize(Report& report, const QString& deviceNode, qint64 length) const override; + bool resize(Report& report, const QString& deviceNode, qint64 length) const override; // bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override; // bool updateUUID(Report& report, const QString& deviceNode) const override; From 4bf5bb467f6c029da7871f8bd2a78410a5f03e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Sun, 3 Dec 2017 12:37:21 +0000 Subject: [PATCH 5/5] Fix conversion to/from QString/QByteArray BUG: 384321 --- src/core/partition.cpp | 2 +- src/core/smartstatus.cpp | 6 +++--- src/fs/filesystem.cpp | 4 ++-- src/fs/luks.cpp | 8 ++++---- src/plugins/libparted/libpartedbackend.cpp | 18 +++++++++--------- src/plugins/libparted/libparteddevice.cpp | 6 +++--- .../libparted/libpartedpartitiontable.cpp | 14 +++++++------- src/util/externalcommand.cpp | 2 +- src/util/htmlreport.cpp | 2 +- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/core/partition.cpp b/src/core/partition.cpp index 405f583..5b7c3a0 100644 --- a/src/core/partition.cpp +++ b/src/core/partition.cpp @@ -335,7 +335,7 @@ bool Partition::unmount(Report& report) const QString canonicalDeviceNode = QFileInfo(deviceNode()).canonicalFilePath(); const QList mountedVolumes = QStorageInfo::mountedVolumes(); for (const QStorageInfo &storage : mountedVolumes) { - if (QFileInfo(QString::fromUtf8(storage.device())).canonicalFilePath() == canonicalDeviceNode ) { + if (QFileInfo(QString::fromLocal8Bit(storage.device())).canonicalFilePath() == canonicalDeviceNode ) { success = false; break; } diff --git a/src/core/smartstatus.cpp b/src/core/smartstatus.cpp index 2a7c280..8b1cb91 100644 --- a/src/core/smartstatus.cpp +++ b/src/core/smartstatus.cpp @@ -77,9 +77,9 @@ void SmartStatus::update() if (sk_disk_identify_parse(skDisk, &skIdentify) < 0) qDebug() << "getting identify data failed for " << devicePath() << ": " << strerror(errno); else { - setModelName(QString::fromUtf8(skIdentify->model)); - setFirmware(QString::fromUtf8(skIdentify->firmware)); - setSerial(QString::fromUtf8(skIdentify->serial)); + setModelName(QString::fromLocal8Bit(skIdentify->model)); + setFirmware(QString::fromLocal8Bit(skIdentify->firmware)); + setSerial(QString::fromLocal8Bit(skIdentify->serial)); } const SkSmartParsedData* skParsed; diff --git a/src/fs/filesystem.cpp b/src/fs/filesystem.cpp index bbc6ae8..fa2413c 100644 --- a/src/fs/filesystem.cpp +++ b/src/fs/filesystem.cpp @@ -110,7 +110,7 @@ static QString readBlkIdValue(const QString& deviceNode, const QString& tag) char* label = nullptr; if ((dev = blkid_get_dev(cache, deviceNode.toLocal8Bit().constData(), BLKID_DEV_NORMAL)) != nullptr && (label = blkid_get_tag_value(cache, tag.toLocal8Bit().constData(), deviceNode.toLocal8Bit().constData()))) { - rval = QString::fromUtf8(label); + rval = QString::fromLocal8Bit(label); free(label); } @@ -138,7 +138,7 @@ QString FileSystem::detectMountPoint(FileSystem* fs, const QString& partitionPat QString partitionCanonicalPath = partitionPathFileInfo.canonicalFilePath(); const QList mountedVolumes = QStorageInfo::mountedVolumes(); for (const QStorageInfo &storage : mountedVolumes) { - if (partitionCanonicalPath == QFileInfo(QString::fromUtf8(storage.device())).canonicalFilePath() ) { + if (partitionCanonicalPath == QFileInfo(QString::fromLocal8Bit(storage.device())).canonicalFilePath() ) { mountPoints.append(storage.rootPath()); } } diff --git a/src/fs/luks.cpp b/src/fs/luks.cpp index a80cf01..86dbaea 100644 --- a/src/fs/luks.cpp +++ b/src/fs/luks.cpp @@ -128,7 +128,7 @@ bool luks::create(Report& report, const QString& deviceNode) QStringLiteral("luksFormat"), deviceNode }); if (!( createCmd.start(-1) && - createCmd.write(m_passphrase.toUtf8() + '\n') == m_passphrase.toUtf8().length() + 1 && + createCmd.write(m_passphrase.toLocal8Bit() + '\n') == m_passphrase.toLocal8Bit().length() + 1 && createCmd.waitFor() && createCmd.exitCode() == 0)) { return false; @@ -139,7 +139,7 @@ bool luks::create(Report& report, const QString& deviceNode) deviceNode, suggestedMapperName(deviceNode) }); - if (!( openCmd.start(-1) && openCmd.write(m_passphrase.toUtf8() + '\n') == m_passphrase.toUtf8().length() + 1 && openCmd.waitFor())) + if (!( openCmd.start(-1) && openCmd.write(m_passphrase.toLocal8Bit() + '\n') == m_passphrase.toLocal8Bit().length() + 1 && openCmd.waitFor())) return false; scan(deviceNode); @@ -262,7 +262,7 @@ bool luks::cryptOpen(QWidget* parent, const QString& deviceNode) suggestedMapperName(deviceNode) }); if (!( openCmd.start(-1) && - openCmd.write(passphrase.toUtf8() + '\n') == passphrase.toUtf8().length() + 1 && + openCmd.write(passphrase.toLocal8Bit() + '\n') == passphrase.toLocal8Bit().length() + 1 && openCmd.waitFor() && openCmd.exitCode() == 0) ) return false; @@ -572,7 +572,7 @@ void luks::getMapperName(const QString& deviceNode) m_MapperName = QString(); if (cmd.run(-1) && cmd.exitCode() == 0) { - const QJsonDocument jsonDocument = QJsonDocument::fromJson(cmd.output().toUtf8()); + const QJsonDocument jsonDocument = QJsonDocument::fromJson(cmd.output().toLocal8Bit()); QJsonObject jsonObject = jsonDocument.object(); const QJsonArray jsonArray = jsonObject[QLatin1String("blockdevices")].toArray(); for (const auto &deviceLine : jsonArray) { diff --git a/src/plugins/libparted/libpartedbackend.cpp b/src/plugins/libparted/libpartedbackend.cpp index 2081fe9..8a06bb4 100644 --- a/src/plugins/libparted/libpartedbackend.cpp +++ b/src/plugins/libparted/libpartedbackend.cpp @@ -107,7 +107,7 @@ typedef struct _GPTDiskData GPTDiskData; */ static qint64 firstUsableSector(const Device& d) { - PedDevice* pedDevice = ped_device_get(d.deviceNode().toLatin1().constData()); + PedDevice* pedDevice = ped_device_get(d.deviceNode().toLocal8Bit().constData()); PedDisk* pedDisk = pedDevice ? ped_disk_new(pedDevice) : nullptr; qint64 rval = 0; @@ -135,7 +135,7 @@ static qint64 firstUsableSector(const Device& d) */ static qint64 lastUsableSector(const Device& d) { - PedDevice* pedDevice = ped_device_get(d.deviceNode().toLatin1().constData()); + PedDevice* pedDevice = ped_device_get(d.deviceNode().toLocal8Bit().constData()); PedDisk* pedDisk = pedDevice ? ped_disk_new(pedDevice) : nullptr; qint64 rval = 0; @@ -305,7 +305,7 @@ void LibPartedBackend::scanDevicePartitions(Device& d, PedDisk* pedDisk) FileSystem::Type type = FileSystem::Unknown; char* pedPath = ped_partition_get_path(pedPartition); - const QString partitionNode = pedPath ? QString::fromUtf8(pedPath) : QString(); + const QString partitionNode = pedPath ? QString::fromLocal8Bit(pedPath) : QString(); free(pedPath); type = detectFileSystem(partitionNode); @@ -393,14 +393,14 @@ DiskDevice* LibPartedBackend::scanDevice(const QString& deviceNode) return nullptr; } - Log(Log::information) << xi18nc("@info:status", "Device found: %1", QString::fromUtf8(pedDevice->model)); + Log(Log::information) << xi18nc("@info:status", "Device found: %1", QString::fromLocal8Bit(pedDevice->model)); - DiskDevice* d = new DiskDevice(QString::fromUtf8(pedDevice->model), QString::fromUtf8(pedDevice->path), pedDevice->bios_geom.heads, pedDevice->bios_geom.sectors, pedDevice->bios_geom.cylinders, pedDevice->sector_size); + DiskDevice* d = new DiskDevice(QString::fromLocal8Bit(pedDevice->model), QString::fromLocal8Bit(pedDevice->path), pedDevice->bios_geom.heads, pedDevice->bios_geom.sectors, pedDevice->bios_geom.cylinders, pedDevice->sector_size); PedDisk* pedDisk = ped_disk_new(pedDevice); if (pedDisk) { - const PartitionTable::TableType type = PartitionTable::nameToTableType(QString::fromUtf8(pedDisk->type->name)); + const PartitionTable::TableType type = PartitionTable::nameToTableType(QString::fromLocal8Bit(pedDisk->type->name)); CoreBackend::setPartitionTableForDevice(*d, new PartitionTable(type, firstUsableSector(*d), lastUsableSector(*d))); CoreBackend::setPartitionTableMaxPrimaries(*d->partitionTable(), ped_disk_get_max_primary_partition_count(pedDisk)); @@ -426,7 +426,7 @@ QList LibPartedBackend::scanDevices(bool excludeReadOnly) QStringLiteral("type,name") }); if (cmd.run(-1) && cmd.exitCode() == 0) { - const QJsonDocument jsonDocument = QJsonDocument::fromJson(cmd.output().toUtf8()); + const QJsonDocument jsonDocument = QJsonDocument::fromJson(cmd.output().toLocal8Bit()); QJsonObject jsonObject = jsonDocument.object(); const QJsonArray jsonArray = jsonObject[QLatin1String("blockdevices")].toArray(); for (const auto &deviceLine : jsonArray) { @@ -479,7 +479,7 @@ FileSystem::Type LibPartedBackend::detectFileSystem(const QString& partitionPath partitionPath.toLocal8Bit().constData(), BLKID_DEV_NORMAL)) != nullptr) { char *string = blkid_get_tag_value(cache, "TYPE", partitionPath.toLocal8Bit().constData()); - QString s = QString::fromUtf8(string); + QString s = QString::fromLocal8Bit(string); free(string); if (s == QStringLiteral("ext2")) rval = FileSystem::Ext2; @@ -497,7 +497,7 @@ FileSystem::Type LibPartedBackend::detectFileSystem(const QString& partitionPath else if (s == QStringLiteral("vfat")) { // libblkid uses SEC_TYPE to distinguish between FAT16 and FAT32 string = blkid_get_tag_value(cache, "SEC_TYPE", partitionPath.toLocal8Bit().constData()); - QString st = QString::fromUtf8(string); + QString st = QString::fromLocal8Bit(string); free(string); if (st == QStringLiteral("msdos")) rval = FileSystem::Fat16; diff --git a/src/plugins/libparted/libparteddevice.cpp b/src/plugins/libparted/libparteddevice.cpp index 4a3bc30..6354b58 100644 --- a/src/plugins/libparted/libparteddevice.cpp +++ b/src/plugins/libparted/libparteddevice.cpp @@ -45,7 +45,7 @@ bool LibPartedDevice::open() if (pedDevice()) return false; - m_PedDevice = ped_device_get(deviceNode().toLatin1().constData()); + m_PedDevice = ped_device_get(deviceNode().toLocal8Bit().constData()); return m_PedDevice != nullptr; } @@ -87,14 +87,14 @@ CoreBackendPartitionTable* LibPartedDevice::openPartitionTable() bool LibPartedDevice::createPartitionTable(Report& report, const PartitionTable& ptable) { - PedDiskType* pedDiskType = ped_disk_type_get(ptable.typeName().toLatin1().constData()); + PedDiskType* pedDiskType = ped_disk_type_get(ptable.typeName().toLocal8Bit().constData()); if (pedDiskType == nullptr) { report.line() << xi18nc("@info:progress", "Creating partition table failed: Could not retrieve partition table type \"%1\" for %2.", ptable.typeName(), deviceNode()); return false; } - PedDevice* dev = ped_device_get(deviceNode().toLatin1().constData()); + PedDevice* dev = ped_device_get(deviceNode().toLocal8Bit().constData()); if (dev == nullptr) { report.line() << xi18nc("@info:progress", "Creating partition table failed: Could not open backend device %1.", deviceNode()); diff --git a/src/plugins/libparted/libpartedpartitiontable.cpp b/src/plugins/libparted/libpartedpartitiontable.cpp index 34cbb10..d4fd7e2 100644 --- a/src/plugins/libparted/libpartedpartitiontable.cpp +++ b/src/plugins/libparted/libpartedpartitiontable.cpp @@ -125,7 +125,7 @@ static PedFileSystemType* getPedFileSystemType(FileSystem::Type t) { for (quint32 i = 0; i < sizeof(mapFileSystemTypeToLibPartedName) / sizeof(mapFileSystemTypeToLibPartedName[0]); i++) if (mapFileSystemTypeToLibPartedName[i].type == t) - return ped_file_system_type_get(mapFileSystemTypeToLibPartedName[i].name.toLatin1().constData()); + return ped_file_system_type_get(mapFileSystemTypeToLibPartedName[i].name.toLocal8Bit().constData()); // if we didn't find anything, go with ext2 as a safe fallback return ped_file_system_type_get("ext2"); @@ -133,7 +133,7 @@ static PedFileSystemType* getPedFileSystemType(FileSystem::Type t) QString LibPartedPartitionTable::createPartition(Report& report, const Partition& partition) { - Q_ASSERT(partition.devicePath() == QString::fromUtf8(pedDevice()->path)); + Q_ASSERT(partition.devicePath() == QString::fromLocal8Bit(pedDevice()->path)); QString rval = QString(); @@ -177,11 +177,11 @@ QString LibPartedPartitionTable::createPartition(Report& report, const Partition if (ped_disk_add_partition(pedDisk(), pedPartition, pedConstraint)) { char *pedPath = ped_partition_get_path(pedPartition); - rval = QString::fromUtf8(pedPath); + rval = QString::fromLocal8Bit(pedPath); free(pedPath); } else { - report.line() << xi18nc("@info:progress", "Failed to add partition %1 to device %2.", partition.deviceNode(), QString::fromUtf8(pedDisk()->dev->path)); + report.line() << xi18nc("@info:progress", "Failed to add partition %1 to device %2.", partition.deviceNode(), QString::fromLocal8Bit(pedDisk()->dev->path)); report.line() << LibPartedBackend::lastPartedExceptionMessage(); } @@ -192,7 +192,7 @@ QString LibPartedPartitionTable::createPartition(Report& report, const Partition bool LibPartedPartitionTable::deletePartition(Report& report, const Partition& partition) { - Q_ASSERT(partition.devicePath() == QString::fromUtf8(pedDevice()->path)); + Q_ASSERT(partition.devicePath() == QString::fromLocal8Bit(pedDevice()->path)); bool rval = false; @@ -213,7 +213,7 @@ bool LibPartedPartitionTable::deletePartition(Report& report, const Partition& p bool LibPartedPartitionTable::updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end) { - Q_ASSERT(partition.devicePath() == QString::fromUtf8(pedDevice()->path)); + Q_ASSERT(partition.devicePath() == QString::fromLocal8Bit(pedDevice()->path)); bool rval = false; @@ -317,7 +317,7 @@ FileSystem::Type LibPartedPartitionTable::detectFileSystemBySector(Report& repor char* pedPath = ped_partition_get_path(pedPartition); FileSystem::Type type = FileSystem::Unknown; if (pedPartition && pedPath) - type = CoreBackendManager::self()->backend()->detectFileSystem(QString::fromUtf8(pedPath)); + type = CoreBackendManager::self()->backend()->detectFileSystem(QString::fromLocal8Bit(pedPath)); else report.line() << xi18nc("@info:progress", "Could not determine file system of partition at sector %1 on device %2.", sector, device.deviceNode()); free(pedPath); diff --git a/src/util/externalcommand.cpp b/src/util/externalcommand.cpp index fd6f4e9..2bbc8fc 100644 --- a/src/util/externalcommand.cpp +++ b/src/util/externalcommand.cpp @@ -59,7 +59,7 @@ ExternalCommand::ExternalCommand(Report& report, const QString& cmd, const QStri void ExternalCommand::setup(const QProcess::ProcessChannelMode processChannelMode) { - setEnvironment(QStringList() << QStringLiteral("LC_ALL=C") << QStringLiteral("PATH=") + QString::fromUtf8(getenv("PATH")) << QStringLiteral("LVM_SUPPRESS_FD_WARNINGS=1")); + setEnvironment(QStringList() << QStringLiteral("LC_ALL=C") << QStringLiteral("PATH=") + QString::fromLocal8Bit(getenv("PATH")) << QStringLiteral("LVM_SUPPRESS_FD_WARNINGS=1")); setProcessChannelMode(processChannelMode); connect(this, qOverload(&QProcess::finished), this, &ExternalCommand::onFinished); diff --git a/src/util/htmlreport.cpp b/src/util/htmlreport.cpp index e0b00d6..0db2e3e 100644 --- a/src/util/htmlreport.cpp +++ b/src/util/htmlreport.cpp @@ -71,7 +71,7 @@ QString HtmlReport::header() struct utsname info; uname(&info); - const QString unameString = QString::fromUtf8(info.sysname) + QStringLiteral(" ") + QString::fromUtf8(info.nodename) + QStringLiteral(" ") + QString::fromUtf8(info.release) + QStringLiteral(" ") + QString::fromUtf8(info.version) + QStringLiteral(" ") + QString::fromUtf8(info.machine); + const QString unameString = QString::fromLocal8Bit(info.sysname) + QStringLiteral(" ") + QString::fromLocal8Bit(info.nodename) + QStringLiteral(" ") + QString::fromLocal8Bit(info.release) + QStringLiteral(" ") + QString::fromLocal8Bit(info.version) + QStringLiteral(" ") + QString::fromLocal8Bit(info.machine); s << "\n" << tableLine(i18n("Date:"), QLocale().toString(QDateTime::currentDateTime(), QLocale::ShortFormat))