Convert more enums to scoped enums.
This commit is contained in:
parent
ee2688d4d9
commit
622def3b56
|
@ -31,7 +31,7 @@
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
static void parseFsSpec(const QString& m_fsSpec, FstabEntryType& m_entryType, QString& m_deviceNode);
|
static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType, QString& m_deviceNode);
|
||||||
static QString findBlkIdDevice(const char *token, const QString& value);
|
static QString findBlkIdDevice(const char *token, const QString& value);
|
||||||
|
|
||||||
struct FstabEntryPrivate
|
struct FstabEntryPrivate
|
||||||
|
@ -44,7 +44,7 @@ struct FstabEntryPrivate
|
||||||
int m_dumpFreq;
|
int m_dumpFreq;
|
||||||
int m_passNumber;
|
int m_passNumber;
|
||||||
QString m_comment;
|
QString m_comment;
|
||||||
FstabEntryType m_entryType;
|
FstabEntry::Type m_entryType;
|
||||||
};
|
};
|
||||||
|
|
||||||
FstabEntry::FstabEntry(const QString& fsSpec, const QString& mountPoint, const QString& type, const QString& options, int dumpFreq, int passNumber, const QString& comment) :
|
FstabEntry::FstabEntry(const QString& fsSpec, const QString& mountPoint, const QString& type, const QString& options, int dumpFreq, int passNumber, const QString& comment) :
|
||||||
|
@ -103,7 +103,7 @@ FstabEntryList readFstabEntries( const QString& fstabPath )
|
||||||
}
|
}
|
||||||
|
|
||||||
fstabFile.close();
|
fstabFile.close();
|
||||||
if (fstabEntries.back().entryType() == comment && fstabEntries.back().comment().isEmpty())
|
if (fstabEntries.back().entryType() == FstabEntry::Type::comment && fstabEntries.back().comment().isEmpty())
|
||||||
fstabEntries.pop_back();
|
fstabEntries.pop_back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ const QString& FstabEntry::comment() const
|
||||||
return d->m_comment;
|
return d->m_comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
FstabEntryType FstabEntry::entryType() const
|
FstabEntry::Type FstabEntry::entryType() const
|
||||||
{
|
{
|
||||||
return d->m_entryType;
|
return d->m_entryType;
|
||||||
}
|
}
|
||||||
|
@ -207,23 +207,23 @@ static QString findBlkIdDevice(const char *token, const QString& value)
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parseFsSpec(const QString& m_fsSpec, FstabEntryType& m_entryType, QString& m_deviceNode)
|
static void parseFsSpec(const QString& m_fsSpec, FstabEntry::Type& m_entryType, QString& m_deviceNode)
|
||||||
{
|
{
|
||||||
m_entryType = FstabEntryType::comment;
|
m_entryType = FstabEntry::Type::comment;
|
||||||
if (m_fsSpec.startsWith(QStringLiteral("UUID="))) {
|
if (m_fsSpec.startsWith(QStringLiteral("UUID="))) {
|
||||||
m_entryType = FstabEntryType::uuid;
|
m_entryType = FstabEntry::Type::uuid;
|
||||||
m_deviceNode = findBlkIdDevice("UUID", QString(m_fsSpec).remove(QStringLiteral("UUID=")));
|
m_deviceNode = findBlkIdDevice("UUID", QString(m_fsSpec).remove(QStringLiteral("UUID=")));
|
||||||
} else if (m_fsSpec.startsWith(QStringLiteral("LABEL="))) {
|
} else if (m_fsSpec.startsWith(QStringLiteral("LABEL="))) {
|
||||||
m_entryType = FstabEntryType::label;
|
m_entryType = FstabEntry::Type::label;
|
||||||
m_deviceNode = findBlkIdDevice("LABEL", QString(m_fsSpec).remove(QStringLiteral("LABEL=")));
|
m_deviceNode = findBlkIdDevice("LABEL", QString(m_fsSpec).remove(QStringLiteral("LABEL=")));
|
||||||
} else if (m_fsSpec.startsWith(QStringLiteral("PARTUUID="))) {
|
} else if (m_fsSpec.startsWith(QStringLiteral("PARTUUID="))) {
|
||||||
m_entryType = FstabEntryType::uuid;
|
m_entryType = FstabEntry::Type::uuid;
|
||||||
m_deviceNode = findBlkIdDevice("PARTUUID", QString(m_fsSpec).remove(QStringLiteral("PARTUUID=")));
|
m_deviceNode = findBlkIdDevice("PARTUUID", QString(m_fsSpec).remove(QStringLiteral("PARTUUID=")));
|
||||||
} else if (m_fsSpec.startsWith(QStringLiteral("PARTLABEL="))) {
|
} else if (m_fsSpec.startsWith(QStringLiteral("PARTLABEL="))) {
|
||||||
m_entryType = FstabEntryType::label;
|
m_entryType = FstabEntry::Type::label;
|
||||||
m_deviceNode = findBlkIdDevice("PARTLABEL", QString(m_fsSpec).remove(QStringLiteral("PARTLABEL=")));
|
m_deviceNode = findBlkIdDevice("PARTLABEL", QString(m_fsSpec).remove(QStringLiteral("PARTLABEL=")));
|
||||||
} else if (m_fsSpec.startsWith(QStringLiteral("/"))) {
|
} else if (m_fsSpec.startsWith(QStringLiteral("/"))) {
|
||||||
m_entryType = FstabEntryType::deviceNode;
|
m_entryType = FstabEntry::Type::deviceNode;
|
||||||
m_deviceNode = m_fsSpec;
|
m_deviceNode = m_fsSpec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ static void parseFsSpec(const QString& m_fsSpec, FstabEntryType& m_entryType, QS
|
||||||
static void writeEntry(QFile& output, const FstabEntry& entry)
|
static void writeEntry(QFile& output, const FstabEntry& entry)
|
||||||
{
|
{
|
||||||
QTextStream s(&output);
|
QTextStream s(&output);
|
||||||
if (entry.entryType() == FstabEntryType::comment) {
|
if (entry.entryType() == FstabEntry::Type::comment) {
|
||||||
s << entry.comment() << "\n";
|
s << entry.comment() << "\n";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,6 @@
|
||||||
|
|
||||||
struct FstabEntryPrivate;
|
struct FstabEntryPrivate;
|
||||||
|
|
||||||
enum FstabEntryType { deviceNode, uuid, label, partlabel, partuuid, comment };
|
|
||||||
|
|
||||||
/** Base class for fstab handling.
|
/** Base class for fstab handling.
|
||||||
|
|
||||||
FstabEntry stores a single line of /etc/fstab file which can be a comment
|
FstabEntry stores a single line of /etc/fstab file which can be a comment
|
||||||
|
@ -39,6 +37,8 @@ enum FstabEntryType { deviceNode, uuid, label, partlabel, partuuid, comment };
|
||||||
class LIBKPMCORE_EXPORT FstabEntry
|
class LIBKPMCORE_EXPORT FstabEntry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum class Type { deviceNode, uuid, label, partlabel, partuuid, comment };
|
||||||
|
|
||||||
FstabEntry(const QString& fsSpec, const QString& mountPoint, const QString& type, const QString& options, int dumpFreq = 0, int passNumber = 0, const QString& comment = QString());
|
FstabEntry(const QString& fsSpec, const QString& mountPoint, const QString& type, const QString& options, int dumpFreq = 0, int passNumber = 0, const QString& comment = QString());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +84,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* @return the type of fstab entry, e.g. device node or UUID or comment only
|
* @return the type of fstab entry, e.g. device node or UUID or comment only
|
||||||
*/
|
*/
|
||||||
FstabEntryType entryType() const;
|
Type entryType() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param s the new value for the fs_spec field of fstab entry
|
* @param s the new value for the fs_spec field of fstab entry
|
||||||
|
|
|
@ -85,10 +85,10 @@ bool PartitionAlignment::isAligned(const Device& d, const Partition& p, bool qui
|
||||||
bool PartitionAlignment::isAligned(const Device& d, const Partition& p, qint64 newFirst, qint64 newLast, bool quiet)
|
bool PartitionAlignment::isAligned(const Device& d, const Partition& p, qint64 newFirst, qint64 newLast, bool quiet)
|
||||||
{
|
{
|
||||||
if (firstDelta(d, p, newFirst) && !quiet)
|
if (firstDelta(d, p, newFirst) && !quiet)
|
||||||
Log(Log::warning) << xi18nc("@info:status", "Partition <filename>%1</filename> is not properly aligned (first sector: %2, modulo: %3).", p.deviceNode(), newFirst, firstDelta(d, p, newFirst));
|
Log(Log::Level::warning) << xi18nc("@info:status", "Partition <filename>%1</filename> is not properly aligned (first sector: %2, modulo: %3).", p.deviceNode(), newFirst, firstDelta(d, p, newFirst));
|
||||||
|
|
||||||
if (lastDelta(d, p, newLast) && !quiet)
|
if (lastDelta(d, p, newLast) && !quiet)
|
||||||
Log(Log::warning) << xi18nc("@info:status", "Partition <filename>%1</filename> is not properly aligned (last sector: %2, modulo: %3).", p.deviceNode(), newLast, lastDelta(d, p, newLast));
|
Log(Log::Level::warning) << xi18nc("@info:status", "Partition <filename>%1</filename> is not properly aligned (last sector: %2, modulo: %3).", p.deviceNode(), newLast, lastDelta(d, p, newLast));
|
||||||
|
|
||||||
return firstDelta(d, p, newFirst) == 0 && lastDelta(d, p, newLast) == 0;
|
return firstDelta(d, p, newFirst) == 0 && lastDelta(d, p, newLast) == 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,8 +35,8 @@ SmartAttribute::SmartAttribute(const SmartAttributeParsedData& a) :
|
||||||
m_Id(a.id()),
|
m_Id(a.id()),
|
||||||
m_Name(getAttrName(a.id())),
|
m_Name(getAttrName(a.id())),
|
||||||
m_Desc(getAttrDescription(a.id())),
|
m_Desc(getAttrDescription(a.id())),
|
||||||
m_FailureType(a.prefailure() ? PreFailure : OldAge),
|
m_FailureType(a.prefailure() ? FailureType::PreFailure : FailureType::OldAge),
|
||||||
m_UpdateType(a.online() ? Online : Offline),
|
m_UpdateType(a.online() ? UpdateType::Online : UpdateType::Offline),
|
||||||
m_Current(a.currentValueValid() ? a.currentValue() : -1),
|
m_Current(a.currentValueValid() ? a.currentValue() : -1),
|
||||||
m_Worst(a.worstValueValid() ? a.worstValue() : -1),
|
m_Worst(a.worstValueValid() ? a.worstValue() : -1),
|
||||||
m_Threshold(a.thresholdValid() ? a.threshold() : -1),
|
m_Threshold(a.thresholdValid() ? a.threshold() : -1),
|
||||||
|
@ -50,19 +50,19 @@ SmartAttribute::SmartAttribute(const SmartAttributeParsedData& a) :
|
||||||
QString SmartAttribute::assessmentToString(Assessment a)
|
QString SmartAttribute::assessmentToString(Assessment a)
|
||||||
{
|
{
|
||||||
switch (a) {
|
switch (a) {
|
||||||
case Failing:
|
case Assessment::Failing:
|
||||||
return xi18nc("@item:intable", "failing");
|
return xi18nc("@item:intable", "failing");
|
||||||
|
|
||||||
case HasFailed:
|
case Assessment::HasFailed:
|
||||||
return xi18nc("@item:intable", "has failed");
|
return xi18nc("@item:intable", "has failed");
|
||||||
|
|
||||||
case Warning:
|
case Assessment::Warning:
|
||||||
return xi18nc("@item:intable", "warning");
|
return xi18nc("@item:intable", "warning");
|
||||||
|
|
||||||
case Good:
|
case Assessment::Good:
|
||||||
return xi18nc("@item:intable", "good");
|
return xi18nc("@item:intable", "good");
|
||||||
|
|
||||||
case NotApplicable:
|
case Assessment::NotApplicable:
|
||||||
default:
|
default:
|
||||||
return xi18nc("@item:intable not applicable", "N/A");
|
return xi18nc("@item:intable not applicable", "N/A");
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ static QString getAttrDescription(qint32 id)
|
||||||
|
|
||||||
static SmartAttribute::Assessment getAssessment(const SmartAttributeParsedData& a)
|
static SmartAttribute::Assessment getAssessment(const SmartAttributeParsedData& a)
|
||||||
{
|
{
|
||||||
SmartAttribute::Assessment rval = SmartAttribute::NotApplicable;
|
SmartAttribute::Assessment rval = SmartAttribute::Assessment::NotApplicable;
|
||||||
|
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
bool hasFailed = false;
|
bool hasFailed = false;
|
||||||
|
@ -235,13 +235,13 @@ static SmartAttribute::Assessment getAssessment(const SmartAttributeParsedData&
|
||||||
}
|
}
|
||||||
|
|
||||||
if (failed)
|
if (failed)
|
||||||
rval = SmartAttribute::Failing;
|
rval = SmartAttribute::Assessment::Failing;
|
||||||
else if (hasFailed)
|
else if (hasFailed)
|
||||||
rval = SmartAttribute::HasFailed;
|
rval = SmartAttribute::Assessment::HasFailed;
|
||||||
else if (a.warn())
|
else if (a.warn())
|
||||||
rval = SmartAttribute::Warning;
|
rval = SmartAttribute::Assessment::Warning;
|
||||||
else if (a.goodNowValid())
|
else if (a.goodNowValid())
|
||||||
rval = SmartAttribute::Good;
|
rval = SmartAttribute::Assessment::Good;
|
||||||
|
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,17 +27,17 @@ class SmartAttributeParsedData;
|
||||||
class LIBKPMCORE_EXPORT SmartAttribute
|
class LIBKPMCORE_EXPORT SmartAttribute
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum FailureType {
|
enum class FailureType {
|
||||||
PreFailure,
|
PreFailure,
|
||||||
OldAge
|
OldAge
|
||||||
};
|
};
|
||||||
|
|
||||||
enum UpdateType {
|
enum class UpdateType {
|
||||||
Online,
|
Online,
|
||||||
Offline
|
Offline
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Assessment {
|
enum class Assessment {
|
||||||
NotApplicable,
|
NotApplicable,
|
||||||
Failing,
|
Failing,
|
||||||
HasFailed,
|
HasFailed,
|
||||||
|
|
|
@ -34,7 +34,7 @@ SmartDiskInformation::SmartDiskInformation() :
|
||||||
m_BadAttributeNow(false),
|
m_BadAttributeNow(false),
|
||||||
m_BadAttributeInThePast(false),
|
m_BadAttributeInThePast(false),
|
||||||
m_SelfTestExecutionStatus(SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER),
|
m_SelfTestExecutionStatus(SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER),
|
||||||
m_Overall(SmartDiskInformation::SMART_OVERALL_BAD_STATUS)
|
m_Overall(SmartDiskInformation::Overall::BadStatus)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -62,36 +62,35 @@ void SmartDiskInformation::updateBadSectors()
|
||||||
void SmartDiskInformation::updateOverall()
|
void SmartDiskInformation::updateOverall()
|
||||||
{
|
{
|
||||||
if (!smartStatus()) {
|
if (!smartStatus()) {
|
||||||
m_Overall = SMART_OVERALL_BAD_STATUS;
|
m_Overall = Overall::BadStatus;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64 sector_threshold = u64log2(size() / 512) * 1024;
|
quint64 sector_threshold = u64log2(size() / 512) * 1024;
|
||||||
|
|
||||||
if (badSectors() >= sector_threshold) {
|
if (badSectors() >= sector_threshold) {
|
||||||
m_Overall = SMART_OVERALL_BAD_SECTOR_MANY;
|
m_Overall = Overall::BadSectorsMany;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
validateBadAttributes();
|
validateBadAttributes();
|
||||||
|
|
||||||
if (m_BadAttributeNow) {
|
if (m_BadAttributeNow) {
|
||||||
m_Overall = SMART_OVERALL_BAD_ATTRIBUTE_NOW;
|
m_Overall = Overall::BadAttributeNow;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (badSectors() > 0) {
|
if (badSectors() > 0) {
|
||||||
m_Overall = SMART_OVERALL_BAD_SECTOR;
|
m_Overall = Overall::BadSector;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_BadAttributeInThePast) {
|
if (m_BadAttributeInThePast) {
|
||||||
m_Overall = SMART_OVERALL_BAD_ATTRIBUTE_IN_THE_PAST;
|
m_Overall = Overall::BadAttributeInThePast;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Overall = SMART_OVERALL_GOOD;
|
m_Overall = Overall::Good;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Update the temperature value based on SMART attributes
|
/** Update the temperature value based on SMART attributes
|
||||||
|
|
|
@ -48,14 +48,13 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/** SMART overall state */
|
/** SMART overall state */
|
||||||
enum SmartOverall {
|
enum class Overall {
|
||||||
SMART_OVERALL_GOOD,
|
Good,
|
||||||
SMART_OVERALL_BAD_ATTRIBUTE_IN_THE_PAST,
|
BadAttributeInThePast,
|
||||||
SMART_OVERALL_BAD_SECTOR,
|
BadSector,
|
||||||
SMART_OVERALL_BAD_ATTRIBUTE_NOW,
|
BadAttributeNow,
|
||||||
SMART_OVERALL_BAD_SECTOR_MANY,
|
BadSectorsMany,
|
||||||
SMART_OVERALL_BAD_STATUS,
|
BadStatus,
|
||||||
_SMART_OVERALL_MAX
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -105,7 +104,7 @@ public:
|
||||||
return m_SelfTestExecutionStatus; /**< @return SMART self execution status */
|
return m_SelfTestExecutionStatus; /**< @return SMART self execution status */
|
||||||
}
|
}
|
||||||
|
|
||||||
SmartOverall overall() const
|
Overall overall() const
|
||||||
{
|
{
|
||||||
return m_Overall; /**< @return SMART overall status */
|
return m_Overall; /**< @return SMART overall status */
|
||||||
}
|
}
|
||||||
|
@ -192,7 +191,7 @@ private:
|
||||||
bool m_BadAttributeNow;
|
bool m_BadAttributeNow;
|
||||||
bool m_BadAttributeInThePast;
|
bool m_BadAttributeInThePast;
|
||||||
SmartSelfTestExecutionStatus m_SelfTestExecutionStatus;
|
SmartSelfTestExecutionStatus m_SelfTestExecutionStatus;
|
||||||
SmartOverall m_Overall;
|
Overall m_Overall;
|
||||||
QList<SmartAttributeParsedData> m_Attributes;
|
QList<SmartAttributeParsedData> m_Attributes;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,8 +37,8 @@ SmartStatus::SmartStatus(const QString &device_path) :
|
||||||
m_ModelName(),
|
m_ModelName(),
|
||||||
m_Serial(),
|
m_Serial(),
|
||||||
m_Firmware(),
|
m_Firmware(),
|
||||||
m_Overall(Bad),
|
m_Overall(Overall::Bad),
|
||||||
m_SelfTestStatus(Success),
|
m_SelfTestStatus(SelfTestStatus::Success),
|
||||||
m_Temp(0),
|
m_Temp(0),
|
||||||
m_BadSectors(0),
|
m_BadSectors(0),
|
||||||
m_PowerCycles(0),
|
m_PowerCycles(0),
|
||||||
|
@ -73,72 +73,72 @@ void SmartStatus::update()
|
||||||
|
|
||||||
switch (disk->selfTestExecutionStatus()) {
|
switch (disk->selfTestExecutionStatus()) {
|
||||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ABORTED:
|
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ABORTED:
|
||||||
setSelfTestStatus(Aborted);
|
setSelfTestStatus(SelfTestStatus::Aborted);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_INTERRUPTED:
|
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_INTERRUPTED:
|
||||||
setSelfTestStatus(Interrupted);
|
setSelfTestStatus(SelfTestStatus::Interrupted);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_FATAL:
|
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_FATAL:
|
||||||
setSelfTestStatus(Fatal);
|
setSelfTestStatus(SelfTestStatus::Fatal);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_UNKNOWN:
|
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_UNKNOWN:
|
||||||
setSelfTestStatus(ErrorUnknown);
|
setSelfTestStatus(SelfTestStatus::ErrorUnknown);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_ELECTRICAL:
|
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_ELECTRICAL:
|
||||||
setSelfTestStatus(ErrorEletrical);
|
setSelfTestStatus(SelfTestStatus::ErrorEletrical);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_SERVO:
|
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_SERVO:
|
||||||
setSelfTestStatus(ErrorServo);
|
setSelfTestStatus(SelfTestStatus::ErrorServo);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_READ:
|
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_READ:
|
||||||
setSelfTestStatus(ErrorRead);
|
setSelfTestStatus(SelfTestStatus::ErrorRead);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_HANDLING:
|
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_ERROR_HANDLING:
|
||||||
setSelfTestStatus(ErrorHandling);
|
setSelfTestStatus(SelfTestStatus::ErrorHandling);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_INPROGRESS:
|
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_INPROGRESS:
|
||||||
setSelfTestStatus(InProgress);
|
setSelfTestStatus(SelfTestStatus::InProgress);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER:
|
case SmartDiskInformation::SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER:
|
||||||
setSelfTestStatus(Success);
|
setSelfTestStatus(SelfTestStatus::Success);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (disk->overall()) {
|
switch (disk->overall()) {
|
||||||
case SmartDiskInformation::SMART_OVERALL_GOOD:
|
case SmartDiskInformation::Overall::Good:
|
||||||
setOverall(Good);
|
setOverall(Overall::Good);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmartDiskInformation::SMART_OVERALL_BAD_ATTRIBUTE_IN_THE_PAST:
|
case SmartDiskInformation::Overall::BadAttributeInThePast:
|
||||||
setOverall(BadPast);
|
setOverall(Overall::BadPast);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmartDiskInformation::SMART_OVERALL_BAD_SECTOR:
|
case SmartDiskInformation::Overall::BadSector:
|
||||||
setOverall(BadSectors);
|
setOverall(Overall::BadSectors);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmartDiskInformation::SMART_OVERALL_BAD_ATTRIBUTE_NOW:
|
case SmartDiskInformation::Overall::BadAttributeNow:
|
||||||
setOverall(BadNow);
|
setOverall(Overall::BadNow);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SmartDiskInformation::SMART_OVERALL_BAD_SECTOR_MANY:
|
case SmartDiskInformation::Overall::BadSectorsMany:
|
||||||
setOverall(BadSectorsMany);
|
setOverall(Overall::BadSectorsMany);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
case SmartDiskInformation::SMART_OVERALL_BAD_STATUS:
|
case SmartDiskInformation::Overall::BadStatus:
|
||||||
setOverall(Bad);
|
setOverall(Overall::Bad);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -167,34 +167,34 @@ QString SmartStatus::tempToString(quint64 mkelvin)
|
||||||
QString SmartStatus::selfTestStatusToString(SmartStatus::SelfTestStatus s)
|
QString SmartStatus::selfTestStatusToString(SmartStatus::SelfTestStatus s)
|
||||||
{
|
{
|
||||||
switch (s) {
|
switch (s) {
|
||||||
case Aborted:
|
case SelfTestStatus::Aborted:
|
||||||
return xi18nc("@item", "Aborted");
|
return xi18nc("@item", "Aborted");
|
||||||
|
|
||||||
case Interrupted:
|
case SelfTestStatus::Interrupted:
|
||||||
return xi18nc("@item", "Interrupted");
|
return xi18nc("@item", "Interrupted");
|
||||||
|
|
||||||
case Fatal:
|
case SelfTestStatus::Fatal:
|
||||||
return xi18nc("@item", "Fatal error");
|
return xi18nc("@item", "Fatal error");
|
||||||
|
|
||||||
case ErrorUnknown:
|
case SelfTestStatus::ErrorUnknown:
|
||||||
return xi18nc("@item", "Unknown error");
|
return xi18nc("@item", "Unknown error");
|
||||||
|
|
||||||
case ErrorEletrical:
|
case SelfTestStatus::ErrorEletrical:
|
||||||
return xi18nc("@item", "Electrical error");
|
return xi18nc("@item", "Electrical error");
|
||||||
|
|
||||||
case ErrorServo:
|
case SelfTestStatus::ErrorServo:
|
||||||
return xi18nc("@item", "Servo error");
|
return xi18nc("@item", "Servo error");
|
||||||
|
|
||||||
case ErrorRead:
|
case SelfTestStatus::ErrorRead:
|
||||||
return xi18nc("@item", "Read error");
|
return xi18nc("@item", "Read error");
|
||||||
|
|
||||||
case ErrorHandling:
|
case SelfTestStatus::ErrorHandling:
|
||||||
return xi18nc("@item", "Handling error");
|
return xi18nc("@item", "Handling error");
|
||||||
|
|
||||||
case InProgress:
|
case SelfTestStatus::InProgress:
|
||||||
return xi18nc("@item", "Self test in progress");
|
return xi18nc("@item", "Self test in progress");
|
||||||
|
|
||||||
case Success:
|
case SelfTestStatus::Success:
|
||||||
default:
|
default:
|
||||||
return xi18nc("@item", "Success");
|
return xi18nc("@item", "Success");
|
||||||
}
|
}
|
||||||
|
@ -204,22 +204,22 @@ QString SmartStatus::selfTestStatusToString(SmartStatus::SelfTestStatus s)
|
||||||
QString SmartStatus::overallAssessmentToString(Overall o)
|
QString SmartStatus::overallAssessmentToString(Overall o)
|
||||||
{
|
{
|
||||||
switch (o) {
|
switch (o) {
|
||||||
case Good:
|
case Overall::Good:
|
||||||
return xi18nc("@item", "Healthy");
|
return xi18nc("@item", "Healthy");
|
||||||
|
|
||||||
case BadPast:
|
case Overall::BadPast:
|
||||||
return xi18nc("@item", "Has been used outside of its design parameters in the past.");
|
return xi18nc("@item", "Has been used outside of its design parameters in the past.");
|
||||||
|
|
||||||
case BadSectors:
|
case Overall::BadSectors:
|
||||||
return xi18nc("@item", "Has some bad sectors.");
|
return xi18nc("@item", "Has some bad sectors.");
|
||||||
|
|
||||||
case BadNow:
|
case Overall::BadNow:
|
||||||
return xi18nc("@item", "Is being used outside of its design parameters right now.");
|
return xi18nc("@item", "Is being used outside of its design parameters right now.");
|
||||||
|
|
||||||
case BadSectorsMany:
|
case Overall::BadSectorsMany:
|
||||||
return xi18nc("@item", "Has many bad sectors.");
|
return xi18nc("@item", "Has many bad sectors.");
|
||||||
|
|
||||||
case Bad:
|
case Overall::Bad:
|
||||||
default:
|
default:
|
||||||
return xi18nc("@item", "Disk failure is imminent. Backup all data!");
|
return xi18nc("@item", "Disk failure is imminent. Backup all data!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct SkDisk;
|
||||||
class LIBKPMCORE_EXPORT SmartStatus
|
class LIBKPMCORE_EXPORT SmartStatus
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Overall {
|
enum class Overall {
|
||||||
Good,
|
Good,
|
||||||
BadPast,
|
BadPast,
|
||||||
BadSectors,
|
BadSectors,
|
||||||
|
@ -40,7 +40,7 @@ public:
|
||||||
Bad
|
Bad
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SelfTestStatus {
|
enum class SelfTestStatus {
|
||||||
Success,
|
Success,
|
||||||
Aborted,
|
Aborted,
|
||||||
Interrupted,
|
Interrupted,
|
||||||
|
|
|
@ -91,12 +91,12 @@ FileSystem::SupportTool btrfs::supportToolName() const
|
||||||
|
|
||||||
qint64 btrfs::minCapacity() const
|
qint64 btrfs::minCapacity() const
|
||||||
{
|
{
|
||||||
return 256 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 256 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 btrfs::maxCapacity() const
|
qint64 btrfs::maxCapacity() const
|
||||||
{
|
{
|
||||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int btrfs::maxLabelLength() const
|
int btrfs::maxLabelLength() const
|
||||||
|
|
|
@ -84,7 +84,7 @@ FileSystem::SupportTool exfat::supportToolName() const
|
||||||
|
|
||||||
qint64 exfat::maxCapacity() const
|
qint64 exfat::maxCapacity() const
|
||||||
{
|
{
|
||||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int exfat::maxLabelLength() const
|
int exfat::maxLabelLength() const
|
||||||
|
|
|
@ -84,7 +84,7 @@ FileSystem::SupportTool ext2::supportToolName() const
|
||||||
|
|
||||||
qint64 ext2::maxCapacity() const
|
qint64 ext2::maxCapacity() const
|
||||||
{
|
{
|
||||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ext2::maxLabelLength() const
|
int ext2::maxLabelLength() const
|
||||||
|
|
|
@ -31,7 +31,7 @@ ext3::ext3(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QStr
|
||||||
|
|
||||||
qint64 ext3::maxCapacity() const
|
qint64 ext3::maxCapacity() const
|
||||||
{
|
{
|
||||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ext3::create(Report& report, const QString& deviceNode)
|
bool ext3::create(Report& report, const QString& deviceNode)
|
||||||
|
|
|
@ -31,7 +31,7 @@ ext4::ext4(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QStr
|
||||||
|
|
||||||
qint64 ext4::maxCapacity() const
|
qint64 ext4::maxCapacity() const
|
||||||
{
|
{
|
||||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ext4::create(Report& report, const QString& deviceNode)
|
bool ext4::create(Report& report, const QString& deviceNode)
|
||||||
|
|
|
@ -100,12 +100,12 @@ FileSystem::SupportTool f2fs::supportToolName() const
|
||||||
|
|
||||||
qint64 f2fs::minCapacity() const
|
qint64 f2fs::minCapacity() const
|
||||||
{
|
{
|
||||||
return 30 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 30 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 f2fs::maxCapacity() const
|
qint64 f2fs::maxCapacity() const
|
||||||
{
|
{
|
||||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
|
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int f2fs::maxLabelLength() const
|
int f2fs::maxLabelLength() const
|
||||||
|
|
|
@ -87,12 +87,12 @@ FileSystem::SupportTool fat12::supportToolName() const
|
||||||
|
|
||||||
qint64 fat12::minCapacity() const
|
qint64 fat12::minCapacity() const
|
||||||
{
|
{
|
||||||
return 1 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 1 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 fat12::maxCapacity() const
|
qint64 fat12::maxCapacity() const
|
||||||
{
|
{
|
||||||
return 255 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 255 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fat12::maxLabelLength() const
|
int fat12::maxLabelLength() const
|
||||||
|
|
|
@ -75,12 +75,12 @@ bool fat16::supportToolFound() const
|
||||||
|
|
||||||
qint64 fat16::minCapacity() const
|
qint64 fat16::minCapacity() const
|
||||||
{
|
{
|
||||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 fat16::maxCapacity() const
|
qint64 fat16::maxCapacity() const
|
||||||
{
|
{
|
||||||
return 4 * Capacity::unitFactor(Capacity::Byte, Capacity::GiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 4 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::GiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fat16::create(Report& report, const QString& deviceNode)
|
bool fat16::create(Report& report, const QString& deviceNode)
|
||||||
|
|
|
@ -32,12 +32,12 @@ fat32::fat32(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QS
|
||||||
|
|
||||||
qint64 fat32::minCapacity() const
|
qint64 fat32::minCapacity() const
|
||||||
{
|
{
|
||||||
return 32 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 32 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 fat32::maxCapacity() const
|
qint64 fat32::maxCapacity() const
|
||||||
{
|
{
|
||||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fat32::create(Report& report, const QString& deviceNode)
|
bool fat32::create(Report& report, const QString& deviceNode)
|
||||||
|
|
|
@ -376,13 +376,13 @@ bool FileSystem::updateBootSector(Report& report, const QString& deviceNode) con
|
||||||
/** @return the minimum capacity valid for this FileSystem in bytes */
|
/** @return the minimum capacity valid for this FileSystem in bytes */
|
||||||
qint64 FileSystem::minCapacity() const
|
qint64 FileSystem::minCapacity() const
|
||||||
{
|
{
|
||||||
return 8 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 8 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the maximum capacity valid for this FileSystem in bytes */
|
/** @return the maximum capacity valid for this FileSystem in bytes */
|
||||||
qint64 FileSystem::maxCapacity() const
|
qint64 FileSystem::maxCapacity() const
|
||||||
{
|
{
|
||||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return the maximum label length valid for this FileSystem */
|
/** @return the maximum label length valid for this FileSystem */
|
||||||
|
|
|
@ -73,7 +73,7 @@ FileSystem::SupportTool hfs::supportToolName() const
|
||||||
|
|
||||||
qint64 hfs::maxCapacity() const
|
qint64 hfs::maxCapacity() const
|
||||||
{
|
{
|
||||||
return 2 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
|
return 2 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int hfs::maxLabelLength() const
|
int hfs::maxLabelLength() const
|
||||||
|
|
|
@ -73,7 +73,7 @@ FileSystem::SupportTool hfsplus::supportToolName() const
|
||||||
|
|
||||||
qint64 hfsplus::maxCapacity() const
|
qint64 hfsplus::maxCapacity() const
|
||||||
{
|
{
|
||||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int hfsplus::maxLabelLength() const
|
int hfsplus::maxLabelLength() const
|
||||||
|
|
|
@ -43,6 +43,6 @@ hpfs::hpfs(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QStr
|
||||||
|
|
||||||
qint64 hpfs::maxCapacity() const
|
qint64 hpfs::maxCapacity() const
|
||||||
{
|
{
|
||||||
return 2 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
|
return 2 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,12 +79,12 @@ FileSystem::SupportTool jfs::supportToolName() const
|
||||||
|
|
||||||
qint64 jfs::minCapacity() const
|
qint64 jfs::minCapacity() const
|
||||||
{
|
{
|
||||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 jfs::maxCapacity() const
|
qint64 jfs::maxCapacity() const
|
||||||
{
|
{
|
||||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
|
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int jfs::maxLabelLength() const
|
int jfs::maxLabelLength() const
|
||||||
|
|
|
@ -17,8 +17,7 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#if !defined(KPMCORE_LUKS_H)
|
#ifndef KPMCORE_LUKS_H
|
||||||
|
|
||||||
#define KPMCORE_LUKS_H
|
#define KPMCORE_LUKS_H
|
||||||
|
|
||||||
#include "util/libpartitionmanagerexport.h"
|
#include "util/libpartitionmanagerexport.h"
|
||||||
|
@ -43,7 +42,7 @@ public:
|
||||||
luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Type::Luks);
|
luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label, FileSystem::Type t = FileSystem::Type::Luks);
|
||||||
~luks() override;
|
~luks() override;
|
||||||
|
|
||||||
enum KeyLocation {
|
enum class KeyLocation {
|
||||||
unknown,
|
unknown,
|
||||||
dmcrypt,
|
dmcrypt,
|
||||||
keyring
|
keyring
|
||||||
|
@ -225,7 +224,7 @@ protected:
|
||||||
qint64 m_PayloadSize;
|
qint64 m_PayloadSize;
|
||||||
QString m_outerUuid;
|
QString m_outerUuid;
|
||||||
|
|
||||||
luks::KeyLocation m_KeyLocation = unknown;
|
luks::KeyLocation m_KeyLocation = KeyLocation::unknown;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ bool luks2::resize(Report& report, const QString& deviceNode, qint64 newLength)
|
||||||
ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"), { QStringLiteral("resize"), mapperName() });
|
ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"), { QStringLiteral("resize"), mapperName() });
|
||||||
report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
|
report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
|
||||||
|
|
||||||
if (m_KeyLocation == keyring) {
|
if (m_KeyLocation == KeyLocation::keyring) {
|
||||||
if (m_passphrase.isEmpty())
|
if (m_passphrase.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
cryptResizeCmd.write(m_passphrase.toLocal8Bit() + '\n');
|
cryptResizeCmd.write(m_passphrase.toLocal8Bit() + '\n');
|
||||||
|
@ -110,7 +110,7 @@ bool luks2::resize(Report& report, const QString& deviceNode, qint64 newLength)
|
||||||
{ QStringLiteral("--size"), QString::number(m_PayloadSize / 512), // FIXME, LUKS2 can have different sector sizes
|
{ QStringLiteral("--size"), QString::number(m_PayloadSize / 512), // FIXME, LUKS2 can have different sector sizes
|
||||||
QStringLiteral("resize"), mapperName() });
|
QStringLiteral("resize"), mapperName() });
|
||||||
report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
|
report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
|
||||||
if (m_KeyLocation == keyring) {
|
if (m_KeyLocation == KeyLocation::keyring) {
|
||||||
if (m_passphrase.isEmpty())
|
if (m_passphrase.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
cryptResizeCmd.write(m_passphrase.toLocal8Bit() + '\n');
|
cryptResizeCmd.write(m_passphrase.toLocal8Bit() + '\n');
|
||||||
|
@ -126,16 +126,16 @@ bool luks2::resize(Report& report, const QString& deviceNode, qint64 newLength)
|
||||||
|
|
||||||
luks::KeyLocation luks2::keyLocation()
|
luks::KeyLocation luks2::keyLocation()
|
||||||
{
|
{
|
||||||
m_KeyLocation = unknown;
|
m_KeyLocation = KeyLocation::unknown;
|
||||||
ExternalCommand statusCmd(QStringLiteral("cryptsetup"), { QStringLiteral("status"), mapperName() });
|
ExternalCommand statusCmd(QStringLiteral("cryptsetup"), { QStringLiteral("status"), mapperName() });
|
||||||
if (statusCmd.run(-1) && statusCmd.exitCode() == 0) {
|
if (statusCmd.run(-1) && statusCmd.exitCode() == 0) {
|
||||||
QRegularExpression re(QStringLiteral("key location:\\s+(\\w+)"));
|
QRegularExpression re(QStringLiteral("key location:\\s+(\\w+)"));
|
||||||
QRegularExpressionMatch rem = re.match(statusCmd.output());
|
QRegularExpressionMatch rem = re.match(statusCmd.output());
|
||||||
if (rem.hasMatch()) {
|
if (rem.hasMatch()) {
|
||||||
if (rem.captured(1) == QStringLiteral("keyring"))
|
if (rem.captured(1) == QStringLiteral("keyring"))
|
||||||
m_KeyLocation = keyring;
|
m_KeyLocation = KeyLocation::keyring;
|
||||||
else if (rem.captured(1) == QStringLiteral("dm-crypt"))
|
else if (rem.captured(1) == QStringLiteral("dm-crypt"))
|
||||||
m_KeyLocation = dmcrypt;
|
m_KeyLocation = KeyLocation::dmcrypt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ FileSystem::SupportTool lvm2_pv::supportToolName() const
|
||||||
|
|
||||||
qint64 lvm2_pv::maxCapacity() const
|
qint64 lvm2_pv::maxCapacity() const
|
||||||
{
|
{
|
||||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 lvm2_pv::readUsedCapacity(const QString& deviceNode) const
|
qint64 lvm2_pv::readUsedCapacity(const QString& deviceNode) const
|
||||||
|
|
|
@ -96,12 +96,12 @@ FileSystem::SupportTool nilfs2::supportToolName() const
|
||||||
|
|
||||||
qint64 nilfs2::minCapacity() const
|
qint64 nilfs2::minCapacity() const
|
||||||
{
|
{
|
||||||
return 128 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 128 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 nilfs2::maxCapacity() const
|
qint64 nilfs2::maxCapacity() const
|
||||||
{
|
{
|
||||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int nilfs2::maxLabelLength() const
|
int nilfs2::maxLabelLength() const
|
||||||
|
|
|
@ -91,12 +91,12 @@ FileSystem::SupportTool ntfs::supportToolName() const
|
||||||
|
|
||||||
qint64 ntfs::minCapacity() const
|
qint64 ntfs::minCapacity() const
|
||||||
{
|
{
|
||||||
return 2 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 2 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 ntfs::maxCapacity() const
|
qint64 ntfs::maxCapacity() const
|
||||||
{
|
{
|
||||||
return 256 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB);
|
return 256 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ntfs::maxLabelLength() const
|
int ntfs::maxLabelLength() const
|
||||||
|
|
|
@ -89,12 +89,12 @@ FileSystem::SupportTool ocfs2::supportToolName() const
|
||||||
|
|
||||||
qint64 ocfs2::minCapacity() const
|
qint64 ocfs2::minCapacity() const
|
||||||
{
|
{
|
||||||
return 14000 * Capacity::unitFactor(Capacity::Byte, Capacity::KiB);
|
return 14000 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::KiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 ocfs2::maxCapacity() const
|
qint64 ocfs2::maxCapacity() const
|
||||||
{
|
{
|
||||||
return 4 * Capacity::unitFactor(Capacity::Byte, Capacity::PiB);
|
return 4 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::PiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 ocfs2::readUsedCapacity(const QString& deviceNode) const
|
qint64 ocfs2::readUsedCapacity(const QString& deviceNode) const
|
||||||
|
|
|
@ -75,7 +75,7 @@ qint64 reiser4::maxCapacity() const
|
||||||
{
|
{
|
||||||
// looks like it's actually unknown. see
|
// looks like it's actually unknown. see
|
||||||
// http://en.wikipedia.org/wiki/Comparison_of_file_systems
|
// http://en.wikipedia.org/wiki/Comparison_of_file_systems
|
||||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int reiser4::maxLabelLength() const
|
int reiser4::maxLabelLength() const
|
||||||
|
|
|
@ -85,12 +85,12 @@ FileSystem::SupportTool reiserfs::supportToolName() const
|
||||||
|
|
||||||
qint64 reiserfs::minCapacity() const
|
qint64 reiserfs::minCapacity() const
|
||||||
{
|
{
|
||||||
return 32 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 32 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 reiserfs::maxCapacity() const
|
qint64 reiserfs::maxCapacity() const
|
||||||
{
|
{
|
||||||
return 16 * Capacity::unitFactor(Capacity::Byte, Capacity::TiB) - Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 16 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::TiB) - Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int reiserfs::maxLabelLength() const
|
int reiserfs::maxLabelLength() const
|
||||||
|
|
|
@ -83,12 +83,12 @@ FileSystem::SupportTool xfs::supportToolName() const
|
||||||
|
|
||||||
qint64 xfs::minCapacity() const
|
qint64 xfs::minCapacity() const
|
||||||
{
|
{
|
||||||
return 32 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 32 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 xfs::maxCapacity() const
|
qint64 xfs::maxCapacity() const
|
||||||
{
|
{
|
||||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
int xfs::maxLabelLength() const
|
int xfs::maxLabelLength() const
|
||||||
|
|
|
@ -77,12 +77,12 @@ FileSystem::SupportTool zfs::supportToolName() const
|
||||||
|
|
||||||
qint64 zfs::minCapacity() const
|
qint64 zfs::minCapacity() const
|
||||||
{
|
{
|
||||||
return 64 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
return 64 * Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::MiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 zfs::maxCapacity() const
|
qint64 zfs::maxCapacity() const
|
||||||
{
|
{
|
||||||
return Capacity::unitFactor(Capacity::Byte, Capacity::EiB);
|
return Capacity::unitFactor(Capacity::Unit::Byte, Capacity::Unit::EiB);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool zfs::remove(Report& report, const QString& deviceNode) const
|
bool zfs::remove(Report& report, const QString& deviceNode) const
|
||||||
|
|
|
@ -88,7 +88,7 @@ bool ResizeFileSystemJob::run(Report& parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
case FileSystem::cmdSupportFileSystem: {
|
case FileSystem::cmdSupportFileSystem: {
|
||||||
const qint64 newLengthInByte = Capacity(newLength() * device().logicalSize()).toInt(Capacity::Byte);
|
const qint64 newLengthInByte = Capacity(newLength() * device().logicalSize()).toInt(Capacity::Unit::Byte);
|
||||||
if (partition().isMounted())
|
if (partition().isMounted())
|
||||||
rval = partition().fileSystem().resizeOnline(*report, partition().deviceNode(), partition().mountPoint(), newLengthInByte);
|
rval = partition().fileSystem().resizeOnline(*report, partition().deviceNode(), partition().mountPoint(), newLengthInByte);
|
||||||
else
|
else
|
||||||
|
|
|
@ -43,9 +43,9 @@ bool ResizeVolumeGroupJob::run(Report& parent)
|
||||||
|
|
||||||
for (const auto &p : partList()) {
|
for (const auto &p : partList()) {
|
||||||
const QString deviceNode = p->roles().has(PartitionRole::Luks) ? static_cast<const FS::luks*>(&p->fileSystem())->mapperName() : p->partitionPath();
|
const QString deviceNode = p->roles().has(PartitionRole::Luks) ? static_cast<const FS::luks*>(&p->fileSystem())->mapperName() : p->partitionPath();
|
||||||
if (type() == ResizeVolumeGroupJob::Grow)
|
if (type() == ResizeVolumeGroupJob::Type::Grow)
|
||||||
rval = LvmDevice::insertPV(*report, device(), deviceNode);
|
rval = LvmDevice::insertPV(*report, device(), deviceNode);
|
||||||
else if (type() == ResizeVolumeGroupJob::Shrink)
|
else if (type() == ResizeVolumeGroupJob::Type::Shrink)
|
||||||
rval = LvmDevice::removePV(*report, device(), deviceNode);
|
rval = LvmDevice::removePV(*report, device(), deviceNode);
|
||||||
|
|
||||||
if (rval == false)
|
if (rval == false)
|
||||||
|
@ -66,10 +66,10 @@ QString ResizeVolumeGroupJob::description() const
|
||||||
partitionList.chop(2);
|
partitionList.chop(2);
|
||||||
const qint32 count = partList().count();
|
const qint32 count = partList().count();
|
||||||
|
|
||||||
if (type() == ResizeVolumeGroupJob::Grow) {
|
if (type() == ResizeVolumeGroupJob::Type::Grow) {
|
||||||
return xi18ncp("@info/plain", "Adding LVM Physical Volume %2 to %3.", "Adding LVM Physical Volumes %2 to %3.", count, partitionList, device().name());
|
return xi18ncp("@info/plain", "Adding LVM Physical Volume %2 to %3.", "Adding LVM Physical Volumes %2 to %3.", count, partitionList, device().name());
|
||||||
}
|
}
|
||||||
if (type() == ResizeVolumeGroupJob::Shrink) {
|
if (type() == ResizeVolumeGroupJob::Type::Shrink) {
|
||||||
return xi18ncp("@info/plain", "Removing LVM Physical Volume %2 from %3.", "Removing LVM Physical Volumes %2 from %3.", count, partitionList, device().name());
|
return xi18ncp("@info/plain", "Removing LVM Physical Volume %2 from %3.", "Removing LVM Physical Volumes %2 from %3.", count, partitionList, device().name());
|
||||||
}
|
}
|
||||||
return xi18nc("@info/plain", "Resizing Volume Group %1 to %2.", device().name(), partitionList);
|
return xi18nc("@info/plain", "Resizing Volume Group %1 to %2.", device().name(), partitionList);
|
||||||
|
|
|
@ -31,9 +31,9 @@ class ResizeVolumeGroupJob : public Job
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum class Type {
|
||||||
Grow = 0,
|
Grow,
|
||||||
Shrink = 1
|
Shrink
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -45,13 +45,13 @@ DeleteOperation::DeleteOperation(Device& d, Partition* p, ShredAction shred) :
|
||||||
m_DeletePartitionJob(new DeletePartitionJob(targetDevice(), deletedPartition()))
|
m_DeletePartitionJob(new DeletePartitionJob(targetDevice(), deletedPartition()))
|
||||||
{
|
{
|
||||||
switch (shredAction()) {
|
switch (shredAction()) {
|
||||||
case NoShred:
|
case ShredAction::NoShred:
|
||||||
m_DeleteFileSystemJob = static_cast<Job*>(new DeleteFileSystemJob(targetDevice(), deletedPartition()));
|
m_DeleteFileSystemJob = static_cast<Job*>(new DeleteFileSystemJob(targetDevice(), deletedPartition()));
|
||||||
break;
|
break;
|
||||||
case ZeroShred:
|
case ShredAction::ZeroShred:
|
||||||
m_DeleteFileSystemJob = static_cast<Job*>(new ShredFileSystemJob(targetDevice(), deletedPartition(), false));
|
m_DeleteFileSystemJob = static_cast<Job*>(new ShredFileSystemJob(targetDevice(), deletedPartition(), false));
|
||||||
break;
|
break;
|
||||||
case RandomShred:
|
case ShredAction::RandomShred:
|
||||||
m_DeleteFileSystemJob = static_cast<Job*>(new ShredFileSystemJob(targetDevice(), deletedPartition(), true));
|
m_DeleteFileSystemJob = static_cast<Job*>(new ShredFileSystemJob(targetDevice(), deletedPartition(), true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ void DeleteOperation::undo()
|
||||||
|
|
||||||
QString DeleteOperation::description() const
|
QString DeleteOperation::description() const
|
||||||
{
|
{
|
||||||
if (shredAction() != NoShred)
|
if (shredAction() != ShredAction::NoShred)
|
||||||
return xi18nc("@info:status", "Shred partition <filename>%1</filename> (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name());
|
return xi18nc("@info:status", "Shred partition <filename>%1</filename> (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name());
|
||||||
else
|
else
|
||||||
return xi18nc("@info:status", "Delete partition <filename>%1</filename> (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name());
|
return xi18nc("@info:status", "Delete partition <filename>%1</filename> (%2, %3)", deletedPartition().deviceNode(), Capacity::formatByteSize(deletedPartition().capacity()), deletedPartition().fileSystem().name());
|
||||||
|
|
|
@ -43,18 +43,18 @@ class LIBKPMCORE_EXPORT DeleteOperation : public Operation
|
||||||
Q_DISABLE_COPY(DeleteOperation)
|
Q_DISABLE_COPY(DeleteOperation)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum ShredAction {
|
enum class ShredAction {
|
||||||
NoShred = 0,
|
NoShred,
|
||||||
ZeroShred,
|
ZeroShred,
|
||||||
RandomShred
|
RandomShred
|
||||||
};
|
};
|
||||||
|
|
||||||
DeleteOperation(Device& d, Partition* p, ShredAction shred = NoShred);
|
DeleteOperation(Device& d, Partition* p, ShredAction shred = ShredAction::NoShred);
|
||||||
~DeleteOperation();
|
~DeleteOperation();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString iconName() const override {
|
QString iconName() const override {
|
||||||
return shredAction() == NoShred ?
|
return shredAction() == ShredAction::NoShred ?
|
||||||
QStringLiteral("edit-delete") :
|
QStringLiteral("edit-delete") :
|
||||||
QStringLiteral("edit-delete-shred");
|
QStringLiteral("edit-delete-shred");
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,12 +89,12 @@ ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& d, const QVect
|
||||||
// *DO NOTHING*
|
// *DO NOTHING*
|
||||||
} else {
|
} else {
|
||||||
if (!toInsertList.isEmpty()) {
|
if (!toInsertList.isEmpty()) {
|
||||||
m_GrowVolumeGroupJob = new ResizeVolumeGroupJob(d, toInsertList, ResizeVolumeGroupJob::Grow);
|
m_GrowVolumeGroupJob = new ResizeVolumeGroupJob(d, toInsertList, ResizeVolumeGroupJob::Type::Grow);
|
||||||
addJob(growVolumeGroupJob());
|
addJob(growVolumeGroupJob());
|
||||||
}
|
}
|
||||||
if (!toRemoveList.isEmpty()) {
|
if (!toRemoveList.isEmpty()) {
|
||||||
m_MovePhysicalVolumeJob = new MovePhysicalVolumeJob(d, toRemoveList);
|
m_MovePhysicalVolumeJob = new MovePhysicalVolumeJob(d, toRemoveList);
|
||||||
m_ShrinkVolumeGroupJob = new ResizeVolumeGroupJob(d, toRemoveList, ResizeVolumeGroupJob::Shrink);
|
m_ShrinkVolumeGroupJob = new ResizeVolumeGroupJob(d, toRemoveList, ResizeVolumeGroupJob::Type::Shrink);
|
||||||
addJob(movePhysicalVolumeJob());
|
addJob(movePhysicalVolumeJob());
|
||||||
addJob(shrinkvolumegroupjob());
|
addJob(shrinkvolumegroupjob());
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,7 +135,7 @@ Device* SfdiskBackend::scanDevice(const QString& deviceNode)
|
||||||
modelName = modelName.left(modelName.length() - 1);
|
modelName = modelName.left(modelName.length() - 1);
|
||||||
qint64 deviceSize = sizeCommand.output().trimmed().toLongLong();
|
qint64 deviceSize = sizeCommand.output().trimmed().toLongLong();
|
||||||
|
|
||||||
Log(Log::information) << xi18nc("@info:status", "Device found: %1", modelName);
|
Log(Log::Level::information) << xi18nc("@info:status", "Device found: %1", modelName);
|
||||||
int logicalSectorSize = sizeCommand2.output().trimmed().toLongLong();
|
int logicalSectorSize = sizeCommand2.output().trimmed().toLongLong();
|
||||||
DiskDevice* d = new DiskDevice(modelName, deviceNode, 255, 63, deviceSize / logicalSectorSize / 255 / 63, logicalSectorSize);
|
DiskDevice* d = new DiskDevice(modelName, deviceNode, 255, 63, deviceSize / logicalSectorSize / 255 / 63, logicalSectorSize);
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,9 @@ Capacity::Capacity(const Partition& p, Type t) :
|
||||||
m_Size(-1)
|
m_Size(-1)
|
||||||
{
|
{
|
||||||
switch (t) {
|
switch (t) {
|
||||||
case Used: m_Size = p.used(); break;
|
case Type::Used: m_Size = p.used(); break;
|
||||||
case Available: m_Size = p.available(); break;
|
case Type::Available: m_Size = p.available(); break;
|
||||||
case Total: m_Size = p.capacity();
|
case Type::Total: m_Size = p.capacity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ Capacity::Capacity(const Device& d) :
|
||||||
*/
|
*/
|
||||||
qint64 Capacity::toInt(Unit u) const
|
qint64 Capacity::toInt(Unit u) const
|
||||||
{
|
{
|
||||||
return static_cast<qint64>(m_Size / unitFactor(Byte, u));
|
return static_cast<qint64>(m_Size / unitFactor(Unit::Byte, u));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the Capacity as double converted to the given Unit.
|
/** Returns the Capacity as double converted to the given Unit.
|
||||||
|
@ -73,7 +73,7 @@ qint64 Capacity::toInt(Unit u) const
|
||||||
*/
|
*/
|
||||||
double Capacity::toDouble(Unit u) const
|
double Capacity::toDouble(Unit u) const
|
||||||
{
|
{
|
||||||
return static_cast<double>(m_Size) / unitFactor(Byte, u);
|
return static_cast<double>(m_Size) / unitFactor(Unit::Byte, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a factor to convert between two Units.
|
/** Returns a factor to convert between two Units.
|
||||||
|
@ -86,14 +86,14 @@ qint64 Capacity::unitFactor(Unit from, Unit to)
|
||||||
Q_ASSERT(from <= to);
|
Q_ASSERT(from <= to);
|
||||||
|
|
||||||
if (from > to) {
|
if (from > to) {
|
||||||
qWarning() << "from: " << from << ", to: " << to;
|
qWarning() << "from: " << static_cast<uint>(from) << ", to: " << static_cast<uint>(to);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 result = 1;
|
qint64 result = 1;
|
||||||
|
|
||||||
qint32 a = from;
|
qint32 a = static_cast<uint>(from);
|
||||||
qint32 b = to;
|
qint32 b = static_cast<uint>(to);
|
||||||
|
|
||||||
while (b-- > a)
|
while (b-- > a)
|
||||||
result *= 1024;
|
result *= 1024;
|
||||||
|
@ -122,7 +122,7 @@ QString Capacity::unitName(Unit u, qint64 val)
|
||||||
if (static_cast<quint32>(u) >= sizeof(unitNames) / sizeof(unitNames[0]))
|
if (static_cast<quint32>(u) >= sizeof(unitNames) / sizeof(unitNames[0]))
|
||||||
return xi18nc("@item:intext unit", "(unknown unit)");
|
return xi18nc("@item:intext unit", "(unknown unit)");
|
||||||
|
|
||||||
return unitNames[u];
|
return unitNames[static_cast<quint32>(u)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Determine if the capacity is valid.
|
/** Determine if the capacity is valid.
|
||||||
|
|
|
@ -36,16 +36,16 @@ class LIBKPMCORE_EXPORT Capacity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Units we can deal with */
|
/** Units we can deal with */
|
||||||
enum Unit { Byte, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB };
|
enum class Unit : uint { Byte, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB };
|
||||||
/** Type of capacity to print */
|
/** Type of capacity to print */
|
||||||
enum Type { Used, Available, Total };
|
enum class Type { Used, Available, Total };
|
||||||
/** Flags for printing */
|
/** Flags for printing */
|
||||||
enum Flag { NoFlags = 0, AppendUnit = 1, AppendBytes = 2 };
|
enum Flag { NoFlags = 0, AppendUnit = 1, AppendBytes = 2 };
|
||||||
Q_DECLARE_FLAGS(Flags, Flag)
|
Q_DECLARE_FLAGS(Flags, Flag)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Capacity(qint64 size);
|
explicit Capacity(qint64 size);
|
||||||
explicit Capacity(const Partition& p, Type t = Total);
|
explicit Capacity(const Partition& p, Type t = Type::Total);
|
||||||
Capacity(const Device& d);
|
Capacity(const Device& d);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -28,15 +28,15 @@
|
||||||
class LIBKPMCORE_EXPORT Log
|
class LIBKPMCORE_EXPORT Log
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Level {
|
enum class Level {
|
||||||
debug = 0,
|
debug,
|
||||||
information = 1,
|
information,
|
||||||
warning = 2,
|
warning,
|
||||||
error = 3
|
error,
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Log(Level lev = information) : ref(1), level(lev) {}
|
Log(Level lev = Level::information) : ref(1), level(lev) {}
|
||||||
~Log();
|
~Log();
|
||||||
Log(const Log& other) : ref(other.ref + 1), level(other.level) {}
|
Log(const Log& other) : ref(other.ref + 1), level(other.level) {}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ static bool testSmartStatus()
|
||||||
if (smart.serial() == QString())
|
if (smart.serial() == QString())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (smart.selfTestStatus())
|
if (smart.selfTestStatus() != SmartStatus::SelfTestStatus::Success)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!smart.isValid())
|
if (!smart.isValid())
|
||||||
|
|
Loading…
Reference in New Issue