Merge branch 'luks-decorator'
This commit is contained in:
commit
0ec83e4e32
|
@ -57,6 +57,7 @@ find_package(KF5 REQUIRED
|
|||
IconThemes
|
||||
KIO
|
||||
Service
|
||||
WidgetsAddons
|
||||
)
|
||||
|
||||
# use sane compile flags
|
||||
|
|
|
@ -45,6 +45,7 @@ target_link_libraries( kpmcore
|
|||
KF5::IconThemes
|
||||
KF5::KIOCore
|
||||
KF5::Service
|
||||
KF5::WidgetsAddons
|
||||
)
|
||||
|
||||
install(TARGETS kpmcore EXPORT KPMcoreTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
|
||||
|
|
|
@ -43,16 +43,16 @@ public:
|
|||
~CopySourceDevice();
|
||||
|
||||
public:
|
||||
virtual bool open();
|
||||
virtual qint32 sectorSize() const;
|
||||
virtual bool readSectors(void* buffer, qint64 readOffset, qint64 numSectors);
|
||||
virtual qint64 length() const;
|
||||
virtual bool overlaps(const CopyTarget& target) const;
|
||||
virtual bool open() override;
|
||||
virtual qint32 sectorSize() const override;
|
||||
virtual bool readSectors(void* buffer, qint64 readOffset, qint64 numSectors) override;
|
||||
virtual qint64 length() const override;
|
||||
virtual bool overlaps(const CopyTarget& target) const override;
|
||||
|
||||
virtual qint64 firstSector() const {
|
||||
virtual qint64 firstSector() const override {
|
||||
return m_FirstSector; /**< @return first sector to copying */
|
||||
}
|
||||
virtual qint64 lastSector() const {
|
||||
virtual qint64 lastSector() const override {
|
||||
return m_LastSector; /**< @return last sector to copy */
|
||||
}
|
||||
|
||||
|
|
|
@ -39,20 +39,20 @@ public:
|
|||
CopySourceFile(const QString& filename, qint32 sectorsize);
|
||||
|
||||
public:
|
||||
virtual bool open();
|
||||
virtual bool readSectors(void* buffer, qint64 readOffset, qint64 numSectors);
|
||||
virtual qint64 length() const;
|
||||
virtual bool open() override;
|
||||
virtual bool readSectors(void* buffer, qint64 readOffset, qint64 numSectors) override;
|
||||
virtual qint64 length() const override;
|
||||
|
||||
virtual qint32 sectorSize() const {
|
||||
virtual qint32 sectorSize() const override {
|
||||
return m_SectorSize; /**< @return the file's sector size */
|
||||
}
|
||||
virtual bool overlaps(const CopyTarget&) const {
|
||||
virtual bool overlaps(const CopyTarget&) const override {
|
||||
return false; /**< @return false for file */
|
||||
}
|
||||
virtual qint64 firstSector() const {
|
||||
virtual qint64 firstSector() const override {
|
||||
return 0; /**< @return 0 for file */
|
||||
}
|
||||
virtual qint64 lastSector() const {
|
||||
virtual qint64 lastSector() const override {
|
||||
return length(); /**< @return equal to length for file. @see length() */
|
||||
}
|
||||
|
||||
|
|
|
@ -37,20 +37,20 @@ public:
|
|||
CopySourceShred(qint64 size, qint32 sectorsize, bool randomShred);
|
||||
|
||||
public:
|
||||
virtual bool open();
|
||||
virtual bool readSectors(void* buffer, qint64 readOffset, qint64 numSectors);
|
||||
virtual qint64 length() const;
|
||||
virtual bool open() override;
|
||||
virtual bool readSectors(void* buffer, qint64 readOffset, qint64 numSectors) override;
|
||||
virtual qint64 length() const override;
|
||||
|
||||
virtual qint32 sectorSize() const {
|
||||
virtual qint32 sectorSize() const override {
|
||||
return m_SectorSize; /**< @return the file's sector size */
|
||||
}
|
||||
virtual bool overlaps(const CopyTarget&) const {
|
||||
virtual bool overlaps(const CopyTarget&) const override {
|
||||
return false; /**< @return false for shred source */
|
||||
}
|
||||
virtual qint64 firstSector() const {
|
||||
virtual qint64 firstSector() const override {
|
||||
return 0; /**< @return 0 for shred source */
|
||||
}
|
||||
virtual qint64 lastSector() const {
|
||||
virtual qint64 lastSector() const override {
|
||||
return length(); /**< @return equal to length for shred source. @see length() */
|
||||
}
|
||||
|
||||
|
|
|
@ -45,13 +45,13 @@ public:
|
|||
~CopyTargetDevice();
|
||||
|
||||
public:
|
||||
virtual bool open();
|
||||
virtual qint32 sectorSize() const;
|
||||
virtual bool writeSectors(void* buffer, qint64 writeOffset, qint64 numSectors);
|
||||
virtual qint64 firstSector() const {
|
||||
virtual bool open() override;
|
||||
virtual qint32 sectorSize() const override;
|
||||
virtual bool writeSectors(void* buffer, qint64 writeOffset, qint64 numSectors) override;
|
||||
virtual qint64 firstSector() const override {
|
||||
return m_FirstSector; /**< @return the first sector to write to */
|
||||
}
|
||||
virtual qint64 lastSector() const {
|
||||
virtual qint64 lastSector() const override {
|
||||
return m_LastSector; /**< @return the last sector to write to */
|
||||
}
|
||||
|
||||
|
|
|
@ -39,16 +39,16 @@ public:
|
|||
CopyTargetFile(const QString& filename, qint32 sectorsize);
|
||||
|
||||
public:
|
||||
virtual bool open();
|
||||
virtual bool writeSectors(void* buffer, qint64 writeOffset, qint64 numSectors);
|
||||
virtual bool open() override;
|
||||
virtual bool writeSectors(void* buffer, qint64 writeOffset, qint64 numSectors) override;
|
||||
|
||||
virtual qint32 sectorSize() const {
|
||||
virtual qint32 sectorSize() const override {
|
||||
return m_SectorSize; /**< @return the file's sector size */
|
||||
}
|
||||
virtual qint64 firstSector() const {
|
||||
virtual qint64 firstSector() const override {
|
||||
return 0; /**< @return always 0 for a file */
|
||||
}
|
||||
virtual qint64 lastSector() const {
|
||||
virtual qint64 lastSector() const override {
|
||||
return sectorsWritten(); /**< @return the number of sectors written so far */
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ static qint32 getPhysicalSectorSize(const QString& device_node)
|
|||
|
||||
if (f.open(QIODevice::ReadOnly)) {
|
||||
QByteArray a = f.readLine();
|
||||
return a.simplified().toInt();
|
||||
return a.trimmed().toInt();
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
|
|
@ -46,7 +46,7 @@ Q_SIGNALS:
|
|||
void progress(const QString& device_node, int progress);
|
||||
|
||||
protected:
|
||||
virtual void run();
|
||||
virtual void run() override;
|
||||
OperationStack& operationStack() {
|
||||
return m_OperationStack;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2015 by Teo Mrnjavac <teo@kde.org> *
|
||||
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
|
@ -294,7 +295,7 @@ bool Partition::mount(Report& report)
|
|||
bool success = false;
|
||||
|
||||
if (fileSystem().canMount(deviceNode()))
|
||||
success = fileSystem().mount(deviceNode());
|
||||
success = fileSystem().mount(deviceNode(), mountPoint());
|
||||
else {
|
||||
ExternalCommand mountCmd(report, QStringLiteral("mount"), QStringList() << QStringLiteral("-v") << deviceNode() << mountPoint());
|
||||
if (mountCmd.run() && mountCmd.exitCode() == 0)
|
||||
|
@ -323,7 +324,11 @@ bool Partition::unmount(Report& report)
|
|||
setMountPoint(QString());
|
||||
} else {
|
||||
|
||||
ExternalCommand umountCmd(report, QStringLiteral("umount"), QStringList() << QStringLiteral("-v") << deviceNode());
|
||||
ExternalCommand umountCmd(report,
|
||||
QStringLiteral("umount"),
|
||||
{ QStringLiteral("-v"),
|
||||
QStringLiteral("-A"),
|
||||
deviceNode() });
|
||||
if (!umountCmd.run() || umountCmd.exitCode() != 0)
|
||||
success = false;
|
||||
}
|
||||
|
|
|
@ -124,21 +124,21 @@ public:
|
|||
return m_Number; /**< @return the Partition's device number, e.g. 7 for /dev/sdd7 */
|
||||
}
|
||||
|
||||
bool isRoot() const {
|
||||
bool isRoot() const override {
|
||||
return false; /**< @return always false for Partition */
|
||||
}
|
||||
|
||||
PartitionNode* parent() {
|
||||
PartitionNode* parent() override {
|
||||
return m_Parent; /**< @return the Partition's parent PartitionNode */
|
||||
}
|
||||
const PartitionNode* parent() const {
|
||||
const PartitionNode* parent() const override {
|
||||
return m_Parent; /**< @return the Partition's parent PartitionNode */
|
||||
}
|
||||
|
||||
Partitions& children() {
|
||||
Partitions& children() override {
|
||||
return m_Children; /**< @return the Partition's children. empty for non-extended. */
|
||||
}
|
||||
const Partitions& children() const {
|
||||
const Partitions& children() const override {
|
||||
return m_Children; /**< @return the Partition's children. empty for non-extended. */
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
void append(Partition* p) {
|
||||
void append(Partition* p) override {
|
||||
m_Children.append(p);
|
||||
}
|
||||
void setDevicePath(const QString& s) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* Copyright (C) 2016 by Teo Mrnjavac <teo@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -36,5 +37,8 @@ QString PartitionRole::toString() const
|
|||
if (roles() & Primary)
|
||||
return i18nc("@item partition role", "primary");
|
||||
|
||||
if (roles() & Luks)
|
||||
return i18nc("@item partition role", "LUKS");
|
||||
|
||||
return i18nc("@item partition role", "none");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2016 by Teo Mrnjavac <teo@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -41,6 +42,7 @@ public:
|
|||
Extended = 2, /**< Extended */
|
||||
Logical = 4, /**< Logical inside an extended */
|
||||
Unallocated = 8, /**< No real Partition, just unallocated space */
|
||||
Luks = 16, /**< Encrypted partition with LUKS key management */
|
||||
|
||||
Any = 255 /**< In case we're looking for a Partition with a PartitionRole, any will do */
|
||||
};
|
||||
|
|
|
@ -97,30 +97,30 @@ public:
|
|||
~PartitionTable();
|
||||
|
||||
public:
|
||||
PartitionNode* parent() {
|
||||
PartitionNode* parent() override {
|
||||
return nullptr; /**< @return always nullptr for PartitionTable */
|
||||
}
|
||||
const PartitionNode* parent() const {
|
||||
const PartitionNode* parent() const override {
|
||||
return nullptr; /**< @return always nullptr for PartitionTable */
|
||||
}
|
||||
|
||||
bool isRoot() const {
|
||||
bool isRoot() const override {
|
||||
return true; /**< @return always true for PartitionTable */
|
||||
}
|
||||
bool isReadOnly() const {
|
||||
return tableTypeIsReadOnly(type()); /**< @return true if the PartitionTable is read only */
|
||||
}
|
||||
|
||||
Partitions& children() {
|
||||
Partitions& children() override {
|
||||
return m_Children; /**< @return the children in this PartitionTable */
|
||||
}
|
||||
const Partitions& children() const {
|
||||
const Partitions& children() const override {
|
||||
return m_Children; /**< @return the children in this PartitionTable */
|
||||
}
|
||||
|
||||
void setType(const Device& d, TableType t);
|
||||
|
||||
void append(Partition* partition);
|
||||
void append(Partition* partition) override;
|
||||
|
||||
qint64 freeSectorsBefore(const Partition& p) const;
|
||||
qint64 freeSectorsAfter(const Partition& p) const;
|
||||
|
|
|
@ -91,7 +91,7 @@ FileSystem::SupportTool btrfs::supportToolName() const
|
|||
|
||||
qint64 btrfs::minCapacity() const
|
||||
{
|
||||
return 40 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
return 100 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
}
|
||||
|
||||
qint64 btrfs::maxCapacity() const
|
||||
|
@ -145,7 +145,8 @@ bool btrfs::resize(Report& report, const QString& deviceNode, qint64 length) con
|
|||
{ QStringLiteral("--verbose"), QStringLiteral("--types"), QStringLiteral("btrfs"), deviceNode, tempDir.path() });
|
||||
|
||||
if (mountCmd.run(-1) && mountCmd.exitCode() == 0) {
|
||||
ExternalCommand resizeCmd(report, QStringLiteral("btrfs"), { QStringLiteral("filesystem"), QStringLiteral("resize"), QString::number(length), tempDir.path() });
|
||||
QString len = length == -1 ? QStringLiteral("max") : QString::number(length);
|
||||
ExternalCommand resizeCmd(report, QStringLiteral("btrfs"), { QStringLiteral("filesystem"), QStringLiteral("resize"), len, tempDir.path() });
|
||||
|
||||
if (resizeCmd.run(-1) && resizeCmd.exitCode() == 0)
|
||||
rval = true;
|
||||
|
|
|
@ -43,55 +43,55 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 minCapacity() const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 minCapacity() const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -42,55 +42,55 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
// virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
// virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
// virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
// virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
// virtual qint64 minCapacity() const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -137,7 +137,9 @@ bool ext2::create(Report& report, const QString& deviceNode) const
|
|||
bool ext2::resize(Report& report, const QString& deviceNode, qint64 length) const
|
||||
{
|
||||
const QString len = QString::number(length / 512) + QStringLiteral("s");
|
||||
ExternalCommand cmd(report, QStringLiteral("resize2fs"), { deviceNode, len });
|
||||
const QStringList args = length == -1 ? QStringList() << deviceNode : QStringList() << deviceNode << len;
|
||||
|
||||
ExternalCommand cmd(report, QStringLiteral("resize2fs"), args);
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,54 +42,54 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -44,8 +44,8 @@ public:
|
|||
|
||||
public:
|
||||
static void init() {}
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -44,8 +44,8 @@ public:
|
|||
|
||||
public:
|
||||
static void init() {}
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -45,22 +45,22 @@ public:
|
|||
public:
|
||||
static void init() {}
|
||||
|
||||
virtual bool create(Report&, const QString&) const;
|
||||
virtual bool create(Report&, const QString&) const override;
|
||||
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
|
||||
virtual bool supportToolFound() const {
|
||||
virtual bool supportToolFound() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,56 +42,56 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
// virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
// virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
// virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
// virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
// virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
// virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
// virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
// virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
// virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
// virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 minCapacity() const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 minCapacity() const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -42,54 +42,54 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 minCapacity() const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 minCapacity() const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -45,11 +45,11 @@ public:
|
|||
public:
|
||||
static void init() {}
|
||||
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual qint64 minCapacity() const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 minCapacity() const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2012 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2015 by Teo Mrnjavac <teo@kde.org> *
|
||||
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
|
@ -22,8 +23,10 @@
|
|||
#include "util/capacity.h"
|
||||
|
||||
#include <blkid/blkid.h>
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
const std::array< QColor, FileSystem::__lastType > FileSystem::defaultColorCode =
|
||||
{
|
||||
|
@ -105,6 +108,61 @@ static QString readBlkIdValue(const QString& deviceNode, const QString& tag)
|
|||
return rval;
|
||||
}
|
||||
|
||||
FileSystem::Type FileSystem::detectFileSystem(const QString& partitionPath)
|
||||
{
|
||||
FileSystem::Type rval = FileSystem::Unknown;
|
||||
|
||||
blkid_cache cache;
|
||||
if (blkid_get_cache(&cache, nullptr) == 0) {
|
||||
blkid_dev dev;
|
||||
|
||||
if ((dev = blkid_get_dev(cache,
|
||||
partitionPath.toLocal8Bit().constData(),
|
||||
BLKID_DEV_NORMAL)) != nullptr) {
|
||||
QString s = QString::fromUtf8(blkid_get_tag_value(cache,
|
||||
"TYPE",
|
||||
partitionPath.toLocal8Bit().constData()));
|
||||
|
||||
if (s == QStringLiteral("ext2")) rval = FileSystem::Ext2;
|
||||
else if (s == QStringLiteral("ext3")) rval = FileSystem::Ext3;
|
||||
else if (s.startsWith(QStringLiteral("ext4"))) rval = FileSystem::Ext4;
|
||||
else if (s == QStringLiteral("swap")) rval = FileSystem::LinuxSwap;
|
||||
else if (s == QStringLiteral("ntfs")) rval = FileSystem::Ntfs;
|
||||
else if (s == QStringLiteral("reiserfs")) rval = FileSystem::ReiserFS;
|
||||
else if (s == QStringLiteral("reiser4")) rval = FileSystem::Reiser4;
|
||||
else if (s == QStringLiteral("xfs")) rval = FileSystem::Xfs;
|
||||
else if (s == QStringLiteral("jfs")) rval = FileSystem::Jfs;
|
||||
else if (s == QStringLiteral("hfs")) rval = FileSystem::Hfs;
|
||||
else if (s == QStringLiteral("hfsplus")) rval = FileSystem::HfsPlus;
|
||||
else if (s == QStringLiteral("ufs")) rval = FileSystem::Ufs;
|
||||
else if (s == QStringLiteral("vfat")) {
|
||||
// libblkid uses SEC_TYPE to distinguish between FAT16 and FAT32
|
||||
QString st = QString::fromUtf8(blkid_get_tag_value(cache,
|
||||
"SEC_TYPE",
|
||||
partitionPath.toLocal8Bit().constData()));
|
||||
if (st == QStringLiteral("msdos"))
|
||||
rval = FileSystem::Fat16;
|
||||
else
|
||||
rval = FileSystem::Fat32;
|
||||
} else if (s == QStringLiteral("btrfs")) rval = FileSystem::Btrfs;
|
||||
else if (s == QStringLiteral("ocfs2")) rval = FileSystem::Ocfs2;
|
||||
else if (s == QStringLiteral("zfs_member")) rval = FileSystem::Zfs;
|
||||
else if (s == QStringLiteral("hpfs")) rval = FileSystem::Hpfs;
|
||||
else if (s == QStringLiteral("crypto_LUKS")) rval = FileSystem::Luks;
|
||||
else if (s == QStringLiteral("exfat")) rval = FileSystem::Exfat;
|
||||
else if (s == QStringLiteral("nilfs2")) rval = FileSystem::Nilfs2;
|
||||
else if (s == QStringLiteral("LVM2_member")) rval = FileSystem::Lvm2_PV;
|
||||
else if (s == QStringLiteral("f2fs")) rval = FileSystem::F2fs;
|
||||
else
|
||||
qWarning() << "blkid: unknown file system type " << s << " on " << partitionPath;
|
||||
}
|
||||
|
||||
blkid_put_cache(cache);
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
/** Reads the label for this FileSystem
|
||||
@param deviceNode the device node for the Partition the FileSystem is on
|
||||
@return the FileSystem label or an empty string in case of error
|
||||
|
@ -127,7 +185,7 @@ bool FileSystem::create(Report& report, const QString& deviceNode) const
|
|||
return true;
|
||||
}
|
||||
|
||||
/** Resized a FileSystem to a given new length
|
||||
/** Resize a FileSystem to a given new length
|
||||
@param report Report to write status information to
|
||||
@param deviceNode the device node for the Partition the FileSystem is on
|
||||
@param newLength the new length for the FileSystem in bytes
|
||||
|
@ -387,8 +445,9 @@ void FileSystem::move(qint64 newStartSector)
|
|||
@param mountPoint the mount point to mount the FileSystem on
|
||||
@return true on success
|
||||
*/
|
||||
bool FileSystem::mount(const QString& mountPoint)
|
||||
bool FileSystem::mount(const QString &deviceNode, const QString &mountPoint)
|
||||
{
|
||||
Q_UNUSED(deviceNode);
|
||||
Q_UNUSED(mountPoint);
|
||||
|
||||
return false;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2012 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2015 by Teo Mrnjavac <teo@kde.org> *
|
||||
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
|
@ -172,6 +173,7 @@ public:
|
|||
static QString nameForType(FileSystem::Type t);
|
||||
static QList<FileSystem::Type> types();
|
||||
static FileSystem::Type typeForName(const QString& s);
|
||||
static FileSystem::Type detectFileSystem(const QString& partitionPath);
|
||||
|
||||
virtual bool canMount(const QString&) const {
|
||||
return false; /**< @return true if this FileSystem can be mounted */
|
||||
|
@ -183,8 +185,8 @@ public:
|
|||
virtual QString mountTitle() const;
|
||||
virtual QString unmountTitle() const;
|
||||
|
||||
virtual bool mount(const QString& mountPoint);
|
||||
virtual bool unmount(const QString& mountPoint);
|
||||
virtual bool mount(const QString& deviceNode, const QString& mountPoint);
|
||||
virtual bool unmount(const QString& deviceNode);
|
||||
|
||||
qint64 firstSector() const {
|
||||
return m_FirstSector; /**< @return the FileSystem's first sector */
|
||||
|
|
28
src/fs/hfs.h
28
src/fs/hfs.h
|
@ -42,38 +42,38 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -42,31 +42,31 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -42,45 +42,45 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual bool supportToolFound() const {
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual bool supportToolFound() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
38
src/fs/jfs.h
38
src/fs/jfs.h
|
@ -42,45 +42,45 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
|
||||
virtual qint64 minCapacity() const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 minCapacity() const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -83,6 +83,7 @@ bool linuxswap::create(Report& report, const QString& deviceNode) const
|
|||
|
||||
bool linuxswap::resize(Report& report, const QString& deviceNode, qint64 length) const
|
||||
{
|
||||
Q_UNUSED(length);
|
||||
const QString label = readLabel(deviceNode);
|
||||
const QString uuid = readUUID(deviceNode);
|
||||
|
||||
|
@ -92,7 +93,7 @@ bool linuxswap::resize(Report& report, const QString& deviceNode, qint64 length)
|
|||
if (!uuid.isEmpty())
|
||||
args << QStringLiteral("--uuid") << uuid;
|
||||
|
||||
args << deviceNode << QString::number(length / 1024);
|
||||
args << deviceNode;
|
||||
|
||||
ExternalCommand cmd(report, QStringLiteral("mkswap"), args);
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
|
@ -131,8 +132,9 @@ QString linuxswap::unmountTitle() const
|
|||
return i18nc("@title:menu", "Deactivate swap");
|
||||
}
|
||||
|
||||
bool linuxswap::mount(const QString& deviceNode)
|
||||
bool linuxswap::mount(const QString& deviceNode, const QString& mountPoint)
|
||||
{
|
||||
Q_UNUSED(mountPoint);
|
||||
ExternalCommand cmd(QStringLiteral("swapon"), { deviceNode });
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
|
|
@ -42,56 +42,56 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual bool copy(Report& report, const QString& targetDeviceNode, const QString& sourceDeviceNode) const;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
virtual bool copy(Report& report, const QString& targetDeviceNode, const QString& sourceDeviceNode) const override;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual bool canMount(const QString&) const {
|
||||
virtual bool canMount(const QString&) const override {
|
||||
return true;
|
||||
}
|
||||
virtual bool canUnmount(const QString&) const {
|
||||
virtual bool canUnmount(const QString&) const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool mount(const QString& deviceNode);
|
||||
virtual bool unmount(const QString& deviceNode);
|
||||
virtual bool mount(const QString& deviceNode, const QString& mountPoint) override;
|
||||
virtual bool unmount(const QString& deviceNode) override;
|
||||
|
||||
virtual QString mountTitle() const;
|
||||
virtual QString unmountTitle() const;
|
||||
virtual QString mountTitle() const override;
|
||||
virtual QString unmountTitle() const override;
|
||||
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_Create;
|
||||
|
|
527
src/fs/luks.cpp
527
src/fs/luks.cpp
|
@ -1,6 +1,7 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2012 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2013 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* Copyright (C) 2015-2016 by Teo Mrnjavac <teo@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -18,17 +19,20 @@
|
|||
|
||||
#include "fs/luks.h"
|
||||
|
||||
#include "gui/decryptluksdialog.h"
|
||||
#include "fs/filesystemfactory.h"
|
||||
|
||||
#include "util/capacity.h"
|
||||
#include "util/externalcommand.h"
|
||||
#include "util/report.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDialog>
|
||||
#include <QPointer>
|
||||
#include <QString>
|
||||
#include <QUuid>
|
||||
|
||||
#include <KLocalizedString>
|
||||
#include <KPasswordDialog>
|
||||
|
||||
namespace FS
|
||||
{
|
||||
|
@ -45,89 +49,478 @@ FileSystem::CommandSupportType luks::m_SetLabel = FileSystem::cmdSupportNone;
|
|||
FileSystem::CommandSupportType luks::m_UpdateUUID = FileSystem::cmdSupportNone;
|
||||
FileSystem::CommandSupportType luks::m_GetUUID = FileSystem::cmdSupportNone;
|
||||
|
||||
luks::luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label) :
|
||||
FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Luks)
|
||||
luks::luks(qint64 firstsector,
|
||||
qint64 lastsector,
|
||||
qint64 sectorsused,
|
||||
const QString& label)
|
||||
: FileSystem(firstsector, lastsector, sectorsused, label, FileSystem::Luks)
|
||||
, m_innerFs(nullptr)
|
||||
, m_isCryptOpen(false)
|
||||
, m_isMounted(false)
|
||||
{
|
||||
}
|
||||
|
||||
luks::~luks()
|
||||
{
|
||||
delete m_innerFs;
|
||||
}
|
||||
|
||||
void luks::init()
|
||||
{
|
||||
m_Create = findExternal(QStringLiteral("cryptsetup")) ? cmdSupportFileSystem : cmdSupportNone;
|
||||
m_SetLabel = cmdSupportFileSystem;
|
||||
m_GetLabel = cmdSupportFileSystem;
|
||||
m_UpdateUUID = findExternal(QStringLiteral("cryptsetup")) ? cmdSupportFileSystem : cmdSupportNone;
|
||||
m_Grow = findExternal(QStringLiteral("cryptsetup")) ? cmdSupportFileSystem : cmdSupportNone;
|
||||
m_Shrink = m_Grow;
|
||||
m_Check = cmdSupportCore;
|
||||
m_Copy = cmdSupportCore;
|
||||
m_Move = cmdSupportCore;
|
||||
m_Backup = cmdSupportCore;
|
||||
m_GetUsed = cmdSupportNone; // libparted does not support LUKS, we do this as a special case
|
||||
m_GetUUID = findExternal(QStringLiteral("cryptsetup")) ? cmdSupportFileSystem : cmdSupportNone;
|
||||
}
|
||||
|
||||
bool luks::supportToolFound() const
|
||||
{
|
||||
return
|
||||
// m_GetUsed != cmdSupportNone &&
|
||||
// m_GetLabel != cmdSupportNone &&
|
||||
// m_SetLabel != cmdSupportNone &&
|
||||
// m_Create != cmdSupportNone &&
|
||||
// m_Check != cmdSupportNone &&
|
||||
m_cryptsetupFound =
|
||||
m_GetLabel != cmdSupportNone &&
|
||||
m_SetLabel != cmdSupportNone &&
|
||||
m_Create != cmdSupportNone &&
|
||||
m_Check != cmdSupportNone &&
|
||||
m_UpdateUUID != cmdSupportNone &&
|
||||
// m_Grow != cmdSupportNone &&
|
||||
// m_Shrink != cmdSupportNone &&
|
||||
m_Grow != cmdSupportNone &&
|
||||
m_Shrink != cmdSupportNone &&
|
||||
m_Copy != cmdSupportNone &&
|
||||
m_Move != cmdSupportNone &&
|
||||
m_Backup != cmdSupportNone &&
|
||||
m_GetUUID != cmdSupportNone;
|
||||
return m_cryptsetupFound &&
|
||||
((m_isCryptOpen && m_innerFs) ? m_innerFs->supportToolFound() : true);
|
||||
}
|
||||
|
||||
FileSystem::SupportTool luks::supportToolName() const
|
||||
{
|
||||
return SupportTool(QStringLiteral("cryptsetup"), QUrl(QStringLiteral("https://code.google.com/p/cryptsetup/")));
|
||||
if (m_isCryptOpen && m_innerFs && m_cryptsetupFound)
|
||||
return m_innerFs->supportToolName();
|
||||
return SupportTool(QStringLiteral("cryptsetup"),
|
||||
QUrl(QStringLiteral("https://code.google.com/p/cryptsetup/")));
|
||||
}
|
||||
|
||||
qint64 luks::minCapacity() const
|
||||
bool luks::create(Report& report, const QString& deviceNode) const
|
||||
{
|
||||
return 3 * Capacity::unitFactor(Capacity::Byte, Capacity::MiB);
|
||||
Q_ASSERT(m_innerFs);
|
||||
Q_ASSERT(!m_passphrase.isEmpty());
|
||||
|
||||
std::vector<QString> commands;
|
||||
commands.push_back(QStringLiteral("echo"));
|
||||
commands.push_back(QStringLiteral("cryptsetup"));
|
||||
std::vector<QStringList> args;
|
||||
args.push_back({ m_passphrase });
|
||||
args.push_back({ QStringLiteral("-s"),
|
||||
QStringLiteral("512"),
|
||||
QStringLiteral("luksFormat"),
|
||||
deviceNode });
|
||||
|
||||
ExternalCommand createCmd(commands, args);
|
||||
if (!(createCmd.run(-1) && createCmd.exitCode() == 0))
|
||||
return false;
|
||||
|
||||
commands.clear();
|
||||
commands.push_back(QStringLiteral("echo"));
|
||||
commands.push_back(QStringLiteral("cryptsetup"));
|
||||
args.clear();
|
||||
args.push_back({ m_passphrase });
|
||||
args.push_back({ QStringLiteral("open"),
|
||||
deviceNode,
|
||||
suggestedMapperName(deviceNode) });
|
||||
|
||||
ExternalCommand openCmd(commands, args);
|
||||
if (!(openCmd.run(-1) && openCmd.exitCode() == 0))
|
||||
return false;
|
||||
|
||||
QString mapperNode = mapperName(deviceNode);
|
||||
if (mapperNode.isEmpty())
|
||||
return false;
|
||||
|
||||
if (!m_innerFs->create(report, mapperNode))
|
||||
return false;
|
||||
|
||||
m_isCryptOpen = (m_innerFs != nullptr);
|
||||
|
||||
if (m_isCryptOpen)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
QString luks::mountTitle() const
|
||||
{
|
||||
return i18nc("@title:menu", "Decrypt");
|
||||
return i18nc("@title:menu", "Mount");
|
||||
}
|
||||
|
||||
QString luks::unmountTitle() const
|
||||
{
|
||||
return i18nc("@title:menu", "Unmount");
|
||||
}
|
||||
|
||||
QString luks::cryptOpenTitle() const
|
||||
{
|
||||
return i18nc("@title:menu", "Decrypt");
|
||||
}
|
||||
|
||||
QString luks::cryptCloseTitle() const
|
||||
{
|
||||
return i18nc("@title:menu", "Deactivate");
|
||||
}
|
||||
|
||||
bool luks::mount(const QString& deviceNode)
|
||||
void luks::setPassphrase(const QString& passphrase)
|
||||
{
|
||||
QPointer<DecryptLuksDialog> dlg = new DecryptLuksDialog(0, deviceNode); //TODO: parent widget instead of 0
|
||||
m_passphrase = passphrase;
|
||||
}
|
||||
|
||||
if (dlg->exec() == QDialog::Accepted)
|
||||
QString luks::passphrase() const
|
||||
{
|
||||
return m_passphrase;
|
||||
}
|
||||
|
||||
bool luks::canMount(const QString& deviceNode) const
|
||||
{
|
||||
return m_isCryptOpen &&
|
||||
!m_isMounted &&
|
||||
m_innerFs &&
|
||||
m_innerFs->canMount(mapperName(deviceNode));
|
||||
}
|
||||
|
||||
bool luks::canUnmount(const QString& deviceNode) const
|
||||
{
|
||||
return m_isCryptOpen &&
|
||||
m_isMounted &&
|
||||
m_innerFs &&
|
||||
m_innerFs->canUnmount(mapperName(deviceNode));
|
||||
}
|
||||
|
||||
bool luks::isMounted() const
|
||||
{
|
||||
return m_isCryptOpen && m_isMounted;
|
||||
}
|
||||
|
||||
void luks::setMounted(bool mounted)
|
||||
{
|
||||
m_isMounted = mounted;
|
||||
}
|
||||
|
||||
bool luks::canCryptOpen(const QString&) const
|
||||
{
|
||||
return !m_isCryptOpen && !m_isMounted && supportToolFound();
|
||||
}
|
||||
|
||||
bool luks::canCryptClose(const QString&) const
|
||||
{
|
||||
return m_isCryptOpen && !m_isMounted && m_cryptsetupFound;
|
||||
}
|
||||
|
||||
bool luks::isCryptOpen() const
|
||||
{
|
||||
return m_isCryptOpen;
|
||||
}
|
||||
|
||||
void luks::setCryptOpen(bool cryptOpen)
|
||||
{
|
||||
m_isCryptOpen = cryptOpen;
|
||||
}
|
||||
|
||||
bool luks::cryptOpen(QWidget* parent, const QString& deviceNode)
|
||||
{
|
||||
if (m_isCryptOpen)
|
||||
{
|
||||
std::vector<QString> commands;
|
||||
commands.push_back(QStringLiteral("echo"));
|
||||
commands.push_back(QStringLiteral("cryptsetup"));
|
||||
std::vector<QStringList> args;
|
||||
args.push_back(QStringList() << dlg->luksPassphrase().text());
|
||||
args.push_back(QStringList() << QStringLiteral("luksOpen") << deviceNode << dlg->luksName().text());
|
||||
ExternalCommand cmd(commands, args);
|
||||
delete dlg;
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
if (!mapperName(deviceNode).isEmpty())
|
||||
{
|
||||
qWarning() << "LUKS device" << deviceNode
|
||||
<< "already decrypted."
|
||||
<< "Cannot decrypt again.";
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
qWarning() << "LUKS device" << deviceNode
|
||||
<< "reportedly decrypted but mapper node not found."
|
||||
<< "Marking device as NOT decrypted and trying to "
|
||||
"decrypt again anyway.";
|
||||
m_isCryptOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
delete dlg;
|
||||
KPasswordDialog dlg( parent );
|
||||
dlg.setPrompt(i18n("Enter passphrase for %1:", deviceNode));
|
||||
if( !dlg.exec() )
|
||||
return false;
|
||||
|
||||
QString passphrase = dlg.password();
|
||||
std::vector<QString> commands;
|
||||
commands.push_back(QStringLiteral("echo"));
|
||||
commands.push_back(QStringLiteral("cryptsetup"));
|
||||
std::vector<QStringList> args;
|
||||
args.push_back({ passphrase });
|
||||
args.push_back({ QStringLiteral("open"),
|
||||
deviceNode,
|
||||
suggestedMapperName(deviceNode) });
|
||||
|
||||
ExternalCommand cmd(commands, args);
|
||||
if (!(cmd.run(-1) && cmd.exitCode() == 0))
|
||||
return false;
|
||||
|
||||
if (m_innerFs)
|
||||
{
|
||||
delete m_innerFs;
|
||||
m_innerFs = nullptr;
|
||||
}
|
||||
|
||||
QString mapperNode = mapperName(deviceNode);
|
||||
if (mapperNode.isEmpty())
|
||||
return false;
|
||||
|
||||
loadInnerFileSystem(mapperNode);
|
||||
m_isCryptOpen = (m_innerFs != nullptr);
|
||||
|
||||
if (m_isCryptOpen)
|
||||
{
|
||||
m_passphrase = passphrase;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool luks::cryptClose(const QString& deviceNode)
|
||||
{
|
||||
if (!m_isCryptOpen)
|
||||
{
|
||||
qWarning() << "Cannot close LUKS device" << deviceNode
|
||||
<< "because it's not open.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_isMounted)
|
||||
{
|
||||
qWarning() << "Cannot close LUKS device" << deviceNode
|
||||
<< "because the filesystem is mounted.";
|
||||
return false;
|
||||
}
|
||||
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("close"), mapperName(deviceNode) });
|
||||
if (!(cmd.run(-1) && cmd.exitCode() == 0))
|
||||
return false;
|
||||
|
||||
delete m_innerFs;
|
||||
m_innerFs = nullptr;
|
||||
|
||||
m_passphrase.clear();
|
||||
setLabel({});
|
||||
setUUID(readUUID(deviceNode));
|
||||
setSectorsUsed(-1);
|
||||
|
||||
m_isCryptOpen = (m_innerFs != nullptr);
|
||||
|
||||
if (!m_isCryptOpen)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void luks::loadInnerFileSystem(const QString& mapperNode)
|
||||
{
|
||||
Q_ASSERT(!m_innerFs);
|
||||
FileSystem::Type innerFsType = detectFileSystem(mapperNode);
|
||||
m_innerFs = FileSystemFactory::cloneWithNewType(innerFsType,
|
||||
*this);
|
||||
setLabel(m_innerFs->readLabel(mapperNode));
|
||||
setUUID(m_innerFs->readUUID(mapperNode));
|
||||
if (m_innerFs->supportGetUsed() == FileSystem::cmdSupportFileSystem) // FIXME:also implement checking space if partition is mounted
|
||||
setSectorsUsed(m_innerFs->readUsedCapacity(mapperNode)/m_logicalSectorSize);
|
||||
}
|
||||
|
||||
void luks::createInnerFileSystem(FileSystem::Type type)
|
||||
{
|
||||
Q_ASSERT(!m_innerFs);
|
||||
m_innerFs = FileSystemFactory::cloneWithNewType(type, *this);
|
||||
}
|
||||
|
||||
bool luks::check(Report& report, const QString& deviceNode) const
|
||||
{
|
||||
Q_ASSERT(m_innerFs);
|
||||
|
||||
QString mapperNode = mapperName(deviceNode);
|
||||
if (mapperNode.isEmpty())
|
||||
return false;
|
||||
|
||||
return m_innerFs->check(report, mapperNode);
|
||||
}
|
||||
|
||||
qint64 luks::readUsedCapacity(const QString& deviceNode) const
|
||||
{
|
||||
if (!m_isCryptOpen)
|
||||
return -1;
|
||||
if (m_innerFs)
|
||||
return m_innerFs->readUsedCapacity(deviceNode);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool luks::mount(const QString& deviceNode, const QString& mountPoint)
|
||||
{
|
||||
if (!m_isCryptOpen)
|
||||
{
|
||||
qWarning() << "Cannot mount device" << deviceNode
|
||||
<< "before decrypting it first.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_isMounted)
|
||||
{
|
||||
qWarning() << "Cannot mount device" << deviceNode
|
||||
<< "because it's already mounted.";
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_innerFs);
|
||||
|
||||
QString mapperNode = mapperName(deviceNode);
|
||||
if (mapperNode.isEmpty())
|
||||
return false;
|
||||
|
||||
if (m_innerFs->canMount(mapperNode))
|
||||
{
|
||||
if (m_innerFs->mount(mapperNode, mountPoint))
|
||||
{
|
||||
m_isMounted = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ExternalCommand mountCmd(
|
||||
QStringLiteral("mount"),
|
||||
{ QStringLiteral("-v"), mapperNode, mountPoint });
|
||||
if (mountCmd.run() && mountCmd.exitCode() == 0)
|
||||
{
|
||||
m_isMounted = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool luks::unmount(const QString& deviceNode)
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"), QStringList() << QStringLiteral("luksClose") << mapperName(deviceNode));
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
if (!m_isCryptOpen)
|
||||
{
|
||||
qWarning() << "Cannot unmount device" << deviceNode
|
||||
<< "before decrypting it first.";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_isMounted)
|
||||
{
|
||||
qWarning() << "Cannot unmount device" << deviceNode
|
||||
<< "because it's not mounted.";
|
||||
return false;
|
||||
}
|
||||
|
||||
Q_ASSERT(m_innerFs);
|
||||
|
||||
QString mapperNode = mapperName(deviceNode);
|
||||
if (mapperNode.isEmpty())
|
||||
return false;
|
||||
|
||||
if (m_innerFs->canUnmount(mapperNode))
|
||||
{
|
||||
if (m_innerFs->unmount(mapperNode))
|
||||
{
|
||||
m_isMounted = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ExternalCommand unmountCmd(
|
||||
QStringLiteral("umount"),
|
||||
{ QStringLiteral("--verbose"), mapperNode });
|
||||
if (unmountCmd.run() && unmountCmd.exitCode() == 0)
|
||||
{
|
||||
m_isMounted = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
FileSystem::Type luks::type() const
|
||||
{
|
||||
if (m_isCryptOpen && m_innerFs)
|
||||
return m_innerFs->type();
|
||||
return FileSystem::Luks;
|
||||
}
|
||||
|
||||
QString luks::suggestedMapperName(const QString& deviceNode) const
|
||||
{
|
||||
return QStringLiteral("luks-") + readOuterUUID(deviceNode);
|
||||
}
|
||||
|
||||
QString luks::readLabel(const QString& deviceNode) const
|
||||
{
|
||||
if (m_isCryptOpen && m_innerFs)
|
||||
return m_innerFs->readLabel(mapperName(deviceNode));
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool luks::writeLabel(Report& report, const QString& deviceNode, const QString& newLabel)
|
||||
{
|
||||
Q_ASSERT(m_innerFs);
|
||||
return m_innerFs->writeLabel(report, mapperName(deviceNode), newLabel);
|
||||
}
|
||||
|
||||
bool luks::resize(Report& report, const QString& deviceNode, qint64 newLength) const
|
||||
{
|
||||
Q_ASSERT(m_innerFs);
|
||||
|
||||
QString mapperNode = mapperName(deviceNode);
|
||||
if (mapperNode.isEmpty())
|
||||
return false;
|
||||
|
||||
qint64 payloadLength = newLength - getPayloadOffset(deviceNode).toInt() * m_logicalSectorSize;
|
||||
if ( newLength - length() * m_logicalSectorSize > 0 )
|
||||
{
|
||||
ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"), { QStringLiteral("resize"), mapperNode });
|
||||
report.line() << xi18nc("@info/plain", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
|
||||
|
||||
if (cryptResizeCmd.run(-1) && cryptResizeCmd.exitCode() == 0)
|
||||
{
|
||||
return m_innerFs->resize(report, mapperNode, newLength - getPayloadOffset(deviceNode).toInt() * m_logicalSectorSize);
|
||||
}
|
||||
else
|
||||
report.line() << xi18nc("@info/plain", "Resizing encrypted file system on partition <filename>%1</filename> failed.", deviceNode);
|
||||
}
|
||||
else if (m_innerFs->resize(report, mapperNode, payloadLength))
|
||||
{
|
||||
ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"), { QStringLiteral("--size"), QString::number(payloadLength / m_logicalSectorSize), QStringLiteral("resize"), mapperNode });
|
||||
report.line() << xi18nc("@info/plain", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
|
||||
if (cryptResizeCmd.run(-1) && cryptResizeCmd.exitCode() == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString luks::readUUID(const QString& deviceNode) const
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"), QStringList() << QStringLiteral("luksUUID") << deviceNode);
|
||||
if (m_isCryptOpen && m_innerFs)
|
||||
return m_innerFs->readUUID(mapperName(deviceNode));
|
||||
return readOuterUUID(deviceNode);
|
||||
}
|
||||
|
||||
QString luks::readOuterUUID(const QString &deviceNode) const
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("luksUUID"), deviceNode });
|
||||
if (cmd.run()) {
|
||||
return cmd.output().simplified();
|
||||
return cmd.output().trimmed();
|
||||
}
|
||||
return QStringLiteral("---");
|
||||
}
|
||||
|
@ -136,34 +529,36 @@ bool luks::updateUUID(Report& report, const QString& deviceNode) const
|
|||
{
|
||||
QUuid uuid = QUuid::createUuid();
|
||||
|
||||
ExternalCommand cmd(report, QStringLiteral("cryptsetup"), QStringList() << QStringLiteral("luksUUID") << deviceNode << QStringLiteral("--uuid") << uuid.toString());
|
||||
ExternalCommand cmd(report,
|
||||
QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("luksUUID"),
|
||||
deviceNode,
|
||||
QStringLiteral("--uuid"),
|
||||
uuid.toString() });
|
||||
return cmd.run(-1) && cmd.exitCode() == 0;
|
||||
}
|
||||
|
||||
bool luks::canMount(const QString&) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool luks::canUnmount(const QString&) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QString luks::mapperName(const QString& deviceNode)
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("find"), QStringList() << QStringLiteral("/dev/mapper/") << QStringLiteral("-exec") << QStringLiteral("cryptsetup") << QStringLiteral("status") << QStringLiteral("{}") << QStringLiteral(";"));
|
||||
if (cmd.run()) {
|
||||
QRegExp rxDeviceName(QStringLiteral("(/dev/mapper/[A-Za-z0-9-/]+) is active[A-Za-z0-9- \\.\n]+[A-Za-z0-9-: \n]+") + deviceNode);
|
||||
if (rxDeviceName.indexIn(cmd.output()) > -1)
|
||||
return rxDeviceName.cap(1);
|
||||
ExternalCommand cmd(QStringLiteral("lsblk"),
|
||||
{ QStringLiteral("--raw"),
|
||||
QStringLiteral("--noheadings"),
|
||||
QStringLiteral("--output"),
|
||||
QStringLiteral("name"),
|
||||
deviceNode });
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
QStringList output=cmd.output().split(QStringLiteral("\n"));
|
||||
output.removeFirst();
|
||||
if (!output.first().isEmpty())
|
||||
return QStringLiteral("/dev/mapper/") + output.first();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString luks::getCipherName(const QString& deviceNode)
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"), QStringList() << QStringLiteral("luksDump") << deviceNode);
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("luksDump"), deviceNode });
|
||||
if (cmd.run()) {
|
||||
QRegExp rxCipherName(QStringLiteral("(?:Cipher name:\\s+)([A-Za-z0-9-]+)"));
|
||||
if (rxCipherName.indexIn(cmd.output()) > -1)
|
||||
|
@ -174,7 +569,8 @@ QString luks::getCipherName(const QString& deviceNode)
|
|||
|
||||
QString luks::getCipherMode(const QString& deviceNode)
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"), QStringList() << QStringLiteral("luksDump") << deviceNode);
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("luksDump"), deviceNode });
|
||||
if (cmd.run()) {
|
||||
QRegExp rxCipherMode(QStringLiteral("(?:Cipher mode:\\s+)([A-Za-z0-9-]+)"));
|
||||
if (rxCipherMode.indexIn(cmd.output()) > -1)
|
||||
|
@ -185,7 +581,8 @@ QString luks::getCipherMode(const QString& deviceNode)
|
|||
|
||||
QString luks::getHashName(const QString& deviceNode)
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"), QStringList() << QStringLiteral("luksDump") << deviceNode);
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("luksDump"), deviceNode });
|
||||
if (cmd.run()) {
|
||||
QRegExp rxHash(QStringLiteral("(?:Hash spec:\\s+)([A-Za-z0-9-]+)"));
|
||||
if (rxHash.indexIn(cmd.output()) > -1)
|
||||
|
@ -196,7 +593,8 @@ QString luks::getHashName(const QString& deviceNode)
|
|||
|
||||
QString luks::getKeySize(const QString& deviceNode)
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"), QStringList() << QStringLiteral("luksDump") << deviceNode);
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("luksDump"), deviceNode });
|
||||
if (cmd.run()) {
|
||||
QRegExp rxKeySize(QStringLiteral("(?:MK bits:\\s+)(\\d+)"));
|
||||
if (rxKeySize.indexIn(cmd.output()) > -1)
|
||||
|
@ -207,7 +605,8 @@ QString luks::getKeySize(const QString& deviceNode)
|
|||
|
||||
QString luks::getPayloadOffset(const QString& deviceNode)
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"), QStringList() << QStringLiteral("luksDump") << deviceNode);
|
||||
ExternalCommand cmd(QStringLiteral("cryptsetup"),
|
||||
{ QStringLiteral("luksDump"), deviceNode });
|
||||
if (cmd.run()) {
|
||||
QRegExp rxPayloadOffset(QStringLiteral("(?:Payload offset:\\s+)(\\d+)"));
|
||||
if (rxPayloadOffset.indexIn(cmd.output()) > -1)
|
||||
|
@ -215,4 +614,26 @@ QString luks::getPayloadOffset(const QString& deviceNode)
|
|||
}
|
||||
return QStringLiteral("---");
|
||||
}
|
||||
|
||||
bool luks::canEncryptType(FileSystem::Type type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case Ext2:
|
||||
case Ext3:
|
||||
case Ext4:
|
||||
case LinuxSwap:
|
||||
case ReiserFS:
|
||||
case Reiser4:
|
||||
case Xfs:
|
||||
case Jfs:
|
||||
case Btrfs:
|
||||
case Zfs:
|
||||
case Lvm2_PV:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
112
src/fs/luks.h
112
src/fs/luks.h
|
@ -1,6 +1,7 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2012 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2013 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* Copyright (C) 2015-2016 by Teo Mrnjavac <teo@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -25,6 +26,7 @@
|
|||
#include "../fs/filesystem.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QPointer>
|
||||
|
||||
class Report;
|
||||
|
||||
|
@ -39,60 +41,105 @@ class LIBKPMCORE_EXPORT luks : public FileSystem
|
|||
{
|
||||
public:
|
||||
luks(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
|
||||
virtual ~luks();
|
||||
|
||||
public:
|
||||
static void init();
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
return m_Grow;
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
if (!m_isCryptOpen)
|
||||
return cmdSupportNone;
|
||||
if (m_Grow && m_innerFs)
|
||||
return m_innerFs->supportGrow();
|
||||
return cmdSupportNone;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
return m_Shrink;
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
if (!m_isCryptOpen)
|
||||
return cmdSupportNone;
|
||||
if (m_Shrink && m_innerFs)
|
||||
return m_innerFs->supportShrink();
|
||||
return cmdSupportNone;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
return m_Check;
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
if (!m_isCryptOpen)
|
||||
return cmdSupportNone;
|
||||
if (m_Check && m_innerFs)
|
||||
return m_innerFs->supportCheck();
|
||||
return cmdSupportNone;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 minCapacity() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual QString readUUID(const QString& deviceNode) const;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
void setLogicalSectorSize(unsigned int logicalSectorSize) {
|
||||
m_logicalSectorSize = logicalSectorSize;
|
||||
}
|
||||
|
||||
virtual bool canMount(const QString&) const;
|
||||
virtual bool canUnmount(const QString&) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report &report, const QString &deviceNode) const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
virtual QString readUUID(const QString& deviceNode) const override;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
virtual QString readLabel(const QString& deviceNode) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
|
||||
virtual bool mount(const QString& deviceNode);
|
||||
virtual bool unmount(const QString& deviceNode);
|
||||
virtual QString mountTitle() const;
|
||||
virtual QString unmountTitle() const;
|
||||
virtual QString mountTitle() const override;
|
||||
virtual QString unmountTitle() const override;
|
||||
QString cryptOpenTitle() const;
|
||||
QString cryptCloseTitle() const;
|
||||
|
||||
void setPassphrase(const QString&);
|
||||
QString passphrase() const;
|
||||
|
||||
virtual bool canMount(const QString&) const override;
|
||||
virtual bool canUnmount(const QString&) const override;
|
||||
bool isMounted() const;
|
||||
void setMounted(bool mounted);
|
||||
|
||||
bool canCryptOpen(const QString& deviceNode) const;
|
||||
bool canCryptClose(const QString& deviceNode) const;
|
||||
bool isCryptOpen() const;
|
||||
void setCryptOpen(bool cryptOpen);
|
||||
|
||||
bool cryptOpen(QWidget* parent, const QString& deviceNode);
|
||||
bool cryptClose(const QString& deviceNode);
|
||||
|
||||
void loadInnerFileSystem(const QString& mapperNode);
|
||||
void createInnerFileSystem(Type type);
|
||||
|
||||
virtual bool mount(const QString& deviceNode, const QString& mountPoint) override;
|
||||
virtual bool unmount(const QString& deviceNode) override;
|
||||
|
||||
virtual FileSystem::Type type() const override;
|
||||
|
||||
QString suggestedMapperName(const QString& deviceNode) const;
|
||||
|
||||
static QString mapperName(const QString& deviceNode);
|
||||
|
||||
|
@ -101,6 +148,10 @@ public:
|
|||
static QString getHashName(const QString& deviceNode);
|
||||
static QString getKeySize(const QString& deviceNode);
|
||||
static QString getPayloadOffset(const QString& deviceNode);
|
||||
static bool canEncryptType(FileSystem::Type type);
|
||||
|
||||
protected:
|
||||
virtual QString readOuterUUID(const QString& deviceNode) const;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
@ -115,6 +166,15 @@ public:
|
|||
static CommandSupportType m_SetLabel;
|
||||
static CommandSupportType m_UpdateUUID;
|
||||
static CommandSupportType m_GetUUID;
|
||||
|
||||
private:
|
||||
mutable FileSystem* m_innerFs;
|
||||
|
||||
mutable bool m_isCryptOpen;
|
||||
mutable bool m_cryptsetupFound;
|
||||
QString m_passphrase;
|
||||
bool m_isMounted;
|
||||
unsigned int m_logicalSectorSize;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -43,54 +43,54 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
// virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool remove(Report& report, const QString& deviceNode) const;
|
||||
// virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
// virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
// virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool remove(Report& report, const QString& deviceNode) const override;
|
||||
// virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
// virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -43,56 +43,56 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
// virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
// virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 minCapacity() const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 minCapacity() const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -123,19 +123,13 @@ qint64 ntfs::readUsedCapacity(const QString& deviceNode) const
|
|||
|
||||
bool ntfs::writeLabel(Report& report, const QString& deviceNode, const QString& newLabel)
|
||||
{
|
||||
ExternalCommand writeCmd(report, QStringLiteral("ntfslabel"), { QStringLiteral("--force"), deviceNode, newLabel.simplified() });
|
||||
ExternalCommand writeCmd(report, QStringLiteral("ntfslabel"), { QStringLiteral("--force"), deviceNode, newLabel });
|
||||
writeCmd.setProcessChannelMode(QProcess::SeparateChannels);
|
||||
|
||||
if (!writeCmd.run(-1))
|
||||
return false;
|
||||
|
||||
ExternalCommand testCmd(QStringLiteral("ntfslabel"), { QStringLiteral("--force"), deviceNode });
|
||||
testCmd.setProcessChannelMode(QProcess::SeparateChannels);
|
||||
|
||||
if (!testCmd.run(-1))
|
||||
return false;
|
||||
|
||||
return testCmd.output().simplified() == newLabel.simplified();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ntfs::check(Report& report, const QString& deviceNode) const
|
||||
|
|
|
@ -42,57 +42,57 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool copy(Report& report, const QString& targetDeviceNode, const QString& sourceDeviceNode) const;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
virtual bool updateBootSector(Report& report, const QString& deviceNode) const;
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool copy(Report& report, const QString& targetDeviceNode, const QString& sourceDeviceNode) const override;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool updateBootSector(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 minCapacity() const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 minCapacity() const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -42,54 +42,54 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 minCapacity() const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 minCapacity() const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -42,36 +42,36 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -148,7 +148,10 @@ bool reiserfs::create(Report& report, const QString& deviceNode) const
|
|||
|
||||
bool reiserfs::resize(Report& report, const QString& deviceNode, qint64 length) const
|
||||
{
|
||||
ExternalCommand cmd(report, QStringLiteral("resize_reiserfs"), { deviceNode, QStringLiteral("-q"), QStringLiteral("-s"), QString::number(length) });
|
||||
const QStringList args = length == -1 ?
|
||||
QStringList() << deviceNode << QStringLiteral("-q") :
|
||||
QStringList() << deviceNode << QStringLiteral("-q") << QStringLiteral("-s") << QString::number(length);
|
||||
ExternalCommand cmd(report, QStringLiteral("resize_reiserfs"), args);
|
||||
|
||||
bool rval = cmd.start(-1);
|
||||
|
||||
|
|
|
@ -44,55 +44,55 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const;
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
virtual bool updateUUID(Report& report, const QString& deviceNode) const override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 minCapacity() const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 minCapacity() const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -40,17 +40,17 @@ public:
|
|||
public:
|
||||
static void init() {}
|
||||
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
|
||||
virtual bool supportToolFound() const {
|
||||
virtual bool supportToolFound() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,13 +42,13 @@ public:
|
|||
public:
|
||||
static void init() {}
|
||||
|
||||
virtual bool create(Report&, const QString&) const;
|
||||
virtual bool create(Report&, const QString&) const override;
|
||||
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
|
||||
virtual bool supportToolFound() const {
|
||||
virtual bool supportToolFound() const override {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
|
||||
public:
|
||||
static void init() {}
|
||||
virtual bool supportToolFound() const {
|
||||
virtual bool supportToolFound() const override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
40
src/fs/xfs.h
40
src/fs/xfs.h
|
@ -42,46 +42,46 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const;
|
||||
virtual bool copy(Report& report, const QString&, const QString&) const;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual qint64 readUsedCapacity(const QString& deviceNode) const override;
|
||||
virtual bool check(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool create(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool copy(Report& report, const QString&, const QString&) const override;
|
||||
virtual bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
|
||||
virtual qint64 minCapacity() const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual qint64 maxLabelLength() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 minCapacity() const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual qint64 maxLabelLength() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
36
src/fs/zfs.h
36
src/fs/zfs.h
|
@ -43,50 +43,50 @@ public:
|
|||
public:
|
||||
static void init();
|
||||
|
||||
virtual bool remove(Report& report, const QString& deviceNode) const;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel);
|
||||
virtual bool remove(Report& report, const QString& deviceNode) const override;
|
||||
virtual bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
||||
|
||||
virtual CommandSupportType supportGetUsed() const {
|
||||
virtual CommandSupportType supportGetUsed() const override {
|
||||
return m_GetUsed;
|
||||
}
|
||||
virtual CommandSupportType supportGetLabel() const {
|
||||
virtual CommandSupportType supportGetLabel() const override {
|
||||
return m_GetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportCreate() const {
|
||||
virtual CommandSupportType supportCreate() const override {
|
||||
return m_Create;
|
||||
}
|
||||
virtual CommandSupportType supportGrow() const {
|
||||
virtual CommandSupportType supportGrow() const override {
|
||||
return m_Grow;
|
||||
}
|
||||
virtual CommandSupportType supportShrink() const {
|
||||
virtual CommandSupportType supportShrink() const override {
|
||||
return m_Shrink;
|
||||
}
|
||||
virtual CommandSupportType supportMove() const {
|
||||
virtual CommandSupportType supportMove() const override {
|
||||
return m_Move;
|
||||
}
|
||||
virtual CommandSupportType supportCheck() const {
|
||||
virtual CommandSupportType supportCheck() const override {
|
||||
return m_Check;
|
||||
}
|
||||
virtual CommandSupportType supportCopy() const {
|
||||
virtual CommandSupportType supportCopy() const override {
|
||||
return m_Copy;
|
||||
}
|
||||
virtual CommandSupportType supportBackup() const {
|
||||
virtual CommandSupportType supportBackup() const override {
|
||||
return m_Backup;
|
||||
}
|
||||
virtual CommandSupportType supportSetLabel() const {
|
||||
virtual CommandSupportType supportSetLabel() const override {
|
||||
return m_SetLabel;
|
||||
}
|
||||
virtual CommandSupportType supportUpdateUUID() const {
|
||||
virtual CommandSupportType supportUpdateUUID() const override {
|
||||
return m_UpdateUUID;
|
||||
}
|
||||
virtual CommandSupportType supportGetUUID() const {
|
||||
virtual CommandSupportType supportGetUUID() const override {
|
||||
return m_GetUUID;
|
||||
}
|
||||
|
||||
virtual qint64 minCapacity() const;
|
||||
virtual qint64 maxCapacity() const;
|
||||
virtual SupportTool supportToolName() const;
|
||||
virtual bool supportToolFound() const;
|
||||
virtual qint64 minCapacity() const override;
|
||||
virtual qint64 maxCapacity() const override;
|
||||
virtual SupportTool supportToolName() const override;
|
||||
virtual bool supportToolFound() const override;
|
||||
|
||||
public:
|
||||
static CommandSupportType m_GetUsed;
|
||||
|
|
|
@ -1,19 +1,11 @@
|
|||
set(GUI_SRC
|
||||
gui/decryptluksdialog.cpp
|
||||
gui/decryptluksdialogwidget.cpp
|
||||
gui/partresizerwidget.cpp
|
||||
gui/partwidget.cpp
|
||||
gui/partwidgetbase.cpp
|
||||
)
|
||||
|
||||
set(GUI_LIB_HDRS
|
||||
gui/decryptluksdialog.h
|
||||
gui/decryptluksdialogwidget.h
|
||||
gui/partresizerwidget.h
|
||||
gui/partwidget.h
|
||||
gui/partwidgetbase.h
|
||||
)
|
||||
|
||||
set(gui_UIFILES
|
||||
gui/decryptluksdialogwidgetbase.ui
|
||||
)
|
||||
|
|
|
@ -1,46 +0,0 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2013 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* *
|
||||
* 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 "gui/decryptluksdialog.h"
|
||||
#include "gui/decryptluksdialogwidget.h"
|
||||
|
||||
#include "core/device.h"
|
||||
#include "core/partitiontable.h"
|
||||
|
||||
#include <KLocalizedString>
|
||||
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
DecryptLuksDialog::DecryptLuksDialog(QWidget* parent, const QString& deviceNode) :
|
||||
QDialog(parent),
|
||||
m_DialogWidget(new DecryptLuksDialogWidget(this)),
|
||||
m_DeviceNode(deviceNode)
|
||||
{
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout(this);
|
||||
setLayout(mainLayout);
|
||||
mainLayout->addWidget(&widget());
|
||||
setWindowTitle(xi18nc("@title:window", "Decrypt LUKS partition on <filename>%1</filename>", this->deviceNode()));
|
||||
|
||||
QDialogButtonBox* dialogButtonBox = new QDialogButtonBox;
|
||||
QPushButton* decryptButton = new QPushButton;
|
||||
decryptButton->setText(i18nc("@action:button", "&Decrypt"));
|
||||
decryptButton->setIcon(QIcon::fromTheme(QStringLiteral("object-unlocked")));
|
||||
dialogButtonBox->addButton(decryptButton, QDialogButtonBox::AcceptRole);
|
||||
mainLayout->addWidget(dialogButtonBox);
|
||||
connect(dialogButtonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2013 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* *
|
||||
* 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/>.*
|
||||
*************************************************************************/
|
||||
|
||||
#if !defined(DECRYPTLUKSDIALOG__H)
|
||||
|
||||
#define DECRYPTLUKSDIALOG__H
|
||||
|
||||
#include "gui/decryptluksdialogwidget.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class Device;
|
||||
|
||||
class DecryptLuksDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DecryptLuksDialog(QWidget* parent, const QString& deviceNode);
|
||||
|
||||
protected:
|
||||
DecryptLuksDialogWidget& widget() { return *m_DialogWidget; }
|
||||
const DecryptLuksDialogWidget& widget() const { return *m_DialogWidget; }
|
||||
const QString& deviceNode() const { return m_DeviceNode; }
|
||||
|
||||
private:
|
||||
DecryptLuksDialogWidget* m_DialogWidget;
|
||||
const QString& m_DeviceNode;
|
||||
|
||||
public:
|
||||
QLineEdit& luksName() { return widget().luksName(); }
|
||||
const QLineEdit& luksName() const { return widget().luksName(); }
|
||||
|
||||
QLineEdit& luksPassphrase() { return widget().luksPassphrase(); }
|
||||
const QLineEdit& luksPassphrase() const { return widget().luksPassphrase(); }
|
||||
};
|
||||
|
||||
|
||||
#endif
|
|
@ -1,24 +0,0 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2013 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* *
|
||||
* 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 "gui/decryptluksdialogwidget.h"
|
||||
|
||||
DecryptLuksDialogWidget::DecryptLuksDialogWidget(QWidget* parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2013 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* *
|
||||
* 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/>.*
|
||||
*************************************************************************/
|
||||
|
||||
#if !defined(DECRYPTLUKSDIALOGWIDGET__H)
|
||||
|
||||
#define DECRYPTLUKSDIALOGWIDGET__H
|
||||
|
||||
#include "ui_decryptluksdialogwidgetbase.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
||||
class DecryptLuksDialogWidget : public QWidget, public Ui::DecryptLuksDialogWidgetBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DecryptLuksDialogWidget(QWidget* parent);
|
||||
|
||||
public:
|
||||
QLineEdit& luksName() { return *m_LineEditName; }
|
||||
const QLineEdit& luksName() const { return *m_LineEditName; }
|
||||
|
||||
QLineEdit& luksPassphrase() { return *m_LineEditPassphrase; }
|
||||
const QLineEdit& luksPassphrase() const { return *m_LineEditPassphrase; }
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,71 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>DecryptLuksDialogWidgetBase</class>
|
||||
<widget class="QWidget" name="DecryptLuksDialogWidgetBase">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>377</width>
|
||||
<height>122</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>10</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_Name">
|
||||
<property name="text">
|
||||
<string>&Name:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_LineEditName</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="m_LineEditName"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_Pass">
|
||||
<property name="text">
|
||||
<string>&Passphrase:</string>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>m_LineEditPassphrase</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="m_LineEditPassphrase">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::MinimumExpanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -39,9 +39,9 @@ public:
|
|||
BackupFileSystemJob(Device& sourcedevice, Partition& sourcepartition, const QString& filename);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual qint32 numSteps() const;
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual qint32 numSteps() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Partition& sourcePartition() {
|
||||
|
|
|
@ -35,8 +35,8 @@ public:
|
|||
CheckFileSystemJob(Partition& p);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Partition& partition() {
|
||||
|
|
|
@ -41,9 +41,9 @@ public:
|
|||
CopyFileSystemJob(Device& targetdevice, Partition& targetpartition, Device& sourcedevice, Partition& sourcepartition);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual qint32 numSteps() const;
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual qint32 numSteps() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Partition& targetPartition() {
|
||||
|
|
|
@ -36,8 +36,8 @@ public:
|
|||
CreateFileSystemJob(Device& d, Partition& p);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Partition& partition() {
|
||||
|
|
|
@ -36,8 +36,8 @@ public:
|
|||
CreatePartitionJob(Device& d, Partition& p);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Partition& partition() {
|
||||
|
|
|
@ -35,8 +35,8 @@ public:
|
|||
CreatePartitionTableJob(Device& d);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Device& device() {
|
||||
|
|
|
@ -39,8 +39,8 @@ public:
|
|||
DeleteFileSystemJob(Device& d, Partition& p);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Partition& partition() {
|
||||
|
|
|
@ -36,8 +36,8 @@ public:
|
|||
DeletePartitionJob(Device& d, Partition& p);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Partition& partition() {
|
||||
|
|
|
@ -39,9 +39,9 @@ public:
|
|||
MoveFileSystemJob(Device& d, Partition& p, qint64 newstart);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual qint32 numSteps() const;
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual qint32 numSteps() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Partition& partition() {
|
||||
|
|
|
@ -40,9 +40,9 @@ public:
|
|||
ResizeFileSystemJob(Device& d, Partition& p, qint64 newlength = -1);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual qint32 numSteps() const;
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual qint32 numSteps() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
bool resizeFileSystemBackend(Report& report);
|
||||
|
|
|
@ -39,9 +39,9 @@ public:
|
|||
RestoreFileSystemJob(Device& targetdevice, Partition& targetpartition, const QString& filename);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual qint32 numSteps() const;
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual qint32 numSteps() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Partition& targetPartition() {
|
||||
|
|
|
@ -38,8 +38,8 @@ public:
|
|||
SetFileSystemLabelJob(Partition& p, const QString& newlabel);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Partition& partition() {
|
||||
|
|
|
@ -41,9 +41,9 @@ public:
|
|||
SetPartFlagsJob(Device& d, Partition& p, PartitionTable::Flags flags);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual qint32 numSteps() const;
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual qint32 numSteps() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Device& device() {
|
||||
|
|
|
@ -43,8 +43,8 @@ public:
|
|||
SetPartGeometryJob(Device& d, Partition& p, qint64 newstart, qint64 newlength);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Partition& partition() {
|
||||
|
|
|
@ -39,9 +39,9 @@ public:
|
|||
ShredFileSystemJob(Device& d, Partition& p, bool randomShred);
|
||||
|
||||
public:
|
||||
virtual bool run(Report& parent);
|
||||
virtual qint32 numSteps() const;
|
||||
virtual QString description() const;
|
||||
virtual bool run(Report& parent) override;
|
||||
virtual qint32 numSteps() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
protected:
|
||||
Partition& partition() {
|
||||
|
|
|
@ -42,17 +42,17 @@ public:
|
|||
BackupOperation(Device& targetDevice, Partition& backupPartition, const QString& filename);
|
||||
|
||||
public:
|
||||
QString iconName() const {
|
||||
QString iconName() const override {
|
||||
return QStringLiteral("document-export");
|
||||
}
|
||||
QString description() const;
|
||||
void preview() {}
|
||||
void undo() {}
|
||||
QString description() const override;
|
||||
void preview() override {}
|
||||
void undo() override {}
|
||||
|
||||
virtual bool targets(const Device&) const {
|
||||
virtual bool targets(const Device&) const override {
|
||||
return false;
|
||||
}
|
||||
virtual bool targets(const Partition&) const {
|
||||
virtual bool targets(const Partition&) const override{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,15 +45,15 @@ public:
|
|||
CheckOperation(Device& targetDevice, Partition& checkedPartition);
|
||||
|
||||
public:
|
||||
QString iconName() const {
|
||||
QString iconName() const override {
|
||||
return QStringLiteral("flag");
|
||||
}
|
||||
QString description() const;
|
||||
void preview() {}
|
||||
void undo() {}
|
||||
QString description() const override;
|
||||
void preview() override {}
|
||||
void undo() override {}
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
virtual bool targets(const Device& d) const override;
|
||||
virtual bool targets(const Partition& p) const override;
|
||||
|
||||
static bool canCheck(const Partition* p);
|
||||
|
||||
|
|
|
@ -55,19 +55,19 @@ public:
|
|||
~CopyOperation();
|
||||
|
||||
public:
|
||||
QString iconName() const {
|
||||
QString iconName() const override {
|
||||
return QStringLiteral("edit-copy");
|
||||
}
|
||||
QString description() const {
|
||||
QString description() const override {
|
||||
return m_Description;
|
||||
}
|
||||
|
||||
bool execute(Report& parent);
|
||||
void preview();
|
||||
void undo();
|
||||
bool execute(Report& parent) override;
|
||||
void preview() override;
|
||||
void undo() override;
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
virtual bool targets(const Device& d) const override;
|
||||
virtual bool targets(const Partition& p) const override;
|
||||
|
||||
static bool canCopy(const Partition* p);
|
||||
static bool canPaste(const Partition* p, const Partition* source);
|
||||
|
|
|
@ -53,16 +53,16 @@ public:
|
|||
~CreateFileSystemOperation();
|
||||
|
||||
public:
|
||||
QString iconName() const {
|
||||
QString iconName() const override {
|
||||
return QStringLiteral("draw-eraser");
|
||||
}
|
||||
QString description() const;
|
||||
void preview();
|
||||
void undo();
|
||||
bool execute(Report& parent);
|
||||
QString description() const override;
|
||||
void preview() override;
|
||||
void undo() override;
|
||||
bool execute(Report& parent) override;
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
virtual bool targets(const Device& d) const override;
|
||||
virtual bool targets(const Partition& p) const override;
|
||||
|
||||
protected:
|
||||
Device& targetDevice() {
|
||||
|
|
|
@ -49,16 +49,16 @@ public:
|
|||
~CreatePartitionTableOperation();
|
||||
|
||||
public:
|
||||
QString iconName() const {
|
||||
QString iconName() const override {
|
||||
return QStringLiteral("edit-clear");
|
||||
}
|
||||
QString description() const;
|
||||
void preview();
|
||||
void undo();
|
||||
bool execute(Report& parent);
|
||||
QString description() const override;
|
||||
void preview() override;
|
||||
void undo() override;
|
||||
bool execute(Report& parent) override;
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition&) const {
|
||||
virtual bool targets(const Device& d) const override;
|
||||
virtual bool targets(const Partition&) const override{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "core/partition.h"
|
||||
#include "core/device.h"
|
||||
#include "core/partitiontable.h"
|
||||
#include "fs/luks.h"
|
||||
|
||||
#include "jobs/deletepartitionjob.h"
|
||||
#include "jobs/deletefilesystemjob.h"
|
||||
|
@ -123,5 +124,16 @@ bool DeleteOperation::canDelete(const Partition* p)
|
|||
if (p->roles().has(PartitionRole::Extended))
|
||||
return p->children().size() == 1 && p->children()[0]->roles().has(PartitionRole::Unallocated);
|
||||
|
||||
if (p->roles().has(PartitionRole::Luks))
|
||||
{
|
||||
const FileSystem& fsRef = p->fileSystem();
|
||||
const FS::luks* luksFs = dynamic_cast<const FS::luks*>(&fsRef);
|
||||
if (!luksFs)
|
||||
return false;
|
||||
|
||||
if (luksFs->isCryptOpen() || luksFs->isMounted())
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -54,20 +54,20 @@ public:
|
|||
~DeleteOperation();
|
||||
|
||||
public:
|
||||
QString iconName() const {
|
||||
QString iconName() const override {
|
||||
return shredAction() == NoShred ?
|
||||
QStringLiteral("edit-delete") :
|
||||
QStringLiteral("edit-delete-shred");
|
||||
}
|
||||
QString description() const;
|
||||
void preview();
|
||||
void undo();
|
||||
QString description() const override;
|
||||
void preview() override;
|
||||
void undo() override;
|
||||
ShredAction shredAction() const {
|
||||
return m_ShredAction;
|
||||
}
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
virtual bool targets(const Device& d) const override;
|
||||
virtual bool targets(const Partition& p) const override;
|
||||
|
||||
static bool canDelete(const Partition* p);
|
||||
|
||||
|
|
|
@ -53,15 +53,15 @@ public:
|
|||
~NewOperation();
|
||||
|
||||
public:
|
||||
QString iconName() const {
|
||||
QString iconName() const override {
|
||||
return QStringLiteral("document-new");
|
||||
}
|
||||
QString description() const;
|
||||
void preview();
|
||||
void undo();
|
||||
QString description() const override;
|
||||
void preview() override;
|
||||
void undo() override;
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
virtual bool targets(const Device& d) const override;
|
||||
virtual bool targets(const Partition& p) const override;
|
||||
|
||||
static bool canCreateNew(const Partition* p);
|
||||
static Partition* createNew(const Partition& cloneFrom, FileSystem::Type type);
|
||||
|
|
|
@ -75,16 +75,16 @@ public:
|
|||
ResizeOperation(Device& d, Partition& p, qint64 newfirst, qint64 newlast);
|
||||
|
||||
public:
|
||||
QString iconName() const {
|
||||
QString iconName() const override {
|
||||
return QStringLiteral("arrow-right-double");
|
||||
}
|
||||
QString description() const;
|
||||
bool execute(Report& parent);
|
||||
void preview();
|
||||
void undo();
|
||||
QString description() const override;
|
||||
bool execute(Report& parent) override;
|
||||
void preview() override;
|
||||
void undo() override;
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
virtual bool targets(const Device& d) const override;
|
||||
virtual bool targets(const Partition& p) const override;
|
||||
|
||||
static bool canGrow(const Partition* p);
|
||||
static bool canShrink(const Partition* p);
|
||||
|
|
|
@ -56,17 +56,17 @@ public:
|
|||
~RestoreOperation();
|
||||
|
||||
public:
|
||||
QString iconName() const {
|
||||
QString iconName() const override {
|
||||
return QStringLiteral("document-import");
|
||||
}
|
||||
QString description() const;
|
||||
bool execute(Report& parent);
|
||||
void undo();
|
||||
QString description() const override;
|
||||
bool execute(Report& parent) override;
|
||||
void undo() override;
|
||||
|
||||
void preview();
|
||||
void preview() override;
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
virtual bool targets(const Device& d) const override;
|
||||
virtual bool targets(const Partition& p) const override;
|
||||
|
||||
static bool canRestore(const Partition* p);
|
||||
static Partition* createRestorePartition(const Device& device, PartitionNode& parent, qint64 start, const QString& fileName);
|
||||
|
|
|
@ -48,15 +48,15 @@ public:
|
|||
SetFileSystemLabelOperation(Partition& p, const QString& newlabel);
|
||||
|
||||
public:
|
||||
QString iconName() const {
|
||||
QString iconName() const override {
|
||||
return QStringLiteral("edit-rename");
|
||||
}
|
||||
QString description() const;
|
||||
void preview();
|
||||
void undo();
|
||||
QString description() const override;
|
||||
void preview() override;
|
||||
void undo() override;
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
virtual bool targets(const Device& d) const override;
|
||||
virtual bool targets(const Partition& p) const override;
|
||||
|
||||
protected:
|
||||
Partition& labeledPartition() {
|
||||
|
|
|
@ -51,15 +51,15 @@ public:
|
|||
SetPartFlagsOperation(Device& d, Partition& p, const PartitionTable::Flags& flags);
|
||||
|
||||
public:
|
||||
QString iconName() const {
|
||||
QString iconName() const override {
|
||||
return QStringLiteral("flag-blue");
|
||||
}
|
||||
QString description() const;
|
||||
void preview();
|
||||
void undo();
|
||||
QString description() const override;
|
||||
void preview() override;
|
||||
void undo() override;
|
||||
|
||||
virtual bool targets(const Device& d) const;
|
||||
virtual bool targets(const Partition& p) const;
|
||||
virtual bool targets(const Device& d) const override;
|
||||
virtual bool targets(const Partition& p) const override;
|
||||
|
||||
protected:
|
||||
Partition& flagPartition() {
|
||||
|
|
|
@ -42,7 +42,7 @@ private:
|
|||
DummyBackend(QObject* parent, const QList<QVariant>& args);
|
||||
|
||||
public:
|
||||
virtual void initFSSupport();
|
||||
virtual void initFSSupport() override;
|
||||
|
||||
virtual QList<Device*> scanDevices(bool excludeReadOnly = false) override;
|
||||
virtual CoreBackendDevice* openDevice(const QString& device_node) override;
|
||||
|
|
|
@ -37,16 +37,16 @@ public:
|
|||
~DummyDevice();
|
||||
|
||||
public:
|
||||
virtual bool open();
|
||||
virtual bool openExclusive();
|
||||
virtual bool close();
|
||||
virtual bool open() override;
|
||||
virtual bool openExclusive() override;
|
||||
virtual bool close() override;
|
||||
|
||||
virtual CoreBackendPartitionTable* openPartitionTable();
|
||||
virtual CoreBackendPartitionTable* openPartitionTable() override;
|
||||
|
||||
virtual bool createPartitionTable(Report& report, const PartitionTable& ptable);
|
||||
virtual bool createPartitionTable(Report& report, const PartitionTable& ptable) override;
|
||||
|
||||
virtual bool readSectors(void* buffer, qint64 offset, qint64 numSectors);
|
||||
virtual bool writeSectors(void* buffer, qint64 offset, qint64 numSectors);
|
||||
virtual bool readSectors(void* buffer, qint64 offset, qint64 numSectors) override;
|
||||
virtual bool writeSectors(void* buffer, qint64 offset, qint64 numSectors) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
DummyPartition();
|
||||
|
||||
public:
|
||||
virtual bool setFlag(Report& report, PartitionTable::Flag flag, bool state);
|
||||
virtual bool setFlag(Report& report, PartitionTable::Flag flag, bool state) override;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -36,20 +36,20 @@ public:
|
|||
~DummyPartitionTable();
|
||||
|
||||
public:
|
||||
virtual bool open();
|
||||
virtual bool open() override;
|
||||
|
||||
virtual bool commit(quint32 timeout = 10);
|
||||
virtual bool commit(quint32 timeout = 10) override;
|
||||
|
||||
virtual CoreBackendPartition* getExtendedPartition();
|
||||
virtual CoreBackendPartition* getPartitionBySector(qint64 sector);
|
||||
virtual CoreBackendPartition* getExtendedPartition() override;
|
||||
virtual CoreBackendPartition* getPartitionBySector(qint64 sector) override;
|
||||
|
||||
virtual QString createPartition(Report& report, const Partition& partition);
|
||||
virtual bool deletePartition(Report& report, const Partition& partition);
|
||||
virtual bool updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end);
|
||||
virtual bool clobberFileSystem(Report& report, const Partition& partition);
|
||||
virtual bool resizeFileSystem(Report& report, const Partition& partition, qint64 newLength);
|
||||
virtual FileSystem::Type detectFileSystemBySector(Report& report, const Device& device, qint64 sector);
|
||||
virtual bool setPartitionSystemType(Report& report, const Partition& partition);
|
||||
virtual QString createPartition(Report& report, const Partition& partition) override;
|
||||
virtual bool deletePartition(Report& report, const Partition& partition) override;
|
||||
virtual bool updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end) override;
|
||||
virtual bool clobberFileSystem(Report& report, const Partition& partition) override;
|
||||
virtual bool resizeFileSystem(Report& report, const Partition& partition, qint64 newLength) override;
|
||||
virtual FileSystem::Type detectFileSystemBySector(Report& report, const Device& device, qint64 sector) override;
|
||||
virtual bool setPartitionSystemType(Report& report, const Partition& partition) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,7 +34,7 @@ set (pmlibpartedbackendplugin_SRCS
|
|||
|
||||
add_library(pmlibpartedbackendplugin SHARED ${pmlibpartedbackendplugin_SRCS})
|
||||
|
||||
target_link_libraries(pmlibpartedbackendplugin kpmcore ${LIBPARTED_LIBS} ${BLKID_LIBRARIES} KF5::KIOCore KF5::I18n)
|
||||
target_link_libraries(pmlibpartedbackendplugin kpmcore ${LIBPARTED_LIBS} KF5::KIOCore KF5::I18n)
|
||||
|
||||
install(TARGETS pmlibpartedbackendplugin DESTINATION ${KDE_INSTALL_PLUGINDIR})
|
||||
kcoreaddons_desktop_to_json(pmlibpartedbackendplugin pmlibpartedbackendplugin.desktop)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2008-2012 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2015-2016 by Teo Mrnjavac <teo@kde.org> *
|
||||
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
|
||||
* Copyright (C) 2016 by Teo Mrnjavac <teo@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -50,7 +50,6 @@
|
|||
|
||||
#include <parted/parted.h>
|
||||
#include <unistd.h>
|
||||
#include <blkid/blkid.h>
|
||||
|
||||
K_PLUGIN_FACTORY_WITH_JSON(LibPartedBackendFactory, "pmlibpartedbackendplugin.json", registerPlugin<LibPartedBackend>();)
|
||||
|
||||
|
@ -215,7 +214,7 @@ static void readSectorsUsed(PedDisk* pedDisk, const Device& d, Partition& p, con
|
|||
|
||||
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
|
||||
|
||||
if (p.isMounted() && freeSpaceInfo.isValid() && mountPoint != QStringLiteral())
|
||||
if (p.isMounted() && freeSpaceInfo.isValid() && mountPoint != QString())
|
||||
p.fileSystem().setSectorsUsed(freeSpaceInfo.used() / d.logicalSectorSize());
|
||||
else if (p.fileSystem().supportGetUsed() == FileSystem::cmdSupportFileSystem)
|
||||
p.fileSystem().setSectorsUsed(p.fileSystem().readUsedCapacity(p.deviceNode()) / d.logicalSectorSize());
|
||||
|
@ -351,12 +350,36 @@ void LibPartedBackend::scanDevicePartitions(Device& d, PedDisk* pedDisk)
|
|||
|
||||
// libparted does not handle LUKS partitions
|
||||
QString mountPoint;
|
||||
bool mounted;
|
||||
if (fs->type() == FileSystem::Luks) {
|
||||
mountPoint = FS::luks::mapperName(node);
|
||||
mounted = (mountPoint != QString()) ? true : false;
|
||||
bool mounted = false;
|
||||
if (type == FileSystem::Luks) {
|
||||
r |= PartitionRole::Luks;
|
||||
FS::luks* luksFs = dynamic_cast<FS::luks*>(fs);
|
||||
QString mapperNode = FS::luks::mapperName(node);
|
||||
bool isCryptOpen = !mapperNode.isEmpty();
|
||||
luksFs->setCryptOpen(isCryptOpen);
|
||||
luksFs->setLogicalSectorSize(d.logicalSectorSize());
|
||||
|
||||
if (isCryptOpen) {
|
||||
luksFs->loadInnerFileSystem(mapperNode);
|
||||
|
||||
mountPoint = mountPoints.findByDevice(mapperNode) ?
|
||||
mountPoints.findByDevice(mapperNode)->mountPoint() :
|
||||
QString();
|
||||
// We cannot use libparted to check the mounted status because
|
||||
// we don't have a PedPartition for the mapper device, so we use
|
||||
// check_mount_point from util-linux instead, defined in the
|
||||
// private header ismounted.h and copied into KPMcore & wrapped
|
||||
// in helpers.h for convenience.
|
||||
mounted = isMounted(mapperNode);
|
||||
} else {
|
||||
mounted = false;
|
||||
}
|
||||
|
||||
luksFs->setMounted(mounted);
|
||||
} else {
|
||||
mountPoint = mountPoints.findByDevice(node) ? mountPoints.findByDevice(node)->mountPoint() : QString();
|
||||
mountPoint = mountPoints.findByDevice(node) ?
|
||||
mountPoints.findByDevice(node)->mountPoint() :
|
||||
QString();
|
||||
mounted = ped_partition_is_busy(pedPartition);
|
||||
}
|
||||
|
||||
|
@ -484,50 +507,12 @@ FileSystem::Type LibPartedBackend::detectFileSystem(PedPartition* pedPartition)
|
|||
{
|
||||
FileSystem::Type rval = FileSystem::Unknown;
|
||||
|
||||
blkid_cache cache;
|
||||
char* pedPath = nullptr;
|
||||
char* pedPath = ped_partition_get_path(pedPartition);
|
||||
|
||||
if (blkid_get_cache(&cache, nullptr) == 0 && (pedPath = ped_partition_get_path(pedPartition))) {
|
||||
blkid_dev dev;
|
||||
if (pedPath)
|
||||
rval = FileSystem::detectFileSystem(QString::fromUtf8(pedPath));
|
||||
|
||||
if ((dev = blkid_get_dev(cache, pedPath, BLKID_DEV_NORMAL)) != nullptr) {
|
||||
QString s = QString::fromUtf8(blkid_get_tag_value(cache, "TYPE", pedPath));
|
||||
if (s == QStringLiteral("ext2")) rval = FileSystem::Ext2;
|
||||
else if (s == QStringLiteral("ext3")) rval = FileSystem::Ext3;
|
||||
else if (s.startsWith(QStringLiteral("ext4"))) rval = FileSystem::Ext4;
|
||||
else if (s == QStringLiteral("swap")) rval = FileSystem::LinuxSwap;
|
||||
else if (s == QStringLiteral("ntfs")) rval = FileSystem::Ntfs;
|
||||
else if (s == QStringLiteral("reiserfs")) rval = FileSystem::ReiserFS;
|
||||
else if (s == QStringLiteral("reiser4")) rval = FileSystem::Reiser4;
|
||||
else if (s == QStringLiteral("xfs")) rval = FileSystem::Xfs;
|
||||
else if (s == QStringLiteral("jfs")) rval = FileSystem::Jfs;
|
||||
else if (s == QStringLiteral("hfs")) rval = FileSystem::Hfs;
|
||||
else if (s == QStringLiteral("hfsplus")) rval = FileSystem::HfsPlus;
|
||||
else if (s == QStringLiteral("ufs")) rval = FileSystem::Ufs;
|
||||
else if (s == QStringLiteral("vfat")) {
|
||||
// libblkid uses SEC_TYPE to distinguish between FAT16 and FAT32
|
||||
QString st = QString::fromUtf8(blkid_get_tag_value(cache, "SEC_TYPE", pedPath));
|
||||
if (st == QStringLiteral("msdos"))
|
||||
rval = FileSystem::Fat16;
|
||||
else
|
||||
rval = FileSystem::Fat32;
|
||||
} else if (s == QStringLiteral("btrfs")) rval = FileSystem::Btrfs;
|
||||
else if (s == QStringLiteral("ocfs2")) rval = FileSystem::Ocfs2;
|
||||
else if (s == QStringLiteral("zfs_member")) rval = FileSystem::Zfs;
|
||||
else if (s == QStringLiteral("hpfs")) rval = FileSystem::Hpfs;
|
||||
else if (s == QStringLiteral("crypto_LUKS")) rval = FileSystem::Luks;
|
||||
else if (s == QStringLiteral("exfat")) rval = FileSystem::Exfat;
|
||||
else if (s == QStringLiteral("nilfs2")) rval = FileSystem::Nilfs2;
|
||||
else if (s == QStringLiteral("LVM2_member")) rval = FileSystem::Lvm2_PV;
|
||||
else if (s == QStringLiteral("f2fs")) rval = FileSystem::F2fs;
|
||||
else
|
||||
qWarning() << "blkid: unknown file system type " << s << " on " << pedPath;
|
||||
}
|
||||
|
||||
blkid_put_cache(cache);
|
||||
|
||||
free(pedPath);
|
||||
}
|
||||
free(pedPath);
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*************************************************************************
|
||||
* Copyright (C) 2008, 2010 by Volker Lanz <vl@fidra.de> *
|
||||
* Copyright (C) 2015 by Teo Mrnjavac <teo@kde.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
|
@ -58,7 +59,7 @@ private:
|
|||
LibPartedBackend(QObject* parent, const QList<QVariant>& args);
|
||||
|
||||
public:
|
||||
virtual void initFSSupport();
|
||||
virtual void initFSSupport() override;
|
||||
|
||||
virtual CoreBackendDevice* openDevice(const QString& device_node) override;
|
||||
virtual CoreBackendDevice* openDeviceExclusive(const QString& device_node) override;
|
||||
|
|
|
@ -39,16 +39,16 @@ public:
|
|||
~LibPartedDevice();
|
||||
|
||||
public:
|
||||
virtual bool open();
|
||||
virtual bool openExclusive();
|
||||
virtual bool close();
|
||||
virtual bool open() override;
|
||||
virtual bool openExclusive() override;
|
||||
virtual bool close() override;
|
||||
|
||||
virtual CoreBackendPartitionTable* openPartitionTable();
|
||||
virtual CoreBackendPartitionTable* openPartitionTable() override;
|
||||
|
||||
virtual bool createPartitionTable(Report& report, const PartitionTable& ptable);
|
||||
virtual bool createPartitionTable(Report& report, const PartitionTable& ptable) override;
|
||||
|
||||
virtual bool readSectors(void* buffer, qint64 offset, qint64 numSectors);
|
||||
virtual bool writeSectors(void* buffer, qint64 offset, qint64 numSectors);
|
||||
virtual bool readSectors(void* buffer, qint64 offset, qint64 numSectors) override;
|
||||
virtual bool writeSectors(void* buffer, qint64 offset, qint64 numSectors) override;
|
||||
|
||||
protected:
|
||||
PedDevice* pedDevice() {
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
LibPartedPartition(PedPartition* ped_partition);
|
||||
|
||||
public:
|
||||
virtual bool setFlag(Report& report, PartitionTable::Flag flag, bool state);
|
||||
virtual bool setFlag(Report& report, PartitionTable::Flag flag, bool state) override;
|
||||
|
||||
private:
|
||||
PedPartition* pedPartition() {
|
||||
|
|
|
@ -38,21 +38,21 @@ public:
|
|||
~LibPartedPartitionTable();
|
||||
|
||||
public:
|
||||
virtual bool open();
|
||||
virtual bool open() override;
|
||||
|
||||
virtual bool commit(quint32 timeout = 10);
|
||||
virtual bool commit(quint32 timeout = 10) override;
|
||||
static bool commit(PedDisk* pd, quint32 timeout = 10);
|
||||
|
||||
virtual CoreBackendPartition* getExtendedPartition();
|
||||
virtual CoreBackendPartition* getPartitionBySector(qint64 sector);
|
||||
virtual CoreBackendPartition* getExtendedPartition() override;
|
||||
virtual CoreBackendPartition* getPartitionBySector(qint64 sector) override;
|
||||
|
||||
virtual QString createPartition(Report& report, const Partition& partition);
|
||||
virtual bool deletePartition(Report& report, const Partition& partition);
|
||||
virtual bool updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end);
|
||||
virtual bool clobberFileSystem(Report& report, const Partition& partition);
|
||||
virtual bool resizeFileSystem(Report& report, const Partition& partition, qint64 newLength);
|
||||
virtual FileSystem::Type detectFileSystemBySector(Report& report, const Device& device, qint64 sector);
|
||||
virtual bool setPartitionSystemType(Report& report, const Partition& partition);
|
||||
virtual QString createPartition(Report& report, const Partition& partition) override;
|
||||
virtual bool deletePartition(Report& report, const Partition& partition) override;
|
||||
virtual bool updateGeometry(Report& report, const Partition& partition, qint64 sector_start, qint64 sector_end) override;
|
||||
virtual bool clobberFileSystem(Report& report, const Partition& partition) override;
|
||||
virtual bool resizeFileSystem(Report& report, const Partition& partition, qint64 newLength) override;
|
||||
virtual FileSystem::Type detectFileSystemBySector(Report& report, const Device& device, qint64 sector) override;
|
||||
virtual bool setPartitionSystemType(Report& report, const Partition& partition) override;
|
||||
|
||||
private:
|
||||
PedDevice* pedDevice() {
|
||||
|
|
|
@ -17,9 +17,10 @@
|
|||
*************************************************************************/
|
||||
|
||||
#include "util/helpers.h"
|
||||
#include "../util/globallog.h"
|
||||
#include "util/externalcommand.h"
|
||||
#include "util/globallog.h"
|
||||
|
||||
#include "../ops/operation.h"
|
||||
#include "ops/operation.h"
|
||||
|
||||
#include <KAboutData>
|
||||
#include <KLocalizedString>
|
||||
|
@ -67,3 +68,18 @@ void showColumnsContextMenu(const QPoint& p, QTreeWidget& tree)
|
|||
tree.resizeColumnToContents(action->data().toInt());
|
||||
}
|
||||
}
|
||||
|
||||
bool isMounted(const QString& deviceNode)
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("lsblk"),
|
||||
{ QStringLiteral("--noheadings"),
|
||||
QStringLiteral("--nodeps"),
|
||||
QStringLiteral("--output"),
|
||||
QStringLiteral("mountpoint"),
|
||||
deviceNode });
|
||||
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
return !cmd.output().trimmed().isEmpty();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
|
||||
#define HELPERS__H
|
||||
|
||||
#include "../util/libpartitionmanagerexport.h"
|
||||
#include "fs/filesystem.h"
|
||||
|
||||
#include "../fs/filesystem.h"
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
class KAboutData;
|
||||
class QString;
|
||||
class QPoint;
|
||||
class QTreeWidget;
|
||||
|
@ -36,4 +35,6 @@ LIBKPMCORE_EXPORT void showColumnsContextMenu(const QPoint& p, QTreeWidget& tree
|
|||
|
||||
LIBKPMCORE_EXPORT bool checkAccessibleDevices();
|
||||
|
||||
LIBKPMCORE_EXPORT bool isMounted(const QString& deviceNode);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,400 +0,0 @@
|
|||
/*
|
||||
* ismounted.c --- Check to see if the filesystem was mounted
|
||||
*
|
||||
* Copyright (C) 1995,1996,1997,1998,1999,2000,2008 Theodore Ts'o.
|
||||
*
|
||||
* This file may be redistributed under the terms of the GNU Public
|
||||
* License.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef HAVE_MNTENT_H
|
||||
#include <mntent.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
#include <sys/param.h>
|
||||
#ifdef __APPLE__
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/mount.h>
|
||||
#endif
|
||||
|
||||
#include "pathnames.h"
|
||||
#include "ismounted.h"
|
||||
#ifdef __linux__
|
||||
# include "loopdev.h"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Fallback defines for old versions of glibc
|
||||
*/
|
||||
#ifdef O_CLOEXEC
|
||||
#define UL_CLOEXECSTR "e"
|
||||
#else
|
||||
#define UL_CLOEXECSTR ""
|
||||
#endif
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_MNTENT_H
|
||||
/*
|
||||
* Helper function which checks a file in /etc/mtab format to see if a
|
||||
* filesystem is mounted. Returns an error if the file doesn't exist
|
||||
* or can't be opened.
|
||||
*/
|
||||
static int check_mntent_file(const char *mtab_file, const char *file,
|
||||
int *mount_flags, char *mtpt, int mtlen)
|
||||
{
|
||||
struct mntent *mnt;
|
||||
struct stat st_buf;
|
||||
int retval = 0;
|
||||
dev_t file_dev=0, file_rdev=0;
|
||||
ino_t file_ino=0;
|
||||
FILE *f;
|
||||
int fd;
|
||||
|
||||
*mount_flags = 0;
|
||||
if ((f = setmntent (mtab_file, "r")) == NULL)
|
||||
return errno;
|
||||
|
||||
if (stat(file, &st_buf) == 0) {
|
||||
if (S_ISBLK(st_buf.st_mode)) {
|
||||
#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
|
||||
file_rdev = st_buf.st_rdev;
|
||||
#endif /* __GNU__ */
|
||||
} else {
|
||||
file_dev = st_buf.st_dev;
|
||||
file_ino = st_buf.st_ino;
|
||||
}
|
||||
}
|
||||
|
||||
while ((mnt = getmntent (f)) != NULL) {
|
||||
if (mnt->mnt_fsname[0] != '/')
|
||||
continue;
|
||||
if (strcmp(file, mnt->mnt_fsname) == 0)
|
||||
break;
|
||||
if (stat(mnt->mnt_fsname, &st_buf) != 0)
|
||||
continue;
|
||||
|
||||
if (S_ISBLK(st_buf.st_mode)) {
|
||||
#ifndef __GNU__
|
||||
if (file_rdev && file_rdev == st_buf.st_rdev)
|
||||
break;
|
||||
#ifdef __linux__
|
||||
/* maybe the file is loopdev backing file */
|
||||
if (file_dev
|
||||
&& major(st_buf.st_rdev) == LOOPDEV_MAJOR
|
||||
&& loopdev_is_used(mnt->mnt_fsname, file, 0, 0))
|
||||
break;
|
||||
#endif /* __linux__ */
|
||||
#endif /* __GNU__ */
|
||||
} else {
|
||||
if (file_dev && ((file_dev == st_buf.st_dev) &&
|
||||
(file_ino == st_buf.st_ino)))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mnt == NULL) {
|
||||
#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
|
||||
/*
|
||||
* Do an extra check to see if this is the root device. We
|
||||
* can't trust /etc/mtab, and /proc/mounts will only list
|
||||
* /dev/root for the root filesystem. Argh. Instead we
|
||||
* check if the given device has the same major/minor number
|
||||
* as the device that the root directory is on.
|
||||
*/
|
||||
if (file_rdev && stat("/", &st_buf) == 0 &&
|
||||
st_buf.st_dev == file_rdev) {
|
||||
*mount_flags = MF_MOUNTED;
|
||||
if (mtpt)
|
||||
strncpy(mtpt, "/", mtlen);
|
||||
goto is_root;
|
||||
}
|
||||
#endif /* __GNU__ */
|
||||
goto errout;
|
||||
}
|
||||
#ifndef __GNU__ /* The GNU hurd is deficient; what else is new? */
|
||||
/* Validate the entry in case /etc/mtab is out of date */
|
||||
/*
|
||||
* We need to be paranoid, because some broken distributions
|
||||
* (read: Slackware) don't initialize /etc/mtab before checking
|
||||
* all of the non-root filesystems on the disk.
|
||||
*/
|
||||
if (stat(mnt->mnt_dir, &st_buf) < 0) {
|
||||
retval = errno;
|
||||
if (retval == ENOENT) {
|
||||
#ifdef DEBUG
|
||||
printf("Bogus entry in %s! (%s does not exist)\n",
|
||||
mtab_file, mnt->mnt_dir);
|
||||
#endif /* DEBUG */
|
||||
retval = 0;
|
||||
}
|
||||
goto errout;
|
||||
}
|
||||
if (file_rdev && (st_buf.st_dev != file_rdev)) {
|
||||
#ifdef DEBUG
|
||||
printf("Bogus entry in %s! (%s not mounted on %s)\n",
|
||||
mtab_file, file, mnt->mnt_dir);
|
||||
#endif /* DEBUG */
|
||||
goto errout;
|
||||
}
|
||||
#endif /* __GNU__ */
|
||||
*mount_flags = MF_MOUNTED;
|
||||
|
||||
#ifdef MNTOPT_RO
|
||||
/* Check to see if the ro option is set */
|
||||
if (hasmntopt(mnt, MNTOPT_RO))
|
||||
*mount_flags |= MF_READONLY;
|
||||
#endif
|
||||
|
||||
if (mtpt)
|
||||
strncpy(mtpt, mnt->mnt_dir, mtlen);
|
||||
/*
|
||||
* Check to see if we're referring to the root filesystem.
|
||||
* If so, do a manual check to see if we can open /etc/mtab
|
||||
* read/write, since if the root is mounted read/only, the
|
||||
* contents of /etc/mtab may not be accurate.
|
||||
*/
|
||||
if (!strcmp(mnt->mnt_dir, "/")) {
|
||||
is_root:
|
||||
#define TEST_FILE "/.ismount-test-file"
|
||||
*mount_flags |= MF_ISROOT;
|
||||
fd = open(TEST_FILE, O_RDWR|O_CREAT|O_CLOEXEC, 0600);
|
||||
if (fd < 0) {
|
||||
if (errno == EROFS)
|
||||
*mount_flags |= MF_READONLY;
|
||||
} else
|
||||
close(fd);
|
||||
(void) unlink(TEST_FILE);
|
||||
}
|
||||
retval = 0;
|
||||
errout:
|
||||
endmntent (f);
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int check_mntent(const char *file, int *mount_flags,
|
||||
char *mtpt, int mtlen)
|
||||
{
|
||||
int retval;
|
||||
|
||||
#ifdef DEBUG
|
||||
retval = check_mntent_file("/tmp/mtab", file, mount_flags,
|
||||
mtpt, mtlen);
|
||||
if (retval == 0)
|
||||
return 0;
|
||||
#endif /* DEBUG */
|
||||
#ifdef __linux__
|
||||
retval = check_mntent_file("/proc/mounts", file, mount_flags,
|
||||
mtpt, mtlen);
|
||||
if (retval == 0 && (*mount_flags != 0))
|
||||
return 0;
|
||||
if (access("/proc/mounts", R_OK) == 0) {
|
||||
*mount_flags = 0;
|
||||
return retval;
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
#if defined(MOUNTED) || defined(_PATH_MOUNTED)
|
||||
#ifndef MOUNTED
|
||||
#define MOUNTED _PATH_MOUNTED
|
||||
#endif /* MOUNTED */
|
||||
retval = check_mntent_file(MOUNTED, file, mount_flags, mtpt, mtlen);
|
||||
return retval;
|
||||
#else
|
||||
*mount_flags = 0;
|
||||
return 0;
|
||||
#endif /* defined(MOUNTED) || defined(_PATH_MOUNTED) */
|
||||
}
|
||||
|
||||
#else
|
||||
#if defined(HAVE_GETMNTINFO)
|
||||
|
||||
static int check_getmntinfo(const char *file, int *mount_flags,
|
||||
char *mtpt, int mtlen)
|
||||
{
|
||||
struct statfs *mp;
|
||||
int len, n;
|
||||
const char *s1;
|
||||
char *s2;
|
||||
|
||||
n = getmntinfo(&mp, MNT_NOWAIT);
|
||||
if (n == 0)
|
||||
return errno;
|
||||
|
||||
len = sizeof(_PATH_DEV) - 1;
|
||||
s1 = file;
|
||||
if (strncmp(_PATH_DEV, s1, len) == 0)
|
||||
s1 += len;
|
||||
|
||||
*mount_flags = 0;
|
||||
while (--n >= 0) {
|
||||
s2 = mp->f_mntfromname;
|
||||
if (strncmp(_PATH_DEV, s2, len) == 0) {
|
||||
s2 += len - 1;
|
||||
*s2 = 'r';
|
||||
}
|
||||
if (strcmp(s1, s2) == 0 || strcmp(s1, &s2[1]) == 0) {
|
||||
*mount_flags = MF_MOUNTED;
|
||||
break;
|
||||
}
|
||||
++mp;
|
||||
}
|
||||
if (mtpt)
|
||||
strncpy(mtpt, mp->f_mntonname, mtlen);
|
||||
return 0;
|
||||
}
|
||||
#endif /* HAVE_GETMNTINFO */
|
||||
#endif /* HAVE_MNTENT_H */
|
||||
|
||||
/*
|
||||
* Check to see if we're dealing with the swap device.
|
||||
*/
|
||||
static int is_swap_device(const char *file)
|
||||
{
|
||||
FILE *f;
|
||||
char buf[1024], *cp;
|
||||
dev_t file_dev;
|
||||
struct stat st_buf;
|
||||
int ret = 0;
|
||||
|
||||
file_dev = 0;
|
||||
#ifndef __GNU__ /* The GNU hurd is broken with respect to stat devices */
|
||||
if ((stat(file, &st_buf) == 0) &&
|
||||
S_ISBLK(st_buf.st_mode))
|
||||
file_dev = st_buf.st_rdev;
|
||||
#endif /* __GNU__ */
|
||||
|
||||
if (!(f = fopen("/proc/swaps", "r" UL_CLOEXECSTR)))
|
||||
return 0;
|
||||
/* Skip the first line */
|
||||
if (!fgets(buf, sizeof(buf), f))
|
||||
goto leave;
|
||||
if (*buf && strncmp(buf, "Filename\t", 9))
|
||||
/* Linux <=2.6.19 contained a bug in the /proc/swaps
|
||||
* code where the header would not be displayed
|
||||
*/
|
||||
goto valid_first_line;
|
||||
|
||||
while (fgets(buf, sizeof(buf), f)) {
|
||||
valid_first_line:
|
||||
if ((cp = strchr(buf, ' ')) != NULL)
|
||||
*cp = 0;
|
||||
if ((cp = strchr(buf, '\t')) != NULL)
|
||||
*cp = 0;
|
||||
if (strcmp(buf, file) == 0) {
|
||||
ret++;
|
||||
break;
|
||||
}
|
||||
#ifndef __GNU__
|
||||
if (file_dev && (stat(buf, &st_buf) == 0) &&
|
||||
S_ISBLK(st_buf.st_mode) &&
|
||||
file_dev == st_buf.st_rdev) {
|
||||
ret++;
|
||||
break;
|
||||
}
|
||||
#endif /* __GNU__ */
|
||||
}
|
||||
|
||||
leave:
|
||||
fclose(f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* check_mount_point() fills determines if the device is mounted or otherwise
|
||||
* busy, and fills in mount_flags with one or more of the following flags:
|
||||
* MF_MOUNTED, MF_ISROOT, MF_READONLY, MF_SWAP, and MF_BUSY. If mtpt is
|
||||
* non-NULL, the directory where the device is mounted is copied to where mtpt
|
||||
* is pointing, up to mtlen characters.
|
||||
*/
|
||||
#ifdef __TURBOC__
|
||||
#pragma argsused
|
||||
#endif
|
||||
int check_mount_point(const char *device, int *mount_flags,
|
||||
char *mtpt, int mtlen)
|
||||
{
|
||||
struct stat st_buf;
|
||||
int retval = 0;
|
||||
int fd;
|
||||
|
||||
if (is_swap_device(device)) {
|
||||
*mount_flags = MF_MOUNTED | MF_SWAP;
|
||||
if (mtpt && mtlen)
|
||||
strncpy(mtpt, "[SWAP]", mtlen);
|
||||
} else {
|
||||
#ifdef HAVE_MNTENT_H
|
||||
retval = check_mntent(device, mount_flags, mtpt, mtlen);
|
||||
#else
|
||||
#ifdef HAVE_GETMNTINFO
|
||||
retval = check_getmntinfo(device, mount_flags, mtpt, mtlen);
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#warning "Can't use getmntent or getmntinfo to check for mounted filesystems!"
|
||||
#endif
|
||||
*mount_flags = 0;
|
||||
#endif /* HAVE_GETMNTINFO */
|
||||
#endif /* HAVE_MNTENT_H */
|
||||
}
|
||||
if (retval)
|
||||
return retval;
|
||||
|
||||
#ifdef __linux__ /* This only works on Linux 2.6+ systems */
|
||||
if ((stat(device, &st_buf) != 0) ||
|
||||
!S_ISBLK(st_buf.st_mode))
|
||||
return 0;
|
||||
fd = open(device, O_RDONLY|O_EXCL|O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
if (errno == EBUSY)
|
||||
*mount_flags |= MF_BUSY;
|
||||
} else
|
||||
close(fd);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_mounted(const char *file)
|
||||
{
|
||||
int retval;
|
||||
int mount_flags = 0;
|
||||
|
||||
retval = check_mount_point(file, &mount_flags, NULL, 0);
|
||||
if (retval)
|
||||
return 0;
|
||||
return mount_flags & MF_MOUNTED;
|
||||
}
|
||||
|
||||
#ifdef TEST_PROGRAM
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int flags = 0;
|
||||
char devname[PATH_MAX];
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Usage: %s device\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (check_mount_point(argv[1], &flags, devname, sizeof(devname)) == 0 &&
|
||||
(flags & MF_MOUNTED)) {
|
||||
if (flags & MF_SWAP)
|
||||
printf("used swap device\n");
|
||||
else
|
||||
printf("mounted on %s\n", devname);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
printf("not mounted\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif /* DEBUG */
|
|
@ -1,14 +0,0 @@
|
|||
#ifndef IS_MOUNTED_H
|
||||
#define IS_MOUNTED_H
|
||||
|
||||
#define MF_MOUNTED 1
|
||||
#define MF_ISROOT 2
|
||||
#define MF_READONLY 4
|
||||
#define MF_SWAP 8
|
||||
#define MF_BUSY 16
|
||||
|
||||
extern int is_mounted(const char *file);
|
||||
extern int check_mount_point(const char *device, int *mount_flags,
|
||||
char *mtpt, int mtlen);
|
||||
|
||||
#endif /* IS_MOUNTED_H */
|
|
@ -1,193 +0,0 @@
|
|||
#ifndef UTIL_LINUX_LOOPDEV_H
|
||||
#define UTIL_LINUX_LOOPDEV_H
|
||||
|
||||
#include "sysfs.h"
|
||||
|
||||
/*
|
||||
* loop_info.lo_encrypt_type
|
||||
*/
|
||||
#define LO_CRYPT_NONE 0
|
||||
#define LO_CRYPT_XOR 1
|
||||
#define LO_CRYPT_DES 2
|
||||
#define LO_CRYPT_CRYPTOAPI 18
|
||||
|
||||
#define LOOP_SET_FD 0x4C00
|
||||
#define LOOP_CLR_FD 0x4C01
|
||||
/*
|
||||
* Obsolete (kernel < 2.6)
|
||||
*
|
||||
* #define LOOP_SET_STATUS 0x4C02
|
||||
* #define LOOP_GET_STATUS 0x4C03
|
||||
*/
|
||||
#define LOOP_SET_STATUS64 0x4C04
|
||||
#define LOOP_GET_STATUS64 0x4C05
|
||||
/* #define LOOP_CHANGE_FD 0x4C06 */
|
||||
#define LOOP_SET_CAPACITY 0x4C07
|
||||
|
||||
/* /dev/loop-control interface */
|
||||
#ifndef LOOP_CTL_ADD
|
||||
# define LOOP_CTL_ADD 0x4C80
|
||||
# define LOOP_CTL_REMOVE 0x4C81
|
||||
# define LOOP_CTL_GET_FREE 0x4C82
|
||||
#endif
|
||||
|
||||
/*
|
||||
* loop_info.lo_flags
|
||||
*/
|
||||
enum {
|
||||
LO_FLAGS_READ_ONLY = 1,
|
||||
LO_FLAGS_USE_AOPS = 2,
|
||||
LO_FLAGS_AUTOCLEAR = 4, /* kernel >= 2.6.25 */
|
||||
LO_FLAGS_PARTSCAN = 8, /* kernel >= 3.2 */
|
||||
};
|
||||
|
||||
#define LO_NAME_SIZE 64
|
||||
#define LO_KEY_SIZE 32
|
||||
|
||||
/*
|
||||
* Linux LOOP_{SET,GET}_STATUS64 ioctl struct
|
||||
*/
|
||||
struct loop_info64 {
|
||||
uint64_t lo_device;
|
||||
uint64_t lo_inode;
|
||||
uint64_t lo_rdevice;
|
||||
uint64_t lo_offset;
|
||||
uint64_t lo_sizelimit; /* bytes, 0 == max available */
|
||||
uint32_t lo_number;
|
||||
uint32_t lo_encrypt_type;
|
||||
uint32_t lo_encrypt_key_size;
|
||||
uint32_t lo_flags;
|
||||
uint8_t lo_file_name[LO_NAME_SIZE];
|
||||
uint8_t lo_crypt_name[LO_NAME_SIZE];
|
||||
uint8_t lo_encrypt_key[LO_KEY_SIZE];
|
||||
uint64_t lo_init[2];
|
||||
};
|
||||
|
||||
#define LOOPDEV_MAJOR 7 /* loop major number */
|
||||
#define LOOPDEV_DEFAULT_NNODES 8 /* default number of loop devices */
|
||||
|
||||
struct loopdev_iter {
|
||||
FILE *proc; /* /proc/partitions */
|
||||
DIR *sysblock; /* /sys/block */
|
||||
int ncur; /* current position */
|
||||
int *minors; /* ary of minor numbers (when scan whole /dev) */
|
||||
int nminors; /* number of items in *minors */
|
||||
int ct_perm; /* count permission problems */
|
||||
int ct_succ; /* count number of detected devices */
|
||||
|
||||
unsigned int done:1; /* scanning done */
|
||||
unsigned int default_check:1;/* check first LOOPDEV_NLOOPS */
|
||||
int flags; /* LOOPITER_FL_* flags */
|
||||
};
|
||||
|
||||
enum {
|
||||
LOOPITER_FL_FREE = (1 << 0),
|
||||
LOOPITER_FL_USED = (1 << 1)
|
||||
};
|
||||
|
||||
/*
|
||||
* handler for work with loop devices
|
||||
*/
|
||||
struct loopdev_cxt {
|
||||
char device[128]; /* device path (e.g. /dev/loop<N>) */
|
||||
char *filename; /* backing file for loopcxt_set_... */
|
||||
int fd; /* open(/dev/looo<N>) */
|
||||
int mode; /* fd mode O_{RDONLY,RDWR} */
|
||||
|
||||
int flags; /* LOOPDEV_FL_* flags */
|
||||
unsigned int has_info:1; /* .info contains data */
|
||||
unsigned int extra_check:1; /* unusual stuff for iterator */
|
||||
unsigned int info_failed:1; /* LOOP_GET_STATUS ioctl failed */
|
||||
unsigned int control_ok:1; /* /dev/loop-control success */
|
||||
|
||||
struct sysfs_cxt sysfs; /* pointer to /sys/dev/block/<maj:min>/ */
|
||||
struct loop_info64 info; /* for GET/SET ioctl */
|
||||
struct loopdev_iter iter; /* scans /sys or /dev for used/free devices */
|
||||
};
|
||||
|
||||
#define UL_LOOPDEVCXT_EMPTY { .fd = -1, .sysfs = UL_SYSFSCXT_EMPTY }
|
||||
|
||||
/*
|
||||
* loopdev_cxt.flags
|
||||
*/
|
||||
enum {
|
||||
LOOPDEV_FL_RDONLY = (1 << 0), /* open(/dev/loop) mode; default */
|
||||
LOOPDEV_FL_RDWR = (1 << 1), /* necessary for loop setup only */
|
||||
LOOPDEV_FL_OFFSET = (1 << 4),
|
||||
LOOPDEV_FL_NOSYSFS = (1 << 5),
|
||||
LOOPDEV_FL_NOIOCTL = (1 << 6),
|
||||
LOOPDEV_FL_DEVSUBDIR = (1 << 7),
|
||||
LOOPDEV_FL_CONTROL = (1 << 8), /* system with /dev/loop-control */
|
||||
LOOPDEV_FL_SIZELIMIT = (1 << 9)
|
||||
};
|
||||
|
||||
/*
|
||||
* High-level
|
||||
*/
|
||||
extern int loopmod_supports_partscan(void);
|
||||
|
||||
extern int is_loopdev(const char *device);
|
||||
extern int loopdev_is_autoclear(const char *device);
|
||||
|
||||
extern char *loopdev_get_backing_file(const char *device);
|
||||
extern int loopdev_is_used(const char *device, const char *filename,
|
||||
uint64_t offset, int flags);
|
||||
extern char *loopdev_find_by_backing_file(const char *filename,
|
||||
uint64_t offset, int flags);
|
||||
extern int loopcxt_find_unused(struct loopdev_cxt *lc);
|
||||
extern int loopdev_delete(const char *device);
|
||||
extern int loopdev_count_by_backing_file(const char *filename, char **loopdev);
|
||||
|
||||
/*
|
||||
* Low-level
|
||||
*/
|
||||
extern int loopcxt_init(struct loopdev_cxt *lc, int flags)
|
||||
__attribute__ ((warn_unused_result));
|
||||
extern void loopcxt_deinit(struct loopdev_cxt *lc);
|
||||
|
||||
extern int loopcxt_set_device(struct loopdev_cxt *lc, const char *device)
|
||||
__attribute__ ((warn_unused_result));
|
||||
extern int loopcxt_has_device(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_add_device(struct loopdev_cxt *lc);
|
||||
extern char *loopcxt_strdup_device(struct loopdev_cxt *lc);
|
||||
extern const char *loopcxt_get_device(struct loopdev_cxt *lc);
|
||||
extern struct sysfs_cxt *loopcxt_get_sysfs(struct loopdev_cxt *lc);
|
||||
extern struct loop_info64 *loopcxt_get_info(struct loopdev_cxt *lc);
|
||||
|
||||
extern int loopcxt_get_fd(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_set_fd(struct loopdev_cxt *lc, int fd, int mode);
|
||||
|
||||
extern int loopcxt_init_iterator(struct loopdev_cxt *lc, int flags);
|
||||
extern int loopcxt_deinit_iterator(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_next(struct loopdev_cxt *lc);
|
||||
|
||||
extern int loopcxt_setup_device(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_delete_device(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_set_capacity(struct loopdev_cxt *lc);
|
||||
|
||||
int loopcxt_set_offset(struct loopdev_cxt *lc, uint64_t offset);
|
||||
int loopcxt_set_sizelimit(struct loopdev_cxt *lc, uint64_t sizelimit);
|
||||
int loopcxt_set_flags(struct loopdev_cxt *lc, uint32_t flags);
|
||||
int loopcxt_set_backing_file(struct loopdev_cxt *lc, const char *filename);
|
||||
|
||||
extern char *loopcxt_get_backing_file(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_get_backing_devno(struct loopdev_cxt *lc, dev_t *devno);
|
||||
extern int loopcxt_get_backing_inode(struct loopdev_cxt *lc, ino_t *ino);
|
||||
extern int loopcxt_get_offset(struct loopdev_cxt *lc, uint64_t *offset);
|
||||
extern int loopcxt_get_sizelimit(struct loopdev_cxt *lc, uint64_t *size);
|
||||
extern int loopcxt_get_encrypt_type(struct loopdev_cxt *lc, uint32_t *type);
|
||||
extern const char *loopcxt_get_crypt_name(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_is_autoclear(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_is_readonly(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_is_partscan(struct loopdev_cxt *lc);
|
||||
extern int loopcxt_find_by_backing_file(struct loopdev_cxt *lc,
|
||||
const char *filename,
|
||||
uint64_t offset, int flags);
|
||||
|
||||
extern int loopcxt_is_used(struct loopdev_cxt *lc,
|
||||
struct stat *st,
|
||||
const char *backing_file,
|
||||
uint64_t offset,
|
||||
int flags);
|
||||
|
||||
#endif /* UTIL_LINUX_LOOPDEV_H */
|
|
@ -1,212 +0,0 @@
|
|||
/*
|
||||
* Vaguely based on
|
||||
* @(#)pathnames.h 5.3 (Berkeley) 5/9/89
|
||||
* This code is in the public domain.
|
||||
*/
|
||||
#ifndef PATHNAMES_H
|
||||
#define PATHNAMES_H
|
||||
|
||||
#ifdef HAVE_PATHS_H
|
||||
#include <paths.h>
|
||||
#endif
|
||||
|
||||
#ifndef __STDC__
|
||||
# error "we need an ANSI compiler"
|
||||
#endif
|
||||
|
||||
/* used by kernel in /proc (e.g. /proc/swaps) for deleted files */
|
||||
#define PATH_DELETED_SUFFIX "\\040(deleted)"
|
||||
#define PATH_DELETED_SUFFIX_SZ (sizeof(PATH_DELETED_SUFFIX) - 1)
|
||||
|
||||
/* DEFPATHs from <paths.h> don't include /usr/local */
|
||||
#undef _PATH_DEFPATH
|
||||
|
||||
#ifdef USE_USRDIR_PATHS_ONLY
|
||||
# define _PATH_DEFPATH "/usr/local/bin:/usr/bin"
|
||||
#else
|
||||
# define _PATH_DEFPATH "/usr/local/bin:/bin:/usr/bin"
|
||||
#endif
|
||||
|
||||
#undef _PATH_DEFPATH_ROOT
|
||||
|
||||
#ifdef USE_USRDIR_PATHS_ONLY
|
||||
# define _PATH_DEFPATH_ROOT "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
|
||||
#else
|
||||
# define _PATH_DEFPATH_ROOT "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
|
||||
#endif
|
||||
|
||||
#define _PATH_SECURETTY "/etc/securetty"
|
||||
#define _PATH_WTMPLOCK "/etc/wtmplock"
|
||||
|
||||
#define _PATH_HUSHLOGIN ".hushlogin"
|
||||
#define _PATH_HUSHLOGINS "/etc/hushlogins"
|
||||
|
||||
#define _PATH_NOLOGIN_TXT "/etc/nologin.txt"
|
||||
|
||||
#ifndef _PATH_MAILDIR
|
||||
#define _PATH_MAILDIR "/var/spool/mail"
|
||||
#endif
|
||||
#define _PATH_MOTDFILE "/etc/motd"
|
||||
#define _PATH_NOLOGIN "/etc/nologin"
|
||||
#define _PATH_VAR_NOLOGIN "/var/run/nologin"
|
||||
|
||||
#define _PATH_LOGIN "/bin/login"
|
||||
#define _PATH_INITTAB "/etc/inittab"
|
||||
#define _PATH_RC "/etc/rc"
|
||||
#define _PATH_REBOOT "/sbin/reboot"
|
||||
#define _PATH_SHUTDOWN "/sbin/shutdown"
|
||||
#define _PATH_SINGLE "/etc/singleboot"
|
||||
#define _PATH_SHUTDOWN_CONF "/etc/shutdown.conf"
|
||||
|
||||
#define _PATH_SECURE "/etc/securesingle"
|
||||
#define _PATH_USERTTY "/etc/usertty"
|
||||
|
||||
#define _PATH_TERMCOLORS_DIRNAME "terminal-colors.d"
|
||||
#define _PATH_TERMCOLORS_DIR "/etc/" _PATH_TERMCOLORS_DIRNAME
|
||||
|
||||
/* used in login-utils/shutdown.c */
|
||||
|
||||
/* used in login-utils/setpwnam.h and login-utils/islocal.c */
|
||||
#define _PATH_PASSWD "/etc/passwd"
|
||||
|
||||
/* used in login-utils/newgrp and login-utils/setpwnam.h*/
|
||||
#define _PATH_GSHADOW "/etc/gshadow"
|
||||
|
||||
/* used in login-utils/setpwnam.h */
|
||||
#define _PATH_GROUP "/etc/group"
|
||||
#define _PATH_SHADOW_PASSWD "/etc/shadow"
|
||||
#define _PATH_SHELLS "/etc/shells"
|
||||
|
||||
/* used in term-utils/agetty.c */
|
||||
#define _PATH_ISSUE "/etc/issue"
|
||||
#define _PATH_OS_RELEASE_ETC "/etc/os-release"
|
||||
#define _PATH_OS_RELEASE_USR "/usr/lib/os-release"
|
||||
|
||||
#define _PATH_NUMLOCK_ON _PATH_LOCALSTATEDIR "/numlock-on"
|
||||
|
||||
#define _PATH_LOGINDEFS "/etc/login.defs"
|
||||
|
||||
/* used in misc-utils/look.c */
|
||||
#define _PATH_WORDS "/usr/share/dict/words"
|
||||
#define _PATH_WORDS_ALT "/usr/share/dict/web2"
|
||||
|
||||
/* mount paths */
|
||||
#define _PATH_UMOUNT "/bin/umount"
|
||||
|
||||
#define _PATH_FILESYSTEMS "/etc/filesystems"
|
||||
#define _PATH_PROC_SWAPS "/proc/swaps"
|
||||
#define _PATH_PROC_FILESYSTEMS "/proc/filesystems"
|
||||
#define _PATH_PROC_MOUNTS "/proc/mounts"
|
||||
#define _PATH_PROC_PARTITIONS "/proc/partitions"
|
||||
#define _PATH_PROC_DEVICES "/proc/devices"
|
||||
#define _PATH_PROC_MOUNTINFO "/proc/self/mountinfo"
|
||||
#define _PATH_PROC_LOCKS "/proc/locks"
|
||||
#define _PATH_PROC_CDROMINFO "/proc/sys/dev/cdrom/info"
|
||||
|
||||
#define _PATH_PROC_UIDMAP "/proc/self/uid_map"
|
||||
#define _PATH_PROC_GIDMAP "/proc/self/gid_map"
|
||||
#define _PATH_PROC_SETGROUPS "/proc/self/setgroups"
|
||||
|
||||
#define _PATH_PROC_ATTR_CURRENT "/proc/self/attr/current"
|
||||
#define _PATH_PROC_ATTR_EXEC "/proc/self/attr/exec"
|
||||
#define _PATH_PROC_CAPLASTCAP "/proc/sys/kernel/cap_last_cap"
|
||||
|
||||
|
||||
#define _PATH_SYS_BLOCK "/sys/block"
|
||||
#define _PATH_SYS_DEVBLOCK "/sys/dev/block"
|
||||
#define _PATH_SYS_CLASS "/sys/class"
|
||||
#define _PATH_SYS_SCSI "/sys/bus/scsi"
|
||||
|
||||
#define _PATH_SYS_SELINUX "/sys/fs/selinux"
|
||||
#define _PATH_SYS_APPARMOR "/sys/kernel/security/apparmor"
|
||||
|
||||
#ifndef _PATH_MOUNTED
|
||||
# ifdef MOUNTED /* deprecated */
|
||||
# define _PATH_MOUNTED MOUNTED
|
||||
# else
|
||||
# define _PATH_MOUNTED "/etc/mtab"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_MNTTAB
|
||||
# ifdef MNTTAB /* deprecated */
|
||||
# define _PATH_MNTTAB MNTTAB
|
||||
# else
|
||||
# define _PATH_MNTTAB "/etc/fstab"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define _PATH_MNTTAB_DIR _PATH_MNTTAB ".d"
|
||||
|
||||
#define _PATH_MOUNTED_LOCK _PATH_MOUNTED "~"
|
||||
#define _PATH_MOUNTED_TMP _PATH_MOUNTED ".tmp"
|
||||
|
||||
#ifndef _PATH_DEV
|
||||
/*
|
||||
* The tailing '/' in _PATH_DEV is there for compatibility with libc.
|
||||
*/
|
||||
# define _PATH_DEV "/dev/"
|
||||
#endif
|
||||
|
||||
#define _PATH_DEV_MEM "/dev/mem"
|
||||
|
||||
#define _PATH_DEV_LOOP "/dev/loop"
|
||||
#define _PATH_DEV_LOOPCTL "/dev/loop-control"
|
||||
#define _PATH_DEV_TTY "/dev/tty"
|
||||
|
||||
|
||||
/* udev paths */
|
||||
#define _PATH_DEV_BYLABEL "/dev/disk/by-label"
|
||||
#define _PATH_DEV_BYUUID "/dev/disk/by-uuid"
|
||||
#define _PATH_DEV_BYID "/dev/disk/by-id"
|
||||
#define _PATH_DEV_BYPATH "/dev/disk/by-path"
|
||||
#define _PATH_DEV_BYPARTLABEL "/dev/disk/by-partlabel"
|
||||
#define _PATH_DEV_BYPARTUUID "/dev/disk/by-partuuid"
|
||||
|
||||
/* hwclock paths */
|
||||
#ifdef CONFIG_ADJTIME_PATH
|
||||
# define _PATH_ADJTIME CONFIG_ADJTIME_PATH
|
||||
#else
|
||||
# define _PATH_ADJTIME "/etc/adjtime"
|
||||
#endif
|
||||
|
||||
#define _PATH_LASTDATE "/var/lib/lastdate"
|
||||
#ifdef __ia64__
|
||||
# define _PATH_RTC_DEV "/dev/efirtc"
|
||||
#else
|
||||
# define _PATH_RTC_DEV "/dev/rtc"
|
||||
#endif
|
||||
|
||||
#ifndef _PATH_BTMP
|
||||
#define _PATH_BTMP "/var/log/btmp"
|
||||
#endif
|
||||
|
||||
/* raw paths*/
|
||||
#define _PATH_RAWDEVDIR "/dev/raw/"
|
||||
#define _PATH_RAWDEVCTL _PATH_RAWDEVDIR "rawctl"
|
||||
/* deprecated */
|
||||
#define _PATH_RAWDEVCTL_OLD "/dev/rawctl"
|
||||
|
||||
/* wdctl path */
|
||||
#define _PATH_WATCHDOG_DEV "/dev/watchdog"
|
||||
|
||||
/* ipc paths */
|
||||
#define _PATH_PROC_SYSV_MSG "/proc/sysvipc/msg"
|
||||
#define _PATH_PROC_SYSV_SEM "/proc/sysvipc/sem"
|
||||
#define _PATH_PROC_SYSV_SHM "/proc/sysvipc/shm"
|
||||
#define _PATH_PROC_IPC_MSGMAX "/proc/sys/kernel/msgmax"
|
||||
#define _PATH_PROC_IPC_MSGMNB "/proc/sys/kernel/msgmnb"
|
||||
#define _PATH_PROC_IPC_MSGMNI "/proc/sys/kernel/msgmni"
|
||||
#define _PATH_PROC_IPC_SEM "/proc/sys/kernel/sem"
|
||||
#define _PATH_PROC_IPC_SHMALL "/proc/sys/kernel/shmall"
|
||||
#define _PATH_PROC_IPC_SHMMAX "/proc/sys/kernel/shmmax"
|
||||
#define _PATH_PROC_IPC_SHMMNI "/proc/sys/kernel/shmmni"
|
||||
|
||||
/* kernel command line */
|
||||
#define _PATH_PROC_CMDLINE "/proc/cmdline"
|
||||
|
||||
/* logger paths */
|
||||
#define _PATH_DEVLOG "/dev/log"
|
||||
|
||||
#endif /* PATHNAMES_H */
|
||||
|
127
src/util/sysfs.h
127
src/util/sysfs.h
|
@ -1,127 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2011 Karel Zak <kzak@redhat.com>
|
||||
*/
|
||||
#ifndef UTIL_LINUX_SYSFS_H
|
||||
#define UTIL_LINUX_SYSFS_H
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <dirent.h>
|
||||
|
||||
struct sysfs_cxt {
|
||||
dev_t devno;
|
||||
int dir_fd; /* /sys/block/<name> */
|
||||
char *dir_path;
|
||||
struct sysfs_cxt *parent;
|
||||
|
||||
unsigned int scsi_host,
|
||||
scsi_channel,
|
||||
scsi_target,
|
||||
scsi_lun;
|
||||
|
||||
unsigned int has_hctl : 1;
|
||||
};
|
||||
|
||||
#define UL_SYSFSCXT_EMPTY { 0, -1, NULL, NULL, 0, 0, 0, 0, 0 }
|
||||
|
||||
extern char *sysfs_devno_attribute_path(dev_t devno, char *buf,
|
||||
size_t bufsiz, const char *attr);
|
||||
extern int sysfs_devno_has_attribute(dev_t devno, const char *attr);
|
||||
extern char *sysfs_devno_path(dev_t devno, char *buf, size_t bufsiz);
|
||||
extern char *sysfs_devno_to_devpath(dev_t devno, char *buf, size_t bufsiz);
|
||||
extern dev_t sysfs_devname_to_devno(const char *name, const char *parent);
|
||||
|
||||
extern int sysfs_init(struct sysfs_cxt *cxt, dev_t devno, struct sysfs_cxt *parent)
|
||||
__attribute__ ((warn_unused_result));
|
||||
extern void sysfs_deinit(struct sysfs_cxt *cxt);
|
||||
|
||||
extern DIR *sysfs_opendir(struct sysfs_cxt *cxt, const char *attr);
|
||||
|
||||
extern int sysfs_stat(struct sysfs_cxt *cxt, const char *attr, struct stat *st);
|
||||
extern ssize_t sysfs_readlink(struct sysfs_cxt *cxt, const char *attr,
|
||||
char *buf, size_t bufsiz);
|
||||
extern int sysfs_has_attribute(struct sysfs_cxt *cxt, const char *attr);
|
||||
|
||||
extern int sysfs_scanf(struct sysfs_cxt *cxt, const char *attr,
|
||||
const char *fmt, ...)
|
||||
__attribute__ ((format (scanf, 3, 4)));
|
||||
|
||||
extern int sysfs_read_s64(struct sysfs_cxt *cxt, const char *attr, int64_t *res);
|
||||
extern int sysfs_read_u64(struct sysfs_cxt *cxt, const char *attr, uint64_t *res);
|
||||
extern int sysfs_read_int(struct sysfs_cxt *cxt, const char *attr, int *res);
|
||||
|
||||
extern int sysfs_write_string(struct sysfs_cxt *cxt, const char *attr, const char *str);
|
||||
extern int sysfs_write_u64(struct sysfs_cxt *cxt, const char *attr, uint64_t num);
|
||||
|
||||
extern char *sysfs_get_devname(struct sysfs_cxt *cxt, char *buf, size_t bufsiz);
|
||||
|
||||
extern char *sysfs_strdup(struct sysfs_cxt *cxt, const char *attr);
|
||||
|
||||
extern int sysfs_count_dirents(struct sysfs_cxt *cxt, const char *attr);
|
||||
extern int sysfs_count_partitions(struct sysfs_cxt *cxt, const char *devname);
|
||||
extern dev_t sysfs_partno_to_devno(struct sysfs_cxt *cxt, int partno);
|
||||
extern char *sysfs_get_slave(struct sysfs_cxt *cxt);
|
||||
|
||||
extern char *sysfs_get_devchain(struct sysfs_cxt *cxt, char *buf, size_t bufsz);
|
||||
extern int sysfs_next_subsystem(struct sysfs_cxt *cxt, char *devchain, char **subsys);
|
||||
extern int sysfs_is_hotpluggable(struct sysfs_cxt *cxt);
|
||||
|
||||
extern int sysfs_is_partition_dirent(DIR *dir, struct dirent *d,
|
||||
const char *parent_name);
|
||||
|
||||
extern int sysfs_devno_to_wholedisk(dev_t dev, char *diskname,
|
||||
size_t len, dev_t *diskdevno);
|
||||
|
||||
extern int sysfs_devno_is_lvm_private(dev_t devno);
|
||||
extern int sysfs_devno_is_wholedisk(dev_t devno);
|
||||
|
||||
extern int sysfs_scsi_get_hctl(struct sysfs_cxt *cxt, int *h,
|
||||
int *c, int *t, int *l);
|
||||
extern char *sysfs_scsi_host_strdup_attribute(struct sysfs_cxt *cxt,
|
||||
const char *type, const char *attr);
|
||||
extern int sysfs_scsi_host_is(struct sysfs_cxt *cxt, const char *type);
|
||||
extern int sysfs_scsi_has_attribute(struct sysfs_cxt *cxt, const char *attr);
|
||||
extern int sysfs_scsi_path_contains(struct sysfs_cxt *cxt, const char *pattern);
|
||||
|
||||
/**
|
||||
* sysfs_devname_sys_to_dev:
|
||||
* @name: devname to be converted in place
|
||||
*
|
||||
* Linux kernel linux/drivers/base/core.c: device_get_devnode()
|
||||
* defines a replacement of '!' in the /sys device name by '/' in the
|
||||
* /dev device name. This helper replaces all ocurrences of '!' in
|
||||
* @name by '/' to convert from /sys to /dev.
|
||||
*/
|
||||
static inline void sysfs_devname_sys_to_dev(char *name)
|
||||
{
|
||||
char *c;
|
||||
|
||||
if (name)
|
||||
while ((c = strchr(name, '!')))
|
||||
c[0] = '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* sysfs_devname_dev_to_sys:
|
||||
* @name: devname to be converted in place
|
||||
*
|
||||
* See sysfs_devname_sys_to_dev().
|
||||
*/
|
||||
static inline void sysfs_devname_dev_to_sys(char *name)
|
||||
{
|
||||
char *c;
|
||||
|
||||
if (name)
|
||||
while ((c = strchr(name, '/')))
|
||||
c[0] = '!';
|
||||
}
|
||||
|
||||
#endif /* UTIL_LINUX_SYSFS_H */
|
Loading…
Reference in New Issue