Initial Device separation
This commit is contained in:
parent
f53cc1b55c
commit
fcc8a7c992
|
@ -15,6 +15,7 @@ set(CORE_SRC
|
||||||
core/devicescanner.cpp
|
core/devicescanner.cpp
|
||||||
core/partitionnode.cpp
|
core/partitionnode.cpp
|
||||||
core/partitionalignment.cpp
|
core/partitionalignment.cpp
|
||||||
|
core/diskdevice.cpp
|
||||||
core/device.cpp
|
core/device.cpp
|
||||||
core/operationstack.cpp
|
core/operationstack.cpp
|
||||||
core/partitionrole.cpp
|
core/partitionrole.cpp
|
||||||
|
@ -25,6 +26,7 @@ set(CORE_LIB_HDRS
|
||||||
core/copysourcedevice.h
|
core/copysourcedevice.h
|
||||||
core/copytarget.h
|
core/copytarget.h
|
||||||
core/copytargetdevice.h
|
core/copytargetdevice.h
|
||||||
|
core/diskdevice.h
|
||||||
core/device.h
|
core/device.h
|
||||||
core/devicescanner.h
|
core/devicescanner.h
|
||||||
core/mountentry.h
|
core/mountentry.h
|
||||||
|
|
|
@ -60,7 +60,7 @@ bool CopySourceDevice::open()
|
||||||
*/
|
*/
|
||||||
qint32 CopySourceDevice::sectorSize() const
|
qint32 CopySourceDevice::sectorSize() const
|
||||||
{
|
{
|
||||||
return device().logicalSectorSize();
|
return device().logicalSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the length of this CopySource
|
/** Returns the length of this CopySource
|
||||||
|
|
|
@ -56,7 +56,7 @@ bool CopyTargetDevice::open()
|
||||||
/** @return the Device's sector size */
|
/** @return the Device's sector size */
|
||||||
qint32 CopyTargetDevice::sectorSize() const
|
qint32 CopyTargetDevice::sectorSize() const
|
||||||
{
|
{
|
||||||
return device().logicalSectorSize();
|
return device().logicalSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Writes the given number of sectors to the Device.
|
/** Writes the given number of sectors to the Device.
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
#include "core/device.h"
|
#include "core/device.h"
|
||||||
|
|
||||||
#include "core/partitiontable.h"
|
#include "core/partitiontable.h"
|
||||||
#include "core/smartstatus.h"
|
#include "core/smartstatus.h"
|
||||||
|
|
||||||
|
@ -25,73 +24,25 @@
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
#include <QFile>
|
|
||||||
#include <QByteArray>
|
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <linux/fs.h>
|
|
||||||
|
|
||||||
#if !defined(BLKPBSZGET)
|
|
||||||
#define BLKPBSZGET _IO(0x12,123)/* get block physical sector size */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static qint32 getPhysicalSectorSize(const QString& device_node)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* possible ways of getting the physical sector size for a drive:
|
|
||||||
* - ioctl(BLKPBSZGET) -- supported with Linux 2.6.32 and later
|
|
||||||
* - /sys/block/sda/queue/physical_block_size
|
|
||||||
* - libblkid from util-linux-ng 2.17 or later
|
|
||||||
* TODO: implement the blkid method
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined(BLKPBSZGET)
|
|
||||||
int phSectorSize = -1;
|
|
||||||
int fd = open(device_node.toLocal8Bit().constData(), O_RDONLY);
|
|
||||||
if (fd != -1) {
|
|
||||||
if (ioctl(fd, BLKPBSZGET, &phSectorSize) >= 0) {
|
|
||||||
close(fd);
|
|
||||||
return phSectorSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QFile f(QStringLiteral("/sys/block/%1/queue/physical_block_size").arg(QString(device_node).remove(QStringLiteral("/dev/"))));
|
|
||||||
|
|
||||||
if (f.open(QIODevice::ReadOnly)) {
|
|
||||||
QByteArray a = f.readLine();
|
|
||||||
return a.trimmed().toInt();
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Constructs a Device with an empty PartitionTable.
|
/** Constructs a Device with an empty PartitionTable.
|
||||||
@param name the Device's name, usually some string defined by the manufacturer
|
@param name the Device's name, usually some string defined by the manufacturer
|
||||||
@param devicenode the Device's node, for example "/dev/sda"
|
@param devicenode the Device's node, for example "/dev/sda"
|
||||||
@param heads the number of heads in CHS notation
|
|
||||||
@param numSectors the number of sectors in CHS notation
|
|
||||||
@param cylinders the number of cylinders in CHS notation
|
|
||||||
@param sectorSize the size of a sector in bytes
|
|
||||||
*/
|
*/
|
||||||
Device::Device(const QString& name, const QString& devicenode, qint32 heads, qint32 numSectors, qint32 cylinders, qint64 sectorSize, const QString& iconname) :
|
Device::Device(const QString& name,
|
||||||
QObject(),
|
const QString& devicenode,
|
||||||
m_Name(name.length() > 0 ? name : i18n("Unknown Device")),
|
const qint32 logicalSize,
|
||||||
m_DeviceNode(devicenode),
|
const qint64 totalLogical,
|
||||||
m_PartitionTable(nullptr),
|
const QString& iconname,
|
||||||
m_Heads(heads),
|
Device::Type type)
|
||||||
m_SectorsPerTrack(numSectors),
|
: QObject()
|
||||||
m_Cylinders(cylinders),
|
, m_Name(name.length() > 0 ? name : i18n("Unknown Device"))
|
||||||
m_LogicalSectorSize(sectorSize),
|
, m_DeviceNode(devicenode)
|
||||||
m_PhysicalSectorSize(getPhysicalSectorSize(devicenode)),
|
, m_LogicalSize(logicalSize)
|
||||||
m_IconName(iconname.isEmpty() ? QStringLiteral("drive-harddisk") : iconname),
|
, m_TotalLogical(totalLogical)
|
||||||
m_SmartStatus(new SmartStatus(devicenode))
|
, m_PartitionTable(nullptr)
|
||||||
|
, m_IconName(iconname.isEmpty() ? QStringLiteral("drive-harddisk") : iconname)
|
||||||
|
, m_SmartStatus(new SmartStatus(devicenode))
|
||||||
|
, m_Type(type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ class CreatePartitionTableOperation;
|
||||||
class CoreBackend;
|
class CoreBackend;
|
||||||
class SmartStatus;
|
class SmartStatus;
|
||||||
|
|
||||||
/** A device.
|
/** A abstract device interface.
|
||||||
|
|
||||||
Represents a device like /dev/sda.
|
Represents a device like /dev/sda.
|
||||||
|
|
||||||
|
@ -47,81 +47,81 @@ class LIBKPMCORE_EXPORT Device : public QObject
|
||||||
friend class CoreBackend;
|
friend class CoreBackend;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Device(const QString& name, const QString& devicenode, qint32 heads, qint32 numSectors, qint32 cylinders, qint64 sectorSize, const QString& iconname = QString());
|
enum Type {
|
||||||
~Device();
|
Disk_Device = 0,
|
||||||
|
LVM_Device = 1, /* VG */
|
||||||
|
RAID_Device = 2, /* software RAID device */
|
||||||
|
Unknown_Device = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Device(const QString& name, const QString& devicenode, const qint32 logicalSize, const qint64 totalLogical, const QString& iconname = QString(), Device::Type type = Device::Disk_Device);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool operator==(const Device& other) const;
|
virtual ~Device();
|
||||||
bool operator!=(const Device& other) const;
|
|
||||||
|
|
||||||
const QString& name() const {
|
public:
|
||||||
|
virtual bool operator==(const Device& other) const;
|
||||||
|
virtual bool operator!=(const Device& other) const;
|
||||||
|
|
||||||
|
virtual const QString& name() const {
|
||||||
return m_Name; /**< @return the Device's name, usually some manufacturer string */
|
return m_Name; /**< @return the Device's name, usually some manufacturer string */
|
||||||
}
|
}
|
||||||
const QString& deviceNode() const {
|
virtual const QString& deviceNode() const {
|
||||||
return m_DeviceNode; /**< @return the Device's node, for example "/dev/sda" */
|
return m_DeviceNode; /**< @return the Device's node, for example "/dev/sda" */
|
||||||
}
|
}
|
||||||
PartitionTable* partitionTable() {
|
|
||||||
|
virtual PartitionTable* partitionTable() {
|
||||||
return m_PartitionTable; /**< @return the Device's PartitionTable */
|
return m_PartitionTable; /**< @return the Device's PartitionTable */
|
||||||
}
|
}
|
||||||
const PartitionTable* partitionTable() const {
|
virtual const PartitionTable* partitionTable() const {
|
||||||
return m_PartitionTable; /**< @return the Device's PartitionTable */
|
return m_PartitionTable; /**< @return the Device's PartitionTable */
|
||||||
}
|
}
|
||||||
qint32 heads() const {
|
|
||||||
return m_Heads; /**< @return the number of heads on the Device in CHS notation */
|
|
||||||
}
|
|
||||||
qint32 cylinders() const {
|
|
||||||
return m_Cylinders; /**< @return the number of cylinders on the Device in CHS notation */
|
|
||||||
}
|
|
||||||
qint32 sectorsPerTrack() const {
|
|
||||||
return m_SectorsPerTrack; /**< @return the number of sectors on the Device in CHS notation */
|
|
||||||
}
|
|
||||||
qint32 physicalSectorSize() const {
|
|
||||||
return m_PhysicalSectorSize; /**< @return the physical sector size the Device uses or -1 if unknown */
|
|
||||||
}
|
|
||||||
qint32 logicalSectorSize() const {
|
|
||||||
return m_LogicalSectorSize; /**< @return the logical sector size the Device uses */
|
|
||||||
}
|
|
||||||
qint64 totalSectors() const {
|
|
||||||
return static_cast<qint64>(heads()) * cylinders() * sectorsPerTrack(); /**< @return the total number of sectors on the device */
|
|
||||||
}
|
|
||||||
qint64 capacity() const {
|
|
||||||
return totalSectors() * logicalSectorSize(); /**< @return the Device's capacity in bytes */
|
|
||||||
}
|
|
||||||
qint64 cylinderSize() const {
|
|
||||||
return static_cast<qint64>(heads()) * sectorsPerTrack(); /**< @return the size of a cylinder on this Device in sectors */
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIconName(const QString& name) {
|
virtual qint64 capacity() const { /**< @return the Device's capacity in bytes */
|
||||||
|
return logicalSize() * totalLogical();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void setIconName(const QString& name) {
|
||||||
m_IconName = name;
|
m_IconName = name;
|
||||||
}
|
}
|
||||||
const QString& iconName() const {
|
virtual const QString& iconName() const {
|
||||||
return m_IconName; /**< @return suggested icon name for this Device */
|
return m_IconName; /**< @return suggested icon name for this Device */
|
||||||
}
|
}
|
||||||
|
|
||||||
SmartStatus& smartStatus() {
|
virtual SmartStatus& smartStatus() {
|
||||||
return *m_SmartStatus;
|
return *m_SmartStatus;
|
||||||
}
|
}
|
||||||
const SmartStatus& smartStatus() const {
|
virtual const SmartStatus& smartStatus() const {
|
||||||
return *m_SmartStatus;
|
return *m_SmartStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString prettyName() const;
|
virtual void setPartitionTable(PartitionTable* ptable) {
|
||||||
|
|
||||||
void setPartitionTable(PartitionTable* ptable) {
|
|
||||||
m_PartitionTable = ptable;
|
m_PartitionTable = ptable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
virtual qint32 logicalSize() const {
|
||||||
|
return m_LogicalSize;
|
||||||
|
}
|
||||||
|
virtual qint64 totalLogical() const {
|
||||||
|
return m_TotalLogical;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual Device::Type type() const {
|
||||||
|
return m_Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual QString prettyName() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
QString m_Name;
|
QString m_Name;
|
||||||
QString m_DeviceNode;
|
QString m_DeviceNode;
|
||||||
|
qint32 m_LogicalSize;
|
||||||
|
qint32 m_TotalLogical;
|
||||||
PartitionTable* m_PartitionTable;
|
PartitionTable* m_PartitionTable;
|
||||||
qint32 m_Heads;
|
|
||||||
qint32 m_SectorsPerTrack;
|
|
||||||
qint32 m_Cylinders;
|
|
||||||
qint32 m_LogicalSectorSize;
|
|
||||||
qint32 m_PhysicalSectorSize;
|
|
||||||
QString m_IconName;
|
QString m_IconName;
|
||||||
SmartStatus* m_SmartStatus;
|
SmartStatus* m_SmartStatus;
|
||||||
|
Device::Type m_Type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,6 +57,7 @@ void DeviceScanner::scan()
|
||||||
clear();
|
clear();
|
||||||
|
|
||||||
QList<Device*> deviceList = CoreBackendManager::self()->backend()->scanDevices();
|
QList<Device*> deviceList = CoreBackendManager::self()->backend()->scanDevices();
|
||||||
|
//TODO: Scan for LVM here and add to the list.
|
||||||
|
|
||||||
foreach(Device * d, deviceList)
|
foreach(Device * d, deviceList)
|
||||||
operationStack().addDevice(d);
|
operationStack().addDevice(d);
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
/*************************************************************************
|
||||||
|
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||||
|
* Copyright (C) 2016 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 "core/diskdevice.h"
|
||||||
|
|
||||||
|
#include "core/partitiontable.h"
|
||||||
|
#include "core/smartstatus.h"
|
||||||
|
|
||||||
|
#include <KLocalizedString>
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QByteArray>
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <linux/fs.h>
|
||||||
|
|
||||||
|
#if !defined(BLKPBSZGET)
|
||||||
|
#define BLKPBSZGET _IO(0x12,123)/* get block physical sector size */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static qint32 getPhysicalSectorSize(const QString& device_node)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* possible ways of getting the physical sector size for a drive:
|
||||||
|
* - ioctl(BLKPBSZGET) -- supported with Linux 2.6.32 and later
|
||||||
|
* - /sys/block/sda/queue/physical_block_size
|
||||||
|
* - libblkid from util-linux-ng 2.17 or later
|
||||||
|
* TODO: implement the blkid method
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(BLKPBSZGET)
|
||||||
|
int phSectorSize = -1;
|
||||||
|
int fd = open(device_node.toLocal8Bit().constData(), O_RDONLY);
|
||||||
|
if (fd != -1) {
|
||||||
|
if (ioctl(fd, BLKPBSZGET, &phSectorSize) >= 0) {
|
||||||
|
close(fd);
|
||||||
|
return phSectorSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
QFile f(QStringLiteral("/sys/block/%1/queue/physical_block_size").arg(QString(device_node).remove(QStringLiteral("/dev/"))));
|
||||||
|
|
||||||
|
if (f.open(QIODevice::ReadOnly)) {
|
||||||
|
QByteArray a = f.readLine();
|
||||||
|
return a.trimmed().toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Constructs a Disk Device with an empty PartitionTable.
|
||||||
|
@param name the Device's name, usually some string defined by the manufacturer
|
||||||
|
@param devicenode the Device's node, for example "/dev/sda"
|
||||||
|
@param heads the number of heads in CHS notation
|
||||||
|
@param numSectors the number of sectors in CHS notation
|
||||||
|
@param cylinders the number of cylinders in CHS notation
|
||||||
|
@param sectorSize the size of a sector in bytes
|
||||||
|
*/
|
||||||
|
DiskDevice::DiskDevice(const QString& name,
|
||||||
|
const QString& devicenode,
|
||||||
|
qint32 heads,
|
||||||
|
qint32 numSectors,
|
||||||
|
qint32 cylinders,
|
||||||
|
qint32 sectorSize,
|
||||||
|
const QString& iconname)
|
||||||
|
: Device(name, devicenode, sectorSize, (static_cast<qint64>(heads) * cylinders * numSectors), iconname, Device::Disk_Device)
|
||||||
|
, m_Heads(heads)
|
||||||
|
, m_SectorsPerTrack(numSectors)
|
||||||
|
, m_Cylinders(cylinders)
|
||||||
|
, m_LogicalSectorSize(sectorSize)
|
||||||
|
, m_PhysicalSectorSize(getPhysicalSectorSize(devicenode))
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
/*************************************************************************
|
||||||
|
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
|
||||||
|
* *
|
||||||
|
* 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(DISKDEVICE__H)
|
||||||
|
|
||||||
|
#define DISKDEVICE__H
|
||||||
|
|
||||||
|
#include "util/libpartitionmanagerexport.h"
|
||||||
|
#include "core/device.h"
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
class PartitionTable;
|
||||||
|
class CreatePartitionTableOperation;
|
||||||
|
class CoreBackend;
|
||||||
|
class SmartStatus;
|
||||||
|
|
||||||
|
/** A disk device.
|
||||||
|
|
||||||
|
Represents a device like /dev/sda.
|
||||||
|
|
||||||
|
Devices are the outermost entity; they contain a PartitionTable that itself contains Partitions.
|
||||||
|
|
||||||
|
@see PartitionTable, Partition
|
||||||
|
@author Volker Lanz <vl@fidra.de>
|
||||||
|
*/
|
||||||
|
class LIBKPMCORE_EXPORT DiskDevice : public Device
|
||||||
|
{
|
||||||
|
Q_DISABLE_COPY(DiskDevice)
|
||||||
|
|
||||||
|
friend class CreatePartitionTableOperation;
|
||||||
|
friend class CoreBackend;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DiskDevice(const QString& name, const QString& devicenode, qint32 heads, qint32 numSectors, qint32 cylinders, qint32 sectorSize, const QString& iconname = QString());
|
||||||
|
|
||||||
|
public:
|
||||||
|
qint32 heads() const {
|
||||||
|
return m_Heads; /**< @return the number of heads on the Device in CHS notation */
|
||||||
|
}
|
||||||
|
qint32 cylinders() const {
|
||||||
|
return m_Cylinders; /**< @return the number of cylinders on the Device in CHS notation */
|
||||||
|
}
|
||||||
|
qint32 sectorsPerTrack() const {
|
||||||
|
return m_SectorsPerTrack; /**< @return the number of sectors on the Device in CHS notation */
|
||||||
|
}
|
||||||
|
qint32 physicalSectorSize() const {
|
||||||
|
return m_PhysicalSectorSize; /**< @return the physical sector size the Device uses or -1 if unknown */
|
||||||
|
}
|
||||||
|
qint32 logicalSectorSize() const {
|
||||||
|
return m_LogicalSectorSize; /**< @return the logical sector size the Device uses */
|
||||||
|
}
|
||||||
|
qint64 totalSectors() const {
|
||||||
|
return static_cast<qint64>(heads()) * cylinders() * sectorsPerTrack(); /**< @return the total number of sectors on the device */
|
||||||
|
}
|
||||||
|
qint64 cylinderSize() const {
|
||||||
|
return static_cast<qint64>(heads()) * sectorsPerTrack(); /**< @return the size of a cylinder on this Device in sectors */
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
qint32 m_Heads;
|
||||||
|
qint32 m_SectorsPerTrack;
|
||||||
|
qint32 m_Cylinders;
|
||||||
|
qint32 m_LogicalSectorSize;
|
||||||
|
qint32 m_PhysicalSectorSize;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -62,11 +62,11 @@ Partition::Partition(PartitionNode* parent, const Device& device, const Partitio
|
||||||
m_AvailableFlags(availableFlags),
|
m_AvailableFlags(availableFlags),
|
||||||
m_ActiveFlags(activeFlags),
|
m_ActiveFlags(activeFlags),
|
||||||
m_IsMounted(mounted),
|
m_IsMounted(mounted),
|
||||||
m_SectorSize(device.logicalSectorSize()),
|
|
||||||
m_State(state)
|
m_State(state)
|
||||||
{
|
{
|
||||||
setPartitionPath(partitionPath);
|
setPartitionPath(partitionPath);
|
||||||
Q_ASSERT(m_Parent);
|
Q_ASSERT(m_Parent);
|
||||||
|
m_SectorSize = device.logicalSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Destroys a Partition, destroying its children and its FileSystem */
|
/** Destroys a Partition, destroying its children and its FileSystem */
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "core/partition.h"
|
#include "core/partition.h"
|
||||||
#include "core/partitiontable.h"
|
#include "core/partitiontable.h"
|
||||||
#include "core/device.h"
|
#include "core/device.h"
|
||||||
|
#include "core/diskdevice.h"
|
||||||
|
|
||||||
#include "fs/filesystem.h"
|
#include "fs/filesystem.h"
|
||||||
|
|
||||||
|
@ -32,12 +33,14 @@ int PartitionAlignment::s_sectorAlignment = 2048;
|
||||||
|
|
||||||
qint64 PartitionAlignment::firstDelta(const Device& d, const Partition& p, qint64 s)
|
qint64 PartitionAlignment::firstDelta(const Device& d, const Partition& p, qint64 s)
|
||||||
{
|
{
|
||||||
|
//TODO: make sure things work for LVM
|
||||||
if (d.partitionTable()->type() == PartitionTable::msdos) {
|
if (d.partitionTable()->type() == PartitionTable::msdos) {
|
||||||
if (p.roles().has(PartitionRole::Logical) && s == 2 * d.sectorsPerTrack())
|
const DiskDevice& diskDevice = dynamic_cast<const DiskDevice&>(d);
|
||||||
return (s - (2 * d.sectorsPerTrack())) % sectorAlignment(d);
|
if (p.roles().has(PartitionRole::Logical) && s == 2 * diskDevice.sectorsPerTrack())
|
||||||
|
return (s - (2 * diskDevice.sectorsPerTrack())) % sectorAlignment(d);
|
||||||
|
|
||||||
if (p.roles().has(PartitionRole::Logical) || s == d.sectorsPerTrack())
|
if (p.roles().has(PartitionRole::Logical) || s == diskDevice.sectorsPerTrack())
|
||||||
return (s - d.sectorsPerTrack()) % sectorAlignment(d);
|
return (s - diskDevice.sectorsPerTrack()) % sectorAlignment(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
return s % sectorAlignment(d);
|
return s % sectorAlignment(d);
|
||||||
|
@ -50,12 +53,14 @@ qint64 PartitionAlignment::lastDelta(const Device& d, const Partition&, qint64 s
|
||||||
|
|
||||||
bool PartitionAlignment::isLengthAligned(const Device& d, const Partition& p)
|
bool PartitionAlignment::isLengthAligned(const Device& d, const Partition& p)
|
||||||
{
|
{
|
||||||
|
//TODO: make sure things work for LVM
|
||||||
if (d.partitionTable()->type() == PartitionTable::msdos) {
|
if (d.partitionTable()->type() == PartitionTable::msdos) {
|
||||||
if (p.roles().has(PartitionRole::Logical) && p.firstSector() == 2 * d.sectorsPerTrack())
|
const DiskDevice& diskDevice = dynamic_cast<const DiskDevice&>(d);
|
||||||
return (p.length() + (2 * d.sectorsPerTrack())) % sectorAlignment(d) == 0;
|
if (p.roles().has(PartitionRole::Logical) && p.firstSector() == 2 * diskDevice.sectorsPerTrack())
|
||||||
|
return (p.length() + (2 * diskDevice.sectorsPerTrack())) % sectorAlignment(d) == 0;
|
||||||
|
|
||||||
if (p.roles().has(PartitionRole::Logical) || p.firstSector() == d.sectorsPerTrack())
|
if (p.roles().has(PartitionRole::Logical) || p.firstSector() == diskDevice.sectorsPerTrack())
|
||||||
return (p.length() + d.sectorsPerTrack()) % sectorAlignment(d) == 0;
|
return (p.length() + diskDevice.sectorsPerTrack()) % sectorAlignment(d) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return p.length() % sectorAlignment(d) == 0;
|
return p.length() % sectorAlignment(d) == 0;
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
Logical = 4, /**< Logical inside an extended */
|
Logical = 4, /**< Logical inside an extended */
|
||||||
Unallocated = 8, /**< No real Partition, just unallocated space */
|
Unallocated = 8, /**< No real Partition, just unallocated space */
|
||||||
Luks = 16, /**< Encrypted partition with LUKS key management */
|
Luks = 16, /**< Encrypted partition with LUKS key management */
|
||||||
|
Lvm_Lv = 32, /**< Logical Volume of LVM */
|
||||||
|
|
||||||
Any = 255 /**< In case we're looking for a Partition with a PartitionRole, any will do */
|
Any = 255 /**< In case we're looking for a Partition with a PartitionRole, any will do */
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
#include "core/partitiontable.h"
|
#include "core/partitiontable.h"
|
||||||
#include "core/partition.h"
|
#include "core/partition.h"
|
||||||
#include "core/device.h"
|
#include "core/device.h"
|
||||||
|
#include "core/diskdevice.h"
|
||||||
#include "core/partitionalignment.h"
|
#include "core/partitionalignment.h"
|
||||||
|
|
||||||
#include "fs/filesystem.h"
|
#include "fs/filesystem.h"
|
||||||
#include "fs/filesystemfactory.h"
|
#include "fs/filesystemfactory.h"
|
||||||
|
|
||||||
|
@ -240,29 +240,38 @@ QStringList PartitionTable::flagNames(Flags flags)
|
||||||
return rval;
|
return rval;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PartitionTable::getUnallocatedRange(const Device& device, PartitionNode& parent, qint64& start, qint64& end)
|
bool PartitionTable::getUnallocatedRange(const Device& d, PartitionNode& parent, qint64& start, qint64& end)
|
||||||
{
|
{
|
||||||
if (!parent.isRoot()) {
|
//TODO: alignment for LVM device
|
||||||
Partition* extended = dynamic_cast<Partition*>(&parent);
|
if (d.type() == Device::Disk_Device) {
|
||||||
|
const DiskDevice& device = dynamic_cast<const DiskDevice&>(d);
|
||||||
|
if (!parent.isRoot()) {
|
||||||
|
Partition* extended = dynamic_cast<Partition*>(&parent);
|
||||||
|
|
||||||
if (extended == nullptr) {
|
if (extended == nullptr) {
|
||||||
qWarning() << "extended is null. start: " << start << ", end: " << end << ", device: " << device.deviceNode();
|
qWarning() << "extended is null. start: " << start << ", end: " << end << ", device: " << device.deviceNode();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Leave a track (cylinder aligned) or sector alignment sectors (sector based) free at the
|
||||||
|
// start for a new partition's metadata
|
||||||
|
start += device.partitionTable()->type() == PartitionTable::msdos ? device.sectorsPerTrack() : PartitionAlignment::sectorAlignment(device);
|
||||||
|
|
||||||
|
// .. and also at the end for the metadata for a partition to follow us, if we're not
|
||||||
|
// at the end of the extended partition
|
||||||
|
if (end < extended->lastSector())
|
||||||
|
end -= device.partitionTable()->type() == PartitionTable::msdos ? device.sectorsPerTrack() : PartitionAlignment::sectorAlignment(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Leave a track (cylinder aligned) or sector alignment sectors (sector based) free at the
|
return end - start + 1 >= PartitionAlignment::sectorAlignment(device);
|
||||||
// start for a new partition's metadata
|
} else if (d.type() == Device::LVM_Device) {
|
||||||
start += device.partitionTable()->type() == PartitionTable::msdos ? device.sectorsPerTrack() : PartitionAlignment::sectorAlignment(device);
|
return false;
|
||||||
|
|
||||||
// .. and also at the end for the metadata for a partition to follow us, if we're not
|
|
||||||
// at the end of the extended partition
|
|
||||||
if (end < extended->lastSector())
|
|
||||||
end -= device.partitionTable()->type() == PartitionTable::msdos ? device.sectorsPerTrack() : PartitionAlignment::sectorAlignment(device);
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
return end - start + 1 >= PartitionAlignment::sectorAlignment(device);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** Creates a new unallocated Partition on the given Device.
|
/** Creates a new unallocated Partition on the given Device.
|
||||||
@param device the Device to create the new Partition on
|
@param device the Device to create the new Partition on
|
||||||
@param parent the parent PartitionNode for the new Partition
|
@param parent the parent PartitionNode for the new Partition
|
||||||
|
@ -369,15 +378,16 @@ void PartitionTable::updateUnallocated(const Device& d)
|
||||||
qint64 PartitionTable::defaultFirstUsable(const Device& d, TableType t)
|
qint64 PartitionTable::defaultFirstUsable(const Device& d, TableType t)
|
||||||
{
|
{
|
||||||
Q_UNUSED(t)
|
Q_UNUSED(t)
|
||||||
return PartitionAlignment::sectorAlignment(d);
|
const DiskDevice& diskDevice = dynamic_cast<const DiskDevice&>(d);
|
||||||
|
return PartitionAlignment::sectorAlignment(diskDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 PartitionTable::defaultLastUsable(const Device& d, TableType t)
|
qint64 PartitionTable::defaultLastUsable(const Device& d, TableType t)
|
||||||
{
|
{
|
||||||
if (t == gpt)
|
if (t == gpt)
|
||||||
return d.totalSectors() - 1 - 32 - 1;
|
return d.totalLogical() - 1 - 32 - 1;
|
||||||
|
|
||||||
return d.totalSectors() - 1;
|
return d.totalLogical() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
@ -452,26 +462,31 @@ bool PartitionTable::tableTypeIsReadOnly(TableType l)
|
||||||
*/
|
*/
|
||||||
bool PartitionTable::isSectorBased(const Device& d) const
|
bool PartitionTable::isSectorBased(const Device& d) const
|
||||||
{
|
{
|
||||||
if (type() == PartitionTable::msdos) {
|
if (d.type() == Device::Disk_Device) {
|
||||||
// the default for empty partition tables is sector based
|
const DiskDevice& diskDevice = dynamic_cast<const DiskDevice&>(d);
|
||||||
if (numPrimaries() == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
quint32 numCylinderAligned = 0;
|
if (type() == PartitionTable::msdos) {
|
||||||
quint32 numSectorAligned = 0;
|
// the default for empty partition tables is sector based
|
||||||
|
if (numPrimaries() == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
// see if we have more cylinder aligned partitions than sector
|
quint32 numCylinderAligned = 0;
|
||||||
// aligned ones.
|
quint32 numSectorAligned = 0;
|
||||||
foreach(const Partition * p, children())
|
|
||||||
if (p->firstSector() % PartitionAlignment::sectorAlignment(d) == 0)
|
// see if we have more cylinder aligned partitions than sector
|
||||||
|
// aligned ones.
|
||||||
|
foreach(const Partition * p, children())
|
||||||
|
if (p->firstSector() % PartitionAlignment::sectorAlignment(diskDevice) == 0)
|
||||||
numSectorAligned++;
|
numSectorAligned++;
|
||||||
else if (p->firstSector() % d.cylinderSize() == 0)
|
else if (p->firstSector() % diskDevice.cylinderSize() == 0)
|
||||||
numCylinderAligned++;
|
numCylinderAligned++;
|
||||||
|
|
||||||
return numSectorAligned >= numCylinderAligned;
|
return numSectorAligned >= numCylinderAligned;
|
||||||
|
}
|
||||||
|
return type() == PartitionTable::msdos_sectorbased;
|
||||||
}
|
}
|
||||||
|
|
||||||
return type() == PartitionTable::msdos_sectorbased;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PartitionTable::setType(const Device& d, TableType t)
|
void PartitionTable::setType(const Device& d, TableType t)
|
||||||
|
|
|
@ -64,7 +64,8 @@ public:
|
||||||
mac,
|
mac,
|
||||||
pc98,
|
pc98,
|
||||||
amiga,
|
amiga,
|
||||||
sun
|
sun,
|
||||||
|
vmd /* Volume Manager Device */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Partition flags */
|
/** Partition flags */
|
||||||
|
|
|
@ -57,7 +57,7 @@ bool BackupFileSystemJob::run(Report& parent)
|
||||||
rval = sourcePartition().fileSystem().backup(*report, sourceDevice(), sourcePartition().deviceNode(), fileName());
|
rval = sourcePartition().fileSystem().backup(*report, sourceDevice(), sourcePartition().deviceNode(), fileName());
|
||||||
else if (sourcePartition().fileSystem().supportBackup() == FileSystem::cmdSupportCore) {
|
else if (sourcePartition().fileSystem().supportBackup() == FileSystem::cmdSupportCore) {
|
||||||
CopySourceDevice copySource(sourceDevice(), sourcePartition().fileSystem().firstSector(), sourcePartition().fileSystem().lastSector());
|
CopySourceDevice copySource(sourceDevice(), sourcePartition().fileSystem().firstSector(), sourcePartition().fileSystem().lastSector());
|
||||||
CopyTargetFile copyTarget(fileName(), sourceDevice().logicalSectorSize());
|
CopyTargetFile copyTarget(fileName(), sourceDevice().logicalSize());
|
||||||
|
|
||||||
if (!copySource.open())
|
if (!copySource.open())
|
||||||
report->line() << xi18nc("@info:progress", "Could not open file system on source partition <filename>%1</filename> for backup.", sourcePartition().deviceNode());
|
report->line() << xi18nc("@info:progress", "Could not open file system on source partition <filename>%1</filename> for backup.", sourcePartition().deviceNode());
|
||||||
|
|
|
@ -49,29 +49,33 @@ bool CreatePartitionJob::run(Report& parent)
|
||||||
|
|
||||||
Report* report = jobStarted(parent);
|
Report* report = jobStarted(parent);
|
||||||
|
|
||||||
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
|
if (device().type() == Device::Disk_Device) {
|
||||||
|
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
|
||||||
|
|
||||||
if (backendDevice) {
|
if (backendDevice) {
|
||||||
CoreBackendPartitionTable* backendPartitionTable = backendDevice->openPartitionTable();
|
CoreBackendPartitionTable* backendPartitionTable = backendDevice->openPartitionTable();
|
||||||
|
|
||||||
if (backendPartitionTable) {
|
if (backendPartitionTable) {
|
||||||
QString partitionPath = backendPartitionTable->createPartition(*report, partition());
|
QString partitionPath = backendPartitionTable->createPartition(*report, partition());
|
||||||
|
|
||||||
if (partitionPath != QString()) {
|
if (partitionPath != QString()) {
|
||||||
rval = true;
|
rval = true;
|
||||||
partition().setPartitionPath(partitionPath);
|
partition().setPartitionPath(partitionPath);
|
||||||
partition().setState(Partition::StateNone);
|
partition().setState(Partition::StateNone);
|
||||||
backendPartitionTable->commit();
|
backendPartitionTable->commit();
|
||||||
|
} else
|
||||||
|
report->line() << xi18nc("@info/plain", "Failed to add partition <filename>%1</filename> to device <filename>%2</filename>.", partition().deviceNode(), device().deviceNode());
|
||||||
|
|
||||||
|
delete backendPartitionTable;
|
||||||
} else
|
} else
|
||||||
report->line() << xi18nc("@info:progress", "Failed to add partition <filename>%1</filename> to device <filename>%2</filename>.", partition().deviceNode(), device().deviceNode());
|
report->line() << xi18nc("@info:progress", "Could not open partition table on device <filename>%1</filename> to create new partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode());
|
||||||
|
|
||||||
delete backendPartitionTable;
|
delete backendDevice;
|
||||||
} else
|
} else
|
||||||
report->line() << xi18nc("@info:progress", "Could not open partition table on device <filename>%1</filename> to create new partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode());
|
report->line() << xi18nc("@info:progress", "Could not open device <filename>%1</filename> to create new partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode());
|
||||||
|
} else if (device().type() == Device::LVM_Device) {
|
||||||
|
|
||||||
delete backendDevice;
|
}
|
||||||
} else
|
|
||||||
report->line() << xi18nc("@info:progress", "Could not open device <filename>%1</filename> to create new partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode());
|
|
||||||
|
|
||||||
jobFinished(*report, rval);
|
jobFinished(*report, rval);
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ bool ResizeFileSystemJob::run(Report& parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
case FileSystem::cmdSupportFileSystem: {
|
case FileSystem::cmdSupportFileSystem: {
|
||||||
const qint64 newLengthInByte = Capacity(newLength() * device().logicalSectorSize()).toInt(Capacity::Byte);
|
const qint64 newLengthInByte = Capacity(newLength() * device().logicalSize()).toInt(Capacity::Byte);
|
||||||
if (partition().isMounted())
|
if (partition().isMounted())
|
||||||
rval = partition().fileSystem().resizeOnline(*report, partition().deviceNode(), partition().mountPoint(), newLengthInByte);
|
rval = partition().fileSystem().resizeOnline(*report, partition().deviceNode(), partition().mountPoint(), newLengthInByte);
|
||||||
else
|
else
|
||||||
|
|
|
@ -211,7 +211,7 @@ QString CopyOperation::updateDescription() const
|
||||||
sourcePartition().deviceNode(),
|
sourcePartition().deviceNode(),
|
||||||
Capacity::formatByteSize(sourcePartition().capacity()),
|
Capacity::formatByteSize(sourcePartition().capacity()),
|
||||||
sourcePartition().fileSystem().name(),
|
sourcePartition().fileSystem().name(),
|
||||||
Capacity::formatByteSize(copiedPartition().firstSector() * targetDevice().logicalSectorSize()),
|
Capacity::formatByteSize(copiedPartition().firstSector() * targetDevice().logicalSize()),
|
||||||
targetDevice().deviceNode()
|
targetDevice().deviceNode()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ QString CopyOperation::updateDescription() const
|
||||||
sourcePartition().deviceNode(),
|
sourcePartition().deviceNode(),
|
||||||
Capacity::formatByteSize(sourcePartition().capacity()),
|
Capacity::formatByteSize(sourcePartition().capacity()),
|
||||||
sourcePartition().fileSystem().name(),
|
sourcePartition().fileSystem().name(),
|
||||||
Capacity::formatByteSize(copiedPartition().firstSector() * targetDevice().logicalSectorSize()),
|
Capacity::formatByteSize(copiedPartition().firstSector() * targetDevice().logicalSize()),
|
||||||
targetDevice().deviceNode(),
|
targetDevice().deviceNode(),
|
||||||
Capacity::formatByteSize(copiedPartition().capacity())
|
Capacity::formatByteSize(copiedPartition().capacity())
|
||||||
);
|
);
|
||||||
|
|
|
@ -199,10 +199,10 @@ QString ResizeOperation::description() const
|
||||||
// Each of these needs a different description. And for reasons of i18n, we cannot
|
// Each of these needs a different description. And for reasons of i18n, we cannot
|
||||||
// just concatenate strings together...
|
// just concatenate strings together...
|
||||||
|
|
||||||
const QString moveDelta = Capacity::formatByteSize(qAbs(newFirstSector() - origFirstSector()) * targetDevice().logicalSectorSize());
|
const QString moveDelta = Capacity::formatByteSize(qAbs(newFirstSector() - origFirstSector()) * targetDevice().logicalSize());
|
||||||
|
|
||||||
const QString origCapacity = Capacity::formatByteSize(origLength() * targetDevice().logicalSectorSize());
|
const QString origCapacity = Capacity::formatByteSize(origLength() * targetDevice().logicalSize());
|
||||||
const QString newCapacity = Capacity::formatByteSize(newLength() * targetDevice().logicalSectorSize());
|
const QString newCapacity = Capacity::formatByteSize(newLength() * targetDevice().logicalSize());
|
||||||
|
|
||||||
switch (resizeAction()) {
|
switch (resizeAction()) {
|
||||||
case MoveLeft:
|
case MoveLeft:
|
||||||
|
|
|
@ -164,7 +164,7 @@ QString RestoreOperation::description() const
|
||||||
if (overwrittenPartition())
|
if (overwrittenPartition())
|
||||||
return xi18nc("@info:status", "Restore partition from <filename>%1</filename> to <filename>%2</filename>", fileName(), overwrittenPartition()->deviceNode());
|
return xi18nc("@info:status", "Restore partition from <filename>%1</filename> to <filename>%2</filename>", fileName(), overwrittenPartition()->deviceNode());
|
||||||
|
|
||||||
return xi18nc("@info:status", "Restore partition on <filename>%1</filename> at %2 from <filename>%3</filename>", targetDevice().deviceNode(), Capacity::formatByteSize(restorePartition().firstSector() * targetDevice().logicalSectorSize()), fileName());
|
return xi18nc("@info:status", "Restore partition on <filename>%1</filename> at %2 from <filename>%3</filename>", targetDevice().deviceNode(), Capacity::formatByteSize(restorePartition().firstSector() * targetDevice().logicalSize()), fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RestoreOperation::setOverwrittenPartition(Partition* p)
|
void RestoreOperation::setOverwrittenPartition(Partition* p)
|
||||||
|
@ -222,7 +222,7 @@ Partition* RestoreOperation::createRestorePartition(const Device& device, Partit
|
||||||
if (!fileInfo.exists())
|
if (!fileInfo.exists())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const qint64 end = start + fileInfo.size() / device.logicalSectorSize() - 1;
|
const qint64 end = start + fileInfo.size() / device.logicalSize() - 1;
|
||||||
Partition* p = new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Unknown, start, end), start, end, QString());
|
Partition* p = new Partition(&parent, device, PartitionRole(r), FileSystemFactory::create(FileSystem::Unknown, start, end), start, end, QString());
|
||||||
|
|
||||||
p->setState(Partition::StateRestore);
|
p->setState(Partition::StateRestore);
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "plugins/dummy/dummybackend.h"
|
#include "plugins/dummy/dummybackend.h"
|
||||||
#include "plugins/dummy/dummydevice.h"
|
#include "plugins/dummy/dummydevice.h"
|
||||||
|
|
||||||
#include "core/device.h"
|
#include "core/diskdevice.h"
|
||||||
#include "core/partition.h"
|
#include "core/partition.h"
|
||||||
#include "core/partitiontable.h"
|
#include "core/partitiontable.h"
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ QList<Device*> DummyBackend::scanDevices(bool excludeLoop)
|
||||||
|
|
||||||
Device* DummyBackend::scanDevice(const QString& device_node)
|
Device* DummyBackend::scanDevice(const QString& device_node)
|
||||||
{
|
{
|
||||||
Device* d = new Device(QStringLiteral("Dummy Device"), QStringLiteral("/tmp") + device_node, 255, 30, 63, 512);
|
DiskDevice* d = new DiskDevice(QStringLiteral("Dummy Device"), QStringLiteral("/tmp") + device_node, 255, 30, 63, 512);
|
||||||
CoreBackend::setPartitionTableForDevice(*d, new PartitionTable(PartitionTable::msdos_sectorbased, 2048, d->totalSectors() - 2048));
|
CoreBackend::setPartitionTableForDevice(*d, new PartitionTable(PartitionTable::msdos_sectorbased, 2048, d->totalSectors() - 2048));
|
||||||
CoreBackend::setPartitionTableMaxPrimaries(*d->partitionTable(), 128);
|
CoreBackend::setPartitionTableMaxPrimaries(*d->partitionTable(), 128);
|
||||||
d->partitionTable()->updateUnallocated(*d);
|
d->partitionTable()->updateUnallocated(*d);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "plugins/libparted/libparteddevice.h"
|
#include "plugins/libparted/libparteddevice.h"
|
||||||
#include "plugins/libparted/pedflags.h"
|
#include "plugins/libparted/pedflags.h"
|
||||||
|
|
||||||
#include "core/device.h"
|
#include "core/diskdevice.h"
|
||||||
#include "core/partition.h"
|
#include "core/partition.h"
|
||||||
#include "core/partitiontable.h"
|
#include "core/partitiontable.h"
|
||||||
#include "core/partitionalignment.h"
|
#include "core/partitionalignment.h"
|
||||||
|
@ -99,7 +99,7 @@ static qint64 readSectorsUsedLibParted(const Partition& p)
|
||||||
@param p the Partition the FileSystem is on
|
@param p the Partition the FileSystem is on
|
||||||
@param mountPoint mount point of the partition in question
|
@param mountPoint mount point of the partition in question
|
||||||
*/
|
*/
|
||||||
static void readSectorsUsed(const Device& d, Partition& p, const QString& mountPoint)
|
static void readSectorsUsed(const DiskDevice& d, Partition& p, const QString& mountPoint)
|
||||||
{
|
{
|
||||||
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
|
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ Device* LibPartedBackend::scanDevice(const QString& deviceNode)
|
||||||
|
|
||||||
Log(Log::information) << xi18nc("@info:status", "Device found: %1", model);
|
Log(Log::information) << xi18nc("@info:status", "Device found: %1", model);
|
||||||
|
|
||||||
Device* d = new Device(model, path, heads, sectors, cylinders, sectorSize);
|
DiskDevice* d = new DiskDevice(model, path, heads, sectors, cylinders, sectorSize);
|
||||||
|
|
||||||
if (pedDiskError)
|
if (pedDiskError)
|
||||||
return d;
|
return d;
|
||||||
|
@ -277,7 +277,7 @@ Device* LibPartedBackend::scanDevice(const QString& deviceNode)
|
||||||
luksFs->setMounted(mounted);
|
luksFs->setMounted(mounted);
|
||||||
} else if (type == FileSystem::Lvm2_PV) {
|
} else if (type == FileSystem::Lvm2_PV) {
|
||||||
//TODO: adding PartitionRole
|
//TODO: adding PartitionRole
|
||||||
mountPoint = FS::lvm2_pv::getVGName(node);
|
mountPoint = FS::lvm2_pv::getVGName(partitionNode);
|
||||||
mounted = false;
|
mounted = false;
|
||||||
} else {
|
} else {
|
||||||
mountPoint = mountPoints.findByDevice(partitionNode) ?
|
mountPoint = mountPoints.findByDevice(partitionNode) ?
|
||||||
|
|
|
@ -38,7 +38,6 @@ class LibPartedPartitionTable;
|
||||||
class LibPartedPartition;
|
class LibPartedPartition;
|
||||||
class OperationStack;
|
class OperationStack;
|
||||||
|
|
||||||
class Device;
|
|
||||||
class KPluginFactory;
|
class KPluginFactory;
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue