From 80de99fc73268c92e3466c53c199ae17971b0a25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Tue, 7 Nov 2017 22:55:28 +0000 Subject: [PATCH] Move setFlags function from CoreBackendPartition to CoreBackendPartitionTable. setFlags function now takes additional argument const Partition& partition. This allows us to completely remove CoreBackendPartition class. Remove getPartitionBySector and getExtendedPartitions. These functions were designed around libparted API and are not very convenient with other backends. --- src/backend/CMakeLists.txt | 2 - src/backend/corebackendpartition.cpp | 23 ------- src/backend/corebackendpartition.h | 49 --------------- src/backend/corebackendpartitiontable.h | 24 ++++---- src/jobs/setpartflagsjob.cpp | 26 +++----- src/plugins/dummy/CMakeLists.txt | 1 - src/plugins/dummy/dummypartition.cpp | 36 ----------- src/plugins/dummy/dummypartition.h | 40 ------------ src/plugins/dummy/dummypartitiontable.cpp | 61 +++++++++---------- src/plugins/dummy/dummypartitiontable.h | 4 +- src/plugins/libparted/CMakeLists.txt | 1 - src/plugins/libparted/libpartedpartition.cpp | 53 ---------------- src/plugins/libparted/libpartedpartition.h | 49 --------------- .../libparted/libpartedpartitiontable.cpp | 58 ++++++++++-------- .../libparted/libpartedpartitiontable.h | 4 +- src/plugins/sfdisk/CMakeLists.txt | 1 - src/plugins/sfdisk/sfdiskpartition.cpp | 35 ----------- src/plugins/sfdisk/sfdiskpartition.h | 40 ------------ src/plugins/sfdisk/sfdiskpartitiontable.cpp | 33 +++++----- src/plugins/sfdisk/sfdiskpartitiontable.h | 4 +- 20 files changed, 99 insertions(+), 445 deletions(-) delete mode 100644 src/backend/corebackendpartition.cpp delete mode 100644 src/backend/corebackendpartition.h delete mode 100644 src/plugins/dummy/dummypartition.cpp delete mode 100644 src/plugins/dummy/dummypartition.h delete mode 100644 src/plugins/libparted/libpartedpartition.cpp delete mode 100644 src/plugins/libparted/libpartedpartition.h delete mode 100644 src/plugins/sfdisk/sfdiskpartition.cpp delete mode 100644 src/plugins/sfdisk/sfdiskpartition.h diff --git a/src/backend/CMakeLists.txt b/src/backend/CMakeLists.txt index 1fb65f4..dc004d0 100644 --- a/src/backend/CMakeLists.txt +++ b/src/backend/CMakeLists.txt @@ -2,7 +2,6 @@ set(BACKEND_SRC backend/corebackendmanager.cpp backend/corebackenddevice.cpp backend/corebackend.cpp - backend/corebackendpartition.cpp backend/corebackendpartitiontable.cpp ) @@ -10,6 +9,5 @@ set(BACKEND_LIB_HDRS backend/corebackend.h backend/corebackenddevice.h backend/corebackendmanager.h - backend/corebackendpartition.h backend/corebackendpartitiontable.h ) diff --git a/src/backend/corebackendpartition.cpp b/src/backend/corebackendpartition.cpp deleted file mode 100644 index 2255528..0000000 --- a/src/backend/corebackendpartition.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/************************************************************************* - * Copyright (C) 2010 by Volker Lanz * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of * - * the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see .* - *************************************************************************/ - -#include "backend/corebackendpartition.h" - - -CoreBackendPartition::CoreBackendPartition() -{ -} diff --git a/src/backend/corebackendpartition.h b/src/backend/corebackendpartition.h deleted file mode 100644 index e902b57..0000000 --- a/src/backend/corebackendpartition.h +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************************* - * Copyright (C) 2010 by Volker Lanz * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of * - * the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see .* - *************************************************************************/ - -#if !defined(KPMCORE_COREBACKENDPARTITION_H) - -#define KPMCORE_COREBACKENDPARTITION_H - -#include "util/libpartitionmanagerexport.h" - -#include "core/partitiontable.h" - -class Report; - -/** - * Represents a partition in the backend plugin. - * @author Volker Lanz - */ -class LIBKPMCORE_EXPORT CoreBackendPartition -{ -public: - CoreBackendPartition(); - virtual ~CoreBackendPartition() {} - -public: - /** - * Set a flag for the partition - * @param report the Report to write information to - * @param flag the flag to set - * @param state the state to set the flag to (i.e., on or off) - * @return true on success - */ - virtual bool setFlag(Report& report, PartitionTable::Flag flag, bool state) = 0; -}; - -#endif diff --git a/src/backend/corebackendpartitiontable.h b/src/backend/corebackendpartitiontable.h index 560031a..1e402ac 100644 --- a/src/backend/corebackendpartitiontable.h +++ b/src/backend/corebackendpartitiontable.h @@ -19,9 +19,9 @@ #define KPMCORE_COREBACKENDPARTITIONTABLE_H -#include "util/libpartitionmanagerexport.h" - +#include "core/partitiontable.h" #include "fs/filesystem.h" +#include "util/libpartitionmanagerexport.h" #include @@ -52,17 +52,6 @@ public: */ virtual bool commit(quint32 timeout = 10) = 0; - /** - * @return pointer to the extended partition as a CoreBackendPartition or nullptr if there is none - */ - virtual CoreBackendPartition* getExtendedPartition() = 0; - - /** - * @param sector sector the partition occupies - * @return the CoreBackendPartition to occupy the given sector or nullptr if not found - */ - virtual CoreBackendPartition* getPartitionBySector(qint64 sector) = 0; - /** * Delete a partition. * @param report the report to write information to @@ -123,6 +112,15 @@ public: * @return true on success */ virtual bool setPartitionSystemType(Report& report, const Partition& partition) = 0; + + /** + * Set a flag for the partition + * @param report the Report to write information to + * @param flag the flag to set + * @param state the state to set the flag to (i.e., on or off) + * @return true on success + */ + virtual bool setFlag(Report& report, const Partition& partition, PartitionTable::Flag flag, bool state) = 0; }; #endif diff --git a/src/jobs/setpartflagsjob.cpp b/src/jobs/setpartflagsjob.cpp index 6f8417a..7fd8715 100644 --- a/src/jobs/setpartflagsjob.cpp +++ b/src/jobs/setpartflagsjob.cpp @@ -21,7 +21,6 @@ #include "backend/corebackend.h" #include "backend/corebackendmanager.h" #include "backend/corebackenddevice.h" -#include "backend/corebackendpartition.h" #include "backend/corebackendpartitiontable.h" #include "core/device.h" @@ -63,29 +62,18 @@ bool SetPartFlagsJob::run(Report& parent) CoreBackendPartitionTable* backendPartitionTable = backendDevice->openPartitionTable(); if (backendPartitionTable) { - CoreBackendPartition* backendPartition = (partition().roles().has(PartitionRole::Extended)) - ? backendPartitionTable->getExtendedPartition() - : backendPartitionTable->getPartitionBySector(partition().firstSector()); + int count = 0; - if (backendPartition) { - int count = 0; + for (const auto &f : PartitionTable::flagList()) { + emit progress(++count); - for (const auto &f : PartitionTable::flagList()) { - emit progress(++count); + const bool state = (flags() & f) ? true : false; - const bool state = (flags() & f) ? true : false; + if (!backendPartitionTable->setFlag(*report, partition(), f, state)) { + report->line() << xi18nc("@info:progress", "There was an error setting flag %1 for partition %2 to state %3.", PartitionTable::flagName(f), partition().deviceNode(), state ? xi18nc("@info:progress flag turned on, active", "on") : xi18nc("@info:progress flag turned off, inactive", "off")); - if (!backendPartition->setFlag(*report, f, state)) { - report->line() << xi18nc("@info:progress", "There was an error setting flag %1 for partition %2 to state %3.", PartitionTable::flagName(f), partition().deviceNode(), state ? xi18nc("@info:progress flag turned on, active", "on") : xi18nc("@info:progress flag turned off, inactive", "off")); - - rval = false; - } + rval = false; } - - delete backendPartition; - } else { - report->line() << xi18nc("@info:progress", "Could not find partition %1 on device %2 to set partition flags.", partition().deviceNode(), device().deviceNode()); - rval = false; } if (rval) diff --git a/src/plugins/dummy/CMakeLists.txt b/src/plugins/dummy/CMakeLists.txt index b7b0ea7..b935d6e 100644 --- a/src/plugins/dummy/CMakeLists.txt +++ b/src/plugins/dummy/CMakeLists.txt @@ -16,7 +16,6 @@ set (pmdummybackendplugin_SRCS dummybackend.cpp dummydevice.cpp - dummypartition.cpp dummypartitiontable.cpp ) diff --git a/src/plugins/dummy/dummypartition.cpp b/src/plugins/dummy/dummypartition.cpp deleted file mode 100644 index f4c335f..0000000 --- a/src/plugins/dummy/dummypartition.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/************************************************************************* - * Copyright (C) 2010 by Volker Lanz * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of * - * the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see .* - *************************************************************************/ - -#include "plugins/dummy/dummypartition.h" -#include "plugins/dummy/dummybackend.h" - -#include "util/report.h" - -DummyPartition::DummyPartition() : - CoreBackendPartition() -{ -} - -bool DummyPartition::setFlag(Report& report, PartitionTable::Flag partitionManagerFlag, bool state) -{ - Q_UNUSED(report); - Q_UNUSED(partitionManagerFlag); - Q_UNUSED(state); - - return true; -} - diff --git a/src/plugins/dummy/dummypartition.h b/src/plugins/dummy/dummypartition.h deleted file mode 100644 index d560fe8..0000000 --- a/src/plugins/dummy/dummypartition.h +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************* - * Copyright (C) 2010 by Volker Lanz * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of * - * the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see .* - *************************************************************************/ - -#if !defined(KPMCORE_DUMMYPARTITION_H) - -#define KPMCORE_DUMMYPARTITION_H - -#include "backend/corebackendpartition.h" - -#include "core/partitiontable.h" - -class Report; - -class DummyPartition : public CoreBackendPartition -{ - Q_DISABLE_COPY(DummyPartition) - -public: - DummyPartition(); - -public: - bool setFlag(Report& report, PartitionTable::Flag flag, bool state) override; -}; - - -#endif diff --git a/src/plugins/dummy/dummypartitiontable.cpp b/src/plugins/dummy/dummypartitiontable.cpp index 8c21d25..8da9328 100644 --- a/src/plugins/dummy/dummypartitiontable.cpp +++ b/src/plugins/dummy/dummypartitiontable.cpp @@ -16,7 +16,6 @@ *************************************************************************/ #include "plugins/dummy/dummypartitiontable.h" -#include "plugins/dummy/dummypartition.h" #include "plugins/dummy/dummybackend.h" #include "core/partition.h" @@ -43,71 +42,59 @@ bool DummyPartitionTable::open() bool DummyPartitionTable::commit(quint32 timeout) { - Q_UNUSED(timeout); + Q_UNUSED(timeout) return true; } -CoreBackendPartition* DummyPartitionTable::getExtendedPartition() -{ - return new DummyPartition(); -} - -CoreBackendPartition* DummyPartitionTable::getPartitionBySector(qint64 sector) -{ - Q_UNUSED(sector); - - return new DummyPartition(); -} - QString DummyPartitionTable::createPartition(Report& report, const Partition& partition) { - Q_UNUSED(report); - Q_UNUSED(partition); + Q_UNUSED(report) + Q_UNUSED(partition) return QStringLiteral("dummy"); } bool DummyPartitionTable::deletePartition(Report& report, const Partition& partition) { - Q_UNUSED(report); - Q_UNUSED(partition); + Q_UNUSED(report) + Q_UNUSED(partition) return true; } bool DummyPartitionTable::updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end) { - Q_UNUSED(report); - Q_UNUSED(partition); - Q_UNUSED(sector_start); - Q_UNUSED(sector_end); + Q_UNUSED(report) + Q_UNUSED(partition) + Q_UNUSED(sector_start) + Q_UNUSED(sector_end) return true; } bool DummyPartitionTable::clobberFileSystem(Report& report, const Partition& partition) { - Q_UNUSED(report); - Q_UNUSED(partition); + Q_UNUSED(report) + Q_UNUSED(partition) return true; } bool DummyPartitionTable::resizeFileSystem(Report& report, const Partition& partition, qint64 newLength) { - Q_UNUSED(report); - Q_UNUSED(partition); - Q_UNUSED(newLength); + Q_UNUSED(report) + Q_UNUSED(partition) + Q_UNUSED(newLength) return true; } FileSystem::Type DummyPartitionTable::detectFileSystemBySector(Report& report, const Device& device, qint64 sector) { - Q_UNUSED(report); - Q_UNUSED(device); - Q_UNUSED(sector); + Q_UNUSED(report) + Q_UNUSED(device) + Q_UNUSED(sector) FileSystem::Type rval = FileSystem::Unknown; return rval; @@ -115,8 +102,18 @@ FileSystem::Type DummyPartitionTable::detectFileSystemBySector(Report& report, c bool DummyPartitionTable::setPartitionSystemType(Report& report, const Partition& partition) { - Q_UNUSED(report); - Q_UNUSED(partition); + Q_UNUSED(report) + Q_UNUSED(partition) + + return true; +} + +bool DummyPartitionTable::setFlag(Report& report, const Partition& partition, PartitionTable::Flag partitionManagerFlag, bool state) +{ + Q_UNUSED(report) + Q_UNUSED(partition) + Q_UNUSED(partitionManagerFlag) + Q_UNUSED(state) return true; } diff --git a/src/plugins/dummy/dummypartitiontable.h b/src/plugins/dummy/dummypartitiontable.h index 6a3289c..3d1da5b 100644 --- a/src/plugins/dummy/dummypartitiontable.h +++ b/src/plugins/dummy/dummypartitiontable.h @@ -40,9 +40,6 @@ public: bool commit(quint32 timeout = 10) override; - CoreBackendPartition* getExtendedPartition() override; - CoreBackendPartition* getPartitionBySector(qint64 sector) override; - QString createPartition(Report& report, const Partition& partition) override; bool deletePartition(Report& report, const Partition& partition) override; bool updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end) override; @@ -50,6 +47,7 @@ public: bool resizeFileSystem(Report& report, const Partition& partition, qint64 newLength) override; FileSystem::Type detectFileSystemBySector(Report& report, const Device& device, qint64 sector) override; bool setPartitionSystemType(Report& report, const Partition& partition) override; + bool setFlag(Report& report, const Partition& partition, PartitionTable::Flag partitionManagerFlag, bool state) override; }; #endif diff --git a/src/plugins/libparted/CMakeLists.txt b/src/plugins/libparted/CMakeLists.txt index 0995554..a123e44 100644 --- a/src/plugins/libparted/CMakeLists.txt +++ b/src/plugins/libparted/CMakeLists.txt @@ -28,7 +28,6 @@ include_directories(${LIBPARTED_INCLUDE_DIR}) set (pmlibpartedbackendplugin_SRCS libpartedbackend.cpp libparteddevice.cpp - libpartedpartition.cpp libpartedpartitiontable.cpp ) diff --git a/src/plugins/libparted/libpartedpartition.cpp b/src/plugins/libparted/libpartedpartition.cpp deleted file mode 100644 index f82a8d7..0000000 --- a/src/plugins/libparted/libpartedpartition.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/************************************************************************* - * Copyright (C) 2010 by Volker Lanz * - * Copyright (C) 2016 by Andrius Štikonas * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of * - * the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see .* - *************************************************************************/ - -#include "plugins/libparted/libpartedpartition.h" -#include "plugins/libparted/libpartedbackend.h" - -#include "util/report.h" - -#include - -LibPartedPartition::LibPartedPartition(PedPartition* ped_partition) : - CoreBackendPartition(), - m_PedPartition(ped_partition) -{ -} - -bool LibPartedPartition::setFlag(Report& report, PartitionTable::Flag partitionManagerFlag, bool state) -{ - Q_ASSERT(pedPartition() != nullptr); - - const PedPartitionFlag f = LibPartedBackend::getPedFlag(partitionManagerFlag); - - // ignore flags that don't exist for this partition - if (!ped_partition_is_flag_available(pedPartition(), f)) { - report.line() << xi18nc("@info:progress", "The flag \"%1\" is not available on the partition's partition table.", PartitionTable::flagName(partitionManagerFlag)); - return true; - } - - // Workaround: libparted claims the hidden flag is available for extended partitions, but - // throws an error when we try to set or clear it. So skip this combination. - if (pedPartition()->type == PED_PARTITION_EXTENDED && partitionManagerFlag == PartitionTable::FlagHidden) - return true; - - if (!ped_partition_set_flag(pedPartition(), f, state ? 1 : 0)) - return false; - - return true; -} diff --git a/src/plugins/libparted/libpartedpartition.h b/src/plugins/libparted/libpartedpartition.h deleted file mode 100644 index 60b61a1..0000000 --- a/src/plugins/libparted/libpartedpartition.h +++ /dev/null @@ -1,49 +0,0 @@ -/************************************************************************* - * Copyright (C) 2010 by Volker Lanz * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of * - * the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see .* - *************************************************************************/ - -#if !defined(KPMCORE_LIBPARTEDPARTITION_H) - -#define KPMCORE_LIBPARTEDPARTITION_H - -#include "backend/corebackendpartition.h" - -#include "core/partitiontable.h" - -#include - -class Report; - -class LibPartedPartition : public CoreBackendPartition -{ - Q_DISABLE_COPY(LibPartedPartition) - -public: - LibPartedPartition(PedPartition* ped_partition); - -public: - bool setFlag(Report& report, PartitionTable::Flag flag, bool state) override; - -private: - PedPartition* pedPartition() { - return m_PedPartition; - } - -private: - PedPartition* m_PedPartition; -}; - -#endif diff --git a/src/plugins/libparted/libpartedpartitiontable.cpp b/src/plugins/libparted/libpartedpartitiontable.cpp index 34cbb10..6c96386 100644 --- a/src/plugins/libparted/libpartedpartitiontable.cpp +++ b/src/plugins/libparted/libpartedpartitiontable.cpp @@ -17,7 +17,6 @@ *************************************************************************/ #include "plugins/libparted/libpartedpartitiontable.h" -#include "plugins/libparted/libpartedpartition.h" #include "plugins/libparted/libpartedbackend.h" #include "backend/corebackend.h" @@ -76,26 +75,6 @@ bool LibPartedPartitionTable::commit(PedDisk* pd, quint32 timeout) return rval; } -CoreBackendPartition* LibPartedPartitionTable::getExtendedPartition() -{ - PedPartition* pedPartition = ped_disk_extended_partition(pedDisk()); - - if (pedPartition == nullptr) - return nullptr; - - return new LibPartedPartition(pedPartition); -} - -CoreBackendPartition* LibPartedPartitionTable::getPartitionBySector(qint64 sector) -{ - PedPartition* pedPartition = ped_disk_get_partition_by_sector(pedDisk(), sector); - - if (pedPartition == nullptr) - return nullptr; - - return new LibPartedPartition(pedPartition); -} - static const struct { FileSystem::Type type; QString name; @@ -302,9 +281,9 @@ bool LibPartedPartitionTable::resizeFileSystem(Report& report, const Partition& } else report.line() << xi18nc("@info:progress", "Could not read geometry for partition %1 while trying to resize the file system.", partition.deviceNode()); #else - Q_UNUSED(report); - Q_UNUSED(partition); - Q_UNUSED(newLength); + Q_UNUSED(report) + Q_UNUSED(partition) + Q_UNUSED(newLength) #endif return rval; @@ -344,3 +323,34 @@ bool LibPartedPartitionTable::setPartitionSystemType(Report& report, const Parti return ped_partition_set_system(pedPartition, pedFsType) != 0; } +bool LibPartedPartitionTable::setFlag(Report& report, const Partition& partition, PartitionTable::Flag partitionManagerFlag, bool state) +{ + PedPartition* pedPartition; + if (partition.roles().has(PartitionRole::Extended)) + pedPartition = ped_disk_extended_partition(pedDisk()); + else + pedPartition = ped_disk_get_partition_by_sector(pedDisk(), partition.firstSector()); + if (pedPartition == nullptr) { + QString deviceNode = QString::fromUtf8(pedDevice()->path); + report.line() << xi18nc("@info:progress", "Could not find partition %1 on device %2 to set partition flags.", partition.deviceNode(), deviceNode); + return false; + } + + const PedPartitionFlag f = LibPartedBackend::getPedFlag(partitionManagerFlag); + + // ignore flags that don't exist for this partition + if (!ped_partition_is_flag_available(pedPartition, f)) { + report.line() << xi18nc("@info:progress", "The flag \"%1\" is not available on the partition's partition table.", PartitionTable::flagName(partitionManagerFlag)); + return true; + } + + // Workaround: libparted claims the hidden flag is available for extended partitions, but + // throws an error when we try to set or clear it. So skip this combination. + if (pedPartition->type == PED_PARTITION_EXTENDED && partitionManagerFlag == PartitionTable::FlagHidden) + return true; + + if (!ped_partition_set_flag(pedPartition, f, state ? 1 : 0)) + return false; + + return true; +} diff --git a/src/plugins/libparted/libpartedpartitiontable.h b/src/plugins/libparted/libpartedpartitiontable.h index efa71b2..3158e34 100644 --- a/src/plugins/libparted/libpartedpartitiontable.h +++ b/src/plugins/libparted/libpartedpartitiontable.h @@ -43,9 +43,6 @@ public: bool commit(quint32 timeout = 10) override; static bool commit(PedDisk* pd, quint32 timeout = 10); - CoreBackendPartition* getExtendedPartition() override; - CoreBackendPartition* getPartitionBySector(qint64 sector) override; - QString createPartition(Report& report, const Partition& partition) override; bool deletePartition(Report& report, const Partition& partition) override; bool updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end) override; @@ -53,6 +50,7 @@ public: bool resizeFileSystem(Report& report, const Partition& partition, qint64 newLength) override; FileSystem::Type detectFileSystemBySector(Report& report, const Device& device, qint64 sector) override; bool setPartitionSystemType(Report& report, const Partition& partition) override; + bool setFlag(Report& report, const Partition& partition, PartitionTable::Flag partitionManagerFlag, bool state) override; private: PedDevice* pedDevice() { diff --git a/src/plugins/sfdisk/CMakeLists.txt b/src/plugins/sfdisk/CMakeLists.txt index a795063..6b21c07 100644 --- a/src/plugins/sfdisk/CMakeLists.txt +++ b/src/plugins/sfdisk/CMakeLists.txt @@ -16,7 +16,6 @@ set (pmsfdiskbackendplugin_SRCS sfdiskbackend.cpp sfdiskdevice.cpp - sfdiskpartition.cpp sfdiskpartitiontable.cpp ) diff --git a/src/plugins/sfdisk/sfdiskpartition.cpp b/src/plugins/sfdisk/sfdiskpartition.cpp deleted file mode 100644 index 09c5b9d..0000000 --- a/src/plugins/sfdisk/sfdiskpartition.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/************************************************************************* - * Copyright (C) 2017 by Andrius Štikonas * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of * - * the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see .* - *************************************************************************/ - -#include "plugins/sfdisk/sfdiskpartition.h" -#include "plugins/sfdisk/sfdiskbackend.h" - -#include "util/report.h" - -SfdiskPartition::SfdiskPartition() : - CoreBackendPartition() -{ -} - -bool SfdiskPartition::setFlag(Report& report, PartitionTable::Flag partitionManagerFlag, bool state) -{ - Q_UNUSED(report); - Q_UNUSED(partitionManagerFlag); - Q_UNUSED(state); - - return true; -} diff --git a/src/plugins/sfdisk/sfdiskpartition.h b/src/plugins/sfdisk/sfdiskpartition.h deleted file mode 100644 index 35a0a03..0000000 --- a/src/plugins/sfdisk/sfdiskpartition.h +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************* - * Copyright (C) 2017 by Andrius Štikonas * - * * - * This program is free software; you can redistribute it and/or * - * modify it under the terms of the GNU General Public License as * - * published by the Free Software Foundation; either version 3 of * - * the License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see .* - *************************************************************************/ - -#if !defined(SFDISKPARTITION__H) - -#define SFDISKPARTITION__H - -#include "backend/corebackendpartition.h" - -#include "core/partitiontable.h" - -class Report; - -class SfdiskPartition : public CoreBackendPartition -{ - Q_DISABLE_COPY(SfdiskPartition); - -public: - SfdiskPartition(); - -public: - bool setFlag(Report& report, PartitionTable::Flag flag, bool state) override; -}; - - -#endif diff --git a/src/plugins/sfdisk/sfdiskpartitiontable.cpp b/src/plugins/sfdisk/sfdiskpartitiontable.cpp index befe761..8bf2bc9 100644 --- a/src/plugins/sfdisk/sfdiskpartitiontable.cpp +++ b/src/plugins/sfdisk/sfdiskpartitiontable.cpp @@ -16,7 +16,6 @@ *************************************************************************/ #include "plugins/sfdisk/sfdiskpartitiontable.h" -#include "plugins/sfdisk/sfdiskpartition.h" #include "backend/corebackend.h" #include "backend/corebackendmanager.h" @@ -62,18 +61,6 @@ bool SfdiskPartitionTable::commit(quint32 timeout) return true; } -CoreBackendPartition* SfdiskPartitionTable::getExtendedPartition() -{ - return new SfdiskPartition(); -} - -CoreBackendPartition* SfdiskPartitionTable::getPartitionBySector(qint64 sector) -{ - Q_UNUSED(sector); - - return nullptr; -} - QString SfdiskPartitionTable::createPartition(Report& report, const Partition& partition) { if ( !(partition.roles().has(PartitionRole::Extended) || partition.roles().has(PartitionRole::Logical) || partition.roles().has(PartitionRole::Primary) ) ) { @@ -139,9 +126,9 @@ bool SfdiskPartitionTable::clobberFileSystem(Report& report, const Partition& pa bool SfdiskPartitionTable::resizeFileSystem(Report& report, const Partition& partition, qint64 newLength) { // sfdisk does not have any partition resize capabilities - Q_UNUSED(report); - Q_UNUSED(partition); - Q_UNUSED(newLength); + Q_UNUSED(report) + Q_UNUSED(partition) + Q_UNUSED(newLength) return false; } @@ -171,8 +158,18 @@ FileSystem::Type SfdiskPartitionTable::detectFileSystemBySector(Report& report, bool SfdiskPartitionTable::setPartitionSystemType(Report& report, const Partition& partition) { - Q_UNUSED(report); - Q_UNUSED(partition); + Q_UNUSED(report) + Q_UNUSED(partition) + + return true; +} + +bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, PartitionTable::Flag partitionManagerFlag, bool state) +{ + Q_UNUSED(report) + Q_UNUSED(partition) + Q_UNUSED(partitionManagerFlag) + Q_UNUSED(state) return true; } diff --git a/src/plugins/sfdisk/sfdiskpartitiontable.h b/src/plugins/sfdisk/sfdiskpartitiontable.h index 9fcbb6e..11e2f03 100644 --- a/src/plugins/sfdisk/sfdiskpartitiontable.h +++ b/src/plugins/sfdisk/sfdiskpartitiontable.h @@ -40,9 +40,6 @@ public: bool commit(quint32 timeout = 10) override; - CoreBackendPartition* getExtendedPartition() override; - CoreBackendPartition* getPartitionBySector(qint64 sector) override; - QString createPartition(Report& report, const Partition& partition) override; bool deletePartition(Report& report, const Partition& partition) override; bool updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end) override; @@ -50,6 +47,7 @@ public: bool resizeFileSystem(Report& report, const Partition& partition, qint64 newLength) override; FileSystem::Type detectFileSystemBySector(Report& report, const Device& device, qint64 sector) override; bool setPartitionSystemType(Report& report, const Partition& partition) override; + bool setFlag(Report& report, const Partition& partition, PartitionTable::Flag flag, bool state) override; private: QString m_deviceNode;