Compare commits
28 Commits
8a3d95e5ec
...
fa5937071b
Author | SHA1 | Date |
---|---|---|
Andrius Štikonas | fa5937071b | |
Andrius Štikonas | 6d272234bb | |
Andrius Štikonas | dd0adbec42 | |
Allen Winter | 3aebd00dee | |
Shubham Jangra | 5e4efa89ec | |
Caio Carvalho | 43da873c36 | |
Shubham Jangra | 281289dfbb | |
Shubham Jangra | 4986b514b5 | |
Shubham Jangra | 9c5b582ed0 | |
Shubham Jangra | c78b35eb41 | |
l10n daemon script | e8d6f7bab6 | |
Andrius Štikonas | 92065f7a23 | |
l10n daemon script | 8139d5c295 | |
l10n daemon script | 7b93571787 | |
Andrius Štikonas | 594c90f4ba | |
Andrius Štikonas | f5b5728c7f | |
Andrius Štikonas | 015f44f535 | |
Andrius Štikonas | 6f703b9309 | |
Albert Astals Cid | 90a6563291 | |
Albert Astals Cid | 7f6fa41bce | |
Andrius Štikonas | ecb78121f3 | |
Andrius Štikonas | 39a5645c38 | |
Andrius Štikonas | 723b05107d | |
Andrius Štikonas | 28e1308ec5 | |
Andrius Štikonas | 3df5acb9e3 | |
Andrius Štikonas | bfa6a327af | |
l10n daemon script | c8e401bc07 | |
Andrius Štikonas | 5a163f8bee |
|
@ -0,0 +1,3 @@
|
||||||
|
#the krazy i18ncheckarg hangs on this file due to extra double-quotes in a QRegularExpression.
|
||||||
|
#No idea how to fix properly so let's just skip the file
|
||||||
|
SKIP /src/fs/fat12.cpp
|
|
@ -23,16 +23,16 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
|
||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
set(QT_MIN_VERSION "5.10.0")
|
set(QT_MIN_VERSION "5.10.0")
|
||||||
set(KF5_MIN_VERSION "5.25")
|
set(KF5_MIN_VERSION "5.56")
|
||||||
set(BLKID_MIN_VERSION "2.32")
|
set(BLKID_MIN_VERSION "2.33.2")
|
||||||
# Qca-qt5 (tested with botan and ossl backends)
|
# Qca-qt5 (tested with botan and ossl backends)
|
||||||
|
|
||||||
# Runtime
|
# Runtime
|
||||||
# smartmontools 7.0
|
# smartmontools 7.0
|
||||||
# Qca plugin (botan or ossl)
|
# Qca plugin (botan or ossl)
|
||||||
|
|
||||||
set(VERSION_MAJOR "3")
|
set(VERSION_MAJOR "4")
|
||||||
set(VERSION_MINOR "80")
|
set(VERSION_MINOR "0")
|
||||||
set(VERSION_RELEASE "0")
|
set(VERSION_RELEASE "0")
|
||||||
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE})
|
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE})
|
||||||
set(SOVERSION "8")
|
set(SOVERSION "8")
|
||||||
|
|
|
@ -3,20 +3,20 @@ Building and installing KDE Partition Manager Core Library from source
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
* [util-linux](https://github.com/karelzak/util-linux) 2.32
|
* [util-linux](https://github.com/karelzak/util-linux) 2.34
|
||||||
|
|
||||||
* [Qt](https://www.qt.io/) 5.10
|
* [Qt](https://www.qt.io/) 5.10
|
||||||
|
|
||||||
* QCA
|
* QCA
|
||||||
|
|
||||||
* Tier 2 [KDE Frameworks](https://www.kde.org/products/frameworks/) 5.25
|
* Tier 2 [KDE Frameworks](https://www.kde.org/products/frameworks/) 5.56
|
||||||
|
|
||||||
## Configure
|
## Configure
|
||||||
|
|
||||||
KPMcore is built with [cmake](https://cmake.org/). It is recommended to build out of tree:
|
KPMcore is built with [cmake](https://cmake.org/). It is recommended to build out of tree:
|
||||||
After unpacking the source, create a separate build directory and run cmake there:
|
After unpacking the source, create a separate build directory and run cmake there:
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$ tar xf kpmcore-x.y.z.tar.xz
|
$ tar xf kpmcore-x.y.z.tar.xz
|
||||||
$ cd kpmcore-x.y.z
|
$ cd kpmcore-x.y.z
|
||||||
$ mkdir build
|
$ mkdir build
|
||||||
|
@ -35,7 +35,7 @@ configure a different install path by passing
|
||||||
`-DCMAKE_INSTALL_PREFIX=<your_path>` to cmake when configuring. To change the
|
`-DCMAKE_INSTALL_PREFIX=<your_path>` to cmake when configuring. To change the
|
||||||
install path after configuring and building, run
|
install path after configuring and building, run
|
||||||
|
|
||||||
```
|
```bash
|
||||||
$ ccmake .
|
$ ccmake .
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ KPMcore supports CMake as (meta-)build system and installs suitable
|
||||||
CMake support files. Typical use of of KPMcore in a `CMakeLists.txt`
|
CMake support files. Typical use of of KPMcore in a `CMakeLists.txt`
|
||||||
looks like this:
|
looks like this:
|
||||||
|
|
||||||
```
|
```cmake
|
||||||
find_package( KPMcore 3.2 REQUIRED )
|
find_package( KPMcore 3.2 REQUIRED )
|
||||||
include_directories( ${KPMCORE_INCLUDE_DIR} )
|
include_directories( ${KPMCORE_INCLUDE_DIR} )
|
||||||
target_link_libraries( target kpmcore )
|
target_link_libraries( target kpmcore )
|
||||||
|
@ -44,7 +44,7 @@ environment variable `KPMCORE_BACKEND` names a backend,
|
||||||
and typical initialization code will look like this (or use the
|
and typical initialization code will look like this (or use the
|
||||||
class `KPMCoreInitializer` from `test/helpers.h`):
|
class `KPMCoreInitializer` from `test/helpers.h`):
|
||||||
|
|
||||||
```
|
```cpp
|
||||||
#include <backend/corebackendmanager.h>
|
#include <backend/corebackendmanager.h>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ result in undefined behavior.
|
||||||
After the backend is initialized you can scan for available devices.
|
After the backend is initialized you can scan for available devices.
|
||||||
If you only want devices from the loaded backend you can call
|
If you only want devices from the loaded backend you can call
|
||||||
|
|
||||||
```
|
```cpp
|
||||||
QList<Device*> devices = backend->scanDevices( excludeReadOnly );
|
QList<Device*> devices = backend->scanDevices( excludeReadOnly );
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ read only devices.
|
||||||
|
|
||||||
Alternatively, you can use KPMcore device scanner
|
Alternatively, you can use KPMcore device scanner
|
||||||
|
|
||||||
```
|
```cpp
|
||||||
#include <core/device.h>
|
#include <core/device.h>
|
||||||
#include <core/devicescanner.h>
|
#include <core/devicescanner.h>
|
||||||
#include <core/operationstack.h>
|
#include <core/operationstack.h>
|
||||||
|
|
|
@ -49,7 +49,7 @@ target_link_libraries( kpmcore PUBLIC
|
||||||
KF5::I18n
|
KF5::I18n
|
||||||
KF5::CoreAddons
|
KF5::CoreAddons
|
||||||
KF5::WidgetsAddons
|
KF5::WidgetsAddons
|
||||||
KF5::Auth
|
KF5::AuthCore
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS kpmcore EXPORT KPMcoreTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
|
install(TARGETS kpmcore EXPORT KPMcoreTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||||
|
|
|
@ -36,6 +36,13 @@ class PartitionTable;
|
||||||
|
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
|
enum class ScanFlag : uint8_t {
|
||||||
|
includeReadOnly = 0x1, /**< devices that are read-only according to the kernel */
|
||||||
|
includeLoopback = 0x2,
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS(ScanFlags, ScanFlag)
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS(ScanFlags)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface class for backend plugins.
|
* Interface class for backend plugins.
|
||||||
* @author Volker Lanz <vl@fidra.de>
|
* @author Volker Lanz <vl@fidra.de>
|
||||||
|
@ -86,8 +93,7 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan for devices in the system.
|
* Scan for devices in the system.
|
||||||
* @param excludeReadOnly when true, devices that are read-only
|
* @param excludeReadOnly when true, are left out of the list.
|
||||||
* according to the kernel are left out of the list.
|
|
||||||
* When false (the default) all devices, writable or
|
* When false (the default) all devices, writable or
|
||||||
* not, including CD ROM devices, are returned.
|
* not, including CD ROM devices, are returned.
|
||||||
* @return a QList of pointers to Device instances. The caller is responsible
|
* @return a QList of pointers to Device instances. The caller is responsible
|
||||||
|
@ -95,7 +101,17 @@ public:
|
||||||
* @note A Device object is a description of the device, not
|
* @note A Device object is a description of the device, not
|
||||||
* an object to operate on. See openDevice().
|
* an object to operate on. See openDevice().
|
||||||
*/
|
*/
|
||||||
virtual QList<Device*> scanDevices(bool excludeReadOnly = false) = 0;
|
[[deprecated("port to scanDevices(ScanFlags)")]] virtual QList<Device*> scanDevices(bool excludeReadOnly = false) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scan for devices in the system.
|
||||||
|
* @param scanFlags can be used to expand the list of scanned devices.
|
||||||
|
* @return a QList of pointers to Device instances. The caller is responsible
|
||||||
|
* for deleting these objects.
|
||||||
|
* @note A Device object is a description of the device, not
|
||||||
|
* an object to operate on. See openDevice().
|
||||||
|
*/
|
||||||
|
virtual QList<Device*> scanDevices(const ScanFlags scanFlags) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan a single device in the system.
|
* Scan a single device in the system.
|
||||||
|
|
|
@ -63,7 +63,7 @@ void DeviceScanner::scan()
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
const QList<Device*> deviceList = CoreBackendManager::self()->backend()->scanDevices();
|
const QList<Device*> deviceList = CoreBackendManager::self()->backend()->scanDevices(ScanFlag::includeLoopback);
|
||||||
|
|
||||||
for (const auto &d : deviceList)
|
for (const auto &d : deviceList)
|
||||||
operationStack().addDevice(d);
|
operationStack().addDevice(d);
|
||||||
|
|
|
@ -193,7 +193,7 @@ Partition* LvmDevice::scanPartition(const QString& lvPath, PartitionTable* pTabl
|
||||||
startSector,
|
startSector,
|
||||||
endSector,
|
endSector,
|
||||||
lvPath,
|
lvPath,
|
||||||
PartitionTable::Flag::FlagNone,
|
PartitionTable::Flag::None,
|
||||||
mountPoint,
|
mountPoint,
|
||||||
mounted);
|
mounted);
|
||||||
return part;
|
return part;
|
||||||
|
|
|
@ -45,6 +45,8 @@ class LIBKPMCORE_EXPORT LvmDevice : public VolumeManagerDevice
|
||||||
{
|
{
|
||||||
Q_DISABLE_COPY(LvmDevice)
|
Q_DISABLE_COPY(LvmDevice)
|
||||||
|
|
||||||
|
friend class VolumeManagerDevice;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LvmDevice(const QString& name, const QString& iconName = QString());
|
LvmDevice(const QString& name, const QString& iconName = QString());
|
||||||
~LvmDevice();
|
~LvmDevice();
|
||||||
|
@ -57,8 +59,6 @@ public:
|
||||||
static QVector<const Partition*> s_DirtyPVs;
|
static QVector<const Partition*> s_DirtyPVs;
|
||||||
static QVector<const Partition*> s_OrphanPVs;
|
static QVector<const Partition*> s_OrphanPVs;
|
||||||
|
|
||||||
static void scanSystemLVM(QList<Device*>& devices);
|
|
||||||
|
|
||||||
static const QStringList getVGs();
|
static const QStringList getVGs();
|
||||||
static const QStringList getLVs(const QString& vgName);
|
static const QStringList getLVs(const QString& vgName);
|
||||||
|
|
||||||
|
@ -105,6 +105,9 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<QHash<QString, qint64>>& LVSizeMap() const;
|
std::unique_ptr<QHash<QString, qint64>>& LVSizeMap() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void scanSystemLVM(QList<Device*>& devices);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
OperationRunner(QObject* parent, OperationStack& ostack);
|
OperationRunner(QObject* parent, OperationStack& ostack);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void run();
|
void run() override;
|
||||||
qint32 numJobs() const;
|
qint32 numJobs() const;
|
||||||
qint32 numOperations() const;
|
qint32 numOperations() const;
|
||||||
qint32 numProgressSub() const;
|
qint32 numProgressSub() const;
|
||||||
|
|
|
@ -86,7 +86,7 @@ public:
|
||||||
StateRestore [[deprecated("Use Partition::State::Restore")]] = Restore
|
StateRestore [[deprecated("Use Partition::State::Restore")]] = Restore
|
||||||
};
|
};
|
||||||
|
|
||||||
Partition(PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem* fs, qint64 sectorStart, qint64 sectorEnd, QString partitionPath, PartitionTable::Flags availableFlags = PartitionTable::FlagNone, const QString& mountPoint = QString(), bool mounted = false, PartitionTable::Flags activeFlags = PartitionTable::FlagNone, State state = State::None);
|
Partition(PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem* fs, qint64 sectorStart, qint64 sectorEnd, QString partitionPath, PartitionTable::Flags availableFlags = PartitionTable::Flag::None, const QString& mountPoint = QString(), bool mounted = false, PartitionTable::Flags activeFlags = PartitionTable::Flag::None, State state = State::None);
|
||||||
~Partition() override;
|
~Partition() override;
|
||||||
|
|
||||||
Partition(const Partition& other, PartitionNode* parent = nullptr);
|
Partition(const Partition& other, PartitionNode* parent = nullptr);
|
||||||
|
@ -238,10 +238,10 @@ public:
|
||||||
void setMounted(bool b);
|
void setMounted(bool b);
|
||||||
|
|
||||||
void setFlag(PartitionTable::Flag f) {
|
void setFlag(PartitionTable::Flag f) {
|
||||||
m_ActiveFlags |= f;
|
m_ActiveFlags = m_ActiveFlags.setFlag(f);
|
||||||
}
|
}
|
||||||
void unsetFlag(PartitionTable::Flag f) {
|
void unsetFlag(PartitionTable::Flag f) {
|
||||||
m_ActiveFlags &= ~f;
|
m_ActiveFlags = m_ActiveFlags.setFlag(f, false);
|
||||||
}
|
}
|
||||||
void setParent(PartitionNode* p) {
|
void setParent(PartitionNode* p) {
|
||||||
m_Parent = p;
|
m_Parent = p;
|
||||||
|
|
|
@ -182,39 +182,39 @@ void PartitionTable::append(Partition* partition)
|
||||||
QString PartitionTable::flagName(Flag f)
|
QString PartitionTable::flagName(Flag f)
|
||||||
{
|
{
|
||||||
switch (f) {
|
switch (f) {
|
||||||
case PartitionTable::FlagBoot:
|
case PartitionTable::Flag::Boot:
|
||||||
return xi18nc("@item partition flag", "boot");
|
return xi18nc("@item partition flag", "boot");
|
||||||
case PartitionTable::FlagRoot:
|
case PartitionTable::Flag::Root:
|
||||||
return xi18nc("@item partition flag", "root");
|
return xi18nc("@item partition flag", "root");
|
||||||
case PartitionTable::FlagSwap:
|
case PartitionTable::Flag::Swap:
|
||||||
return xi18nc("@item partition flag", "swap");
|
return xi18nc("@item partition flag", "swap");
|
||||||
case PartitionTable::FlagHidden:
|
case PartitionTable::Flag::Hidden:
|
||||||
return xi18nc("@item partition flag", "hidden");
|
return xi18nc("@item partition flag", "hidden");
|
||||||
case PartitionTable::FlagRaid:
|
case PartitionTable::Flag::Raid:
|
||||||
return xi18nc("@item partition flag", "raid");
|
return xi18nc("@item partition flag", "raid");
|
||||||
case PartitionTable::FlagLvm:
|
case PartitionTable::Flag::Lvm:
|
||||||
return xi18nc("@item partition flag", "lvm");
|
return xi18nc("@item partition flag", "lvm");
|
||||||
case PartitionTable::FlagLba:
|
case PartitionTable::Flag::Lba:
|
||||||
return xi18nc("@item partition flag", "lba");
|
return xi18nc("@item partition flag", "lba");
|
||||||
case PartitionTable::FlagHpService:
|
case PartitionTable::Flag::HpService:
|
||||||
return xi18nc("@item partition flag", "hpservice");
|
return xi18nc("@item partition flag", "hpservice");
|
||||||
case PartitionTable::FlagPalo:
|
case PartitionTable::Flag::Palo:
|
||||||
return xi18nc("@item partition flag", "palo");
|
return xi18nc("@item partition flag", "palo");
|
||||||
case PartitionTable::FlagPrep:
|
case PartitionTable::Flag::Prep:
|
||||||
return xi18nc("@item partition flag", "prep");
|
return xi18nc("@item partition flag", "prep");
|
||||||
case PartitionTable::FlagMsftReserved:
|
case PartitionTable::Flag::MsftReserved:
|
||||||
return xi18nc("@item partition flag", "msft-reserved");
|
return xi18nc("@item partition flag", "msft-reserved");
|
||||||
case PartitionTable::FlagBiosGrub:
|
case PartitionTable::Flag::BiosGrub:
|
||||||
return xi18nc("@item partition flag", "bios-grub");
|
return xi18nc("@item partition flag", "bios-grub");
|
||||||
case PartitionTable::FlagAppleTvRecovery:
|
case PartitionTable::Flag::AppleTvRecovery:
|
||||||
return xi18nc("@item partition flag", "apple-tv-recovery");
|
return xi18nc("@item partition flag", "apple-tv-recovery");
|
||||||
case PartitionTable::FlagDiag:
|
case PartitionTable::Flag::Diag:
|
||||||
return xi18nc("@item partition flag", "diag");
|
return xi18nc("@item partition flag", "diag");
|
||||||
case PartitionTable::FlagLegacyBoot:
|
case PartitionTable::Flag::LegacyBoot:
|
||||||
return xi18nc("@item partition flag", "legacy-boot");
|
return xi18nc("@item partition flag", "legacy-boot");
|
||||||
case PartitionTable::FlagMsftData:
|
case PartitionTable::Flag::MsftData:
|
||||||
return xi18nc("@item partition flag", "msft-data");
|
return xi18nc("@item partition flag", "msft-data");
|
||||||
case PartitionTable::FlagIrst:
|
case PartitionTable::Flag::Irst:
|
||||||
return xi18nc("@item partition flag", "irst");
|
return xi18nc("@item partition flag", "irst");
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -228,23 +228,23 @@ const QList<PartitionTable::Flag> PartitionTable::flagList()
|
||||||
{
|
{
|
||||||
QList<PartitionTable::Flag> rval;
|
QList<PartitionTable::Flag> rval;
|
||||||
|
|
||||||
rval.append(PartitionTable::FlagBoot);
|
rval.append(PartitionTable::Flag::Boot);
|
||||||
rval.append(PartitionTable::FlagRoot);
|
rval.append(PartitionTable::Flag::Root);
|
||||||
rval.append(PartitionTable::FlagSwap);
|
rval.append(PartitionTable::Flag::Swap);
|
||||||
rval.append(PartitionTable::FlagHidden);
|
rval.append(PartitionTable::Flag::Hidden);
|
||||||
rval.append(PartitionTable::FlagRaid);
|
rval.append(PartitionTable::Flag::Raid);
|
||||||
rval.append(PartitionTable::FlagLvm);
|
rval.append(PartitionTable::Flag::Lvm);
|
||||||
rval.append(PartitionTable::FlagLba);
|
rval.append(PartitionTable::Flag::Lba);
|
||||||
rval.append(PartitionTable::FlagHpService);
|
rval.append(PartitionTable::Flag::HpService);
|
||||||
rval.append(PartitionTable::FlagPalo);
|
rval.append(PartitionTable::Flag::Palo);
|
||||||
rval.append(PartitionTable::FlagPrep);
|
rval.append(PartitionTable::Flag::Prep);
|
||||||
rval.append(PartitionTable::FlagMsftReserved);
|
rval.append(PartitionTable::Flag::MsftReserved);
|
||||||
rval.append(PartitionTable::FlagBiosGrub);
|
rval.append(PartitionTable::Flag::BiosGrub);
|
||||||
rval.append(PartitionTable::FlagAppleTvRecovery);
|
rval.append(PartitionTable::Flag::AppleTvRecovery);
|
||||||
rval.append(PartitionTable::FlagDiag);
|
rval.append(PartitionTable::Flag::Diag);
|
||||||
rval.append(PartitionTable::FlagLegacyBoot);
|
rval.append(PartitionTable::Flag::LegacyBoot);
|
||||||
rval.append(PartitionTable::FlagMsftData);
|
rval.append(PartitionTable::Flag::MsftData);
|
||||||
rval.append(PartitionTable::FlagIrst);
|
rval.append(PartitionTable::Flag::Irst);
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
@ -269,6 +269,20 @@ QStringList PartitionTable::flagNames(Flags flags)
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param list QStringList of the flags' names
|
||||||
|
@returns flags corresponding to names
|
||||||
|
*/
|
||||||
|
PartitionTable::Flags PartitionTable::flagsFromList(const QStringList list)
|
||||||
|
{
|
||||||
|
Flags flags;
|
||||||
|
|
||||||
|
for (const auto &flag : flagList())
|
||||||
|
if (list.contains(flagName(flag)))
|
||||||
|
flags.setFlag(flag);
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
bool PartitionTable::getUnallocatedRange(const Device& d, PartitionNode& parent, qint64& start, qint64& end)
|
bool PartitionTable::getUnallocatedRange(const Device& d, PartitionNode& parent, qint64& start, qint64& end)
|
||||||
{
|
{
|
||||||
if (d.type() == Device::Type::Disk_Device) {
|
if (d.type() == Device::Type::Disk_Device) {
|
||||||
|
|
|
@ -16,8 +16,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#if !defined(KPMCORE_PARTITIONTABLE_H)
|
#ifndef KPMCORE_PARTITIONTABLE_H
|
||||||
|
|
||||||
#define KPMCORE_PARTITIONTABLE_H
|
#define KPMCORE_PARTITIONTABLE_H
|
||||||
|
|
||||||
#include "util/libpartitionmanagerexport.h"
|
#include "util/libpartitionmanagerexport.h"
|
||||||
|
@ -50,7 +49,7 @@ class LIBKPMCORE_EXPORT PartitionTable : public PartitionNode
|
||||||
friend LIBKPMCORE_EXPORT QTextStream& operator<<(QTextStream& stream, const PartitionTable& ptable);
|
friend LIBKPMCORE_EXPORT QTextStream& operator<<(QTextStream& stream, const PartitionTable& ptable);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum TableType : qint8 {
|
enum TableType : int8_t {
|
||||||
unknownTableType = -1,
|
unknownTableType = -1,
|
||||||
|
|
||||||
aix,
|
aix,
|
||||||
|
@ -69,30 +68,47 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Partition flags */
|
/** Partition flags */
|
||||||
enum Flag : qint32 {
|
enum Flag : uint32_t {
|
||||||
FlagNone = 0,
|
None = 0x0,
|
||||||
FlagBoot = 1,
|
Boot = 0x1,
|
||||||
FlagRoot = 2,
|
Root = 0x2,
|
||||||
FlagSwap = 4,
|
Swap = 0x4,
|
||||||
FlagHidden = 8,
|
Hidden = 0x8,
|
||||||
FlagRaid = 16,
|
Raid = 0x10,
|
||||||
FlagLvm = 32,
|
Lvm = 0x20,
|
||||||
FlagLba = 64,
|
Lba = 0x40,
|
||||||
FlagHpService = 128,
|
HpService = 0x80,
|
||||||
FlagPalo = 256,
|
Palo = 0x100,
|
||||||
FlagPrep = 512,
|
Prep = 0x200,
|
||||||
FlagMsftReserved = 1024,
|
MsftReserved = 0x400,
|
||||||
FlagBiosGrub = 2048,
|
BiosGrub = 0x800,
|
||||||
FlagAppleTvRecovery = 4096,
|
AppleTvRecovery = 0x1000,
|
||||||
FlagDiag = 8192,
|
Diag = 0x2000,
|
||||||
FlagLegacyBoot = 16384,
|
LegacyBoot = 0x4000,
|
||||||
FlagMsftData = 32768,
|
MsftData = 0x8000,
|
||||||
FlagIrst = 65536,
|
Irst = 0x100000,
|
||||||
FlagEsp [[deprecated]] = FlagBoot
|
FlagNone [[deprecated("Use PartitionTable::Flag::None")]] = None,
|
||||||
|
FlagBoot [[deprecated("Use PartitionTable::Flag::Boot")]] = Boot,
|
||||||
|
FlagRoot [[deprecated("Use PartitionTable::Flag::Root")]] = Root,
|
||||||
|
FlagSwap [[deprecated("Use PartitionTable::Flag::Swap")]] = Swap,
|
||||||
|
FlagHidden [[deprecated("Use PartitionTable::Flag::Hidden")]] = Hidden,
|
||||||
|
FlagRaid [[deprecated("Use PartitionTable::Flag::Raid")]] = Raid,
|
||||||
|
FlagLvm [[deprecated("Use PartitionTable::Flag::Lvm")]] = Lvm,
|
||||||
|
FlagLba [[deprecated("Use PartitionTable::Flag::Lba")]] = Lba,
|
||||||
|
FlagHpService [[deprecated("Use PartitionTable::Flag::HpService")]] = HpService,
|
||||||
|
FlagPalo [[deprecated("Use PartitionTable::Flag::Palo")]] = Palo,
|
||||||
|
FlagPrep [[deprecated("Use PartitionTable::Flag::Prep")]] = Prep,
|
||||||
|
FlagMsftReserved [[deprecated("Use PartitionTable::Flag::MsftReserved")]] = MsftReserved,
|
||||||
|
FlagBiosGrub [[deprecated("Use PartitionTable::Flag::BiosGrub")]] = BiosGrub,
|
||||||
|
FlagAppleTvRecovery [[deprecated("Use PartitionTable::Flag::AppleTvRecovery")]] = AppleTvRecovery,
|
||||||
|
FlagDiag [[deprecated("Use PartitionTable::Flag::Diag")]] = Diag,
|
||||||
|
FlagLegacyBoot [[deprecated("Use PartitionTable::Flag::LegacyBoot")]] = LegacyBoot,
|
||||||
|
FlagMsftData [[deprecated("Use PartitionTable::Flag::MsftData")]] = MsftData,
|
||||||
|
FlagIrst [[deprecated("Use PartitionTable::Flag::Irst")]] = Irst,
|
||||||
|
FlagEsp [[deprecated("Use PartitionTable::Flag::Boot")]] = Boot
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_FLAGS(Flags, Flag)
|
Q_DECLARE_FLAGS(Flags, Flag)
|
||||||
Q_FLAG(Flag)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PartitionTable(TableType type, qint64 firstUsable, qint64 lastUsable);
|
PartitionTable(TableType type, qint64 firstUsable, qint64 lastUsable);
|
||||||
|
@ -168,6 +184,7 @@ public:
|
||||||
static const QList<Flag> flagList();
|
static const QList<Flag> flagList();
|
||||||
static QString flagName(Flag f);
|
static QString flagName(Flag f);
|
||||||
static QStringList flagNames(Flags f);
|
static QStringList flagNames(Flags f);
|
||||||
|
static PartitionTable::Flags flagsFromList(const QStringList list);
|
||||||
|
|
||||||
static bool getUnallocatedRange(const Device& device, PartitionNode& parent, qint64& start, qint64& end);
|
static bool getUnallocatedRange(const Device& device, PartitionNode& parent, qint64& start, qint64& end);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ class LIBKPMCORE_EXPORT SoftwareRAID : public VolumeManagerDevice
|
||||||
{
|
{
|
||||||
Q_DISABLE_COPY(SoftwareRAID)
|
Q_DISABLE_COPY(SoftwareRAID)
|
||||||
|
|
||||||
|
friend class VolumeManagerDevice;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum class Status {
|
enum class Status {
|
||||||
Active,
|
Active,
|
||||||
|
@ -61,8 +63,6 @@ public:
|
||||||
void setStatus(SoftwareRAID::Status status);
|
void setStatus(SoftwareRAID::Status status);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void scanSoftwareRAID(QList<Device*>& devices);
|
|
||||||
|
|
||||||
static qint32 getRaidLevel(const QString& path);
|
static qint32 getRaidLevel(const QString& path);
|
||||||
static qint64 getChunkSize(const QString& path);
|
static qint64 getChunkSize(const QString& path);
|
||||||
static qint64 getTotalChunk(const QString& path);
|
static qint64 getTotalChunk(const QString& path);
|
||||||
|
@ -95,6 +95,8 @@ protected:
|
||||||
qint64 mappedSector(const QString &partitionPath, qint64 sector) const override;
|
qint64 mappedSector(const QString &partitionPath, qint64 sector) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
static void scanSoftwareRAID(QList<Device*>& devices);
|
||||||
|
|
||||||
static QString getDetail(const QString& path);
|
static QString getDetail(const QString& path);
|
||||||
|
|
||||||
static QString getRAIDConfiguration(const QString& configurationPath);
|
static QString getRAIDConfiguration(const QString& configurationPath);
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include "core/device_p.h"
|
#include "core/device_p.h"
|
||||||
#include "core/volumemanagerdevice.h"
|
#include "core/volumemanagerdevice.h"
|
||||||
#include "core/volumemanagerdevice_p.h"
|
#include "core/volumemanagerdevice_p.h"
|
||||||
|
#include "core/lvmdevice.h"
|
||||||
|
#include "core/raid/softwareraid.h"
|
||||||
|
|
||||||
/** Constructs an abstract Volume Manager Device with an empty PartitionTable.
|
/** Constructs an abstract Volume Manager Device with an empty PartitionTable.
|
||||||
*
|
*
|
||||||
|
@ -37,6 +39,12 @@ VolumeManagerDevice::VolumeManagerDevice(std::shared_ptr<VolumeManagerDevicePriv
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VolumeManagerDevice::scanDevices(QList<Device*>& devices)
|
||||||
|
{
|
||||||
|
SoftwareRAID::scanSoftwareRAID(devices);
|
||||||
|
LvmDevice::scanSystemLVM(devices); // LVM scanner needs all other devices, so should be last
|
||||||
|
}
|
||||||
|
|
||||||
QString VolumeManagerDevice::prettyDeviceNodeList() const
|
QString VolumeManagerDevice::prettyDeviceNodeList() const
|
||||||
{
|
{
|
||||||
return deviceNodes().join(QStringLiteral(", "));
|
return deviceNodes().join(QStringLiteral(", "));
|
||||||
|
|
|
@ -80,6 +80,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
static void scanDevices(QList<Device*>& devices);
|
||||||
|
|
||||||
/** join deviceNodes together into comma-separated list
|
/** join deviceNodes together into comma-separated list
|
||||||
*
|
*
|
||||||
* @return comma-separated list of deviceNodes
|
* @return comma-separated list of deviceNodes
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
#include <QRegularExpression>
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
namespace FS
|
namespace FS
|
||||||
{
|
{
|
||||||
|
|
||||||
|
FileSystem::CommandSupportType unknown::m_Move = FileSystem::cmdSupportNone;
|
||||||
|
|
||||||
unknown::unknown(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
|
unknown::unknown(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
|
||||||
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Unknown)
|
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Type::Unknown)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#if !defined(KPMCORE_UNKNOWN_H)
|
#ifndef KPMCORE_UNKNOWN_H
|
||||||
|
|
||||||
#define KPMCORE_UNKNOWN_H
|
#define KPMCORE_UNKNOWN_H
|
||||||
|
|
||||||
#include "util/libpartitionmanagerexport.h"
|
#include "util/libpartitionmanagerexport.h"
|
||||||
|
@ -40,6 +39,12 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool canMount(const QString & deviceNode, const QString & mountPoint) const override;
|
bool canMount(const QString & deviceNode, const QString & mountPoint) const override;
|
||||||
|
|
||||||
|
CommandSupportType supportMove() const override {
|
||||||
|
return m_Move;
|
||||||
|
}
|
||||||
|
|
||||||
|
static CommandSupportType m_Move;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -142,11 +142,11 @@ protected:
|
||||||
m_Device = &d;
|
m_Device = &d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void paintEvent(QPaintEvent* event);
|
void paintEvent(QPaintEvent* event) override;
|
||||||
void resizeEvent(QResizeEvent* event);
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
void mousePressEvent(QMouseEvent* event);
|
void mousePressEvent(QMouseEvent* event) override;
|
||||||
void mouseMoveEvent(QMouseEvent* event);
|
void mouseMoveEvent(QMouseEvent* event) override;
|
||||||
void mouseReleaseEvent(QMouseEvent* event);
|
void mouseReleaseEvent(QMouseEvent* event) override;
|
||||||
|
|
||||||
PartWidget& partWidget() {
|
PartWidget& partWidget() {
|
||||||
Q_ASSERT(m_PartWidget);
|
Q_ASSERT(m_PartWidget);
|
||||||
|
|
|
@ -64,8 +64,8 @@ public:
|
||||||
void setFileSystemColorCode( const std::vector<QColor>& colorCode );
|
void setFileSystemColorCode( const std::vector<QColor>& colorCode );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent* event);
|
void paintEvent(QPaintEvent* event) override;
|
||||||
void resizeEvent(QResizeEvent* event);
|
void resizeEvent(QResizeEvent* event) override;
|
||||||
|
|
||||||
QColor activeColor(const QColor& col) const;
|
QColor activeColor(const QColor& col) const;
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ Partition* CopyOperation::createCopy(const Partition& target, const Partition& s
|
||||||
p->fileSystem().setFirstSector(p->firstSector());
|
p->fileSystem().setFirstSector(p->firstSector());
|
||||||
p->fileSystem().setLastSector(p->lastSector());
|
p->fileSystem().setLastSector(p->lastSector());
|
||||||
|
|
||||||
p->setFlags(PartitionTable::FlagNone);
|
p->setFlags(PartitionTable::Flag::None);
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ NewOperation::NewOperation(Device& d, Partition* p) :
|
||||||
addJob(createFileSystemJob());
|
addJob(createFileSystemJob());
|
||||||
|
|
||||||
if (fs.type() == FileSystem::Type::Lvm2_PV) {
|
if (fs.type() == FileSystem::Type::Lvm2_PV) {
|
||||||
m_SetPartFlagsJob = new SetPartFlagsJob(targetDevice(), newPartition(), PartitionTable::FlagLvm);
|
m_SetPartFlagsJob = new SetPartFlagsJob(targetDevice(), newPartition(), PartitionTable::Flag::Lvm);
|
||||||
addJob(setPartFlagsJob());
|
addJob(setPartFlagsJob());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,15 +46,21 @@ void DummyBackend::initFSSupport()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Device*> DummyBackend::scanDevices(bool excludeLoop)
|
QList<Device*> DummyBackend::scanDevices(bool excludeReadOnly)
|
||||||
{
|
{
|
||||||
Q_UNUSED(excludeLoop)
|
Q_UNUSED(excludeReadOnly)
|
||||||
|
return scanDevices(ScanFlags());
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<Device*> DummyBackend::scanDevices(const ScanFlags scanFlags)
|
||||||
|
{
|
||||||
|
Q_UNUSED(scanFlags)
|
||||||
QList<Device*> result;
|
QList<Device*> result;
|
||||||
result.append(scanDevice(QStringLiteral("/dev/sda")));
|
result.append(scanDevice(QStringLiteral("/dev/sda")));
|
||||||
|
|
||||||
emitScanProgress(QStringLiteral("/dev/sda"), 100);
|
emitScanProgress(QStringLiteral("/dev/sda"), 100);
|
||||||
|
|
||||||
return result;
|
return scanDevices(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Device* DummyBackend::scanDevice(const QString& deviceNode)
|
Device* DummyBackend::scanDevice(const QString& deviceNode)
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
void initFSSupport() override;
|
void initFSSupport() override;
|
||||||
|
|
||||||
QList<Device*> scanDevices(bool excludeReadOnly = false) override;
|
QList<Device*> scanDevices(bool excludeReadOnly = false) override;
|
||||||
|
QList<Device*> scanDevices(const ScanFlags scanFlags) override;
|
||||||
std::unique_ptr<CoreBackendDevice> openDevice(const Device& d) override;
|
std::unique_ptr<CoreBackendDevice> openDevice(const Device& d) override;
|
||||||
std::unique_ptr<CoreBackendDevice> openDeviceExclusive(const Device& d) override;
|
std::unique_ptr<CoreBackendDevice> openDeviceExclusive(const Device& d) override;
|
||||||
bool closeDevice(std::unique_ptr<CoreBackendDevice> coreDevice) override;
|
bool closeDevice(std::unique_ptr<CoreBackendDevice> coreDevice) override;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
"Name[ca@valencia]": "Volker Lanz",
|
"Name[ca@valencia]": "Volker Lanz",
|
||||||
"Name[ca]": "Volker Lanz",
|
"Name[ca]": "Volker Lanz",
|
||||||
"Name[cs]": "Volker Lanz",
|
"Name[cs]": "Volker Lanz",
|
||||||
|
"Name[da]": "Volker Lanz",
|
||||||
"Name[de]": "Volker Lanz",
|
"Name[de]": "Volker Lanz",
|
||||||
"Name[el]": "Volker Lanz",
|
"Name[el]": "Volker Lanz",
|
||||||
"Name[en_GB]": "Volker Lanz",
|
"Name[en_GB]": "Volker Lanz",
|
||||||
|
@ -23,11 +24,13 @@
|
||||||
"Name[pl]": "Volker Lanz",
|
"Name[pl]": "Volker Lanz",
|
||||||
"Name[pt]": "Volker Lanz",
|
"Name[pt]": "Volker Lanz",
|
||||||
"Name[pt_BR]": "Volker Lanz",
|
"Name[pt_BR]": "Volker Lanz",
|
||||||
|
"Name[ru]": "Volker Lanz",
|
||||||
"Name[sk]": "Volker Lanz",
|
"Name[sk]": "Volker Lanz",
|
||||||
"Name[sv]": "Volker Lanz",
|
"Name[sv]": "Volker Lanz",
|
||||||
"Name[uk]": "Volker Lanz",
|
"Name[uk]": "Volker Lanz",
|
||||||
"Name[x-test]": "xxVolker Lanzxx",
|
"Name[x-test]": "xxVolker Lanzxx",
|
||||||
"Name[zh_CN]": "Volker Lanz"
|
"Name[zh_CN]": "Volker Lanz",
|
||||||
|
"Name[zh_TW]": "Volker Lanz"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Category": "BackendPlugin",
|
"Category": "BackendPlugin",
|
||||||
|
@ -35,6 +38,7 @@
|
||||||
"Description[ca@valencia]": "Un dorsal fals del gestor de particions del KDE amb la finalitat de fer proves.",
|
"Description[ca@valencia]": "Un dorsal fals del gestor de particions del KDE amb la finalitat de fer proves.",
|
||||||
"Description[ca]": "Un dorsal fals del gestor de particions del KDE amb la finalitat de fer proves.",
|
"Description[ca]": "Un dorsal fals del gestor de particions del KDE amb la finalitat de fer proves.",
|
||||||
"Description[cs]": "Falešná podpůrná vrstva pro správce diskových oddílů KDE pro testovací účely.",
|
"Description[cs]": "Falešná podpůrná vrstva pro správce diskových oddílů KDE pro testovací účely.",
|
||||||
|
"Description[da]": "En KDE-partitionshåndtering med attrap-backend til testformål.",
|
||||||
"Description[de]": "Ein Dummy-Backend für die KDE-Partitionsverwaltung zu Testzwecken.",
|
"Description[de]": "Ein Dummy-Backend für die KDE-Partitionsverwaltung zu Testzwecken.",
|
||||||
"Description[el]": "Ένα εικονικό σύστημα υποστήριξης διαχειριστή κατατμήσεων του KDE για δοκιμές.",
|
"Description[el]": "Ένα εικονικό σύστημα υποστήριξης διαχειριστή κατατμήσεων του KDE για δοκιμές.",
|
||||||
"Description[en_GB]": "A KDE Partition Manager dummy backend for testing purposes.",
|
"Description[en_GB]": "A KDE Partition Manager dummy backend for testing purposes.",
|
||||||
|
@ -54,6 +58,7 @@
|
||||||
"Description[uk]": "Тестовий додаток сервера Керування розділами KDE.",
|
"Description[uk]": "Тестовий додаток сервера Керування розділами KDE.",
|
||||||
"Description[x-test]": "xxA KDE Partition Manager dummy backend for testing purposes.xx",
|
"Description[x-test]": "xxA KDE Partition Manager dummy backend for testing purposes.xx",
|
||||||
"Description[zh_CN]": "测试用的 KDE 分区管理器的虚拟后端",
|
"Description[zh_CN]": "测试用的 KDE 分区管理器的虚拟后端",
|
||||||
|
"Description[zh_TW]": "使用虛設後端的 KDE 磁碟分割區管理員,可用來測試。",
|
||||||
"EnabledByDefault": true,
|
"EnabledByDefault": true,
|
||||||
"Icon": "preferences-plugin",
|
"Icon": "preferences-plugin",
|
||||||
"Id": "pmdummybackendplugin",
|
"Id": "pmdummybackendplugin",
|
||||||
|
@ -62,6 +67,7 @@
|
||||||
"Name[ca@valencia]": "Dorsal fals del gestor de particions del KDE",
|
"Name[ca@valencia]": "Dorsal fals del gestor de particions del KDE",
|
||||||
"Name[ca]": "Dorsal fals del gestor de particions del KDE",
|
"Name[ca]": "Dorsal fals del gestor de particions del KDE",
|
||||||
"Name[cs]": "Podpůrná vrstva pro správce diskových oddílů pro KDE",
|
"Name[cs]": "Podpůrná vrstva pro správce diskových oddílů pro KDE",
|
||||||
|
"Name[da]": "KDE-partitionshåndtering med attrap-backend",
|
||||||
"Name[de]": "KDE-Partitionsverwaltung Dummy-Backend",
|
"Name[de]": "KDE-Partitionsverwaltung Dummy-Backend",
|
||||||
"Name[el]": "KDE Εικονικό σύστημα υποστήριξης διαχειριστή κατατμήσεων",
|
"Name[el]": "KDE Εικονικό σύστημα υποστήριξης διαχειριστή κατατμήσεων",
|
||||||
"Name[en_GB]": "KDE Partition Manager Dummy Backend",
|
"Name[en_GB]": "KDE Partition Manager Dummy Backend",
|
||||||
|
@ -82,6 +88,7 @@
|
||||||
"Name[uk]": "Тестовий додаток сервера Керування розділами KDE",
|
"Name[uk]": "Тестовий додаток сервера Керування розділами KDE",
|
||||||
"Name[x-test]": "xxKDE Partition Manager Dummy Backendxx",
|
"Name[x-test]": "xxKDE Partition Manager Dummy Backendxx",
|
||||||
"Name[zh_CN]": "KDE 分区管理器虚拟后端",
|
"Name[zh_CN]": "KDE 分区管理器虚拟后端",
|
||||||
|
"Name[zh_TW]": "KDE 磁碟分割區管理員 (虛設後端)",
|
||||||
"ServiceTypes": [
|
"ServiceTypes": [
|
||||||
"PartitionManager/Plugin"
|
"PartitionManager/Plugin"
|
||||||
],
|
],
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
"Name[ca@valencia]": "Andrius Štikonas",
|
"Name[ca@valencia]": "Andrius Štikonas",
|
||||||
"Name[ca]": "Andrius Štikonas",
|
"Name[ca]": "Andrius Štikonas",
|
||||||
"Name[cs]": "Andrius Štikonas",
|
"Name[cs]": "Andrius Štikonas",
|
||||||
|
"Name[da]": "Andrius Štikonas",
|
||||||
"Name[de]": "Andrius Štikonas",
|
"Name[de]": "Andrius Štikonas",
|
||||||
"Name[el]": "Andrius Štikonas",
|
"Name[el]": "Andrius Štikonas",
|
||||||
"Name[en_GB]": "Andrius Štikonas",
|
"Name[en_GB]": "Andrius Štikonas",
|
||||||
|
@ -23,11 +24,13 @@
|
||||||
"Name[pl]": "Andrius Štikonas",
|
"Name[pl]": "Andrius Štikonas",
|
||||||
"Name[pt]": "Andrius Štikonas",
|
"Name[pt]": "Andrius Štikonas",
|
||||||
"Name[pt_BR]": "Andrius Štikonas",
|
"Name[pt_BR]": "Andrius Štikonas",
|
||||||
|
"Name[ru]": "Andrius Štikonas",
|
||||||
"Name[sk]": "Andrius Štikonas",
|
"Name[sk]": "Andrius Štikonas",
|
||||||
"Name[sv]": "Andrius Štikonas",
|
"Name[sv]": "Andrius Štikonas",
|
||||||
"Name[uk]": "Andrius Štikonas",
|
"Name[uk]": "Andrius Štikonas",
|
||||||
"Name[x-test]": "xxAndrius Štikonasxx",
|
"Name[x-test]": "xxAndrius Štikonasxx",
|
||||||
"Name[zh_CN]": "Andrius Štikonas"
|
"Name[zh_CN]": "Andrius Štikonas",
|
||||||
|
"Name[zh_TW]": "Andrius Štikonas"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"Category": "BackendPlugin",
|
"Category": "BackendPlugin",
|
||||||
|
@ -35,6 +38,7 @@
|
||||||
"Description[ca@valencia]": "Un dorsal «sfdisk» del gestor de particions del KDE.",
|
"Description[ca@valencia]": "Un dorsal «sfdisk» del gestor de particions del KDE.",
|
||||||
"Description[ca]": "Un dorsal «sfdisk» del gestor de particions del KDE.",
|
"Description[ca]": "Un dorsal «sfdisk» del gestor de particions del KDE.",
|
||||||
"Description[cs]": "Podpůrná vrstva sfdisk pro správce diskových oddílů pro KDE.",
|
"Description[cs]": "Podpůrná vrstva sfdisk pro správce diskových oddílů pro KDE.",
|
||||||
|
"Description[da]": "En KDE-partitionshåndtering med sfdisk-backend.",
|
||||||
"Description[de]": "Ein sfdisk-Backend für die KDE-Partitionsverwaltung.",
|
"Description[de]": "Ein sfdisk-Backend für die KDE-Partitionsverwaltung.",
|
||||||
"Description[el]": "Σύστημα υποστήριξης sfdisk διαχειριστή κατατμήσεων του KDE.",
|
"Description[el]": "Σύστημα υποστήριξης sfdisk διαχειριστή κατατμήσεων του KDE.",
|
||||||
"Description[en_GB]": "A KDE Partition Manager sfdisk backend.",
|
"Description[en_GB]": "A KDE Partition Manager sfdisk backend.",
|
||||||
|
@ -53,6 +57,7 @@
|
||||||
"Description[sv]": "Ett sfdisk bakgrundsprogram till KDE:s partitionshanterare",
|
"Description[sv]": "Ett sfdisk bakgrundsprogram till KDE:s partitionshanterare",
|
||||||
"Description[uk]": "Додаток sfdisk сервера Керування розділами KDE.",
|
"Description[uk]": "Додаток sfdisk сервера Керування розділами KDE.",
|
||||||
"Description[x-test]": "xxA KDE Partition Manager sfdisk backend.xx",
|
"Description[x-test]": "xxA KDE Partition Manager sfdisk backend.xx",
|
||||||
|
"Description[zh_TW]": "使用 sfdisk 作為後端的 KDE 磁碟分割區管理員。",
|
||||||
"EnabledByDefault": true,
|
"EnabledByDefault": true,
|
||||||
"Icon": "preferences-plugin",
|
"Icon": "preferences-plugin",
|
||||||
"Id": "pmsfdiskbackendplugin",
|
"Id": "pmsfdiskbackendplugin",
|
||||||
|
@ -61,6 +66,7 @@
|
||||||
"Name[ca@valencia]": "Dorsal «sfdisk» del gestor de particions del KDE",
|
"Name[ca@valencia]": "Dorsal «sfdisk» del gestor de particions del KDE",
|
||||||
"Name[ca]": "Dorsal «sfdisk» del gestor de particions del KDE",
|
"Name[ca]": "Dorsal «sfdisk» del gestor de particions del KDE",
|
||||||
"Name[cs]": "Podpůrná vrstva sfdisk pro správce diskových oddílů pro KDE",
|
"Name[cs]": "Podpůrná vrstva sfdisk pro správce diskových oddílů pro KDE",
|
||||||
|
"Name[da]": "KDE-partitionshåndtering med sfdisk-backend",
|
||||||
"Name[de]": "KDE-Partitionsverwaltung sfdisk-Backend",
|
"Name[de]": "KDE-Partitionsverwaltung sfdisk-Backend",
|
||||||
"Name[el]": "KDE Σύστημα υποστήριξης sfdisk διαχειριστή κατατμήσεων",
|
"Name[el]": "KDE Σύστημα υποστήριξης sfdisk διαχειριστή κατατμήσεων",
|
||||||
"Name[en_GB]": "KDE Partition Manager sfdisk Backend",
|
"Name[en_GB]": "KDE Partition Manager sfdisk Backend",
|
||||||
|
@ -79,6 +85,7 @@
|
||||||
"Name[sv]": "KDE:s partitionshanterare sfdisk bakgrundsprogram",
|
"Name[sv]": "KDE:s partitionshanterare sfdisk bakgrundsprogram",
|
||||||
"Name[uk]": "Додаток sfdisk сервера Керування розділами KDE",
|
"Name[uk]": "Додаток sfdisk сервера Керування розділами KDE",
|
||||||
"Name[x-test]": "xxKDE Partition Manager sfdisk Backendxx",
|
"Name[x-test]": "xxKDE Partition Manager sfdisk Backendxx",
|
||||||
|
"Name[zh_TW]": "KDE 磁碟分割區管理員 (sfdisk 後端)",
|
||||||
"ServiceTypes": [
|
"ServiceTypes": [
|
||||||
"PartitionManager/Plugin"
|
"PartitionManager/Plugin"
|
||||||
],
|
],
|
||||||
|
|
|
@ -64,7 +64,14 @@ void SfdiskBackend::initFSSupport()
|
||||||
|
|
||||||
QList<Device*> SfdiskBackend::scanDevices(bool excludeReadOnly)
|
QList<Device*> SfdiskBackend::scanDevices(bool excludeReadOnly)
|
||||||
{
|
{
|
||||||
// TODO: add another bool option for loopDevices
|
return scanDevices(excludeReadOnly ? ScanFlags() : ScanFlag::includeReadOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<Device*> SfdiskBackend::scanDevices(const ScanFlags scanFlags)
|
||||||
|
{
|
||||||
|
const bool includeReadOnly = scanFlags.testFlag(ScanFlag::includeReadOnly);
|
||||||
|
const bool includeLoopback = scanFlags.testFlag(ScanFlag::includeLoopback);
|
||||||
|
|
||||||
QList<Device*> result;
|
QList<Device*> result;
|
||||||
QStringList deviceNodes;
|
QStringList deviceNodes;
|
||||||
|
|
||||||
|
@ -82,11 +89,14 @@ QList<Device*> SfdiskBackend::scanDevices(bool excludeReadOnly)
|
||||||
const QJsonArray jsonArray = jsonObject[QLatin1String("blockdevices")].toArray();
|
const QJsonArray jsonArray = jsonObject[QLatin1String("blockdevices")].toArray();
|
||||||
for (const auto &deviceLine : jsonArray) {
|
for (const auto &deviceLine : jsonArray) {
|
||||||
QJsonObject deviceObject = deviceLine.toObject();
|
QJsonObject deviceObject = deviceLine.toObject();
|
||||||
if (deviceObject[QLatin1String("type")].toString() != QLatin1String("disk"))
|
if (! (deviceObject[QLatin1String("type")].toString() == QLatin1String("disk")
|
||||||
|
|| (includeLoopback && deviceObject[QLatin1String("type")].toString() == QLatin1String("loop")) ))
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const QString deviceNode = deviceObject[QLatin1String("name")].toString();
|
const QString deviceNode = deviceObject[QLatin1String("name")].toString();
|
||||||
if (excludeReadOnly) {
|
if (!includeReadOnly) {
|
||||||
QString deviceName = deviceNode;
|
QString deviceName = deviceNode;
|
||||||
deviceName.remove(QStringLiteral("/dev/"));
|
deviceName.remove(QStringLiteral("/dev/"));
|
||||||
QFile f(QStringLiteral("/sys/block/%1/ro").arg(deviceName));
|
QFile f(QStringLiteral("/sys/block/%1/ro").arg(deviceName));
|
||||||
|
@ -107,14 +117,15 @@ QList<Device*> SfdiskBackend::scanDevices(bool excludeReadOnly)
|
||||||
result.append(device);
|
result.append(device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SoftwareRAID::scanSoftwareRAID(result);
|
|
||||||
LvmDevice::scanSystemLVM(result); // LVM scanner needs all other devices, so should be last
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VolumeManagerDevice::scanDevices(result); // scan all types of VolumeManagerDevices
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Create a Device for the given device_node and scan it for partitions.
|
/** Create a Device for the given device_node and scan it for partitions.
|
||||||
@param deviceNode the device node (e.g. "/dev/sda")
|
@param deviceNode the device node (e.g. "/dev/sda")
|
||||||
@return the created Device object. callers need to free this.
|
@return the created Device object. callers need to free this.
|
||||||
|
@ -213,8 +224,6 @@ Device* SfdiskBackend::scanDevice(const QString& deviceNode)
|
||||||
{
|
{
|
||||||
QList<Device *> availableDevices = scanDevices();
|
QList<Device *> availableDevices = scanDevices();
|
||||||
|
|
||||||
LvmDevice::scanSystemLVM(availableDevices);
|
|
||||||
|
|
||||||
for (Device *device : qAsConst(availableDevices))
|
for (Device *device : qAsConst(availableDevices))
|
||||||
if (device->deviceNode() == deviceNode)
|
if (device->deviceNode() == deviceNode)
|
||||||
return device;
|
return device;
|
||||||
|
@ -240,18 +249,19 @@ void SfdiskBackend::scanDevicePartitions(Device& d, const QJsonArray& jsonPartit
|
||||||
const qint64 start = partitionObject[QLatin1String("start")].toVariant().toLongLong();
|
const qint64 start = partitionObject[QLatin1String("start")].toVariant().toLongLong();
|
||||||
const qint64 size = partitionObject[QLatin1String("size")].toVariant().toLongLong();
|
const qint64 size = partitionObject[QLatin1String("size")].toVariant().toLongLong();
|
||||||
const QString partitionType = partitionObject[QLatin1String("type")].toString();
|
const QString partitionType = partitionObject[QLatin1String("type")].toString();
|
||||||
PartitionTable::Flags activeFlags = partitionObject[QLatin1String("bootable")].toBool() ? PartitionTable::FlagBoot : PartitionTable::FlagNone;
|
PartitionTable::Flags activeFlags = partitionObject[QLatin1String("bootable")].toBool() ? PartitionTable::Flag::Boot : PartitionTable::Flag::None;
|
||||||
|
|
||||||
if (partitionType == QStringLiteral("C12A7328-F81F-11D2-BA4B-00A0C93EC93B"))
|
if (partitionType == QStringLiteral("C12A7328-F81F-11D2-BA4B-00A0C93EC93B"))
|
||||||
activeFlags |= PartitionTable::FlagBoot;
|
activeFlags |= PartitionTable::Flag::Boot;
|
||||||
else if (partitionType == QStringLiteral("21686148-6449-6E6F-744E-656564454649"))
|
else if (partitionType == QStringLiteral("21686148-6449-6E6F-744E-656564454649"))
|
||||||
activeFlags |= PartitionTable::FlagBiosGrub;
|
activeFlags |= PartitionTable::Flag::BiosGrub;
|
||||||
|
|
||||||
FileSystem::Type type = FileSystem::Type::Unknown;
|
FileSystem::Type type = FileSystem::Type::Unknown;
|
||||||
type = detectFileSystem(partitionNode);
|
type = detectFileSystem(partitionNode);
|
||||||
PartitionRole::Roles r = PartitionRole::Primary;
|
PartitionRole::Roles r = PartitionRole::Primary;
|
||||||
|
|
||||||
if ( (d.partitionTable()->type() == PartitionTable::msdos || d.partitionTable()->type() == PartitionTable::msdos_sectorbased) && partitionType.toInt() == 5 ) {
|
if ( (d.partitionTable()->type() == PartitionTable::msdos || d.partitionTable()->type() == PartitionTable::msdos_sectorbased) &&
|
||||||
|
( partitionType == QStringLiteral("5") || partitionType == QStringLiteral("f") ) ) {
|
||||||
r = PartitionRole::Extended;
|
r = PartitionRole::Extended;
|
||||||
type = FileSystem::Type::Extended;
|
type = FileSystem::Type::Extended;
|
||||||
}
|
}
|
||||||
|
@ -317,16 +327,15 @@ bool SfdiskBackend::updateDevicePartitionTable(Device &d, const QJsonObject &jso
|
||||||
QString tableType = jsonPartitionTable[QLatin1String("label")].toString();
|
QString tableType = jsonPartitionTable[QLatin1String("label")].toString();
|
||||||
const PartitionTable::TableType type = PartitionTable::nameToTableType(tableType);
|
const PartitionTable::TableType type = PartitionTable::nameToTableType(tableType);
|
||||||
|
|
||||||
qint64 firstUsableSector = 0, lastUsableSector;
|
qint64 firstUsableSector = 0;
|
||||||
|
qint64 lastUsableSector;
|
||||||
|
|
||||||
if ( d.type() == Device::Type::Disk_Device )
|
if (d.type() == Device::Type::Disk_Device) {
|
||||||
{
|
|
||||||
const DiskDevice* diskDevice = static_cast<const DiskDevice*>(&d);
|
const DiskDevice* diskDevice = static_cast<const DiskDevice*>(&d);
|
||||||
|
|
||||||
lastUsableSector = diskDevice->totalSectors();
|
lastUsableSector = diskDevice->totalSectors();
|
||||||
}
|
}
|
||||||
else if ( d.type() == Device::Type::SoftwareRAID_Device )
|
else if (d.type() == Device::Type::SoftwareRAID_Device) {
|
||||||
{
|
|
||||||
const SoftwareRAID* raidDevice = static_cast<const SoftwareRAID*>(&d);
|
const SoftwareRAID* raidDevice = static_cast<const SoftwareRAID*>(&d);
|
||||||
|
|
||||||
lastUsableSector = raidDevice->totalLogical() - 1;
|
lastUsableSector = raidDevice->totalLogical() - 1;
|
||||||
|
@ -361,6 +370,7 @@ bool SfdiskBackend::updateDevicePartitionTable(Device &d, const QJsonObject &jso
|
||||||
else
|
else
|
||||||
maxEntries = 128;
|
maxEntries = 128;
|
||||||
CoreBackend::setPartitionTableMaxPrimaries(*d.partitionTable(), maxEntries);
|
CoreBackend::setPartitionTableMaxPrimaries(*d.partitionTable(), maxEntries);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -494,11 +504,11 @@ PartitionTable::Flags SfdiskBackend::availableFlags(PartitionTable::TableType ty
|
||||||
if (type == PartitionTable::gpt) {
|
if (type == PartitionTable::gpt) {
|
||||||
// These are not really flags but for now keep them for compatibility
|
// These are not really flags but for now keep them for compatibility
|
||||||
// We should implement changing partition type
|
// We should implement changing partition type
|
||||||
flags = PartitionTable::Flag::FlagBiosGrub |
|
flags = PartitionTable::Flag::BiosGrub |
|
||||||
PartitionTable::Flag::FlagBoot;
|
PartitionTable::Flag::Boot;
|
||||||
}
|
}
|
||||||
else if (type == PartitionTable::msdos || type == PartitionTable::msdos_sectorbased)
|
else if (type == PartitionTable::msdos || type == PartitionTable::msdos_sectorbased)
|
||||||
flags = PartitionTable::FlagBoot;
|
flags = PartitionTable::Flag::Boot;
|
||||||
|
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ public:
|
||||||
void initFSSupport() override;
|
void initFSSupport() override;
|
||||||
|
|
||||||
QList<Device*> scanDevices(bool excludeReadOnly = false) override;
|
QList<Device*> scanDevices(bool excludeReadOnly = false) override;
|
||||||
|
QList<Device*> scanDevices(const ScanFlags scanFlags) override;
|
||||||
std::unique_ptr<CoreBackendDevice> openDevice(const Device& d) override;
|
std::unique_ptr<CoreBackendDevice> openDevice(const Device& d) override;
|
||||||
std::unique_ptr<CoreBackendDevice> openDeviceExclusive(const Device& d) override;
|
std::unique_ptr<CoreBackendDevice> openDeviceExclusive(const Device& d) override;
|
||||||
bool closeDevice(std::unique_ptr<CoreBackendDevice> coreDevice) override;
|
bool closeDevice(std::unique_ptr<CoreBackendDevice> coreDevice) override;
|
||||||
|
|
|
@ -227,13 +227,13 @@ bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, P
|
||||||
if (m_device->partitionTable()->type() == PartitionTable::TableType::msdos ||
|
if (m_device->partitionTable()->type() == PartitionTable::TableType::msdos ||
|
||||||
m_device->partitionTable()->type() == PartitionTable::TableType::msdos_sectorbased) {
|
m_device->partitionTable()->type() == PartitionTable::TableType::msdos_sectorbased) {
|
||||||
// We only allow setting one active partition per device
|
// We only allow setting one active partition per device
|
||||||
if (flag == PartitionTable::Flag::FlagBoot && state == true) {
|
if (flag == PartitionTable::Flag::Boot && state == true) {
|
||||||
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--activate"), m_device->deviceNode(), QString::number(partition.number()) } );
|
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--activate"), m_device->deviceNode(), QString::number(partition.number()) } );
|
||||||
if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0)
|
if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
} else if (flag == PartitionTable::Flag::FlagBoot && state == false) {
|
} else if (flag == PartitionTable::Flag::Boot && state == false) {
|
||||||
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--activate"), m_device->deviceNode(), QStringLiteral("-") } );
|
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--activate"), m_device->deviceNode(), QStringLiteral("-") } );
|
||||||
if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0)
|
if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0)
|
||||||
return true;
|
return true;
|
||||||
|
@ -242,7 +242,7 @@ bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, P
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag == PartitionTable::Flag::FlagBoot && state == true) {
|
if (flag == PartitionTable::Flag::Boot && state == true) {
|
||||||
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--part-type"), m_device->deviceNode(), QString::number(partition.number()),
|
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--part-type"), m_device->deviceNode(), QString::number(partition.number()),
|
||||||
QStringLiteral("C12A7328-F81F-11D2-BA4B-00A0C93EC93B") } );
|
QStringLiteral("C12A7328-F81F-11D2-BA4B-00A0C93EC93B") } );
|
||||||
if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0)
|
if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0)
|
||||||
|
@ -250,10 +250,10 @@ bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, P
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (flag == PartitionTable::Flag::FlagBoot && state == false)
|
if (flag == PartitionTable::Flag::Boot && state == false)
|
||||||
setPartitionSystemType(report, partition);
|
setPartitionSystemType(report, partition);
|
||||||
|
|
||||||
if (flag == PartitionTable::Flag::FlagBiosGrub && state == true) {
|
if (flag == PartitionTable::Flag::BiosGrub && state == true) {
|
||||||
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--part-type"), m_device->deviceNode(), QString::number(partition.number()),
|
ExternalCommand sfdiskCommand(report, QStringLiteral("sfdisk"), { QStringLiteral("--part-type"), m_device->deviceNode(), QString::number(partition.number()),
|
||||||
QStringLiteral("21686148-6449-6E6F-744E-656564454649") } );
|
QStringLiteral("21686148-6449-6E6F-744E-656564454649") } );
|
||||||
if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0)
|
if (sfdiskCommand.run(-1) && sfdiskCommand.exitCode() == 0)
|
||||||
|
@ -261,7 +261,7 @@ bool SfdiskPartitionTable::setFlag(Report& report, const Partition& partition, P
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (flag == PartitionTable::Flag::FlagBiosGrub && state == false)
|
if (flag == PartitionTable::Flag::BiosGrub && state == false)
|
||||||
setPartitionSystemType(report, partition);
|
setPartitionSystemType(report, partition);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -45,7 +45,7 @@ target_link_libraries(kpmcore_externalcommand
|
||||||
qca-qt5
|
qca-qt5
|
||||||
Qt5::Core
|
Qt5::Core
|
||||||
Qt5::DBus
|
Qt5::DBus
|
||||||
KF5::Auth
|
KF5::AuthCore
|
||||||
KF5::I18n
|
KF5::I18n
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,11 @@ class LIBKPMCORE_EXPORT Capacity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Units we can deal with */
|
/** Units we can deal with */
|
||||||
enum Unit : uint { Byte, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB };
|
enum class Unit : uint8_t {Byte, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB };
|
||||||
/** Type of capacity to print */
|
/** Type of capacity to print */
|
||||||
enum class Type { Used, Available, Total };
|
enum class Type : uint8_t { Used, Available, Total };
|
||||||
/** Flags for printing */
|
/** Flags for printing */
|
||||||
enum class Flag { NoFlags = 0, AppendUnit = 1, AppendBytes = 2 };
|
enum class Flag : uint8_t { NoFlags = 0, AppendUnit = 1, AppendBytes = 2 };
|
||||||
Q_DECLARE_FLAGS(Flags, Flag)
|
Q_DECLARE_FLAGS(Flags, Flag)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -183,7 +183,7 @@ bool ExternalCommand::start(int timeout)
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExternalCommand::copyBlocks(CopySource& source, CopyTarget& target)
|
bool ExternalCommand::copyBlocks(const CopySource& source, CopyTarget& target)
|
||||||
{
|
{
|
||||||
bool rval = true;
|
bool rval = true;
|
||||||
const qint64 blockSize = 10 * 1024 * 1024; // number of bytes per block to copy
|
const qint64 blockSize = 10 * 1024 * 1024; // number of bytes per block to copy
|
||||||
|
@ -293,6 +293,8 @@ bool ExternalCommand::writeData(Report& commandReport, const QByteArray& buffer,
|
||||||
|
|
||||||
bool ExternalCommand::write(const QByteArray& input)
|
bool ExternalCommand::write(const QByteArray& input)
|
||||||
{
|
{
|
||||||
|
if ( qEnvironmentVariableIsSet( "KPMCORE_DEBUG" ))
|
||||||
|
qDebug() << "Command input:" << QString::fromLocal8Bit(input);
|
||||||
d->m_Input = input;
|
d->m_Input = input;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -375,7 +377,7 @@ void ExternalCommand::setExitCode(int i)
|
||||||
bool ExternalCommand::startHelper()
|
bool ExternalCommand::startHelper()
|
||||||
{
|
{
|
||||||
if (!QDBusConnection::systemBus().isConnected()) {
|
if (!QDBusConnection::systemBus().isConnected()) {
|
||||||
qWarning() << "Could not connect to DBus session bus";
|
qWarning() << "Could not connect to DBus system bus";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QDBusInterface iface(QStringLiteral("org.kde.kpmcore.helperinterface"), QStringLiteral("/Helper"), QStringLiteral("org.kde.kpmcore.externalcommand"), QDBusConnection::systemBus());
|
QDBusInterface iface(QStringLiteral("org.kde.kpmcore.helperinterface"), QStringLiteral("/Helper"), QStringLiteral("org.kde.kpmcore.externalcommand"), QDBusConnection::systemBus());
|
||||||
|
@ -448,7 +450,7 @@ quint64 ExternalCommand::getNonce(QDBusInterface& iface)
|
||||||
QDBusPendingCall pcall = iface.asyncCall(QStringLiteral("getNonce"));
|
QDBusPendingCall pcall = iface.asyncCall(QStringLiteral("getNonce"));
|
||||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall);
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pcall);
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
unsigned long long rval = 0;
|
quint64 rval = 0;
|
||||||
|
|
||||||
auto exitLoop = [&] (QDBusPendingCallWatcher *watcher) {
|
auto exitLoop = [&] (QDBusPendingCallWatcher *watcher) {
|
||||||
loop.exit();
|
loop.exit();
|
||||||
|
@ -456,7 +458,7 @@ quint64 ExternalCommand::getNonce(QDBusInterface& iface)
|
||||||
if (watcher->isError())
|
if (watcher->isError())
|
||||||
qWarning() << watcher->error();
|
qWarning() << watcher->error();
|
||||||
else {
|
else {
|
||||||
QDBusPendingReply<unsigned long long> reply = *watcher;
|
QDBusPendingReply<quint64> reply = *watcher;
|
||||||
rval = reply;
|
rval = reply;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -68,8 +68,8 @@ public:
|
||||||
~ExternalCommand();
|
~ExternalCommand();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool copyBlocks(CopySource& source, CopyTarget& target);
|
bool copyBlocks(const CopySource& source, CopyTarget& target);
|
||||||
bool writeData(Report& report, const QByteArray& buffer, const QString& deviceNode, const quint64 firstByte); // same as copyBlocks but from QByteArray
|
bool writeData(Report& commandReport, const QByteArray& buffer, const QString& deviceNode, const quint64 firstByte); // same as copyBlocks but from QByteArray
|
||||||
|
|
||||||
/**< @param cmd the command to run */
|
/**< @param cmd the command to run */
|
||||||
void setCommand(const QString& cmd);
|
void setCommand(const QString& cmd);
|
||||||
|
|
|
@ -90,7 +90,7 @@ ActionReply ExternalCommandHelper::init(const QVariantMap& args)
|
||||||
*/
|
*/
|
||||||
quint64 ExternalCommandHelper::getNonce()
|
quint64 ExternalCommandHelper::getNonce()
|
||||||
{
|
{
|
||||||
quint64 nonce = m_Generator.generate();
|
const quint64 nonce = m_Generator.generate();
|
||||||
m_Nonces.insert(nonce);
|
m_Nonces.insert(nonce);
|
||||||
return nonce;
|
return nonce;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ quint64 ExternalCommandHelper::getNonce()
|
||||||
@param size the number of bytes to read
|
@param size the number of bytes to read
|
||||||
@return true on success
|
@return true on success
|
||||||
*/
|
*/
|
||||||
bool ExternalCommandHelper::readData(const QString& sourceDevice, QByteArray& buffer, qint64 offset, qint64 size)
|
bool ExternalCommandHelper::readData(const QString& sourceDevice, QByteArray& buffer, const qint64 offset, const qint64 size)
|
||||||
{
|
{
|
||||||
QFile device(sourceDevice);
|
QFile device(sourceDevice);
|
||||||
|
|
||||||
|
@ -132,9 +132,10 @@ bool ExternalCommandHelper::readData(const QString& sourceDevice, QByteArray& bu
|
||||||
@param offset offset where to begin writing
|
@param offset offset where to begin writing
|
||||||
@return true on success
|
@return true on success
|
||||||
*/
|
*/
|
||||||
bool ExternalCommandHelper::writeData(const QString &targetDevice, const QByteArray& buffer, qint64 offset)
|
bool ExternalCommandHelper::writeData(const QString &targetDevice, const QByteArray& buffer, const qint64 offset)
|
||||||
{
|
{
|
||||||
QFile device(targetDevice);
|
QFile device(targetDevice);
|
||||||
|
|
||||||
if (!device.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Unbuffered)) {
|
if (!device.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Unbuffered)) {
|
||||||
qCritical() << xi18n("Could not open device <filename>%1</filename> for writing.", targetDevice);
|
qCritical() << xi18n("Could not open device <filename>%1</filename> for writing.", targetDevice);
|
||||||
return false;
|
return false;
|
||||||
|
@ -149,6 +150,7 @@ bool ExternalCommandHelper::writeData(const QString &targetDevice, const QByteAr
|
||||||
qCritical() << xi18n("Could not write to device <filename>%1</filename>.", targetDevice);
|
qCritical() << xi18n("Could not write to device <filename>%1</filename>.", targetDevice);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ Q_SIGNALS:
|
||||||
void quit();
|
void quit();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool readData(const QString& sourceDevice, QByteArray& buffer, qint64 offset, qint64 size);
|
bool readData(const QString& sourceDevice, QByteArray& buffer, const qint64 offset, const qint64 size);
|
||||||
bool writeData(const QString& targetDevice, const QByteArray& buffer, qint64 offset);
|
bool writeData(const QString& targetDevice, const QByteArray& buffer, const qint64 offset);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
ActionReply init(const QVariantMap& args);
|
ActionReply init(const QVariantMap& args);
|
||||||
|
|
|
@ -6,6 +6,7 @@ Name=Start external command daemon
|
||||||
Name[ca]=Inicia el dimoni d'ordres externes
|
Name[ca]=Inicia el dimoni d'ordres externes
|
||||||
Name[ca@valencia]=Inicia el dimoni d'ordres externes
|
Name[ca@valencia]=Inicia el dimoni d'ordres externes
|
||||||
Name[cs]=Spustit démona externích příkazů
|
Name[cs]=Spustit démona externích příkazů
|
||||||
|
Name[da]=Start ekstern kommando-dæmon
|
||||||
Name[de]=Externen Befehlsdienst starten
|
Name[de]=Externen Befehlsdienst starten
|
||||||
Name[el]=Εκκίνηση διεργασίας με εξωτερική εντολή
|
Name[el]=Εκκίνηση διεργασίας με εξωτερική εντολή
|
||||||
Name[en_GB]=Start external command daemon
|
Name[en_GB]=Start external command daemon
|
||||||
|
@ -19,15 +20,18 @@ Name[lt]=Paleisti išorinių komandų tarnybą
|
||||||
Name[nl]=Start externe opdrachtdaemon
|
Name[nl]=Start externe opdrachtdaemon
|
||||||
Name[pl]=Rozpocznij usługę zewnętrznego polecenia
|
Name[pl]=Rozpocznij usługę zewnętrznego polecenia
|
||||||
Name[pt]=Iniciar o servidor de comandos externos
|
Name[pt]=Iniciar o servidor de comandos externos
|
||||||
|
Name[pt_BR]=Iniciar comando externo do daemon
|
||||||
Name[sk]=Spustiť externé démony príkazov
|
Name[sk]=Spustiť externé démony príkazov
|
||||||
Name[sv]=Starta extern kommandodemon
|
Name[sv]=Starta extern kommandodemon
|
||||||
Name[uk]=Запуск фонової служби зовнішньої команди
|
Name[uk]=Запуск фонової служби зовнішньої команди
|
||||||
Name[x-test]=xxStart external command daemonxx
|
Name[x-test]=xxStart external command daemonxx
|
||||||
|
Name[zh_TW]=啟動外部指令守護程式
|
||||||
Description=Administrative privileges are required to manage disks
|
Description=Administrative privileges are required to manage disks
|
||||||
Description[ast]=Ríquense los privilexos alministrativos pa xestionar discos
|
Description[ast]=Ríquense los privilexos alministrativos pa xestionar discos
|
||||||
Description[ca]=Es requereixen privilegis d'administrador per gestionar discs
|
Description[ca]=Es requereixen privilegis d'administrador per gestionar discs
|
||||||
Description[ca@valencia]=Es requereixen privilegis d'administrador per gestionar discs
|
Description[ca@valencia]=Es requereixen privilegis d'administrador per gestionar discs
|
||||||
Description[cs]=Pro správu disků jsou potřeba práva administrátora
|
Description[cs]=Pro správu disků jsou potřeba práva administrátora
|
||||||
|
Description[da]=Der kræves administrative rettigheder for at håndtere diske
|
||||||
Description[de]=Systemverwalterrechte sind zur Verwaltung von Festplatten erforderlich
|
Description[de]=Systemverwalterrechte sind zur Verwaltung von Festplatten erforderlich
|
||||||
Description[el]=Απαιτούνται δικαιώματα διαχειριστή για τη διαχείριση δίσκων
|
Description[el]=Απαιτούνται δικαιώματα διαχειριστή για τη διαχείριση δίσκων
|
||||||
Description[en_GB]=Administrative privileges are required to manage disks
|
Description[en_GB]=Administrative privileges are required to manage disks
|
||||||
|
@ -45,5 +49,6 @@ Description[pt_BR]=São necessários privilégios administrativos para gerenciar
|
||||||
Description[sv]=Administratörsprivilegier krävs för att hantera diskar
|
Description[sv]=Administratörsprivilegier krävs för att hantera diskar
|
||||||
Description[uk]=Для керування дисками потрібні права доступу адміністратора (root)
|
Description[uk]=Для керування дисками потрібні права доступу адміністратора (root)
|
||||||
Description[x-test]=xxAdministrative privileges are required to manage disksxx
|
Description[x-test]=xxAdministrative privileges are required to manage disksxx
|
||||||
|
Description[zh_TW]=管理硬碟需要管理員權限
|
||||||
Policy=auth_admin
|
Policy=auth_admin
|
||||||
Persistence=session
|
Persistence=session
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
class runcmd : public QThread {
|
class runcmd : public QThread {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void run()
|
void run() override
|
||||||
{
|
{
|
||||||
ExternalCommand blkidCmd(QStringLiteral("blkid"), {});
|
ExternalCommand blkidCmd(QStringLiteral("blkid"), {});
|
||||||
blkidCmd.run();
|
blkidCmd.run();
|
||||||
|
@ -41,7 +41,7 @@ void run()
|
||||||
class runcmd2 : public QThread {
|
class runcmd2 : public QThread {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void run()
|
void run() override
|
||||||
{
|
{
|
||||||
ExternalCommand lsblkCmd(QStringLiteral("lsblk"), { QStringLiteral("--nodeps"), QStringLiteral("--json") });
|
ExternalCommand lsblkCmd(QStringLiteral("lsblk"), { QStringLiteral("--nodeps"), QStringLiteral("--json") });
|
||||||
lsblkCmd.run();
|
lsblkCmd.run();
|
||||||
|
|
|
@ -86,7 +86,7 @@ int main( int argc, char **argv )
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto devices = backend->scanDevices();
|
const auto devices = backend->scanDevices(ScanFlag::includeLoopback);
|
||||||
qDebug() << "Found" << devices.length() << "devices.";
|
qDebug() << "Found" << devices.length() << "devices.";
|
||||||
for (const auto pdev : devices)
|
for (const auto pdev : devices)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue