2018-07-10 00:01:34 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* Copyright (C) 2018 by Caio Carvalho <caiojcarvalho@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#if !defined(KPMCORE_SOFTWARERAID_H)
|
|
|
|
#define KPMCORE_SOFTWARERAID_H
|
|
|
|
|
|
|
|
#include "core/volumemanagerdevice.h"
|
|
|
|
#include "util/libpartitionmanagerexport.h"
|
|
|
|
#include "util/report.h"
|
|
|
|
|
|
|
|
class LIBKPMCORE_EXPORT SoftwareRAID : public VolumeManagerDevice
|
|
|
|
{
|
|
|
|
Q_DISABLE_COPY(SoftwareRAID)
|
|
|
|
|
|
|
|
public:
|
2018-07-15 17:11:50 +01:00
|
|
|
enum class Status {
|
|
|
|
Active,
|
|
|
|
Inactive,
|
|
|
|
Resync,
|
|
|
|
Recovery,
|
|
|
|
};
|
|
|
|
|
|
|
|
SoftwareRAID(const QString& name,
|
|
|
|
SoftwareRAID::Status status = SoftwareRAID::Status::Active,
|
|
|
|
const QString& iconName = QString());
|
2018-07-10 00:01:34 +01:00
|
|
|
|
|
|
|
const QStringList deviceNodes() const override;
|
|
|
|
const QStringList& partitionNodes() const override;
|
|
|
|
qint64 partitionSize(QString &partitionPath) const override;
|
|
|
|
|
|
|
|
virtual bool growArray(Report& report, const QStringList& devices);
|
|
|
|
|
|
|
|
virtual bool shrinkArray(Report& report, const QStringList& devices);
|
|
|
|
|
2018-07-13 21:56:13 +01:00
|
|
|
virtual QString prettyName() const override;
|
|
|
|
|
2018-07-15 14:31:27 +01:00
|
|
|
virtual bool operator==(const Device& other) const override;
|
|
|
|
|
2018-07-11 16:03:44 +01:00
|
|
|
qint32 raidLevel() const;
|
|
|
|
qint64 chunkSize() const;
|
|
|
|
qint64 totalChunk() const;
|
|
|
|
qint64 arraySize() const;
|
|
|
|
QString uuid() const;
|
|
|
|
QStringList devicePathList() const;
|
2018-07-15 17:11:50 +01:00
|
|
|
SoftwareRAID::Status status() const;
|
2018-07-15 14:31:27 +01:00
|
|
|
|
2018-07-15 17:11:50 +01:00
|
|
|
void setStatus(SoftwareRAID::Status status);
|
2018-07-11 16:03:44 +01:00
|
|
|
|
2018-07-10 00:01:34 +01:00
|
|
|
public:
|
|
|
|
static void scanSoftwareRAID(QList<Device*>& devices);
|
|
|
|
|
|
|
|
static qint32 getRaidLevel(const QString& path);
|
|
|
|
static qint64 getChunkSize(const QString& path);
|
|
|
|
static qint64 getTotalChunk(const QString& path);
|
|
|
|
static qint64 getArraySize(const QString& path);
|
|
|
|
static QString getUUID(const QString& path);
|
|
|
|
static QStringList getDevicePathList(const QString& path);
|
|
|
|
|
2018-07-11 03:03:21 +01:00
|
|
|
static bool isRaidPath(const QString& path);
|
|
|
|
|
2018-07-10 00:01:34 +01:00
|
|
|
static bool createSoftwareRAID(Report& report,
|
|
|
|
const QString& name,
|
|
|
|
const QStringList devicePathList,
|
|
|
|
const qint32 raidLevel,
|
|
|
|
const qint32 chunkSize);
|
|
|
|
|
|
|
|
static bool deleteSoftwareRAID(Report& report,
|
|
|
|
SoftwareRAID& raidDevice);
|
|
|
|
|
2018-07-12 18:38:52 +01:00
|
|
|
static bool assembleSoftwareRAID(const QString& deviceNode);
|
2018-07-10 00:01:34 +01:00
|
|
|
|
2018-07-12 18:38:52 +01:00
|
|
|
static bool stopSoftwareRAID(const QString& deviceNode);
|
|
|
|
|
|
|
|
static bool reassembleSoftwareRAID(const QString& deviceNode);
|
2018-07-10 00:01:34 +01:00
|
|
|
|
2018-07-15 23:38:33 +01:00
|
|
|
static bool isRaidMember(const QString& path);
|
|
|
|
|
2018-07-10 00:01:34 +01:00
|
|
|
protected:
|
|
|
|
void initPartitions() override;
|
|
|
|
|
|
|
|
qint64 mappedSector(const QString &partitionPath, qint64 sector) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
static QString getDetail(const QString& path);
|
2018-07-15 14:31:27 +01:00
|
|
|
|
|
|
|
static QString getRAIDConfiguration(const QString& configurationPath);
|
2018-07-10 00:01:34 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SOFTWARERAID_H
|