Compare commits

...

38 Commits

Author SHA1 Message Date
Andrius Štikonas fbe54e21f3 Merge branch 'fstab' 2020-09-15 01:09:38 +01:00
Andrius Štikonas ba46ea64ba defaults option in fstab is not necessary, e.g. defaults,ro is the same as defaults. 2020-09-14 02:25:36 +01:00
Andrius Štikonas a928c62a7d Make fstab parsing slightly more readable. 2020-09-14 02:19:14 +01:00
Andrius Štikonas 1d195b00da Prettier formatting of fstab file. 2020-09-14 02:15:20 +01:00
Andrius Štikonas 1782a9d4bb Port away from deprecated QTime::elapsed. 2020-09-13 17:25:51 +01:00
Andrius Štikonas 2ed9953694 Simplify some External Command functions. 2020-09-11 20:27:24 +01:00
Andrius Štikonas 5b80c6045c Fix fstab editing functionality.
In the old code QByteArray fstabContents was actually empty.
Also, writeData function was opening file in append mode,
thus nothing was actually written.

Split writeData function into two:
  * one for block devices
  * another for writing fstab file

BUG: 417205
2020-09-10 23:54:23 +01:00
Adriaan de Groot 45bd205e79 Typofix: the function was half-renamed before the merge 2020-09-01 13:44:22 +02:00
Andrius Štikonas 997e8df183 Add a note about json fixes in util-linux 2.37 2020-08-28 22:41:43 +01:00
Adriaan de Groot 6aa9d93728 Workaround bad JSON output from sfdisk.
The output of `sfdisk --json /dev/sdb` is not necessarily
valid JSON. Then, no partition information is stored,
no first-valid-lba in particular. This leads to new partitions
being made from sector 0, which is invalid on a GPT table.

The workaround is to manually fix the known-broken JSON
from sfdisk. This is amply documented in a standalone
static function.

FIXES #425097
2020-08-24 22:53:54 +02:00
l10n daemon script 394859444f SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-07-26 05:51:19 +02:00
l10n daemon script 73a1deb092 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-07-25 05:37:40 +02:00
Andrius Štikonas dc604c4d31 sfdisk: simplify scanDevice by moving out partition setup logic. 2020-06-19 01:52:16 +01:00
l10n daemon script ffb7147f01 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-06-18 05:48:51 +02:00
l10n daemon script 1843a99895 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-06-17 14:16:14 +02:00
Gaël PORTAY 6f4b883130 sfdisk: Move GPT Attributes functions to new sfdiskgptattributes
This centralizes the two get functions related to GPT Attributes.
2020-06-16 20:15:56 -04:00
Gaël PORTAY 547fa609fe sfdisk: Read GPT type and attributes at scanning
The GPT type and attributes can be set since the commits 0529ebf (Add
support for setting the specific GPT type) and 0ffec31 (Add new job to
set the GPT partition attributes).

But these two data from existing partitions are not read and are missing
though.

This reads the GPT type and attributes data at scanning from the json
output, after the GPT name/label and uuid are read.
2020-06-16 15:45:53 -04:00
Gaël PORTAY 0ffec31e2b Add new job to set the GPT partition attributes
The GPT partition layout supports partition attributes.

The CLI sfdisk sets the partition attributes using the option
--part-attrs. See the examples below:

	$ cat <<EOF | sfdisk disk.img
	label: gpt
	type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, size=64M
	type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
	EOF
	(...)

	$ sfdisk --part-attrs disk.img 1 RequiredPartition,NoBlockIOProtocol,LegacyBIOSBootable,48
	(...)

	$ sfdisk --part-attrs disk.img 2 60,61,62,63
	(...)

	$ sfdisk --dump disk.img
	(...)
	disk.img1 : start=        2048, size=      131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=BBE806BB-8567-A843-9FF5-9B6B35D2908E, attrs="RequiredPartition NoBlockIOProtocol LegacyBIOSBootable GUID:48"
	disk.img2 : start=      133120, size=     1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=7DB39F08-C138-664B-B38E-ED2DEB549AA6, attrs="GUID:60,61,62,63"

This commit introduces the new job set-partition-attributes that is used
in the new-operation to set the attributes of the partition. The job
uses the newly introduced method setPartitionAttributes that is
implemented by the sfdisk and dummy backends.

Note: This is a copypaste of what was done for GPT partition label in
commit f585f6c (Add new job to set the GPT partition label) and GPT
partition UUID in commit 1dde035 (Add new job to set the GPT partition
UUID).

Note: RequiredPartition, NoBlockIOProtocol, LegacyBIOSBootable are
key words for 0, 1 and 2.
2020-06-15 17:51:42 -04:00
Andrius Štikonas 9dd118c58b Merge branch 'partition-uuid' into 'master'
Partition uuid

See merge request kde/kpmcore!8
2020-05-15 16:52:23 +00:00
Gaël PORTAY e12f0ec391 Store the generated partitition UUID after creation
The GPT UUID are generated by the backends automatically once a
partition is created.

This reads the UUID that was generated after the creation of a partition
and stores it back to the object Partition.
2020-05-15 12:13:41 -04:00
Gaël PORTAY 1dde035705 Add new job to set the GPT partition UUID
The GPT partition layout supports unique GUID partitions.

The CLI sfdisk sets the partition UUID using the option --part-uuid.
See the examples below:

	$ cat <<EOF | sfdisk disk.img
	label: gpt
	type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, size=64M
	type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
	EOF
	(...)

	$ sfdisk --dump disk.img
	(...)
	disk.img1 : start=        2048, size=      131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=BBE806BB-8567-A843-9FF5-9B6B35D2908E
	disk.img2 : start=      133120, size=     1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=7DB39F08-C138-664B-B38E-ED2DEB549AA6

	$ sfdisk --part-uuid disk.img 1 00000000^C000-0000-0000-000000000000
	(...)

	$ sfdisk --part-uuid disk.img 2 11111111-1111-1111-1111-111111111111
	(...)

	$ sfdisk --dump disk.img
	(...)
	disk.img1 : start=        2048, size=      131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=00000000-0000-0000-0000-000000000000
	disk.img2 : start=      133120, size=     1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=11111111-1111-1111-1111-111111111111

This commit introduces the new job set-partition-uuid that is used in
the new-operation to set the UUID of the partition. The job uses the
newly introduced method setPartitionUUID that is implemented by the
sfdisk and dummy backends.

Note: This is a copypaste of what was done for GTP partition label in
commit f585f6c (Add new job to set the GPT partition label).
2020-05-15 12:13:17 -04:00
Andrius Štikonas df4e2332f4 Merge branch 'fix-typos' into 'master'
Fix typos

See merge request kde/kpmcore!7
2020-05-15 15:51:06 +00:00
Gaël PORTAY e9992714a1 Fix typos 2020-05-15 11:39:55 -04:00
l10n daemon script 3c6ee043f6 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-05-09 06:34:55 +02:00
Adriaan de Groot 1d9b1161d4 On non-Linux, findBlkIdDevice() has unused parameters
Summary: Add Q_UNUSED() to mark the unused parameters

Test Plan: Builds with fewer warnings on FreeBSD

Differential Revision: https://phabricator.kde.org/D24155
2020-05-08 16:18:14 +02:00
Andrius Štikonas cacdb7b634 Fix some issues spotted by David Faure.
In particular, add a check for partition capacity to be positive.
2020-05-08 15:10:56 +01:00
l10n daemon script a2a9bb8301 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-04-04 06:23:31 +02:00
Andrius Štikonas d6b2584d1b Merge branch 'partition-name' into 'master'
Add support for setting the GPT partition name.

See merge request kde/kpmcore!4
2020-03-28 00:42:09 +00:00
l10n daemon script a4379583b3 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-03-27 06:21:07 +01:00
Gaël PORTAY f585f6c3ad Add new job to set the GPT partition label
The GPT partition layout supports naming partitions.

The support for the partition label was added in the backend libparted
since commit 28fa6ac (Add support for GTP partition labels).

The libparted was removed later by commit 8fa1814 (Remove libparted
backend) and no backend sets the partition label.

The CLI sfdisk sets the partition label using the option --part-label.
See the examples below:

	$ cat <<EOF | sfdisk disk.img
	label: gpt
	type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, size=64M
	type=0FC63DAF-8483-4772-8E79-3D69D8477DE4
	EOF
	(...)

	$ sfdisk --part-label disk.img 1 efi
	(...)

	$ sfdisk --part-label disk.img 2 rootfs
	(...)

	$ sfdisk --dump disk.img
	(...)
	disk.img1 : start=        2048, size=      131072, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=D08E5B2A-4649-9F4A-AEA3-6C3048888EAA, name="efi"
	disk.img2 : start=      133120, size=     1963999, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4, uuid=0BEEFE82-19EA-DC4C-BB6A-27B6DA0C3BD2, name="rootfs"

This commit introduces the new job set-partition-label that is used in
the new-operation to set the label of the partition. The job uses the
newly introduced method setPartitionLabel that is implemented by the
sfdisk and dummy backends.
2020-03-25 11:20:01 -04:00
l10n daemon script 52c29aaf10 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-03-25 06:42:28 +01:00
Andrius Štikonas 6921398ba3 Merge branch 'gportay/kpmcore-partition-type' 2020-03-22 01:49:35 +00:00
Andrius Štikonas 4fdaf6b1c8 Bump soversion of kpmcore. 2020-03-22 01:49:25 +00:00
Andrius Štikonas a810d0d2fd Merge branch 'gportay/kpmcore-update-filesystem-features-api' 2020-03-22 01:24:57 +00:00
Gaël PORTAY 9d6c98ff4a Replace FSFeature by QVariantMap
The object QVariant is a native object in the Qt world that represents
any type of value: boolean, integer, string, floating point, date,
UUID...

This change updates the API to use the object QVariant and provide a
more flexible API to represent the filesystem features.
2020-03-21 18:09:01 -04:00
Yuri Chornoivan 62aaa90a29
Fix minor EBN issues 2020-03-21 11:22:15 +00:00
Gaël PORTAY 0529ebfb01 Add support for setting the specific GPT type
The GPT partition layout defines the type of the partition using a
UUID[1]. The type of the partition is not related to the underlying
filesystem but to its functionality: rootfs, home, var, swap, esp...

The UUID 4f68bce3-e8cd-4db1-96e7-fbcaf984b709 defines the root partition
(/), the UUID 933ac7e1-2eb4-4f13-b844-0e14e2aef915 defines the home
partition (/home), the UUID 4d21b016-b534-45c2-a9fb-5c16e091fd2d defines
the variable partition (/var)... Also, the UUIDs may vary depending on
the architecture (x86, x86_64, arm or aarch64).

KPMcore guesses the type depending on the underlying filesystem.

This commit enables the setting of a more specific GPT type if it is
specified through the method Partition::setType(). It falls back to the
previous guess type if the type is left unset.

[1]: https://systemd.io/DISCOVERABLE_PARTITIONS/
2020-03-20 22:15:50 -04:00
l10n daemon script 59269f63df SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-03-11 06:00:21 +01:00
129 changed files with 1159 additions and 448 deletions

View File

@ -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)

View File

@ -39,7 +39,7 @@ class Report;
class CoreBackendDevice
{
public:
CoreBackendDevice(const QString& deviceNode);
explicit CoreBackendDevice(const QString& deviceNode);
virtual ~CoreBackendDevice() {}
public:

View File

@ -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.

View File

@ -36,7 +36,7 @@ class CopyTarget;
class CopySourceFile : public CopySource
{
public:
CopySourceFile(const QString& filename);
explicit CopySourceFile(const QString& filename);
public:
bool open() override;

View File

@ -34,7 +34,7 @@
class CopyTargetByteArray : public CopyTarget
{
public:
CopyTargetByteArray(QByteArray& array);
explicit CopyTargetByteArray(QByteArray& array);
public:
bool open() override {

View File

@ -36,7 +36,7 @@ class QString;
class CopyTargetFile : public CopyTarget
{
public:
CopyTargetFile(const QString& filename);
explicit CopyTargetFile(const QString& filename);
public:
bool open() override;

View File

@ -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);
}

View File

@ -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
*/

View File

@ -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() );

View File

@ -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:

View File

@ -51,7 +51,7 @@ public:
typedef QList<Operation*> Operations;
public:
OperationStack(QObject* parent = nullptr);
explicit OperationStack(QObject* parent = nullptr);
~OperationStack();
Q_SIGNALS:

View File

@ -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;

View File

@ -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());

View File

@ -46,7 +46,7 @@ public:
};
public:
SmartAttribute(const SmartAttributeParsedData& a);
explicit SmartAttribute(const SmartAttributeParsedData& a);
public:
qint32 id() const {

View File

@ -32,7 +32,7 @@ class SmartDiskInformation;
class SmartParser
{
public:
SmartParser(const QString &device_path);
explicit SmartParser(const QString &device_path);
~SmartParser();
public:

View File

@ -57,7 +57,7 @@ public:
typedef QList<SmartAttribute> Attributes;
public:
SmartStatus(const QString &device_path);
explicit SmartStatus(const QString &device_path);
public:
void update();

View File

@ -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"

View File

@ -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

View File

@ -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)
{
}

View File

@ -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 {

View File

@ -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)
{
}

View File

@ -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 {

View File

@ -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(","));

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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(","));

View File

@ -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;

View File

@ -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(","));

View File

@ -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;

View File

@ -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(","));

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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:

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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))

View File

@ -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;

View File

@ -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"));
}
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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;
};

View File

@ -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;

View File

@ -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();

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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 {

View File

@ -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)
{
}

View File

@ -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 = {});
};

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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 = {});
};
}

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)

View File

@ -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 {

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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 {

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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 {

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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)
{
}

View File

@ -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;

View File

@ -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);

View File

@ -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);
}
}

View File

@ -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

View File

@ -32,7 +32,7 @@ class QString;
class CheckFileSystemJob : public Job
{
public:
CheckFileSystemJob(Partition& p);
explicit CheckFileSystemJob(Partition& p);
public:
bool run(Report& parent) override;

View File

@ -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

View File

@ -32,7 +32,7 @@ class QString;
class CreatePartitionTableJob : public Job
{
public:
CreatePartitionTableJob(Device& d);
explicit CreatePartitionTableJob(Device& d);
public:
bool run(Report& parent) override;

View File

@ -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;

View File

@ -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