Compare commits
38 Commits
efb970ba11
...
fbe54e21f3
Author | SHA1 | Date |
---|---|---|
Andrius Štikonas | fbe54e21f3 | |
Andrius Štikonas | ba46ea64ba | |
Andrius Štikonas | a928c62a7d | |
Andrius Štikonas | 1d195b00da | |
Andrius Štikonas | 1782a9d4bb | |
Andrius Štikonas | 2ed9953694 | |
Andrius Štikonas | 5b80c6045c | |
Adriaan de Groot | 45bd205e79 | |
Andrius Štikonas | 997e8df183 | |
Adriaan de Groot | 6aa9d93728 | |
l10n daemon script | 394859444f | |
l10n daemon script | 73a1deb092 | |
Andrius Štikonas | dc604c4d31 | |
l10n daemon script | ffb7147f01 | |
l10n daemon script | 1843a99895 | |
Gaël PORTAY | 6f4b883130 | |
Gaël PORTAY | 547fa609fe | |
Gaël PORTAY | 0ffec31e2b | |
Andrius Štikonas | 9dd118c58b | |
Gaël PORTAY | e12f0ec391 | |
Gaël PORTAY | 1dde035705 | |
Andrius Štikonas | df4e2332f4 | |
Gaël PORTAY | e9992714a1 | |
l10n daemon script | 3c6ee043f6 | |
Adriaan de Groot | 1d9b1161d4 | |
Andrius Štikonas | cacdb7b634 | |
l10n daemon script | a2a9bb8301 | |
Andrius Štikonas | d6b2584d1b | |
l10n daemon script | a4379583b3 | |
Gaël PORTAY | f585f6c3ad | |
l10n daemon script | 52c29aaf10 | |
Andrius Štikonas | 6921398ba3 | |
Andrius Štikonas | 4fdaf6b1c8 | |
Andrius Štikonas | a810d0d2fd | |
Gaël PORTAY | 9d6c98ff4a | |
Yuri Chornoivan | 62aaa90a29 | |
Gaël PORTAY | 0529ebfb01 | |
l10n daemon script | 59269f63df |
|
@ -35,7 +35,7 @@ set(VERSION_MAJOR "4")
|
|||
set(VERSION_MINOR "1")
|
||||
set(VERSION_RELEASE "0")
|
||||
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_RELEASE})
|
||||
set(SOVERSION "9")
|
||||
set(SOVERSION "10")
|
||||
add_definitions(-D'VERSION="${VERSION}"') #"
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
|
|
@ -39,7 +39,7 @@ class Report;
|
|||
class CoreBackendDevice
|
||||
{
|
||||
public:
|
||||
CoreBackendDevice(const QString& deviceNode);
|
||||
explicit CoreBackendDevice(const QString& deviceNode);
|
||||
virtual ~CoreBackendDevice() {}
|
||||
|
||||
public:
|
||||
|
|
|
@ -103,6 +103,47 @@ public:
|
|||
*/
|
||||
virtual bool updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end) = 0;
|
||||
|
||||
/**
|
||||
* Get the UUID of a partition in the partition table (GPT only).
|
||||
* The partition UUID is known as PARTUUID by several utilities. The device-manager links
|
||||
* the device under /dev/disk/by-partuuid/<uuid>.
|
||||
* @param report the report to write information to
|
||||
* @param partition the partition to get the UUID for
|
||||
* @return the partition UUID
|
||||
*/
|
||||
virtual QString getPartitionUUID(Report& report, const Partition& partition) = 0;
|
||||
|
||||
/**
|
||||
* Set the label of a partition in the partition table (GPT only).
|
||||
* The label is set in the GPT partition name entry. The partition name is known as PARTLABEL by
|
||||
* several utilities. The device-manager links the device under /dev/disk/by-partlabel/<label>.
|
||||
* @param report the report to write information to
|
||||
* @param partition the partition to set the label for
|
||||
* @param label the new label for the partition
|
||||
* @return true on success
|
||||
*/
|
||||
virtual bool setPartitionLabel(Report& report, const Partition& partition, const QString& label) = 0;
|
||||
|
||||
/**
|
||||
* Set the UUID of a partition in the partition table (GPT only).
|
||||
* The partition UUID is known as PARTUUID by several utilities. The device-manager links
|
||||
* the device under /dev/disk/by-partuuid/<uuid>.
|
||||
* @param report the report to write information to
|
||||
* @param partition the partition to set the UUID for
|
||||
* @param uuid the new UUID for the partition
|
||||
* @return true on success
|
||||
*/
|
||||
virtual bool setPartitionUUID(Report& report, const Partition& partition, const QString& uuid) = 0;
|
||||
|
||||
/**
|
||||
* Set the attributes of a partition in the partition table (GPT only).
|
||||
* @param report the report to write information to
|
||||
* @param partition the partition to set the attributes for
|
||||
* @param attrs the new attributes for the partition
|
||||
* @return true on success
|
||||
*/
|
||||
virtual bool setPartitionAttributes(Report& report, const Partition& partition, quint64 attrs) = 0;
|
||||
|
||||
/**
|
||||
* Set the system type (e.g. 83 for Linux) of a partition. The type to set is taken from
|
||||
* the partition's file system.
|
||||
|
|
|
@ -36,7 +36,7 @@ class CopyTarget;
|
|||
class CopySourceFile : public CopySource
|
||||
{
|
||||
public:
|
||||
CopySourceFile(const QString& filename);
|
||||
explicit CopySourceFile(const QString& filename);
|
||||
|
||||
public:
|
||||
bool open() override;
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
class CopyTargetByteArray : public CopyTarget
|
||||
{
|
||||
public:
|
||||
CopyTargetByteArray(QByteArray& array);
|
||||
explicit CopyTargetByteArray(QByteArray& array);
|
||||
|
||||
public:
|
||||
bool open() override {
|
||||
|
|
|
@ -36,7 +36,7 @@ class QString;
|
|||
class CopyTargetFile : public CopyTarget
|
||||
{
|
||||
public:
|
||||
CopyTargetFile(const QString& filename);
|
||||
explicit CopyTargetFile(const QString& filename);
|
||||
|
||||
public:
|
||||
bool open() override;
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include "util/externalcommand.h"
|
||||
#include "util/report.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
#include <blkid/blkid.h>
|
||||
#endif
|
||||
|
@ -34,6 +36,8 @@
|
|||
|
||||
static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType, QString& m_deviceNode);
|
||||
static QString findBlkIdDevice(const char *token, const QString& value);
|
||||
static void writeEntry(QTextStream& s, const FstabEntry& entry, std::array<unsigned int, 4> columnWidth);
|
||||
std::array<unsigned int, 4> fstabColumnWidth(const FstabEntryList& fstabEntries);
|
||||
|
||||
struct FstabEntryPrivate
|
||||
{
|
||||
|
@ -59,6 +63,7 @@ FstabEntry::FstabEntry(const QString& fsSpec, const QString& mountPoint, const Q
|
|||
d->m_comment = comment;
|
||||
|
||||
d->m_options = options.split(QLatin1Char(','));
|
||||
d->m_options.removeAll(QStringLiteral("defaults"));
|
||||
parseFsSpec(d->m_fsSpec, d->m_entryType, d->m_deviceNode);
|
||||
}
|
||||
|
||||
|
@ -88,15 +93,20 @@ FstabEntryList readFstabEntries( const QString& fstabPath )
|
|||
// (4) dump frequency (optional, defaults to 0), no comment is allowed if omitted,
|
||||
// (5) pass number (optional, defaults to 0), no comment is allowed if omitted,
|
||||
// (#) comment (optional).
|
||||
auto fsSpec = splitLine.at(0);
|
||||
auto mountPoint = splitLine.at(1);
|
||||
auto fsType = splitLine.at(2);
|
||||
auto options = splitLine.at(3);
|
||||
|
||||
switch (splitLine.length()) {
|
||||
case 4:
|
||||
fstabEntries.push_back( {splitLine.at(0), splitLine.at(1), splitLine.at(2), splitLine.at(3) } );
|
||||
fstabEntries.push_back( {fsSpec, mountPoint, fsType, options } );
|
||||
break;
|
||||
case 5:
|
||||
fstabEntries.push_back( {splitLine.at(0), splitLine.at(1), splitLine.at(2), splitLine.at(3), splitLine.at(4).toInt() } );
|
||||
fstabEntries.push_back( {fsSpec, mountPoint, fsType, options, splitLine.at(4).toInt() } );
|
||||
break;
|
||||
case 6:
|
||||
fstabEntries.push_back( {splitLine.at(0), splitLine.at(1), splitLine.at(2), splitLine.at(3), splitLine.at(4).toInt(), splitLine.at(5).toInt(), comment.isEmpty() ? QString() : QLatin1Char('#') + comment } );
|
||||
fstabEntries.push_back( {fsSpec, mountPoint, fsType, options, splitLine.at(4).toInt(), splitLine.at(5).toInt(), comment.isEmpty() ? QString() : QLatin1Char('#') + comment } );
|
||||
break;
|
||||
default:
|
||||
fstabEntries.push_back( { {}, {}, {}, {}, {}, {}, QLatin1Char('#') + line } );
|
||||
|
@ -142,6 +152,11 @@ const QStringList& FstabEntry::options() const
|
|||
return d->m_options;
|
||||
}
|
||||
|
||||
const QString FstabEntry::optionsString() const
|
||||
{
|
||||
return options().size() > 0 ? options().join(QLatin1Char(',')) : QStringLiteral("defaults");
|
||||
}
|
||||
|
||||
int FstabEntry::dumpFreq() const
|
||||
{
|
||||
return d->m_dumpFreq;
|
||||
|
@ -203,6 +218,9 @@ static QString findBlkIdDevice(const char *token, const QString& value)
|
|||
rval = QString::fromLocal8Bit(c);
|
||||
free(c);
|
||||
}
|
||||
#else
|
||||
Q_UNUSED(token);
|
||||
Q_UNUSED(value);
|
||||
#endif
|
||||
|
||||
return rval;
|
||||
|
@ -229,40 +247,50 @@ static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType,
|
|||
}
|
||||
}
|
||||
|
||||
static void writeEntry(QTextStream& s, const FstabEntry& entry)
|
||||
|
||||
// Used to nicely format fstab file
|
||||
std::array<unsigned int, 4> fstabColumnWidth(const FstabEntryList& fstabEntries)
|
||||
{
|
||||
std::array<unsigned int, 4> columnWidth;
|
||||
|
||||
#define FIELD_WIDTH(x) 3 + std::max_element(fstabEntries.begin(), fstabEntries.end(), [](const FstabEntry& a, const FstabEntry& b) {return a.x().length() < b.x().length(); })->x().length();
|
||||
|
||||
columnWidth[0] = FIELD_WIDTH(fsSpec);
|
||||
columnWidth[1] = FIELD_WIDTH(mountPoint);
|
||||
columnWidth[2] = FIELD_WIDTH(type);
|
||||
columnWidth[3] = FIELD_WIDTH(optionsString);
|
||||
|
||||
return columnWidth;
|
||||
}
|
||||
|
||||
static void writeEntry(QTextStream& s, const FstabEntry& entry, std::array<unsigned int, 4> columnWidth)
|
||||
{
|
||||
if (entry.entryType() == FstabEntry::Type::comment) {
|
||||
s << entry.comment() << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
QString options;
|
||||
if (entry.options().size() > 0) {
|
||||
options = entry.options().join(QLatin1Char(','));
|
||||
if (options.isEmpty())
|
||||
options = QStringLiteral("defaults");
|
||||
}
|
||||
else
|
||||
options = QStringLiteral("defaults");
|
||||
|
||||
s << entry.fsSpec() << "\t"
|
||||
<< (entry.mountPoint().isEmpty() ? QStringLiteral("none") : entry.mountPoint()) << "\t"
|
||||
<< entry.type() << "\t"
|
||||
<< options << "\t"
|
||||
<< entry.dumpFreq() << "\t"
|
||||
<< entry.passNumber() << "\t"
|
||||
s.setFieldAlignment(QTextStream::AlignLeft);
|
||||
s.setFieldWidth(columnWidth[0]);
|
||||
s << entry.fsSpec()
|
||||
<< qSetFieldWidth(columnWidth[1]) << (entry.mountPoint().isEmpty() ? QStringLiteral("none") : entry.mountPoint())
|
||||
<< qSetFieldWidth(columnWidth[2]) << entry.type()
|
||||
<< qSetFieldWidth(columnWidth[3]) << entry.optionsString() << qSetFieldWidth(0)
|
||||
<< entry.dumpFreq() << " "
|
||||
<< entry.passNumber() << " "
|
||||
<< entry.comment() << "\n";
|
||||
}
|
||||
|
||||
bool writeMountpoints(const FstabEntryList& fstabEntries, const QString& filename)
|
||||
{
|
||||
Report report(nullptr);
|
||||
QByteArray fstabContents;
|
||||
QString fstabContents;
|
||||
QTextStream out(&fstabContents);
|
||||
|
||||
std::array<unsigned int, 4> columnWidth = fstabColumnWidth(fstabEntries);
|
||||
|
||||
for (const auto &e : fstabEntries)
|
||||
writeEntry(out, e);
|
||||
writeEntry(out, e, columnWidth);
|
||||
|
||||
ExternalCommand cmd;
|
||||
return cmd.writeData(report, fstabContents, filename, 0);
|
||||
return cmd.createFile(fstabContents.toLocal8Bit(), filename);
|
||||
}
|
||||
|
|
|
@ -66,6 +66,11 @@ public:
|
|||
*/
|
||||
const QStringList& options() const;
|
||||
|
||||
/**
|
||||
* @return the mount options associated with the file system
|
||||
*/
|
||||
const QString optionsString() const;
|
||||
|
||||
/**
|
||||
* @return the fs_freq field of fstab entry
|
||||
*/
|
||||
|
|
|
@ -171,7 +171,7 @@ Partition* LvmDevice::scanPartition(const QString& lvPath, PartitionTable* pTabl
|
|||
mountPoint = FileSystem::detectMountPoint(fs, lvPath);
|
||||
mounted = FileSystem::detectMountStatus(fs, lvPath);
|
||||
|
||||
if (mountPoint != QString() && fs->type() != FileSystem::Type::LinuxSwap) {
|
||||
if (!mountPoint.isEmpty() && fs->type() != FileSystem::Type::LinuxSwap) {
|
||||
const QStorageInfo storage = QStorageInfo(mountPoint);
|
||||
if (logicalSize() > 0 && fs->type() != FileSystem::Type::Luks && mounted && storage.isValid())
|
||||
fs->setSectorsUsed( (storage.bytesTotal() - storage.bytesFree()) / logicalSize() );
|
||||
|
|
|
@ -48,7 +48,7 @@ class LIBKPMCORE_EXPORT LvmDevice : public VolumeManagerDevice
|
|||
friend class VolumeManagerDevice;
|
||||
|
||||
public:
|
||||
LvmDevice(const QString& name, const QString& iconName = QString());
|
||||
explicit LvmDevice(const QString& name, const QString& iconName = QString());
|
||||
~LvmDevice();
|
||||
|
||||
public:
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
typedef QList<Operation*> Operations;
|
||||
|
||||
public:
|
||||
OperationStack(QObject* parent = nullptr);
|
||||
explicit OperationStack(QObject* parent = nullptr);
|
||||
~OperationStack();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QtGlobal>
|
||||
#include <QPointer>
|
||||
|
||||
|
@ -125,9 +124,15 @@ public:
|
|||
const QString& label() const {
|
||||
return m_Label; /**< @return the GPT Partition label */
|
||||
}
|
||||
const QString& type() const {
|
||||
return m_Type; /**< @return the GPT Partition type */
|
||||
}
|
||||
const QString& uuid() const {
|
||||
return m_UUID; /**< @return the GPT Partition UUID */
|
||||
}
|
||||
quint64 attributes() const {
|
||||
return m_Attributes; /**< @return the GPT Partition attributes */
|
||||
}
|
||||
qint64 firstSector() const {
|
||||
return m_FirstSector; /**< @return the Partition's first sector on the Device */
|
||||
}
|
||||
|
@ -210,9 +215,15 @@ public:
|
|||
void setLabel(const QString& s) {
|
||||
m_Label = s; /**< @param s the new label */
|
||||
}
|
||||
void setType(const QString& s) {
|
||||
m_Type = s; /**< @param s the new type */
|
||||
}
|
||||
void setUUID(const QString& s) {
|
||||
m_UUID = s; /**< @param s the new UUID */
|
||||
}
|
||||
void setAttributes(quint64 f) {
|
||||
m_Attributes = f; /**< @param f the new attributes */
|
||||
}
|
||||
|
||||
void append(Partition* p) override {
|
||||
m_Children.append(p);
|
||||
|
@ -266,7 +277,9 @@ private:
|
|||
qint64 m_LastSector;
|
||||
QString m_DevicePath;
|
||||
QString m_Label;
|
||||
QString m_Type;
|
||||
QString m_UUID;
|
||||
quint64 m_Attributes;
|
||||
QString m_PartitionPath;
|
||||
QString m_MountPoint;
|
||||
PartitionTable::Flags m_AvailableFlags;
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
Recovery,
|
||||
};
|
||||
|
||||
SoftwareRAID(const QString& name,
|
||||
explicit SoftwareRAID(const QString& name,
|
||||
SoftwareRAID::Status status = SoftwareRAID::Status::Active,
|
||||
const QString& iconName = QString());
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
};
|
||||
|
||||
public:
|
||||
SmartAttribute(const SmartAttributeParsedData& a);
|
||||
explicit SmartAttribute(const SmartAttributeParsedData& a);
|
||||
|
||||
public:
|
||||
qint32 id() const {
|
||||
|
|
|
@ -32,7 +32,7 @@ class SmartDiskInformation;
|
|||
class SmartParser
|
||||
{
|
||||
public:
|
||||
SmartParser(const QString &device_path);
|
||||
explicit SmartParser(const QString &device_path);
|
||||
~SmartParser();
|
||||
|
||||
public:
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
typedef QList<SmartAttribute> Attributes;
|
||||
|
||||
public:
|
||||
SmartStatus(const QString &device_path);
|
||||
explicit SmartStatus(const QString &device_path);
|
||||
|
||||
public:
|
||||
void update();
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||
*************************************************************************/
|
||||
|
||||
#include "core/device_p.h"
|
||||
#include "core/volumemanagerdevice.h"
|
||||
#include "core/volumemanagerdevice_p.h"
|
||||
#include "core/device_p.h"
|
||||
#include "core/lvmdevice.h"
|
||||
#include "core/raid/softwareraid.h"
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@ set(FS_SRC
|
|||
fs/fat12.cpp
|
||||
fs/fat16.cpp
|
||||
fs/fat32.cpp
|
||||
fs/feature.cpp
|
||||
fs/filesystem.cpp
|
||||
fs/filesystemfactory.cpp
|
||||
fs/hfs.cpp
|
||||
|
@ -51,7 +50,6 @@ set(FS_LIB_HDRS
|
|||
fs/fat12.h
|
||||
fs/fat16.h
|
||||
fs/fat32.h
|
||||
fs/feature.h
|
||||
fs/filesystem.h
|
||||
fs/filesystemfactory.h
|
||||
fs/hfs.h
|
||||
|
|
|
@ -23,7 +23,7 @@ FileSystem::CommandSupportType apfs::m_Move = FileSystem::cmdSupportCore;
|
|||
FileSystem::CommandSupportType apfs::m_Copy = FileSystem::cmdSupportCore;
|
||||
FileSystem::CommandSupportType apfs::m_Backup = FileSystem::cmdSupportCore;
|
||||
|
||||
apfs::apfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
apfs::apfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Apfs)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT apfs : public FileSystem
|
||||
{
|
||||
public:
|
||||
apfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
apfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
CommandSupportType supportMove() const override {
|
||||
|
|
|
@ -23,7 +23,7 @@ FileSystem::CommandSupportType bitlocker::m_Move = FileSystem::cmdSupportCore;
|
|||
FileSystem::CommandSupportType bitlocker::m_Copy = FileSystem::cmdSupportCore;
|
||||
FileSystem::CommandSupportType bitlocker::m_Backup = FileSystem::cmdSupportCore;
|
||||
|
||||
bitlocker::bitlocker(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
bitlocker::bitlocker(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::BitLocker)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT bitlocker : public FileSystem
|
||||
{
|
||||
public:
|
||||
bitlocker(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
bitlocker(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
CommandSupportType supportMove() const override {
|
||||
|
|
|
@ -43,7 +43,7 @@ FileSystem::CommandSupportType btrfs::m_SetLabel = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType btrfs::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType btrfs::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
btrfs::btrfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
btrfs::btrfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Btrfs)
|
||||
{
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ void btrfs::init()
|
|||
// First line is introductory text, we don't need it
|
||||
lines.removeFirst();
|
||||
|
||||
for (auto l : lines) {
|
||||
for (const auto& l: lines) {
|
||||
if (!l.isEmpty())
|
||||
addAvailableFeature(l.split(QStringLiteral(" ")).first());
|
||||
}
|
||||
|
@ -148,12 +148,15 @@ bool btrfs::create(Report& report, const QString& deviceNode)
|
|||
|
||||
if (!this->features().isEmpty()) {
|
||||
QStringList feature_list = QStringList();
|
||||
for (auto f : this->features()) {
|
||||
if (f.type() == FSFeature::Type::Bool) {
|
||||
if (f.bValue())
|
||||
feature_list << f.name();
|
||||
else
|
||||
feature_list << (QStringLiteral("^") + f.name());
|
||||
for (const auto& k : this->features().keys()) {
|
||||
const auto& v = this->features().value(k);
|
||||
if (v.type() == QVariant::Type::Bool) {
|
||||
if (v.toBool())
|
||||
feature_list << k;
|
||||
else
|
||||
feature_list << (QStringLiteral("^") + k);
|
||||
} else {
|
||||
qWarning() << "Ignoring feature" << k << "of type" << v.type() << "; requires type QVariant::bool.";
|
||||
}
|
||||
}
|
||||
args << QStringLiteral("--features") << feature_list.join(QStringLiteral(","));
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT btrfs : public FileSystem
|
||||
{
|
||||
public:
|
||||
btrfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
btrfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -38,7 +38,7 @@ FileSystem::CommandSupportType exfat::m_SetLabel = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType exfat::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType exfat::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
exfat::exfat(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
exfat::exfat(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Exfat)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT exfat : public FileSystem
|
||||
{
|
||||
public:
|
||||
exfat(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
exfat(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -39,7 +39,7 @@ FileSystem::CommandSupportType ext2::m_SetLabel = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType ext2::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType ext2::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
ext2::ext2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features, FileSystem::Type t) :
|
||||
ext2::ext2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features, FileSystem::Type t) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, t)
|
||||
{
|
||||
}
|
||||
|
@ -168,12 +168,15 @@ bool ext2::create(Report& report, const QString& deviceNode)
|
|||
|
||||
if (!this->features().isEmpty()) {
|
||||
QStringList feature_list = QStringList();
|
||||
for (auto f : this->features()) {
|
||||
if (f.type() == FSFeature::Type::Bool) {
|
||||
if (f.bValue())
|
||||
feature_list << f.name();
|
||||
else
|
||||
feature_list << (QStringLiteral("^") + f.name());
|
||||
for (const auto& k : this->features().keys()) {
|
||||
const auto& v = this->features().value(k);
|
||||
if (v.type() == QVariant::Type::Bool) {
|
||||
if (v.toBool())
|
||||
feature_list << k;
|
||||
else
|
||||
feature_list << (QStringLiteral("^") + k);
|
||||
} else {
|
||||
qWarning() << "Ignoring feature" << k << "of type" << v.type() << "; requires type QVariant::bool.";
|
||||
}
|
||||
}
|
||||
args << QStringLiteral("-O") << feature_list.join(QStringLiteral(","));
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT ext2 : public FileSystem
|
||||
{
|
||||
public:
|
||||
ext2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {}, FileSystem::Type t = FileSystem::Type::Ext2);
|
||||
ext2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {}, FileSystem::Type t = FileSystem::Type::Ext2);
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
namespace FS
|
||||
{
|
||||
ext3::ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
ext3::ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
ext2(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Ext3)
|
||||
{
|
||||
}
|
||||
|
@ -40,12 +40,15 @@ bool ext3::create(Report& report, const QString& deviceNode)
|
|||
|
||||
if (!this->features().isEmpty()) {
|
||||
QStringList feature_list = QStringList();
|
||||
for (auto f : this->features()) {
|
||||
if (f.type() == FSFeature::Type::Bool) {
|
||||
if (f.bValue())
|
||||
feature_list << f.name();
|
||||
else
|
||||
feature_list << (QStringLiteral("^") + f.name());
|
||||
for (const auto& k : this->features().keys()) {
|
||||
const auto& v = this->features().value(k);
|
||||
if (v.type() == QVariant::Type::Bool) {
|
||||
if (v.toBool())
|
||||
feature_list << k;
|
||||
else
|
||||
feature_list << (QStringLiteral("^") + k);
|
||||
} else {
|
||||
qWarning() << "Ignoring feature" << k << "of type" << v.type() << "; requires type QVariant::bool.";
|
||||
}
|
||||
}
|
||||
args << QStringLiteral("-O") << feature_list.join(QStringLiteral(","));
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT ext3 : public ext2
|
||||
{
|
||||
public:
|
||||
ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
bool create(Report& report, const QString& deviceNode) override;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
namespace FS
|
||||
{
|
||||
ext4::ext4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
ext4::ext4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
ext2(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Ext4)
|
||||
{
|
||||
}
|
||||
|
@ -40,12 +40,15 @@ bool ext4::create(Report& report, const QString& deviceNode)
|
|||
|
||||
if (!this->features().isEmpty()) {
|
||||
QStringList feature_list = QStringList();
|
||||
for (auto f : this->features()) {
|
||||
if (f.type() == FSFeature::Type::Bool) {
|
||||
if (f.bValue())
|
||||
feature_list << f.name();
|
||||
else
|
||||
feature_list << (QStringLiteral("^") + f.name());
|
||||
for (const auto& k : this->features().keys()) {
|
||||
const auto& v = this->features().value(k);
|
||||
if (v.type() == QVariant::Type::Bool) {
|
||||
if (v.toBool())
|
||||
feature_list << k;
|
||||
else
|
||||
feature_list << (QStringLiteral("^") + k);
|
||||
} else {
|
||||
qWarning() << "Ignoring feature" << k << "of type" << v.type() << "; requires type QVariant::bool.";
|
||||
}
|
||||
}
|
||||
args << QStringLiteral("-O") << feature_list.join(QStringLiteral(","));
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT ext4 : public ext2
|
||||
{
|
||||
public:
|
||||
ext4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
ext4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
bool create(Report& report, const QString& deviceNode) override;
|
||||
|
|
|
@ -24,7 +24,7 @@ FileSystem::CommandSupportType extended::m_Grow = FileSystem::cmdSupportCore;
|
|||
FileSystem::CommandSupportType extended::m_Shrink = FileSystem::cmdSupportCore;
|
||||
FileSystem::CommandSupportType extended::m_Move = FileSystem::cmdSupportCore;
|
||||
|
||||
extended::extended(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
extended::extended(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Extended)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT extended : public FileSystem
|
||||
{
|
||||
public:
|
||||
extended(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
extended(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ FileSystem::CommandSupportType f2fs::m_UpdateUUID = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType f2fs::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
bool f2fs::oldVersion = false; // 1.8.x or older
|
||||
|
||||
f2fs::f2fs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
f2fs::f2fs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::F2fs)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT f2fs : public FileSystem
|
||||
{
|
||||
public:
|
||||
f2fs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
f2fs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -49,7 +49,7 @@ FileSystem::CommandSupportType fat12::m_Backup = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType fat12::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType fat12::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
fat12::fat12(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features, FileSystem::Type t) :
|
||||
fat12::fat12(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features, FileSystem::Type t) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, t)
|
||||
{
|
||||
}
|
||||
|
@ -66,8 +66,8 @@ void fat12::init()
|
|||
m_GetUUID = cmdSupportCore;
|
||||
|
||||
if (m_Create == cmdSupportFileSystem) {
|
||||
addAvailableFeature(QStringLiteral("sector-size"), FSFeature::Type::Int);
|
||||
addAvailableFeature(QStringLiteral("sectors-per-cluster"), FSFeature::Type::Int);
|
||||
addAvailableFeature(QStringLiteral("sector-size"));
|
||||
addAvailableFeature(QStringLiteral("sectors-per-cluster"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,17 +169,18 @@ bool fat12::createWithFatSize(Report &report, const QString& deviceNode, int fat
|
|||
if (fatSize != 12 && fatSize != 16 && fatSize != 32)
|
||||
return false;
|
||||
|
||||
for (auto f : this->features()) {
|
||||
if (f.name() == QStringLiteral("sector-size")) {
|
||||
quint32 sectorSize = f.iValue();
|
||||
for (const auto& k : this->features().keys()) {
|
||||
const auto& v = this->features().value(k);
|
||||
if (k == QStringLiteral("sector-size")) {
|
||||
quint32 sectorSize = v.toInt();
|
||||
|
||||
/* sectorSize has to be a power of 2 between 512 and 32768 */
|
||||
if (sectorSize >= 512 && sectorSize <= 32768 && sectorSize == qNextPowerOfTwo(sectorSize - 1))
|
||||
args << QStringLiteral("-S%1").arg(sectorSize);
|
||||
else
|
||||
qWarning() << QStringLiteral("FAT sector size %1 is invalid, using default").arg(sectorSize);
|
||||
} else if (f.name() == QStringLiteral("sectors-per-cluster")) {
|
||||
quint32 sectorsPerCluster = f.iValue();
|
||||
} else if (k == QStringLiteral("sectors-per-cluster")) {
|
||||
quint32 sectorsPerCluster = v.toInt();
|
||||
|
||||
/* sectorsPerCluster has to be a power of 2 between 2 and 128 */
|
||||
if (sectorsPerCluster <= 128 && sectorsPerCluster == qNextPowerOfTwo(sectorsPerCluster - 1))
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT fat12 : public FileSystem
|
||||
{
|
||||
public:
|
||||
fat12(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {}, FileSystem::Type t = FileSystem::Type::Fat12);
|
||||
fat12(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {}, FileSystem::Type t = FileSystem::Type::Fat12);
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
namespace FS
|
||||
{
|
||||
fat16::fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features, FileSystem::Type type) :
|
||||
fat16::fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features, FileSystem::Type type) :
|
||||
fat12(firstsector, lastsector, sectorsused, label, features, type)
|
||||
{
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ void fat16::init()
|
|||
m_GetUUID = cmdSupportCore;
|
||||
|
||||
if (m_Create == cmdSupportFileSystem) {
|
||||
addAvailableFeature(QStringLiteral("sector-size"), FSFeature::Type::Int);
|
||||
addAvailableFeature(QStringLiteral("sectors-per-cluster"), FSFeature::Type::Int);
|
||||
addAvailableFeature(QStringLiteral("sector-size"));
|
||||
addAvailableFeature(QStringLiteral("sectors-per-cluster"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT fat16 : public fat12
|
||||
{
|
||||
public:
|
||||
fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {}, FileSystem::Type type = FileSystem::Type::Fat16);
|
||||
fat16(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {}, FileSystem::Type type = FileSystem::Type::Fat16);
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
namespace FS
|
||||
{
|
||||
fat32::fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
fat32::fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
fat16(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Fat32)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT fat32 : public fat16
|
||||
{
|
||||
public:
|
||||
fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
bool create(Report& report, const QString& deviceNode) override;
|
||||
|
|
|
@ -1,126 +0,0 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2019 by Collabora Ltd <arnaud.ferraris@collabora.com> *
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>.*
|
||||
*************************************************************************/
|
||||
|
||||
#include "fs/filesystem.h"
|
||||
|
||||
struct FSFeaturePrivate {
|
||||
QString m_name;
|
||||
FSFeature::Type m_type;
|
||||
bool m_boolean;
|
||||
int m_integer;
|
||||
QString m_string;
|
||||
};
|
||||
|
||||
FSFeature::FSFeature(const QString& n, FSFeature::Type t) :
|
||||
d(std::make_unique<FSFeaturePrivate>())
|
||||
{
|
||||
d->m_name = n;
|
||||
d->m_type = t;
|
||||
}
|
||||
|
||||
FSFeature::FSFeature(const QString& n, bool b) :
|
||||
d(std::make_unique<FSFeaturePrivate>())
|
||||
{
|
||||
d->m_name = n;
|
||||
d->m_type = FSFeature::Type::Bool;
|
||||
d->m_boolean = b;
|
||||
}
|
||||
|
||||
FSFeature::FSFeature(const QString& n, int i) :
|
||||
d(std::make_unique<FSFeaturePrivate>())
|
||||
{
|
||||
d->m_name = n;
|
||||
d->m_type = FSFeature::Type::Int;
|
||||
d->m_integer = i;
|
||||
}
|
||||
|
||||
FSFeature::FSFeature(const QString& n, const QString& s) :
|
||||
d(std::make_unique<FSFeaturePrivate>())
|
||||
{
|
||||
d->m_name = n;
|
||||
d->m_type = FSFeature::Type::String;
|
||||
d->m_string = s;
|
||||
}
|
||||
|
||||
FSFeature::FSFeature(const FSFeature& other) :
|
||||
d(std::make_unique<FSFeaturePrivate>(*(other.d)))
|
||||
{
|
||||
}
|
||||
|
||||
FSFeature::~FSFeature()
|
||||
{
|
||||
}
|
||||
|
||||
FSFeature& FSFeature::operator=(const FSFeature& other)
|
||||
{
|
||||
if (&other != this)
|
||||
*d = *(other.d);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
const QString& FSFeature::name()
|
||||
{
|
||||
return d->m_name;
|
||||
}
|
||||
|
||||
FSFeature::Type FSFeature::type()
|
||||
{
|
||||
return d->m_type;
|
||||
}
|
||||
|
||||
bool FSFeature::bValue()
|
||||
{
|
||||
return d->m_boolean;
|
||||
}
|
||||
|
||||
int FSFeature::iValue()
|
||||
{
|
||||
return d->m_integer;
|
||||
}
|
||||
|
||||
const QString& FSFeature::sValue()
|
||||
{
|
||||
return d->m_string;
|
||||
}
|
||||
|
||||
bool FSFeature::setValue(bool b)
|
||||
{
|
||||
if (d->m_type != FSFeature::Type::Bool)
|
||||
return false;
|
||||
|
||||
d->m_boolean = b;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FSFeature::setValue(int i)
|
||||
{
|
||||
if (d->m_type != FSFeature::Type::Int)
|
||||
return false;
|
||||
|
||||
d->m_integer = i;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FSFeature::setValue(const QString& s)
|
||||
{
|
||||
if (d->m_type != FSFeature::Type::String)
|
||||
return false;
|
||||
|
||||
d->m_string = s;
|
||||
return true;
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2019 by Collabora Ltd <arnaud.ferraris@collabora.com> *
|
||||
* *
|
||||
* 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 <http://www.gnu.org/licenses/>.*
|
||||
*************************************************************************/
|
||||
|
||||
#ifndef KPMCORE_FSFEATURE_H
|
||||
#define KPMCORE_FSFEATURE_H
|
||||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
|
||||
struct FSFeaturePrivate;
|
||||
|
||||
/**
|
||||
* Class for filesystem-specific features
|
||||
*
|
||||
* FSFeatures have a name, type (boolean, integer or string) and value.
|
||||
* This class can be used to describe specific features for any FileSystem, but it
|
||||
* is up to each FileSystem implementation to handle them as needed.
|
||||
*/
|
||||
class LIBKPMCORE_EXPORT FSFeature
|
||||
{
|
||||
public:
|
||||
enum Type : int {
|
||||
Bool,
|
||||
Int,
|
||||
String
|
||||
};
|
||||
|
||||
public:
|
||||
FSFeature(const QString& n, Type t = Type::Bool);
|
||||
FSFeature(const QString& n, bool b);
|
||||
FSFeature(const QString& n, int i);
|
||||
FSFeature(const QString& n, const QString& s);
|
||||
FSFeature(const FSFeature& f);
|
||||
~FSFeature();
|
||||
|
||||
FSFeature& operator=(const FSFeature& f);
|
||||
|
||||
Type type();
|
||||
const QString& name();
|
||||
|
||||
/**< @return the value of a boolean FSFeature ; feature type is NOT checked */
|
||||
bool bValue();
|
||||
/**< @return the value of an integer FSFeature ; feature type is NOT checked */
|
||||
int iValue();
|
||||
/**< @return the value of a string FSFeature ; feature type is NOT checked */
|
||||
const QString& sValue();
|
||||
|
||||
/**
|
||||
* Set feature value
|
||||
* @return false if the feature is of the wrong type
|
||||
*/
|
||||
bool setValue(bool b);
|
||||
bool setValue(int i);
|
||||
bool setValue(const QString& s);
|
||||
|
||||
private:
|
||||
std::unique_ptr<FSFeaturePrivate> d;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -17,9 +17,9 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||
*************************************************************************/
|
||||
|
||||
#include "fs/filesystem.h"
|
||||
#include "core/fstab.h"
|
||||
|
||||
#include "fs/filesystem.h"
|
||||
#include "fs/lvm2_pv.h"
|
||||
|
||||
#include "backend/corebackend.h"
|
||||
|
@ -84,8 +84,8 @@ struct FileSystemPrivate {
|
|||
qint64 m_SectorsUsed;
|
||||
QString m_Label;
|
||||
QString m_UUID;
|
||||
QList<FSFeature> m_AvailableFeatures;
|
||||
QList<FSFeature> m_Features;
|
||||
QStringList m_AvailableFeatures;
|
||||
QVariantMap m_Features;
|
||||
};
|
||||
|
||||
/** Creates a new FileSystem object
|
||||
|
@ -114,7 +114,7 @@ FileSystem::FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused
|
|||
@param features the FileSystem features
|
||||
@param type the FileSystem type
|
||||
*/
|
||||
FileSystem::FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features, FileSystem::Type type) :
|
||||
FileSystem::FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features, FileSystem::Type type) :
|
||||
d(std::make_unique<FileSystemPrivate>())
|
||||
{
|
||||
d->m_Type = type;
|
||||
|
@ -174,7 +174,7 @@ bool FileSystem::detectMountStatus(FileSystem* fs, const QString& partitionPath)
|
|||
bool mounted = false;
|
||||
|
||||
if (fs->type() == FileSystem::Type::Lvm2_PV) {
|
||||
mounted = FS::lvm2_pv::getVGName(partitionPath) != QString();
|
||||
mounted = !FS::lvm2_pv::getVGName(partitionPath).isEmpty();
|
||||
} else {
|
||||
mounted = isMounted(partitionPath);
|
||||
}
|
||||
|
@ -604,24 +604,21 @@ bool FileSystem::findExternal(const QString& cmdName, const QStringList& args, i
|
|||
return cmd.exitCode() == 0 || cmd.exitCode() == expectedCode;
|
||||
}
|
||||
|
||||
void FileSystem::addAvailableFeature(const FSFeature& feature)
|
||||
void FileSystem::addAvailableFeature(const QString& name)
|
||||
{
|
||||
d->m_AvailableFeatures.append(feature);
|
||||
d->m_AvailableFeatures.append(name);
|
||||
}
|
||||
|
||||
void FileSystem::addAvailableFeature(const QString& name, FSFeature::Type type)
|
||||
void FileSystem::addFeature(const QString& name, const QVariant& value)
|
||||
{
|
||||
d->m_AvailableFeatures.append(FSFeature(name, type));
|
||||
d->m_Features.insert(name, value);
|
||||
}
|
||||
|
||||
void FileSystem::addFeature(const FSFeature& feature)
|
||||
void FileSystem::addFeatures(const QVariantMap& features)
|
||||
{
|
||||
d->m_Features.append(feature);
|
||||
}
|
||||
|
||||
void FileSystem::addFeatures(const QList<FSFeature>& features)
|
||||
{
|
||||
d->m_Features.append(features);
|
||||
for (const auto& k : features.keys()) {
|
||||
d->m_Features.insert(k, features.value(k));
|
||||
}
|
||||
}
|
||||
|
||||
bool FileSystem::supportToolFound() const
|
||||
|
@ -649,12 +646,12 @@ const QString& FileSystem::label() const
|
|||
return d->m_Label;
|
||||
}
|
||||
|
||||
const QList<FSFeature>& FileSystem::availableFeatures() const
|
||||
const QStringList& FileSystem::availableFeatures() const
|
||||
{
|
||||
return d->m_AvailableFeatures;
|
||||
}
|
||||
|
||||
const QList<FSFeature>& FileSystem::features() const
|
||||
const QVariantMap& FileSystem::features() const
|
||||
{
|
||||
return d->m_Features;
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@
|
|||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
#include "fs/feature.h"
|
||||
|
||||
#include <QVariant>
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
|
@ -116,7 +115,7 @@ public:
|
|||
|
||||
protected:
|
||||
FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type type);
|
||||
FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features, FileSystem::Type type);
|
||||
FileSystem(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features, FileSystem::Type type);
|
||||
|
||||
public:
|
||||
virtual ~FileSystem();
|
||||
|
@ -271,16 +270,17 @@ public:
|
|||
const QString& label() const;
|
||||
|
||||
/**< @return the FileSystem's available features */
|
||||
const QList<FSFeature>& availableFeatures() const;
|
||||
const QStringList& availableFeatures() const;
|
||||
|
||||
/**< @return the FileSystem's features */
|
||||
const QList<FSFeature>& features() const;
|
||||
const QVariantMap& features() const;
|
||||
|
||||
/**< @param feature the feature to add to the FileSystem */
|
||||
void addFeature(const FSFeature& feature);
|
||||
/**< @param the feature's name to add to the FileSystem */
|
||||
/**< @param the feature's value to add to the FileSystem */
|
||||
void addFeature(const QString& name, const QVariant& value);
|
||||
|
||||
/**< @param features the list of features to add to the FileSystem */
|
||||
void addFeatures(const QList<FSFeature>& features);
|
||||
void addFeatures(const QVariantMap& features);
|
||||
|
||||
/**< @return the sector size in the underlying Device */
|
||||
qint64 sectorSize() const;
|
||||
|
@ -305,8 +305,7 @@ public:
|
|||
|
||||
protected:
|
||||
static bool findExternal(const QString& cmdName, const QStringList& args = QStringList(), int exptectedCode = 1);
|
||||
void addAvailableFeature(const FSFeature& feature);
|
||||
void addAvailableFeature(const QString& name, FSFeature::Type type = FSFeature::Type::Bool);
|
||||
void addAvailableFeature(const QString& name);
|
||||
|
||||
std::unique_ptr<FileSystemPrivate> d;
|
||||
};
|
||||
|
|
|
@ -116,7 +116,7 @@ void FileSystemFactory::init()
|
|||
@param label the FileSystem's label
|
||||
@return pointer to the newly created FileSystem object or nullptr if FileSystem could not be created
|
||||
*/
|
||||
FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qint64 lastsector, qint64 sectorSize, qint64 sectorsused, const QString& label, const QList<FSFeature>& features, const QString& uuid)
|
||||
FileSystem* FileSystemFactory::create(FileSystem::Type t, qint64 firstsector, qint64 lastsector, qint64 sectorSize, qint64 sectorsused, const QString& label, const QVariantMap& features, const QString& uuid)
|
||||
{
|
||||
FileSystem* fs = nullptr;
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
#ifndef KPMCORE_FILESYSTEMFACTORY_H
|
||||
#define KPMCORE_FILESYSTEMFACTORY_H
|
||||
|
||||
#include "fs/feature.h"
|
||||
#include "fs/filesystem.h"
|
||||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
@ -42,7 +41,7 @@ private:
|
|||
|
||||
public:
|
||||
static void init();
|
||||
static FileSystem* create(FileSystem::Type t, qint64 firstsector, qint64 lastsector, qint64 sectorSize, qint64 sectorsused = -1, const QString& label = QString(), const QList<FSFeature>& features = {}, const QString& uuid = QString());
|
||||
static FileSystem* create(FileSystem::Type t, qint64 firstsector, qint64 lastsector, qint64 sectorSize, qint64 sectorsused = -1, const QString& label = QString(), const QVariantMap& features = {}, const QString& uuid = QString());
|
||||
static FileSystem* create(const FileSystem& other);
|
||||
static FileSystem* cloneWithNewType(FileSystem::Type newType, const FileSystem& other);
|
||||
static const FileSystems& map();
|
||||
|
|
|
@ -34,7 +34,7 @@ FileSystem::CommandSupportType hfs::m_Check = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType hfs::m_Copy = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType hfs::m_Backup = FileSystem::cmdSupportNone;
|
||||
|
||||
hfs::hfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
hfs::hfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Hfs)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT hfs : public FileSystem
|
||||
{
|
||||
public:
|
||||
hfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
hfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -34,7 +34,7 @@ FileSystem::CommandSupportType hfsplus::m_Create = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType hfsplus::m_Copy = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType hfsplus::m_Backup = FileSystem::cmdSupportNone;
|
||||
|
||||
hfsplus::hfsplus(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
hfsplus::hfsplus(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::HfsPlus)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT hfsplus : public FileSystem
|
||||
{
|
||||
public:
|
||||
hfsplus(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
hfsplus(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -36,7 +36,7 @@ FileSystem::CommandSupportType hpfs::m_SetLabel = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType hpfs::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType hpfs::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
hpfs::hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
hpfs::hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Hpfs)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT hpfs : public FileSystem
|
||||
{
|
||||
public:
|
||||
hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
CommandSupportType supportGetUsed() const override {
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace FS
|
||||
{
|
||||
|
||||
iso9660::iso9660(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
iso9660::iso9660(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Iso9660)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT iso9660 : public FileSystem
|
||||
{
|
||||
public:
|
||||
iso9660(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
iso9660(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ FileSystem::CommandSupportType jfs::m_Copy = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType jfs::m_Backup = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType jfs::m_SetLabel = FileSystem::cmdSupportNone;
|
||||
|
||||
jfs::jfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
jfs::jfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Jfs)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT jfs : public FileSystem
|
||||
{
|
||||
public:
|
||||
jfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
jfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
namespace FS
|
||||
{
|
||||
|
||||
linuxraidmember::linuxraidmember(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
linuxraidmember::linuxraidmember(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::LinuxRaidMember)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT linuxraidmember : public FileSystem
|
||||
{
|
||||
public:
|
||||
linuxraidmember(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
linuxraidmember(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ FileSystem::CommandSupportType linuxswap::m_SetLabel = FileSystem::cmdSupportNon
|
|||
FileSystem::CommandSupportType linuxswap::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType linuxswap::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
linuxswap::linuxswap(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
linuxswap::linuxswap(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::LinuxSwap)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT linuxswap : public FileSystem
|
||||
{
|
||||
public:
|
||||
linuxswap(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
linuxswap(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -63,7 +63,7 @@ luks::luks(qint64 firstsector,
|
|||
qint64 lastsector,
|
||||
qint64 sectorsused,
|
||||
const QString& label,
|
||||
const QList<FSFeature>& features,
|
||||
const QVariantMap& features,
|
||||
FileSystem::Type t)
|
||||
: FileSystem(firstsector, lastsector, sectorsused, label, features, t)
|
||||
, m_innerFs(nullptr)
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT luks : public FileSystem
|
||||
{
|
||||
public:
|
||||
luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {}, FileSystem::Type t = FileSystem::Type::Luks);
|
||||
luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {}, FileSystem::Type t = FileSystem::Type::Luks);
|
||||
~luks() override;
|
||||
|
||||
enum class KeyLocation {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
namespace FS
|
||||
{
|
||||
|
||||
luks2::luks2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features)
|
||||
luks2::luks2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features)
|
||||
: luks(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Luks2)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT luks2 : public luks
|
||||
{
|
||||
public:
|
||||
luks2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
luks2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
~luks2() override;
|
||||
|
||||
bool create(Report& report, const QString& deviceNode) override;
|
||||
|
|
|
@ -42,7 +42,7 @@ FileSystem::CommandSupportType lvm2_pv::m_UpdateUUID = FileSystem::cmdSupportNon
|
|||
FileSystem::CommandSupportType lvm2_pv::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
lvm2_pv::lvm2_pv(qint64 firstsector, qint64 lastsector,
|
||||
qint64 sectorsused, const QString& label, const QList<FSFeature>& features)
|
||||
qint64 sectorsused, const QString& label, const QVariantMap& features)
|
||||
: FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Lvm2_PV)
|
||||
, m_PESize(0)
|
||||
, m_TotalPE(0)
|
||||
|
|
|
@ -89,7 +89,7 @@ class LIBKPMCORE_EXPORT lvm2_pv : public FileSystem
|
|||
{
|
||||
|
||||
public:
|
||||
lvm2_pv(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
lvm2_pv(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -33,7 +33,7 @@ FileSystem::CommandSupportType minix::m_Create = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType minix::m_Copy = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType minix::m_Backup = FileSystem::cmdSupportNone;
|
||||
|
||||
minix::minix(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
minix::minix(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Minix)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT minix : public FileSystem
|
||||
{
|
||||
public:
|
||||
minix(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
minix(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
void init() override;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ FileSystem::CommandSupportType nilfs2::m_SetLabel = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType nilfs2::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType nilfs2::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
nilfs2::nilfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
nilfs2::nilfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Nilfs2)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT nilfs2 : public FileSystem
|
||||
{
|
||||
public:
|
||||
nilfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
nilfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -48,7 +48,7 @@ FileSystem::CommandSupportType ntfs::m_SetLabel = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType ntfs::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType ntfs::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
ntfs::ntfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
ntfs::ntfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Ntfs)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT ntfs : public FileSystem
|
||||
{
|
||||
public:
|
||||
ntfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
ntfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -39,7 +39,7 @@ FileSystem::CommandSupportType ocfs2::m_SetLabel = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType ocfs2::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType ocfs2::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
ocfs2::ocfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
ocfs2::ocfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Ocfs2)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT ocfs2 : public FileSystem
|
||||
{
|
||||
public:
|
||||
ocfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
ocfs2(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -34,7 +34,7 @@ FileSystem::CommandSupportType reiser4::m_Check = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType reiser4::m_Copy = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType reiser4::m_Backup = FileSystem::cmdSupportNone;
|
||||
|
||||
reiser4::reiser4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
reiser4::reiser4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Reiser4)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT reiser4 : public FileSystem
|
||||
{
|
||||
public:
|
||||
reiser4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
reiser4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -41,7 +41,7 @@ FileSystem::CommandSupportType reiserfs::m_SetLabel = FileSystem::cmdSupportNone
|
|||
FileSystem::CommandSupportType reiserfs::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType reiserfs::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
reiserfs::reiserfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
reiserfs::reiserfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::ReiserFS)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT reiserfs : public FileSystem
|
||||
{
|
||||
public:
|
||||
reiserfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
reiserfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -39,7 +39,7 @@ FileSystem::CommandSupportType udf::m_UpdateUUID = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType udf::m_Create = FileSystem::cmdSupportNone;
|
||||
bool udf::oldMkudffsVersion = false;
|
||||
|
||||
udf::udf(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
udf::udf(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Udf)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT udf : public FileSystem
|
||||
{
|
||||
public:
|
||||
udf(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
udf(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -23,7 +23,7 @@ FileSystem::CommandSupportType ufs::m_Move = FileSystem::cmdSupportCore;
|
|||
FileSystem::CommandSupportType ufs::m_Copy = FileSystem::cmdSupportCore;
|
||||
FileSystem::CommandSupportType ufs::m_Backup = FileSystem::cmdSupportCore;
|
||||
|
||||
ufs::ufs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
ufs::ufs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Ufs)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT ufs : public FileSystem
|
||||
{
|
||||
public:
|
||||
ufs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
ufs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
CommandSupportType supportMove() const override {
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace FS
|
|||
{
|
||||
FileSystem::CommandSupportType unformatted::m_Create = FileSystem::cmdSupportFileSystem;
|
||||
|
||||
unformatted::unformatted(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
unformatted::unformatted(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Unformatted)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT unformatted : public FileSystem
|
||||
{
|
||||
public:
|
||||
unformatted(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
unformatted(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
bool create(Report&, const QString&) override;
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace FS
|
|||
|
||||
FileSystem::CommandSupportType unknown::m_Move = FileSystem::cmdSupportNone;
|
||||
|
||||
unknown::unknown(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
unknown::unknown(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Unknown)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT unknown : public FileSystem
|
||||
{
|
||||
public:
|
||||
unknown(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
unknown(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
bool supportToolFound() const override {
|
||||
|
|
|
@ -41,7 +41,7 @@ FileSystem::CommandSupportType xfs::m_Copy = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType xfs::m_Backup = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType xfs::m_SetLabel = FileSystem::cmdSupportNone;
|
||||
|
||||
xfs::xfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
xfs::xfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Xfs)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT xfs : public FileSystem
|
||||
{
|
||||
public:
|
||||
xfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
xfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -39,7 +39,7 @@ FileSystem::CommandSupportType zfs::m_SetLabel = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType zfs::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType zfs::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
zfs::zfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features) :
|
||||
zfs::zfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, features, FileSystem::Type::Zfs)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace FS
|
|||
class LIBKPMCORE_EXPORT zfs : public FileSystem
|
||||
{
|
||||
public:
|
||||
zfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QList<FSFeature>& features = {});
|
||||
zfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, const QVariantMap& features = {});
|
||||
|
||||
public:
|
||||
void init() override;
|
||||
|
|
|
@ -45,7 +45,7 @@ class LIBKPMCORE_EXPORT PartResizerWidget : public QWidget
|
|||
Q_DISABLE_COPY(PartResizerWidget)
|
||||
|
||||
public:
|
||||
PartResizerWidget(QWidget* parent);
|
||||
explicit PartResizerWidget(QWidget* parent);
|
||||
|
||||
public:
|
||||
void init(Device& d, Partition& p, qint64 minFirst, qint64 maxLast, bool read_only = false, bool move_allowed = true);
|
||||
|
|
|
@ -93,21 +93,22 @@ void PartWidget::paintEvent(QPaintEvent*)
|
|||
if (partition() == nullptr)
|
||||
return;
|
||||
|
||||
const int usedPercentage = static_cast<int>(partition()->used() * 100 / partition()->capacity());
|
||||
auto partitionCapacity = partition()->capacity();
|
||||
if (partitionCapacity <= 0)
|
||||
return;
|
||||
|
||||
const int usedPercentage = static_cast<int>(partition()->used() * 100 / partitionCapacity);
|
||||
const int w = width() * usedPercentage / 100;
|
||||
|
||||
QPainter painter(this);
|
||||
painter.setRenderHints(QPainter::Antialiasing);
|
||||
|
||||
const QColor base = activeColor(m_fileSystemColorCode[ static_cast<int>(partition()->fileSystem().type()) ]);
|
||||
if (partition()->roles().has(PartitionRole::Extended)) {
|
||||
drawGradient(&painter, activeColor(
|
||||
m_fileSystemColorCode[ static_cast<int>(partition()->fileSystem().type()) ]),
|
||||
QRect(0, 0, width(), height()));
|
||||
drawGradient(&painter, base, QRect(0, 0, width(), height()));
|
||||
return;
|
||||
}
|
||||
|
||||
const QColor base = activeColor(m_fileSystemColorCode[ static_cast<int>(partition()->fileSystem().type()) ]);
|
||||
|
||||
if (!partition()->roles().has(PartitionRole::Unallocated)) {
|
||||
const QColor dark = base.darker(105);
|
||||
const QColor light = base.lighter(120);
|
||||
|
@ -124,11 +125,11 @@ void PartWidget::paintEvent(QPaintEvent*)
|
|||
QString text = partition()->deviceNode().remove(QStringLiteral("/dev/")) + QStringLiteral("\n") + QString(Capacity::formatByteSize(partition()->capacity()));
|
||||
|
||||
const QRect textRect(0, 0, width() - 1, height() - 1);
|
||||
const QRect boundingRect = painter.boundingRect(textRect, Qt::AlignVCenter | Qt::AlignHCenter, text);
|
||||
const QRect boundingRect = painter.boundingRect(textRect, Qt::AlignCenter, text);
|
||||
if (boundingRect.x() > PartWidgetBase::borderWidth() && boundingRect.y() > PartWidgetBase::borderHeight()) {
|
||||
if (isActive())
|
||||
painter.setPen(QColor(255, 255, 255));
|
||||
painter.drawText(textRect, Qt::AlignVCenter | Qt::AlignHCenter, text);
|
||||
painter.setPen(Qt::white);
|
||||
painter.drawText(textRect, Qt::AlignCenter, text);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,9 @@ set(JOBS_SRC
|
|||
jobs/shredfilesystemjob.cpp
|
||||
jobs/createpartitionjob.cpp
|
||||
jobs/createpartitiontablejob.cpp
|
||||
jobs/setpartitionlabeljob.cpp
|
||||
jobs/setpartitionuuidjob.cpp
|
||||
jobs/setpartitionattributesjob.cpp
|
||||
jobs/createvolumegroupjob.cpp
|
||||
jobs/removevolumegroupjob.cpp
|
||||
jobs/deactivatevolumegroupjob.cpp
|
||||
|
|
|
@ -32,7 +32,7 @@ class QString;
|
|||
class CheckFileSystemJob : public Job
|
||||
{
|
||||
public:
|
||||
CheckFileSystemJob(Partition& p);
|
||||
explicit CheckFileSystemJob(Partition& p);
|
||||
|
||||
public:
|
||||
bool run(Report& parent) override;
|
||||
|
|
|
@ -59,11 +59,15 @@ bool CreatePartitionJob::run(Report& parent)
|
|||
if (backendPartitionTable) {
|
||||
QString partitionPath = backendPartitionTable->createPartition(*report, partition());
|
||||
|
||||
if (partitionPath != QString()) {
|
||||
if (!partitionPath.isEmpty()) {
|
||||
rval = true;
|
||||
partition().setPartitionPath(partitionPath);
|
||||
partition().setState(Partition::State::None);
|
||||
backendPartitionTable->commit();
|
||||
// The UUID is supported by GPT only; it is generated automatically once the creation of a partition.
|
||||
// Store the generated UUID to the partition object if no UUID is set.
|
||||
if (m_Device.partitionTable()->type() == PartitionTable::gpt && partition().uuid().isEmpty())
|
||||
partition().setUUID(backendPartitionTable->getPartitionUUID(*report, partition()));
|
||||
} else
|
||||
report->line() << xi18nc("@info/plain", "Failed to add partition <filename>%1</filename> to device <filename>%2</filename>.", partition().deviceNode(), device().deviceNode());
|
||||
} else
|
||||
|
|
|
@ -32,7 +32,7 @@ class QString;
|
|||
class CreatePartitionTableJob : public Job
|
||||
{
|
||||
public:
|
||||
CreatePartitionTableJob(Device& d);
|
||||
explicit CreatePartitionTableJob(Device& d);
|
||||
|
||||
public:
|
||||
bool run(Report& parent) override;
|
||||
|
|
|
@ -30,7 +30,7 @@ class QString;
|
|||
class DeactivateLogicalVolumeJob : public Job
|
||||
{
|
||||
public:
|
||||
DeactivateLogicalVolumeJob(const VolumeManagerDevice& dev, const QStringList lvPaths = {});
|
||||
explicit DeactivateLogicalVolumeJob(const VolumeManagerDevice& dev, const QStringList lvPaths = {});
|
||||
|
||||
public:
|
||||
bool run(Report& parent) override;
|
||||
|
|
|
@ -30,7 +30,7 @@ class QString;
|
|||
class DeactivateVolumeGroupJob : public Job
|
||||
{
|
||||
public:
|
||||
DeactivateVolumeGroupJob(VolumeManagerDevice& dev);
|
||||
explicit DeactivateVolumeGroupJob(VolumeManagerDevice& dev);
|
||||
|
||||
public:
|
||||
bool run(Report& parent) override;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue